OpenShot Audio Library | OpenShotAudio: juce_Result.cpp Source File

OpenShot Audio Library | OpenShotAudio 0.4.0

Loading...
Searching...
No Matches
juce_Result.cpp
1/*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - 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
23namespace juce
24{
25
26Result::Result() noexcept {}
27
28Result::Result (const String& message) noexcept
29 : errorMessage (message)
30{
31}
32
33Result::Result (const Result& other)
34 : errorMessage (other.errorMessage)
35{
36}
37
38Result& Result::operator= (const Result& other)
39{
40 errorMessage = other.errorMessage;
41 return *this;
42}
43
44Result::Result (Result&& other) noexcept
45 : errorMessage (std::move (other.errorMessage))
46{
47}
48
49Result& Result::operator= (Result&& other) noexcept
50{
51 errorMessage = std::move (other.errorMessage);
52 return *this;
53}
54
55bool Result::operator== (const Result& other) const noexcept
56{
57 return errorMessage == other.errorMessage;
58}
59
60bool Result::operator!= (const Result& other) const noexcept
61{
62 return errorMessage != other.errorMessage;
63}
64
65 Result Result::fail (const String& errorMessage) noexcept
66{
67 return Result (errorMessage.isEmpty() ? "Unknown Error" : errorMessage);
68}
69
70 const String& Result::getErrorMessage() const noexcept
71{
72 return errorMessage;
73}
74
75 bool Result::wasOk() const noexcept { return errorMessage.isEmpty(); }
76Result::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(); }
79
80} // namespace juce
juce::Result
Definition juce_Result.h:57
juce::String
Definition juce_String.h:53
juce::String::isEmpty
bool isEmpty() const noexcept
Definition juce_String.h:310