Crow  1.0
A C++ microframework for the web
crow::json::wvalue Class Reference

JSON write value. More...

Inheritance diagram for crow::json::wvalue:
Collaboration diagram for crow::json::wvalue:

Classes

union  number
 

Public Types

using object = std::unordered_map< std::string, wvalue >
 
using list = std::vector< wvalue >
 

Public Member Functions

type t () const
 
 wvalue ()
 
 wvalue (std::nullptr_t)
 
 wvalue (bool value)
 
 wvalue (std::uint8_t value)
 
 wvalue (std::uint16_t value)
 
 wvalue (std::uint32_t value)
 
 wvalue (std::uint64_t value)
 
 wvalue (std::int8_t value)
 
 wvalue (std::int16_t value)
 
 wvalue (std::int32_t value)
 
 wvalue (std::int64_t value)
 
 wvalue (float value)
 
 wvalue (double value)
 
 wvalue (char const *value)
 
 wvalue (std::string const &value)
 
 wvalue (std::string &&value)
 
 wvalue (std::initializer_list< std::pair< std::string const, wvalue >> initializer_list)
 
 wvalue (object const &value)
 
 wvalue (object &&value)
 
 wvalue (const list &r)
 
 wvalue (list &r)
 
 wvalue (const rvalue &r)
 Create a write value from a read value (useful for editing JSON strings). More...
 
 wvalue (const wvalue &r)
 
 wvalue (wvalue &&r)
 
wvalueoperator= (wvalue &&r)
 
void clear ()
 Used for compatibility, same as reset() More...
 
void reset ()
 
wvalueoperator= (std::nullptr_t)
 
wvalueoperator= (bool value)
 
wvalueoperator= (double value)
 
wvalueoperator= (unsigned short value)
 
wvalueoperator= (short value)
 
wvalueoperator= (long long value)
 
wvalueoperator= (long value)
 
wvalueoperator= (int value)
 
wvalueoperator= (unsigned long long value)
 
wvalueoperator= (unsigned long value)
 
wvalueoperator= (unsigned int value)
 
wvalueoperator= (const char *str)
 
wvalueoperator= (const std::string &str)
 
wvalueoperator= (list &&v)
 
template<typename T >
wvalueoperator= (const std::vector< T > &v)
 
wvalueoperator= (std::initializer_list< std::pair< std::string const, wvalue >> initializer_list)
 
wvalueoperator= (object const &value)
 
wvalueoperator= (object &&value)
 
wvalueoperator= (std::function< std::string(std::string &)> &&func)
 
wvalueoperator[] (unsigned index)
 
int count (const std::string &str)
 
wvalueoperator[] (const std::string &str)
 
std::vector< std::string > keys () const
 
std::string execute (std::string txt="") const
 
std::size_t size () const
 If the wvalue is a list, it returns the length of the list, otherwise it returns 1. More...
 
size_t estimate_length () const
 Returns an estimated size of the value in bytes. More...
 
std::string dump () const
 

Public Attributes

std::string content_type
 

Private Member Functions

void dump_string (const std::string &str, std::string &out) const
 
void dump_internal (const wvalue &v, std::string &out) const
 

Private Attributes

type t_ {type::Null}
 The type of the value. More...
 
num_type nt {num_type::Null}
 The specific type of the number if t_ is a number. More...
 
union crow::json::wvalue::number num
 Value if type is a number. More...
 
std::string s
 Value if type is a string. More...
 
std::unique_ptr< listl
 Value if type is a list. More...
 
std::unique_ptr< objecto
 Value if type is a JSON object. More...
 
std::function< std::string(std::string &)> f
 Value if type is a function (C++ lambda) More...
 

Friends

class crow::mustache::template_t
 

Detailed Description

JSON write value.

Value can mean any json value, including a JSON object.
Write means this class is used to primarily assemble JSON objects using keys and values and export those into a string.

Member Typedef Documentation

◆ object

using crow::json::wvalue::object = std::unordered_map<std::string, wvalue>

◆ list

using crow::json::wvalue::list = std::vector<wvalue>

Constructor & Destructor Documentation

