@@ -35,7 +35,7 @@ struct IPv6Parser : ParserCommon, public IPv6Prefix {
35
35
return false ;
36
36
}
37
37
str = str.substr (1 );
38
- } while (!str.empty ());
38
+ } while (!str.empty ());
39
39
return true ;
40
40
}
41
41
@@ -49,12 +49,12 @@ struct IPv6Parser : ParserCommon, public IPv6Prefix {
49
49
return str[1 ] == ' .' || str[2 ] == ' .' || str[3 ] == ' .' ;
50
50
}
51
51
52
- bool consumeDotted ( int index ) {
52
+ bool parseDotted ( ) {
53
53
std::array<uint8_t , 4 > octets;
54
- if (!consumeDecimalOctet (octets[0 ]) || !consumeDot () || //
55
- !consumeDecimalOctet (octets[1 ]) || !consumeDot () || //
56
- !consumeDecimalOctet (octets[2 ]) || !consumeDot () || //
57
- !consumeDecimalOctet (octets[3 ])) {
54
+ if (!parseDecimalOctet (octets[0 ]) || !consume<Char< ' . ' >> () || //
55
+ !parseDecimalOctet (octets[1 ]) || !consume<Char< ' . ' >> () || //
56
+ !parseDecimalOctet (octets[2 ]) || !consume<Char< ' . ' >> () || //
57
+ !parseDecimalOctet (octets[3 ])) {
58
58
return false ;
59
59
}
60
60
bits |= static_cast <uint32_t >(octets[0 ]) << 24 ;
@@ -64,9 +64,9 @@ struct IPv6Parser : ParserCommon, public IPv6Prefix {
64
64
return true ;
65
65
}
66
66
67
- bool consumePrefixLength () { return consumeDecimalNumber <uint8_t , bits_count>(prefixLength); }
67
+ bool consumePrefixLength () { return parseDecimalNumber <uint8_t , bits_count>(prefixLength); }
68
68
69
- bool consumeAddressPart () {
69
+ bool parseAddressPart () {
70
70
std::bitset<bits_count> b;
71
71
int index = 0 ;
72
72
bool doubleColonFound = false ;
@@ -80,18 +80,18 @@ struct IPv6Parser : ParserCommon, public IPv6Prefix {
80
80
while (index < hexadecatets_count) {
81
81
if ((state == Separator || state == DoubleColon) &&
82
82
(doubleColonFound || index == hexadecatets_count - 2 ) && checkDotted ()) {
83
- if (!consumeDotted ( index )) {
83
+ if (!parseDotted ( )) {
84
84
return false ;
85
85
}
86
86
b <<= 32 ;
87
87
index += 2 ;
88
88
break ;
89
- } else if (state != Hexadecatet && consumeHexadecimalHexadecatet (value)) {
89
+ } else if (state != Hexadecatet && parseHexadecimalHexadecatet (value)) {
90
90
state = Hexadecatet;
91
91
b <<= 16 ;
92
92
b |= value;
93
93
index ++;
94
- } else if (state != Separator && consumeDoubleColon ()) {
94
+ } else if (state != Separator && consumeSequence< ' : ' , ' : ' > ()) {
95
95
state = DoubleColon;
96
96
if (index > hexadecatets_count - 1 || doubleColonFound) {
97
97
return false ;
@@ -102,7 +102,7 @@ struct IPv6Parser : ParserCommon, public IPv6Prefix {
102
102
// This ensures that we can't have more than 7 hexadecatets when there's
103
103
// a double-colon, even though we don't actually process a hexadecatet.
104
104
index ++;
105
- } else if (state == Hexadecatet && consumeColon ()) {
105
+ } else if (state == Hexadecatet && consume<Char< ' : ' >> ()) {
106
106
state = Separator;
107
107
} else {
108
108
// Unable to match anything: this is the end.
@@ -120,11 +120,11 @@ struct IPv6Parser : ParserCommon, public IPv6Prefix {
120
120
}
121
121
122
122
bool parseAddress () {
123
- return consumeAddressPart () && (!consumePercent () || consumeZoneId ()) && str.empty ();
123
+ return parseAddressPart () && (!consume<Char< ' % ' >> () || consumeZoneId ()) && str.empty ();
124
124
}
125
125
126
126
bool parsePrefix () {
127
- return consumeAddressPart () && consumeSlash () && consumePrefixLength () && str.empty ();
127
+ return parseAddressPart () && consume<Char< ' / ' >> () && consumePrefixLength () && str.empty ();
128
128
}
129
129
};
130
130
0 commit comments