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

#include <cVarMap.h>

Inheritance diagram for GrayLib::cVarMap:
IScriptableEnumerator IScriptableGetter IScriptableSetter GrayLib::cVariantCommon GrayLib::cVariantMap

Public Types

enum  M_TYPE_ { M_QTY }
 
- 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 Member Functions

virtual cScriptableInterfaceDefPtr _stdcall get_ScriptInterfaceDef () const
 
 cVarMap ()
 
 cVarMap (const cVarMap &rMap)
 
size_t GetHeapStats (OUT ITERATE_t &iAllocCount) const
 
HRESULT SerializeOutput (cStreamOutput &file) const
 
HRESULT SerializeInput (cStreamInput &file)
 
ITERATE_t get_KeyQty () const
 
cVarTuplePtr GetMapElement (ITERATE_t index) const
 
const cVariantGetMapElementVal (ITERATE_t index) const
 
cVarTuplePtr FindKeyPtrA (cAtomRef aKey) const
 
cVarTuplePtr FindKeyPtr (const ATOMCHAR_t *pszKey) const
 
cVarTuplePtr MakeKeyPtrA (cAtomRef aKey)
 
cVarTuplePtr MakeKeyPtr (const ATOMCHAR_t *pszKey)
 
cVarTuplePtr FindKeyPtrX (const ATOMCHAR_t *pszKeyX) const
 
cVarTuplePtr MakeKeyPtrX (const ATOMCHAR_t *pszKeyX)
 
bool RemoveKeyA (cAtomRef aKey)
 
bool RemoveKey (const ATOMCHAR_t *pszKey)
 
HRESULT SetValA (cAtomRef aKey, const cVariant &vVal)
 
HRESULT SetValNULL (cAtomRef aKey)
 
HRESULT SetValVarN (const ATOMCHAR_t *pszKey, const cVariant &vVal)
 
HRESULT SetValVar (const ATOMCHAR_t *pszKey, const cVariant &vVal)
 
HRESULT SetValStr (const ATOMCHAR_t *pszKey, const ATOMCHAR_t *pszVal)
 
const cVariantGetValVar (const ATOMCHAR_t *pszKey) const
 
const cVariantoperator[] (const ATOMCHAR_t *pszKey) const
 
cVariantRefValVar (const ATOMCHAR_t *pszKey)
 
cVariantoperator[] (const ATOMCHAR_t *pszKey)
 
cStringA GetValAsStr (const ATOMCHAR_t *pszKey) const
 
UINT32 GetValAsDWord (const ATOMCHAR_t *pszKey, UINT32 uValDefault=0) const
 
int GetValAsInt (const ATOMCHAR_t *pszKey, int iValDefault=0) const
 
float GetValAsFloat (const ATOMCHAR_t *pszKey, float fValDefault=0.0f) const
 
STDMETHOD() s_GetEnum (ITERATE_t i, OUT cStringA &rsPropName, OUT cVariant &rvValRet)
 
STDMETHOD() s_GetByName (const ATOMCHAR_t *pszPropName, OUT cVariant &vValRet)
 
STDMETHOD() s_Put (const ATOMCHAR_t *pszPropName, const cVariant &vValSet)
 
StrLen_t AddHtmlArgsLen (const ATOMCHAR_t *pszArgs)
 
ITERATE_t FindValAsStr (const ATOMCHAR_t *pszVal) const
 
ITERATE_t FindValAsInt (int iVal, const ATOMCHAR_t *pszPrefix=nullptr) const
 
void s_WriteTags (IScriptableSetter &s, const ATOMCHAR_t *pszKeyPrefix=nullptr) const
 
ITERATE_t AddTuple (cVarTuple *pVar)
 
HRESULT s_InvokeExtProp (const cVariant &vArgs, cVariant &vValRet)
 
HRESULT LoadTuple (IScriptableEnumerator &section)
 
HRESULT DumpTagsHead (cStreamOutput *pOut, const ATOMCHAR_t *pszName) const
 
