AnnaDB 1.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Friends | List of all members
tyson::TySonObject Class Reference

#include <TySON.hpp>

Public Member Functions

 TySonObject (std::string_view object) noexcept
 
bool operator== (const TySonObject &rhs) const noexcept
 
bool operator< (const TySonObject &rhs) const noexcept
 
bool emplace (const std::string &key, tyson::TySonObject &&value)
 
std::optional< TySonObjectoperator[] (const std::string_view key) const noexcept
 
TySonType type () const noexcept
 
template<TySonType T>
std::string value () const noexcept
 
template<TySonType T>
requires (T == TySonType::Bool)
bool value () const noexcept
 
template<TySonType T>
requires (T == TySonType::Null)
std::string value () const noexcept
 
template<TySonType T>
requires (T == TySonType::Link)
std::pair< std::string, std::string > value () const noexcept
 
template<TySonType T>
requires (T == TySonType::Vector)
std::vector< TySonObjectvalue () const noexcept
 
template<TySonType T>
requires (T == TySonType::Map)
std::map< TySonObject, TySonObjectvalue () const noexcept
 
template<typename T >
requires std::is_arithmetic_v<T>
value () const
 

Static Public Member Functions

template<typename T >
requires std::is_integral_v<T>
static TySonObject Number (T number) noexcept
 
static TySonObject String (const std::string &str) noexcept
 
static TySonObject Bool (bool bl) noexcept
 
static TySonObject Null () noexcept
 
static TySonObject Keep () noexcept
 
static TySonObject Timestamp (unsigned long long seconds) noexcept
 
static TySonObject Link (const std::string &collection, const std::string &uuid) noexcept
 
template<std::convertible_to< tyson::TySonObject > ... Values>
static TySonObject Vector (Values &&...objs) noexcept
 
static TySonObject Value (const std::string &field, TySonObject &&val) noexcept
 
static TySonObject ProjectValue (const std::string &value) noexcept
 
static TySonObject Map (std::map< std::string, TySonObject > &objs) noexcept
 
static TySonObject Map (const std::string &key, TySonObject &&obj) noexcept
 
static TySonObject Map () noexcept
 

Friends

std::ostream & operator<< (std::ostream &out, TySonObject const &obj) noexcept
 

Detailed Description

The TySonObject class which is the base of all TySON types

See also
AnnaDB data types

Constructor & Destructor Documentation

◆ TySonObject()

tyson::TySonObject::TySonObject ( std::string_view  object)
inlineexplicitnoexcept

Create a new TySonObject from a raw AnnaDB data type string

Parameters
objectrepresenting a AnnaDB data type
See also
AnnaDB data types

Member Function Documentation

◆ Bool()

static TySonObject tyson::TySonObject::Bool ( bool  bl)
inlinestaticnoexcept

Create a new TySonObject Bool

Parameters
blthe value of the new TySonObject
Returns
new TySonObject

◆ emplace()

bool tyson::TySonObject::emplace ( const std::string &  key,
tyson::TySonObject &&  value 
)
inline

Insert new element to a TySON::MAP

Parameters
keythe key of the new entry
valuethe value assigned to the key
Returns
true if inserting was successful

◆ Keep()

static TySonObject tyson::TySonObject::Keep ( )
inlinestaticnoexcept

Create a new TySonObject Keep used for project queries

Returns
new TySonObject

◆ Link()

static TySonObject tyson::TySonObject::Link ( const std::string &  collection,
const std::string &  uuid 
)
inlinestaticnoexcept

Create a new TySonObject Link

Parameters
collectionthe name of the reference collection
uuidthe id of the element inside of the collection
Returns
new TySonObject

◆ Map() [1/3]

static TySonObject tyson::TySonObject::Map ( )
inlinestaticnoexcept

Create a new empty TySonObject Map

Parameters
objsa std::map of std::string and TySonObject
Returns
new TySonObject

◆ Map() [2/3]

static TySonObject tyson::TySonObject::Map ( const std::string &  key,
TySonObject &&  obj 
)
inlinestaticnoexcept

Create a new TySonObject Map instantiated with a single value

Parameters
keyas string
objmust be a TySonObject
Returns

◆ Map() [3/3]

static TySonObject tyson::TySonObject::Map ( std::map< std::string, TySonObject > &  objs)
inlinestaticnoexcept

Create a new TySonObject Map

Parameters
objsa std::map of std::string and TySonObject
Returns
new TySonObject

◆ Null()

static TySonObject tyson::TySonObject::Null ( )
inlinestaticnoexcept

Create a new TySonObject Null

Returns
new TySonObject

◆ Number()

