Wolframe, 0.0.3

_Wolframe::serialize::StructDescriptionBase Class Reference

Base class for structure description used for introspection in serialization/deserialization. More...

#include <structDescriptionBase.hpp>

Inheritance diagram for _Wolframe::serialize::StructDescriptionBase:
_Wolframe::serialize::StructDescription< Structure >

Public Types

enum  ElementType { Atomic, Struct, Vector }
 Type of a structure element. More...
 
enum  ElementRequirement { NoRequirement, Mandatory, Optional }
 Constraints definition of a structure element. More...
 
typedef std::vector< std::pair
< std::string,
StructDescriptionBase > > 
Map
 
typedef bool(* Parse )(langbind::TypedInputFilter &flt, Context &ctx, ParseStateStack &stk)
 
typedef bool(* Fetch )(Context &ctx, SerializeStateStack &stk)
 
typedef bool(* Constructor )(void *obj)
 
typedef void(* Destructor )(void *obj)
 

Public Member Functions

Parse parse () const
 Non intrusive parser call function of this sructure. More...
 
Fetch fetch () const
 Non intrusive serializer call (fetch the next element) function of this sructure. More...
 
 StructDescriptionBase (Constructor c, Destructor d, const char *tn, std::size_t os, std::size_t sz, ElementType t, Parse pa, Fetch pr, ElementRequirement req_)
 Constructor. More...
 
 StructDescriptionBase (const char *tn, std::size_t os, std::size_t sz, ElementType t, Parse pa, Fetch pr, ElementRequirement req_)
 Constructor. More...
 
 StructDescriptionBase (const StructDescriptionBase &o)
 Copy constructor. More...
 
 StructDescriptionBase ()
 Default constructor. More...
 
bool parse (void *obj, langbind::TypedInputFilter &in, Context &ctx, ParseStateStack &stk) const
 Call of parser of the serialization passed to fill an object and validate the serialization sequence. More...
 
bool setAtomicValue (void *obj, std::size_t idx, const std::string &value) const
 Initializes an atomic element in a structure. More...
 
bool init (void *obj) const
 Initialize the structure referenced with 'obj'. More...
 
void done (void *obj) const
 Destroy the structure referenced with 'obj'. More...
 
std::size_t size () const
 Get the allocation size of this structure in bytes. More...
 
std::size_t ofs () const
 Get the offset of this structure inside the holding parent structure. More...
 
ElementType type () const
 Get the element kind (type of access) of this structure or atomic element. More...
 
Map::const_iterator find (const std::string &name) const
 Find an element in this structure by name. More...
 
Map::const_iterator find_cis (const std::string &name) const
 Case insensitive find an element in this structure by name. More...
 
std::string names (const char *sep) const
 Return the element names of this structure as string for error messages. More...
 
Map::const_iterator begin () const
 Get the start iterator on the elements of this structure. More...
 
Map::const_iterator end () const
 Get the end iterator on the elements of this structure. More...
 
void define (const std::string &name, const StructDescriptionBase &dd)
 Define an element of this structure. More...
 
std::size_t nof_attributes () const
 Get the number of attributes of a struct. More...
 
void defineEndOfAttributes ()
 Define the number of attributes of a struct. More...
 
std::size_t nof_elements () const
 Get the number of elements in the structure or array. More...
 
const char * typeName () const
 Get the type name of this structure. More...
 
bool mandatory () const
 Find out if the element in the structure is mandatory. More...
 
bool optional () const
 Find out if the element in the structure is optional. More...
 
void requirement (ElementRequirement requirement_)
 Set element occurrence requirement. More...
 

Protected Member Functions

StructDescriptionBaselast ()
 

Private Attributes

Constructor m_constructor
 
Destructor m_destructor
 
const char * m_typename
 
std::size_t m_ofs
 
std::size_t m_size
 
std::size_t m_nof_attributes
 
Map m_elem
 
ElementType m_type
 
Parse m_parse
 
Fetch m_fetch
 
ElementRequirement m_requirement
 

Detailed Description

Base class for structure description used for introspection in serialization/deserialization.

Member Typedef Documentation

typedef bool(* _Wolframe::serialize::StructDescriptionBase::Constructor)(void *obj)
typedef void(* _Wolframe::serialize::StructDescriptionBase::Destructor)(void *obj)
typedef bool(* _Wolframe::serialize::StructDescriptionBase::Fetch)(Context &ctx, SerializeStateStack &stk)
typedef std::vector<std::pair<std::string,StructDescriptionBase> > _Wolframe::serialize::StructDescriptionBase::Map
typedef bool(* _Wolframe::serialize::StructDescriptionBase::Parse)(langbind::TypedInputFilter &flt, Context &ctx, ParseStateStack &stk)

Member Enumeration Documentation

Constraints definition of a structure element.

Enumerator
NoRequirement 

no explicit condition

Mandatory 

element is always mandatory, even if structure is filled and validated in "relaxed" mode

Optional 

element is always optional, even if structure is filled and validated in "strict" mode

Type of a structure element.

Enumerator
Atomic 

Atomic element type.

Struct 

Structure with fixed number of named elements.

Vector 

Array of structures or atomic values.

Constructor & Destructor Documentation

