LMMS
Loading...
Searching...
No Matches
Result.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the Water library.
5 Copyright (c) 2016 ROLI Ltd.
6 Copyright (C) 2017-2022 Filipe Coelho <falktx@falktx.com>
7
8 Permission is granted to use this software under the terms of the ISC license
9 http://www.isc.org/downloads/software-support-policy/isc-license/
10
11 Permission to use, copy, modify, and/or distribute this software for any
12 purpose with or without fee is hereby granted, provided that the above
13 copyright notice and this permission notice appear in all copies.
14
15 THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH REGARD
16 TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
17 FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT,
18 OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
19 USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
20 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
21 OF THIS SOFTWARE.
22
23 ==============================================================================
24*/
25
26#ifndef WATER_RESULT_H_INCLUDED
27#define WATER_RESULT_H_INCLUDED
28
29#include "../water.h"
30
31#include <string>
32
33namespace water {
34
35//==============================================================================
63class Result
64{
65public:
66 //==============================================================================
68 static Result ok() noexcept { return Result(); }
69
74 static Result fail (const std::string& errorMessage) noexcept;
75
76 //==============================================================================
78 bool wasOk() const noexcept;
79
84 bool failed() const noexcept;
85
89 operator bool() const noexcept;
90
94 bool operator!() const noexcept;
95
100
101 //==============================================================================
103 Result& operator= (const Result&);
104
105 bool operator== (const Result& other) const noexcept;
106 bool operator!= (const Result& other) const noexcept;
107
108private:
110
111 // The default constructor is not for public use!
112 // Instead, use Result::ok() or Result::fail()
114 explicit Result (const std::string&) noexcept;
115
116 // These casts are private to prevent people trying to use the Result object in numeric contexts
117 operator int() const;
118 operator void*() const;
119};
120
121}
122
123#endif // WATER_RESULT_H_INCLUDED
#define noexcept
Definition DistrhoDefines.h:72
Result(const Result &)
Definition Result.cpp:37
Definition Result.h:64
static Result ok() noexcept
Definition Result.h:68
static Result fail(const std::string &errorMessage) noexcept
Definition Result.cpp:58
bool wasOk() const noexcept
Definition Result.cpp:68
std::string errorMessage
Definition Result.h:109
bool failed() const noexcept
Definition Result.cpp:70
Result(const Result &)
Definition Result.cpp:37
Result() noexcept
Definition Result.cpp:30
virtual void getErrorMessage(char *string)=0
Definition juce_Uuid.h:141
Definition AudioSampleBuffer.h:33
#define const
Definition zconf.h:137