MySQL  8.0.20
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, Oracle and/or its affiliates. All rights reserved.
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
Our own string classes, used pervasively throughout the executor.
void write_at_position(int position, uint32 value, String *str)
Definition: unsafe_string_append.h:55
Using this class is fraught with peril, and you need to be very careful when doing so...
Definition: sql_string.h:164
Functions for reading and storing in machine-independent format.
unsigned int uint
Definition: uca-dump.cc:29
uint32_t uint32
Definition: my_inttypes.h:66
void qs_append(const char *str_in, size_t len, String *str)
Definition: sql_string.cc:679
int n
Definition: xcom_base.c:425
void float8store(char *V, double M)
Definition: my_byteorder.h:202
void q_append(const char c, String *str)
Definition: unsafe_string_append.h:34
void int4store(char *pT, uint32 A)
Definition: my_byteorder.h:172
const string value("\alue\)
size_t length() const
Definition: sql_string.h:238