ZeroErr
Loading...
Searching...
No Matches
zeroerr::IRObject Struct Reference

Interface for serializable objects. More...

#include <serialization.h>

Collaboration diagram for zeroerr::IRObject:

Classes

struct  Childrens

Public Types

enum  Type {
  Undefined = 0 , Int , Float , String ,
  ShortString , Object
}

Public Member Functions

 IRObject () noexcept
 ~IRObject ()
 IRObject (const IRObject &other)
 IRObject (IRObject &&other) noexcept
IRObject & operator= (const IRObject &other)
IRObject & operator= (IRObject &&other) noexcept
void Reset () noexcept
template<typename T>
std::enable_if< std::is_integral< T >::value, T >::type GetScalar () const
template<typename T>
std::enable_if< std::is_floating_point< T >::value, T >::type GetScalar () const
template<typename T>
std::enable_if< std::is_enum< T >::value, T >::type GetScalar () const
template<typename T>
std::enable_if< detail::StringLike< T >::owning, T >::type GetScalar () const
template<typename T>
std::enable_if< std::is_integral< T >::value, void >::type SetScalar (T val)
template<typename T>
std::enable_if< std::is_floating_point< T >::value, void >::type SetScalar (T val)
template<typename T>
std::enable_if< std::is_enum< T >::value, void >::type SetScalar (T val)
template<typename T>
std::enable_if< detail::StringLike< T >::owning, void >::type SetScalar (T val)
void SetScalar (const IRObject &obj)
Childrens GetChildren () const
void SetChildren (IRObject *children)

Static Public Member Functions

template<typename T>
static std::enable_if< std::is_integral< T >::value||std::is_floating_point< T >::value||detail::StringLike< T >::owning||std::is_enum< T >::value, IRObject >::type FromCorpus (T val)
template<typename T>
static std::enable_if< detail::is_container< T >::value &&!detail::StringLike< T >::owning, IRObject >::type FromCorpus (const T &val)
template<class TupType, unsigned... I>
static void handle_tuple (const TupType &_tup, IRObject *children, detail::seq< I... >)
template<typename... Args>
static IRObject FromCorpus (const std::tuple< Args... > &val)
template<typename T1, typename T2>
static IRObject FromCorpus (const std::pair< T1, T2 > &val)
template<typename T>
static std::enable_if< std::is_integral< T >::value||std::is_enum< T >::value, T >::type ToCorpus (const IRObject &obj)
template<typename T>
static std::enable_if< std::is_floating_point< T >::value, T >::type ToCorpus (const IRObject &obj)
template<typename T>
static std::enable_if< detail::StringLike< T >::owning, T >::type ToCorpus (const IRObject &obj)
template<typename TupType, unsigned... I>
static TupType parse_tuple (IRObject *children, detail::seq< I... >)
template<typename T>
static std::enable_if< detail::is_container< T >::value &&!detail::StringLike< T >::owning, T >::type ToCorpus (const IRObject &obj)
template<typename T>
static std::enable_if< detail::is_specialization< T, std::tuple >::value, T >::type ToCorpus (const IRObject &obj)
template<typename T>
static std::enable_if< detail::is_specialization< T, std::pair >::value, T >::type ToCorpus (const IRObject &obj)
static char * alloc_str (size_t size)
static IRObject * alloc (size_t size)
static zeroerr::String ToString (const IRObject &obj)
static IRObject FromString (zeroerr::String str)
static std::vector< uint8_t > ToBinary (IRObject obj)
static IRObject FromBinary (std::vector< uint8_t > bin)

Public Attributes

union { 
   int64_t   i 
   double   f 
   char *   s 
   char   ss [8] 
   IRObject *   o 
}; 
char others [7]
unsigned char type

Detailed Description

Interface for serializable objects.

IRObject (Intermediate Representation Object) provides a low-level interface for serializing data types into a common format. It uses a union to store different data types and provides type-safe access through templated getter methods.

The object can store:

  • Integers (int64_t)
  • Floating point numbers (double)
  • Strings (char* for long strings, char[8] for short strings)
  • Nested objects (IRObject*)

Memory management:

  • The object takes ownership of allocated strings and nested objects
  • Copy/move operations perform deep copies/moves
  • The destructor frees any owned memory

Usage example:

obj.i = 42;
int value = obj.GetScalar<int>(); // value = 42
IRObject() noexcept
Definition serialization.h:46
unsigned char type
Definition serialization.h:64
std::enable_if< std::is_integral< T >::value, T >::type GetScalar() const
Definition serialization.h:67
int64_t i
Definition serialization.h:57
@ Int
Definition serialization.h:54

Member Enumeration Documentation

◆ Type

Enumerator
Undefined 
Int 
Float 
String 
ShortString 
Object 

Constructor & Destructor Documentation

◆ IRObject() [1/3]

zeroerr::IRObject::IRObject ( )
inlinenoexcept

◆ ~IRObject()

zeroerr::IRObject::~IRObject ( )

◆ IRObject() [2/3]

zeroerr::IRObject::IRObject ( const IRObject & other)

◆ IRObject() [3/3]

zeroerr::IRObject::IRObject ( IRObject && other)
noexcept

Member Function Documentation

◆ alloc()

IRObject * zeroerr::IRObject::alloc ( size_t size)
static

◆ alloc_str()

char * zeroerr::IRObject::alloc_str ( size_t size)
static

◆ FromBinary()

IRObject zeroerr::IRObject::FromBinary ( std::vector< uint8_t > bin)
static

