MySQL 9.6.0
Source Code Documentation
strconv.h
Go to the documentation of this file.
1/* Copyright (c) 2011, 2025, Oracle and/or its affiliates.
2
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License, version 2.0,
5 as published by the Free Software Foundation.
6
7 This program is designed to work with certain software (including
8 but not limited to OpenSSL) that is licensed under separate terms,
9 as designated in a particular file or component or in included license
10 documentation. The authors of MySQL hereby grant you an additional
11 permission to link the program and your derivative works with the
12 separately licensed software that they have either included with
13 the program or referenced in the documentation.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License, version 2.0, for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */
23
24#include "mysql/ranges/buffer_interface.h" // Buffer_interface
25#include "mysql/strconv/encode/out_str.h" // Out_str_base
26#include "mysql/utils/return_status.h" // Return_status
27#include "sql_string.h" // String
28
29/// Output string wrapper for String
30///
31/// @see mysql/strconv/outstr.h
33 : public mysql::ranges::Buffer_interface<Out_str_growable_mysql_string>,
35 public:
38 [[nodiscard]] std::size_t initial_capacity() const {
39 return m_str.alloced_length();
40 }
41 [[nodiscard]] std::size_t size() const { return m_str.length(); }
42 [[nodiscard]] char *data() const { return m_str.ptr(); }
43 [[nodiscard]] mysql::utils::Return_status resize(std::size_t new_size) const {
45 m_str.length(new_size);
46 m_str.ptr()[new_size] = '\0';
48 }
49
50 private:
52};
53
54/// Return a new Output String Wrapper that wraps the given String.
55///
56/// This enables passing (wrapped) String objects to mysql::strconv::encode.
59}
Experimental API header.
Output string wrapper for String.
Definition: strconv.h:34
String & m_str
Definition: strconv.h:51
static constexpr auto resize_policy
Definition: strconv.h:36
mysql::utils::Return_status resize(std::size_t new_size) const
Definition: strconv.h:43
std::size_t initial_capacity() const
Definition: strconv.h:38
char * data() const
Definition: strconv.h:42
std::size_t size() const
Definition: strconv.h:41
Out_str_growable_mysql_string(String &str) noexcept
Definition: strconv.h:37
Using this class is fraught with peril, and you need to be very careful when doing so.
Definition: sql_string.h:169
bool alloc(size_t arg_length)
Definition: sql_string.h:412
const char * ptr() const
Definition: sql_string.h:251
size_t length() const
Definition: sql_string.h:243
size_t alloced_length() const
Definition: sql_string.h:244
CRTP base class that provides a rich API for classes that behave like byte buffers.
Definition: buffer_interface.h:102
Top of the hierarchy.
Definition: out_str.h:194
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1077
Return_status
Simple, strongly-typed enumeration to indicate internal status: ok, error.
Definition: return_status.h:40
@ ok
operation succeeded
@ error
operation failed
noexcept
The return type for any call_and_catch(f, args...) call where f(args...) returns Type.
Definition: call_and_catch.h:76
Experimental API header.
Experimental API header.
auto out_str_growable(String &str)
Return a new Output String Wrapper that wraps the given String.
Definition: strconv.h:57
Our own string classes, used pervasively throughout the executor.