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

#include <cVariant.h>

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

Public Member Functions

 cVariant () noexcept
 
 cVariant (const ATOMCHAR_t **ppArrayArgs, ITERATE_t iArgQty)
 
 cVariant (const cVariantArray &aVals)
 
 cVariant (const cVariantArrayT &aVals)
 
 cVariant (const cAtomRef &atomVal)
 
 cVariant (const cStringA &strAVal)
 
 cVariant (const cStringW &strWVal)
 
 cVariant (const char *pszVal)
 
 cVariant (const wchar_t *pwsVal)
 store as cString. More...
 
 cVariant (const cTimeInt &timei)
 BSTR. More...
 
 cVariant (const cTimeDouble &timed)
 
 cVariant (const GUID &guid)
 
 cVariant (const cVarMap &rMap)
 
 cVariant (cVariantMap *pMap)
 
 cVariant (IXObject *pXObj)
 
 cVariant (VARTYPE_TYPE eVarType, UINT32 uVal)
 
 cVariant (VARTYPE_TYPE eVarType, UINT64 uVal)
 
 cVariant (VARTYPE_TYPE eVarType, const void *pvData, size_t nLen=0)
 
 cVariant (const THIS_t &vVal)
 
 cVariant (THIS_t &&ref) noexcept
 
 ~cVariant ()
 
size_t GetHeapStats (OUT ITERATE_t &iAllocCount) const
 
VARTYPE_TYPE get_VarType () const noexcept
 
const cVariantTypeDefget_VarTypeDef () const noexcept
 
bool isNoType () const noexcept
 
bool isVarTypeNumeric () const noexcept
 
bool isVarTypeFloat () const noexcept
 
bool isVarTypeString () const noexcept
 
bool isNumSigned () const noexcept
 
bool isStringA () const noexcept
 UTF8 format string. char*. More...
 
bool isStringW () const noexcept
 UNICODE format string. wchar_t*. More...
 
bool isTime () const noexcept
 a time stamp? More...
 
bool isArray () const noexcept
 
bool isStringExp () const noexcept
 
bool isXObj () const noexcept
 
bool isHResult () const noexcept
 
size_t get_DataSize () const
 
const void * get_DataPtr () const
 
COMPARE_t Compare (const cVariant &vVar) const
 
bool IsEqualTo (const THIS_t &vVar) const
 
bool operator== (const THIS_t &vVar) const
 
bool operator!= (const THIS_t &vVar) const
 
bool isHResultError () const
 
bool isEmptyVar () const
 
bool isZeroVar () const
 Not exactly VARTYPE_NoType but nearly the same. i.e. empty string or array. More...
 
void SetZeroVar (VARTYPE_TYPE eVarType=VARTYPE_NoType)
 All isEmptyVar(s) are also isZeroVar(s) More...
 
void SetNoType ()
 empty example of the type. More...
 
void SetClear ()
 
void put_Var (const cVariant &vVar)
 
void SetVarData (VARTYPE_TYPE eVarType, const void *pData, size_t iLen)
 
bool SetVarType (VARTYPE_TYPE eVarType, const cVariant &vVal)
 
const char * get_StrCA () const
 
void put_StrCA (const char *x)
 
const wchar_t * get_StrCW () const
 constant string. DANGEROUS?! (string must persist) More...
 
void put_StrCW (const wchar_t *x)
 
const GChar_tget_StrC () const
 constant string. DANGEROUS?! (string must persist) More...
 
void put_StrC (const GChar_t *x)
 
cAtomRef get_Atom () const
 
void put_Atom (cAtomRef x)
 
cString get_Str () const
 
void put_Str (cString x)
 
cStringA get_StrA () const
 
void put_StrA (cStringA x)
 
cStringW get_StrW () const
 
void put_StrW (cStringW x)
 
cStringA get_StrExp () const
 
void put_StrExp (cStringA x)
 
double get_TimeDouble () const
 
void put_TimeDouble (double x)
 
TIMESEC_t get_TimeInt () const
 
void put_TimeInt (TIMESEC_t x)
 
CYS_t get_CYS () const
 
void put_CYS (CYS_t x)
 
CY_t get_CY () const
 
void put_CY (CY_t x)
 
UID_t get_UID () const
 
void put_UID (UID_t x)
 
HRESULT get_HResult () const
 
void put_HResult (HRESULT x)
 
COLORREF get_Color () const
 
void put_Color (COLORREF x)
 
cVariantVector3< float > get_Vector3 () const
 
void put_Vector3 (const float *x)
 
void put_Int (int nVal)
 
int get_Int () const
 
template<typename _TYPE_CH >
cStringT< _TYPE_CH > get_StrT () const
 
void put_UID (const IXObject *pXObj)
 
void put_Array (const cVariantArray &aVars)
 
void put_ArrayT (const cVariantArrayT &aVals)
 
void put_Vector3 (float x, float y, float z)
 
IXObjectget_XObj () const
 
void put_XObj (IXObject *pXObj)
 
void SetTimeIntNow ()
 
void SetTimeDoubleNow ()
 
