kind.ipp 968 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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_IMPL_KIND_IPP
  10. #define BOOST_JSON_IMPL_KIND_IPP
  11. #include <boost/json/kind.hpp>
  12. #include <ostream>
  13. BOOST_JSON_NS_BEGIN
  14. string_view
  15. to_string(kind k) noexcept
  16. {
  17. switch(k)
  18. {
  19. case kind::array: return "array";
  20. case kind::object: return "object";
  21. case kind::string: return "string";
  22. case kind::int64: return "int64";
  23. case kind::uint64: return "uint64";
  24. case kind::double_: return "double";
  25. case kind::bool_: return "bool";
  26. default: // satisfy warnings
  27. case kind::null: return "null";
  28. }
  29. }
  30. std::ostream&
  31. operator<<(std::ostream& os, kind k)
  32. {
  33. os << to_string(k);
  34. return os;
  35. }
  36. BOOST_JSON_NS_END
  37. #endif