void FixWeird ()
 
StrLen_t GetStr (ATOMCHAR_t *pszArgs, StrLen_t nLenMax, const ATOMCHAR_t *pszLineBreak=nullptr) const
 
HRESULT SetStr (const ATOMCHAR_t *pszArgs)
 
COMPARE_t Compare (const cVarMap *pMap) const
 
HRESULT SetFromArrays (int iQty, const char **ppszNames, const char **ppszVals)
 
 UNITTEST2_PREDEF (cVarMap)
 

Static Public Member Functions

static cAtomRef GRAYCALL MakeKeyNameRef (const ATOMCHAR_t *&pszKey, bool bMustExist, bool bAllowDots)
 
- 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

cArraySortHash< cVarTuple, ATOMCODE_tm_aTuples
 Hash sorted by ATOMCODE_t. NOT alphabetic sort. More...
 

Static Public Attributes

static const ATOMCHAR_tk_pszKeyDefault = "_"
 Default name for keys with not valid names. "_" (or no name) More...
 
static cScriptableInterfaceDef sm_ScriptInterfaceDef
 
static cScriptableMethod sm_Methods [M_QTY+1]
 
- 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...
 

Detailed Description

Collection of named values. 'property bag' or Map. (Name=Value) Similar to PHP array, MFC CMap, cIniMap, JSON object ? Sorted by cAtomRef hash number, NOT by alpha.

Member Enumeration Documentation

◆ M_TYPE_

Enumerator
M_QTY 

Constructor & Destructor Documentation

◆ cVarMap() [1/2]

GrayLib::cVarMap::cVarMap ( )
inline

◆ cVarMap() [2/2]

GrayLib::cVarMap::cVarMap ( const cVarMap rMap)
inline

Member Function Documentation

◆ AddHtmlArgsLen()

StrLen_t GrayLib::cVarMap::AddHtmlArgsLen ( const ATOMCHAR_t pszArgs)

Parse a list of args in HTML format. cNetURL coding. Given POST args in pszArgs. Add these to the cVarMap. Don't clear existing stuff.

  • pContentData = "x=1&y=2&z=4" or "T1=stuff1&B1=Submit&T2=stuff2"
    Returns
    length of pszArgs parsed data. (chars).

◆ AddTuple()

ITERATE_t GrayLib::cVarMap::AddTuple ( cVarTuple pVar)

Add a single tuple.

◆ Compare()

COMPARE_t GrayLib::cVarMap::Compare ( const cVarMap pMap) const

◆ DumpTagsHead()

HRESULT GrayLib::cVarMap::DumpTagsHead ( cStreamOutput pOut,
const ATOMCHAR_t pszName 
) const

Use this with pOut = cStreamStringA or cStreamQueue

◆ FindKeyPtr()

cVarTuplePtr GrayLib::cVarMap::FindKeyPtr ( const ATOMCHAR_t pszKey) const

parse the name and return the pVar if found. shortcut - if atom doesn't exit then the key doesn't exist.

◆ FindKeyPtrA()

cVarTuplePtr GrayLib::cVarMap::FindKeyPtrA ( cAtomRef  aKey) const

ASSUME aKey is already processed by MakeKeyNameRef()

◆ FindKeyPtrX()

cVarTuplePtr GrayLib::cVarMap::FindKeyPtrX ( const ATOMCHAR_t pszKeyX) const

◆ FindValAsInt()

ITERATE_t GrayLib::cVarMap::FindValAsInt ( int  iVal,
const ATOMCHAR_t pszPrefix = nullptr 
) const

Find a tag that has this numeric value (not key) in the array just used for testing purposes.

◆ FindValAsStr()

ITERATE_t GrayLib::cVarMap::FindValAsStr ( const ATOMCHAR_t pszVal) const

Find a tag that has this string value (not key) in the array

◆ FixWeird()

void GrayLib::cVarMap::FixWeird ( )

