MySQL 8.4.2
Source Code Documentation
json_binary.h
Go to the documentation of this file.
1#ifndef JSON_BINARY_INCLUDED
2#define JSON_BINARY_INCLUDED
3
4/* Copyright (c) 2015, 2024, Oracle and/or its affiliates.
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2.0,
8 as published by the Free Software Foundation.
9
10 This program is designed to work with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful,
19 but WITHOUT ANY WARRANTY; without even the implied warranty of
20 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 GNU General Public License, version 2.0, for more details.
22
23 You should have received a copy of the GNU General Public License
24 along with this program; if not, write to the Free Software
25 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
26
27/**
28 @file
29
30 This file specifies the interface for serializing JSON values into
31 binary representation, and for reading values back from the binary
32 representation.
33
34 The binary format is as follows:
35
36 Each JSON value (scalar, object or array) has a one byte type
37 identifier followed by the actual value.
38
39 If the value is a JSON object, its binary representation will have a
40 header that contains:
41
42 - the member count
43 - the size of the binary value in bytes
44 - a list of pointers to each key
45 - a list of pointers to each value
46
47 The actual keys and values will come after the header, in the same
48 order as in the header.
49
50 Similarly, if the value is a JSON array, the binary representation
51 will have a header with
52
53 - the element count
54 - the size of the binary value in bytes
55 - a list of pointers to each value
56
57 followed by the actual values, in the same order as in the header.
58
59 @verbatim
60 doc ::= type value
61
62 type ::=
63 0x00 | // small JSON object
64 0x01 | // large JSON object
65 0x02 | // small JSON array
66 0x03 | // large JSON array
67 0x04 | // literal (true/false/null)
68 0x05 | // int16
69 0x06 | // uint16
70 0x07 | // int32
71 0x08 | // uint32
72 0x09 | // int64
73 0x0a | // uint64
74 0x0b | // double
75 0x0c | // utf8mb4 string
76 0x0f // custom data (any MySQL data type)
77
78 value ::=
79 object |
80 array |
81 literal |
82 number |
83 string |
84 custom-data
85
86 object ::= element-count size key-entry* value-entry* key* value*
87
88 array ::= element-count size value-entry* value*
89
90 // number of members in object or number of elements in array
91 element-count ::=
92 uint16 | // if used in small JSON object/array
93 uint32 // if used in large JSON object/array
94
95 // number of bytes in the binary representation of the object or array
96 size ::=
97 uint16 | // if used in small JSON object/array
98 uint32 // if used in large JSON object/array
99
100 key-entry ::= key-offset key-length
101
102 key-offset ::=
103 uint16 | // if used in small JSON object
104 uint32 // if used in large JSON object
105
106 key-length ::= uint16 // key length must be less than 64KB
107
108 value-entry ::= type offset-or-inlined-value
109
110 // This field holds either the offset to where the value is stored,
111 // or the value itself if it is small enough to be inlined (that is,
112 // if it is a JSON literal or a small enough [u]int).
113 offset-or-inlined-value ::=
114 uint16 | // if used in small JSON object/array
115 uint32 // if used in large JSON object/array
116
117 key ::= utf8mb4-data
118
119 literal ::=
120 0x00 | // JSON null literal
121 0x01 | // JSON true literal
122 0x02 | // JSON false literal
123
124 number ::= .... // little-endian format for [u]int(16|32|64), whereas
125 // double is stored in a platform-independent, eight-byte
126 // format using float8store()
127
128 string ::= data-length utf8mb4-data
129
130 custom-data ::= custom-type data-length binary-data
131
132 custom-type ::= uint8 // type identifier that matches the
133 // internal enum_field_types enum
134
135 data-length ::= uint8* // If the high bit of a byte is 1, the length
136 // field is continued in the next byte,
137 // otherwise it is the last byte of the length
138 // field. So we need 1 byte to represent
139 // lengths up to 127, 2 bytes to represent
140 // lengths up to 16383, and so on...
141 @endverbatim
142*/
143
144#include <stddef.h>
145#include <cassert>
146#include <cstdint>
147#include <string>
148
149/*
150 This file is part of our public interface for the 'json_binary' library.
151 This means that #includes of MySQL headers here should be limited to
152 files that are INSTALLed.
153*/
154#include "field_types.h" // enum_field_types
156
157#ifdef MYSQL_SERVER
158class Field_json;
159class Json_wrapper;
160class THD;
161#endif
162
163class Json_dom;
164class String;
165
166#if defined(WIN32) && defined(EXPORT_JSON_FUNCTIONS)
167#define EXPORT_JSON_FUNCTION __declspec(dllexport)
168#else
169#define EXPORT_JSON_FUNCTION
170#endif
171
172namespace json_binary {
173
174void write_offset_or_size(char *dest, size_t offset_or_size, bool large);
175
176bool append_offset_or_size(String *dest, size_t offset_or_size, bool large);
177
178bool append_int16(String *dest, int16_t value);
179
180bool attempt_inline_value(const Json_dom *value, String *dest, size_t pos,
181 bool large);
182
183uint32_t read_offset_or_size(const char *data, bool large);
184
185bool inlined_type(uint8_t type, bool large);
186
187uint8_t offset_size(bool large);
188uint8_t key_entry_size(bool large);
189uint8_t value_entry_size(bool large);
190
191/**
192 Serialize the JSON document represented by dom to binary format in
193 the destination string, replacing any content already in the
194 destination string.
195
196 @param[in] dom the input DOM tree
197 @param error_handler a handler that is invoked if an error occurs
198 @param[in,out] dest the destination string
199 @retval false on success
200 @retval true if an error occurred
201 */
202bool serialize(const Json_dom *dom,
203 const JsonSerializationErrorHandler &error_handler,
204 String *dest);
205
206/**
207 Class used for reading JSON values that are stored in the binary
208 format. Values are parsed lazily, so that only the parts of the
209 value that are interesting to the caller, are read. Array elements
210 can be looked up in constant time using the element() function.
211 Object members can be looked up in O(log n) time using the lookup()
212 function.
213*/
214class Value {
215 public:
216 enum enum_type : uint8_t {
227 ERROR /* Not really a type. Used to signal that an
228 error was detected. */
229 };
230
231 /**
232 Does this value, and all of its members, represent a valid JSON
233 value?
234 */
236 bool is_valid() const;
237
239 enum_type type() const { return m_type; }
240
241 /// Does this value use the large storage format?
243 bool large_format() const { return m_large; }
244
245 /**
246 Get a pointer to the beginning of the STRING or OPAQUE data
247 represented by this instance.
248 */
250 const char *get_data() const {
251 assert(m_type == STRING || m_type == OPAQUE);
252 return m_data;
253 }
254
255 /**
256 Get the length in bytes of the STRING or OPAQUE value represented by
257 this instance.
258 */
260 uint32_t get_data_length() const {
261 assert(m_type == STRING || m_type == OPAQUE);
262 return m_length;
263 }
264
265 /**
266 Get the length in bytes of the STRING or OPAQUE value represented by
267 this instance.
268 */
270 uint32_t get_container_length() const {
271 assert(m_type == ARRAY || m_type == OBJECT);
272 return m_length;
273 }
274
276 const char *get_container_data() const {
277 assert(m_type == ARRAY || m_type == OBJECT);
278 return m_data;
279 }
280
281 /** Get the value of an INT. */
283 int64_t get_int64() const {
284 assert(m_type == INT);
285 return m_int_value;
286 }
287
288 /** Get the value of a UINT. */
290 uint64_t get_uint64() const {
291 assert(m_type == UINT);
292 return static_cast<uint64_t>(m_int_value);
293 }
294
295 /** Get the value of a DOUBLE. */
297 double get_double() const {
298 assert(m_type == DOUBLE);
299 return m_double_value;
300 }
301
302 /**
303 Get the number of elements in an array, or the number of members in
304 an object.
305 */
307 uint32_t element_count() const {
308 assert(m_type == ARRAY || m_type == OBJECT);
309 return m_element_count;
310 }
311
312 /**
313 Get the MySQL field type of an opaque value. Identifies the type of
314 the value stored in the data portion of an opaque value.
315 */
318 assert(m_type == OPAQUE);
319 return m_field_type;
320 }
321
323 Value element(size_t pos) const;
324
326 Value key(size_t pos) const;
327
329 Value lookup(const char *key, size_t length) const;
330
332 Value lookup(const std::string &key) const {
333 return lookup(key.c_str(), key.length());
334 }
335
337 size_t lookup_index(const char *key, size_t length) const;
338
340 size_t lookup_index(const std::string &key) const {
341 return lookup_index(key.c_str(), key.length());
342 }
343
345 bool is_backed_by(const String *str) const;
346
348 bool raw_binary(const JsonSerializationErrorHandler &error_handler,
349 String *buf) const;
351 bool get_free_space(const JsonSerializationErrorHandler &error_handler,
352 size_t *space) const;
353#ifdef MYSQL_SERVER
354 bool update_in_shadow(const Field_json *field, size_t pos,
355 Json_wrapper *new_value, size_t data_offset,
356 size_t data_length, const char *original,
357 char *destination, bool *changed) const;
358 bool remove_in_shadow(const Field_json *field, size_t pos,
359 const char *original, char *destination) const;
360#endif
362 bool has_space(size_t pos, size_t needed, size_t *offset) const;
363
364 /** Constructor for values that represent literals or errors. */
366 explicit Value(enum_type t) : m_data(nullptr), m_type(t) {
367 assert(t == LITERAL_NULL || t == LITERAL_TRUE || t == LITERAL_FALSE ||
368 t == ERROR);
369 }
370
371 /** Constructor for values that represent ints or uints. */
373 explicit Value(enum_type t, int64_t val) : m_int_value(val), m_type(t) {
374 assert(t == INT || t == UINT);
375 }
376
377 /** Constructor for values that represent doubles. */
379 explicit Value(double val) : m_double_value(val), m_type(DOUBLE) {}
380
381 /** Constructor for values that represent strings. */
383 Value(const char *data, uint32_t len)
384 : m_data(data), m_length(len), m_type(STRING) {}
385
386 /**
387 Constructor for values that represent arrays or objects.
388
389 @param t type
390 @param data pointer to the start of the binary representation
391 @param bytes the number of bytes in the binary representation of the value
392 @param element_count the number of elements or members in the value
393 @param large true if the value should be stored in the large
394 storage format with 4 byte offsets instead of 2 byte offsets
395 */
397 Value(enum_type t, const char *data, uint32_t bytes, uint32_t element_count,
398 bool large)
399 : m_data(data),
401 m_length(bytes),
402 m_type(t),
403 m_large(large) {
404 assert(t == ARRAY || t == OBJECT);
405 }
406
407 /** Constructor for values that represent opaque data. */
409 Value(enum_field_types ft, const char *data, uint32_t len)
410 : m_data(data), m_length(len), m_field_type(ft), m_type(OPAQUE) {}
411
412 /** Empty constructor. Produces a value that represents an error condition. */
415
416 /** Is this value an array? */
418 bool is_array() const { return m_type == ARRAY; }
419
420 /** Is this value an object? */
422 bool is_object() const { return m_type == OBJECT; }
423
424 /**
425 Format the JSON value to an external JSON string in buffer in
426 the format of ISO/IEC 10646.
427
428 @param[in,out] buffer the formatted string is appended, so make sure
429 the length is set correctly before calling
430 @param[in] depth_handler Pointer to a function that should handle error
431 occurred when depth is exceeded.
432
433 @return false formatting went well, else true
434 */
436 bool to_std_string(std::string *buffer,
437 const JsonErrorHandler &depth_handler) const;
438
439 /**
440 Format the JSON value to an external JSON string in buffer in the format of
441 ISO/IEC 10646. Add newlines and indentation for readability.
442
443 @param[in,out] buffer the buffer that receives the formatted string
444 (the string is appended, so make sure the length
445 is set correctly before calling)
446 @param[in] depth_handler Pointer to a function that should handle error
447 occurred when depth is exceeded.
448
449 @retval false on success
450 @retval true on error
451 */
453 bool to_pretty_std_string(std::string *buffer,
454 const JsonErrorHandler &depth_handler) const;
455
456 /**
457 Compare two Values
458 @note This function is limited to scalars only, for objects/arrays it
459 asserts. The main purpose is to separate old/new scalar values for updates
460 on multi-valued indexes.
461 @returns
462 -1 this < val
463 0 this == val
464 1 this > val
465 */
466#ifdef MYSQL_SERVER
467 int eq(const Value &val) const;
468#endif
469
471 size_t key_entry_offset(size_t pos) const;
472
474 size_t value_entry_offset(size_t pos) const;
475
476 private:
477 /*
478 Instances use only one of m_data, m_int_value and m_double_value,
479 so keep them in a union to save space in memory.
480 */
481 union {
482 /**
483 Pointer to the start of the binary representation of the value. Only
484 used by STRING, OPAQUE, OBJECT and ARRAY.
485
486 The memory pointed to by this member is not owned by this Value
487 object. Callers that create Value objects must make sure that the
488 memory is not freed as long as the Value object is alive.
489 */
490 const char *m_data;
491 /** The value if the type is INT or UINT. */
492 int64_t m_int_value;
493 /** The value if the type is DOUBLE. */
495 };
496
497 /**
498 Element count for arrays and objects. Unused for other types.
499 */
501
502 /**
503 The full length (in bytes) of the binary representation of an array or
504 object, or the length of a string or opaque value. Unused for other types.
505 */
506 uint32_t m_length;
507
508 /**
509 The MySQL field type of the value, in case the type of the value is
510 OPAQUE. Otherwise, it is unused.
511 */
513
514 /** The JSON type of the value. */
516
517 /**
518 True if an array or an object uses the large storage format with 4
519 byte offsets instead of 2 byte offsets.
520 */
522
523 bool first_value_offset(size_t *offset) const;
524 bool element_offsets(size_t pos, size_t *start, size_t *end,
525 bool *inlined) const;
526};
527
528/**
529 Parse a JSON binary document.
530
531 @param[in] data a pointer to the binary data
532 @param[in] len the size of the binary document in bytes
533 @return an object that allows access to the contents of the document
534*/
536Value parse_binary(const char *data, size_t len);
537
538/**
539 How much space is needed for a JSON value when it is stored in the binary
540 format.
541
542 @param[in] value the JSON value to add to a document
543 @param[in] large true if the large storage format is used
544 @param[out] needed gets set to the amount of bytes needed to store
545 the value
546 @retval false if successful
547 @retval true if an error occurred while calculating the needed space
548*/
549#ifdef MYSQL_SERVER
550bool space_needed(const Json_wrapper *value, bool large, size_t *needed);
551#endif
552
553/**
554 Apply a function to every value in a JSON document. That is, apply
555 the function to the root node of the JSON document, to all its
556 children, grandchildren and so on.
557
558 @param value the root of the JSON document
559 @param func the function to apply
560 @retval true if the processing was stopped
561 @retval false if the processing was completed
562
563 @tparam Func a functor type that takes a #json_binary::Value
564 parameter and returns a `bool` which is `true` if the processing
565 should stop or `false` if the processing should continue with the
566 next node
567*/
568template <typename Func>
569bool for_each_node(const Value &value, const Func &func) {
570 if (func(value)) return true;
571
572 if (value.is_array() || value.is_object())
573 for (size_t i = 0, size = value.element_count(); i < size; ++i)
574 if (for_each_node(value.element(i), func)) return true;
575
576 return false;
577}
578} // namespace json_binary
579
580#endif /* JSON_BINARY_INCLUDED */
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:251
A field that stores a JSON value.
Definition: field.h:4001
Error handler for the functions that serialize a JSON value in the JSON binary storage format.
Definition: json_error_handler.h:49
JSON DOM abstract base class.
Definition: json_dom.h:173
Abstraction for accessing JSON values irrespective of whether they are (started out as) binary JSON v...
Definition: json_dom.h:1153
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:167
For each client connection we create a separate thread with THD serving as a thread/connection descri...
Definition: sql_lexer_thd.h:36
Class used for reading JSON values that are stored in the binary format.
Definition: json_binary.h:214
double m_double_value
The value if the type is DOUBLE.
Definition: json_binary.h:494
EXPORT_JSON_FUNCTION uint32_t element_count() const
Get the number of elements in an array, or the number of members in an object.
Definition: json_binary.h:307
EXPORT_JSON_FUNCTION const char * get_data() const
Get a pointer to the beginning of the STRING or OPAQUE data represented by this instance.
Definition: json_binary.h:250
EXPORT_JSON_FUNCTION Value(enum_field_types ft, const char *data, uint32_t len)
Constructor for values that represent opaque data.
Definition: json_binary.h:409
EXPORT_JSON_FUNCTION Value key(size_t pos) const
Get the key of the member stored at the specified position in a JSON object.
Definition: json_binary.cc:1150
EXPORT_JSON_FUNCTION Value lookup(const std::string &key) const
Definition: json_binary.h:332
EXPORT_JSON_FUNCTION enum_field_types field_type() const
Get the MySQL field type of an opaque value.
Definition: json_binary.h:317
EXPORT_JSON_FUNCTION Value(enum_type t, const char *data, uint32_t bytes, uint32_t element_count, bool large)
Constructor for values that represent arrays or objects.
Definition: json_binary.h:397
EXPORT_JSON_FUNCTION int64_t get_int64() const
Get the value of an INT.
Definition: json_binary.h:283
bool m_large
True if an array or an object uses the large storage format with 4 byte offsets instead of 2 byte off...
Definition: json_binary.h:521
EXPORT_JSON_FUNCTION Value(const char *data, uint32_t len)
Constructor for values that represent strings.
Definition: json_binary.h:383
int64_t m_int_value
The value if the type is INT or UINT.
Definition: json_binary.h:492
EXPORT_JSON_FUNCTION uint32_t get_data_length() const
Get the length in bytes of the STRING or OPAQUE value represented by this instance.
Definition: json_binary.h:260
EXPORT_JSON_FUNCTION size_t value_entry_offset(size_t pos) const
Get the offset of the value entry that describes the element at a given position in this array or obj...
Definition: json_binary.cc:1543
bool first_value_offset(size_t *offset) const
Find the lowest possible offset where a value can be located inside this array or object.
Definition: json_binary.cc:1397
EXPORT_JSON_FUNCTION bool is_object() const
Is this value an object?
Definition: json_binary.h:422
EXPORT_JSON_FUNCTION bool to_std_string(std::string *buffer, const JsonErrorHandler &depth_handler) const
Format the JSON value to an external JSON string in buffer in the format of ISO/IEC 10646.
Definition: json_binary.cc:2131
EXPORT_JSON_FUNCTION bool to_pretty_std_string(std::string *buffer, const JsonErrorHandler &depth_handler) const
Format the JSON value to an external JSON string in buffer in the format of ISO/IEC 10646.
Definition: json_binary.cc:2143
EXPORT_JSON_FUNCTION size_t lookup_index(const std::string &key) const
Definition: json_binary.h:340
EXPORT_JSON_FUNCTION const char * get_container_data() const
Definition: json_binary.h:276
EXPORT_JSON_FUNCTION Value(double val)
Constructor for values that represent doubles.
Definition: json_binary.h:379
EXPORT_JSON_FUNCTION bool get_free_space(const JsonSerializationErrorHandler &error_handler, size_t *space) const
Get the amount of unused space in the binary representation of this value.
Definition: json_binary.cc:1991
uint32_t m_length
The full length (in bytes) of the binary representation of an array or object, or the length of a str...
Definition: json_binary.h:506
enum_type
Definition: json_binary.h:216
@ DOUBLE
Definition: json_binary.h:222
@ LITERAL_FALSE
Definition: json_binary.h:225
@ INT
Definition: json_binary.h:220
@ STRING
Definition: json_binary.h:219
@ OBJECT
Definition: json_binary.h:217
@ LITERAL_TRUE
Definition: json_binary.h:224
@ ERROR
Definition: json_binary.h:227
@ LITERAL_NULL
Definition: json_binary.h:223
@ UINT
Definition: json_binary.h:221
@ OPAQUE
Definition: json_binary.h:226
@ ARRAY
Definition: json_binary.h:218
EXPORT_JSON_FUNCTION uint32_t get_container_length() const
Get the length in bytes of the STRING or OPAQUE value represented by this instance.
Definition: json_binary.h:270
EXPORT_JSON_FUNCTION Value()
Empty constructor.
Definition: json_binary.h:414
EXPORT_JSON_FUNCTION Value lookup(const char *key, size_t length) const
Get the value associated with the specified key in a JSON object.
Definition: json_binary.cc:1188
EXPORT_JSON_FUNCTION enum_type type() const
Definition: json_binary.h:239
EXPORT_JSON_FUNCTION bool has_space(size_t pos, size_t needed, size_t *offset) const
Does this array or object have enough space to replace the value at the given position with another v...
Definition: json_binary.cc:1429
int eq(const Value &val) const
Compare two Values.
Definition: json_binary.cc:2085
EXPORT_JSON_FUNCTION Value(enum_type t)
Constructor for values that represent literals or errors.
Definition: json_binary.h:366
enum_field_types m_field_type
The MySQL field type of the value, in case the type of the value is OPAQUE.
Definition: json_binary.h:512
EXPORT_JSON_FUNCTION size_t lookup_index(const char *key, size_t length) const
Get the index of the element with the specified key in a JSON object.
Definition: json_binary.cc:1202
EXPORT_JSON_FUNCTION bool is_array() const
Is this value an array?
Definition: json_binary.h:418
EXPORT_JSON_FUNCTION Value element(size_t pos) const
Get the element at the specified position of a JSON array or a JSON object.
Definition: json_binary.cc:1111
EXPORT_JSON_FUNCTION bool large_format() const
Does this value use the large storage format?
Definition: json_binary.h:243
EXPORT_JSON_FUNCTION bool is_backed_by(const String *str) const
Is this binary value pointing to data that is contained in the specified string.
Definition: json_binary.cc:1250
enum_type m_type
The JSON type of the value.
Definition: json_binary.h:515
bool update_in_shadow(const Field_json *field, size_t pos, Json_wrapper *new_value, size_t data_offset, size_t data_length, const char *original, char *destination, bool *changed) const
Update a value in an array or object.
Definition: json_binary.cc:1748
bool remove_in_shadow(const Field_json *field, size_t pos, const char *original, char *destination) const
Remove a value from an array or object.
Definition: json_binary.cc:1937
const char * m_data
Pointer to the start of the binary representation of the value.
Definition: json_binary.h:490
EXPORT_JSON_FUNCTION uint64_t get_uint64() const
Get the value of a UINT.
Definition: json_binary.h:290
EXPORT_JSON_FUNCTION size_t key_entry_offset(size_t pos) const
Get the offset of the key entry that describes the key of the member at a given position in this obje...
Definition: json_binary.cc:1530
EXPORT_JSON_FUNCTION bool raw_binary(const JsonSerializationErrorHandler &error_handler, String *buf) const
Copy the binary representation of this value into a buffer, replacing the contents of the receiving b...
Definition: json_binary.cc:1275
EXPORT_JSON_FUNCTION bool is_valid() const
Does this value, and all of its members, represent a valid JSON value?
Definition: json_binary.cc:884
bool element_offsets(size_t pos, size_t *start, size_t *end, bool *inlined) const
Find the start offset and the end offset of the specified element.
Definition: json_binary.cc:1340
EXPORT_JSON_FUNCTION Value(enum_type t, int64_t val)
Constructor for values that represent ints or uints.
Definition: json_binary.h:373
uint32_t m_element_count
Element count for arrays and objects.
Definition: json_binary.h:500
EXPORT_JSON_FUNCTION double get_double() const
Get the value of a DOUBLE.
Definition: json_binary.h:297
This file contains the field type.
enum_field_types
Column types for MySQL Note: Keep include/mysql/components/services/bits/stored_program_bits....
Definition: field_types.h:55
static void start(mysql_harness::PluginFuncEnv *env)
Definition: http_auth_backend_plugin.cc:180
#define EXPORT_JSON_FUNCTION
Definition: json_binary.h:169
std::function< void()> JsonErrorHandler
Definition: json_error_handler.h:36
uint32 element_count
Definition: my_tree.h:52
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
Definition: buf0block_hint.cc:30
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
Definition: json_binary.cc:108
void write_offset_or_size(char *dest, size_t offset_or_size, bool large)
Write an offset or a size to a char array.
Definition: json_binary.cc:241
uint8_t offset_size(bool large)
Get the size of an offset value.
Definition: json_binary.cc:435
bool space_needed(const Json_wrapper *value, bool large, size_t *needed)
How much space is needed for a JSON value when it is stored in the binary format.
Definition: json_binary.cc:1557
bool serialize(const Json_dom *dom, const JsonSerializationErrorHandler &error_handler, String *dest)
Serialize the JSON document represented by dom to binary format in the destination string,...
Definition: json_binary.cc:140
bool append_offset_or_size(String *dest, size_t offset_or_size, bool large)
Append an offset or a size to a String.
Definition: json_binary.cc:209
bool append_int16(String *dest, int16_t value)
Encode a 16-bit int at the end of the destination string.
Definition: json_binary.cc:177
bool attempt_inline_value(const Json_dom *value, String *dest, size_t pos, bool large)
Attempt to inline a value in its value entry at the beginning of an object or an array.
Definition: json_binary.cc:468
uint32_t read_offset_or_size(const char *data, bool large)
Read an offset or size field from a buffer.
Definition: json_binary.cc:1015
bool for_each_node(const Value &value, const Func &func)
Apply a function to every value in a JSON document.
Definition: json_binary.h:569
bool inlined_type(uint8_t type, bool large)
Will a value of the specified type be inlined?
Definition: json_binary.cc:416
Value parse_binary(const char *data, size_t len)
Parse a JSON binary document.
Definition: json_binary.cc:1086
uint8_t value_entry_size(bool large)
Get the size of a value entry.
Definition: json_binary.cc:453
uint8_t key_entry_size(bool large)
Get the size of a key entry.
Definition: json_binary.cc:444
size_t size(const char *const c)
Definition: base64.h:46
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
required string type
Definition: replication_group_member_actions.proto:34