parse_options.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. //
  2. // Copyright (c) 2020 Krystian Stasiowski (sdkrystian@gmail.com)
  3. //
  4. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  5. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // Official repository: https://github.com/boostorg/json
  8. //
  9. #ifndef BOOST_JSON_PARSE_OPTIONS_HPP
  10. #define BOOST_JSON_PARSE_OPTIONS_HPP
  11. #include <boost/json/detail/config.hpp>
  12. namespace boost {
  13. namespace json {
  14. /** Parser options
  15. This structure is used for specifying
  16. maximum parsing depth, and whether
  17. to allow various non-standard extensions.
  18. Default-constructed options set maximum
  19. parsing depth to 32 and specify that only
  20. standard JSON is allowed,
  21. @see
  22. @ref basic_parser,
  23. @ref parser.
  24. */
  25. struct parse_options
  26. {
  27. /** Maximum nesting level of arrays and objects.
  28. This specifies the maximum number of nested
  29. structures allowed while parsing a JSON text. If
  30. this limit is exceeded during a parse, an
  31. error is returned.
  32. @see
  33. @ref basic_parser,
  34. @ref stream_parser.
  35. */
  36. std::size_t max_depth = 32;
  37. /** Non-standard extension option
  38. Allow C and C++ style comments to appear
  39. anywhere that whitespace is permissible.
  40. @see
  41. @ref basic_parser,
  42. @ref stream_parser.
  43. */
  44. bool allow_comments = false;
  45. /** Non-standard extension option
  46. Allow a trailing comma to appear after
  47. the last element of any array or object.
  48. @see
  49. @ref basic_parser,
  50. @ref stream_parser.
  51. */
  52. bool allow_trailing_commas = false;
  53. /** Non-standard extension option
  54. Allow invalid UTF-8 sequnces to appear
  55. in keys and strings.
  56. @note This increases parsing performance.
  57. @see
  58. @ref basic_parser,
  59. @ref stream_parser.
  60. */
  61. bool allow_invalid_utf8 = false;
  62. };
  63. } // namespace json
  64. } // namespace boost
  65. #endif