Check all the tags for XObj,UID validity. Off-line UID's don't resolve but thats OK!??

◆ get_KeyQty()

ITERATE_t GrayLib::cVarMap::get_KeyQty ( ) const
inline

◆ get_ScriptInterfaceDef()

virtual cScriptableInterfaceDefPtr _stdcall GrayLib::cVarMap::get_ScriptInterfaceDef ( ) const
inlinevirtual

◆ GetHeapStats()

size_t GrayLib::cVarMap::GetHeapStats ( OUT ITERATE_t iAllocCount) const

Get heap stats assuming we own all that we reference (which is not normal)

◆ GetMapElement()

cVarTuplePtr GrayLib::cVarMap::GetMapElement ( ITERATE_t  index) const
inline

◆ GetMapElementVal()

const cVariant& GrayLib::cVarMap::GetMapElementVal ( ITERATE_t  index) const
inline

◆ GetStr()

StrLen_t GrayLib::cVarMap::GetStr ( ATOMCHAR_t pszArgs,
StrLen_t  nLenMax,
const ATOMCHAR_t pszLineBreak = nullptr 
) const

Get the whole map as a string. Use JSON format. Use the JSON Writer if you want this to be pretty. Bool = 0,1 not true/false

◆ GetValAsDWord()

UINT32 GrayLib::cVarMap::GetValAsDWord ( const ATOMCHAR_t pszKey,
UINT32  uValDefault = 0 
) const
Returns
uValDefault = default if the key was not found.

◆ GetValAsFloat()

float GrayLib::cVarMap::GetValAsFloat ( const ATOMCHAR_t pszKey,
float  fValDefault = 0.0f 
) const
Returns
fValDefault = default if the key was not found.

◆ GetValAsInt()

int GrayLib::cVarMap::GetValAsInt ( const ATOMCHAR_t pszKey,
int  iValDefault = 0 
) const
Returns
iValDefault = default if the key was not found.

◆ GetValAsStr()

cStringA GrayLib::cVarMap::GetValAsStr ( const ATOMCHAR_t pszKey) const

◆ GetValVar()

const cVariant& GrayLib::cVarMap::GetValVar ( const ATOMCHAR_t pszKey) const
inline

◆ LoadTuple()

HRESULT GrayLib::cVarMap::LoadTuple ( IScriptableEnumerator section)

◆ MakeKeyNameRef()

cAtomRef GRAYCALL GrayLib::cVarMap::MakeKeyNameRef ( const ATOMCHAR_t *&  pszKey,
bool  bMustExist,
bool  bAllowDots 
)
static

Parse a name for valid length, chars. IF the name is not valid we should just FAIL.

  • bMustExist = DO NOT CREATE THIS. return null if no atom by this name already exists.
    Returns
    a temp string containing the tag. pszKey = skip over key.
    Note
    JSON allows dots.
    Todo:
    If it is an array then correct for that. [] = (empty brackets) use the first empty spot.

◆ MakeKeyPtr()

cVarTuplePtr GrayLib::cVarMap::MakeKeyPtr ( const ATOMCHAR_t pszKey)

Find or make a key tuple.

◆ MakeKeyPtrA()

cVarTuplePtr GrayLib::cVarMap::MakeKeyPtrA ( cAtomRef  aKey)

Find or make a key tuple. ASSUME aKey is already processed by MakeKeyNameRef() and is valid.

◆ MakeKeyPtrX()

cVarTuplePtr GrayLib::cVarMap::MakeKeyPtrX ( const ATOMCHAR_t pszKeyX)

◆ operator[]() [1/2]

cVariant& GrayLib::cVarMap::operator[] ( const ATOMCHAR_t pszKey)
inline

◆ operator[]() [2/2]

const cVariant& GrayLib::cVarMap::operator[] ( const ATOMCHAR_t pszKey) const
inline

◆ RefValVar()

