Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
GrayLib::cVariantData Class Reference

#include <cVariantData.h>

Inheritance diagram for GrayLib::cVariantData:
GrayLib::cVariantCommon GrayLib::cVariant

Public Member Functions

cVariantArraydref_Array () const
 
cVariantArrayTdref_ArrayT () const
 
const cAtomRefdref_Atom () const
 
const cStringAdref_String () const
 
const cStringWdref_StringW () const
 
cHeapBlockdref_Blob () const
 
cVariantMapPtrdref_Map () const
 
CIXObjPtrdref_XObj () const
 
HRESULT SerializeOutputType (cStreamOutput &file, VARTYPE_TYPE eVarType) const
 
HRESULT SerializeInputType (cStreamInput &file, VARTYPE_TYPE eVarType)
 

Static Public Member Functions

static const cVariantTypeDefGetVarTypeDef (VARTYPE_TYPE eVarType) noexcept
 
static bool GRAYCALL IsVarTypeCompatible (VARTYPE_TYPE eVarType1, VARTYPE_TYPE eVarType2)
 
static COMPARE_t GRAYCALL CompareDataPtr (VARTYPE_TYPE eVarType, const void *pData1, const void *pData2)
 
static bool IsXObj (VARTYPE_TYPE eVarType) noexcept
 
- Static Public Member Functions inherited from GrayLib::cVariantCommon
static StrLen_t GRAYCALL CopyLenQ (ATOMCHAR_t *pszDst, const ATOMCHAR_t *pszSrc, StrLen_t iLenMax, STR_BLOCK_TYPE eBlock)
 When converting to string. More...
 

Public Attributes

