39 std::string::const_iterator first = v.begin();
40 if (!
parse(first, v.end(), *
this) || first != v.end())
41 throw std::invalid_argument(
"invalid IP address: \"" + v +
"\"");
44 std::ostringstream oss;
51 bool parse(std::string::const_iterator& first, std::string::const_iterator last,
ip_address& v) {
52 std::string::const_iterator f = first;
54 for (
size_t i = 0; i < 4; ++i) {
60 unsigned int c = (
unsigned int)*f;
65 if (c <
'1' ||
'9' < c)
70 if (
'0' <= c && c <=
'9') {
71 n = n * 10 + (c -
'0');
74 if (
'0' <= c && c <=
'9') {
75 n = n * 10 + (c -
'0');
ip_address()
Construct null.
std::string string() const
Calculate string.
friend bool TECOMMONEXPORT parse(std::string::const_iterator &first, std::string::const_iterator last, ip_address &v)
Parse IP address, returning whether found or not and advancing first and setting address if found...
bool parse(std::string::const_iterator &first, std::string::const_iterator last, authority &v)
Parse URI authority, returning whether found or not and advancing first and setting authority if foun...
std::ostream & operator<<(std::ostream &os) const
Stream out.
static const char SEPARATOR_CHAR
separator ('.')