MySQL 9.6.0
Source Code Documentation
mysql_json_encode.h
Go to the documentation of this file.
1/* Copyright (c) 2025, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify
4it under the terms of the GNU General Public License, version 2.0,
5as published by the Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful,
16but WITHOUT ANY WARRANTY; without even the implied warranty of
17MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18GNU General Public License, version 2.0, for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#ifndef MYSQL_JSON_ENCODE_H
25#define MYSQL_JSON_ENCODE_H
26
29
30/**
31 @ingroup group_components_services_inventory
32
33 A specialized service that transcodes input text from specified encoding into
34 UTF-8 (MB4) and escapes JSON characters. Regular encoders require that
35 a source is placed in single buffer and the size of the output buffer cannot
36 be determined (it must be counted). This service allows to transcode input
37 buffer in chunks.
38*/
39BEGIN_SERVICE_DEFINITION(mysql_json_encode)
40
41/**
42 Transcode input buffer (a chunk of data) into destination buffer.
43
44 @param [in] src Input buffer pointer.
45 @param [in] src_end When dividing input stream into smaller chunks, this
46 pointer must be set to src_data_end -
47 max_encoded_char - 1, where max_encoded_char is the
48 maximum lenght of the character in the specified
49 encoding (charset argument). This ensures that a
50 partial character is not consumed. The last chunk
51 should be called with src_end == src_data_end and the
52 returned pointer should point to src_data_end.
53 @param [in] src_data_end Input buffer end pointer.
54 @param [in] dst Destination buffer.
55 @param [in] dst_end Destination buffer end. The buffer should be at least
56 6 buffer long (JSON encodes single character as
57 \\uXXXX), which can be a case in a single encode
58 method call.
59 @param [in] charset Input data encoding.
60 @param [out] dst_out Pointer ending the transcoded data buffer. The
61 pointer is not part of the transcoded data.
62
63 @return Pointer to the next data withing the input buffer to be transcoded.
64*/
65DECLARE_METHOD(const unsigned char *, encode,
66 (const unsigned char *src, const unsigned char *src_end,
67 const unsigned char *src_data_end, unsigned char *dst,
68 unsigned char *dst_end, const CHARSET_INFO_h charset,
69 unsigned char **dst_out));
70
71END_SERVICE_DEFINITION(mysql_json_encode)
72
73#endif /* MYSQL_JSON_ENCODE_H */
struct CHARSET_INFO_h_imp * CHARSET_INFO_h
Definition: mysql_string.h:41
const std::string charset("charset")
void encode(const Debug_format &format, Is_string_target auto &target, const Repeat &repeat)
Definition: debug_repeat.h:39
#define DECLARE_METHOD(retval, name, args)
Declares a method as a part of the Service definition.
Definition: service.h:103
#define END_SERVICE_DEFINITION(name)
A macro to end the last Service definition started with the BEGIN_SERVICE_DEFINITION macro.
Definition: service.h:91
#define BEGIN_SERVICE_DEFINITION(name)
Declares a new Service.
Definition: service.h:86