void StrExpIgnore ()
 Convert VARTYPE_StringExp to VARTYPE_String. More...
 
void SetVarTypeSimplest (bool bKeepFloat)
 
HRESULT put_StrExpUnk (const ATOMCHAR_t *pStrExp)
 partially parse an expression string. (if simple types) More...
 
HRESULT put_StrExpEval (const ATOMCHAR_t *pStrExp)
 
cVariant get_VarExpEval () const
 
StrLen_t GetStrExpUnk (ATOMCHAR_t *pszStr, StrLen_t iLenMax, bool bInArray=false) const
 
CY_t GetCY (bool bAssumeNaked=false, CY_t uValMul=k_CYMul) const
 
void SetBlobData (const void *pData, size_t nSize, VARTYPE_TYPE eVarType=VARTYPE_Blob)
 
void put_Blob (const cHeapBlock &b, VARTYPE_TYPE eVarType=VARTYPE_Blob)
 
size_t GetBlobData (void *pData, size_t nSizeMax) const
 
size_t SetBlobStr (VARTYPE_TYPE eVarType, const ATOMCHAR_t *pszStr)
 
cHeapBlockMakeRefBlob (VARTYPE_TYPE eVarType)
 
 operator const char * () const
 
const THIS_toperator= (const char *x)
 
 operator const wchar_t * () const
 
const THIS_toperator= (const wchar_t *x)
 
 operator cStringA () const
 
const THIS_toperator= (const cStringA &x)
 
 operator cStringW () const
 
const THIS_toperator= (const cStringW &x)
 
const THIS_toperator= (const THIS_t &vVal)
 
void SetMove (THIS_t &ref)
 
THIS_toperator= (THIS_t &&ref)
 
void put_Map (cVariantMap *pMap)
 Map helpers. More...
 
const cVariantGetMapVar (const ATOMCHAR_t *pszName) const
 
cVariantMapPtr MakeMap ()
 
cVariantMakeMapVar (const ATOMCHAR_t *pszName)
 
HRESULT SetMapVar (const ATOMCHAR_t *pszName, const cVariant &vSet)
 
const THIS_toperator[] (const ATOMCHAR_t *pszName) const
 
THIS_toperator[] (const ATOMCHAR_t *pszName)
 
ITERATE_t get_ArraySize () const
 Array helpers. Use of these indicates it should be converted to an array! More...
 
ITERATE_t MakeArraySize (bool bBreakQuotes=false)
 Parse also ! More...
 
THIS_tMakeArrayElement (ITERATE_t index=k_ITERATE_BAD)
 
cVariantArrayMakeArray ()
 
bool IsArrayChild (const cVariant &vVal) const
 
ITERATE_t SetArray (const ATOMCHAR_t **ppArgs, ITERATE_t iArgQty, ITERATE_t nQtyAppend=0)
 
ITERATE_t SetArrayParse (const ATOMCHAR_t *pszStr)
 
void RemoveArrayElement (ITERATE_t index, ITERATE_t iQty=1)
 
bool InsertArrayElement (ITERATE_t index, const cVariant &vVal)
 
double get_ArrayRangeDouble () const
 
ITERATE_t AppendArray (cVariant &vValArray)
 Append a variant array to the array. More...
 
const THIS_tGetArrayElement (ITERATE_t index) const
 
const THIS_toperator[] (ITERATE_t index) const
 
bool SetArrayElement (ITERATE_t index, const cVariant &vVal)
 
void AddArrayElement (const THIS_t &vVal)
 
THIS_toperator[] (ITERATE_t index)
 
void SetArrayStrCA (ITERATE_t index, const char *Val)
 
void AddArrayStrCA (const char *Val)
 
void SetArrayStrCW (ITERATE_t index, const wchar_t *Val)
 
void AddArrayStrCW (const wchar_t *Val)
 
void SetArrayStrC (ITERATE_t index, const GChar_t *Val)
 
void AddArrayStrC (const GChar_t *Val)
 
void SetArrayAtom (ITERATE_t index, cAtomRef Val)
 
void AddArrayAtom (cAtomRef Val)
 
void SetArrayStr (ITERATE_t index, cString Val)
 
void AddArrayStr (cString Val)
 
void SetArrayStrA (ITERATE_t index, cStringA Val)
 
void AddArrayStrA (cStringA Val)
 
void SetArrayStrW (ITERATE_t index, cStringW Val)
 
void AddArrayStrW (cStringW Val)
 
void SetArrayStrExp (ITERATE_t index, cStringA Val)
 
void AddArrayStrExp (cStringA Val)
 
void SetArrayUID (ITERATE_t index, UID_t Val)
 
void AddArrayUID (UID_t Val)
 
void SetArrayTimeInt (ITERATE_t index, TIMESEC_t Val)
 
void AddArrayTimeInt (TIMESEC_t Val)
 
void SetArrayVector3 (ITERATE_t index, const float *Val)
 
void AddArrayVector3 (const float *Val)
 
void SetArrayInt (ITERATE_t index, int Val)
 
void AddArrayInt (int Val)
 
