MySQL 9.0.0
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, 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#include "my_byteorder.h"
28#include "sql_string.h"
29
30/*
31 The following append operations do NOT check allocated memory
32 q_*** methods writes values of parameters itself
33 qs_*** methods writes string representation of value
34*/
35inline void q_append(const char c, String *str) {
36 (*str)[str->length()] = c;
37 str->length(str->length() + 1);
38}
39inline void q_append(const uint32 n, String *str) {
40 int4store(&((*str)[str->length()]), n);
41 str->length(str->length() + 4);
42}
43inline void q_append(double d, String *str) {
44 float8store(&((*str)[str->length()]), d);
45 str->length(str->length() + 8);
46}
47inline void q_append(double *d, String *str) {
48 float8store(&((*str)[str->length()]), *d);
49 str->length(str->length() + 8);
50}
51inline void q_append(const char *data, size_t data_len, String *str) {
52 memcpy(&((*str)[str->length()]), data, data_len);
53 str->length(str->length() + data_len);
54}
55
56inline void write_at_position(int position, uint32 value, String *str) {
57 int4store(&((*str)[position]), value);
58}
59
60void qs_append(const char *str_in, size_t len, String *str);
61void qs_append(double d, size_t len, String *str);
62inline void qs_append(const char c, String *str) {
63 (*str)[str->length()] = c;
64 str->length(str->length() + 1);
65}
66void qs_append(int i, String *str);
67void qs_append(uint i, String *str);
68
69#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:167
Functions for reading and storing in machine-independent format.
void float8store(char *V, double M)
Definition: my_byteorder.h:210
void int4store(char *pT, uint32 A)
Definition: my_byteorder.h:180
uint32_t uint32
Definition: my_inttypes.h:67
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1081
Our own string classes, used pervasively throughout the executor.
void write_at_position(int position, uint32 value, String *str)
Definition: unsafe_string_append.h:56
void q_append(const char c, String *str)
Definition: unsafe_string_append.h:35
void qs_append(const char *str_in, size_t len, String *str)
Definition: sql_string.cc:650
int n
Definition: xcom_base.cc:509