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


C++ Args::erase方法代码示例

本文整理汇总了C++中Args::erase方法的典型用法代码示例。如果您正苦于以下问题:C++ Args::erase方法的具体用法?C++ Args::erase怎么用?C++ Args::erase使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Args的用法示例。


在下文中一共展示了Args::erase方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: LoginCommand

        //A factory method that accept a string representation of a command with arguments and a stomp client pointer
        // and returns an appropriate Command object that represents the string command
        Command * CommandFactory::createFactory(std::string const &command_string, stomp::TwitterClient *client) {

            Args argumentList;
            boost::split(argumentList, command_string, boost::is_any_of(" "), boost::token_compress_on);
            
            std::string command_name = argumentList[0];
            
            //Remove the first element - that being the command_name, leaving only the actual arguments in the list
            argumentList.erase(argumentList.begin());

            Command *cmd = 0;

            //Ugly, we know, but C++ can't do a switch-case on strings and we didn't have enought time to find a more elegant solution
            if (command_name == "login") {
                cmd = new LoginCommand(client, argumentList);
            } else if (command_name == "follow") {
                cmd = new FollowCommand(client, argumentList);
            } else if (command_name == "unfollow") {
                cmd = new UnfollowCommand(client, argumentList);
            } else if (command_name == "tweet") {
                cmd = new TweetCommand(client, argumentList);
            } else if (command_name == "clients") {
                cmd = new ClientsCommand(client, argumentList);
            } else if (command_name == "stats") {
                cmd = new StatsCommand(client, argumentList);
            } else if (command_name == "logout") {
                cmd = new LogoutCommand(client, argumentList);
            } else if (command_name == "stop") {
                cmd = new StopCommand(client, argumentList);
            } else {
                std::cerr << "Unknown command type" << std::endl;
            }
            
            return cmd;
        }
开发者ID:lidanh,项目名称:TwitterClientServer,代码行数:37,代码来源:CommandFactory.cpp

示例2: ErrBadArgs

void FlagImpl<std::string>::Parse( Args & args )
{
     for( Args::iterator arg = args.begin(); arg != args.end(); ++arg )
     {
          if( !arg->compare( GetFlag() ))
          {
               if( IsAlreadySet() ) // если флаг задан( уже встречалс¤ среди переданных аргументов )
                    throw exception::ErrBadArgs();
               Args::iterator flag = arg; // первый аргумент - флаг
               Args::iterator opt = ++arg; // следущий за ним аргумент - опци¤ 
               if( opt == args.end() )
                    throw exception::ErrBadArgs();
               SetVal( *opt );
               SetIsAlreadySet(); // выставл¤ем признак того, что данный флаг уже задан( защита от дублировани¤ )
               // удал¤ем из списка аргументов считанные флаг и опцию
               args.erase( flag ); 
               args.erase( opt );
               break;
          }
     }
}
开发者ID:garmonbozzzia,项目名称:XmlSignWebService,代码行数:21,代码来源:flag.cpp

示例3: fetch

LastfmService::Result LastfmService::fetch(Args &args)
{
	Result result;
	
	std::string url = baseURL;
	url += methodName();
	for (Args::const_iterator it = args.begin(); it != args.end(); ++it)
	{
		url += "&";
		url += it->first;
		url += "=";
		url += Curl::escape(it->second);
	}
	
	std::string data;
	CURLcode code = Curl::perform(data, url);
	
	if (code != CURLE_OK)
	{
		result.second = curl_easy_strerror(code);
		return result;
	}
	
	if (actionFailed(data))
	{
		StripHtmlTags(data);
		result.second = data;
		return result;
	}
	
	if (!parse(data))
	{
		// if relevant part of data was not found and one of arguments
		// was language, try to fetch it again without that parameter.
		// otherwise just report failure.
		Args::iterator lang = args.find("lang");
		if (lang != args.end())
		{
			args.erase(lang);
			return fetch(args);
		}
		else
		{
			// parse should change data to error msg, if it fails
			result.second = data;
			return result;
		}
	}
	
	result.first = true;
	result.second = data;
	return result;
}
开发者ID:bear24rw,项目名称:ncmpcpp,代码行数:53,代码来源:lastfm_service.cpp


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