27 ::new (&mResult) Type (inRHS.
mResult);
46 ::new (&mResult) Type (std::move(inRHS.mResult));
50 ::new (&mError)
String(std::move(inRHS.mError));
68 mState = inRHS.mState;
73 ::new (&mResult) Type (inRHS.
mResult);
92 mState = inRHS.mState;
97 ::new (&mResult) Type (std::move(inRHS.mResult));
101 ::new (&mError)
String(std::move(inRHS.mError));
104 case EState::Invalid:
126 case EState::Invalid:
130 mState = EState::Invalid;
134 bool IsEmpty()
const {
return mState == EState::Invalid; }
137 bool IsValid()
const {
return mState == EState::Valid; }
143 void Set(
const Type &inResult) { Clear(); ::new (&mResult) Type(inResult); mState = EState::Valid; }
146 void Set(Type &&inResult) { Clear(); ::new (&mResult) Type(std::move(inResult)); mState = EState::Valid; }
149 bool HasError()
const {
return mState == EState::Error; }
155 void SetError(
const char *inError) { Clear(); ::new (&mError)
String(inError); mState = EState::Error; }
156 void SetError(
const string_view &inError) { Clear(); ::new (&mError)
String(inError); mState = EState::Error; }
157 void SetError(
String &&inError) { Clear(); ::new (&mError)
String(std::move(inError)); mState = EState::Error; }
167 enum class EState :
uint8
174 EState mState = EState::Invalid;
std::uint8_t uint8
Definition: Core.h:440
#define JPH_GCC_SUPPRESS_WARNING(w)
Definition: Core.h:264
#define JPH_NAMESPACE_END
Definition: Core.h:367
#define JPH_NAMESPACE_BEGIN
Definition: Core.h:361
#define JPH_ASSERT(...)
Definition: IssueReporting.h:33
std::basic_string< char, std::char_traits< char >, STLAllocator< char > > String
Definition: STLAllocator.h:82
@ Invalid
Next token on the stream was not a valid data type.
Helper class that either contains a valid result or an error.
Definition: Result.h:15
bool IsValid() const
Checks if the result is valid.
Definition: Result.h:137
void SetError(String &&inError)
Definition: Result.h:157
Result(const Result< Type > &inRHS)
Copy constructor.
Definition: Result.h:21
void Clear()
Clear result or error.
Definition: Result.h:114
void SetError(const char *inError)
Set an error value.
Definition: Result.h:155
Type mResult
The actual result object.
Definition: Result.h:162
void Set(const Type &inResult)
Set the result value.
Definition: Result.h:143
bool HasError() const
Check if we had an error.
Definition: Result.h:149
void Set(Type &&inResult)
Set the result value (move value)
Definition: Result.h:146
const String & GetError() const
Get the error value.
Definition: Result.h:152
Result()
Default constructor.
Definition: Result.h:18
bool IsEmpty() const
Checks if the result is still uninitialized.
Definition: Result.h:134
const Type & Get() const
Get the result value.
Definition: Result.h:140
~Result()
Destructor.
Definition: Result.h:61
void SetError(const string_view &inError)
Definition: Result.h:156
Result(Result< Type > &&inRHS) noexcept
Move constructor.
Definition: Result.h:40
String mError
The error description if the result failed.
Definition: Result.h:163