当前位置: 首页>>代码示例>>C++>>正文


C++ CellArray类代码示例

本文整理汇总了C++中CellArray的典型用法代码示例。如果您正苦于以下问题:C++ CellArray类的具体用法?C++ CellArray怎么用?C++ CellArray使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CellArray类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ArrayFindString

// native ArrayFindString(Array:which, const item[]);
static cell AMX_NATIVE_CALL ArrayFindString(AMX* amx, cell* params)
{
	CellArray* vec = HandleToVector(amx, params[1]);

	if (vec == NULL)
	{
		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;
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:27,代码来源:datastructs.cpp

示例2: PushStackArray

// native PushStackArray(Stack:handle, const any:values[], size= -1);
static cell AMX_NATIVE_CALL PushStackArray(AMX* amx, cell* params)
{
	CellArray* vec = HandleToVector(amx, params[1]);

	if (vec == NULL)
	{
		return 0;
	}

	cell *blk = vec->push();

	if (!blk)
	{
		LogError(amx, AMX_ERR_NATIVE, "Failed to grow stack");
		return 0;
	}

	cell *addr = get_amxaddr(amx, params[2]);
	size_t indexes = vec->blocksize();

	if (params[3] != -1 && (size_t)params[3] <= vec->blocksize())
	{
		indexes = params[3];
	}

	memcpy(blk, addr, indexes * sizeof(cell));

	return 1;
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:30,代码来源:stackstructs.cpp

示例3: FindStringInArray

static cell_t FindStringInArray(IPluginContext *pContext, const cell_t *params)
{
	CellArray *array;
	HandleError err;
	HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);

	if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) 
		!= HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
	}

	char *str;
	pContext->LocalToString(params[2], &str);

	for (unsigned int i = 0; i < array->size(); i++)
	{
		const char *array_str = (const char *)array->at(i);
		if (strcmp(str, array_str) == 0)
		{
			return (cell_t) i;
		}
	}

	return -1;
}
开发者ID:MercureS,项目名称:sourcemod,代码行数:26,代码来源:smn_adt_array.cpp

示例4: PopStackString

// native bool:PopStackString(Stack:handle, buffer[], maxlength, &written = 0);
static cell AMX_NATIVE_CALL PopStackString(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;
	}

	if (vec->size() == 0)
	{
		return 0;
	}

	size_t idx = vec->size() - 1;
	cell *blk = vec->at(idx);

	int numWritten = set_amxstring_utf8(amx, params[2], blk, amxstring_len(blk), params[3]);
	*get_amxaddr(amx, params[4]) = numWritten;

	vec->remove(idx);

	return 1;
}
开发者ID:Arkshine,项目名称:amxmodx,代码行数:26,代码来源:stackstructs.cpp

示例5: FindValueInArray

static cell_t FindValueInArray(IPluginContext *pContext, const cell_t *params)
{
	CellArray *array;
	HandleError err;
	HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);

	if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array))
		!= HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
	}

	// the blocknumber is not guaranteed to always be passed
	size_t blocknumber = 0;
	if (params[0] >= 3)
	{
		blocknumber = (size_t) params[3];
	}

	if (blocknumber >= array->blocksize())
	{
		return pContext->ThrowNativeError("Invalid block %d (blocksize: %d)", blocknumber, array->blocksize());
	}

	for (unsigned int i = 0; i < array->size(); i++)
	{
		cell_t *blk = array->at(i);
		if (params[2] == blk[blocknumber])
		{
			return (cell_t) i;
		}
	}

	return -1;
}
开发者ID:DJLaca,项目名称:sourcemod,代码行数:35,代码来源:smn_adt_array.cpp

示例6: ArrayClone

// native Array:ArrayClone(Array:which);
static cell AMX_NATIVE_CALL ArrayClone(AMX* amx, cell* params)
{
	CellArray* vec = HandleToVector(amx, params[1]);

	if (vec == NULL)
	{
		return 0;
	}

	CellArray *clonevec = vec->clone();

	// Scan through the vector list to see if any are NULL.
	// NULL means the vector was previously destroyed.
	for (unsigned int i = 0; i < VectorHolder.length(); ++i)
	{
		if (VectorHolder[i] == NULL)
		{
			VectorHolder[i] = clonevec;
			return i + 1;
		}
	}

	VectorHolder.append(clonevec);

	return VectorHolder.length();
}
开发者ID:Chuvi-w,项目名称:amxmodx,代码行数:27,代码来源:datastructs.cpp

示例7: 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));
}
开发者ID:Javivi,项目名称:amxmodx,代码行数:34,代码来源:datastructs.cpp

示例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);
}
开发者ID:Javivi,项目名称:amxmodx,代码行数:28,代码来源:datastructs.cpp

示例9: PushArrayArray

