kind.ipp 1006 B

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