Metall v0.30
A persistent memory allocator for data-centric analytics
 
Loading...
Searching...
No Matches
json_fwd.hpp
Go to the documentation of this file.
1// Copyright 2021 Lawrence Livermore National Security, LLC and other Metall
2// Project Developers. See the top-level COPYRIGHT file for details.
3//
4// SPDX-License-Identifier: (Apache-2.0 OR MIT)
5
8
9#ifndef METALL_JSON_JSON_FWD_HPP
10#define METALL_JSON_JSON_FWD_HPP
11
12#include <string>
13#include <variant>
14
15#ifdef DOXYGEN_SKIP
17#define METALL_LINK_WITH_BOOST_JSON
18
20#define METALL_BOOST_JSON_SRC_INCLUDED
21#endif
22
23#ifdef METALL_LINK_WITH_BOOST_JSON
24#include <boost/json.hpp>
25#else
26#ifndef METALL_BOOST_JSON_SRC_INCLUDED
27#define METALL_BOOST_JSON_SRC_INCLUDED
28#include <boost/json/src.hpp>
29#endif // METALL_BOOST_JSON_SRC_INCLUDED
30#endif // METALL_LINK_WITH_BOOST_JSON
31
33
37namespace metall::json {
39using null_type = std::monostate;
40
42template <typename char_t, typename traits, typename allocator_type>
45
47template <typename allocator_type = std::allocator<std::byte>>
49} // namespace metall::json
50
51// Forward declaration
52#if !defined(DOXYGEN_SKIP)
53
54namespace metall::json {
55
56template <typename allocator_type = std::allocator<std::byte>>
57class value;
58
59template <typename allocator_type = std::allocator<std::byte>>
60class array;
61
62template <typename char_type = char,
63 typename char_traits = std::char_traits<char_type>,
64 typename allocator_type = std::allocator<char_type>>
65class key_value_pair;
66
67template <typename allocator_type = std::allocator<std::byte>>
68class object;
69
70template <typename allocator_type>
71void swap(value<allocator_type> &, value<allocator_type> &) noexcept;
72
73template <typename allocator_type>
74void swap(string<allocator_type> &, string<allocator_type> &) noexcept;
75
76template <typename allocator_type>
77void swap(array<allocator_type> &, array<allocator_type> &) noexcept;
78
79template <typename allocator_type>
80void swap(object<allocator_type> &, object<allocator_type> &) noexcept;
81
82template <typename char_type, typename char_traits, typename allocator_type>
83void swap(key_value_pair<char_type, char_traits, allocator_type> &,
84 key_value_pair<char_type, char_traits, allocator_type> &) noexcept;
85
86template <typename char_type, typename char_traits, typename allocator_type>
87bool operator==(const key_value_pair<char_type, char_traits, allocator_type> &,
88 const boost::json::key_value_pair &);
89
90template <typename char_type, typename char_traits, typename allocator_type>
91bool operator==(const boost::json::key_value_pair &,
92 const key_value_pair<char_type, char_traits, allocator_type> &);
93
94template <typename char_type, typename char_traits, typename allocator_type>
95bool operator!=(const key_value_pair<char_type, char_traits, allocator_type> &,
96 const boost::json::key_value_pair &);
97
98template <typename char_type, typename char_traits, typename allocator_type>
99bool operator!=(const boost::json::key_value_pair &,
100 const key_value_pair<char_type, char_traits, allocator_type> &);
101
102template <typename allocator_type>
103bool operator==(const value<allocator_type> &, const boost::json::value &);
104
105template <typename allocator_type>
106bool operator==(const boost::json::value &, const value<allocator_type> &);
107
108template <typename allocator_type>
109bool operator!=(const value<allocator_type> &, const boost::json::value &);
110
111template <typename allocator_type>
112bool operator!=(const boost::json::value &, const value<allocator_type> &);
113
114template <typename allocator_type>
115bool operator==(const array<allocator_type> &, const boost::json::array &);
116
117template <typename allocator_type>
118bool operator==(const boost::json::array &, const array<allocator_type> &);
119
120template <typename allocator_type>
121bool operator!=(const array<allocator_type> &, const boost::json::array &);
122
123template <typename allocator_type>
124bool operator!=(const boost::json::array &, const array<allocator_type> &);
125
126template <typename allocator_type>
127bool operator==(const object<allocator_type> &, const boost::json::object &);
128
129template <typename allocator_type>
130bool operator==(const boost::json::object &, const object<allocator_type> &);
131
132template <typename allocator_type>
133bool operator!=(const object<allocator_type> &, const boost::json::object &);
134
135template <typename allocator_type>
136bool operator!=(const boost::json::object &, const object<allocator_type> &);
137
138template <typename char_t, typename traits, typename allocator>
139bool operator==(const basic_string<char_t, traits, allocator> &,
140 const boost::json::string &);
141
142template <typename char_t, typename traits, typename allocator>
143bool operator==(const boost::json::string &,
144 const basic_string<char_t, traits, allocator> &);
145
146template <typename char_t, typename traits, typename allocator>
147bool operator!=(const basic_string<char_t, traits, allocator> &,
148 const boost::json::string &);
149
150template <typename char_t, typename traits, typename allocator>
151bool operator!=(const boost::json::string &,
152 const basic_string<char_t, traits, allocator> &);
153
154template <typename allocator_type, int indent_size = 2>
155void pretty_print(std::ostream &, const value<allocator_type> &);
156
157template <typename allocator_type>
158std::string serialize(const value<allocator_type> &);
159
160template <typename allocator_type>
161std::string serialize(const object<allocator_type> &);
162
163template <typename allocator_type>
164std::string serialize(const array<allocator_type> &);
165
166template <typename char_type, typename traits, typename allocator_type>
167std::string serialize(const basic_string<char_type, traits, allocator_type> &);
168
169template <typename allocator_type>
170std::ostream &operator<<(std::ostream &, const value<allocator_type> &);
171
172template <typename allocator_type>
173std::ostream &operator<<(std::ostream &, const object<allocator_type> &);
174
175template <typename allocator_type>
176std::ostream &operator<<(std::ostream &, const array<allocator_type> &);
177
178template <typename allocator_type = std::allocator<std::byte>>
179value<allocator_type> parse(std::string_view,
180 const allocator_type &allocator = allocator_type());
181
182template <typename T, typename allocator_type = std::allocator<std::byte>>
183value<allocator_type> value_from(
184 T &&, const allocator_type &allocator = allocator_type());
185
186template <typename T, typename allocator_type>
187T value_to(const value<allocator_type> &);
188
189namespace jsndtl {
190
191template <typename allocator_type, typename other_value_type>
192bool general_value_equal(const value<allocator_type> &,
193 const other_value_type &) noexcept;
194
195template <typename char_t, typename traits, typename allocator,
196 typename other_string_type>
197bool general_string_equal(const basic_string<char_t, traits, allocator> &,
198 const other_string_type &) noexcept;
199
200template <typename allocator_type, typename other_array_type>
201bool general_array_equal(const array<allocator_type> &,
202 const other_array_type &) noexcept;
203
204template <typename allocator_type, typename other_object_type>
205bool general_object_equal(const object<allocator_type> &,
206 const other_object_type &) noexcept;
207
208template <typename char_type, typename char_traits, typename allocator_type,
209 typename other_key_value_pair_type>
211 const key_value_pair<char_type, char_traits, allocator_type> &,
212 const other_key_value_pair_type &) noexcept;
213} // namespace jsndtl
214
215#endif // DOXYGEN_SKIP
216
217} // namespace metall::json
218
219#endif // METALL_JSON_JSON_FWD_HPP
boost::container::vector< T, Allocator > vector
A vector container that uses Metall as its default allocator.
Definition vector.hpp:17
bool general_value_equal(const value< allocator_type > &value, const other_value_type &other_value) noexcept
Provides 'equal' calculation for other value types that have the same interface as the value class.
Definition value.hpp:28
bool general_string_equal(const basic_string< char_t, traits, allocator > &string, const other_string_type &other_string) noexcept
Definition string.hpp:17
bool general_array_equal(const array< allocator_type > &array, const other_array_type &other_array) noexcept
Provides 'equal' calculation for other array types that have the same interface as the array class.
Definition array.hpp:28
bool general_key_value_pair_equal(const key_value_pair< char_type, char_traits, allocator_type > &key_value, const other_key_value_pair_type &other_key_value) noexcept
Provides 'equal' calculation for other key-value types that have the same interface as the object cla...
Definition key_value_pair.hpp:26
Namespace for Metall JSON container, which is in an experimental phase.
Definition array.hpp:17
value< allocator_type > parse(std::string_view input_json_string, const allocator_type &allocator=allocator_type())
Parses a JSON represented as a string.
Definition parse.hpp:28
std::ostream & operator<<(std::ostream &os, const value< allocator_type > &val)
Definition serialize.hpp:51
std::string serialize(const value< allocator_type > &input)
Definition serialize.hpp:22
metall::container::basic_string< char_t, traits, allocator_type > basic_string
JSON basic string type.
Definition json_fwd.hpp:44
std::monostate null_type
JSON null type.
Definition json_fwd.hpp:39
bool operator==(const key_value_pair< char_type, char_traits, allocator_type > &key_value, const bj::key_value_pair &bj_key_value)
Definition equal.hpp:18
void swap(array< allocator_type > &lhd, array< allocator_type > &rhd) noexcept
Swap value instances.
Definition array.hpp:193
void pretty_print(std::ostream &os, const value< allocator_type > &json_value)
Pretty-prints a JSON value.
Definition pretty_print.hpp:75
bool operator!=(const key_value_pair< char_type, char_traits, allocator_type > &key_value, const bj::key_value_pair &bj_key_value)
Definition equal.hpp:32
T value_to(const mj::value< allocator_type > &value)
Convert a JSON value to another data type.
Definition value_to.hpp:72
value< allocator_type > value_from(T &&input_data, const allocator_type &allocator=allocator_type())
Convert an input data and construct a JSON value.
Definition value_from.hpp:71
basic_string< char, std::char_traits< char >, allocator_type > string
JSON string.
Definition json_fwd.hpp:48