1  
//
1  
//
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
2  
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
3  
//
3  
//
4  
// Distributed under the Boost Software License, Version 1.0. (See accompanying
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)
5  
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6  
//
6  
//
7  
// Official repository: https://github.com/boostorg/json
7  
// Official repository: https://github.com/boostorg/json
8  
//
8  
//
9  

9  

10  
#ifndef BOOST_JSON_IMPL_KIND_IPP
10  
#ifndef BOOST_JSON_IMPL_KIND_IPP
11  
#define BOOST_JSON_IMPL_KIND_IPP
11  
#define BOOST_JSON_IMPL_KIND_IPP
12  

12  

13  
#include <boost/json/kind.hpp>
13  
#include <boost/json/kind.hpp>
14  
#include <ostream>
14  
#include <ostream>
15  

15  

16  
namespace boost {
16  
namespace boost {
17  
namespace json {
17  
namespace json {
18  

18  

19  
string_view
19  
string_view
20  
to_string(kind k) noexcept
20  
to_string(kind k) noexcept
21  
{
21  
{
22  
    switch(k)
22  
    switch(k)
23  
    {
23  
    {
24  
    case kind::array:   return "array";
24  
    case kind::array:   return "array";
25  
    case kind::object:  return "object";
25  
    case kind::object:  return "object";
26  
    case kind::string:  return "string";
26  
    case kind::string:  return "string";
27  
    case kind::int64:   return "int64";
27  
    case kind::int64:   return "int64";
28  
    case kind::uint64:  return "uint64";
28  
    case kind::uint64:  return "uint64";
29  
    case kind::double_: return "double";
29  
    case kind::double_: return "double";
30  
    case kind::bool_:   return "bool";
30  
    case kind::bool_:   return "bool";
31  
    default: // satisfy warnings
31  
    default: // satisfy warnings
32  
    case kind::null:    return "null";
32  
    case kind::null:    return "null";
33  
    }
33  
    }
34  
}
34  
}
35  

35  

36  
std::ostream&
36  
std::ostream&
37  
operator<<(std::ostream& os, kind k)
37  
operator<<(std::ostream& os, kind k)
38  
{
38  
{
39  
    os << to_string(k);
39  
    os << to_string(k);
40  
    return os;
40  
    return os;
41  
}
41  
}
42  

42  

43  
} // namespace json
43  
} // namespace json
44  
} // namespace boost
44  
} // namespace boost
45  

45  

46  
#endif
46  
#endif