cVariant & GrayLib::cVarMap::RefValVar ( const ATOMCHAR_t pszKey)

@pszTag = fail if the name is not valid ???

◆ RemoveKey()

bool GrayLib::cVarMap::RemoveKey ( const ATOMCHAR_t pszKey)

◆ RemoveKeyA()

bool GrayLib::cVarMap::RemoveKeyA ( cAtomRef  aKey)

ASSUME aKey is already processed by MakeKeyNameRef() and is valid.

◆ s_GetByName()

HRESULT GrayLib::cVarMap::s_GetByName ( const ATOMCHAR_t pszPropName,
OUT cVariant vValRet 
)

◆ s_GetEnum()

HRESULT GrayLib::cVarMap::s_GetEnum ( ITERATE_t  i,
OUT cStringA rsPropName,
OUT cVariant rvValRet 
)

◆ s_InvokeExtProp()

HRESULT GrayLib::cVarMap::s_InvokeExtProp ( const cVariant vArgs,
cVariant vValRet 
)

◆ s_Put()

HRESULT GrayLib::cVarMap::s_Put ( const ATOMCHAR_t pszPropName,
const cVariant vValSet 
)

◆ s_WriteTags()

void GrayLib::cVarMap::s_WriteTags ( IScriptableSetter s,
const ATOMCHAR_t pszKeyPrefix = nullptr 
) const

List out (call s_Put) all the keys to a IScriptableSetter/cScriptFileWriter file. They will be in some sort of HASHCODE_t sorted order.

◆ SerializeInput()

HRESULT GrayLib::cVarMap::SerializeInput ( cStreamInput file)

◆ SerializeOutput()

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

◆ SetFromArrays()

HRESULT GrayLib::cVarMap::SetFromArrays ( int  iQty,
const char **  ppszNames,
const char **  ppszVals 
)

◆ SetStr()

HRESULT GrayLib::cVarMap::SetStr ( const ATOMCHAR_t pszArgs)

Parse and Set the map via a string in JSON format.

◆ SetValA()

HRESULT GrayLib::cVarMap::SetValA ( cAtomRef  aKey,
const cVariant vVal 
)

set/replace/create key.

Returns
-1 = error or delete index of the new entry in the array.

◆ SetValNULL()

HRESULT GrayLib::cVarMap::SetValNULL ( cAtomRef  aKey)

I want to blank this key from the database.

◆ SetValStr()

HRESULT GrayLib::cVarMap::SetValStr ( const ATOMCHAR_t pszKey,
const ATOMCHAR_t pszVal 
)

Set a single key with a string. "" = delete key. ASSUME: pszKey has been clipped of unwanted beginning and trailing spaces.

  • pszVal = a string or simple numeric. No Parsing.

◆ SetValVar()

HRESULT GrayLib::cVarMap::SetValVar ( const ATOMCHAR_t pszKey,
const cVariant vVal 
)

Set a key with a variant. empty variant = delete

◆ SetValVarN()

HRESULT GrayLib::cVarMap::SetValVarN ( const ATOMCHAR_t pszKey,
const cVariant vVal 
)

Set a key with a variant. Allow a null variant.

◆ UNITTEST2_PREDEF()

GrayLib::cVarMap::UNITTEST2_PREDEF ( cVarMap  )

Member Data Documentation

◆ k_pszKeyDefault

const ATOMCHAR_t * GrayLib::cVarMap::k_pszKeyDefault = "_"
static

Default name for keys with not valid names. "_" (or no name)

◆ m_aTuples

cArraySortHash<cVarTuple, ATOMCODE_t> GrayLib::cVarMap::m_aTuples

Hash sorted by ATOMCODE_t. NOT alphabetic sort.

◆ sm_Methods

cScriptableMethod GrayLib::cVarMap::sm_Methods[M_QTY+1]
static

◆ sm_ScriptInterfaceDef

cScriptableInterfaceDef GrayLib::cVarMap::sm_ScriptInterfaceDef
static

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