union {
m_u
 

Static Public Attributes

static const cVariantTypeDef k_VarTypeDef [VARTYPE_QTY]
 type metadata. More...
 
static IXObjMgrsm_pIXObjMgr = nullptr
 For cVariant UID to XObject conversion. More...
 
static bool sm_bShowUnsignedAsHex = true
 show unsigned as hex when converting to string. default=true More...
 
- Static Public Attributes inherited from GrayLib::cVariantCommon
static const ITERATE_t k_MaxElements = 64*1024
 (arbitrary) Max elements that may be parsed in array or map. More...
 
static const ITERATE_t k_MaxElements2 = 256
 arbitrary max for simple things. More...
 
static const CYS_t k_CYSMul = 100
 2 fixed places = cents. CYS_t More...
 
static const CY_t k_CYMul = 10000
 4 fixed places = hundredths of a cent. CY_t More...
 

Protected Member Functions

void DestructData (VARTYPE_TYPE eVarType)
 
void construct_Array (ITERATE_t iSize)
 
void construct_Array (const cVariantArray &a)
 
void construct_ArrayT (ITERATE_t iSize, VARTYPE_TYPE eVarTypeElem)
 
void construct_ArrayT (const cVariantArrayT &a)
 
void construct_Atom (const cAtomRef &a)
 
void construct_Atom (const ATOMCHAR_t *p)
 
void construct_String (const cStringA &s)
 
void construct_String (const char *pszVal)
 
void construct_StringW (const cStringW &s)
 
void construct_StringW (const wchar_t *pwVal)
 
void construct_Blob (const void *pData, size_t nSize)
 
void construct_Blob (const cHeapBlock &b)
 
void construct_Map (cVariantMap *p)
 
void construct_XObj (IXObject *p)
 
size_t GetDataSize (VARTYPE_TYPE eVarType) const
 
const void * GetDataPtr (VARTYPE_TYPE eVarType) const
 
size_t GetHeapStats (VARTYPE_TYPE eVarType, OUT ITERATE_t &iAllocCount) const
 
bool IsEmptyVar (VARTYPE_TYPE eVarType) const
 
bool IsZeroVar (VARTYPE_TYPE eVarType) const
 
void InitZeroVar (VARTYPE_TYPE eVarType)
 
void InitVar (VARTYPE_TYPE eVarType, const cVariantData &vVal)
 
StrLen_t GetStr_Array (ATOMCHAR_t *pszStr, StrLen_t iLenMax) const
 
StrLen_t GetStr_ArrayT (ATOMCHAR_t *pszStr, StrLen_t iLenMax) const
 
StrLen_t GetStr_CY (ATOMCHAR_t *pszStr, StrLen_t iLenMax) const
 
StrLen_t GetStr_CYS (ATOMCHAR_t *pszStr, StrLen_t iLenMax) const
 
StrLen_t GetStr_Blob (ATOMCHAR_t *pszStr, StrLen_t nLenMax) const
 
StrLen_t GetStr_HResult (ATOMCHAR_t *pszStr, StrLen_t iLenMax, bool bQuote=true) const
 
StrLen_t GetStrExpT (VARTYPE_TYPE eVarType, ATOMCHAR_t *pszStr, StrLen_t iLenMax, bool bInArray=true) const
 

Friends

class cVariantArrayT
 

Additional Inherited Members

- Public Types inherited from GrayLib::cVariantCommon
typedef INT32 CYS_t
 type for 2 fixed point int for currency/money. More...
 
typedef INT64 CY_t
 type for 4 fixed point int for currency/money. More...
 

Detailed Description

The 'value' (or data) portion of the variant. union of all supported data types. VARTYPE_TYPE MUST be known and ASSUMED to use this directly. _WIN32 max inline data size = 12 bytes = 3 * sizeof(UINT) like tagVARIANT = COM sizeof(VARIANT) = 16 bytes (_WIN32)

Member Function Documentation

◆ CompareDataPtr()

COMPARE_t GRAYCALL GrayLib::cVariantData::CompareDataPtr ( VARTYPE_TYPE  eVarType,
const void *  pData1,
const void *  pData2 
)
static

With 2 pointers assumed to point at variants data. used with Blob, get_DataPtr(), get_DataSize() NOT the same as serialize. Dangerous. mostly used for cStructElem. (with some exceptions)

Returns
0 = match,

◆ construct_Array() [1/2]

void GrayLib::cVariantData::construct_Array ( const cVariantArray a)
protected

VARTYPE_Array

◆ construct_Array() [2/2]

void GrayLib::cVariantData::construct_Array ( ITERATE_t  iSize)
protected

VARTYPE_Array

◆ construct_ArrayT() [1/2]

void GrayLib::cVariantData::construct_ArrayT ( const cVariantArrayT a)
protected

VARTYPE_ArrayT

◆ construct_ArrayT() [2/2]

void GrayLib::cVariantData::construct_ArrayT ( ITERATE_t  iSize,
VARTYPE_TYPE  eVarTypeElem 
)
protected

VARTYPE_ArrayT

◆ construct_Atom() [1/2]

void GrayLib::cVariantData::construct_Atom ( const ATOMCHAR_t p)
protected

VARTYPE_Atom

◆ construct_Atom() [2/2]

void GrayLib::cVariantData::construct_Atom ( const cAtomRef a)
protected

VARTYPE_Atom

◆ construct_Blob() [1/2]

void GrayLib::cVariantData::construct_Blob ( const cHeapBlock b)
protected

VARTYPE_GUID VARTYPE_Blob

◆ construct_Blob() [2/2]

void GrayLib::cVariantData::construct_Blob ( const void *  pData,
size_t  nSize 
)
protected

VARTYPE_GUID VARTYPE_Blob

◆ construct_Map()

void GrayLib::cVariantData::construct_Map ( cVariantMap p)
protected

VARTYPE_Map

◆ construct_String() [1/2]

void GrayLib::cVariantData::construct_String ( const char *  pszVal)
protected

VARTYPE_StringExp VARTYPE_String

◆ construct_String() [2/2]

void GrayLib::cVariantData::construct_String ( const cStringA s)
protected

VARTYPE_StringExp VARTYPE_String

◆ construct_StringW() [1/2]

void GrayLib::cVariantData::construct_StringW ( const cStringW s)
protected

VARTYPE_StringW

◆ construct_StringW() [2/2]

void GrayLib::cVariantData::construct_StringW ( const wchar_t *  pwVal)
protected

VARTYPE_StringW

◆ construct_XObj()

void GrayLib::cVariantData::construct_XObj ( IXObject p)
protected

VARTYPE_XObj

◆ DestructData()

void GrayLib::cVariantData::DestructData ( VARTYPE_TYPE  eVarType)
protected

Destroy the contents.

◆ dref_Array()

cVariantArray & GrayLib::cVariantData::dref_Array ( ) const

ASSUME VARTYPE_Array:

◆ dref_ArrayT()

cVariantArrayT & GrayLib::cVariantData::dref_ArrayT ( ) const

ASSUME VARTYPE_ArrayT:

◆ dref_Atom()

const cAtomRef & GrayLib::cVariantData::dref_Atom ( ) const

ASSUME VARTYPE_Atom

◆ dref_Blob()

cHeapBlock & GrayLib::cVariantData::dref_Blob ( ) const

ASSUME VARTYPE_Blob, VARTYPE_GUID

◆ dref_Map()

cVariantMapPtr & GrayLib::cVariantData::dref_Map ( ) const

ASSUME VARTYPE_Map

◆ dref_String()

const cStringA & GrayLib::cVariantData::dref_String ( ) const

ASSUME VARTYPE_StringExp VARTYPE_String:

◆ dref_StringW()

const cStringW & GrayLib::cVariantData::dref_StringW ( ) const

ASSUME VARTYPE_StringW:

◆ dref_XObj()

CIXObjPtr & GrayLib::cVariantData::dref_XObj ( ) const

ASSUME VARTYPE_XObj

◆ GetDataPtr()

const void * GrayLib::cVariantData::GetDataPtr ( VARTYPE_TYPE  eVarType) const
protected

Get a raw generic pointer to data. NOT always the same as &m_u if CTYPE_FLAG_Alloc type. used with GetDataSize, Blob, get_DataSize(), CompareDataPtr() NOT the same as serialize.

◆ GetDataSize()

size_t GrayLib::cVariantData::GetDataSize ( VARTYPE_TYPE  eVarType) const
protected

Get size of the actual data. (Not ref if CTYPE_FLAG_Alloc) used with GetDataPtr, Blob, get_DataPtr(), CompareDataPtr() NOT the same as serialize size. Like GetHeapStats ?

◆ GetHeapStats()

size_t GrayLib::cVariantData::GetHeapStats ( VARTYPE_TYPE  eVarType,
OUT ITERATE_t iAllocCount 
) const
protected
Returns
size in bytes used by this. Not the same as serialization size.

◆ GetStr_Array()

StrLen_t GrayLib::cVariantData::GetStr_Array ( ATOMCHAR_t pszStr,
StrLen_t  iLenMax 
) const
protected

VARTYPE_Array Convert the array to a string (comma separated values). assume symmetrical re-parse as array.