void SetArrayXObj (ITERATE_t index, IXObject *Val)
 
void AddArrayXObj (IXObject *Val)
 
void AddArrayUID (const IXObject *pObj)
 
HRESULT SerializeOutput (cStreamOutput &file) const
 Serialize out/in to a byte stream. More...
 
HRESULT SerializeInputType (cStreamInput &file, VARTYPE_TYPE eVarType)
 
HRESULT SerializeInput (cStreamInput &file)
 
HRESULT Serialize (cArchive &a)
 
 UNITTEST_FRIEND (cVariant)
 
template<>
cStringT< char > get_StrT () const
 
template<>
cStringT< wchar_t > get_StrT () const
 
- Public Member Functions inherited from GrayLib::cVariantData
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 bool GRAYCALL v_Var2Strings (cArrayStringA &a, cVariant &vVal)
 
static void GRAYCALL v_Strings2Var (cVariant &vVal, const cArrayStringA &a)
 
- Static Public Member Functions inherited from GrayLib::cVariantData
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...
 

Static Public Attributes

static const cVariant k_VarNULL
 VARTYPE_NoType isNoType() More...
 
- Static Public Attributes inherited from GrayLib::cVariantData
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 InitVar (const cVariant &vVar)
 
void InitVar (VARTYPE_TYPE eVarType, const void *pStr, size_t iLen)
 
void EmptyLast ()
 
const cStringAref_StrA () const
 
- Protected Member Functions inherited from GrayLib::cVariantData
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
 

Protected Attributes

VARTYPE_TYPE m_eVarType
 type for cVariantData. VT_NULL or VARTYPE (for COM). really held in a single BYTE More...
 

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...
 
