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


C++ Tokens::next方法代码示例

本文整理汇总了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;
	}
}
开发者ID:Costallat,项目名称:spark-telnet-server-lib,代码行数:29,代码来源:CommandLineEngine.cpp

示例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;
}
开发者ID:jtalbot,项目名称:fungi,代码行数:11,代码来源:pbrt.cpp

示例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;
}
开发者ID:jtalbot,项目名称:fungi,代码行数:11,代码来源:pbrt.cpp

示例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;
}
开发者ID:jtalbot,项目名称:fungi,代码行数:11,代码来源:pbrt.cpp

示例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;
        }
    }
}
开发者ID:jtalbot,项目名称:fungi,代码行数:11,代码来源:pbrt.cpp

示例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);
		}
	}
}
开发者ID:Costallat,项目名称:spark-telnet-server-lib,代码行数:47,代码来源:CommandLineEngine.cpp

示例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;
}
开发者ID:Costallat,项目名称:spark-telnet-server-lib,代码行数:65,代码来源:CommandLineEngine.cpp

示例8: parseInt

int64_t parseInt(Tokens& tokens) { return stoll(tokens.next()); }
开发者ID:jtalbot,项目名称:fungi,代码行数:1,代码来源:pbrt.cpp

示例9: parseReal

float parseReal(Tokens& tokens) { return stof(tokens.next()); }
开发者ID:jtalbot,项目名称:fungi,代码行数:1,代码来源:pbrt.cpp

示例10: parseString

std::string parseString(Tokens& tokens) {
    auto t = tokens.next();

    // strip off quotes and return
    return t.substr(1, t.length() - 2);
}
开发者ID:jtalbot,项目名称:fungi,代码行数:6,代码来源:pbrt.cpp


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