本文整理汇总了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;
}
示例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;
}
}
}
示例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;
}