Skip to content

Instantly share code, notes, and snippets.

@mattytrentini
Created November 21, 2010 23:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattytrentini/709266 to your computer and use it in GitHub Desktop.
Save mattytrentini/709266 to your computer and use it in GitHub Desktop.
CgiParameters
typedef CgiParameters map<string, string>;
CgiParameters test;
test["a"] = "1";
test["b"] = "fred";
test["c"] = "1.04";
EXPECT_EQ(1, GetCgiParameter<int>(test, "a"))
EXPECT_EQ(string("fred"), GetCgiParameter<string>(test, "b"))
EXPECT_EQ_FLOAT(1.04f, GetCgiParameter<float>(test, "c"))
template <typename T>
T GetCgiParameter(const CgiParameters& params, const string& name)
{
CgiParameters::const_iterator it = params.find(name);
if (it == params.end())
{
throw CgiParameterNotFound;
}
return boost::lexical_cast<T>(*it->second);
}
CgiParameters test(parseCgiParameters("?a=1&b=fred&c=1.04"));
CgiParameters parseCgiParameters(const string& http_parameters)
{
std::string params = url_decode(http_parameters);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment