liuxiaolong
2021-07-20 58d904a328c0d849769b483e901a0be9426b8209
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
//
// Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
// Official repository: https://github.com/boostorg/json
//
 
#ifndef BOOST_JSON_KIND_HPP
#define BOOST_JSON_KIND_HPP
 
#include <boost/json/detail/config.hpp>
#include <boost/json/string_view.hpp>
#include <iosfwd>
 
BOOST_JSON_NS_BEGIN
 
/** Constants for identifying the type of a value
 
    These values are returned from @ref value::kind
*/
// Order matters
enum class kind : unsigned char
{
    /// The null value.
    null,
 
    /// A `bool`.
    bool_,
 
    /// A `std::int64_t`
    int64,
 
    /// A `std::uint64_t`
    uint64,
 
    /// A `double`.
    double_,
 
    /// A @ref string.
    string,
 
    /// An @ref array.
    array,
 
    /// An @ref object.
    object
};
 
/** Return a string representing a kind.
 
    This provides a human-readable string
    representing a @ref kind. This may be
    useful for diagnostics.
 
    @returns The string.
 
    @param k The kind.
*/
BOOST_JSON_DECL
string_view
to_string(kind k) noexcept;
 
/** Format a kind to an output stream.
 
    This allows a @ref kind to be formatted as
    a string, typically for diagnostics.
 
    @returns The output stream.
 
    @param os The output stream to format to.
 
    @param k The kind to format.
*/
BOOST_JSON_DECL
std::ostream&
operator<<(std::ostream& os, kind k);
 
/** A tag type used to select a @ref value constructor overload.
 
    The library provides the constant @ref array_kind
    which may be used to select the @ref value constructor
    that creates an empty @ref array.
 
    @see @ref array_kind
*/
struct array_kind_t
{
};
 
/** A tag type used to select a @ref value constructor overload.
 
    The library provides the constant @ref object_kind
    which may be used to select the @ref value constructor
    that creates an empty @ref object.
 
    @see @ref object_kind
*/
struct object_kind_t
{
};
 
/** A tag type used to select a @ref value constructor overload.
 
    The library provides the constant @ref string_kind
    which may be used to select the @ref value constructor
    that creates an empty @ref string.
 
    @see @ref string_kind
*/
struct string_kind_t
{
};
 
/** A constant used to select a @ref value constructor overload.
 
    The library provides this constant to allow efficient
    construction of a @ref value containing an empty @ref array.
 
    @par Example
    @code
    storage_ptr sp;
    value jv( array_kind, sp ); // sp is an optional parameter
    @endcode
 
    @see @ref array_kind_t
*/
BOOST_JSON_INLINE_VARIABLE(array_kind, array_kind_t);
 
/** A constant used to select a @ref value constructor overload.
 
    The library provides this constant to allow efficient
    construction of a @ref value containing an empty @ref object.
 
    @par Example
    @code
    storage_ptr sp;
    value jv( object_kind, sp ); // sp is an optional parameter
    @endcode
 
    @see @ref object_kind_t
*/
BOOST_JSON_INLINE_VARIABLE(object_kind, object_kind_t);
 
/** A constant used to select a @ref value constructor overload.
 
    The library provides this constant to allow efficient
    construction of a @ref value containing an empty @ref string.
 
    @par Example
    @code
    storage_ptr sp;
    value jv( string_kind, sp ); // sp is an optional parameter
    @endcode
 
    @see @ref string_kind_t
*/
BOOST_JSON_INLINE_VARIABLE(string_kind, string_kind_t);
 
BOOST_JSON_NS_END
 
#endif