mirror of
https://github.com/alliedmodders/sourcemod.git
synced 2025-12-06 18:08:36 +00:00
Merge 630277c4dc into 6439769d50
This commit is contained in:
commit
0bbe71f92b
@ -763,6 +763,34 @@ static cell_t smn_KvGetDataType(IPluginContext *pCtx, const cell_t *params)
|
|||||||
return pStk->pCurRoot.front()->GetDataType(name);
|
return pStk->pCurRoot.front()->GetDataType(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static cell_t smn_KeyValuesExport(IPluginContext *pCtx, const cell_t *params)
|
||||||
|
{
|
||||||
|
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||||
|
HandleError herr;
|
||||||
|
HandleSecurity sec;
|
||||||
|
KeyValueStack *pStk;
|
||||||
|
|
||||||
|
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 *pNewKV = new KeyValues(NULL /* Will be initialized in KeyValues::operator=() */ );
|
||||||
|
|
||||||
|
*pNewKV = *(pStk->pCurRoot.front()); // KeyValues::operator=() to recursive copy.
|
||||||
|
|
||||||
|
KeyValueStack *pExportStk = new KeyValueStack;
|
||||||
|
|
||||||
|
pExportStk->pBase = pNewKV;
|
||||||
|
pExportStk->pCurRoot.push(pNewKV);
|
||||||
|
|
||||||
|
return handlesys->CreateHandle(g_KeyValueType, pExportStk, pCtx->GetIdentity(), g_pCoreIdent, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static cell_t smn_KeyValuesToFile(IPluginContext *pCtx, const cell_t *params)
|
static cell_t smn_KeyValuesToFile(IPluginContext *pCtx, const cell_t *params)
|
||||||
{
|
{
|
||||||
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
Handle_t hndl = static_cast<Handle_t>(params[1]);
|
||||||
@ -1253,6 +1281,7 @@ REGISTER_NATIVES(keyvaluenatives)
|
|||||||
{"KeyValues.Import", KeyValues_Import},
|
{"KeyValues.Import", KeyValues_Import},
|
||||||
{"KeyValues.ImportFromFile", smn_FileToKeyValues},
|
{"KeyValues.ImportFromFile", smn_FileToKeyValues},
|
||||||
{"KeyValues.ImportFromString", smn_StringToKeyValues},
|
{"KeyValues.ImportFromString", smn_StringToKeyValues},
|
||||||
|
{"KeyValues.Export", smn_KeyValuesExport},
|
||||||
{"KeyValues.ExportToFile", smn_KeyValuesToFile},
|
{"KeyValues.ExportToFile", smn_KeyValuesToFile},
|
||||||
{"KeyValues.ExportToString", smn_KeyValuesToString},
|
{"KeyValues.ExportToString", smn_KeyValuesToString},
|
||||||
{"KeyValues.ExportLength.get", smn_KeyValuesExportLength},
|
{"KeyValues.ExportLength.get", smn_KeyValuesExportLength},
|
||||||
|
|||||||
@ -62,6 +62,12 @@ methodmap KeyValues < Handle
|
|||||||
// @param firstValue If firstKey is non-empty, specifies the first key's value.
|
// @param firstValue If firstKey is non-empty, specifies the first key's value.
|
||||||
public native KeyValues(const char[] name, const char[] firstKey="", const char[] firstValue="");
|
public native KeyValues(const char[] name, const char[] firstKey="", const char[] firstValue="");
|
||||||
|
|
||||||
|
// Exports a KeyValues tree to new descriptor. The tree is dumped from the current position.
|
||||||
|
// The Handle must be closed.
|
||||||
|
//
|
||||||
|
// @return A Handle to a new KeyValues structure.
|
||||||
|
public native KeyValues Export();
|
||||||
|
|
||||||
// Exports a KeyValues tree to a file. The tree is dumped from the current position.
|
// Exports a KeyValues tree to a file. The tree is dumped from the current position.
|
||||||
//
|
//
|
||||||
// @param file File to dump write to.
|
// @param file File to dump write to.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user