本文整理汇总了C++中KeyValues::GetNameSymbol方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::GetNameSymbol方法的具体用法?C++ KeyValues::GetNameSymbol怎么用?C++ KeyValues::GetNameSymbol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValues
的用法示例。
在下文中一共展示了KeyValues::GetNameSymbol方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: smn_GetNameSymbol
static cell_t smn_GetNameSymbol(IPluginContext *pContext, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError herr;
HandleSecurity sec;
KeyValueStack *pStk;
cell_t *val;
char *key;
sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None)
{
return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
}
if (pStk->pCurRoot.size() < 2)
{
return 0;
}
pContext->LocalToString(params[2], &key);
KeyValues *pKv = pStk->pCurRoot.front()->FindKey(key);
if (!pKv)
{
return 0;
}
pContext->LocalToPhysAddr(params[3], &val);
*val = pKv->GetNameSymbol();
return 1;
}
示例2: smn_KvGetSectionSymbol
static cell_t smn_KvGetSectionSymbol(IPluginContext *pCtx, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError herr;
HandleSecurity sec;
KeyValueStack *pStk;
cell_t *val;
sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent;
if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None)
{
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
}
KeyValues *pSection = pStk->pCurRoot.front();
pCtx->LocalToPhysAddr(params[2], &val);
*val = pSection->GetNameSymbol();
if (!*val)
{
return 0;
}
return 1;
}
示例3: LoadBorders
//-----------------------------------------------------------------------------
// Purpose: create the Border objects from the scheme data
//-----------------------------------------------------------------------------
void CScheme::LoadBorders()
{
m_pkvBorders = m_pData->FindKey("Borders", true);
{for ( KeyValues *kv = m_pkvBorders->GetFirstSubKey(); kv != NULL; kv = kv->GetNextKey())
{
if (kv->GetDataType() == KeyValues::TYPE_STRING)
{
// it's referencing another border, ignore for now
}
else
{
int i = m_BorderList.AddToTail();
Border *border = new Border();
border->SetName(kv->GetName());
border->ApplySchemeSettings(this, kv);
m_BorderList[i].border = border;
m_BorderList[i].bSharedBorder = false;
m_BorderList[i].borderSymbol = kv->GetNameSymbol();
}
}}
// iterate again to get the border references
for ( KeyValues *kv = m_pkvBorders->GetFirstSubKey(); kv != NULL; kv = kv->GetNextKey())
{
if (kv->GetDataType() == KeyValues::TYPE_STRING)
{
// it's referencing another border, find it
Border *border = (Border *)GetBorder(kv->GetString());
// const char *str = kv->GetName();
Assert(border);
// add an entry that just references the existing border
int i = m_BorderList.AddToTail();
m_BorderList[i].border = border;
m_BorderList[i].bSharedBorder = true;
m_BorderList[i].borderSymbol = kv->GetNameSymbol();
}
}
m_pBaseBorder = GetBorder("BaseBorder");
}
示例4: RecursiveLoadFromBuffer
void KeyValues::RecursiveLoadFromBuffer(char const *resourceName, CUtlBuffer &buf)
{
CKeyErrorContext errorReport(this);
bool wasQuoted;
CKeyErrorContext errorKey(INVALID_KEY_SYMBOL);
while (1)
{
const char *name = ReadToken(buf, wasQuoted);
if (!name)
{
g_KeyValuesErrorStack.ReportError("RecursiveLoadFromBuffer: got EOF instead of keyname");
break;
}
if (!*name)
{
g_KeyValuesErrorStack.ReportError("RecursiveLoadFromBuffer: got empty keyname");
break;
}
if (*name == '}' && !wasQuoted )
break;
KeyValues *dat = CreateKey(name);
errorKey.Reset(dat->GetNameSymbol());
const char *value = ReadToken(buf, wasQuoted);
if (!value)
{
g_KeyValuesErrorStack.ReportError("RecursiveLoadFromBuffer: got NULL key");
break;
}
if (*value == '}' && !wasQuoted)
{
g_KeyValuesErrorStack.ReportError("RecursiveLoadFromBuffer: got } in key");
break;
}
if (*value == '{' && !wasQuoted)
{
errorKey.Reset(INVALID_KEY_SYMBOL);
dat->RecursiveLoadFromBuffer(resourceName, buf);
}
else
{
if (dat->m_sValue)
{
delete [] dat->m_sValue;
dat->m_sValue = NULL;
}
int len = Q_strlen(value);
char *pIEnd;
char *pFEnd;
const char *pSEnd = value + len;
int ival = strtol(value, &pIEnd, 10);
float fval = (float)strtod(value, &pFEnd);
if (*value == 0)
{
dat->m_iDataType = TYPE_STRING;
}
else if ((18 == len) && (value[0] == '0') && (value[1] == 'x'))
{
int64 retVal = 0;
for (int i = 2; i < 2 + 16; i++)
{
char digit = value[i];
if (digit >= 'a')
digit -= 'a' - ('9' + 1);
else if (digit >= 'A')
digit -= 'A' - ('9' + 1);
retVal = (retVal * 16) + (digit - '0');
}
dat->m_sValue = new char [sizeof(uint64)];
*((uint64 *)dat->m_sValue) = retVal;
dat->m_iDataType = TYPE_UINT64;
}
else if ((pFEnd > pIEnd) && (pFEnd == pSEnd))
{
dat->m_flValue = fval;
dat->m_iDataType = TYPE_FLOAT;
}
else if (pIEnd == pSEnd)
{
dat->m_iValue = ival;
dat->m_iDataType = TYPE_INT;
}
else
//.........这里部分代码省略.........
示例5: RecursiveCopyKeyValues
void KeyValues::RecursiveCopyKeyValues(KeyValues &src)
{
m_iKeyName = src.GetNameSymbol();
if (!src.m_pSub)
{
m_iDataType = src.m_iDataType;
char buf[256];
switch (src.m_iDataType)
{
case TYPE_NONE:
{
break;
}
case TYPE_STRING:
{
if (src.m_sValue)
{
m_sValue = new char[Q_strlen(src.m_sValue) + 1];
Q_strcpy(m_sValue, src.m_sValue);
}
break;
}
case TYPE_INT:
{
m_iValue = src.m_iValue;
Q_snprintf(buf, sizeof(buf), "%d", m_iValue);
m_sValue = new char[strlen(buf) + 1];
Q_strcpy(m_sValue, buf);
break;
}
case TYPE_FLOAT:
{
m_flValue = src.m_flValue;
Q_snprintf(buf, sizeof(buf), "%f", m_flValue);
m_sValue = new char[strlen(buf) + 1];
Q_strcpy(m_sValue, buf);
break;
}
case TYPE_PTR:
{
m_pValue = src.m_pValue;
break;
}
case TYPE_UINT64:
{
m_sValue = new char[sizeof(uint64)];
Q_memcpy(m_sValue, src.m_sValue, sizeof(uint64));
break;
}
case TYPE_COLOR:
{
m_Color[0] = src.m_Color[0];
m_Color[1] = src.m_Color[1];
m_Color[2] = src.m_Color[2];
m_Color[3] = src.m_Color[3];
break;
}
default:
{
Assert(0);
break;
}
}
}
if (src.m_pSub)
{
m_pSub = new KeyValues(NULL);
m_pSub->RecursiveCopyKeyValues(*src.m_pSub);
}
if (src.m_pPeer)
{
m_pPeer = new KeyValues(NULL);
m_pPeer->RecursiveCopyKeyValues(*src.m_pPeer);
}
}