LMMS
Loading...
Searching...
No Matches
Result.cpp
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#include "Result.h"
27
28namespace water {
29
31
32Result::Result (const std::string& message) noexcept
34{
35}
36
37Result::Result (const Result& other)
39{
40}
41
43{
45 return *this;
46}
47
48bool Result::operator== (const Result& other) const noexcept
49{
50 return errorMessage == other.errorMessage;
51}
52
53bool Result::operator!= (const Result& other) const noexcept
54{
55 return errorMessage != other.errorMessage;
56}
57
58Result Result::fail (const std::string& errorMessage) noexcept
59{
60 return Result (errorMessage.empty() ? "Unknown Error" : errorMessage);
61}
62
64{
65 return errorMessage;
66}
67
68bool Result::wasOk() const noexcept { return errorMessage.empty(); }
69Result::operator bool() const noexcept { return errorMessage.empty(); }
70bool Result::failed() const noexcept { return !errorMessage.empty(); }
71bool Result::operator!() const noexcept { return !errorMessage.empty(); }
72
73}
#define noexcept
Definition DistrhoDefines.h:72
static void message(int level, const char *fmt,...)
Definition adplugdb.cpp:120
bool operator!() const noexcept
Definition Result.cpp:71
const std::string & getErrorMessage() const noexcept
Definition Result.cpp:63
bool operator==(const Result &other) const noexcept
Definition Result.cpp:48
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
bool operator!=(const Result &other) const noexcept
Definition Result.cpp:53
Result & operator=(const Result &)
Definition Result.cpp:42
Result(const Result &)
Definition Result.cpp:37
Result() noexcept
Definition Result.cpp:30
Definition AudioSampleBuffer.h:33
#define const
Definition zconf.h:137