31template <
class Archive_concrete_type>
32template <
class Field_type, Field_size field_size_defined,
typename Enabler>
35 m_archive << Field_wrapper<const Field_type, field_size_defined>(field);
36 m_archive.put_field_separator();
39template <
class Archive_concrete_type>
40template <
class Field_type, Field_size field_size_defined,
typename Enabler>
44 m_archive.process_field_separator();
47template <
class Archive_concrete_type>
48template <
class Field_type, Field_size field_size_defined,
typename Enabler>
52 using Enumeration_type =
decltype(enumeration_value_encoded);
53 m_archive << Field_wrapper<Enumeration_type, field_size_defined>(
54 enumeration_value_encoded);
55 m_archive.put_field_separator();
58template <
class Archive_concrete_type>
59template <
class Field_type, Field_size field_size_defined,
typename Enabler>
63 using Enumeration_type =
decltype(enumeration_value_encoded);
65 enumeration_value_encoded);
66 auto [enumeration_value_decoded, conversion_code] =
67 mysql::utils::to_enumeration<Field_type, Enumeration_type>(
68 enumeration_value_encoded);
69 field = enumeration_value_decoded;
75 m_archive.process_field_separator();
78template <
class Archive_concrete_type>
79template <
class Field_type, Field_size field_size_defined,
typename Enabler>
82 uint64_t encoded_size = field.size();
85 for (
const auto &internal_field : field) {
86 m_archive.put_entry_separator();
88 encode_field<value_type, 0>(internal_field);
90 m_archive.put_field_separator();
93template <
class Archive_concrete_type>
94template <
class Field_type, Field_size field_size_defined,
typename Enabler>
97 uint64_t encoded_size;
101 for (uint64_t internal_id = 0; internal_id < encoded_size; ++internal_id) {
104 decode_field<value_type, 0>(internal_field);
105 field.push_back(internal_field);
106 m_archive.process_entry_separator();
108 m_archive.process_field_separator();
111template <
class Archive_concrete_type>
112template <
class Field_type, Field_size field_size_defined,
typename Enabler>
119template <
class Archive_concrete_type>
120template <
class Field_type, Field_size field_size_defined,
typename Enabler>
129template <
class Archive_concrete_type>
130template <
class Field_type, Field_size field_size_defined,
typename Enabler>
133 uint64_t encoded_size = field.size();
135 for (
auto &pair : field) {
137 using mapped_type =
typename Field_type::mapped_type;
140 encode_field<key_type, 0>(pair.first);
141 m_archive.put_entry_separator();
142 encode_field<mapped_type, 0>(pair.second);
143 m_archive.put_entry_separator();
145 m_archive.put_field_separator();
148template <
class Archive_concrete_type>
149template <
class Field_type, Field_size field_size_defined,
typename Enabler>
152 uint64_t encoded_size;
155 for (uint64_t entry_id = 0; entry_id < encoded_size; ++entry_id) {
157 using mapped_type =
typename Field_type::mapped_type;
162 decode_field<key_type, 0>(
key);
163 m_archive.process_entry_separator();
164 decode_field<mapped_type, 0>(value);
165 m_archive.process_entry_separator();
166 field.insert(std::make_pair(
key, value));
168 m_archive.process_field_separator();
171template <
class Archive_concrete_type>
172template <
class Field_type, Field_size field_size_defined,
typename Enabler>
175 uint64_t encoded_size = field.size();
178 for (
const auto &internal_field : field) {
180 encode_field<value_type, 0>(internal_field);
181 m_archive.put_entry_separator();
183 m_archive.put_field_separator();
186template <
class Archive_concrete_type>
187template <
class Field_type, Field_size field_size_defined,
typename Enabler>
190 uint64_t encoded_size;
194 for (uint64_t internal_id = 0; internal_id < encoded_size; ++internal_id) {
197 decode_field<value_type, 0>(internal_field);
198 field.emplace(internal_field);
199 m_archive.process_entry_separator();
201 m_archive.process_field_separator();
204template <
class Archive_concrete_type>
205template <
class Field_type, Field_size field_size_defined,
typename Enabler>
208 using value_type = std::remove_reference_t<
decltype(
210 for (
const auto &internal_field : field) {
212 encode_field<value_type, 0>(internal_field);
213 m_archive.put_entry_separator();
215 m_archive.put_field_separator();
218template <
class Archive_concrete_type>
219template <
class Field_type, Field_size field_size_defined,
typename Enabler>
222 using value_type = std::remove_reference_t<
decltype(
224 for (
auto &internal_field : field) {
226 decode_field<value_type, 0>(internal_field);
227 m_archive.process_entry_separator();
229 m_archive.process_field_separator();
232template <
class Archive_concrete_type>
233template <
class Field_type, Field_size field_size_defined,
typename Enabler>
236 return Archive_concrete_type::template get_size(
240template <
class Archive_concrete_type>
241template <
class Field_type, Field_size field_size_defined,
typename Enabler>
245 using Enumeration_type =
decltype(enumeration_value_encoded);
246 return get_field_size<Enumeration_type, field_size_defined>(
247 enumeration_value_encoded);
250template <
class Archive_concrete_type>
251template <
class Field_type, Field_size field_size_defined,
typename Enabler>
254 std::size_t field_size = 0;
256 uint64_t encoded_size = field.size();
257 field_size += get_field_size<uint64_t, 0>(encoded_size);
258 for (
const auto &internal_field : field) {
259 field_size += get_field_size<value_type, 0>(internal_field);
264template <
class Archive_concrete_type>
265template <
class Field_type, Field_size field_size_defined,
typename Enabler>
272template <
class Archive_concrete_type>
273template <
class Field_type, Field_size field_size_defined,
typename Enabler>
277 using mapped_type =
typename Field_type::mapped_type;
278 std::size_t field_size = 0;
279 uint64_t encoded_size = field.size();
280 field_size += get_field_size<uint64_t, 0>(encoded_size);
281 for (
auto &pair : field) {
282 field_size += get_field_size<key_type, 0>(pair.first);
283 field_size += get_field_size<mapped_type, 0>(pair.second);
288template <
class Archive_concrete_type>
289template <
class Field_type, Field_size field_size_defined,
typename Enabler>
292 std::size_t field_size = 0;
293 uint64_t encoded_size = field.size();
294 field_size += get_field_size<uint64_t, 0>(encoded_size);
296 for (
const auto &internal_field : field) {
297 field_size += get_field_size<value_type, 0>(internal_field);
302template <
class Archive_concrete_type>
303template <
class Field_type, Field_size field_size_defined,
typename Enabler>
306 std::size_t field_size = 0;
307 using value_type = std::remove_reference_t<
decltype(
309 for (
const auto &internal_field : field) {
310 field_size += get_field_size<value_type, 0>(internal_field);
315template <
class Archive_concrete_type>
316template <
class Field_type, Field_size field_size_defined>
320 bool is_provided =
false;
321 if (this->is_good() ==
true) {
324 for (
size_t level_id = 0; level_id < level; ++level_id) {
325 m_archive.put_level_separator();
328 m_archive.put_entry_separator();
334template <
class Archive_concrete_type>
335template <
class Field_type, Field_size field_size_defined>
339 bool is_provided =
false;
340 if (this->is_good() ==
true) {
342 for (
size_t level_id = 0; level_id < level; ++level_id) {
343 m_archive.process_level_separator();
347 if (
field_id != field_type_read || this->is_good() ==
false) {
353 m_archive.process_entry_separator();
359template <
class Archive_concrete_type>
360template <
class Field_type, Field_size field_size_defined>
364 bool is_provided = encode_field_id(level,
field_id, field_definition);
366 encode_field<Field_type, field_size_defined>(field_definition.
get_ref());
370template <
class Archive_concrete_type>
371template <
class Field_type, Field_size field_size_defined>
377 if (m_archive.get_read_pos() == serializable_end_pos &&
378 serializable_end_pos != 0) {
383 bool is_provided = decode_field_id(level,
field_id, field_definition);
385 decode_field<Field_type, field_size_defined>(field_definition.
get_ref());
389template <
class Serializable_type>
391 const Serializable_type &serializable) {
393 auto func_s = [&last_non_ignorable_field_id](
const auto &nested,
395 if (nested.is_any_field_provided() && nested.is_ignorable() ==
false) {
396 last_non_ignorable_field_id = nested_id + 1;
399 auto func_f = [&last_non_ignorable_field_id](
400 const auto &field,
auto processed_field_id) ->
auto {
401 if (field.run_encode_predicate() && field.is_field_ignorable() ==
false) {
402 last_non_ignorable_field_id = processed_field_id + 1;
405 serializable.do_for_each_field(func_s, func_f);
406 return last_non_ignorable_field_id;
409template <
class Archive_concrete_type>
410template <
class Serializable_type>
416 uint64_t encoded_size =
417 Serializer_type::get_size_serializable(
field_id, serializable, skip_id);
422 if (skip_id ==
false) {
424 m_archive.put_field_separator();
427 m_archive.put_field_separator();
429 m_archive.put_field_separator();
432template <
class Archive_concrete_type>
433template <
class Serializable_type>
438 uint64_t encoded_size = 0;
440 if (skip_id ==
false) {
443 m_archive.process_field_separator();
444 if (field_type_read !=
field_id || this->is_good() ==
false) {
451 if (this->is_good()) {
452 auto last_known_field_id = serializable.get_last_field_id();
454 m_archive.process_field_separator();
456 m_archive.process_field_separator();
458 if (last_known_field_id + 1 < last_non_ignorable_field_id) {
461 "Unknown, non ignorable fields found in the data stream.",
465 return static_cast<std::size_t
>(encoded_size);
468template <
class Archive_concrete_type>
469template <
class Field_type, Field_size field_size_defined>
473 std::size_t calculated_size = 0;
476 auto size_id_type = Archive_concrete_type::template get_size(
478 calculated_size = get_field_size<Field_type, field_size_defined>(
482 return calculated_size;
485template <
class Archive_concrete_type>
486template <
class Serializable_concrete_type>
490 std::size_t serializable_overhead_type = 0;
491 if (skip_id ==
false) {
492 serializable_overhead_type = Archive_concrete_type::template get_size(
495 auto serializable_size = serializable.template get_size_internal<Base_type>();
496 auto serializable_overhead_size = Archive_concrete_type::template get_size(
502 auto serializable_overhead_last_non_ignorable_field_id =
503 Archive_concrete_type::template get_size(
505 return serializable_overhead_type + serializable_overhead_size +
506 serializable_overhead_last_non_ignorable_field_id + serializable_size;
Field definition provided by classes implementing Serializable interface.
Definition: field_definition.h:45
Field_type & get_ref()
Definition: field_definition.h:101
void run_field_missing() const
Runs "field missing functor" in case field is not available in the provided encoded data.
Definition: field_definition.h:106
bool run_encode_predicate() const
Runs encode predicate functor.
Definition: field_definition.h:110
Wrapper for fields to hold field reference and user-defined, compile-time field size.
Definition: field_wrapper.h:43
Error used internally in serialization framework.
Definition: serialization_error.h:46
Basic serializer that is implementing Serializer interface.
Definition: serializer_default.h:63
static std::size_t get_size_field_def(Field_id_type field_id, const Field_definition< Field_type, field_size_defined > &field_definition)
Function returns size of serialized field_definition object.
Definition: serializer_default_impl.hpp:470
static std::size_t get_field_size(const Field_type &field)
Function used internally to calculate size of fields, version for basic types.
Definition: serializer_default_impl.hpp:234
void encode(Level_type level, Field_id_type field_id, const Field_definition< Field_type, field_size_defined > &field_definition)
Function used to encode one field.
Definition: serializer_default_impl.hpp:361
bool encode_field_id(Level_type level, Field_id_type field_id, const Field_definition< Field_type, field_size_defined > &field_definition)
Function used internally to encode field_id and handle optional fields.
Definition: serializer_default_impl.hpp:317
bool decode_field_id(Level_type level, Field_id_type field_id, Field_definition< Field_type, field_size_defined > &field_definition)
Function used internally to decode field_id and handle optional fields.
Definition: serializer_default_impl.hpp:336
void decode_field(Field_type &field)
Function used internally to decode field_id and handle optional fields, version for basic types.
Definition: serializer_default_impl.hpp:41
static std::size_t get_size_serializable(Field_id_type field_id, const Serializable_concrete_type &serializable, bool skip_id=false)
Function returns size of serialized field_definition object.
Definition: serializer_default_impl.hpp:487
void decode(Level_type level, Field_id_type field_id, std::size_t serializable_end_pos, Field_definition< Field_type, field_size_defined > &field_definition)
Function used to decode one field.
Definition: serializer_default_impl.hpp:372
std::size_t decode_serializable_metadata(Level_type level, Field_id_type field_id, Serializable_type &serializable, bool skip_id)
This function loads serializable metadata.
Definition: serializer_default_impl.hpp:435
void encode_field(const Field_type &field)
Function used internally to encode field_id and handle optional fields, version for basic types.
Definition: serializer_default_impl.hpp:33
void encode_serializable_metadata(Level_type level, Field_id_type field_id, const Serializable_type &serializable, bool skip_id)
This function saves serializable metadata.
Definition: serializer_default_impl.hpp:411
void encode_serializable(Level_type level, Field_id_type field_id, const Serializable_type &serializable, bool skip_id)
Function used to encode serializable field, this function saves serializable metadata and calls seria...
Definition: serializer_impl.hpp:118
void decode_serializable(Level_type level, Field_id_type field_id, std::size_t serializable_end_pos, Serializable_type &serializable, bool skip_id)
Function used to decode serializable field, this function loads serializable metadata and calls seria...
Definition: serializer_impl.hpp:158
uint16_t value_type
Definition: vt100.h:184
int key_type
Definition: method.h:38
Field_id_type find_last_non_ignorable_field_id(const Serializable_type &serializable)
Definition: serializer_default_impl.hpp:390
std::size_t Level_type
Type of the "level" used to indicate on which level of the nested message internal fields are defined...
Definition: serialization_types.h:40
uint64_t Field_id_type
Type for field_id assigned to each field in the.
Definition: serialization_types.h:42
auto create_varlen_field_wrapper(Field_type &field_reference)
Definition: field_wrapper.h:85
@ unknown_field
unknown field found in the data stream
@ data_integrity_error
corrupted data, unexpected value found
@ field_id_mismatch
field id read does not match expected field id
constexpr decltype(auto) to_underlying(Enum_type enum_value)
Helper function that converts enum type to underlying integer type.
Definition: enumeration_utils.h:44
const char * begin(const char *const c)
Definition: base64.h:44
required string key
Definition: replication_asynchronous_connection_failover.proto:60
static const LEX_CSTRING field_id
Definition: sql_show_processlist.cc:49
Definition: sql_resultset.h:36
Helper tag for array types to help compiler pick the correct method.
Definition: serializer_default.h:49
Helper tag for enum types to help compiler pick the correct method.
Definition: serializer_default.h:45
Helper tag for map types to help compiler pick the correct method.
Definition: serializer_default.h:47
Helper tag for serializable types to help compiler pick the correct method.
Definition: serializer_default.h:54
Helper tag for set types to help compiler pick the correct method.
Definition: serializer_default.h:51
Helper tag for vector types to help compiler pick the correct method.
Definition: serializer_default.h:43