- Public Attributes inherited from GrayLib::cVariantData
union {
m_u
 

Detailed Description

Holds a value of various/any type. morph-able type. ASSUME always convertible to/from a string. similar to: the MFC/ATL/COM VARIANT type. CComVariant or _variant_t for ATL. based on VARIANT COleVariant for MFC, CDBVariant for ODBC, var in c# or JavaScript.

Constructor & Destructor Documentation

◆ cVariant() [1/20]

GrayLib::cVariant::cVariant ( )
inlinenoexcept

◆ cVariant() [2/20]

GrayLib::cVariant::cVariant ( const ATOMCHAR_t **  ppArrayArgs,
ITERATE_t  iArgQty 
)

input array of strings.

◆ cVariant() [3/20]

GrayLib::cVariant::cVariant ( const cVariantArray aVals)

◆ cVariant() [4/20]

GrayLib::cVariant::cVariant ( const cVariantArrayT aVals)

◆ cVariant() [5/20]

GrayLib::cVariant::cVariant ( const cAtomRef atomVal)

VARTYPE_Atom

◆ cVariant() [6/20]

GrayLib::cVariant::cVariant ( const cStringA strAVal)

VARTYPE_String

◆ cVariant() [7/20]

GrayLib::cVariant::cVariant ( const cStringW strWVal)

VARTYPE_StringW

◆ cVariant() [8/20]

GrayLib::cVariant::cVariant ( const char *  pszVal)

VARTYPE_String UTF8

Note
Do not assume the pointer is 'static const'

◆ cVariant() [9/20]

GrayLib::cVariant::cVariant ( const wchar_t *  pwsVal)

store as cString.

VARTYPE_StringW

◆ cVariant() [10/20]

GrayLib::cVariant::cVariant ( const cTimeInt timei)

BSTR.

◆ cVariant() [11/20]

GrayLib::cVariant::cVariant ( const cTimeDouble timed)

◆ cVariant() [12/20]

GrayLib::cVariant::cVariant ( const GUID guid)

◆ cVariant() [13/20]

GrayLib::cVariant::cVariant ( const cVarMap rMap)

◆ cVariant() [14/20]

GrayLib::cVariant::cVariant ( cVariantMap pMap)

◆ cVariant() [15/20]

GrayLib::cVariant::cVariant ( IXObject pXObj)

◆ cVariant() [16/20]

GrayLib::cVariant::cVariant ( VARTYPE_TYPE  eVarType,
UINT32  uVal 
)
inline

Assign specific/special types with a static value. VARTYPE_UID, VARTYPE_Color, VARTYPE_HResult, VARTYPE_CYS

◆ cVariant() [17/20]

GrayLib::cVariant::cVariant ( VARTYPE_TYPE  eVarType,
UINT64  uVal 
)
inline

Assign specific/special types with a static value. ASSERT( eVarType == VARTYPE_TimeInt || eVarType == VARTYPE_CY );

◆ cVariant() [18/20]

GrayLib::cVariant::cVariant ( VARTYPE_TYPE  eVarType,
const void *  pvData,
size_t  nLen = 0 
)
inline

Assign specific/special types with a pointer. ASSERT( eVarType == VARTYPE_Blob || eVarType == VARTYPE_GUID || isStaticSize());

◆ cVariant() [19/20]

GrayLib::cVariant::cVariant ( const THIS_t vVal)
inline

◆ cVariant() [20/20]

GrayLib::cVariant::cVariant ( THIS_t &&  ref)
inlinenoexcept

move constructor

◆ ~cVariant()

GrayLib::cVariant::~cVariant ( )
inline

Member Function Documentation

◆ AddArrayAtom()

void GrayLib::cVariant::AddArrayAtom ( cAtomRef  Val)
inline

◆ AddArrayElement()

void GrayLib::cVariant::AddArrayElement ( const THIS_t vVal)
inline

◆ AddArrayInt()

void GrayLib::cVariant::AddArrayInt ( int  Val)
inline

◆ AddArrayStr()

void GrayLib::cVariant::AddArrayStr ( cString  Val)
inline

◆ AddArrayStrA()

void GrayLib::cVariant::AddArrayStrA ( cStringA  Val)
inline

◆ AddArrayStrC()

void GrayLib::cVariant::AddArrayStrC ( const GChar_t Val)
inline

◆ AddArrayStrCA()

void GrayLib::cVariant::AddArrayStrCA ( const char *  Val)
inline

◆ AddArrayStrCW()

void GrayLib::cVariant::AddArrayStrCW ( const wchar_t *  Val)
inline

◆ AddArrayStrExp()

void GrayLib::cVariant::AddArrayStrExp ( cStringA  Val)
inline

◆ AddArrayStrW()

void GrayLib::cVariant::AddArrayStrW ( cStringW  Val)
inline

◆ AddArrayTimeInt()

void GrayLib::cVariant::AddArrayTimeInt ( TIMESEC_t  Val)
inline

◆ AddArrayUID() [1/2]

void GrayLib::cVariant::AddArrayUID ( const IXObject pObj)
inline

◆ AddArrayUID() [2/2]

void GrayLib::cVariant::AddArrayUID ( UID_t  Val)
inline

◆ AddArrayVector3()

void GrayLib::cVariant::AddArrayVector3 ( const float *  Val)
inline

◆ AddArrayXObj()

void GrayLib::cVariant::AddArrayXObj ( IXObject Val)
inline

◆ AppendArray()

ITERATE_t GrayLib::cVariant::AppendArray ( cVariant vValArray)

Append a variant array to the array.

◆ Compare()

COMPARE_t GrayLib::cVariant::Compare ( const cVariant vVar) const
Note
this could be optimized for numeric types.
Returns
0 = same.

◆ EmptyLast()

void GrayLib::cVariant::EmptyLast ( )
protected

Destroy contents, but Don't bother clearing m_eVarType

◆ get_ArrayRangeDouble()

double GrayLib::cVariant::get_ArrayRangeDouble ( ) const

This is a weird case. move out of here ??? Get a random value in a range. or set of weighted ranges. Numbers in { ... }

◆ get_ArraySize()

ITERATE_t GrayLib::cVariant::get_ArraySize ( ) const

Array helpers. Use of these indicates it should be converted to an array!

Returns
Quantity of elements in array. k_MaxElements

◆ get_Atom()

cAtomRef GrayLib::cVariant::get_Atom ( ) const

get atom.

◆ get_Color()

COLORREF GrayLib::cVariant::get_Color ( ) const

◆ get_CY()

cVariant::CY_t GrayLib::cVariant::get_CY ( ) const

◆ get_CYS()

cVariant::CYS_t GrayLib::cVariant::get_CYS ( ) const

◆ get_DataPtr()

const void * GrayLib::cVariant::get_DataPtr ( ) const

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

◆ get_DataSize()

size_t GrayLib::cVariant::get_DataSize ( ) const

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

◆ get_HResult()

HRESULT GrayLib::cVariant::get_HResult ( ) const

VARTYPE_HResult

◆ get_Int()

int GrayLib::cVariant::get_Int ( ) const
inline

◆ get_Str()

cString GrayLib::cVariant::get_Str ( ) const

◆ get_StrA()

cStringA GrayLib::cVariant::get_StrA ( ) const

Get a raw string. for display. not necessarily parsable with put_StrExpUnk() Similar to get_StrCA() Non quoted.

◆ get_StrC()

const GChar_t * GrayLib::cVariant::get_StrC ( ) const

constant string. DANGEROUS?! (string must persist)

◆ get_StrCA()

const char * GrayLib::cVariant::get_StrCA ( ) const

Similar to get_StrA()

Returns
a static pointer to the char string. Non quoted strings.

◆ get_StrCW()

const wchar_t * GrayLib::cVariant::get_StrCW ( ) const

constant string. DANGEROUS?! (string must persist)

Returns
a static pointer to the wchar_t string.

◆ get_StrExp()

cStringA GrayLib::cVariant::get_StrExp ( ) const

Get a string that will get parsed with put_StrExpUnk() or put_StrExpEval(). Is properly escaped. may have quotes commands, etc.

◆ get_StrT() [1/3]

template<>
cStringT<char> GrayLib::cVariant::get_StrT ( ) const
inline

◆ get_StrT() [2/3]

template<>
cStringT<wchar_t> GrayLib::cVariant::get_StrT ( ) const
inline

◆ get_StrT() [3/3]

template<typename _TYPE_CH >
cStringT<_TYPE_CH> GrayLib::cVariant::get_StrT ( ) const
inline

◆ get_StrW()

cStringW GrayLib::cVariant::get_StrW ( ) const

Non quoted.

◆ get_TimeDouble()

double GrayLib::cVariant::get_TimeDouble ( ) const

VARTYPE_TimeDouble cTimeDouble number of days since Y date.

◆ get_TimeInt()

TIMESEC_t GrayLib::cVariant::get_TimeInt ( ) const

VARTYPE_TimeInt Number of seconds from X date. cTimeInt

◆ get_UID()

UID_t GrayLib::cVariant::get_UID ( ) const

◆ get_VarExpEval()

cVariant GrayLib::cVariant::get_VarExpEval ( ) const

◆ get_VarType()

VARTYPE_TYPE GrayLib::cVariant::get_VarType ( ) const
inlinenoexcept

◆ get_VarTypeDef()

const cVariantTypeDef& GrayLib::cVariant::get_VarTypeDef ( ) const
inlinenoexcept

◆ get_Vector3()

cVariantVector3< float > GrayLib::cVariant::get_Vector3 ( ) const

VARTYPE_Vector3 an array of 3 floats. but not dynamically allocated.

◆ get_XObj()

IXObject * GrayLib::cVariant::get_XObj ( ) const

◆ GetArrayElement()

const cVariant & GrayLib::cVariant::GetArrayElement ( ITERATE_t  index) const

do not change the variant. Just get a copy

◆ GetBlobData()

size_t GrayLib::cVariant::GetBlobData ( void *  pData,
size_t  nSizeMax 
) const

Get the data for a memory blob.

Returns
resultant size in bytes.

◆ GetCY()

cVariant::CY_t GrayLib::cVariant::GetCY ( bool  bAssumeNaked = false,
CY_t  uValMul = k_CYMul 
) const

VARTYPE_CY, VARTYPE_CYS Get currency/money value. uValMul = k_CYMul bAssumeNaked = If converting from a string and no decimal point is present. true = assume string is total number of tenths.

◆ GetHeapStats()

size_t GrayLib::cVariant::GetHeapStats ( OUT ITERATE_t iAllocCount) const
Returns
size in bytes used by this. Not the same as serialization size.

◆ GetMapVar()

const cVariant & GrayLib::cVariant::GetMapVar ( const ATOMCHAR_t pszName) const

◆ GetStrExpUnk()

StrLen_t GrayLib::cVariant::GetStrExpUnk ( ATOMCHAR_t pszStr,
StrLen_t  iLenMax,
bool  bInArray = false 
) const
inline

Quote strings if it seems reasonable.

◆ InitVar() [1/2]

void GrayLib::cVariant::InitVar ( const cVariant vVar)
protected

Copy from another cVariant. don't bother freeing previous contents of *this

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

◆ InitVar() [2/2]

void GrayLib::cVariant::InitVar ( VARTYPE_TYPE  eVarType,
const void *  pStr,
size_t  iLen 
)
protected

Set the new variant with data of get_DataPtr() form. don't bother freeing previous contents. assume un-init values.

Note
Internal call that does not properly clear previous value !!! DANGER ASSUME nLen is big enough? ASSUME pData is correct type.
  • nLen = -1 = zero terminated or default.
ASSERT( eVarType == VARTYPE_Blob || eVarType == VARTYPE_GUID || isStaticSize());

◆ InsertArrayElement()

bool GrayLib::cVariant::InsertArrayElement ( ITERATE_t  index,
const cVariant vVal 
)

insert element into array.

◆ isArray()

bool GrayLib::cVariant::isArray ( ) const
inlinenoexcept

Is this an array of something?

◆ IsArrayChild()

bool GrayLib::cVariant::IsArrayChild ( const cVariant vVal) const

Is vVal one of my children?

◆ isEmptyVar()

bool GrayLib::cVariant::isEmptyVar ( ) const

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

◆ IsEqualTo()

bool GrayLib::cVariant::IsEqualTo ( const THIS_t vVar) const
inline

◆ isHResult()

bool GrayLib::cVariant::isHResult ( ) const
inlinenoexcept

an HResult error code type result? may be success code.

◆ isHResultError()

bool GrayLib::cVariant::isHResultError ( ) const
inline

◆ isNoType()

bool GrayLib::cVariant::isNoType ( ) const
inlinenoexcept

no value was set ?

◆ isNumSigned()

bool GrayLib::cVariant::isNumSigned ( ) const
inlinenoexcept

◆ isStringA()

bool GrayLib::cVariant::isStringA ( ) const
inlinenoexcept

UTF8 format string. char*.

◆ isStringExp()

bool GrayLib::cVariant::isStringExp ( ) const
inlinenoexcept

Is this string some sort of unparsed expression.

◆ isStringW()

bool GrayLib::cVariant::isStringW ( ) const
inlinenoexcept

UNICODE format string. wchar_t*.

◆ isTime()

bool GrayLib::cVariant::isTime ( ) const
inlinenoexcept

a time stamp?

◆ isVarTypeFloat()

bool GrayLib::cVariant::isVarTypeFloat ( ) const
inlinenoexcept

◆ isVarTypeNumeric()

bool GrayLib::cVariant::isVarTypeNumeric ( ) const
inlinenoexcept

◆ isVarTypeString()

bool GrayLib::cVariant::isVarTypeString ( ) const
inlinenoexcept

◆ isXObj()

bool GrayLib::cVariant::isXObj ( ) const
inlinenoexcept

◆ isZeroVar()

bool GrayLib::cVariant::isZeroVar ( ) const

Not exactly VARTYPE_NoType but nearly the same. i.e. empty string or array.

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

◆ MakeArray()

cVariantArray & GrayLib::cVariant::MakeArray ( )

force to VARTYPE_Array. attempt to preserve current variant as part of the array.

◆ MakeArrayElement()

cVariant & GrayLib::cVariant::MakeArrayElement ( ITERATE_t  index = k_ITERATE_BAD)

Get an array element reference that i could modify. if it does not exist then create it.

