simdjson  3.11.0
Ridiculously Fast JSON
implementation_simdjson_result_base.h
1 #ifndef SIMDJSON_GENERIC_IMPLEMENTATION_SIMDJSON_RESULT_BASE_H
2 
3 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
4 #define SIMDJSON_GENERIC_IMPLEMENTATION_SIMDJSON_RESULT_BASE_H
5 #include "simdjson/generic/base.h"
6 #endif // SIMDJSON_CONDITIONAL_INCLUDE
7 
8 namespace simdjson {
9 namespace SIMDJSON_IMPLEMENTATION {
10 
11 // This is a near copy of include/error.h's implementation_simdjson_result_base, except it doesn't use std::pair
12 // so we can avoid inlining errors
13 // TODO reconcile these!
34 template<typename T>
36 
40  simdjson_inline implementation_simdjson_result_base() noexcept = default;
41 
45  simdjson_inline implementation_simdjson_result_base(error_code error) noexcept;
46 
50  simdjson_inline implementation_simdjson_result_base(T &&value) noexcept;
51 
55  simdjson_inline implementation_simdjson_result_base(T &&value, error_code error) noexcept;
56 
63  simdjson_inline void tie(T &value, error_code &error) && noexcept;
64 
70  simdjson_inline error_code get(T &value) && noexcept;
71 
75  simdjson_inline error_code error() const noexcept;
76 
77 #if SIMDJSON_EXCEPTIONS
78 
84  simdjson_inline T& value() & noexcept(false);
85 
91  simdjson_inline T&& value() && noexcept(false);
92 
98  simdjson_inline T&& take_value() && noexcept(false);
99 
105  simdjson_inline operator T&&() && noexcept(false);
106 
107 
108 #endif // SIMDJSON_EXCEPTIONS
109 
114  simdjson_inline const T& value_unsafe() const& noexcept;
119  simdjson_inline T& value_unsafe() & noexcept;
124  simdjson_inline T&& value_unsafe() && noexcept;
125 protected:
127  T first{};
129 }; // struct implementation_simdjson_result_base
130 
131 } // namespace SIMDJSON_IMPLEMENTATION
132 } // namespace simdjson
133 
134 #endif // SIMDJSON_GENERIC_IMPLEMENTATION_SIMDJSON_RESULT_BASE_H
The top level simdjson namespace, containing everything the library provides.
Definition: base.h:8
error_code
All possible errors returned by simdjson.
Definition: error.h:19
@ UNINITIALIZED
unknown error, or uninitialized document
Definition: error.h:32
simdjson_inline implementation_simdjson_result_base() noexcept=default
Create a new empty result with error = UNINITIALIZED.
simdjson_inline T & value() &noexcept(false)
Get the result value.
simdjson_inline const T & value_unsafe() const &noexcept
Get the result value.
simdjson_inline T && value() &&noexcept(false)
Take the result value (move it).
simdjson_inline error_code get(T &value) &&noexcept
Move the value to the provided variable.
simdjson_inline void tie(T &value, error_code &error) &&noexcept
Move the value and the error to the provided variables.
simdjson_inline T && take_value() &&noexcept(false)
Take the result value (move it).