set_pointer_options.hpp 2.1 KB

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