simdjson 4.6.4
Ridiculously Fast JSON
Loading...
Searching...
No Matches
simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number Struct Reference

A type representing a JSON number. More...

#include <json_type.h>

Public Member Functions

simdjson_inline ondemand::number_type get_number_type () const noexcept
 return the automatically determined type of the number: number_type::floating_point_number, number_type::signed_integer or number_type::unsigned_integer.
 
simdjson_inline bool is_uint64 () const noexcept
 return true if the automatically determined type of the number is number_type::unsigned_integer.
 
simdjson_inline uint64_t get_uint64 () const noexcept
 return the value as a uint64_t, only valid if is_uint64() is true.
 
simdjson_inline operator uint64_t () const noexcept
 
simdjson_inline bool is_int64 () const noexcept
 return true if the automatically determined type of the number is number_type::signed_integer.
 
simdjson_inline int64_t get_int64 () const noexcept
 return the value as a int64_t, only valid if is_int64() is true.
 
simdjson_inline operator int64_t () const noexcept
 
simdjson_inline bool is_double () const noexcept
 return true if the automatically determined type of the number is number_type::floating_point_number.
 
simdjson_inline double get_double () const noexcept
 return the value as a double, only valid if is_double() is true.
 
simdjson_inline operator double () const noexcept
 
simdjson_inline double as_double () const noexcept
 Convert the number to a double.
 

Protected Member Functions

simdjson_inline void append_s64 (int64_t value) noexcept
 Store a signed 64-bit value to the number.
 
simdjson_inline void append_u64 (uint64_t value) noexcept
 Store an unsigned 64-bit value to the number.
 
simdjson_inline void append_double (double value) noexcept
 Store a double value to the number.
 
simdjson_inline void skip_double () noexcept
 Specifies that the value is a double, but leave it undefined.
 

Protected Attributes

union { 
 
   double   floating_point_number 
 
   int64_t   signed_integer 
 
   uint64_t   unsigned_integer 
 
payload 
 End of friend declarations.
 
number_type type {number_type::signed_integer}
 

Detailed Description

A type representing a JSON number.

The design of the struct is deliberately straight-forward. All functions return standard values with no error check.

Definition at line 33 of file json_type.h.

Member Function Documentation

◆ append_double()

simdjson_inline void simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::append_double ( double  value)
protectednoexcept

Store a double value to the number.

Definition at line 95 of file json_type-inl.h.

◆ append_s64()

simdjson_inline void simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::append_s64 ( int64_t  value)
protectednoexcept

Store a signed 64-bit value to the number.

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

◆ append_u64()

simdjson_inline void simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::append_u64 ( uint64_t  value)
protectednoexcept

Store an unsigned 64-bit value to the number.

Definition at line 90 of file json_type-inl.h.

◆ as_double()

simdjson_inline double simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::as_double ( ) const
noexcept

Convert the number to a double.

Though it always succeed, the conversion may be lossy if the number cannot be represented exactly.

Definition at line 75 of file json_type-inl.h.

◆ get_double()

simdjson_inline double simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::get_double ( ) const
noexcept

return the value as a double, only valid if is_double() is true.

Definition at line 67 of file json_type-inl.h.

◆ get_int64()

simdjson_inline int64_t simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::get_int64 ( ) const
noexcept

return the value as a int64_t, only valid if is_int64() is true.

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

◆ get_number_type()

simdjson_inline number_type simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::get_number_type ( ) const
noexcept

return the automatically determined type of the number: number_type::floating_point_number, number_type::signed_integer or number_type::unsigned_integer.

enum class number_type { floating_point_number=1, /// a binary64 number signed_integer, /// a signed integer that fits in a 64-bit word using two's complement unsigned_integer /// a positive integer larger or equal to 1<<63 };

Definition at line 35 of file json_type-inl.h.

◆ get_uint64()

simdjson_inline uint64_t simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::get_uint64 ( ) const
noexcept

return the value as a uint64_t, only valid if is_uint64() is true.

Definition at line 43 of file json_type-inl.h.

◆ is_double()

simdjson_inline bool simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::is_double ( ) const
noexcept

return true if the automatically determined type of the number is number_type::floating_point_number.

Definition at line 63 of file json_type-inl.h.

◆ is_int64()

simdjson_inline bool simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::is_int64 ( ) const
noexcept

return true if the automatically determined type of the number is number_type::signed_integer.

Definition at line 51 of file json_type-inl.h.

◆ is_uint64()

simdjson_inline bool simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::is_uint64 ( ) const
noexcept

return true if the automatically determined type of the number is number_type::unsigned_integer.

Definition at line 39 of file json_type-inl.h.

◆ operator double()

simdjson_inline simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::operator double ( ) const
noexcept

Definition at line 71 of file json_type-inl.h.

◆ operator int64_t()

simdjson_inline simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::operator int64_t ( ) const
noexcept

Definition at line 59 of file json_type-inl.h.

◆ operator uint64_t()

simdjson_inline simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::operator uint64_t ( ) const
noexcept

Definition at line 47 of file json_type-inl.h.

◆ skip_double()

simdjson_inline void simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::skip_double ( )
protectednoexcept

Specifies that the value is a double, but leave it undefined.

Definition at line 100 of file json_type-inl.h.

Member Data Documentation

◆ floating_point_number

double simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::floating_point_number

Definition at line 116 of file json_type.h.

◆ [union]

union { ... } simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::payload

End of friend declarations.

Our attributes are a union type (size = 64 bits) followed by a type indicator.

◆ signed_integer

int64_t simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::signed_integer

Definition at line 117 of file json_type.h.

◆ type

number_type simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::type {number_type::signed_integer}
protected

Definition at line 120 of file json_type.h.

◆ unsigned_integer

uint64_t simdjson::SIMDJSON_IMPLEMENTATION::ondemand::number::unsigned_integer

Definition at line 118 of file json_type.h.


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