  • index = k_ITERATE_BAD = add at the end.

◆ MakeArraySize()

ITERATE_t GrayLib::cVariant::MakeArraySize ( bool  bBreakQuotes = false)

Parse also !

Try to convert existing data to array.

  • bBreakQuotes = Try to parse any strings. (even quoted string?)
    Returns
    size of the array.

◆ MakeMap()

cVariantMapPtr GrayLib::cVariant::MakeMap ( )

◆ MakeMapVar()

cVariant & GrayLib::cVariant::MakeMapVar ( const ATOMCHAR_t pszName)

◆ MakeRefBlob()

cHeapBlock & GrayLib::cVariant::MakeRefBlob ( VARTYPE_TYPE  eVarType)

VARTYPE_Blob, VARTYPE_GUID

◆ operator const char *()

GrayLib::cVariant::operator const char * ( ) const
inline

◆ operator const wchar_t *()

GrayLib::cVariant::operator const wchar_t * ( ) const
inline

◆ operator cStringA()

GrayLib::cVariant::operator cStringA ( ) const
inline

◆ operator cStringW()

GrayLib::cVariant::operator cStringW ( ) const
inline

◆ operator!=()

bool GrayLib::cVariant::operator!= ( const THIS_t vVar) const
inline

◆ operator=() [1/6]

const THIS_t& GrayLib::cVariant::operator= ( const char *  x)
inline

◆ operator=() [2/6]

const THIS_t& GrayLib::cVariant::operator= ( const cStringA x)
inline

◆ operator=() [3/6]

const THIS_t& GrayLib::cVariant::operator= ( const cStringW x)
inline

◆ operator=() [4/6]

const THIS_t& GrayLib::cVariant::operator= ( const THIS_t vVal)
inline

◆ operator=() [5/6]

const THIS_t& GrayLib::cVariant::operator= ( const wchar_t *  x)
inline

◆ operator=() [6/6]

THIS_t& GrayLib::cVariant::operator= ( THIS_t &&  ref)
inline

move assignment operator

◆ operator==()

bool GrayLib::cVariant::operator== ( const THIS_t vVar) const
inline

◆ operator[]() [1/4]

THIS_t& GrayLib::cVariant::operator[] ( const ATOMCHAR_t pszName)
inline

◆ operator[]() [2/4]

const THIS_t& GrayLib::cVariant::operator[] ( const ATOMCHAR_t pszName) const
inline

◆ operator[]() [3/4]

THIS_t& GrayLib::cVariant::operator[] ( ITERATE_t  index)
inline

◆ operator[]() [4/4]

const THIS_t& GrayLib::cVariant::operator[] ( ITERATE_t  index) const
inline

◆ put_Array()

void GrayLib::cVariant::put_Array ( const cVariantArray aVars)

◆ put_ArrayT()

void GrayLib::cVariant::put_ArrayT ( const cVariantArrayT aVals)

◆ put_Atom()

void GrayLib::cVariant::put_Atom ( cAtomRef  x)

◆ put_Blob()

void GrayLib::cVariant::put_Blob ( const cHeapBlock b,
VARTYPE_TYPE  eVarType = VARTYPE_Blob 
)
inline

◆ put_Color()

void GrayLib::cVariant::put_Color ( COLORREF  x)

◆ put_CY()

void GrayLib::cVariant::put_CY ( cVariant::CY_t  nVal)

VARTYPE_CY Put currency/money value. k_CYMul

◆ put_CYS()

void GrayLib::cVariant::put_CYS ( cVariant::CYS_t  nVal)

◆ put_HResult()

void GrayLib::cVariant::put_HResult ( HRESULT  x)

VARTYPE_HResult

◆ put_Int()

void GrayLib::cVariant::put_Int ( int  nVal)
inline

◆ put_Map()

void GrayLib::cVariant::put_Map ( cVariantMap pMap)

Map helpers.

◆ put_Str()

void GrayLib::cVariant::put_Str ( cString  x)

VARTYPE_String

◆ put_StrA()

void GrayLib::cVariant::put_StrA ( cStringA  x)

Assume any escape sequence stuff in here is supposed to be here.

◆ put_StrC()

void GrayLib::cVariant::put_StrC ( const GChar_t x)

◆ put_StrCA()

void GrayLib::cVariant::put_StrCA ( const char *  x)

If we know the string is in constant space or storage is secure. just store the pointer.

Note
Dangerous!?

◆ put_StrCW()

void GrayLib::cVariant::put_StrCW ( const wchar_t *  x)
Note
Dangerous!? The pointer is assumed to be pointing to something that will not move or be freed, etc.

◆ put_StrExp()

void GrayLib::cVariant::put_StrExp ( cStringA  x)

A string expression that may be parsed/evaluated at some later time. VARTYPE_StringExp

◆ put_StrExpEval()

HRESULT GrayLib::cVariant::put_StrExpEval ( const ATOMCHAR_t pStrExp)

◆ put_StrExpUnk()

HRESULT GrayLib::cVariant::put_StrExpUnk ( const ATOMCHAR_t pStrExp)

partially parse an expression string. (if simple types)

Do a partial interpretation of this unknown expression string. VARTYPE_StringExp Try to guess what its proper VarType is from string format. No maths/symbolics are evaluated.

◆ put_StrW()

void GrayLib::cVariant::put_StrW ( cStringW  x)

Assume any escape sequence stuff in here is supposed to be here.

◆ put_TimeDouble()

void GrayLib::cVariant::put_TimeDouble ( double  x)

VARTYPE_TimeDouble