_Wolframe::serialize::StructDescriptionBase::StructDescriptionBase ( Constructor  c,
Destructor  d,
const char *  tn,
std::size_t  os,
std::size_t  sz,
ElementType  t,
Parse  pa,
Fetch  pr,
ElementRequirement  req_ 
)

Constructor.

_Wolframe::serialize::StructDescriptionBase::StructDescriptionBase ( const char *  tn,
std::size_t  os,
std::size_t  sz,
ElementType  t,
Parse  pa,
Fetch  pr,
ElementRequirement  req_ 
)

Constructor.

_Wolframe::serialize::StructDescriptionBase::StructDescriptionBase ( const StructDescriptionBase o)

Copy constructor.

_Wolframe::serialize::StructDescriptionBase::StructDescriptionBase ( )

Default constructor.

Member Function Documentation

Map::const_iterator _Wolframe::serialize::StructDescriptionBase::begin ( ) const
inline

Get the start iterator on the elements of this structure.

void _Wolframe::serialize::StructDescriptionBase::define ( const std::string &  name,
const StructDescriptionBase dd 
)
inline

Define an element of this structure.

Remarks
Does not check for duplicate definitions
void _Wolframe::serialize::StructDescriptionBase::defineEndOfAttributes ( )
inline

Define the number of attributes of a struct.

Returns
the number of attributes or 0
Remarks
returns 0 this is not of type Struct
void _Wolframe::serialize::StructDescriptionBase::done ( void *  obj) const
inline

Destroy the structure referenced with 'obj'.

Map::const_iterator _Wolframe::serialize::StructDescriptionBase::end ( ) const
inline

Get the end iterator on the elements of this structure.

Fetch _Wolframe::serialize::StructDescriptionBase::fetch ( ) const
inline

Non intrusive serializer call (fetch the next element) function of this sructure.

Map::const_iterator _Wolframe::serialize::StructDescriptionBase::find ( const std::string &  name) const

Find an element in this structure by name.

Map::const_iterator _Wolframe::serialize::StructDescriptionBase::find_cis ( const std::string &  name) const

Case insensitive find an element in this structure by name.

bool _Wolframe::serialize::StructDescriptionBase::init ( void *  obj) const
inline

Initialize the structure referenced with 'obj'.

StructDescriptionBase& _Wolframe::serialize::StructDescriptionBase::last ( )
inlineprotected
bool _Wolframe::serialize::StructDescriptionBase::mandatory ( ) const
inline

Find out if the element in the structure is mandatory.

Returns
true, if yes
std::string _Wolframe::serialize::StructDescriptionBase::names ( const char *  sep) const

Return the element names of this structure as string for error messages.

std::size_t _Wolframe::serialize::StructDescriptionBase::nof_attributes ( ) const
inline

Get the number of attributes of a struct.

Remarks
returns 0 this is not of type (ContentType) Struct
Returns
the number of attributes or 0
std::size_t _Wolframe::serialize::StructDescriptionBase::nof_elements ( ) const
inline

Get the number of elements in the structure or array.

Returns
the number of elements or 0 in case of an atomic value
std::size_t _Wolframe::serialize::StructDescriptionBase::ofs ( ) const
inline

Get the offset of this structure inside the holding parent structure.

bool _Wolframe::serialize::StructDescriptionBase::optional ( ) const
inline

Find out if the element in the structure is optional.

Returns
true, if yes
Parse _Wolframe::serialize::StructDescriptionBase::parse ( ) const
inline

Non intrusive parser call function of this sructure.

bool _Wolframe::serialize::StructDescriptionBase::parse ( void *  obj,
langbind::TypedInputFilter in,
Context ctx,
ParseStateStack stk 
) const

Call of parser of the serialization passed to fill an object and validate the serialization sequence.

void _Wolframe::serialize::StructDescriptionBase::requirement ( ElementRequirement  requirement_)
inline

Set element occurrence requirement.

bool _Wolframe::serialize::StructDescriptionBase::setAtomicValue ( void *  obj,
std::size_t  idx,
const std::string &  value 
) const

Initializes an atomic element in a structure.

Remarks
Not very efficient implementation
std::size_t _Wolframe::serialize::StructDescriptionBase::size ( ) const
inline

Get the allocation size of this structure in bytes.

ElementType _Wolframe::serialize::StructDescriptionBase::type ( ) const
inline

Get the element kind (type of access) of this structure or atomic element.

const char* _Wolframe::serialize::StructDescriptionBase::typeName ( ) const
inline

Get the type name of this structure.

Member Data Documentation

Constructor _Wolframe::serialize::StructDescriptionBase::m_constructor
private
Destructor _Wolframe::serialize::StructDescriptionBase::m_destructor
private
Map _Wolframe::serialize::StructDescriptionBase::m_elem
private
Fetch _Wolframe::serialize::StructDescriptionBase::m_fetch
private
std::size_t _Wolframe::serialize::StructDescriptionBase::m_nof_attributes
private
std::size_t _Wolframe::serialize::StructDescriptionBase::m_ofs
private
Parse _Wolframe::serialize::StructDescriptionBase::m_parse
private
ElementRequirement _Wolframe::serialize::StructDescriptionBase::m_requirement
private
std::size_t _Wolframe::serialize::StructDescriptionBase::m_size
private
ElementType _Wolframe::serialize::StructDescriptionBase::m_type
private
const char* _Wolframe::serialize::StructDescriptionBase::m_typename
private

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