1 /* 2 ============================================================================== 3 4 This file is part of the JUCE library. 5 Copyright (c) 2020 - Raw Material Software Limited 6 7 JUCE is an open source library subject to commercial or open-source 8 licensing. 9 10 The code included in this file is provided under the terms of the ISC license 11 http://www.isc.org/downloads/software-support-policy/isc-license. Permission 12 To use, copy, modify, and/or distribute this software for any purpose with or 13 without fee is hereby granted provided that the above copyright notice and 14 this permission notice appear in all copies. 15 16 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER 17 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE 18 DISCLAIMED. 19 20 ============================================================================== 21 */ 22 23 namespace juce 24 { 25 Result()26Result::Result() noexcept {} 27 Result(const String & message)28Result::Result (const String& message) noexcept 29 : errorMessage (message) 30 { 31 } 32 Result(const Result & other)33Result::Result (const Result& other) 34 : errorMessage (other.errorMessage) 35 { 36 } 37 operator =(const Result & other)38Result& Result::operator= (const Result& other) 39 { 40 errorMessage = other.errorMessage; 41 return *this; 42 } 43 Result(Result && other)44Result::Result (Result&& other) noexcept 45 : errorMessage (std::move (other.errorMessage)) 46 { 47 } 48 operator =(Result && other)49Result& Result::operator= (Result&& other) noexcept 50 { 51 errorMessage = std::move (other.errorMessage); 52 return *this; 53 } 54 operator ==(const Result & other) const55bool Result::operator== (const Result& other) const noexcept 56 { 57 return errorMessage == other.errorMessage; 58 } 59 operator !=(const Result & other) const60bool Result::operator!= (const Result& other) const noexcept 61 { 62 return errorMessage != other.errorMessage; 63 } 64 fail(const String & errorMessage)65Result Result::fail (const String& errorMessage) noexcept 66 { 67 return Result (errorMessage.isEmpty() ? "Unknown Error" : errorMessage); 68 } 69 getErrorMessage() const70const String& Result::getErrorMessage() const noexcept 71 { 72 return errorMessage; 73 } 74 wasOk() const75bool Result::wasOk() const noexcept { return errorMessage.isEmpty(); } operator bool() const76Result::operator bool() const noexcept { return errorMessage.isEmpty(); } failed() const77bool Result::failed() const noexcept { return errorMessage.isNotEmpty(); } operator !() const78bool Result::operator!() const noexcept { return errorMessage.isNotEmpty(); } 79 80 } // namespace juce 81