  • dVal = DATE = double. similar to cTimeFile ?

◆ put_TimeInt()

void GrayLib::cVariant::put_TimeInt ( TIMESEC_t  x)

◆ put_UID() [1/2]

void GrayLib::cVariant::put_UID ( const IXObject pXObj)

◆ put_UID() [2/2]

void GrayLib::cVariant::put_UID ( UID_t  x)

◆ put_Var()

void GrayLib::cVariant::put_Var ( const cVariant vVar)

Just copy the cVariant vVal

◆ put_Vector3() [1/2]

void GrayLib::cVariant::put_Vector3 ( const float *  x)

VARTYPE_Vector3 The same as an array of 3 floats.

◆ put_Vector3() [2/2]

void GrayLib::cVariant::put_Vector3 ( float  x,
float  y,
float  z 
)

◆ put_XObj()

void GrayLib::cVariant::put_XObj ( IXObject pXObj)

pVal usage count is incremented!

◆ ref_StrA()

const cStringA & GrayLib::cVariant::ref_StrA ( ) const
protected

VARTYPE_StringExp,VARTYPE_String or VARTYPE_Atom

◆ RemoveArrayElement()

void GrayLib::cVariant::RemoveArrayElement ( ITERATE_t  index,
ITERATE_t  iQty = 1 
)

remove the N'th element of the array.

◆ Serialize()

HRESULT GrayLib::cVariant::Serialize ( cArchive a)

◆ SerializeInput()

HRESULT GrayLib::cVariant::SerializeInput ( cStreamInput file)
Returns
S_OK = enough data. <0 = error HRESULT_WIN32_C(ERROR_IO_INCOMPLETE)

◆ SerializeInputType()

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

◆ SerializeOutput()

HRESULT GrayLib::cVariant::SerializeOutput ( cStreamOutput file) const

Serialize out/in to a byte stream.

prefix with the data type. it may not be known.

Note
cVariant serialization should NEVER change.

◆ SetArray()

ITERATE_t GrayLib::cVariant::SetArray ( const ATOMCHAR_t **  ppArgs,
ITERATE_t  iArgQty,
ITERATE_t  nQtyAppend = 0 
)

Parse an array of strings into a variant array. put_StrExpUnk

