cesium-native  0.41.0
Result.h
1 #pragma once
2 
3 #include <CesiumUtility/ErrorList.h>
4 #include <CesiumUtility/IntrusivePointer.h>
5 
6 #include <optional>
7 
8 namespace CesiumUtility {
9 
16 template <typename T> struct Result {
17  Result(T value_) noexcept : value(std::move(value_)), errors() {}
18 
19  Result(T value_, ErrorList errors_) noexcept
20  : value(std::move(value_)), errors(std::move(errors_)) {}
21 
22  Result(ErrorList errors_) noexcept : value(), errors(std::move(errors_)) {}
23 
31  std::optional<T> value;
32 
41 };
42 
49 template <typename T> struct Result<CesiumUtility::IntrusivePointer<T>> {
51  : pValue(std::move(pValue_)), errors() {}
52 
53  Result(CesiumUtility::IntrusivePointer<T> pValue_, ErrorList errors_) noexcept
54  : pValue(std::move(pValue_)), errors(std::move(errors_)) {}
55 
56  Result(ErrorList errors_) noexcept
57  : pValue(nullptr), errors(std::move(errors_)) {}
58 
67 
76 };
77 
84 template <typename T> using ResultPointer = Result<IntrusivePointer<T>>;
85 
86 } // namespace CesiumUtility
A smart pointer that calls addReference and releaseReference on the controlled object.
Utility classes for Cesium.
The container to store the error and warning list when loading a tile or glTF content.
Definition: ErrorList.h:17
CesiumUtility::IntrusivePointer< T > pValue
The value, if the operation succeeded to the point where it can provide one.
Definition: Result.h:66
ErrorList errors
The errors and warnings that occurred during the operation.
Definition: Result.h:75
Holds the result of an operation. If the operation succeeds, it will provide a value....
Definition: Result.h:16
ErrorList errors
The errors and warnings that occurred during the operation.
Definition: Result.h:40
std::optional< T > value
The value, if the operation succeeded to the point where it can provide one.
Definition: Result.h:31