serialize_options.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //
  2. // Copyright (c) 2023 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_SERIALIZE_OPTIONS_HPP
  10. #define BOOST_JSON_SERIALIZE_OPTIONS_HPP
  11. #include <boost/json/detail/config.hpp>
  12. #include <iosfwd>
  13. namespace boost {
  14. namespace json {
  15. /** Serialize options
  16. This structure is used for specifying whether to allow non-standard
  17. extensions. Default-constructed options specify that only standard JSON is
  18. produced.
  19. @see @ref serialize, @ref serializer.
  20. */
  21. struct serialize_options
  22. {
  23. /** Non-standard extension option.
  24. Output `Infinity`, `-Infinity` and `NaN` for positive infinity,
  25. negative infinity, and "not a number" doubles.
  26. @see @ref serialize, @ref serializer.
  27. */
  28. bool allow_infinity_and_nan = false;
  29. /** Set JSON serialization options on input stream.
  30. The function stores serialization options in the private storage of the
  31. stream. If the stream fails to allocate necessary private storage,
  32. `badbit` will be set on it.
  33. @return Reference to `os`.
  34. @par Complexity
  35. Amortized constant (due to potential memory allocation by the stream).
  36. @par Exception Safety
  37. Strong guarantee. The stream may throw as configured by @ref
  38. std::ios::exceptions.
  39. @param os The output stream.
  40. @param opts The options to store.
  41. */
  42. BOOST_JSON_DECL
  43. friend
  44. std::ostream&
  45. operator<<( std::ostream& os, serialize_options const& opts );
  46. };
  47. } // namespace json
  48. } // namespace boost
  49. #endif // BOOST_JSON_SERIALIZE_OPTIONS_HPP