  • nQtyAppend = append to this array starting at this position.
    Returns
    Number of args.
    Todo:
    VARTYPE_Vector3 ??

◆ SetArrayAtom()

void GrayLib::cVariant::SetArrayAtom ( ITERATE_t  index,
cAtomRef  Val 
)
inline

◆ SetArrayElement()

bool GrayLib::cVariant::SetArrayElement ( ITERATE_t  index,
const cVariant vVal 
)

if it does not exist then create it !

Note
DOES NOT PARSE STRINGS to form Arrays.

◆ SetArrayInt()

void GrayLib::cVariant::SetArrayInt ( ITERATE_t  index,
int  Val 
)
inline

◆ SetArrayParse()

ITERATE_t GrayLib::cVariant::SetArrayParse ( const ATOMCHAR_t pszStr)

Parse a string for an Array

  • nQtyAppend = append to this array starting at this position.
  • eBlock = STR_BLOCK_CURLY
    Returns
    Number of elements.

◆ SetArrayStr()

void GrayLib::cVariant::SetArrayStr ( ITERATE_t  index,
cString  Val 
)
inline

◆ SetArrayStrA()

void GrayLib::cVariant::SetArrayStrA ( ITERATE_t  index,
cStringA  Val 
)
inline

◆ SetArrayStrC()

void GrayLib::cVariant::SetArrayStrC ( ITERATE_t  index,
const GChar_t Val 
)
inline

◆ SetArrayStrCA()

void GrayLib::cVariant::SetArrayStrCA ( ITERATE_t  index,
const char *  Val 
)
inline

◆ SetArrayStrCW()

void GrayLib::cVariant::SetArrayStrCW ( ITERATE_t  index,
const wchar_t *  Val 
)
inline

◆ SetArrayStrExp()

void GrayLib::cVariant::SetArrayStrExp ( ITERATE_t  index,
cStringA  Val 
)
inline

◆ SetArrayStrW()

void GrayLib::cVariant::SetArrayStrW ( ITERATE_t  index,
cStringW  Val 
)
inline

◆ SetArrayTimeInt()

void GrayLib::cVariant::SetArrayTimeInt ( ITERATE_t  index,
TIMESEC_t  Val 
)
inline

◆ SetArrayUID()

void GrayLib::cVariant::SetArrayUID ( ITERATE_t  index,
UID_t  Val 
)
inline

◆ SetArrayVector3()

void GrayLib::cVariant::SetArrayVector3 ( ITERATE_t  index,
const float *  Val 
)
inline

◆ SetArrayXObj()

void GrayLib::cVariant::SetArrayXObj ( ITERATE_t  index,
IXObject Val 
)
inline

◆ SetBlobData()

void GrayLib::cVariant::SetBlobData ( const void *  pData,
size_t  nSize,
VARTYPE_TYPE  eVarType = VARTYPE_Blob 
)
  • eVarType = VARTYPE_Blob or VARTYPE_GUID Similar to SerVarFirst() but for Blob.

◆ SetBlobStr()

size_t GrayLib::cVariant::SetBlobStr ( VARTYPE_TYPE  eVarType,
const ATOMCHAR_t pszStr 
)

VARTYPE_Blob Set a binary blob from encoded string. VARTYPE_StringExp

