serialize.hpp 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. //
  2. // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
  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_HPP
  10. #define BOOST_JSON_SERIALIZE_HPP
  11. #include <boost/json/detail/config.hpp>
  12. #include <boost/json/value.hpp>
  13. #include <iosfwd>
  14. #include <string>
  15. namespace boost {
  16. namespace json {
  17. /** Return a string representing a serialized element.
  18. This function serializes `t` as JSON and returns
  19. it as a `std::string`.
  20. @par Complexity
  21. Constant or linear in the size of `t`.
  22. @par Exception Safety
  23. Strong guarantee.
  24. Calls to allocate may throw.
  25. @return The serialized string
  26. @param t The value to serialize
  27. */
  28. /** @{ */
  29. BOOST_JSON_DECL
  30. std::string
  31. serialize(value const& t);
  32. BOOST_JSON_DECL
  33. std::string
  34. serialize(array const& t);
  35. BOOST_JSON_DECL
  36. std::string
  37. serialize(object const& t);
  38. BOOST_JSON_DECL
  39. std::string
  40. serialize(string const& t);
  41. BOOST_JSON_DECL
  42. std::string
  43. serialize(string_view t);
  44. /** @} */
  45. } // namespace json
  46. } // namespace boost
  47. #endif