Sese Framework  2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
sese::Value Class Reference

Value Container Class. More...

#include <Value.h>

Classes

class  Dict
 Dictionary Value Container Type. More...
 
class  List
 List Value Container Type. More...
 
class  Null
 Null Value Container Type. More...
 

Public Types

enum class  Type {
  NONE = 0 , BOOL , INT , DOUBLE ,
  STRING , BLOB , LIST , DICT
}
 
using Integer = int64_t
 
using String = std::string
 
using Blob = std::vector<uint8_t>
 
using StreamifyStack = std::stack<std::tuple<const Value *, unsigned int, unsigned int>>
 
using StreamifyIterStack = std::stack<std::map<std::string, std::shared_ptr<Value>>::const_iterator>
 

Public Member Functions

 Value ()=default
 
 Value (Type type)
 
 Value (bool value)
 bool
 
 Value (Integer value)
 Integer.
 
 Value (double value)
 double
 
 Value (const char *value)
 string
 
 Value (const char *bytes, size_t length)
 blob
 
 Value (String &&value) noexcept
 string
 
 Value (Blob &&value)
 blob
 
 Value (List &&value)
 list
 
 Value (Dict &&value)
 dict
 
Type getType () const
 
bool isNull () const
 
bool isBool () const
 
bool isInt () const
 
bool isDouble () const
 
bool isString () const
 
bool isBlob () const
 
bool isList () const
 
bool isDict () const
 
std::optional< bool > getIfBool () const
 
std::optional< IntegergetIfInt () const
 
std::optional< double > getIfDouble () const
 
StringgetIfString ()
 
BlobgetIfBlob ()
 
DictgetIfDict ()
 
ListgetIfList ()
 
bool getBool () const
 
Integer getInt () const
 
double getDouble () const
 
const StringgetString () const
 
StringgetString ()
 
const BlobgetBlob () const
 
BlobgetBlob ()
 
const ListgetList () const
 
ListgetList ()
 
const DictgetDict () const
 
DictgetDict ()
 
std::string toStringBasic () const noexcept
 
std::string toString () const noexcept
 
void toString (text::StringBuilder &string_builder) const noexcept
 
bool operator== (const Value &rhs) const
 
bool operator!= (const Value &rhs) const
 

Static Public Member Functions

static Value list ()
 
static Value dict ()
 

Static Private Member Functions

static void writeSpace (text::StringBuilder &string_builder, size_t count)
 
static void toStringDict (text::StringBuilder &string_builder, StreamifyStack &stack, StreamifyIterStack &map_iter_stack)
 
static void toStringList (text::StringBuilder &string_builder, StreamifyStack &stack, StreamifyIterStack &map_iter_stack)
 

Private Attributes

std::variant< Null, bool, Integer, double, String, Blob, List, Dictdata
 

Detailed Description

Value Container Class.

Member Typedef Documentation

◆ Blob

using sese::Value::Blob = std::vector<uint8_t>

◆ Integer

using sese::Value::Integer = int64_t

◆ StreamifyIterStack

using sese::Value::StreamifyIterStack = std::stack<std::map<std::string, std::shared_ptr<Value>>::const_iterator>

◆ StreamifyStack

using sese::Value::StreamifyStack = std::stack<std::tuple<const Value *, unsigned int, unsigned int>>

◆ String

using sese::Value::String = std::string

Member Enumeration Documentation

◆ Type

enum class sese::Value::Type
strong
Enumerator
NONE 
BOOL 
INT 
DOUBLE 
STRING 
BLOB 
LIST 
DICT 

Constructor & Destructor Documentation

◆ Value() [1/11]

sese::Value::Value ( )
default

Referenced by dict(), and list().

◆ Value() [2/11]

Value::Value ( Type type)
explicit

References BLOB, BOOL, data, DICT, DOUBLE, INT, LIST, NONE, and STRING.

◆ Value() [3/11]

Value::Value ( bool value)
explicit

bool

◆ Value() [4/11]

Value::Value ( Integer value)
explicit

Integer.

◆ Value() [5/11]

Value::Value ( double value)
explicit

double

◆ Value() [6/11]

Value::Value ( const char * value)
explicit

string

◆ Value() [7/11]

Value::Value ( const char * bytes,
size_t length )
explicit

blob

References data.

◆ Value() [8/11]

Value::Value ( String && value)
explicitnoexcept

string

◆ Value() [9/11]

Value::Value ( Blob && value)
explicit

blob

◆ Value() [10/11]

Value::Value ( List && value)
explicit

list

◆ Value() [11/11]

Value::Value ( Dict && value)
explicit

dict

Member Function Documentation

◆ dict()