static cell_t PushArrayArray(IPluginContext *pContext, const cell_t *params)
{
	CellArray *array;
	HandleError err;
	HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);

	if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) 
		!= HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
	}

	cell_t *blk = array->push();
	if (!blk)
	{
		return pContext->ThrowNativeError("Failed to grow array");
	}

	cell_t *addr;
	pContext->LocalToPhysAddr(params[2], &addr);

	size_t indexes = array->blocksize();
	if (params[3] != -1 && (size_t)params[3] <= array->blocksize())
	{
		indexes = params[3];
	}

	memcpy(blk, addr, sizeof(cell_t) * indexes);

	return (cell_t)(array->size() - 1);
}
开发者ID:MercureS,项目名称:sourcemod,代码行数:31,代码来源:smn_adt_array.cpp

示例10: PushStackString

// native PushStackString(Stack:handle, const value[]);
static cell AMX_NATIVE_CALL PushStackString(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 stack");
		return 0;
	}

	int len;
	const char *value = get_amxstring(amx, params[2], 0, len);

	strncopy(blk, value, vec->blocksize());

	return 1;
}
开发者ID:Arkshine,项目名称:amxmodx,代码行数:26,代码来源:stackstructs.cpp

示例11: PushArrayString

static cell_t PushArrayString(IPluginContext *pContext, const cell_t *params)
{
	CellArray *array;
	HandleError err;
	HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);

	if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) 
		!= HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
	}

	cell_t *blk = array->push();
	if (!blk)
	{
		return pContext->ThrowNativeError("Failed to grow array");
	}

	char *str;
	pContext->LocalToString(params[2], &str);

	smcore.strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));

	return (cell_t)(array->size() - 1);
}
开发者ID:MercureS,项目名称:sourcemod,代码行数:25,代码来源:smn_adt_array.cpp

示例12: PopStackString

static cell_t PopStackString(IPluginContext *pContext, const cell_t *params)
{
	HandleError err;
	CellArray *array;
	size_t idx, numWritten;
	cell_t *blk, *pWritten;
	HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);

	if ((err = g_HandleSys.ReadHandle(params[1], htCellStack, &sec, (void **)&array)) 
		!= HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
	}

	if (array->size() == 0)
	{
		return 0;
	}

	idx = array->size() - 1;
	blk = array->at(idx);
	pContext->StringToLocalUTF8(params[2], params[3], (char *)blk, &numWritten);
	pContext->LocalToPhysAddr(params[4], &pWritten);
	*pWritten = (cell_t)numWritten;
	array->remove(idx);

	return 1;
}
开发者ID:asceth,项目名称:synapi,代码行数:28,代码来源:smn_adt_stack.cpp

示例13: GetArrayString

static cell_t GetArrayString(IPluginContext *pContext, const cell_t *params)
{
	CellArray *array;
	HandleError err;
	HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);

	if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) 
		!= HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
	}

	size_t idx = (size_t)params[2];
	if (idx >= array->size())
	{
		return pContext->ThrowNativeError("Invalid index %d (count: %d)", idx, array->size());
	}

	cell_t *blk = array->at(idx);
	size_t numWritten = 0;

	pContext->StringToLocalUTF8(params[3], params[4], (char *)blk, &numWritten);

	return numWritten;
}
开发者ID:MercureS,项目名称:sourcemod,代码行数:25,代码来源:smn_adt_array.cpp

示例14: SetArrayString

static cell_t SetArrayString(IPluginContext *pContext, const cell_t *params)
{
	CellArray *array;
	HandleError err;
	HandleSecurity sec(pContext->GetIdentity(), g_pCoreIdent);

	if ((err = handlesys->ReadHandle(params[1], htCellArray, &sec, (void **)&array)) 
		!= HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid Handle %x (error: %d)", params[1], err);
	}

	size_t idx = (size_t)params[2];
	if (idx >= array->size())
	{
		return pContext->ThrowNativeError("Invalid index %d (count: %d)", idx, array->size());
	}

	cell_t *blk = array->at(idx);

	char *str;
	pContext->LocalToString(params[3], &str);

	return smcore.strncopy((char *)blk, str, array->blocksize() * sizeof(cell_t));
}
开发者ID:MercureS,项目名称:sourcemod,代码行数:25,代码来源:smn_adt_array.cpp

示例15: PushStackArray

// native PushStackArray(Stack:handle, const any:values[], size= -1);
static cell AMX_NATIVE_CALL PushStackArray(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 stack");
		return 0;
	}

	cell *addr = get_amxaddr(amx, params[2]);
	size_t indexes = vec->blocksize();

	if (params[3] != -1 && (size_t)params[3] <= vec->blocksize())
	{
		indexes = params[3];
	}

	memcpy(blk, addr, indexes * sizeof(cell));

	return 1;
}
开发者ID:Arkshine,项目名称:amxmodx,代码行数:31,代码来源:stackstructs.cpp


注:本文中的CellArray类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。