本文整理汇总了C++中Tokens::next方法的典型用法代码示例。如果您正苦于以下问题:C++ Tokens::next方法的具体用法?C++ Tokens::next怎么用?C++ Tokens::next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tokens
的用法示例。
在下文中一共展示了Tokens::next方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: set
void CommandLineEngine::set(Print * printer, Tokens & tk, FunctionFlags ff)
{
if( ff == FF_HelpText ) {
if( printer ) {
printer->println("Function Name: Set");
printer->println("Description: Use it to set a macro. When using set do not include the $ sign.");
printer->println("To use a macro type the $macro name. For instance the following commands.");
printer->println("set redpin D7");
printer->println("pin $redpin high");
printer->println("The set function syntax is as follows:");
printer->println("set [macroname] [value]");
}
return;
}
String arg, val;
if( !tk.next(arg) || !tk.next(val) )
quickprint("Invalid syntax. Type help set")
UserMacros::iterator it = findMacro(arg);
if( it == mUserMacros.end() ) {
UserMacroDef um = { arg, val};
mUserMacros.push_back( um );
}
else{
it->value = val;
}
}
示例2: parseBools
std::vector<bool> parseBools(Tokens& tokens) {
std::vector<bool> r;
if (tokens.peek() == "[") {
tokens.next();
while (tokens.peek() != "]") r.push_back(parseBool(tokens));
tokens.next();
} else {
r.push_back(parseBool(tokens));
}
return r;
}
示例3: parseInts
std::vector<int64_t> parseInts(Tokens& tokens) {
std::vector<int64_t> r;
if (tokens.peek() == "[") {
tokens.next();
while (tokens.peek() != "]") r.push_back(parseInt(tokens));
tokens.next();
} else {
r.push_back(parseInt(tokens));
}
return r;
}
示例4: parseStrings
std::vector<std::string> parseStrings(Tokens& tokens) {
std::vector<std::string> r;
if (tokens.peek() == "[") {
tokens.next();
while (tokens.peek() != "]") r.push_back(parseString(tokens));
tokens.next();
} else {
r.push_back(parseString(tokens));
}
return r;
}
示例5: parse
void parse(Tokens& tokens) {
while (!tokens.done()) {
auto token = tokens.next();
auto c = Commands.find(token);
if (c != Commands.end())
c->second(tokens);
else {
std::cout << "Unable to find PBRT command: " << token << std::endl;
}
}
}
示例6: help
void CommandLineEngine::help(Print * printer, Tokens & tk, FunctionFlags ff)
{
if (!printer)
return;
UserFunctions::iterator it;
String arg;
if( tk.next(arg) )
{
if( arg.equalsIgnoreCase("help") )
{
printer->println("Type help without any arguments to learn more.");
return;
}
else if( arg.equalsIgnoreCase("set") )
{
set(printer, tk, FF_HelpText);
return;
}
it = findFunction(arg);
if( it == mUserFunctions.end() )
{
printer->print("Unable to locate the function: ");
printer->println(arg);
return;
}
// Call the function and tell it to display its help text
it->func(printer, tk, FF_HelpText);
return;
}
else
{
printer->println("Function Name: help");
printer->println("Type help <function name> to learn more about that function.");
printer->println("The following functions are defined:");
printer->println("help");
printer->println("set");
// List all the functions
for( it = mUserFunctions.begin(); it != mUserFunctions.end(); ++it)
{
printer->println(it->name);
}
}
}
示例7: execute
bool CommandLineEngine::execute( String cmdLine, Print * printer )
{
if( cmdLine.length() <= 0 )
return false;
Tokens tk;
if( Tokens::Tokenize(tk,cmdLine).isEmpty() )
return false;
// Replace the macros now
// doMacros uses external iterator so the internal iterator of tk is untouched
doMacros( tk );
// Now find the function and call it
// But first check if it is one of the built in functions
String func;
if (!tk.next(func))
return false;
// Remove trailing weird space issues
func.trim();
if( func.equalsIgnoreCase("set") ) {
// Built in function
set( printer, tk, FF_Normal );
}
else if ( func.equalsIgnoreCase("help") ) {
// Built in function
help( printer, tk, FF_Normal );
}
else {
bool foundfunction = false;
// Now Search for the function and call the user function if
// we can find it
for( UserFunctions::iterator it = mUserFunctions.begin(); it != mUserFunctions.end(); ++it )
{
if( func.equalsIgnoreCase( it->name) ) {
foundfunction = true;
it->func( printer ? printer : &nullprinter,
tk,
FF_Normal);
break;
}
}
if( !foundfunction ) {
if(printer) {
printer->print("Unable to find the specified command: ");
printer->println( func );
}
return false;
}
}
return true;
}
示例8: parseInt
int64_t parseInt(Tokens& tokens) { return stoll(tokens.next()); }
示例9: parseReal
float parseReal(Tokens& tokens) { return stof(tokens.next()); }
示例10: parseString
std::string parseString(Tokens& tokens) {
auto t = tokens.next();
// strip off quotes and return
return t.substr(1, t.length() - 2);
}