44 std::string::const_iterator first = v.begin();
45 if (!
parse(first, v.end(), *
this) || first != v.end())
46 throw std::invalid_argument(
"invalid IP v6 address: \"" + v +
"\"");
53 first = std::string::npos;
57 for (
size_t i = 0;; ++i)
79 std::ostringstream oss;
89 zfirst = std::string::npos;
90 zlast = std::string::npos;
92 for (
size_t i = 0; i < 8; ++i)
93 if (i < zfirst || zlast <= i) {
96 os << std::hex << std::uppercase <<
hextets_[i];
97 }
else if (i == zfirst)
103 bool parse(std::string::const_iterator& first, std::string::const_iterator last,
unsigned short& v) {
104 std::string::const_iterator f = first;
105 unsigned int tmp = 0;
107 for (; i < 4; ++i, ++f) {
110 unsigned int c = (
unsigned int)*f;
111 if (
'0' <= c && c <=
'9')
112 tmp = (tmp << 4) + (c -
'0');
113 else if (
'A' <= c && c <=
'F')
114 tmp = (tmp << 4) + (c -
'A' + 10);
115 else if (
'a' <= c && c <=
'f')
116 tmp = (tmp << 4) + (c -
'a' + 10);
126 bool parse(std::string::const_iterator& first, std::string::const_iterator last,
ipv6_address& v) {
127 std::string::const_iterator f = first;
132 std::string::const_iterator digits;
147 std::string::const_iterator anchor = f;
152 if (
parse(anchor, last, v4)) {
167 size_t zeros = 8 - i;
168 for (i = 0; i < 8; ++i) {
170 if (elide < i && zeros) {
friend bool TECOMMONEXPORT parse(std::string::const_iterator &first, std::string::const_iterator last, ipv6_address &v)
Parse IP v6 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 & write(std::ostream &os, bool compress=false) const
Stream out.
ipv6_address()
Construct null.
bool zero_run(size_t &first, size_t &last) const
bool is_null() const
Test if null (all 0's).
unsigned short hextets_[8]
static const char SEPARATOR_CHAR
separator (':')
static const char SEPARATOR_CHAR
separator ('.')
std::string string(bool compress=false) const
Calculate string representation.