本文整理汇总了C++中DynArray::add方法的典型用法代码示例。如果您正苦于以下问题:C++ DynArray::add方法的具体用法?C++ DynArray::add怎么用?C++ DynArray::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynArray
的用法示例。
在下文中一共展示了DynArray::add方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set
void set(const char * key, int val){
if(keys->isIn(key)){
valarray->get(keys->indexofVal(key))->add(val);
}
else{
keys->add(key);
DynArray<int> *vala = new DynArray<int>();
vala->add(val);
valarray->add(vala);
}
}
示例2: parse
// ---------------------------------------------------------------- //
bool CommandInterpreter::parse( CommandProcessor& cp, const char* command )
{
if (!command)
return false;
if(command[0] == '#') //Comment
return true;
// Split the command into full command name and parameter list
DynArray<string> split;
{ FOREACH_TOKEN( token, command, "()" ) split.add( token ); }
if( split.size() < 1 || split.size() > 2 ) return false;
const char* strFullCommandName = "EMPTY";
const char* strParams = "EMPTY";
if(split.size() >= 1) {
strFullCommandName = split[0].c_str();
if(split.size() == 2)
strParams = split[1].c_str();
}
// Request the command
CommandRef commandRef = cp.requestCommand( strFullCommandName );
if( commandRef && commandRef->object )
{
CommandParameters* cmdParams;
parseParams( cp, commandRef, strParams, cmdParams );
// Call the command
commandRef->action->call( commandRef->object, *cmdParams );
delete cmdParams;
return true;
}
parseErrors.add("Command not found.");
return false;
}
示例3: parseParams
// ---------------------------------------------------------------- //
bool CommandInterpreter::parseParams( CommandProcessor& cp
, CommandCached const * const cmd
, const char* strParams
, CommandParameters*& out )
{
// Now split the parameter list
DynArray<const char*> params;
{ FOREACH_TOKEN( token, strParams, "," ) params.add( token ); }
// Make sure the parameter list is the expected size
if( params.size() < cmd->input.size() )
{
parseErrors.add("Not enough parameters.");
return false;
}
// Loop through the signature and pack all of the parameters into the command parameters class
out = new CommandParameters( cmd->getSignatureSize( cp, params ) );
int offset = 0;
for( int i=0; i<cmd->input.size(); ++i )
parseAndPack( cp, cmd->input[i], params[i], *out, offset );
return true;
}