◆ getBlob() [1/2]

Value::Blob & Value::getBlob ( )
nodiscard

References data, and isBlob().

◆ getBlob() [2/2]

const Value::Blob & Value::getBlob ( ) const
nodiscard

References data, and isBlob().

◆ getBool()

bool Value::getBool ( ) const
nodiscard

References data, and isBool().

◆ getDict() [1/2]

Value::Dict & Value::getDict ( )
nodiscard

References data, and isDict().

◆ getDict() [2/2]

const Value::Dict & Value::getDict ( ) const
nodiscard

References data, and isDict().

Referenced by sese::Json::streamify(), and sese::Yaml::streamify().

◆ getDouble()

double Value::getDouble ( ) const
nodiscard

References data, and isDouble().

◆ getIfBlob()

Value::Blob * Value::getIfBlob ( )
nodiscard

References data.

◆ getIfBool()

std::optional< bool > Value::getIfBool ( ) const
nodiscard

Allow numeric types to be converted to boolean

Returns
Boolean value

References data, isBool(), isDouble(), and isInt().

◆ getIfDict()

Value::Dict * Value::getIfDict ( )
nodiscard

References data.

◆ getIfDouble()

std::optional< double > Value::getIfDouble ( ) const
nodiscard

Allow numeric types to be converted to double

Returns
Double value

References data, isDouble(), and isInt().

◆ getIfInt()

std::optional< Value::Integer > Value::getIfInt ( ) const
nodiscard

Allow numeric types to be converted to integer

Returns
Integer value

References data, isDouble(), and isInt().

◆ getIfList()

Value::List * Value::getIfList ( )
nodiscard

References data.

◆ getIfString()

Value::String * Value::getIfString ( )
nodiscard

References data.

◆ getInt()

Value::Integer Value::getInt ( ) const
nodiscard

References data, and isInt().

◆ getList() [1/2]

Value::List & Value::getList ( )
nodiscard

References data, and isList().

◆ getList() [2/2]

const Value::List & Value::getList ( ) const
nodiscard

References data, and isList().

◆ getString() [1/2]

Value::String & Value::getString ( )
nodiscard

References data, and isString().

◆ getString() [2/2]

const Value::String & Value::getString ( ) const
nodiscard

References data, and isString().

◆ getType()

Value::Type Value::getType ( ) const
nodiscard

◆ isBlob()

bool Value::isBlob ( ) const
nodiscard

References BLOB, and getType().

Referenced by getBlob(), and getBlob().

◆ isBool()

bool Value::isBool ( ) const
nodiscard

References BOOL, and getType().

Referenced by getBool(), and getIfBool().

◆ isDict()

bool Value::isDict ( ) const
nodiscard

◆ isDouble()

bool Value::isDouble ( ) const
nodiscard

References DOUBLE, and getType().

Referenced by getDouble(), getIfBool(), getIfDouble(), and getIfInt().

◆ isInt()

bool Value::isInt ( ) const
nodiscard

References getType(), and INT.

Referenced by getIfBool(), getIfDouble(), getIfInt(), and getInt().

◆ isList()

bool Value::isList ( ) const
nodiscard

References getType(), and LIST.

Referenced by getList(), and getList().

◆ isNull()

bool Value::isNull ( ) const
nodiscard

References getType(), and NONE.

◆ isString()

bool Value::isString ( ) const
nodiscard

References getType(), and STRING.

Referenced by getString(), and getString().

◆ list()

◆ operator!=()

bool Value::operator!= ( const Value & rhs) const

◆ operator==()

bool Value::operator== ( const Value & rhs) const

References BLOB, BOOL, data, DICT, DOUBLE, getType(), INT, LIST, NONE, and STRING.

◆ toString() [1/2]

std::string Value::toString ( ) const
nodiscardnoexcept

◆ toString() [2/2]

void Value::toString ( text::StringBuilder & string_builder) const
noexcept

References count().

◆ toStringBasic()

std::string Value::toStringBasic ( ) const
nodiscardnoexcept

References BLOB, BOOL, data, DOUBLE, getType(), INT, NONE, and STRING.

◆ toStringDict()

void Value::toStringDict ( text::StringBuilder & string_builder,
StreamifyStack & stack,
StreamifyIterStack & map_iter_stack )
staticprivate

References count(), and writeSpace().

◆ toStringList()

void Value::toStringList ( text::StringBuilder & string_builder,
StreamifyStack & stack,
StreamifyIterStack & map_iter_stack )
staticprivate

References count(), and writeSpace().

◆ writeSpace()

void Value::writeSpace ( text::StringBuilder & string_builder,
size_t count )
staticprivate

Member Data Documentation

◆ data


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