  • iMaxSize = includes room for '\0'. (just like memcpy) so iMaxSize=sizeof(Dst) is OK !

◆ GetStr_ArrayT()

StrLen_t GrayLib::cVariantData::GetStr_ArrayT ( ATOMCHAR_t pszStr,
StrLen_t  iLenMax 
) const
protected

VARTYPE_ArrayT Convert the array to a string (comma separated values). assume symmetrical re-parse as array.

  • iMaxSize = includes room for '\0'. (just like memcpy) so iMaxSize=sizeof(Dst) is OK !

◆ GetStr_Blob()

StrLen_t GrayLib::cVariantData::GetStr_Blob ( ATOMCHAR_t pszStr,
StrLen_t  nLenMax 
) const
protected

VARTYPE_Blob, VARTYPE_GUID Get an encoded string for binary blob data. Just a VARTYPE_StringExp

  1. Base64 string.
  2. "plain string". (if the chars are in valid range)

◆ GetStr_CY()

StrLen_t GrayLib::cVariantData::GetStr_CY ( ATOMCHAR_t pszStr,
StrLen_t  iLenMax 
) const
protected

VARTYPE_CY into a string

Returns
String length

◆ GetStr_CYS()

StrLen_t GrayLib::cVariantData::GetStr_CYS ( ATOMCHAR_t pszStr,
StrLen_t  iLenMax 
) const
protected

VARTYPE_CYS into a string

Returns
String length

◆ GetStr_HResult()

StrLen_t GrayLib::cVariantData::GetStr_HResult ( ATOMCHAR_t pszStr,
StrLen_t  iLenMax,
bool  bQuote = true 
) const
protected

VARTYPE_HResult Describe the HRESULT error code.

◆ GetStrExpT()

StrLen_t GrayLib::cVariantData::GetStrExpT ( VARTYPE_TYPE  eVarType,
ATOMCHAR_t pszStr,
StrLen_t  iLenMax,
bool  bInArray = true 
) const
protected

Make the value (or best representation we can make of it) into the string. GetStrExpUnk result is VARTYPE_StringExp that may be used with put_StrExpUnk() etc. Quote strings if it seems reasonable.

