本文整理汇总了C++中NativeHandle::lookup方法的典型用法代码示例。如果您正苦于以下问题:C++ NativeHandle::lookup方法的具体用法?C++ NativeHandle::lookup怎么用?C++ NativeHandle::lookup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NativeHandle
的用法示例。
在下文中一共展示了NativeHandle::lookup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TrieSetString
// native TrieSetString(Trie:handle, const key[], const data[], bool:replace = true);
static cell AMX_NATIVE_CALL TrieSetString(AMX *amx, cell *params)
{
CellTrie *t = TrieHandles.lookup(params[1]);
if (!t)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid map handle provided (%d)", params[1]);
return 0;
}
int len;
const char *key = get_amxstring(amx, params[2], 0, len);
const char *value = get_amxstring(amx, params[3], 1, len);
StringHashMap<Entry>::Insert i = t->map.findForAdd(key);
if (!i.found())
{
if (!t->map.add(i, key))
{
return 0;
}
i->value.setString(value);
return 1;
}
// Old plugin doesn't have 'replace' parameter.
if (*params / sizeof(cell) == 4 && !params[4])
{
return 0;
}
i->value.setString(value);
return 1;
}
示例2: handle
// native SMCError:SMC_ParseFile(SMCParser:handle, const file[], &line = 0, &col = 0, any:data = 0);
static cell AMX_NATIVE_CALL SMC_ParseFile(AMX *amx, cell *params)
{
ParseInfo *p = TextParsersHandles.lookup(params[1]);
if (!p)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid SMC parse handle (%d)", params[1]);
return 0;
}
if (*params / sizeof(cell) >= 5)
{
p->data = params[5];
}
int length;
const char *file = build_pathname("%s", get_amxstring(amx, params[2], 0, length));
SMCStates states;
SMCError p_err = textparsers->ParseFile_SMC(file, p, &states);
*get_amxaddr(amx, params[3]) = states.line;
*get_amxaddr(amx, params[4]) = states.col;
return static_cast<cell>(p_err);
}
示例3: ArraySwap
// native ArraySwap(Array:which, item1, item2);
static cell AMX_NATIVE_CALL ArraySwap(AMX* amx, cell* params)
{
CellArray* vec = ArrayHandles.lookup(params[1]);
if (!vec)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", params[1]);
return 0;
}
size_t idx1 = (size_t)params[2];
size_t idx2 = (size_t)params[3];
if (idx1 >= vec->size())
{
LogError(amx, AMX_ERR_NATIVE, "Invalid index %d (count: %d)", idx1, vec->size());
return 0;
}
if (idx2 >= vec->size())
{
LogError(amx, AMX_ERR_NATIVE, "Invalid index %d (count: %d)", idx2, vec->size());
return 0;
}
vec->swap(idx1, idx2);
return 1;
}
示例4: ArrayFindString
// native ArrayFindString(Array:which, const item[]);
static cell AMX_NATIVE_CALL ArrayFindString(AMX* amx, cell* params)
{
CellArray* vec = ArrayHandles.lookup(params[1]);
if (!vec)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", params[1]);
return -1;
}
cell *b, *a = get_amxaddr(amx, params[2]);
size_t cellcount = vec->blocksize();
size_t a_len = ke::Max(1, amxstring_len(a));
size_t len = a_len > cellcount ? cellcount : a_len;
for (size_t i = 0; i < vec->size(); i++)
{
b = vec->at(i);
if (fastcellcmp(a, b, len))
{
return static_cast<cell>(i);
}
}
return -1;
}
示例5: LoadGameConfigFile
// native GameConfig:LoadGameConfigFile(const file[]);
static cell AMX_NATIVE_CALL LoadGameConfigFile(AMX *amx, cell *params)
{
int length;
const char *filename = get_amxstring(amx, params[1], 0, length);
IGameConfig *config = nullptr;
char error[128];
if (!ConfigManager.LoadGameConfigFile(filename, &config, error, sizeof(error)))
{
LogError(amx, AMX_ERR_NATIVE, "Unable to open %s: %s", filename, error);
return 0;
}
int handle = GameConfigHandle.create();
auto configHandle = GameConfigHandle.lookup(handle);
if (!configHandle)
{
return 0;
}
configHandle->m_config = config;
return handle;
}
示例6: handle
// native INI_SetReaders(INIParser:smc, const kvFunc[], const nsFunc[] = "" );
static cell AMX_NATIVE_CALL INI_SetReaders(AMX *amx, cell *params)
{
ParseInfo *p = TextParsersHandles.lookup(params[1]);
if (!p)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid INI parse handle (%d)", params[1]);
return 0;
}
int kvLength = 0, nsLength = 0;
const char *funcName = nullptr;
if ((funcName = get_amxstring(amx, params[2], 0, kvLength)) && kvLength)
{
p->key_value = registerSPForwardByName(amx, funcName, FP_CELL, FP_STRING, FP_STRING, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
if (kvLength && (funcName = get_amxstring(amx, params[3], 1, nsLength)) && nsLength)
{
p->new_section = registerSPForwardByName(amx, funcName, FP_CELL, FP_STRING, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE);
}
if (p->key_value == -1 || (nsLength && p->new_section == -1))
{
LogError(amx, AMX_ERR_NATIVE, "Function is not present (function \"%s\") (plugin \"%s\")", funcName, g_plugins.findPluginFast(amx)->getName());
return 0;
}
return 1;
}
示例7: TrieGetString
// native bool:TrieGetString(Trie:handle, const key[], buff[], len, &size = 0);
static cell AMX_NATIVE_CALL TrieGetString(AMX *amx, cell *params)
{
CellTrie *t = TrieHandles.lookup(params[1]);
if (!t)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid map handle provided (%d)", params[1]);
return 0;
}
if (params[4] < 0)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid buffer size (%d)", params[4]);
return 0;
}
int len;
const char *key = get_amxstring(amx, params[2], 0, len);
cell *pSize = get_amxaddr(amx, params[5]);
StringHashMap<Entry>::Result r = t->map.find(key);
if (!r.found() || !r->value.isString())
{
return 0;
}
*pSize = (cell)set_amxstring_utf8(amx, params[3], r->value.chars(), strlen(r->value.chars()), params[4]);
return 1;
}
示例8: ArrayGetStringHandle
// native DoNotUse : ArrayGetStringHandle(Array : which, item);
static cell AMX_NATIVE_CALL ArrayGetStringHandle(AMX* amx, cell* params)
{
CellArray* vec = ArrayHandles.lookup(params[1]);
if (!vec)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", params[1]);
return 0;
}
size_t idx = (size_t)params[2];
if (idx >= vec->size())
{
LogError(amx, AMX_ERR_NATIVE, "Invalid index %d (count: %d)", idx, vec->size());
return 0;
}
cell* ptr = vec->at(idx);
if (ptr == NULL)
{
return 0;
}
return reinterpret_cast<cell>(ptr);
}
示例9: strncopy
// native ArraySetString(Array:which, item, const input[]);
static cell AMX_NATIVE_CALL ArraySetString(AMX* amx, cell* params)
{
CellArray* vec = ArrayHandles.lookup(params[1]);
if (!vec)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", params[1]);
return 0;
}
size_t idx = (size_t)params[2];
if (idx >= vec->size())
{
LogError(amx, AMX_ERR_NATIVE, "Invalid index %d (count: %d)", idx, vec->size());
return 0;
}
cell *blk = vec->at(idx);
int len;
char *str = get_amxstring(amx, params[3], 0, len);
return strncopy(blk, str, ke::Min((size_t)len + 1, vec->blocksize()));
}
示例10: ArrayPushArray
// native ArrayPushArray(Array:which, const any:input[], size = -1);
static cell AMX_NATIVE_CALL ArrayPushArray(AMX* amx, cell* params)
{
CellArray* vec = ArrayHandles.lookup(params[1]);
if (!vec)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", params[1]);
return 0;
}
cell *blk = vec->push();
if (!blk)
{
LogError(amx, AMX_ERR_NATIVE, "Failed to grow array");
return 0;
}
cell *addr = get_amxaddr(amx, params[2]);
size_t indexes = vec->blocksize();
if (*params / sizeof(cell) == 3)
{
if (params[3] != -1 && (size_t)params[3] <= vec->blocksize())
{
indexes = params[3];
}
}
memcpy(blk, addr, sizeof(cell) * indexes);
return static_cast<cell>((vec->size() - 1));
}
示例11: ArraySetArray
// native ArraySetArray(Array:which, item, const any:input[], size =-1);
static cell AMX_NATIVE_CALL ArraySetArray(AMX* amx, cell* params)
{
CellArray* vec = ArrayHandles.lookup(params[1]);
if (!vec)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", params[1]);
return 0;
}
size_t idx = (size_t)params[2];
if (idx >= vec->size())
{
LogError(amx, AMX_ERR_NATIVE, "Invalid index %d (count: %d)", idx, vec->size());
return 0;
}
cell *blk = vec->at(idx);
size_t indexes = vec->blocksize();
if (*params / sizeof(cell) == 4)
{
if (params[4] != -1 && (size_t)params[4] <= vec->blocksize())
{
indexes = params[4];
}
}
cell *addr = get_amxaddr(amx, params[3]);
memcpy(blk, addr, sizeof(cell) * indexes);
return indexes;
}
示例12: TrieGetCell
// native bool:TrieGetCell(Trie:handle, const key[], &any:value);
static cell AMX_NATIVE_CALL TrieGetCell(AMX *amx, cell *params)
{
CellTrie *t = TrieHandles.lookup(params[1]);
if (!t)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid map handle provided (%d)", params[1]);
return 0;
}
int len;
const char *key = get_amxstring(amx, params[2], 0, len);
StringHashMap<Entry>::Result r = t->map.find(key);
if (!r.found())
{
return 0;
}
cell *ptr = get_amxaddr(amx, params[3]);
if (r->value.isCell())
{
*ptr = r->value.cell_();
return 1;
}
return 0;
}
示例13: ArrayClone
// native Array:ArrayClone(Array:which);
static cell AMX_NATIVE_CALL ArrayClone(AMX* amx, cell* params)
{
CellArray* vec = ArrayHandles.lookup(params[1]);
if (!vec)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid array handle provided (%d)", params[1]);
return 0;
}
return ArrayHandles.clone(vec->clone());
}
示例14: TrieGetSize
// native TrieGetSize(Trie:handle);
static cell AMX_NATIVE_CALL TrieGetSize(AMX *amx, cell *params)
{
CellTrie *t = TrieHandles.lookup(params[1]);
if (!t)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid map handle provided (%d)", params[1]);
return 0;
}
return t->map.elements();
}
示例15: TrieClear
// native Trie::TrieClear(Trie:handle);
static cell AMX_NATIVE_CALL TrieClear(AMX *amx, cell *params)
{
CellTrie *t = TrieHandles.lookup(params[1]);
if (!t)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid map handle provided (%d)", params[1]);
return 0;
}
t->map.clear();
return 1;
}