serialize_options.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // Copyright (c) 2023 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_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
  20. @ref serialize,
  21. @ref serializer.
  22. */
  23. struct serialize_options
  24. {
  25. /** Non-standard extension option
  26. Output `Infinity`, `-Infinity` and `NaN` for positive infinity,
  27. negative infinity, and "not a number" doubles.
  28. @see
  29. @ref serialize,
  30. @ref serializer.
  31. */
  32. bool allow_infinity_and_nan = false;
  33. /** Set JSON serialization options on input stream.
  34. The function stores serialization options in the private storage of the
  35. stream. If the stream fails to allocate necessary private storage,
  36. `badbit` will be set on it.
  37. @return Reference to `os`.
  38. @par Complexity
  39. Amortized constant (due to potential memory allocation by the stream).
  40. @par Exception Safety
  41. Strong guarantee.
  42. The stream may throw as configured by
  43. [`std::ios::exceptions`](https://en.cppreference.com/w/cpp/io/basic_ios/exceptions).
  44. @param os The output stream.
  45. @param opts The options to store.
  46. */
  47. BOOST_JSON_DECL
  48. friend
  49. std::ostream&
  50. operator<<( std::ostream& os, serialize_options const& opts );
  51. };
  52. } // namespace json
  53. } // namespace boost
  54. #endif // BOOST_JSON_SERIALIZE_OPTIONS_HPP