Add remaining files
[juce-lv2.git] / juce / source / src / core / juce_Result.cpp
blobad86a3e65864ffcb037e5981705d91ec050fd6b8
1 /*
2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #include "juce_StandardHeader.h"
28 BEGIN_JUCE_NAMESPACE
30 #include "juce_Result.h"
33 //==============================================================================
34 Result::Result (const String& message) noexcept
35 : errorMessage (message)
39 Result::Result (const Result& other)
40 : errorMessage (other.errorMessage)
44 Result& Result::operator= (const Result& other)
46 errorMessage = other.errorMessage;
47 return *this;
50 bool Result::operator== (const Result& other) const noexcept
52 return errorMessage == other.errorMessage;
55 bool Result::operator!= (const Result& other) const noexcept
57 return errorMessage != other.errorMessage;
60 Result Result::ok() noexcept
62 return Result (String::empty);
65 Result Result::fail (const String& errorMessage) noexcept
67 return Result (errorMessage.isEmpty() ? "Unknown Error" : errorMessage);
70 const String& Result::getErrorMessage() const noexcept
72 return errorMessage;
75 bool Result::wasOk() const noexcept { return errorMessage.isEmpty(); }
76 Result::operator bool() const noexcept { return errorMessage.isEmpty(); }
77 bool Result::failed() const noexcept { return errorMessage.isNotEmpty(); }
78 bool Result::operator!() const noexcept { return errorMessage.isNotEmpty(); }
81 END_JUCE_NAMESPACE