writer.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  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_DETAIL_WRITER_HPP
  10. #define BOOST_JSON_DETAIL_WRITER_HPP
  11. #include <boost/json/detail/literals.hpp>
  12. #include <boost/json/detail/stack.hpp>
  13. #include <boost/json/detail/stream.hpp>
  14. #include <boost/json/conversion.hpp>
  15. #include <boost/json/serialize_options.hpp>
  16. #include <boost/json/value.hpp>
  17. namespace boost {
  18. namespace json {
  19. namespace detail {
  20. struct writer
  21. {
  22. enum class state : char;
  23. stack st_;
  24. serialize_options opts_;
  25. const_stream cs0_;
  26. void const* p_ = nullptr;
  27. char buf_[detail::max_number_chars + 1];
  28. writer(
  29. storage_ptr sp,
  30. unsigned char* buf,
  31. std::size_t buf_size,
  32. serialize_options const& opts) noexcept;
  33. inline
  34. bool
  35. suspend(state st);
  36. template<class U, class T>
  37. bool
  38. suspend(state st, U u, T const* po);
  39. };
  40. bool
  41. BOOST_JSON_DECL
  42. write_true(writer& w, stream& ss);
  43. bool
  44. BOOST_JSON_DECL
  45. write_false(writer& w, stream& ss);
  46. bool
  47. BOOST_JSON_DECL
  48. write_null(writer& w, stream& ss);
  49. bool
  50. BOOST_JSON_DECL
  51. write_int64(writer&, stream& ss, std::int64_t i);
  52. bool
  53. BOOST_JSON_DECL
  54. write_uint64(writer&, stream& ss, std::uint64_t i);
  55. bool
  56. BOOST_JSON_DECL
  57. write_double(writer&, stream& ss, double d);
  58. bool
  59. BOOST_JSON_DECL
  60. resume_buffer(writer&, stream& ss);
  61. bool
  62. BOOST_JSON_DECL
  63. write_string(writer& w, stream& ss);
  64. bool
  65. BOOST_JSON_DECL
  66. resume_string(writer& w, stream& ss);
  67. } // namespace detail
  68. } // namespace json
  69. } // namespace boost
  70. #endif // BOOST_JSON_DETAIL_WRITER_HPP