  1. Base64 string.
  2. plain string. (if the chars are in valid range)
  3. comma separated byte values.

◆ SetClear()

void GrayLib::cVariant::SetClear ( )
inline

◆ SetMapVar()

HRESULT GrayLib::cVariant::SetMapVar ( const ATOMCHAR_t pszName,
const cVariant vSet 
)

◆ SetMove()

void GrayLib::cVariant::SetMove ( THIS_t ref)
inline

◆ SetNoType()

void GrayLib::cVariant::SetNoType ( )
inline

empty example of the type.

◆ SetTimeDoubleNow()

void GrayLib::cVariant::SetTimeDoubleNow ( )

set the time to be now.

◆ SetTimeIntNow()

void GrayLib::cVariant::SetTimeIntNow ( )

set the time to be now.

◆ SetVarData()

void GrayLib::cVariant::SetVarData ( VARTYPE_TYPE  eVarType,
const void *  pData,
size_t  iLen 
)

Set blob like types of data. VARTYPE_Blob, VARTYPE_GUID or isStaticSized()

◆ SetVarType()

bool GrayLib::cVariant::SetVarType ( VARTYPE_TYPE  eVarType,
const cVariant vVal 
)

convert to a new variant type from the value of another variant. make sure its VARTYPE_TYPE is set/converted to eVarType

◆ SetVarTypeSimplest()

void GrayLib::cVariant::SetVarTypeSimplest ( bool  bKeepFloat)

reduce VARTYPE_TYPE to a smallest that can hold the value accurately.

  • bKeepFloat = keep float format for math that may occur later.

◆ SetZeroVar()

void GrayLib::cVariant::SetZeroVar ( VARTYPE_TYPE  eVarType = VARTYPE_NoType)

All isEmptyVar(s) are also isZeroVar(s)

Set a zero value of a specific VARTYPE_TYPE. Not the same as NULL/NoType. (Not sure why anyone cares about the type really) Compliment of isZeroVar()

◆ StrExpIgnore()

void GrayLib::cVariant::StrExpIgnore ( )

Convert VARTYPE_StringExp to VARTYPE_String.

Convert VARTYPE_StringExp to VARTYPE_String if it looks like an expression just make it a string. Evaluate it later or never.

◆ UNITTEST_FRIEND()

GrayLib::cVariant::UNITTEST_FRIEND ( cVariant  )

◆ v_Strings2Var()

void GRAYCALL GrayLib::cVariant::v_Strings2Var ( cVariant vVal,
const cArrayStringA a 
)
static

get cArrayStringA (array of strings) as a cVariant

◆ v_Var2Strings()

bool GRAYCALL GrayLib::cVariant::v_Var2Strings ( cArrayStringA a,
cVariant vVal 
)
static

set cArrayStringA (array of strings) from a cVariant,

Member Data Documentation

◆ k_VarNULL

const cVariant GrayLib::cVariant::k_VarNULL
static

VARTYPE_NoType isNoType()

◆ m_eVarType

VARTYPE_TYPE GrayLib::cVariant::m_eVarType
protected

type for cVariantData. VT_NULL or VARTYPE (for COM). really held in a single BYTE


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