userver: formats::json::Array Class Reference
Loading...
Searching...
No Matches
formats::json::Array Class Referencefinal

#include <userver/formats/json/array.hpp>

Detailed Description

Non-mutable JSON array representation.

This class is implemented in terms of formats::json::Value and cannot represent anything else but a JSON array. Use it when you need to explicitly state that only JSON array is expected.

Definition at line 22 of file array.hpp.

+ Inheritance diagram for formats::json::Array:

Public Types

using const_iterator = Iterator< IterTraits, common::IteratorDirection::kForward >
 
using const_reverse_iterator = Iterator< IterTraits, common::IteratorDirection::kReverse >
 

Public Member Functions

 Array ()
 Creates empty array.
 
 Array (const Value &value)
 
 Array (Value &&value)
 
 Array (ValueBuilder &&builder)
 Creates array extracting value from the builder.
 
 Array (const Array &)=default
 
 Array (Array &&) noexcept=default
 
Arrayoperator= (const Array &) &=default
 
Arrayoperator= (Array &&) noexcept=default
 
const ValueGetValue () const &
 Returns formats::json::Value.
 
Value && ExtractValue () &&
 Returns formats::json::Value.
 
Value operator[] (std::string_view key) const =delete
 
bool operator== (const Array &other) const
 Compares values.
 
bool operator!= (const Array &other) const
 
Array Clone () const
 Returns a deep copy of array (see formats::json::Value::Clone).
 
const_iterator begin () const
 
const_iterator end () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator rend () const
 
bool IsEmpty () const
 
std::size_t GetSize () const
 
void CheckInBounds (std::size_t index) const
 
template<typename T >
auto As () const
 
template<typename T , typename First , typename... Rest>
auto As (First &&default_arg, Rest &&... more_default_args) const
 
template<typename T >
auto As (DefaultConstructed) const
 
template<typename T >
ConvertTo () const
 
template<typename T , typename First , typename... Rest>
ConvertTo (First &&default_arg, Rest &&... more_default_args) const
 
template<>
bool ConvertTo () const
 
template<>
int64_t ConvertTo () const
 
template<>
uint64_t ConvertTo () const
 
template<>
double ConvertTo () const
 
std::string GetPath () const
 
bool IsRoot () const noexcept
 

Private Member Functions

Value operator[] (std::size_t index) const
 Access array member by index for read.
 
bool operator== (const Value &other) const
 Compares values.
 
bool operator!= (const Value &other) const
 

Member Typedef Documentation

◆ const_iterator

using formats::json::Value::const_iterator = Iterator<IterTraits, common::IteratorDirection::kForward>

Definition at line 69 of file value.hpp.

◆ const_reverse_iterator

using formats::json::Value::const_reverse_iterator = Iterator<IterTraits, common::IteratorDirection::kReverse>

Definition at line 70 of file value.hpp.

Constructor & Destructor Documentation

◆ Array() [1/3]

formats::json::Array::Array ( const Value value)
inlineexplicit
Exceptions
TypeMismatchExceptionif value is not an array

Definition at line 31 of file array.hpp.

◆ Array() [2/3]

formats::json::Array::Array ( Value &&  value)
inlineexplicit
Exceptions
TypeMismatchExceptionif value is not an array

Definition at line 38 of file array.hpp.

◆ Array() [3/3]

formats::json::Array::Array ( ValueBuilder &&  builder)
explicit

Creates array extracting value from the builder.

Exceptions
TypeMismatchExceptionif extracted value is not an array.

Member Function Documentation

◆ As() [1/3]

template<typename T >
auto formats::json::Value::As ( ) const
See also
formats::json::Value::As

Definition at line 188 of file value.hpp.

◆ As() [2/3]

template<typename T >
auto formats::json::Value::As ( Value::DefaultConstructed  ) const
See also
formats::json::Value::As

Definition at line 200 of file value.hpp.

◆ As() [3/3]

template<typename T , typename First , typename... Rest>
auto formats::json::Value::As ( First &&  default_arg,
Rest &&...  more_default_args 
) const
See also
formats::json::Value::As

Definition at line 194 of file value.hpp.

◆ begin()

const_iterator formats::json::Value::begin ( ) const

◆ CheckInBounds()

void formats::json::Value::CheckInBounds ( std::size_t  index) const

◆ Clone()

Array formats::json::Array::Clone ( ) const
inline

Returns a deep copy of array (see formats::json::Value::Clone).

Definition at line 104 of file array.hpp.

◆ ConvertTo() [1/6]

template<typename T >
T formats::json::Value::ConvertTo ( ) const
See also
formats::json::Value::ConvertTo

Definition at line 205 of file value.hpp.

◆ ConvertTo() [2/6]

template<>
double formats::json::Value::ConvertTo ( ) const

◆ ConvertTo() [3/6]

template<>
uint64_t formats::json::Value::ConvertTo ( ) const

◆ ConvertTo() [4/6]

template<>
int64_t formats::json::Value::ConvertTo ( ) const

◆ ConvertTo() [5/6]

template<>
bool formats::json::Value::ConvertTo ( ) const

◆ ConvertTo() [6/6]

template<typename T , typename First , typename... Rest>
T formats::json::Value::ConvertTo ( First &&  default_arg,
Rest &&...  more_default_args 
) const
See also
formats::json::Value::ConvertTo

Definition at line 210 of file value.hpp.

◆ end()

const_iterator formats::json::Value::end ( ) const

◆ ExtractValue()

Value && formats::json::Array::ExtractValue ( ) &&
inline

Returns formats::json::Value.

Definition at line 58 of file array.hpp.

◆ GetPath()

std::string formats::json::Value::GetPath ( ) const

◆ GetSize()

std::size_t formats::json::Value::GetSize ( ) const

◆ GetValue()

const Value & formats::json::Array::GetValue ( ) const &
inline

Returns formats::json::Value.

Definition at line 55 of file array.hpp.

◆ IsEmpty()

bool formats::json::Value::IsEmpty ( ) const

◆ IsRoot()

bool formats::json::Value::IsRoot ( ) const
noexcept

◆ operator!=()

bool formats::json::Array::operator!= ( const Array other) const
inline

Definition at line 89 of file array.hpp.

◆ operator==()

bool formats::json::Array::operator== ( const Array other) const
inline

Compares values.

Definition at line 88 of file array.hpp.

◆ rbegin()

const_reverse_iterator formats::json::Value::rbegin ( ) const

◆ rend()

const_reverse_iterator formats::json::Value::rend ( ) const

The documentation for this class was generated from the following file: