added new native KvJumpToKeySymbol

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401713
This commit is contained in:
Matt Woodrow 2007-11-21 06:49:40 +00:00
parent 58ff2d14af
commit 64a07ce198
2 changed files with 38 additions and 0 deletions

View File

@ -406,6 +406,34 @@ static cell_t smn_KvJumpToKey(IPluginContext *pCtx, const cell_t *params)
return 1;
}
static cell_t smn_KvJumpToKeySymbol(IPluginContext *pCtx, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
HandleError herr;
HandleSecurity sec;
char *name;
KeyValueStack *pStk;
sec.pOwner = NULL;
sec.pIdentity = g_pCoreIdent;
if ((herr=g_HandleSys.ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
!= HandleError_None)
{
return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
}
KeyValues *pSubKey = pStk->pCurRoot.front();
pSubKey = pSubKey->FindKey(params[2]);
if (!pSubKey)
{
return 0;
}
pStk->pCurRoot.push(pSubKey);
return 1;
}
static cell_t smn_KvGotoFirstSubKey(IPluginContext *pCtx, const cell_t *params)
{
Handle_t hndl = static_cast<Handle_t>(params[1]);
@ -937,6 +965,7 @@ REGISTER_NATIVES(keyvaluenatives)
{"KvGetUInt64", smn_KvGetUInt64},
{"CreateKeyValues", smn_CreateKeyValues},
{"KvJumpToKey", smn_KvJumpToKey},
{"KvJumpToKeySymbol", smn_KvJumpToKeySymbol},
{"KvGotoNextKey", smn_KvGotoNextKey},
{"KvJumpFirstSubKey", smn_KvGotoFirstSubKey}, /* BACKWARDS COMPAT SHIM */
{"KvGotoFirstSubKey", smn_KvGotoFirstSubKey},

View File

@ -191,6 +191,15 @@ native KvGetUInt64(Handle:kv, const String:key[], value[2], defvalue[2]={0,0});
*/
native bool:KvJumpToKey(Handle:kv, const String:key[], bool:create=false);
/**
* Sets the current position in the KeyValues tree to the given key.
*
* @param kv KeyValues Handle.
* @param id KeyValues id.
* @return True if the key exists, false if it does not.
*/
native bool:KvJumpToKeySymbol(Handle:kv, id);
/**
* Sets the current position in the KeyValues tree to the first sub key.
* This native adds to the internal traversal stack.