remixsettings_bits=1; wysiwyg=1,2,3,abc; remixclosed_tabs=0; remixgroup_closed_tabs=786432; remixlang=0; remixchk=5; remixsid=35d4f9907281708019490d07728c27ca5c10e5de7a869c322222225e3219e; audio_vol=100
のような文字列を持っていると、thamをmap :: name
< - >value
にパースしてboost :: spiritを使って書き戻すことができるのだろうか?ブースト・スピリット:値ペアの文字列をマップ<文字列、文字列>に変換する方法
更新: それでは、私が行っている:
#include <iostream>
#include <sstream>
#include <string>
#include <map>
//...
std::map<std::string, std::string> user_control::parse_cookie(std::string cookie_data)
{
std::map<std::string, std::string> parsed_cookie;
std::string token, token2;
std::istringstream iss(cookie_data);
while (getline(iss, token, ' '))
{
std::string name, val;
std::istringstream iss2(token);
int num = 0 ;
while (getline(iss2, token2, '='))
{
if (num == 0)
{
name = token2;
num++;
}
else
{
val = token2;
std::string::iterator it = val.end() - 1;
if (*it == ';')
val.erase(it);
}
}
std::cout << "name: " << name << " value: " << val << std::endl;
parsed_cookie.insert(std::pair<std::string, std::string>(name, val));
}
return parsed_cookie;
}
が、私は実際にどのようにブースト::精神コードにポート私のコードをに疑問に思います。
あなたはそれを精神的に書き直したいのですが、なぜですか?あなたは長いコンパイル時が好きですから? –