Skip to content

Commit 66a2807

Browse files
committed
Rename invalid_json to simdjson_error
1 parent c3009eb commit 66a2807

File tree

4 files changed

+35
-35
lines changed

4 files changed

+35
-35
lines changed

benchmark/bench_parse_call.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ static void parser_parse_exception(State& state) {
3030
for (auto _ : state) {
3131
try {
3232
UNUSED document &doc = parser.parse(EMPTY_ARRAY);
33-
} catch(invalid_json &j) {
33+
} catch(simdjson_error &j) {
3434
return;
3535
}
3636
}
@@ -55,7 +55,7 @@ static void document_parse_exception(State& state) {
5555
for (auto _ : state) {
5656
try {
5757
UNUSED document doc = document::parse(EMPTY_ARRAY);
58-
} catch(invalid_json &j) {
58+
} catch(simdjson_error &j) {
5959
return;
6060
}
6161
}

include/simdjson/document.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -83,14 +83,14 @@ class document {
8383
* Read the root element of this document as a JSON array.
8484
*
8585
* @return The JSON array.
86-
* @exception invalid_json(UNEXPECTED_TYPE) if the JSON element is not an array
86+
* @exception simdjson_error(UNEXPECTED_TYPE) if the JSON element is not an array
8787
*/
8888
operator array() const noexcept(false);
8989
/**
9090
* Read this element as a JSON object (key/value pairs).
9191
*
9292
* @return The JSON object.
93-
* @exception invalid_json(UNEXPECTED_TYPE) if the JSON element is not an object
93+
* @exception simdjson_error(UNEXPECTED_TYPE) if the JSON element is not an object
9494
*/
9595
operator object() const noexcept(false);
9696

@@ -239,7 +239,7 @@ class document::doc_result {
239239
* Return the document, or throw an exception if it is invalid.
240240
*
241241
* @return the document.
242-
* @exception invalid_json if the document is invalid or there was an error parsing it.
242+
* @exception simdjson_error if the document is invalid or there was an error parsing it.
243243
*/
244244
operator document() noexcept(false);
245245

@@ -298,7 +298,7 @@ class document::doc_ref_result {
298298
* A reference to the document, or throw an exception if it is invalid.
299299
*
300300
* @return the document.
301-
* @exception invalid_json if the document is invalid or there was an error parsing it.
301+
* @exception simdjson_error if the document is invalid or there was an error parsing it.
302302
*/
303303
operator document&() noexcept(false);
304304

@@ -449,7 +449,7 @@ class document::element : protected document::tape_ref {
449449
* Read this element as a boolean.
450450
*
451451
* @return The boolean value
452-
* @exception invalid_json(UNEXPECTED_TYPE) if the JSON element is not a boolean.
452+
* @exception simdjson_error(UNEXPECTED_TYPE) if the JSON element is not a boolean.
453453
*/
454454
inline operator bool() const noexcept(false);
455455

@@ -460,7 +460,7 @@ class document::element : protected document::tape_ref {
460460
* an actual string.
461461
*
462462
* @return The string value.
463-
* @exception invalid_json(UNEXPECTED_TYPE) if the JSON element is not a string.
463+
* @exception simdjson_error(UNEXPECTED_TYPE) if the JSON element is not a string.
464464
*/
465465
inline explicit operator const char*() const noexcept(false);
466466

@@ -471,46 +471,46 @@ class document::element : protected document::tape_ref {
471471
* an actual string.
472472
*
473473
* @return The string value.
474-
* @exception invalid_json(UNEXPECTED_TYPE) if the JSON element is not a string.
474+
* @exception simdjson_error(UNEXPECTED_TYPE) if the JSON element is not a string.
475475
*/
476476
inline operator std::string_view() const noexcept(false);
477477

478478
/**
479479
* Read this element as an unsigned integer.
480480
*
481481
* @return The integer value.
482-
* @exception invalid_json(UNEXPECTED_TYPE) if the JSON element is not an integer
483-
* @exception invalid_json(NUMBER_OUT_OF_RANGE) if the integer doesn't fit in 64 bits or is negative
482+
* @exception simdjson_error(UNEXPECTED_TYPE) if the JSON element is not an integer
483+
* @exception simdjson_error(NUMBER_OUT_OF_RANGE) if the integer doesn't fit in 64 bits or is negative
484484
*/
485485
inline operator uint64_t() const noexcept(false);
486486
/**
487487
* Read this element as an signed integer.
488488
*
489489
* @return The integer value.
490-
* @exception invalid_json(UNEXPECTED_TYPE) if the JSON element is not an integer
491-
* @exception invalid_json(NUMBER_OUT_OF_RANGE) if the integer doesn't fit in 64 bits
490+
* @exception simdjson_error(UNEXPECTED_TYPE) if the JSON element is not an integer
491+
* @exception simdjson_error(NUMBER_OUT_OF_RANGE) if the integer doesn't fit in 64 bits
492492
*/
493493
inline operator int64_t() const noexcept(false);
494494
/**
495495
* Read this element as an double.
496496
*
497497
* @return The double value.
498-
* @exception invalid_json(UNEXPECTED_TYPE) if the JSON element is not a number
499-
* @exception invalid_json(NUMBER_OUT_OF_RANGE) if the integer doesn't fit in 64 bits or is negative
498+
* @exception simdjson_error(UNEXPECTED_TYPE) if the JSON element is not a number
499+
* @exception simdjson_error(NUMBER_OUT_OF_RANGE) if the integer doesn't fit in 64 bits or is negative
500500
*/
501501
inline operator double() const noexcept(false);
502502
/**
503503
* Read this element as a JSON array.
504504
*
505505
* @return The JSON array.
506-
* @exception invalid_json(UNEXPECTED_TYPE) if the JSON element is not an array
506+
* @exception simdjson_error(UNEXPECTED_TYPE) if the JSON element is not an array
507507
*/
508508
inline operator document::array() const noexcept(false);
509509
/**
510510
* Read this element as a JSON object (key/value pairs).
511511
*
512512
* @return The JSON object.
513-
* @exception invalid_json(UNEXPECTED_TYPE) if the JSON element is not an object
513+
* @exception simdjson_error(UNEXPECTED_TYPE) if the JSON element is not an object
514514
*/
515515
inline operator document::object() const noexcept(false);
516516

@@ -1187,7 +1187,7 @@ class document::parser {
11871187

11881188
// type aliases for backcompat
11891189
using Iterator = document::iterator;
1190-
using InvalidJSON = invalid_json;
1190+
using InvalidJSON = simdjson_error;
11911191

11921192
// Next location to write to in the tape
11931193
uint32_t current_loc{0};

include/simdjson/error.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,12 @@ inline std::ostream& operator<<(std::ostream& out, error_code error) noexcept;
5252
/**
5353
* Exception thrown when an exception-supporting simdjson method is called
5454
*/
55-
struct invalid_json : public std::exception {
55+
struct simdjson_error : public std::exception {
5656
/**
5757
* Create an exception from a simdjson error code.
5858
* @param error The error code
5959
*/
60-
invalid_json(error_code error) noexcept : _error{error} { }
60+
simdjson_error(error_code error) noexcept : _error{error} { }
6161
/** The error message */
6262
const char *what() const noexcept { return error_message(error()); }
6363
error_code error() const noexcept { return _error; }

include/simdjson/inline/document.h

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -20,32 +20,32 @@ template<typename T>
2020
inline document::element_result<T>::element_result(error_code _error) noexcept : value(), error{_error} {}
2121
template<>
2222
inline document::element_result<std::string_view>::operator std::string_view() const noexcept(false) {
23-
if (error) { throw invalid_json(error); }
23+
if (error) { throw simdjson_error(error); }
2424
return value;
2525
}
2626
template<>
2727
inline document::element_result<const char *>::operator const char *() const noexcept(false) {
28-
if (error) { throw invalid_json(error); }
28+
if (error) { throw simdjson_error(error); }
2929
return value;
3030
}
3131
template<>
3232
inline document::element_result<bool>::operator bool() const noexcept(false) {
33-
if (error) { throw invalid_json(error); }
33+
if (error) { throw simdjson_error(error); }
3434
return value;
3535
}
3636
template<>
3737
inline document::element_result<uint64_t>::operator uint64_t() const noexcept(false) {
38-
if (error) { throw invalid_json(error); }
38+
if (error) { throw simdjson_error(error); }
3939
return value;
4040
}
4141
template<>
4242
inline document::element_result<int64_t>::operator int64_t() const noexcept(false) {
43-
if (error) { throw invalid_json(error); }
43+
if (error) { throw simdjson_error(error); }
4444
return value;
4545
}
4646
template<>
4747
inline document::element_result<double>::operator double() const noexcept(false) {
48-
if (error) { throw invalid_json(error); }
48+
if (error) { throw simdjson_error(error); }
4949
return value;
5050
}
5151

@@ -55,15 +55,15 @@ inline document::element_result<double>::operator double() const noexcept(false)
5555
inline document::element_result<document::array>::element_result(document::array _value) noexcept : value(_value), error{SUCCESS} {}
5656
inline document::element_result<document::array>::element_result(error_code _error) noexcept : value(), error{_error} {}
5757
inline document::element_result<document::array>::operator document::array() const noexcept(false) {
58-
if (error) { throw invalid_json(error); }
58+
if (error) { throw simdjson_error(error); }
5959
return value;
6060
}
6161
inline document::array::iterator document::element_result<document::array>::begin() const noexcept(false) {
62-
if (error) { throw invalid_json(error); }
62+
if (error) { throw simdjson_error(error); }
6363
return value.begin();
6464
}
6565
inline document::array::iterator document::element_result<document::array>::end() const noexcept(false) {
66-
if (error) { throw invalid_json(error); }
66+
if (error) { throw simdjson_error(error); }
6767
return value.end();
6868
}
6969

@@ -73,7 +73,7 @@ inline document::array::iterator document::element_result<document::array>::end(
7373
inline document::element_result<document::object>::element_result(document::object _value) noexcept : value(_value), error{SUCCESS} {}
7474
inline document::element_result<document::object>::element_result(error_code _error) noexcept : value(), error{_error} {}
7575
inline document::element_result<document::object>::operator document::object() const noexcept(false) {
76-
if (error) { throw invalid_json(error); }
76+
if (error) { throw simdjson_error(error); }
7777
return value;
7878
}
7979
inline document::element_result<document::element> document::element_result<document::object>::operator[](const std::string_view &key) const noexcept {
@@ -85,11 +85,11 @@ inline document::element_result<document::element> document::element_result<docu
8585
return value[key];
8686
}
8787
inline document::object::iterator document::element_result<document::object>::begin() const noexcept(false) {
88-
if (error) { throw invalid_json(error); }
88+
if (error) { throw simdjson_error(error); }
8989
return value.begin();
9090
}
9191
inline document::object::iterator document::element_result<document::object>::end() const noexcept(false) {
92-
if (error) { throw invalid_json(error); }
92+
if (error) { throw simdjson_error(error); }
9393
return value.end();
9494
}
9595

@@ -441,7 +441,7 @@ inline bool document::dump_raw_tape(std::ostream &os) const noexcept {
441441
inline document::doc_ref_result::doc_ref_result(document &_doc, error_code _error) noexcept : doc(_doc), error(_error) { }
442442
inline document::doc_ref_result::operator document&() noexcept(false) {
443443
if (error) {
444-
throw invalid_json(error);
444+
throw simdjson_error(error);
445445
}
446446
return doc;
447447
}
@@ -454,7 +454,7 @@ inline document::doc_result::doc_result(document &&_doc) noexcept : doc(std::mov
454454
inline document::doc_result::doc_result(error_code _error) noexcept : doc(), error(_error) { }
455455
inline document::doc_result::operator document() noexcept(false) {
456456
if (error) {
457-
throw invalid_json(error);
457+
throw simdjson_error(error);
458458
}
459459
return std::move(doc);
460460
}
@@ -473,7 +473,7 @@ inline bool document::parser::dump_raw_tape(std::ostream &os) const noexcept {
473473
}
474474
inline const document &document::parser::get_document() const noexcept(false) {
475475
if (!is_valid()) {
476-
throw invalid_json(error);
476+
throw simdjson_error(error);
477477
}
478478
return doc;
479479
}

0 commit comments

Comments
 (0)