Skip to content

Commit

Permalink
allow_invalid_utf16
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaishnav Katiyar committed Apr 10, 2024
1 parent 9f85ed6 commit dc95216
Show file tree
Hide file tree
Showing 6 changed files with 265 additions and 70 deletions.
6 changes: 6 additions & 0 deletions doc/qbk/io/parsing.qbk
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@ with __parse_options__ is possible:

[doc_parsing_6]

When 'allow_invalid_utf16' is enabled, the parser will not throw an error in the case of
illegal leading, trailing, or half a surrogate. Instead, it will replace the
invalid UTF-16 code point(s) with the Unicode replacement character.

[doc_parsing_15]

[caution When enabling comment support take extra care not to drop whitespace
when reading the input. For example, `std::getline` removes the
endline characters from the string it produces.]
Expand Down
21 changes: 14 additions & 7 deletions include/boost/json/basic_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,30 +407,34 @@ class basic_parser
std::integral_constant<bool, StackEmpty_> stack_empty,
std::integral_constant<bool, AllowComments_> allow_comments,
/*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8);
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
bool allow_bad_utf16);

template<bool AllowComments_/*,
bool AllowTrailing_, bool AllowBadUTF8_*/>
const char* resume_value(const char* p,
std::integral_constant<bool, AllowComments_> allow_comments,
/*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8);
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
bool allow_bad_utf16);

template<bool StackEmpty_, bool AllowComments_/*,
bool AllowTrailing_, bool AllowBadUTF8_*/>
const char* parse_object(const char* p,
std::integral_constant<bool, StackEmpty_> stack_empty,
std::integral_constant<bool, AllowComments_> allow_comments,
/*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8);
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
bool allow_bad_utf16);

template<bool StackEmpty_, bool AllowComments_/*,
bool AllowTrailing_, bool AllowBadUTF8_*/>
const char* parse_array(const char* p,
std::integral_constant<bool, StackEmpty_> stack_empty,
std::integral_constant<bool, AllowComments_> allow_comments,
/*std::integral_constant<bool, AllowTrailing_>*/ bool allow_trailing,
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8);
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
bool allow_bad_utf16);

template<int Literal>
const char* parse_literal(const char* p,
Expand All @@ -441,7 +445,8 @@ class basic_parser
const char* parse_string(const char* p,
std::integral_constant<bool, StackEmpty_> stack_empty,
std::integral_constant<bool, IsKey_> is_key,
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8);
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
bool allow_bad_utf16);

template<bool StackEmpty_, char First_, number_precision Numbers_>
const char* parse_number(const char* p,
Expand All @@ -454,7 +459,8 @@ class basic_parser
const char* parse_unescaped(const char* p,
std::integral_constant<bool, StackEmpty_> stack_empty,
std::integral_constant<bool, IsKey_> is_key,
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8);
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
bool allow_bad_utf16);

template<bool StackEmpty_/*, bool IsKey_,
bool AllowBadUTF8_*/>
Expand All @@ -463,7 +469,8 @@ class basic_parser
std::size_t total,
std::integral_constant<bool, StackEmpty_> stack_empty,
/*std::integral_constant<bool, IsKey_>*/ bool is_key,
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8);
/*std::integral_constant<bool, AllowBadUTF8_>*/ bool allow_bad_utf8,
bool allow_bad_utf16);

// intentionally private
std::size_t
Expand Down
Loading

0 comments on commit dc95216

Please sign in to comment.