◆ wvalue() [1/24]

crow::json::wvalue::wvalue ( )
inline

◆ wvalue() [2/24]

crow::json::wvalue::wvalue ( std::nullptr_t  )
inline

◆ wvalue() [3/24]

crow::json::wvalue::wvalue ( bool  value)
inline

◆ wvalue() [4/24]

crow::json::wvalue::wvalue ( std::uint8_t  value)
inline

◆ wvalue() [5/24]

crow::json::wvalue::wvalue ( std::uint16_t  value)
inline

◆ wvalue() [6/24]

crow::json::wvalue::wvalue ( std::uint32_t  value)
inline

◆ wvalue() [7/24]

crow::json::wvalue::wvalue ( std::uint64_t  value)
inline

◆ wvalue() [8/24]

crow::json::wvalue::wvalue ( std::int8_t  value)
inline

◆ wvalue() [9/24]

crow::json::wvalue::wvalue ( std::int16_t  value)
inline

◆ wvalue() [10/24]

crow::json::wvalue::wvalue ( std::int32_t  value)
inline

◆ wvalue() [11/24]

crow::json::wvalue::wvalue ( std::int64_t  value)
inline

◆ wvalue() [12/24]

crow::json::wvalue::wvalue ( float  value)
inline

◆ wvalue() [13/24]

crow::json::wvalue::wvalue ( double  value)
inline

◆ wvalue() [14/24]

crow::json::wvalue::wvalue ( char const *  value)
inline

◆ wvalue() [15/24]

crow::json::wvalue::wvalue ( std::string const &  value)
inline

◆ wvalue() [16/24]

crow::json::wvalue::wvalue ( std::string &&  value)
inline

◆ wvalue() [17/24]

crow::json::wvalue::wvalue ( std::initializer_list< std::pair< std::string const, wvalue >>  initializer_list)
inline

◆ wvalue() [18/24]

crow::json::wvalue::wvalue ( object const &  value)
inline

◆ wvalue() [19/24]

crow::json::wvalue::wvalue ( object &&  value)
inline

◆ wvalue() [20/24]

crow::json::wvalue::wvalue ( const list r)
inline

◆ wvalue() [21/24]

crow::json::wvalue::wvalue ( list r)
inline

◆ wvalue() [22/24]

crow::json::wvalue::wvalue ( const rvalue r)
inline

Create a write value from a read value (useful for editing JSON strings).

Here is the call graph for this function:

◆ wvalue() [23/24]

crow::json::wvalue::wvalue ( const wvalue r)
inline
Here is the call graph for this function:

◆ wvalue() [24/24]

crow::json::wvalue::wvalue ( wvalue &&  r)
inline

Member Function Documentation

◆ t()

type crow::json::wvalue::t ( ) const
inline
Here is the caller graph for this function:

◆ operator=() [1/20]

wvalue& crow::json::wvalue::operator= ( wvalue &&  r)
inline

◆ clear()

void crow::json::wvalue::clear ( )
inline

Used for compatibility, same as reset()

Here is the call graph for this function:

◆ reset()

void crow::json::wvalue::reset ( )
inline
Here is the caller graph for this function:

◆ operator=() [2/20]

wvalue& crow::json::wvalue::operator= ( std::nullptr_t  )
inline
Here is the call graph for this function:

◆ operator=() [3/20]

wvalue& crow::json::wvalue::operator= ( bool  value)
inline
Here is the call graph for this function:

◆ operator=() [4/20]

wvalue& crow::json::wvalue::operator= ( double  value)
inline
Here is the call graph for this function:

◆ operator=() [5/20]

wvalue& crow::json::wvalue::operator= ( unsigned short  value)
inline
Here is the call graph for this function:

◆ operator=() [6/20]

wvalue& crow::json::wvalue::operator= ( short  value)
inline
Here is the call graph for this function:

◆ operator=() [7/20]

wvalue& crow::json::wvalue::operator= ( long long  value)
inline
Here is the call graph for this function:

◆ operator=() [8/20]

wvalue& crow::json::wvalue::operator= ( long  value)
inline
Here is the call graph for this function:

