MySQL  8.0.27
Source Code Documentation
unsafe_string_append.h
Go to the documentation of this file.
1 #ifndef UNSAFE_STRING_APPEND_INCLUDED
2 #define UNSAFE_STRING_APPEND_INCLUDED
3 
4 /* Copyright (c) 2018, 2021, 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 also distributed 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 included with MySQL.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License, version 2.0, for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
25 
26 #include "my_byteorder.h"
27 #include "sql_string.h"
28 
29 /*
30  The following append operations do NOT check alloced memory
31  q_*** methods writes values of parameters itself
32  qs_*** methods writes string representation of value
33 */
34 inline void q_append(const char c, String *str) {
35  (*str)[str->length()] = c;
36  str->length(str->length() + 1);
37 }
38 inline void q_append(const uint32 n, String *str) {
39  int4store(&((*str)[str->length()]), n);
40  str->length(str->length() + 4);
41 }
42 inline void q_append(double d, String *str) {
43  float8store(&((*str)[str->length()]), d);
44  str->length(str->length() + 8);
45 }
46 inline void q_append(double *d, String *str) {
47  float8store(&((*str)[str->length()]), *d);
48  str->length(str->length() + 8);
49 }
50 inline void q_append(const char *data, size_t data_len, String *str) {
51  memcpy(&((*str)[str->length()]), data, data_len);
52  str->length(str->length() + data_len);
53 }
54 
55 inline void write_at_position(int position, uint32 value, String *str) {
56  int4store(&((*str)[position]), value);
57 }
58 
59 void qs_append(const char *str_in, size_t len, String *str);
60 void qs_append(double d, size_t len, String *str);
61 inline void qs_append(const char c, String *str) {
62  (*str)[str->length()] = c;
63  str->length(str->length() + 1);
64 }
65 void qs_append(int i, String *str);
66 void qs_append(uint i, String *str);
67 
68 #endif // UNSAFE_STRING_APPEND_INCLUDED
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:165
Functions for reading and storing in machine-independent format.
void float8store(char *V, double M)
Definition: my_byteorder.h:202
void int4store(char *pT, uint32 A)
Definition: my_byteorder.h:172
uint32_t uint32
Definition: my_inttypes.h:66
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1056
const string value("\"Value\"")
Our own string classes, used pervasively throughout the executor.
unsigned int uint
Definition: uca-dump.cc:29
void write_at_position(int position, uint32 value, String *str)
Definition: unsafe_string_append.h:55
void q_append(const char c, String *str)
Definition: unsafe_string_append.h:34
void qs_append(const char *str_in, size_t len, String *str)
Definition: sql_string.cc:681
int n
Definition: xcom_base.cc:505