libgenua
Basic Geometry, Numerical Algorithms and Interfaces
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Groups Pages
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
TypeCode Class Reference

Detailed Description

Integer type code.

TypeCode is a single integer value containing a code which identifies a plain old data type. Its main purpose is to standardize the way binary data is tagged in files using integer or string code tags.

#include <typecode.h>

Inheritance diagram for TypeCode:
[legend]
Collaboration diagram for TypeCode:
[legend]

Public Member Functions

 TypeCode ()
 create undefined code object
 
 TypeCode (int v)
 create a defined object
 
bool operator== (const TypeCode &c) const
 equivalence
 
bool operator!= (const TypeCode &c) const
 equivalence
 
const char * toString () const
 string representation of current code value
 
int value () const
 access value
 
int width () const
 width of the type in bytes
 
bool isReal () const
 type is real-valued, but not complex
 
bool isComplex () const
 type is complex-valued
 
bool isInt () const
 type is integer
 
bool isString () const
 type is string
 
bool compatible (TypeCode a) const
 tests if value conversion will succeed
 
template<typename ValueType >
bool extract (const char *raw, ValueType &x) const
 convert from memory location to value
 
template<typename ValueType >
bool extract (size_t nval, const char *raw, ValueType dst[]) const
 copy with value conversion, assuming dst has enough space
 
template<typename IndexType , typename ValueType >
bool extract (size_t nidx, const IndexType idx[], const char *raw, ValueType dst[]) const
 copy with value conversion, assuming dst has enough space
 
template<typename ValueType >
bool inject (size_t nval, const ValueType a[], char *dst) const
 copy with value conversion, assuming dst has enough space
 
bool toXmlBlock (XmlElement &xe, size_t nval, const char *ptr, bool share) const
 create a data block in XML element
 
bool fromXmlBlock (const XmlElement &xe, size_t nval, char *ptr)
 retrieve a data block from XML element
 

Static Public Member Functions

static int width (int code)
 width of the type in bytes
 
static TypeCode fromString (const std::string &s)
 create type code from string
 
template<typename PodType >
static TypeCode of ()
 generate type code at compile time
 
template<typename SrcType , typename DstType >
static DstType recast (const char *raw, size_t i)
 type conversion, general form
 
template<typename SrcType , typename DstType >
static void copy (const char *raw, size_t nval, DstType *dst)
 type conversion, general form
 
static bool fromString (const char *s, char **tail, int &value)
 utility overload
 
static bool fromString (const char *s, char **tail, uint &value)
 utility overload
 
static bool fromString (const char *s, char **tail, int8_t &value)
 utility overload
 
static bool fromString (const char *s, char **tail, uint8_t &value)
 utility overload
 
static bool fromString (const char *s, char **tail, int16_t &value)
 utility overload
 
static bool fromString (const char *s, char **tail, uint16_t &value)
 utility overload
 
static bool fromString (const char *s, char **tail, int64_t &value)
 utility overload
 
static bool fromString (const char *s, char **tail, uint64_t &value)
 utility overload
 
static bool fromString (const char *s, char **tail, double &value)
 utility overload
 
static bool fromString (const char *s, char **tail, float &value)
 utility overload
 
- Static Public Member Functions inherited from EnumObject< 15 >
static int nkeys ()
 number of keys defined
 

Private Attributes

TypeCode::Code ivalue
 integer code
 

Static Private Attributes

static const char * keylist []
 type names
 

Additional Inherited Members

- Static Protected Member Functions inherited from EnumObject< 15 >
static uint findKey (const char *begin, const char *end, const char *keylist[])
 return the index of the key in keylist which is contained in (begin,end)
 

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