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 , Int , Float , String ,
  ShortString , Object
}
 

Public Member Functions

 IRObject ()
 
 ~IRObject ()
 
 IRObject (const IRObject &other)
 
 IRObject (IRObject &&other)
 
IRObjectoperator= (const IRObject &other)
 
IRObjectoperator= (IRObject &&other)
 
template<typename T >
std::enable_if< std::is_integral< T >::value, T >::type GetScalar ()
 
template<typename T >
std::enable_if< std::is_floating_point< T >::value, T >::type GetScalar ()
 
template<typename T >
std::enable_if< std::is_enum< T >::value, T >::type GetScalar ()
 
template<typename T >
std::enable_if< std::is_same< T, std::string >::value, T >::type GetScalar ()
 
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< std::is_same< T, std::string >::value, void >::type SetScalar (T val)
 
void SetScalar (const IRObject &obj)
 
Childrens GetChildren ()
 
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||std::is_same< T, std::string >::value||std::is_enum< T >::value, IRObject >::type FromCorpus (T val)
 
template<typename T >
static std::enable_if< detail::is_container< T >::value &&!std::is_same< T, std::string >::value, 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 (IRObject obj)
 
template<typename T >
static std::enable_if< std::is_floating_point< T >::value, T >::type ToCorpus (IRObject obj)
 
template<typename T >
static std::enable_if< std::is_same< T, std::string >::value, T >::type ToCorpus (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 &&!std::is_same< T, std::string >::value, T >::type ToCorpus (IRObject obj)
 
template<typename T >
static std::enable_if< detail::is_specialization< T, std::tuple >::value, T >::type ToCorpus (IRObject obj)
 
template<typename T >
static std::enable_if< detail::is_specialization< T, std::pair >::value, T >::type ToCorpus (IRObject obj)
 
static char * alloc_str (size_t size)
 
static IRObjectalloc (size_t size)
 
static std::string ToString (IRObject obj)
 
static IRObject FromString (std::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 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
Interface for serializable objects.
Definition serialization.h:43
int64_t i
Definition serialization.h:61
std::enable_if< std::is_integral< T >::value, T >::type GetScalar()
Definition serialization.h:71
@ Int
Definition serialization.h:58
unsigned type
Definition serialization.h:68

Member Enumeration Documentation

◆ Type

Enumerator
Undefined 
Int 
Float 
String 
ShortString 
Object 

Constructor & Destructor Documentation

◆ IRObject() [1/3]

zeroerr::IRObject::IRObject ( )
inline

◆ ~IRObject()

zeroerr::IRObject::~IRObject ( )
inline

◆ IRObject() [2/3]

zeroerr::IRObject::IRObject ( const IRObject other)
inline

◆ IRObject() [3/3]

zeroerr::IRObject::IRObject ( IRObject &&  other)
inline

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 >
static IRObject zeroerr::IRObject::FromCorpus ( const std::pair< T1, T2 > &  val)
inlinestatic

◆ FromCorpus() [2/4]

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

◆ FromCorpus() [3/4]

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

◆ FromCorpus() [4/4]

template<typename T >
static std::enable_if< std::is_integral< T >::value||std::is_floating_point< T >::value||std::is_same< T, std::string >::value||std::is_enum< T >::value, IRObject >::type zeroerr::IRObject::FromCorpus ( val)
inlinestatic

◆ FromString()

IRObject zeroerr::IRObject::FromString ( std::string  str)
static

◆ GetChildren()

Childrens zeroerr::IRObject::GetChildren ( )
inline

◆ GetScalar() [1/4]

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

◆ GetScalar() [2/4]

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

◆ GetScalar() [3/4]

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

◆ GetScalar() [4/4]

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

◆ handle_tuple()

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

◆ operator=() [1/2]

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

◆ operator=() [2/2]

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

◆ parse_tuple()

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

◆ 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< std::is_integral< T >::value, void >::type zeroerr::IRObject::SetScalar ( val)
inline

◆ SetScalar() [3/5]

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

◆ SetScalar() [4/5]

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

◆ SetScalar() [5/5]

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

◆ ToBinary()

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

◆ ToCorpus() [1/6]

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

◆ ToCorpus() [2/6]

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

◆ ToCorpus() [3/6]

template<typename T >
static std::enable_if< std::is_same< T, std::string >::value, T >::type zeroerr::IRObject::ToCorpus ( IRObject  obj)
inlinestatic

◆ ToCorpus() [4/6]

template<typename T >
static std::enable_if< detail::is_container< T >::value &&!std::is_same< T, std::string >::value, T >::type zeroerr::IRObject::ToCorpus ( IRObject  obj)
inlinestatic

◆ ToCorpus() [5/6]

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

◆ ToCorpus() [6/6]

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

◆ ToString()

std::string zeroerr::IRObject::ToString ( 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 zeroerr::IRObject::type

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