本文整理汇总了C++中Generator::addCommand方法的典型用法代码示例。如果您正苦于以下问题:C++ Generator::addCommand方法的具体用法?C++ Generator::addCommand怎么用?C++ Generator::addCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Generator
的用法示例。
在下文中一共展示了Generator::addCommand方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(Generator, addCommand)
{
std::vector<const char*> cmd1;
cmd1.push_back("this");
cmd1.push_back("is");
cmd1.push_back("a");
cmd1.push_back("test");
std::vector<const char*> cmd2;
cmd2.push_back("this");
cmd2.push_back("is");
cmd2.push_back("a");
cmd2.push_back("second");
cmd2.push_back("test");
Generator g;
g.addCommand(cmd1);
EXPECT_EQ(1, g.cmds.size());
EXPECT_EQ(4, g.cmds[0].size());
g.addCommand(cmd2);
EXPECT_EQ(2, g.cmds.size());
EXPECT_EQ(4, g.cmds[0].size());
EXPECT_EQ(5, g.cmds[1].size());
g.addCommand(cmd1);
EXPECT_EQ(3, g.cmds.size());
EXPECT_EQ(4, g.cmds[0].size());
EXPECT_EQ(5, g.cmds[1].size());
EXPECT_EQ(4, g.cmds[2].size());
}
示例2: Generator
Generator *Generator::fromXML ( const rapidxml::xml_node<> *src )
{
using namespace rapidxml;
std::vector<const char*> cmd;
Generator *g = new Generator();
xml_node<> *n = src->first_node(XML::target_generator_descriptionNName);
if ( n != NULL )
{
g->addDescription(n->value());
}
if (src->first_node(XML::target_generator_commandNName))
{
cmd.empty();
n = src->first_node(XML::target_generator_commandNName);
do
{
if (n->first_node(XML::target_generator_command_argumentNName))
{
xml_node<> *o = n->last_node(XML::target_generator_command_argumentNName);
// We are going backwords in hope of minimising vector resizes.
do
{
unsigned int pos;
sscanf(o->last_attribute(XML::target_generator_command_argument_posAName)->value(), "%u", &pos);
if ( pos >= cmd.size() )
cmd.resize(pos+1, NULL);
cmd[pos] = strdup(o->value());
} while ( o = o->previous_sibling(XML::target_generator_command_argumentNName) );
}
g->addCommand(cmd);
} while ( n = n->next_sibling(XML::target_generator_commandNName) );
}
return g;
}