◆ FromCorpus() [1/4]

template<typename T1, typename T2>
IRObject zeroerr::IRObject::FromCorpus ( const std::pair< T1, T2 > & val)
inlinestatic

◆ FromCorpus() [2/4]

template<typename... Args>
IRObject zeroerr::IRObject::FromCorpus ( const std::tuple< Args... > & val)
inlinestatic

◆ FromCorpus() [3/4]

template<typename T>
std::enable_if< detail::is_container< T >::value &&!detail::StringLike< T >::owning, IRObject >::type zeroerr::IRObject::FromCorpus ( const T & val)
inlinestatic

◆ FromCorpus() [4/4]

template<typename T>
std::enable_if< std::is_integral< T >::value||std::is_floating_point< T >::value||detail::StringLike< T >::owning||std::is_enum< T >::value, IRObject >::type zeroerr::IRObject::FromCorpus ( T val)
inlinestatic

◆ FromString()

IRObject zeroerr::IRObject::FromString ( zeroerr::String str)
static

◆ GetChildren()

Childrens zeroerr::IRObject::GetChildren ( ) const
inline

◆ GetScalar() [1/4]

template<typename T>
std::enable_if< detail::StringLike< T >::owning, T >::type zeroerr::IRObject::GetScalar ( ) const
inline

◆ GetScalar() [2/4]

template<typename T>
std::enable_if< std::is_enum< T >::value, T >::type zeroerr::IRObject::GetScalar ( ) const
inline

◆ GetScalar() [3/4]

template<typename T>
std::enable_if< std::is_floating_point< T >::value, T >::type zeroerr::IRObject::GetScalar ( ) const
inline

◆ GetScalar() [4/4]

template<typename T>
std::enable_if< std::is_integral< T >::value, T >::type zeroerr::IRObject::GetScalar ( ) const
inline

◆ handle_tuple()

template<class TupType, unsigned... I>
void zeroerr::IRObject::handle_tuple ( const TupType & _tup,
IRObject * children,
detail::seq< I... >  )
inlinestatic

◆ operator=() [1/2]

IRObject & zeroerr::IRObject::operator= ( const IRObject & other)

◆ operator=() [2/2]

IRObject & zeroerr::IRObject::operator= ( IRObject && other)
noexcept

◆ parse_tuple()

template<typename TupType, unsigned... I>
TupType zeroerr::IRObject::parse_tuple ( IRObject * children,
detail::seq< I... >  )
inlinestatic

◆ Reset()

void zeroerr::IRObject::Reset ( )
noexcept

◆ SetChildren()

void zeroerr::IRObject::SetChildren ( IRObject * children)
inline

◆ SetScalar() [1/5]

void zeroerr::IRObject::SetScalar ( const IRObject & obj)
inline

◆ SetScalar() [2/5]

template<typename T>
std::enable_if< detail::StringLike< T >::owning, void >::type zeroerr::IRObject::SetScalar ( T val)
inline

◆ SetScalar() [3/5]

template<typename T>
std::enable_if< std::is_enum< T >::value, void >::type zeroerr::IRObject::SetScalar ( T val)
inline

◆ SetScalar() [4/5]

template<typename T>
std::enable_if< std::is_floating_point< T >::value, void >::type zeroerr::IRObject::SetScalar ( T val)
inline

◆ SetScalar() [5/5]

template<typename T>
std::enable_if< std::is_integral< T >::value, void >::type zeroerr::IRObject::SetScalar ( T val)
inline

◆ ToBinary()

std::vector< uint8_t > zeroerr::IRObject::ToBinary ( IRObject obj)
static

◆ ToCorpus() [1/6]

template<typename T>
std::enable_if< detail::is_specialization< T, std::pair >::value, T >::type zeroerr::IRObject::ToCorpus ( const IRObject & obj)
inlinestatic

◆ ToCorpus() [2/6]

template<typename T>
std::enable_if< detail::is_specialization< T, std::tuple >::value, T >::type zeroerr::IRObject::ToCorpus ( const IRObject & obj)
inlinestatic

◆ ToCorpus() [3/6]

template<typename T>
std::enable_if< detail::is_container< T >::value &&!detail::StringLike< T >::owning, T >::type zeroerr::IRObject::ToCorpus ( const IRObject & obj)
inlinestatic

◆ ToCorpus() [4/6]

template<typename T>
std::enable_if< detail::StringLike< T >::owning, T >::type zeroerr::IRObject::ToCorpus ( const IRObject & obj)
inlinestatic

◆ ToCorpus() [5/6]

template<typename T>
std::enable_if< std::is_floating_point< T >::value, T >::type zeroerr::IRObject::ToCorpus ( const IRObject & obj)
inlinestatic

◆ ToCorpus() [6/6]

template<typename T>
std::enable_if< std::is_integral< T >::value||std::is_enum< T >::value, T >::type zeroerr::IRObject::ToCorpus ( const IRObject & obj)
inlinestatic

◆ ToString()

zeroerr::String zeroerr::IRObject::ToString ( const IRObject & obj)
static

Member Data Documentation

◆ [union]

union { ... } zeroerr::IRObject

◆ f

double zeroerr::IRObject::f

◆ i

int64_t zeroerr::IRObject::i

◆ o

IRObject* zeroerr::IRObject::o

◆ others

char zeroerr::IRObject::others[7]

◆ s

char* zeroerr::IRObject::s

◆ ss

char zeroerr::IRObject::ss[8]

◆ type

unsigned char zeroerr::IRObject::type

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