RMQ - RabbitMQ C++ Library
rmqt_fieldvalue.h
1// Copyright 2020-2023 Bloomberg Finance L.P.
2// SPDX-License-Identifier: Apache-2.0
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15
16#ifndef INCLUDED_RMQT_FIELDVALUE
17#define INCLUDED_RMQT_FIELDVALUE
18
19#include <rmqt_shortstring.h>
20
21#include <bdlb_variant.h>
22#include <bdlt_datetime.h>
23#include <bsls_compilerfeatures.h>
24
25#include <bsl_cstdint.h>
26#include <bsl_map.h>
27#include <bsl_memory.h>
28#include <bsl_ostream.h>
29#include <bsl_string.h>
30#include <bsl_utility.h>
31#include <bsl_vector.h>
32
33#ifdef BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS
34#include <bsl_initializer_list.h>
35#endif
36
37namespace BloombergLP {
38namespace rmqt {
39
40struct FieldArray;
41struct FieldTable;
42
70typedef bdlb::Variant<bool,
71 int8_t,
72 uint8_t,
73 int16_t,
74 uint16_t,
75 int32_t,
76 uint32_t,
77 int64_t,
78 uint64_t,
79 float,
80 double,
81 bsl::string,
82 bsl::vector<bsl::uint8_t>,
83 bsl::shared_ptr<FieldArray>,
84 bdlt::Datetime,
85 bsl::shared_ptr<FieldTable> >
86 FieldValue;
87
91struct FieldArray : public bsl::vector<FieldValue> {
92 FieldArray();
93 explicit FieldArray(const bsl::vector<FieldValue>& array);
94
95#ifdef BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS
96 FieldArray(bsl::initializer_list<FieldValue> items);
97
98 static bsl::shared_ptr<FieldArray> make(bsl::initializer_list<FieldValue>);
99#endif
100};
101
108struct FieldTable : public bsl::map<bsl::string, FieldValue> {
109
110 FieldTable();
111 explicit FieldTable(const bsl::map<bsl::string, FieldValue>& t);
112
113#ifdef BSLS_COMPILERFEATURES_SUPPORT_GENERALIZED_INITIALIZERS
115 bsl::initializer_list<bsl::pair<const bsl::string, FieldValue> > items);
116
117 static bsl::shared_ptr<FieldTable>
118 make(bsl::initializer_list<bsl::pair<const bsl::string, FieldValue> >);
119#endif
120
121 bsl::ostream&
122 print(bsl::ostream& stream, int level, int spacesPerLevel) const;
123};
124
125bool operator==(const rmqt::FieldValue& left, const rmqt::FieldValue& right);
126bool operator!=(const rmqt::FieldValue& left, const rmqt::FieldValue& right);
127
128bsl::ostream& operator<<(bsl::ostream& os, const FieldTable& table);
129bsl::ostream& operator<<(bsl::ostream& os,
130 const bsl::shared_ptr<FieldTable>& table);
131bsl::ostream& operator<<(bsl::ostream& os, const FieldValue& value);
132
133} // namespace rmqt
134} // namespace BloombergLP
135
136#endif
Represents AMQP 0.9.1 Field Array (list of FieldValues)
Definition: rmqt_fieldvalue.h:91
Represents AMQP 0.9.1 Field Table (dict of FieldValues)
Definition: rmqt_fieldvalue.h:108