simdjson 4.6.4
Ridiculously Fast JSON
Loading...
Searching...
No Matches
simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T > Struct Template Reference

The result of a simdjson operation that could fail. More...

#include <implementation_simdjson_result_base.h>

Public Types

using value_type = T
 
using error_type = error_code
 

Public Member Functions

simdjson_inline implementation_simdjson_result_base () noexcept=default
 Create a new empty result with error = UNINITIALIZED.
 
simdjson_inline implementation_simdjson_result_base (error_code error) noexcept
 Create a new error result.
 
simdjson_inline implementation_simdjson_result_base (T &&value) noexcept
 Create a new successful result.
 
simdjson_inline implementation_simdjson_result_base (T &&value, error_code error) noexcept
 Create a new result with both things (use if you don't want to branch when creating the result).
 
simdjson_inline void tie (T &value, error_code &error) &&noexcept
 Move the value and the error to the provided variables.
 
simdjson_warn_unused simdjson_inline error_code get (T &value) &&noexcept
 Move the value to the provided variable.
 
simdjson_warn_unused simdjson_inline error_code error () const noexcept
 The error.
 
simdjson_warn_unused simdjson_inline bool has_value () const noexcept
 Whether there is a value.
 
simdjson_inline T & operator* () &noexcept(false)
 Get the result value.
 
simdjson_inline T && operator* () &&noexcept(false)
 
simdjson_inline T * operator-> () noexcept(false)
 Arrow operator to access members of the contained value.
 
simdjson_inline const T * operator-> () const noexcept(false)
 
simdjson_inline T & value () &noexcept(false)
 
simdjson_inline T && value () &&noexcept(false)
 Take the result value (move it).
 
simdjson_inline T && take_value () &&noexcept(false)
 Take the result value (move it).
 
simdjson_inline operator T&& () &&noexcept(false)
 Cast to the value (will throw on error).
 
simdjson_inline const T & value_unsafe () const &noexcept
 Get the result value.
 
simdjson_inline T & value_unsafe () &noexcept
 Get the result value.
 
simdjson_inline T && value_unsafe () &&noexcept
 Take the result value (move it).
 

Protected Attributes

first {}
 users should never directly access first and second.
 
error_code second {UNINITIALIZED}
 Users should never directly access 'first'.
 

Detailed Description

template<typename T>
struct simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >

The result of a simdjson operation that could fail.

Gives the option of reading error codes, or throwing an exception by casting to the desired result.

This is a base class for implementations that want to add functions to the result type for chaining.

Override like:

struct simdjson_result<T> : public internal::implementation_simdjson_result_base<T> { simdjson_result() noexcept : internal::implementation_simdjson_result_base<T>() {} simdjson_result(error_code error) noexcept : internal::implementation_simdjson_result_base<T>(error) {} simdjson_result(T &&value) noexcept : internal::implementation_simdjson_result_base<T>(std::forward(value)) {} simdjson_result(T &&value, error_code error) noexcept : internal::implementation_simdjson_result_base<T>(value, error) {} // Your extra methods here }

Then any method returning simdjson_result<T> will be chainable with your methods.

Definition at line 35 of file implementation_simdjson_result_base.h.

Member Typedef Documentation

◆ error_type

Definition at line 142 of file implementation_simdjson_result_base.h.

◆ value_type

template<typename T >
using simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::value_type = T

Definition at line 141 of file implementation_simdjson_result_base.h.

Constructor & Destructor Documentation

◆ implementation_simdjson_result_base() [1/3]

template<typename T >
simdjson_inline simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::implementation_simdjson_result_base ( error_code  error)
noexcept

Create a new error result.

Definition at line 110 of file implementation_simdjson_result_base-inl.h.

◆ implementation_simdjson_result_base() [2/3]

template<typename T >
simdjson_inline simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::implementation_simdjson_result_base ( T &&  value)
noexcept

Create a new successful result.

Definition at line 113 of file implementation_simdjson_result_base-inl.h.

◆ implementation_simdjson_result_base() [3/3]

template<typename T >
simdjson_inline simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::implementation_simdjson_result_base ( T &&  value,
error_code  error 
)
noexcept

Create a new result with both things (use if you don't want to branch when creating the result).

Definition at line 107 of file implementation_simdjson_result_base-inl.h.

Member Function Documentation

◆ error()

template<typename T >
simdjson_warn_unused simdjson_inline error_code simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::error ( ) const
noexcept

The error.

Definition at line 32 of file implementation_simdjson_result_base-inl.h.

◆ get()

template<typename T >
simdjson_warn_unused simdjson_inline error_code simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::get ( T &  value) &&
noexcept

Move the value to the provided variable.

Parameters
valueThe variable to assign the value to. May not be set if there is an error.

Definition at line 25 of file implementation_simdjson_result_base-inl.h.

◆ has_value()

template<typename T >
simdjson_warn_unused simdjson_inline bool simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::has_value ( ) const
noexcept

Whether there is a value.

Definition at line 38 of file implementation_simdjson_result_base-inl.h.

◆ operator T&&()

template<typename T >
simdjson_inline simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::operator T&& ( ) &&

Cast to the value (will throw on error).

Exceptions
simdjson_errorif there was an error.

Definition at line 85 of file implementation_simdjson_result_base-inl.h.

◆ operator*() [1/2]

template<typename T >
simdjson_inline T && simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::operator* ( ) &&

Definition at line 50 of file implementation_simdjson_result_base-inl.h.

◆ operator*() [2/2]

template<typename T >
simdjson_inline T & simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::operator* ( ) &

Get the result value.

Exceptions
simdjson_errorif there was an error.

Definition at line 45 of file implementation_simdjson_result_base-inl.h.

◆ operator->() [1/2]

template<typename T >
simdjson_inline const T * simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::operator-> ( ) const

Definition at line 62 of file implementation_simdjson_result_base-inl.h.

◆ operator->() [2/2]

template<typename T >
simdjson_inline T * simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::operator-> ( )

Arrow operator to access members of the contained value.

Exceptions
simdjson_errorif there was an error.

Definition at line 55 of file implementation_simdjson_result_base-inl.h.

◆ take_value()

template<typename T >
simdjson_inline T && simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::take_value ( ) &&

Take the result value (move it).

Exceptions
simdjson_errorif there was an error.

Definition at line 79 of file implementation_simdjson_result_base-inl.h.

◆ tie()

template<typename T >
simdjson_inline void simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::tie ( T &  value,
error_code error 
) &&
noexcept

Move the value and the error to the provided variables.

Parameters
valueThe variable to assign the value to. May not be set if there is an error.
errorThe variable to assign the error to. Set to SUCCESS if there is no error.

Definition at line 17 of file implementation_simdjson_result_base-inl.h.

◆ value() [1/2]

template<typename T >
simdjson_inline T && simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::value ( ) &&

Take the result value (move it).

Exceptions
simdjson_errorif there was an error.

Definition at line 74 of file implementation_simdjson_result_base-inl.h.

◆ value() [2/2]

template<typename T >
simdjson_inline T & simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::value ( ) &

Definition at line 68 of file implementation_simdjson_result_base-inl.h.

◆ value_unsafe() [1/3]

template<typename T >
simdjson_inline T && simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::value_unsafe ( ) &&
noexcept

Take the result value (move it).

This function is safe if and only the error() method returns a value that evaluates to false.

Definition at line 102 of file implementation_simdjson_result_base-inl.h.

◆ value_unsafe() [2/3]

template<typename T >
simdjson_inline T & simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::value_unsafe ( ) &
noexcept

Get the result value.

This function is safe if and only the error() method returns a value that evaluates to false.

Definition at line 97 of file implementation_simdjson_result_base-inl.h.

◆ value_unsafe() [3/3]

template<typename T >
simdjson_inline const T & simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::value_unsafe ( ) const &
noexcept

Get the result value.

This function is safe if and only the error() method returns a value that evaluates to false.

Definition at line 92 of file implementation_simdjson_result_base-inl.h.

Member Data Documentation

◆ first

template<typename T >
T simdjson::SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base< T >::first {}
protected

users should never directly access first and second.

Definition at line 146 of file implementation_simdjson_result_base.h.

◆ second

Users should never directly access 'first'.

Definition at line 147 of file implementation_simdjson_result_base.h.


The documentation for this struct was generated from the following files: