set_pointer_options.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // Copyright (c) 2022 Dmitry Arkhipov (grisumbras@yandex.ru)
  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_SET_POINTER_OPTIONS_HPP
  10. #define BOOST_JSON_SET_POINTER_OPTIONS_HPP
  11. #include <boost/json/detail/config.hpp>
  12. namespace boost {
  13. namespace json {
  14. /** Options for @ref value::set_at_pointer
  15. This structure is used for controlling behavior of
  16. @ref value::set_at_pointer regarding creation of intermediate elements.
  17. */
  18. struct set_pointer_options
  19. {
  20. /** Whether to create arrays.
  21. The option controls whether arrays are created when a pointer token is
  22. a number or a past-the-end marker.
  23. */
  24. bool create_arrays = true;
  25. /** Whether to create objects
  26. The option controls whether objects are created for valid pointer
  27. tokens.
  28. */
  29. bool create_objects = true;
  30. /** Whether to replace non-null scalars.
  31. If the option is `true` any non-object, non-array value can be replaced
  32. by either an @ref object or a @ref array. If it's `false`, only `null`
  33. values can be replaced.
  34. */
  35. bool replace_any_scalar = false;
  36. /** Maximum amount of elements added per one pointer token.
  37. When addressing @ref array elements the number represented by pointer
  38. token can exceed the size of the array. In that case several elements
  39. may be created to satisfy the request. This option limits the amount of
  40. elements that can be added per one pointer token. This can be
  41. important, because in general such operations can be dangerous, since a
  42. relatively small string `"/18446744073709551616"` can request all of
  43. the machine's memory. For that reason the default value for this option
  44. is 1, that is no more than 1 element can be added per one pointer
  45. token.
  46. */
  47. std::size_t max_created_elements = 1;
  48. };
  49. } // namespace json
  50. } // namespace boost
  51. #endif // BOOST_JSON_SET_POINTER_OPTIONS_HPP