◆ operator=() [9/20]

wvalue& crow::json::wvalue::operator= ( int  value)
inline
Here is the call graph for this function:

◆ operator=() [10/20]

wvalue& crow::json::wvalue::operator= ( unsigned long long  value)
inline
Here is the call graph for this function:

◆ operator=() [11/20]

wvalue& crow::json::wvalue::operator= ( unsigned long  value)
inline
Here is the call graph for this function:

◆ operator=() [12/20]

wvalue& crow::json::wvalue::operator= ( unsigned int  value)
inline
Here is the call graph for this function:

◆ operator=() [13/20]

wvalue& crow::json::wvalue::operator= ( const char *  str)
inline
Here is the call graph for this function:

◆ operator=() [14/20]

wvalue& crow::json::wvalue::operator= ( const std::string &  str)
inline
Here is the call graph for this function:

◆ operator=() [15/20]

wvalue& crow::json::wvalue::operator= ( list &&  v)
inline
Here is the call graph for this function:

◆ operator=() [16/20]

template<typename T >
wvalue& crow::json::wvalue::operator= ( const std::vector< T > &  v)
inline
Here is the call graph for this function:

◆ operator=() [17/20]

wvalue& crow::json::wvalue::operator= ( std::initializer_list< std::pair< std::string const, wvalue >>  initializer_list)
inline
Here is the call graph for this function:

◆ operator=() [18/20]

wvalue& crow::json::wvalue::operator= ( object const &  value)
inline
Here is the call graph for this function:

◆ operator=() [19/20]

wvalue& crow::json::wvalue::operator= ( object &&  value)
inline
Here is the call graph for this function:

◆ operator=() [20/20]

wvalue& crow::json::wvalue::operator= ( std::function< std::string(std::string &)> &&  func)
inline
Here is the call graph for this function:

◆ operator[]() [1/2]

wvalue& crow::json::wvalue::operator[] ( unsigned  index)
inline
Here is the call graph for this function:

◆ count()

int crow::json::wvalue::count ( const std::string &  str)
inline
Here is the caller graph for this function:

◆ operator[]() [2/2]

wvalue& crow::json::wvalue::operator[] ( const std::string &  str)
inline
Here is the call graph for this function:

◆ keys()

std::vector<std::string> crow::json::wvalue::keys ( ) const
inline

◆ execute()

std::string crow::json::wvalue::execute ( std::string  txt = "") const
inline

◆ size()

std::size_t crow::json::wvalue::size ( ) const
inline

If the wvalue is a list, it returns the length of the list, otherwise it returns 1.

Here is the caller graph for this function:

◆ estimate_length()

size_t crow::json::wvalue::estimate_length ( ) const
inline

Returns an estimated size of the value in bytes.

Here is the caller graph for this function:

◆ dump_string()

void crow::json::wvalue::dump_string ( const std::string &  str,
std::string &  out 
) const
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dump_internal()

void crow::json::wvalue::dump_internal ( const wvalue v,
std::string &  out 
) const
inlineprivate
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dump()

std::string crow::json::wvalue::dump ( ) const
inlinevirtual

Implements crow::returnable.

Here is the call graph for this function:

Friends And Related Function Documentation

◆ crow::mustache::template_t

friend class crow::mustache::template_t
friend

Member Data Documentation

◆ t_

type crow::json::wvalue::t_ {type::Null}
private

The type of the value.

◆ nt

num_type crow::json::wvalue::nt {num_type::Null}
private

The specific type of the number if t_ is a number.

◆ num

union crow::json::wvalue::number crow::json::wvalue::num
private

Value if type is a number.

◆ s

std::string crow::json::wvalue::s
private

Value if type is a string.

◆ l

std::unique_ptr<list> crow::json::wvalue::l
private

Value if type is a list.

◆ o

std::unique_ptr<object> crow::json::wvalue::o
private

Value if type is a JSON object.

◆ f

std::function<std::string(std::string&)> crow::json::wvalue::f
private

Value if type is a function (C++ lambda)

◆ content_type

std::string crow::returnable::content_type
inherited

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