template<typename T >
requires std::is_integral_v<T>
static TySonObject tyson::TySonObject::Number ( number)
inlinestaticnoexcept

Create a new TySonObject Number

Template Parameters
Tan integral type
Parameters
numberthe value of the new TySonObject
Returns
new TySonObject

◆ operator<()

bool tyson::TySonObject::operator< ( const TySonObject rhs) const
inlinenoexcept

Compare the TySON object

Parameters
rhsTySonObject
Returns
bool

◆ operator==()

bool tyson::TySonObject::operator== ( const TySonObject rhs) const
inlinenoexcept

Compare the TySON object

Parameters
rhsTySonObject
Returns
bool

◆ operator[]()

std::optional< TySonObject > tyson::TySonObject::operator[] ( const std::string_view  key) const
inlinenoexcept

Get the value of a AnnaDB Map as TySonObject

Parameters
keymust be a string inside of AnnaDB Map
Returns
TySonObject value from a TySonObject Map if exists

◆ ProjectValue()

static TySonObject tyson::TySonObject::ProjectValue ( const std::string &  value)
inlinestaticnoexcept

Create a new TySonObject required for query project statements

See also
query.annadb::Query::UpdateType
Parameters
valthe value which should be used instead
Returns
new TySonObject

◆ String()

static TySonObject tyson::TySonObject::String ( const std::string &  str)
inlinestaticnoexcept

Create a new TySonObject String

Parameters
strthe value of the new TySonObject
Returns
new TySonObject

◆ Timestamp()

static TySonObject tyson::TySonObject::Timestamp ( unsigned long long  seconds)
inlinestaticnoexcept

Create a new TySonObject Timestamp

Parameters
secondsthat have elapsed since the Unix epoch
Returns
new TySonObject

◆ type()

TySonType tyson::TySonObject::type ( ) const
inlinenoexcept
Returns
the type name of the current TysonObject

◆ value() [1/7]

template<typename T >
requires std::is_arithmetic_v<T>
T tyson::TySonObject::value ( ) const
inline

If the TySonObject represents a AnnaDB Number Primitive you can parse it into the type you want normal it will be returned as string

Template Parameters
Tmust be a arithmetic type
Returns
the casted value

◆ value() [2/7]

template<TySonType T>
std::string tyson::TySonObject::value ( ) const
inlinenoexcept

Get the current value of the TySonObject

Template Parameters
Tmust be of type TySonType
Returns
the current value representation

◆ value() [3/7]

template<TySonType T>
requires (T == TySonType::Bool)
bool tyson::TySonObject::value ( ) const
inlinenoexcept

If the TySonObject represents a AnnaDB Bool Primitive

Template Parameters
TTySonType::Bool
Returns
true if the value representation is the string true false otherwise

◆ value() [4/7]

template<TySonType T>
requires (T == TySonType::Null)
std::string tyson::TySonObject::value ( ) const
inlinenoexcept

If the TySonObject represents a AnnaDB null Primitive

Template Parameters
TTySonType::Null
Returns
an empty string to indicate null

◆ value() [5/7]

template<TySonType T>
requires (T == TySonType::Link)
std::pair< std::string, std::string > tyson::TySonObject::value ( ) const
inlinenoexcept

If the TySonObject represents a AnnaDB Link Primitive

Template Parameters
TTySonType::Link
Returns
collection name and object_id as uuid-string

◆ value() [6/7]

template<TySonType T>
requires (T == TySonType::Vector)
std::vector< TySonObject > tyson::TySonObject::value ( ) const
inlinenoexcept

If the TySonObject represents a AnnaDB Vector

Template Parameters
TTySonType::Vector
Returns
vector of TySonObjects

◆ value() [7/7]

template<TySonType T>
requires (T == TySonType::Map)
std::map< TySonObject, TySonObject > tyson::TySonObject::value ( ) const
inlinenoexcept

If the TySonObject represents a AnnaDB Map

Template Parameters
TTySonType::Map
Returns
Key-Value pairs of TySonObjects

◆ Value()

static TySonObject tyson::TySonObject::Value ( const std::string &  field,
TySonObject &&  val 
)
inlinestaticnoexcept

Create a new TySonObject required for query update statements

See also
query.annadb::Query::UpdateType
Parameters
fieldthe collection field name
valthe TySonObject which should be used instead
Returns
new TySonObject

◆ Vector()

template<std::convertible_to< tyson::TySonObject > ... Values>
static TySonObject tyson::TySonObject::Vector ( Values &&...  objs)
inlinestaticnoexcept

Create a new TySonObject Vector

Parameters
objsa std::vector of TySonObjects
Returns
new TySonObject

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