1 #include <msp/strings/format.h>
2 #include <msp/strings/lexicalcast.h>
3 #include <msp/strings/regex.h>
11 Version parse_version(const std::string &ver)
13 if(RegMatch match = Regex("^HTTP/([0-9]+).([0-9]+)$").match(ver))
14 return lexical_cast<unsigned>(match[1].str)<<4 | lexical_cast<unsigned>(match[2].str);
16 throw invalid_argument("parse_version");
19 string version_str(Version ver)
21 return format("HTTP/%u.%u", (ver>>4)&0xF, ver&0xF);