  • iMaxSize = includes room for '\0'. (just like memcpy) so iMaxSize=sizeof(Dst) is OK ! bInArray = make this re-parsable via put_StrExpUnk() inside an array. e.g. Dates MUST be quoted.
    Note
    ASSUME a max allowed string size of StrT::k_LEN_MAX
    Returns
    the length of the string.

◆ GetVarTypeDef()

static const cVariantTypeDef& GrayLib::cVariantData::GetVarTypeDef ( VARTYPE_TYPE  eVarType)
inlinestaticnoexcept

Get the cVariantTypeDef metadata for the VARTYPE_TYPE.

◆ InitVar()

void GrayLib::cVariantData::InitVar ( VARTYPE_TYPE  eVarType,
const cVariantData vVal 
)
protected

Copy from another cVariantData.

Note
Internal call that does not properly clear previous *this !!!

◆ InitZeroVar()

void GrayLib::cVariantData::InitZeroVar ( VARTYPE_TYPE  eVarType)
protected

Set a zero value of a specific VARTYPE_TYPE. Compliment of isZeroVar()

Note
Does not destruct previous contents !

◆ IsEmptyVar()

bool GrayLib::cVariantData::IsEmptyVar ( VARTYPE_TYPE  eVarType) const
protected

Not isNoType() but nearly the same. i.e. empty string or array. Null but it has Type info. nothing of any real value here?

◆ IsVarTypeCompatible()

bool GRAYCALL GrayLib::cVariantData::IsVarTypeCompatible ( VARTYPE_TYPE  eVarType1,
VARTYPE_TYPE  eVarType2 
)
static

Can the 2 types be interchanged in general. ignore overflow/range issues. Numbers, strings, times

◆ IsXObj()

static bool GrayLib::cVariantData::IsXObj ( VARTYPE_TYPE  eVarType)
inlinestaticnoexcept

◆ IsZeroVar()

bool GrayLib::cVariantData::IsZeroVar ( VARTYPE_TYPE  eVarType) const
protected

All EmptyVar(s) are also ZeroVar(s) but not all zero is empty. Opposite of SetZeroVar();

◆ SerializeInputType()

HRESULT GrayLib::cVariantData::SerializeInputType ( cStreamInput file,
VARTYPE_TYPE  eVarType 
)

Read data from a known/assumed VARTYPE_TYPE eVarType. ASSUME: any previous contents are already freed.

  • eVarType = assume the data was stored of eVarType VARTYPE_TYPE
    Returns
    VARTYPE_TYPE = good. enough data. translated to this type. <0 = error or out of data in input stream.

◆ SerializeOutputType()

HRESULT GrayLib::cVariantData::SerializeOutputType ( cStreamOutput file,
VARTYPE_TYPE  eVarType 
) const

write out (binary format) just the data (m_u) and assume we already know the VARTYPE_TYPE. must match get_DataSize()

Note
cVariant serialization should NEVER change.
  • eVarType = assume the data was stored of eVarType VARTYPE_TYPE

Friends And Related Function Documentation

◆ cVariantArrayT

friend class cVariantArrayT
friend

Member Data Documentation

◆ k_VarTypeDef

const cVariantTypeDef GrayLib::cVariantData::k_VarTypeDef
static
Initial value:
=
{
{ "NoType", 0, 0 },
#define cVariantTypeDEF(a,b,c,d,e,f)
}

type metadata.

◆ 

union { ... } GrayLib::cVariantData::m_u

◆ sm_bShowUnsignedAsHex

bool GrayLib::cVariantData::sm_bShowUnsignedAsHex = true
static

show unsigned as hex when converting to string. default=true

For looking up UID as XObject. GRAYLIB_LINK cXObjMgr::isSingleCreated()

◆ sm_pIXObjMgr

IXObjMgr * GrayLib::cVariantData::sm_pIXObjMgr = nullptr
static

For cVariant UID to XObject conversion.


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