本文整理汇总了C++中Args::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ Args::clear方法的具体用法?C++ Args::clear怎么用?C++ Args::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Args
的用法示例。
在下文中一共展示了Args::clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ArgsFromTuple
void TmpArguments::ArgsFromTuple(AstNode* node, Args& args)
{
if (node == NULL)
{
args.clear();
return;
}
Tuple *tuple = dynamic_cast<Tuple*>(node);
if (tuple == NULL)
{
throw syntax_error(node->loc, "AstNode must be a tuple");
}
args.clear();
args.reserve(tuple->items.size());
for (AstNodes::const_iterator i = tuple->items.begin();
i != tuple->items.end(); ++i)
{
Arg *arg = dynamic_cast<Arg*>(*i);
if (arg == NULL)
{
throw syntax_error((*i)->loc, "argument must be an arg type");
}
args.push_back(arg);
}
}
示例2: parse
int InputParser::parse(istream &input, Args &args)
{
reset();
args.clear();
int lines = 0;
getline(input, line_);
++lines;
for(; (size_t)pos_ < line_.length(); ++pos_) {
char c = line_[pos_];
switch(c) {
case '\\': {
if(pos_ == line_.length() - 1) {
// Escaped newline, get next line of input
nextLine(input, args);
++lines;
}
else {
escapedCharacter();
}
break;
}
case ' ':
case '\t':
case '\n':
case '\r': {
whitespace(args);
break;
}
case '\'':
case '"': {
quote(args, c);
break;
}
case '{': {
openCurly();
break;
}
case '}': {
closeCurly();
break;
}
case '#': {
if (!inQuotes())
pos_ = line_.length();
break; // force end of parse for this line
}
default: {
character();
break;
}
}
if(inQuotes() && pos_ == line_.length() - 1) {
// We have an unfinished quote, so get the next line
nextLine(input, args);
++lines;
}
}
endOfArg(args);
line_ = "";
return lines;
}