Metall  v0.28
A persistent memory allocator for data-centric analytics
equal.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 
6 #ifndef METALL_JSON_EQUAL_HPP
7 #define METALL_JSON_EQUAL_HPP
8 
10 
11 namespace metall::json {
12 
13 namespace {
14 namespace bj = boost::json;
15 }
16 
17 template <typename char_type, typename char_traits, typename allocator_type>
18 inline bool operator==(
20  const bj::key_value_pair &bj_key_value) {
21  return jsndtl::general_key_value_pair_equal(key_value, bj_key_value);
22 }
23 
24 template <typename char_type, typename char_traits, typename allocator_type>
25 inline bool operator==(
26  const bj::key_value_pair &bj_key_value,
28  return key_value == bj_key_value;
29 }
30 
31 template <typename char_type, typename char_traits, typename allocator_type>
32 inline bool operator!=(
34  const bj::key_value_pair &bj_key_value) {
35  return !(key_value == bj_key_value);
36 }
37 
38 template <typename char_type, typename char_traits, typename allocator_type>
39 inline bool operator!=(
40  const bj::key_value_pair &bj_key_value,
42  return key_value != bj_key_value;
43 }
44 
45 template <typename allocator_type>
47  const bj::value &bj_value) {
48  return jsndtl::general_value_equal(value, bj_value);
49 }
50 
51 template <typename allocator_type>
52 inline bool operator==(const bj::value &bj_value,
54  return value == bj_value;
55 }
56 
57 template <typename allocator_type>
59  const bj::value &bj_value) {
60  return !(value == bj_value);
61 }
62 
63 template <typename allocator_type>
64 inline bool operator!=(const bj::value &bj_value,
66  return value != bj_value;
67 }
68 
69 template <typename allocator_type>
71  const bj::array &bj_array) {
72  return jsndtl::general_array_equal(array, bj_array);
73 }
74 
75 template <typename allocator_type>
76 inline bool operator==(const bj::array &bj_array,
78  return array == bj_array;
79 }
80 
81 template <typename allocator_type>
83  const bj::array &bj_array) {
84  return !(array == bj_array);
85 }
86 
87 template <typename allocator_type>
88 inline bool operator!=(const bj::array &bj_array,
90  return array != bj_array;
91 }
92 
93 template <typename allocator_type>
94 inline bool operator==(const object<allocator_type> &object,
95  const bj::object &bj_object) {
96  return jsndtl::general_object_equal(object, bj_object);
97 }
98 
99 template <typename allocator_type>
100 inline bool operator==(const bj::object &bj_object,
101  const object<allocator_type> &object) {
102  return object == bj_object;
103 }
104 
105 template <typename allocator_type>
106 inline bool operator!=(const object<allocator_type> &object,
107  const bj::object &bj_object) {
108  return !(object == bj_object);
109 }
110 
111 template <typename allocator_type>
112 inline bool operator!=(const bj::object &bj_object,
113  const object<allocator_type> &object) {
114  return object != bj_object;
115 }
116 
117 template <typename char_t, typename traits, typename allocator>
119  const bj::string &bj_string) {
120  return jsndtl::general_string_equal(string, bj_string);
121 }
122 
123 template <typename char_t, typename traits, typename allocator>
124 inline bool operator==(const bj::string &bj_string,
126  return string == bj_string;
127 }
128 
129 template <typename char_t, typename traits, typename allocator>
131  const bj::string &bj_string) {
132  return !(string == bj_string);
133 }
134 
135 template <typename char_t, typename traits, typename allocator>
136 inline bool operator!=(const bj::string &bj_string,
138  return string != bj_string;
139 }
140 } // namespace metall::json
141 #endif // METALL_JSON_EQUAL_HPP
JSON array. An array is an ordered collection of values.
Definition: array.hpp:43
A class for holding a pair of JSON string (as its key) and JSON value (as its value).
Definition: key_value_pair.hpp:47
JSON object. An object is a table key and value pairs. The order of key-value pairs depends on the im...
Definition: object.hpp:22
basic_string< char > string
A string container that uses char as its character type and Metall as its default allocator.
Definition: string.hpp:23
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_object_equal(const object< allocator_type > &object, const other_object_type &other_object) noexcept
Provides 'equal' calculation for other object types that have the same interface as the object class.
Definition: object.hpp:38
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
metall::container::basic_string< char_t, traits, allocator_type > basic_string
JSON basic string type.
Definition: json_fwd.hpp:44
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
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