MySQL 9.6.0
Source Code Documentation
out_str.h
Go to the documentation of this file.
1// Copyright (c) 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#ifndef MYSQL_STRCONV_ENCODE_OUT_STR_H
25#define MYSQL_STRCONV_ENCODE_OUT_STR_H
26
27/// @file
28/// Experimental API header
29
30#include <cassert> // assert
31#include <concepts> // invokable
32#include "mysql/allocators/memory_resource.h" // Memory_resource
33#include "mysql/meta/is_charlike.h" // Is_charlike
34#include "mysql/meta/is_either.h" // Is_either
35#include "mysql/meta/is_pointer.h" // Is_pointer_to
36#include "mysql/meta/is_specialization.h" // Is_specialization
37#include "mysql/meta/not_decayed.h" // Not_decayed
38#include "mysql/ranges/buffer_interface.h" // Buffer_interface
39#include "mysql/utils/call_and_catch.h" // call_and_catch
40#include "mysql/utils/char_cast.h" // char_cast
41#include "mysql/utils/return_status.h" // Return_status
42
43/// @addtogroup GroupLibsMysqlStrconv
44/// @{
45///
46/// Wrappers around output buffers for string-producing functions, enabling
47/// a single string producer to accept multiple string representations and
48/// allocation policies.
49///
50/// Anyone that defines a string-producing function usually has to make several
51/// decisions, and this framework makes it easy to support all variants without
52/// duplicating/repeating code:
53///
54/// - Who allocates the string: the function or the caller?
55///
56/// - How are strings represented: std::string or raw pointer? For raw pointers,
57/// how is the length represented: an integer length, or a raw pointer to the
58/// end? Are characters `char`, `unsigned char`, or `std::byte`? Which integer
59/// type is used for the length?
60///
61/// - Should the string be null-terminated or not?
62///
63/// If the string producer will only be used in code that follows one defined
64/// convention, the API can just use that. Otherwise, in more heterogeneous
65/// environments, use this library as follows:
66///
67/// - The string-producing function should take an `Out_str &` as out-parameter:
68/// @code
69/// Return_status produce(Out_str &out);
70/// @endcode
71///
72/// - The user code should pass an object returned by any of the `out_str_*`
73/// functions, which return a wrapper around the output parameters. For
74/// example:
75/// @code
76/// std::string str;
77/// // Allocate and write to `str`; return error if allocation fails.
78/// if (produce(out_str_growable(str)) == Return_status::error) { ... }
79/// @endcode
80/// or
81/// @code
82/// char *str = nullptr;
83/// char *end = str;
84/// // Allocate memory and write to `str`.
85/// // If allocation fails, return error.
86/// // Make the string null-terminated (the _z suffix).
87/// // Make `end` point to the null character.
88/// if (produce(out_str_growable_z(str, end)) == Return_status::error) {...}
89/// @endcode
90/// or
91/// @code
92/// unsigned char str[1024];
93/// size_t size = 1024;
94/// // We know the produced string is at most 1024 bytes (otherwise, behavior
95/// // is undefined). Write the string to `str`.
96/// // Do not make the string null-terminated (the _nz suffix).
97/// // Set `size` to the actual number of bytes written.
98/// if (produce(out_str_fixed_nz(str, size)) == Return_status::Error) { ... }
99/// @endcode
100/// or
101/// @code
102/// std::byte str[1024];
103/// size_t size = 1024;
104/// // We know the produced string is at most 1024 bytes (otherwise, behavior
105/// // is undefined). Write the string to `str`.
106/// // Do not make the string null-terminated (the _nz suffix).
107/// // Set `size` to the actual number of bytes written.
108/// produce(out_str_fixed_nz(str, size));
109/// @endcode
110/// These are only examples: each of `_growable`, `_fixed` can be combined
111/// with all string representations (std::string, begin+end, or begin+length).
112/// Raw pointer representations can be either null-terminated or not (the
113/// `_z`/`_nz` suffixes); optionally take a Memory_resource parameter; use
114/// `char`, `unsigned char`, or `std::byte` for the character type; and their
115/// sizes can be any integer type.
116///
117/// - To write to Output String Wrappers, while taking both the resize policy
118/// and the zero-termination policy into account, the implementation of
119/// `produce` may use the function `out_str_write`. `out_str_write` takes
120/// an invocable as argument; the invocable is what actually generates the
121/// string, and `out_str_write` performs the allocation (and checking for
122/// out-of-memory errors), and writes the null-termination byte if required.
123
124// ==== Overview of implementation ====
125//
126// We implement out-strings using a class hierarchy with the following levels:
127//
128// - Out_str_base is the common base class. It is empty, and is used only to
129// identify that classes belong to the hierarchy.
130//
131// - `Representation_string`, `Representation_strstr`, and
132// `Representation_strsize` define the three representations of strings which
133// use std::string, begin pointer+end pointer, and begin pointer+size,
134// respectively. They all inherit from `Out_str_base` and `Buffer_interface`,
135// and provide the following members:
136//
137// public:
138// // Return pointer to the first character, using three alternative
139// // representations of characters.
140// char *data() const;
141// unsigned char *udata() const;
142// std::byte *bdata() const;
143// // Before `store_size` has been invoked, return the initial capacity;
144// // otherwise undefined.
145// std::size_t initial_capacity() const;
146// // After `store_size` has been invoked, return the output size; otherwise
147// // undefined.
148// std::size_t size() const;
149//
150// protected:
151// // Stores the given value in the size field.
152// void store_size(size_t);
153//
154// (Functionality common to `Representation_ptrsize` and
155// `Representation_ptrstr` is defined in their common base class
156// `Represntation_ptr_base`. All `Representation_*` classes use
157// `Buffer_interface`.)
158//
159// - `Policy_fixed`, `Policy_growable_string`, `Policy_growable_ptr` define the
160// resize policy and the null-termination policy. All take a template
161// parameter that specifies a base class among the three `Representation_*`
162// classes above. This allows the next level in the hierarchy to compose a
163// policy with a representation (see below) . The `Policy_*` provide the
164// following members:
165//
166// public:
167// // `growable` for `Policy_growable_*`; `fixed` for `Policy_fixed`.
168// static constexpr Resize_policy resize_policy;
169// // Change size by according to the resize policy, call `store_size`, and
170// // set the null-termination byte if required.
171// Return_status resize(size_t);
172//
173// - `Out_str_{fixed|growable}_{string|ptrsize|ptrptr}_alias` are type aliases
174// that combine one of the representations with one of the resize policies, by
175// passing the representation class as template argument to the policy class.
176//
177// - `Out_str_{fixed|growable}_{string|ptrsize|ptrptr}` are classes
178// corresponding to each alias. They do not provide any new functionality
179// compared to the aliases. However, for technical reasons the Policy classes,
180// and therefore also the aliases, have the Memory_resoruce constructor
181// argument before other arguments, which is a little inconvenient/unnatural
182// since this argument is optional. These classes fix that. Also, the names
183// of these classes are more succinct than the aliases when they appear in
184// stack traces and compilation errors.
185//
186// - `out_str{growable|fixed{_nz|z}}` are factory functions that users call
187// to wrap their output string arguments.
188
189namespace mysql::strconv {
190
191// ==== Common base ====
192
193/// Top of the hierarchy
195
196// NOLINTBEGIN(performance-enum-size): silence clang-tidy's pointless hint
197
198/// Indicates whether an Ouput String Wrapper is growable or fixed-size.
200
201/// Indicates whether an Output String Wrapper requires that the string shall
202/// be null-terminated or not.
203enum class Null_terminated { no, yes };
204
205/// Indicates the type of string represention used by an Output String Wrapper.
207 /// String represented as `std::string`
208 string,
209 /// String represented using raw pointer to beginning and raw pointer to end.
210 ptrptr,
211 /// String represented using raw pointer to beginning and integral size.
212 ptrsize
213};
214
215// NOLINTEND(performance-enum-size)
216
217/// True if Test is an Output String Wrapper, i.e., derived from Out_str_base.
218template <class Test>
219concept Is_out_str =
220 std::derived_from<Test, Out_str_base> && // this comment helps clang-format
221 requires(Test test, std::size_t new_size) {
222 { test.initial_capacity() } -> std::same_as<std::size_t>;
223 { test.size() } -> std::same_as<std::size_t>;
224 {
225 test.resize(new_size)
227 { test.data() } -> std::same_as<char *>;
228 { test.udata() } -> std::same_as<unsigned char *>;
229 { test.bdata() } -> std::same_as<std::byte *>;
230 { Test::resize_policy } -> std::convertible_to<Resize_policy>;
231 };
232
233/// True if Test is an Output String Wrapper with Resize_policy *fixed*.
234template <class Test>
236 (Test::resize_policy == Resize_policy::fixed);
237
238/// True if Test is an Output String Wrapper with Resize_policy *growable*.
239template <class Test>
241 (Test::resize_policy == Resize_policy::growable);
242
243} // namespace mysql::strconv
244
245// ==== Classes implementing string representations ====
246
247namespace mysql::strconv::detail {
248
249/// Represent a string as an object, typically std::string.
250///
251/// This stores a reference to the object. The object can be a specialization of
252/// std::string, or any other class implementing `data`, `size`, and `resize`
253/// members.
254template <class String_tp>
256 : public mysql::ranges::Buffer_interface<Representation_string<String_tp>>,
257 public Out_str_base {
258 public:
260
261 /// Construct a new object wrapping the given `str` object.
262 explicit Representation_string(String_tp &str) : m_str(str) {}
263
264 /// Return a raw pointer to the data.
265 [[nodiscard]] char *data() const {
266 return mysql::utils::char_cast(m_str.data());
267 }
268
269 /// Before `resize`, return the capacity of the string.
270 [[nodiscard]] std::size_t initial_capacity() const {
271 return m_str.capacity();
272 }
273
274 /// After `resize`, return the size of the string.
275 [[nodiscard]] std::size_t size() const { return m_str.size(); }
276
277 protected:
278 /// Store the string size.
279 void store_size(std::size_t size_arg) const { m_str.resize(size_arg); }
280
281 /// Reference to string storage.
282 String_tp &m_str;
283};
284
285/// Common CRTP base class for Representation_ptrptr and Representation_ptrsize.
286///
287/// This stores either a pointer to the beginning of the string, or a reference
288/// to a pointer to the beginning of the string; the template argument decides
289/// which.
290///
291/// @tparam Self_tp Class implementing `size` member.
292///
293/// @tparam Ptr_tp Type of char pointer: either `char *&`, if the buffer is
294/// resizable, or `char *`, for fixed-size buffers.
295template <class Self_tp, class Ptr_tp>
297 public Out_str_base {
298 public:
299 /// Construct a new object wrapping the buffer at the given position.
300 explicit Representation_ptr_base(Ptr_tp first, std::size_t capacity)
301 : m_first(first), m_initial_capacity(capacity) {}
302
303 /// Return pointer to the data.
304 [[nodiscard]] char *data() const { return mysql::utils::char_cast(m_first); }
305
306 /// Before `resize`, return the value of the size field.
307 [[nodiscard]] std::size_t initial_capacity() const {
308 return std::size_t(m_initial_capacity);
309 }
310
311 protected:
312 /// Pointer to first character.
313 Ptr_tp m_first;
314
315 /// Initial capacity.
317};
318
319/// Represent a string as raw pointer to the beginning and raw pointer to the
320/// end.
321///
322/// This stores both pointers. The end is always a reference (determined by the
323/// template arguent); the beginning is optionally a reference.
324///
325/// @tparam Ptr_tp Type of char pointer to the beginning: either `char *&`, if
326/// the buffer is resizable, or `char *`, for fixed-size buffers.
327template <class Ptr_tp>
329 : public Representation_ptr_base<Representation_ptrptr<Ptr_tp>, Ptr_tp> {
331
332 public:
334
335 /// Construct a new object from the given pointer to begin and pointer to end
336 /// of capacity, and the given reference to pointer to the end.
337 explicit Representation_ptrptr(Ptr_tp first, Ptr_tp &last,
338 Ptr_tp capacity_end)
339 : Base_t(first,
340 std::size_t((capacity_end == nullptr ? last : capacity_end) -
341 first)),
342 m_last(last) {
343 if (capacity_end == nullptr)
344 assert(first <= last);
345 else
346 assert(first <= capacity_end);
347 }
348
349 // After `resize`, return the distance between the begin pointer and the end
350 // pointer.
351 [[nodiscard]] std::size_t size() const { return m_last - this->m_first; }
352
353 protected:
354 /// Alter the end pointer.
355 void store_size(std::size_t size_arg) const {
356 m_last = this->m_first + size_arg;
357 }
358
359 /// Reference to end pointer.
360 Ptr_tp &m_last;
361};
362
363/// Represent a string as raw pointer to the beginning, and integer size.
364///
365/// This stores the pointer and integer. The size is always a reference; the
366/// beginning is optinally a reference (determined by the template argument).
367///
368/// @tparam Ptr_tp Type of char pointer to the beginning: either `char *&`, if
369/// the buffer is resizable, or `char *`, for fixed-size buffers.
370///
371/// @tparam Size_tp Type of size field.
372template <class Ptr_tp, std::integral Size_tp>
374 : public Representation_ptr_base<Representation_ptrsize<Ptr_tp, Size_tp>,
375 Ptr_tp> {
376 using Base_t =
378
379 public:
381
382 /// Construct a new object from the given begin pointer, reference to size,
383 /// and capacity.
384 explicit Representation_ptrsize(Ptr_tp first, Size_tp &size_arg,
385 Size_tp capacity)
386 : Base_t(first, std::size_t(capacity == 0 ? size_arg : capacity)),
387 m_size(size_arg) {}
388
389 /// After `resize`, return the value of the size field.
390 [[nodiscard]] std::size_t size() const { return std::size_t(m_size); }
391
392 protected:
393 /// Alter the size field.
394 void store_size(std::size_t size_arg) const { m_size = Size_tp(size_arg); }
395
396 /// Reference to integral size.
397 Size_tp &m_size;
398};
399
400// ==== Classes implementing resize policies and null termination ====
401//
402// The three CRTP base classes:
403// Policy_growable_string
404// Policy_growable_ptr
405// Policy_fixed
406//
407// Each implements resize() (which uses implementations of initial_capacity(),
408// store_size(), and data() provided by the subclass).
409
410/// Base class for Out_str_growable_string.
411///
412/// @tparam Representation_tp base class to inherit from, which provides the
413/// string representation.
414template <class Representation_tp>
415class Policy_growable_string : public Representation_tp {
416 public:
417 static constexpr auto resize_policy = Resize_policy::growable;
418 static constexpr auto null_terminated = Null_terminated::yes;
419
420 /// Construct a new object, forwarding all arguments to the base class.
421 explicit Policy_growable_string(auto &...args) : Representation_tp(args...) {}
422
423 /// Resize the std::string object.
424 ///
425 /// @param size The new size
426 ///
427 /// @return Return_status::ok on success, Return_status::error if an
428 /// out-of-memory error occurs.
429 [[nodiscard]] mysql::utils::Return_status resize(std::size_t size) const {
430 return mysql::utils::call_and_catch([&] { this->m_str.resize(size); });
431 }
432};
433
434/// Base class for all Out_str_growable_ptr* classes.
435///
436/// @tparam Representation_tp base class to inherit from, which provides the
437/// string representation.
438///
439/// @tparam null_terminated_tp Indicate whether the string should be
440/// null-terminated or not.
441template <class Char_tp, class Representation_tp,
442 Null_terminated null_terminated_tp>
443class Policy_growable_ptr : public Representation_tp {
444 static constexpr size_t null_size =
445 (null_terminated_tp == Null_terminated::yes) ? 1 : 0;
446 using This_t =
448
449 public:
450 static constexpr auto resize_policy = Resize_policy::growable;
451 static constexpr auto null_terminated = null_terminated_tp;
452
453 /// Construct a new object, forwarding all arguments to the base class.
454 template <class... Args_t>
455 requires mysql::meta::Not_decayed<This_t, Args_t...>
456 explicit Policy_growable_ptr(Args_t &&...args)
457 : Representation_tp(std::forward<Args_t>(args)...) {}
458
459 /// Construct a new object with the given Memory_resource, forwarding all
460 /// remaining arguments to the base class.
461 template <class... Args_t>
463 mysql::allocators::Memory_resource memory_resource, Args_t &&...args)
464 : Representation_tp(std::forward<Args_t>(args)...),
465 m_memory_resource(std::move(memory_resource)) {}
466
467 /// Return the Memory_resource.
469 return m_memory_resource;
470 }
471
472 /// Resize the character buffer and store the new size.
473 ///
474 /// @param size_arg The new size
475 ///
476 /// @return Return_status::ok on success, Return_status::error if an
477 /// out-of-memory error occurs.
478 [[nodiscard]] mysql::utils::Return_status resize(std::size_t size_arg) const {
479 if (size_arg > this->initial_capacity() || this->m_first == nullptr) {
480 auto *new_first = reinterpret_cast<Char_tp *>(
482 if (new_first == nullptr) return mysql::utils::Return_status::error;
483 m_memory_resource.deallocate(this->m_first);
484 this->m_first = new_first;
485 }
486 this->store_size(size_arg);
487 if constexpr (null_terminated_tp == Null_terminated::yes &&
488 Representation_tp::representation_type !=
490 this->data()[size_arg] = '\0';
491 }
493 }
494
495 private:
497};
498
499/// Base class for all Out_str_fixed* classes.
500///
501/// @tparam Representation_tp base class to inherit from, which provides the
502/// string representation.
503///
504/// @tparam null_terminated_tp Indicate whether the string should be
505/// null-terminated or not.
506template <class Representation_tp, Null_terminated null_terminated_tp>
507class Policy_fixed : public Representation_tp {
508 private:
510
511 public:
512 static constexpr auto resize_policy = Resize_policy::fixed;
513 static constexpr auto null_terminated = null_terminated_tp;
514
515 /// Construct a new object, forwarding all arguments to the base class.
516 template <class... Args_t>
517 requires mysql::meta::Not_decayed<This_t, Args_t...>
518 explicit Policy_fixed(Args_t &&...args)
519 : Representation_tp(std::forward<Args_t>(args)...) {}
520
521 /// Assume that the character buffer has at least the given new size, and
522 /// store the new size.
523 ///
524 /// @param size_arg The new size.
525 void resize(std::size_t size_arg) const {
526 assert(size_arg <= this->initial_capacity());
527 this->store_size(size_arg);
528 if constexpr (null_terminated_tp == Null_terminated::yes &&
529 Representation_tp::representation_type !=
531 this->data()[size_arg] = '\0';
532 }
533 }
534};
535
536// ==== Type aliases that combine a representation and a resize policy ====
537
538template <class String_tp>
541
542template <class Size_tp>
545
546template <class Size_tp>
549
550template <class Char_tp>
553
554template <class Char_tp>
557
558template <class String_tp>
561
562template <mysql::meta::Is_charlike Char_t, std::integral Size_tp>
566
567template <mysql::meta::Is_charlike Char_t, std::integral Size_tp>
571
572template <mysql::meta::Is_charlike Char_t>
576
577template <mysql::meta::Is_charlike Char_t>
581
582} // namespace mysql::strconv::detail
583
584// ==== Classes wrapping the aliases ====
585
586namespace mysql::strconv {
587
588// ---- Fixed-size output buffers ----
589
590/// Non-growable output buffer wrapper, represented as std::string.
591template <class String_tp>
593 : public detail::Out_str_fixed_string_alias<String_tp> {
594 public:
595 explicit Out_str_fixed_string(String_tp &str)
596 : detail::Out_str_fixed_string_alias<String_tp>(str) {}
597};
598
599/// Non-growable output buffer wrapper, represented as raw pointers to the
600/// beginning and end, null-terminated.
601template <class Char_tp>
603 : public detail::Out_str_fixed_ptrptr_z_alias<Char_tp> {
605
606 public:
607 template <class... Args_t>
608 requires mysql::meta::Not_decayed<This_t, Args_t...>
609 explicit Out_str_fixed_ptrptr_z(Args_t &&...args)
611 std::forward<Args_t>(args)...) {}
612};
613
614/// Non-growable output buffer wrapper, represented as raw pointers to the
615/// beginning and end, non-null-terminated.
616template <class Char_tp>
618 : public detail::Out_str_fixed_ptrptr_nz_alias<Char_tp> {
620
621 public:
622 template <class... Args_t>
623 requires mysql::meta::Not_decayed<This_t, Args_t...>
624 explicit Out_str_fixed_ptrptr_nz(Args_t &&...args)
626 std::forward<Args_t>(args)...) {}
627};
628
629/// Non-growable output buffer wrapper, represented as raw pointer to the
630/// beginning, and integer size, null-terminated.
631template <class Size_tp>
633 : public detail::Out_str_fixed_ptrsize_z_alias<Size_tp> {
635
636 public:
637 template <class... Args_t>
638 requires mysql::meta::Not_decayed<This_t, Args_t...>
639 explicit Out_str_fixed_ptrsize_z(Args_t &&...args)
641 std::forward<Args_t>(args)...) {}
642};
643
644/// Non-growable output buffer wrapper, represented as raw pointer to the
645/// beginning, and integer size, non-null-terminated.
646template <class Size_tp>
650
651 public:
652 template <class... Args_t>
653 requires mysql::meta::Not_decayed<This_t, Args_t...>
654 explicit Out_str_fixed_ptrsize_nz(Args_t &&...args)
656 std::forward<Args_t>(args)...) {}
657};
658
659// ---- Growable output buffers ----
660
661/// Growable output buffer wrapper, represented as std::string.
662template <class String_tp>
664 : public detail::Out_str_growable_string_alias<String_tp> {
665 public:
666 explicit Out_str_growable_string(String_tp &str)
668};
669
670/// Growable output buffer wrapper, represented as raw pointer to the
671/// beginning, and integer size, null-terminated.
672template <mysql::meta::Is_charlike Char_t, std::integral Size_tp>
674 : public detail::Out_str_growable_ptrsize_z_alias<Char_t, Size_tp> {
675 public:
677 Char_t *&first, Size_tp &size, Size_tp capacity,
678 const mysql::allocators::Memory_resource &memory_resource)
679 : detail::Out_str_growable_ptrsize_z_alias<Char_t, Size_tp>(
680 memory_resource, first, size, capacity) {}
681};
682
683/// Growable output buffer wrapper, represented as raw pointer to the
684/// beginning, and integer size, non-null-terminated.
685template <mysql::meta::Is_charlike Char_t, std::integral Size_tp>
687 : public detail::Out_str_growable_ptrsize_nz_alias<Char_t, Size_tp> {
688 public:
690 Char_t *&first, Size_tp &size, Size_tp capacity,
691 const mysql::allocators::Memory_resource &memory_resource)
692 : detail::Out_str_growable_ptrsize_nz_alias<Char_t, Size_tp>(
693 memory_resource, first, size, capacity) {}
694};
695
696/// Growable output buffer wrapper, represented as raw pointers to the beginning
697/// and end, null-terminated.
698template <mysql::meta::Is_charlike Char_t>
701 public:
703 Char_t *&first, Char_t *&last, Char_t *&capacity_end,
704 const mysql::allocators::Memory_resource &memory_resource)
705 : detail::Out_str_growable_ptrptr_z_alias<Char_t>(memory_resource, first,
706 last, capacity_end) {}
707};
708
709/// Growable output buffer wrapper, represented as raw pointers to the beginning
710/// and end, non-null-terminated.
711template <mysql::meta::Is_charlike Char_t>
714 public:
716 Char_t *&first, Char_t *&last, Char_t *&capacity_end,
717 const mysql::allocators::Memory_resource &memory_resource)
718 : detail::Out_str_growable_ptrptr_nz_alias<Char_t>(memory_resource, first,
719 last, capacity_end) {}
720};
721
722// ==== API factory functions ====
723
724// ---- API factory functions with resize policy "fixed", string argument ----
725
726/// Return a wrapper around a non-growable output buffer, represented as a
727/// std::string or similar type.
728///
729/// @param[in,out] str Reference to std::string, or other type that provides
730/// similar `capacity`, `resize`, and `data` members.
731///
732/// @return Object of subclass of `Out_str_base`, which wraps `str`.
733template <mysql::meta::Is_specialization<std::basic_string> String_t>
734[[nodiscard]] auto out_str_fixed(String_t &str) {
736}
737
738// ---- API factory functions with resize policy "fixed", raw pointers ----
739
740/// Return a wrapper around a non-growable, null-terminated output buffer,
741/// represented using a raw pointer to the beginning and a reference to an
742/// integral size.
743///
744/// Functions accepting this type as argument will typically write to the
745/// character buffer and alter `length` to point to the zero byte.
746///
747/// @param[in,out] first Raw pointer to the beginning of a character buffer.
748///
749/// @param[out] length Reference to integer, which writers may update to the
750/// number of string characters not counting the null-termination character.
751///
752/// @param capacity Available capacity to write string characters, not counting
753/// the null-termination character. Note that this should be one less than the
754/// actual buffer size. May be omitted, in which case this value is taken from
755/// `length` instead.
756///
757/// @return Object of subclass of `Out_str_base`, which wraps the given range of
758/// characters.
759template <std::integral Size_t>
760[[nodiscard]] auto out_str_fixed_z(
762 Size_t capacity = 0) {
763 // In case `first` is `unsigned char *`, cast to `char *` in order to collapse
764 // template instantiations for `unsigned char *` and `char *`.
765 //
766 // The cast to `char *` is safe because C++ strict aliasing rules specifically
767 // allow `char *` to alias other types. (In other cases in this file, casting
768 // one argument to `char *` would require casting other arguments to `char
769 // *&`, which is not allowed.)
771 capacity);
772}
773
774/// Return a wrapper around a non-growable, null-terminated output buffer,
775/// represented using raw a pointer to the beginning and a reference to a raw
776/// pointer to the end.
777///
778/// Functions accepting this type as argument will typically write to the
779/// character buffer and alter `last` to point to the zero byte.
780///
781/// @param[in,out] first Raw pointer to the beginning of a character buffer.
782///
783/// @param[out] last Reference to raw pointer, which writers may update to point
784/// to the null-termination character.
785///
786/// @param capacity_end Pointer to the last character that may be used for the
787/// null-termination character. Note that this is the last character *included*
788/// in the buffer, not one-past-the-last buffer character. May be omitted, in
789/// which case this value is taken from `last` instead.
790///
791/// @return Object of subclass of `Out_str_base`, which wraps the given range of
792/// characters.
793template <mysql::meta::Is_charlike Char_t,
795[[nodiscard]] auto out_str_fixed_z(Charptr_t first, Char_t *&last,
796 Char_t *capacity_end = nullptr) {
797 return Out_str_fixed_ptrptr_z<Char_t>(first, last, capacity_end);
798}
799
800/// Return a wrapper around a non-growable, non-null-terminated output buffer,
801/// represented using a raw pointer to the beginning and a reference to an
802/// integral size.
803///
804/// Functions accepting this type as argument will typically write to the
805/// character buffer and alter `length` to the past-the-end character.
806///
807/// @param[in,out] first Raw pointer to the beginning of a character buffer.
808///
809/// @param[out] length Reference to integer, which writers may update to the
810/// number of string characters written. May be omitted, in which case this
811/// value is taken from `length` instead.
812///
813/// @param capacity Available capacity to write string characters.
814///
815/// @return Object of subclass of `Out_str_base`, which wraps the given range of
816/// characters.
817template <std::integral Size_t>
818[[nodiscard]] auto out_str_fixed_nz(
820 Size_t capacity = 0) {
821 // In case `first` is `unsigned char *`, cast to `char *` in order to collapse
822 // template instantiations for `unsigned char *` and `char *`.
823 //
824 // The cast to `char *` is safe because C++ strict aliasing rules specifically
825 // allow `char *` to alias other types. (In other cases in this file, casting
826 // one argument to `char *` would require casting other arguments to `char
827 // *&`, which is not allowed.)
829 length, capacity);
830}
831
832/// Return a wrapper around a non-growable, non-null-terminated output buffer,
833/// represented using raw a pointer to the beginning and a reference to a raw
834/// pointer to the end.
835///
836/// Functions accepting this type as argument will typically write to the
837/// character buffer and alter `last` to the past-the-end character.
838///
839/// @param[in,out] first Raw pointer to the beginning of a character buffer.
840///
841/// @param[out] last Reference to raw pointer, which writers may update to point
842/// to one-past-the-last character written.
843///
844/// @param capacity_end Pointer to one-past-the-last character that may be
845/// written. May be omitted, in which case this value is taken from `last`
846/// instead.
847///
848/// @return Object of subclass of `Out_str_base`, which wraps the given range of
849/// characters.
850template <mysql::meta::Is_charlike Char_t,
852[[nodiscard]] auto out_str_fixed_nz(Charptr_t first, Char_t *&last,
853 Char_t *capacity_end = nullptr) {
854 return Out_str_fixed_ptrptr_nz<Char_t>(first, last, capacity_end);
855}
856
857// ---- API factory functions with resize policy "fixed", arrays ----
858
859// These are equivalent to the versions that take a "pointer", except they take
860// an array whose length is known at compile-time as argument, and assert that
861// the array size is sufficient.
862
863/// Return a wrapper around a non-growable, null-terminated output buffer,
864/// represented as an array and a reference to an integral size.
865///
866/// Functions accepting this type as argument will typically write to the
867/// character buffer and alter `length` to point to the zero byte.
868///
869/// @param[in,out] first Raw pointer to the beginning of a character buffer.
870///
871/// @param[out] length Reference to integer, which writers may update to the
872/// number of string characters not counting the null-termination character.
873///
874/// @param capacity Available capacity to write string characters, not counting
875/// the null-termination character. Note that this should be one less than the
876/// actual buffer size. May be omitted, in which case this value is taken from
877/// `length` instead.
878///
879/// @return Object of subclass of `Out_str_base`, which wraps the given range of
880/// characters.
881template <std::integral Size_t, std::ptrdiff_t array_size>
882[[nodiscard]] auto out_str_fixed_z(
883 mysql::meta::Is_charlike auto(&first)[array_size], Size_t &length,
884 Size_t capacity = 0) {
885 if (capacity == 0)
886 assert(length <= array_size - 1);
887 else
888 assert(capacity <= array_size - 1);
889 return out_str_fixed_z(reinterpret_cast<char *>(first), length, capacity);
890}
891
892/// Return a wrapper around a non-growable, null-terminated output buffer,
893/// represented as an array and a reference to a raw pointer to the end.
894///
895/// Functions accepting this type as argument will typically write to the
896/// character buffer and alter `last` to point to the zero byte.
897///
898/// @param[in,out] first Raw pointer to the beginning of a character buffer.
899///
900/// @param[out] last Reference to raw pointer, which writers may update to point
901/// to the null-termination character.
902///
903/// @param capacity_end Pointer to the last character that may be used for the
904/// null-termination character. Note that this is the last character *included*
905/// in the buffer, not one-past-the-last buffer character. May be omitted, in
906/// which case this value is taken from `last` instead.
907///
908/// @return Object of subclass of `Out_str_base`, which wraps the given range of
909/// characters.
910template <mysql::meta::Is_charlike Char_t, std::ptrdiff_t array_size>
911[[nodiscard]] auto out_str_fixed_z(Char_t (&first)[array_size], Char_t *&last,
912 Char_t *capacity_end = nullptr) {
913 if (capacity_end == nullptr)
914 assert(last - first <= array_size - 1);
915 else
916 assert(capacity_end - first <= array_size - 1);
917 return out_str_fixed_z(reinterpret_cast<Char_t *>(first), last, capacity_end);
918}
919
920/// Return a wrapper around a non-growable, non-null-terminated output buffer,
921/// represented as an array and a reference to an integral size.
922///
923/// Functions accepting this type as argument will typically write to the
924/// character buffer and alter `length` to the past-the-end character.
925///
926/// @param[in,out] first Raw pointer to the beginning of a character buffer.
927///
928/// @param[out] length Reference to integer, which writers may update to the
929/// number of string characters written.
930///
931/// @param capacity Available capacity to write string characters. May be
932/// omitted, in which case this value is taken from `length` instead.
933///
934/// @return Object of subclass of `Out_str_base`, which wraps the given range of
935/// characters.
936template <std::integral Size_t, std::ptrdiff_t array_size>
937[[nodiscard]] auto out_str_fixed_nz(
938 mysql::meta::Is_charlike auto(&first)[array_size], Size_t &length,
939 Size_t capacity = 0) {
940 if (capacity == 0)
941 assert(length <= array_size);
942 else
943 assert(capacity <= array_size);
944 return out_str_fixed_nz(reinterpret_cast<char *>(first), length, capacity);
945}
946
947/// Return a wrapper around a non-growable, non-null-terminated output buffer,
948/// represented as an array and a reference to a raw pointer to the end.
949///
950/// Functions accepting this type as argument will typically write to the
951/// character buffer and alter `last` to the past-the-end character.
952///
953/// @param[in,out] first Raw pointer to the beginning of a character buffer.
954///
955/// @param[out] last Reference to raw pointer, which writers may update to point
956/// to one-past-the-last character written.
957///
958/// @param capacity_end Pointer to one-past-the-last character that may be
959/// written. May be omitted, in which case this value is taken from `last`
960/// instead.
961///
962/// @return Object of subclass of `Out_str_base`, which wraps the given range of
963/// characters.
964template <mysql::meta::Is_charlike Char_t, std::ptrdiff_t array_size>
965[[nodiscard]] auto out_str_fixed_nz(Char_t (&first)[array_size], Char_t *&last,
966 Char_t *capacity_end = nullptr) {
967 if (capacity_end == nullptr)
968 assert(last - first <= array_size);
969 else
970 assert(capacity_end - first <= array_size);
971 return out_str_fixed_nz(reinterpret_cast<Char_t *>(first), last,
972 capacity_end);
973}
974
975// ---- API factory functions with resize policy "growable" ----
976
977/// Return a wrapper around a growable output buffer, represented as a
978/// std::string or similar type.
979///
980/// @param[in,out] str Reference to std::string, or other type that provides
981/// similar `capacity`, `reserve`, `resize`, and `data` members.
982///
983/// @return Object of subclass of `Out_str_base`, which wraps `str`.
984template <mysql::meta::Is_specialization<std::basic_string> String_t>
985[[nodiscard]] auto out_str_growable(String_t &str) {
987}
988
989/// Return a wrapper around a growable, null-terminated output buffer,
990/// represented using a reference to a raw pointer to the beginning and a
991/// reference to an integral size.
992///
993/// Functions accepting this type as argument will typically allocate a new
994/// buffer and replace `first` by it if the given one is too small; then write
995/// to the character buffer and alter `length` to point to the zero byte.
996///
997/// @param[in,out] first Reference to raw pointer to the beginning of a
998/// character buffer. May be nullptr if length is 0; otherwise must be a valid
999/// pointer.
1000///
1001/// @param[out] length Reference to integer, which writers may update to the
1002/// number of string characters not counting the null-termination character.
1003///
1004/// @param capacity Available capacity to write string characters, not counting
1005/// the null-termination character. Note that this should be one less than the
1006/// actual buffer size. May be omitted, in which case this value is taken from
1007/// `length` instead.
1008///
1009/// @param memory_resource Memory_resource to allocate bytes. If omitted, uses
1010/// the default-constructed Memory_resource, which uses std::malloc and
1011/// std::free.
1012///
1013/// @return Object of subclass of `Out_str_base`, which wraps the given range of
1014/// characters.
1015template <mysql::meta::Is_charlike Char_t, std::integral Size_t>
1016[[nodiscard]] auto out_str_growable_z(
1017 Char_t *&first, Size_t &length, Size_t capacity = 0,
1018 const mysql::allocators::Memory_resource &memory_resource = {}) {
1019 return Out_str_growable_ptrsize_z<Char_t, Size_t>(first, length, capacity,
1020 memory_resource);
1021}
1022
1023/// Return a wrapper around a growable, null-terminated output buffer,
1024/// represented using reference to a raw a pointer to the beginning and a
1025/// reference to a raw pointer to the end.
1026///
1027/// Functions accepting this type as argument will typically allocate a new
1028/// buffer and replace `first` by it if the given one is too small; then write
1029/// to the character buffer and alter `last` to point to the zero byte.
1030///
1031/// @param[in,out] first Reference to raw pointer to the beginning of a
1032/// character buffer. May be nullptr if last is nullptr; otherwise must be a
1033/// valid pointer.
1034///
1035/// @param[out] last Reference to raw pointer, which writers may update to point
1036/// to the null-termination character.
1037///
1038/// @param capacity_end Pointer to the last character that may be used for the
1039/// null-termination character. Note that this is the last character *included*
1040/// in the buffer, not one-past-the-last buffer character. May be omitted, in
1041/// which case this value is taken from `last` instead.
1042///
1043/// @param memory_resource Memory_resource to allocate bytes. If omitted, uses
1044/// the default-constructed Memory_resource, which uses std::malloc and
1045/// std::free.
1046///
1047/// @return Object of subclass of `Out_str_base`, which wraps the given range of
1048/// characters.
1049template <mysql::meta::Is_charlike Char_t>
1050[[nodiscard]] auto out_str_growable_z(
1051 Char_t *&first, Char_t *&last, Char_t *capacity_end = nullptr,
1052 const mysql::allocators::Memory_resource &memory_resource = {}) {
1053 return Out_str_growable_ptrptr_z<Char_t>(first, last, capacity_end,
1054 memory_resource);
1055}
1056
1057/// Return a wrapper around a growable, non-null-terminated output buffer,
1058/// represented using a reference to a raw pointer to the beginning and a
1059/// reference to an integral size.
1060///
1061/// Functions accepting this type as argument will typically allocate a new
1062/// buffer and replace `first` by it if the given one is too small; then write
1063/// to the character buffer and alter `length` to the past-the-end character.
1064///
1065/// @param[in,out] first Reference to raw pointer to the beginning of a
1066/// character buffer. May be nullptr if length is 0; otherwise must be a valid
1067/// pointer.
1068///
1069/// @param[out] length Reference to integer, which writers may update to the
1070/// number of string characters written.
1071///
1072/// @param capacity Available capacity to write string characters. May be
1073/// omitted, in which case this value is taken from `length` instead.
1074///
1075/// @param memory_resource Memory_resource to allocate bytes. If omitted, uses
1076/// the default-constructed Memory_resource, which uses std::malloc and
1077/// std::free.
1078///
1079/// @return Object of subclass of `Out_str_base`, which wraps the given range of
1080/// characters.
1081template <mysql::meta::Is_charlike Char_t, std::integral Size_t>
1082[[nodiscard]] auto out_str_growable_nz(
1083 Char_t *&first, Size_t &length, Size_t capacity = 0,
1084 const mysql::allocators::Memory_resource &memory_resource = {}) {
1085 return Out_str_growable_ptrsize_nz<Char_t, Size_t>(first, length, capacity,
1086 memory_resource);
1087}
1088
1089/// Return a wrapper around a growable, non-null-terminated output buffer,
1090/// represented using reference to a raw a pointer to the beginning and a
1091/// reference to a raw pointer to the end
1092///
1093/// Functions accepting this type as argument will typically allocate a new
1094/// buffer and replace `first` by it if the given one is too small; then write
1095/// to the character buffer and alter `last` to point to the past-the-end
1096/// character.
1097///
1098/// @param[in,out] first Reference to raw pointer to the beginning of a
1099/// character buffer. May be nullptr if last is nullptr; otherwise must be a
1100/// valid pointer.
1101///
1102/// @param[out] last Reference to raw pointer, which writers may update to point
1103/// to one-past-the-last character written.
1104///
1105/// @param capacity_end Pointer to one-past-the-last character that may be
1106/// written. May be omitted, in which case this value is taken from `last`
1107/// instead.
1108///
1109/// @param memory_resource Memory_resource to allocate bytes. If omitted, uses
1110/// the default-constructed Memory_resource, which uses std::malloc and
1111/// std::free.
1112///
1113/// @return Object of subclass of `Out_str_base`, which wraps the given range of
1114/// characters.
1115template <mysql::meta::Is_charlike Char_t>
1116[[nodiscard]] auto out_str_growable_nz(
1117 Char_t *&first, Char_t *&last, Char_t *capacity_end = nullptr,
1118 const mysql::allocators::Memory_resource &memory_resource = {}) {
1119 return Out_str_growable_ptrptr_nz<Char_t>(first, last, capacity_end,
1120 memory_resource);
1121}
1122
1123} // namespace mysql::strconv
1124
1125// addtogroup GroupLibsMysqlStrconv
1126/// @}
1127
1128#endif // ifndef MYSQL_STRCONV_ENCODE_OUT_STR_H
Kerberos Client Authentication nullptr
Definition: auth_kerberos_client_plugin.cc:247
Experimental API header.
Experimental API header.
Experimental API header.
Polymorphism-free memory resource class with custom allocator and deallocator functions.
Definition: memory_resource.h:88
void * allocate(Size_t n) const
Allocate memory using the provided allocator.
Definition: memory_resource.h:113
void deallocate(Ptr_t p) const
Deallocate memory using the provided deallocator.
Definition: memory_resource.h:118
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
Non-growable output buffer wrapper, represented as raw pointers to the beginning and end,...
Definition: out_str.h:618
Out_str_fixed_ptrptr_nz< Char_tp > This_t
Definition: out_str.h:619
Out_str_fixed_ptrptr_nz(Args_t &&...args)
Definition: out_str.h:624
Non-growable output buffer wrapper, represented as raw pointers to the beginning and end,...
Definition: out_str.h:603
Out_str_fixed_ptrptr_z< Char_tp > This_t
Definition: out_str.h:604
Out_str_fixed_ptrptr_z(Args_t &&...args)
Definition: out_str.h:609
Non-growable output buffer wrapper, represented as raw pointer to the beginning, and integer size,...
Definition: out_str.h:648
Out_str_fixed_ptrsize_nz(Args_t &&...args)
Definition: out_str.h:654
Out_str_fixed_ptrsize_nz< Size_tp > This_t
Definition: out_str.h:649
Non-growable output buffer wrapper, represented as raw pointer to the beginning, and integer size,...
Definition: out_str.h:633
Out_str_fixed_ptrsize_z(Args_t &&...args)
Definition: out_str.h:639
Out_str_fixed_ptrsize_z< Size_tp > This_t
Definition: out_str.h:634
Non-growable output buffer wrapper, represented as std::string.
Definition: out_str.h:593
Out_str_fixed_string(String_tp &str)
Definition: out_str.h:595
Growable output buffer wrapper, represented as raw pointers to the beginning and end,...
Definition: out_str.h:713
Out_str_growable_ptrptr_nz(Char_t *&first, Char_t *&last, Char_t *&capacity_end, const mysql::allocators::Memory_resource &memory_resource)
Definition: out_str.h:715
Growable output buffer wrapper, represented as raw pointers to the beginning and end,...
Definition: out_str.h:700
Out_str_growable_ptrptr_z(Char_t *&first, Char_t *&last, Char_t *&capacity_end, const mysql::allocators::Memory_resource &memory_resource)
Definition: out_str.h:702
Growable output buffer wrapper, represented as raw pointer to the beginning, and integer size,...
Definition: out_str.h:687
Out_str_growable_ptrsize_nz(Char_t *&first, Size_tp &size, Size_tp capacity, const mysql::allocators::Memory_resource &memory_resource)
Definition: out_str.h:689
Growable output buffer wrapper, represented as raw pointer to the beginning, and integer size,...
Definition: out_str.h:674
Out_str_growable_ptrsize_z(Char_t *&first, Size_tp &size, Size_tp capacity, const mysql::allocators::Memory_resource &memory_resource)
Definition: out_str.h:676
Growable output buffer wrapper, represented as std::string.
Definition: out_str.h:664
Out_str_growable_string(String_tp &str)
Definition: out_str.h:666
Base class for all Out_str_fixed* classes.
Definition: out_str.h:507
void resize(std::size_t size_arg) const
Assume that the character buffer has at least the given new size, and store the new size.
Definition: out_str.h:525
Policy_fixed(Args_t &&...args)
Construct a new object, forwarding all arguments to the base class.
Definition: out_str.h:518
Policy_fixed< Representation_tp, null_terminated_tp > This_t
Definition: out_str.h:509
static constexpr auto resize_policy
Definition: out_str.h:512
static constexpr auto null_terminated
Definition: out_str.h:513
Base class for all Out_str_growable_ptr* classes.
Definition: out_str.h:443
static constexpr auto resize_policy
Definition: out_str.h:450
Policy_growable_ptr< Char_tp, Representation_tp, null_terminated_tp > This_t
Definition: out_str.h:447
static constexpr size_t null_size
Definition: out_str.h:444
Policy_growable_ptr(Args_t &&...args)
Construct a new object, forwarding all arguments to the base class.
Definition: out_str.h:456
mysql::allocators::Memory_resource get_memory_resource() const
Return the Memory_resource.
Definition: out_str.h:468
static constexpr auto null_terminated
Definition: out_str.h:451
mysql::allocators::Memory_resource m_memory_resource
Definition: out_str.h:496
mysql::utils::Return_status resize(std::size_t size_arg) const
Resize the character buffer and store the new size.
Definition: out_str.h:478
Policy_growable_ptr(mysql::allocators::Memory_resource memory_resource, Args_t &&...args)
Construct a new object with the given Memory_resource, forwarding all remaining arguments to the base...
Definition: out_str.h:462
Base class for Out_str_growable_string.
Definition: out_str.h:415
Policy_growable_string(auto &...args)
Construct a new object, forwarding all arguments to the base class.
Definition: out_str.h:421
mysql::utils::Return_status resize(std::size_t size) const
Resize the std::string object.
Definition: out_str.h:429
static constexpr auto null_terminated
Definition: out_str.h:418
static constexpr auto resize_policy
Definition: out_str.h:417
Common CRTP base class for Representation_ptrptr and Representation_ptrsize.
Definition: out_str.h:297
char * data() const
Return pointer to the data.
Definition: out_str.h:304
std::size_t m_initial_capacity
Initial capacity.
Definition: out_str.h:316
Representation_ptr_base(Ptr_tp first, std::size_t capacity)
Construct a new object wrapping the buffer at the given position.
Definition: out_str.h:300
std::size_t initial_capacity() const
Before resize, return the value of the size field.
Definition: out_str.h:307
Ptr_tp m_first
Pointer to first character.
Definition: out_str.h:313
Represent a string as raw pointer to the beginning and raw pointer to the end.
Definition: out_str.h:329
static constexpr auto representation_type
Definition: out_str.h:333
void store_size(std::size_t size_arg) const
Alter the end pointer.
Definition: out_str.h:355
Representation_ptrptr(Ptr_tp first, Ptr_tp &last, Ptr_tp capacity_end)
Construct a new object from the given pointer to begin and pointer to end of capacity,...
Definition: out_str.h:337
std::size_t size() const
Definition: out_str.h:351
Ptr_tp & m_last
Reference to end pointer.
Definition: out_str.h:360
Represent a string as raw pointer to the beginning, and integer size.
Definition: out_str.h:375
void store_size(std::size_t size_arg) const
Alter the size field.
Definition: out_str.h:394
Size_tp & m_size
Reference to integral size.
Definition: out_str.h:397
std::size_t size() const
After resize, return the value of the size field.
Definition: out_str.h:390
static constexpr auto representation_type
Definition: out_str.h:380
Representation_ptrsize(Ptr_tp first, Size_tp &size_arg, Size_tp capacity)
Construct a new object from the given begin pointer, reference to size, and capacity.
Definition: out_str.h:384
Represent a string as an object, typically std::string.
Definition: out_str.h:257
std::size_t initial_capacity() const
Before resize, return the capacity of the string.
Definition: out_str.h:270
String_tp & m_str
Reference to string storage.
Definition: out_str.h:282
char * data() const
Return a raw pointer to the data.
Definition: out_str.h:265
void store_size(std::size_t size_arg) const
Store the string size.
Definition: out_str.h:279
std::size_t size() const
After resize, return the size of the string.
Definition: out_str.h:275
Representation_string(String_tp &str)
Construct a new object wrapping the given str object.
Definition: out_str.h:262
static constexpr auto representation_type
Definition: out_str.h:259
true if Test, with cvref removed, is char, unsigned char, or std::byte.
Definition: is_charlike.h:51
True if Test is equal to one of Types.
Definition: is_either.h:39
true if Test is pointer to char, unsigned char, or std::byte, and not any array.
Definition: is_charlike.h:58
Definition: is_pointer.h:44
false if Args is exactly one type, say A, and std::decay_t<A> equals Type.
Definition: not_decayed.h:84
True if Test is an Output String Wrapper with Resize_policy fixed.
Definition: out_str.h:235
True if Test is an Output String Wrapper with Resize_policy growable.
Definition: out_str.h:240
True if Test is an Output String Wrapper, i.e., derived from Out_str_base.
Definition: out_str.h:219
Experimental API header.
Experimental API header.
Experimental API header.
Experimental API header.
Class that wraps resources in a polymorphic manner.
std::string str(const mysqlrouter::ConfigGenerator::Options::Endpoint &ep)
Definition: config_generator.cc:1077
Definition: fts0fts.cc:236
bool length(const dd::Spatial_reference_system *srs, const Geometry *g1, double *length, bool *null) noexcept
Computes the length of linestrings and multilinestrings.
Definition: length.cc:76
Definition: gtid_binary_format_conv.h:252
Policy_growable_ptr< Char_t, Representation_ptrsize< Char_t *&, Size_tp >, Null_terminated::no > Out_str_growable_ptrsize_nz_alias
Definition: out_str.h:570
Policy_fixed< Representation_string< String_tp >, Null_terminated::yes > Out_str_fixed_string_alias
Definition: out_str.h:540
Policy_growable_ptr< Char_t, Representation_ptrsize< Char_t *&, Size_tp >, Null_terminated::yes > Out_str_growable_ptrsize_z_alias
Definition: out_str.h:565
Policy_growable_string< Representation_string< String_tp > > Out_str_growable_string_alias
Definition: out_str.h:560
Policy_fixed< Representation_ptrptr< Char_tp * >, Null_terminated::yes > Out_str_fixed_ptrptr_z_alias
Definition: out_str.h:552
Policy_fixed< Representation_ptrsize< char *, Size_tp >, Null_terminated::yes > Out_str_fixed_ptrsize_z_alias
Definition: out_str.h:544
Policy_fixed< Representation_ptrsize< char *, Size_tp >, Null_terminated::no > Out_str_fixed_ptrsize_nz_alias
Definition: out_str.h:548
Policy_growable_ptr< Char_t, Representation_ptrptr< Char_t *& >, Null_terminated::no > Out_str_growable_ptrptr_nz_alias
Definition: out_str.h:580
Policy_growable_ptr< Char_t, Representation_ptrptr< Char_t *& >, Null_terminated::yes > Out_str_growable_ptrptr_z_alias
Definition: out_str.h:575
Policy_fixed< Representation_ptrptr< Char_tp * >, Null_terminated::no > Out_str_fixed_ptrptr_nz_alias
Definition: out_str.h:556
Definition: gtid_binary_format.h:41
Representation_type
Indicates the type of string represention used by an Output String Wrapper.
Definition: out_str.h:206
@ ptrptr
String represented using raw pointer to beginning and raw pointer to end.
@ string
String represented as std::string
@ ptrsize
String represented using raw pointer to beginning and integral size.
auto out_str_fixed_nz(mysql::meta::Is_pointer_to_charlike auto first, Size_t &length, Size_t capacity=0)
Return a wrapper around a non-growable, non-null-terminated output buffer, represented using a raw po...
Definition: out_str.h:818
Resize_policy
Indicates whether an Ouput String Wrapper is growable or fixed-size.
Definition: out_str.h:199
auto out_str_fixed(String_t &str)
Return a wrapper around a non-growable output buffer, represented as a std::string or similar type.
Definition: out_str.h:734
auto out_str_growable_nz(Char_t *&first, Size_t &length, Size_t capacity=0, const mysql::allocators::Memory_resource &memory_resource={})
Return a wrapper around a growable, non-null-terminated output buffer, represented using a reference ...
Definition: out_str.h:1082
auto out_str_growable_z(Char_t *&first, Size_t &length, Size_t capacity=0, const mysql::allocators::Memory_resource &memory_resource={})
Return a wrapper around a growable, null-terminated output buffer, represented using a reference to a...
Definition: out_str.h:1016
auto out_str_fixed_z(mysql::meta::Is_pointer_to_charlike auto first, Size_t &length, Size_t capacity=0)
Return a wrapper around a non-growable, null-terminated output buffer, represented using a raw pointe...
Definition: out_str.h:760
Null_terminated
Indicates whether an Output String Wrapper requires that the string shall be null-terminated or not.
Definition: out_str.h:203
auto out_str_growable(String_t &str)
Return a wrapper around a growable output buffer, represented as a std::string or similar type.
Definition: out_str.h:985
Return_status
Simple, strongly-typed enumeration to indicate internal status: ok, error.
Definition: return_status.h:40
@ ok
operation succeeded
@ error
operation failed
Char_t & char_cast(mysql::meta::Is_charlike auto &ref)
Definition: char_cast.h:41
size_t size(const char *const c)
Definition: base64.h:46
Define std::hash<Gtid>.
Definition: gtid.h:355
Experimental API header.
Experimental API header.