xentara-utils v2.0.4
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::json::decoder::String Class Referencefinal

An accessor used for reading a JSON string progressively. More...

#include <xentara/utils/json/decoder/String.hpp>

+ Inheritance diagram for xentara::utils::json::decoder::String:

Classes

class  Iterator
 An iterator that can be used to iterator over a string as UTF-8 code units. More...
 

Public Member Functions

 String ()=delete
 This type is not user-constructible.
 
template<typename Char , typename CharTraits , typename Allocator >
internal operator std::basic_string< Char, CharTraits, Allocator > ()
 Reads the entire string.
 
template<tools::StringType StdString>
auto read (const typename StdString::allocator_type &allocator=typename StdString::allocator_type()) -> StdString
 Reads the entire string.
 
auto begin () -> Iterator
 Returns an object that can be used to iterate over the string data.
 
constexpr auto end () noexcept -> std::default_sentinel_t
 Returns an sentinel that can be used to determine if an iterator is exhausted.
 
template<typename Char , typename CharTraits , typename Allocator >
 operator std::basic_string< Char, CharTraits, Allocator > ()
 

Detailed Description

An accessor used for reading a JSON string progressively.

Objects of this class can be moved, but not copied.

Constructor & Destructor Documentation

◆ String()

xentara::utils::json::decoder::String::String ( )
delete

This type is not user-constructible.

Member Function Documentation

◆ begin()

auto xentara::utils::json::decoder::String::begin ( ) -> Iterator

Returns an object that can be used to iterate over the string data.

Returns
An iterator that allows reading the string as individual UTF-8 code units
Exceptions
std::runtime_errorAn error occured reading the first code unit from the stream

◆ end()

constexpr auto xentara::utils::json::decoder::String::end ( ) -> std::default_sentinel_t
constexprnoexcept

Returns an sentinel that can be used to determine if an iterator is exhausted.

Returns
An sentinel for code unit iterators

◆ operator std::basic_string< Char, CharTraits, Allocator >() [1/2]

template<typename Char , typename CharTraits , typename Allocator >
internal xentara::utils::json::decoder::String::operator std::basic_string< Char, CharTraits, Allocator > ( )

Reads the entire string.

Exceptions
SyntaxErrorThe stream does not contain a valid JSON string
std::runtime_errorAn error occured reading from the stream
Returns
The string, in UTF-8 encoding

◆ operator std::basic_string< Char, CharTraits, Allocator >() [2/2]

template<typename Char , typename CharTraits , typename Allocator >
xentara::utils::json::decoder::String::operator std::basic_string< Char, CharTraits, Allocator > ( )

◆ read()

template<tools::StringType StdString>
auto xentara::utils::json::decoder::String::read ( const typename StdString::allocator_type &  allocator = typename StdString::allocator_type()) -> StdString

Reads the entire string.

Exceptions
SyntaxErrorThe stream does not contain a valid JSON string
std::runtime_errorAn error occured reading from the stream
Parameters
allocatorThe allocator for the returned string
Returns
The string, in UTF-8 encoding