parse_options.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. BOOST_JSON_NS_BEGIN
  13. /** Parser options
  14. This structure is used for specifying
  15. maximum parsing depth, and whether
  16. to allow various non-standard extensions.
  17. Default-constructed options set maximum
  18. parsing depth to 32 and specify that only
  19. standard JSON is allowed,
  20. @see
  21. @ref basic_parser,
  22. @ref parser.
  23. */
  24. struct parse_options
  25. {
  26. /** Maximum nesting level of arrays and objects.
  27. This specifies the maximum number of nested
  28. structures allowed while parsing a JSON. If
  29. this limit is exceeded during a parse, an
  30. error is returned.
  31. @see
  32. @ref basic_parser,
  33. @ref stream_parser.
  34. */
  35. std::size_t max_depth = 32;
  36. /** Non-standard extension option
  37. Allow C and C++ style comments to appear
  38. anywhere that whitespace is permissible.
  39. @see
  40. @ref basic_parser,
  41. @ref stream_parser.
  42. */
  43. bool allow_comments = false;
  44. /** Non-standard extension option
  45. Allow a trailing comma to appear after
  46. the last element of any array or object.
  47. @see
  48. @ref basic_parser,
  49. @ref stream_parser.
  50. */
  51. bool allow_trailing_commas = false;
  52. /** Non-standard extension option
  53. Allow invalid UTF-8 sequnces to appear
  54. in keys and strings.
  55. @note This increases parsing performance.
  56. @see
  57. @ref basic_parser,
  58. @ref stream_parser.
  59. */
  60. bool allow_invalid_utf8 = false;
  61. };
  62. BOOST_JSON_NS_END
  63. #endif