Skip to content

Commit 7c69c17

Browse files
thewtexhjmjohnson
authored andcommitted
COMP: Avoid ... operator
To address: D:\a\ITKPerformanceBenchmarking\ITKPerformanceBenchmarking\src\jsonxx.cc(222): error C2143: syntax error: missing ':' before '...' D:\a\ITKPerformanceBenchmarking\ITKPerformanceBenchmarking\src\jsonxx.cc(222): error C2059: syntax error: '...'
1 parent 43b11a6 commit 7c69c17

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

src/jsonxx.cc

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,53 @@ parse_number(std::istream & input, Number & value)
239239
{
240240
input.clear();
241241
input.seekg(rollback);
242+
243+
switch (input.peek()) {
244+
case '-':
245+
input.get();
246+
value = -std::numeric_limits<Number>::infinity();
247+
break;
248+
case '+':
249+
case '0':
250+
case '1':
251+
case '2':
252+
case '3':
253+
case '4':
254+
case '5':
255+
case '6':
256+
case '7':
257+
case '8':
258+
case '9':
259+
input.get();
260+
value = std::numeric_limits<Number>::infinity();
261+
break;
262+
default:
263+
return false;
264+
}
265+
266+
int ch;
267+
do {
268+
ch = input.get();
269+
} while (isdigit(ch));
270+
271+
if (ch != 'E' && ch != 'e') {
272+
return false;
273+
}
274+
275+
int exponent;
276+
input >> exponent;
277+
return !input.fail();
278+
}
279+
280+
bool parse_bool(std::istream& input, Boolean& value) {
281+
if (match("true", input)) {
282+
value = true;
283+
return true;
284+
}
285+
if (match("false", input)) {
286+
value = false;
287+
return true;
288+
}
242289
return false;
243290
}
244291
return true;

0 commit comments

Comments
 (0)