MySQL 9.0.0
Source Code Documentation
StringBuffer< buff_sz > Class Template Reference

String class wrapper with a preallocated buffer of size buff_sz. More...

#include <sql_string.h>

Inheritance diagram for StringBuffer< buff_sz >:
[legend]

Public Member Functions

 StringBuffer ()
 
 StringBuffer (const CHARSET_INFO *cs)
 
 StringBuffer (const char *str, size_t length, const CHARSET_INFO *cs)
 
- Public Member Functions inherited from String
 String ()
 
 String (size_t length_arg)
 
 String (const char *str, const CHARSET_INFO *cs)
 
 String (const char *str, size_t len, const CHARSET_INFO *cs)
 
 String (char *str, size_t len, const CHARSET_INFO *cs)
 
 String (const String &str)
 
 String (String &&str) noexcept
 
 ~String ()
 
void set_charset (const CHARSET_INFO *charset_arg)
 
const CHARSET_INFOcharset () const
 
size_t length () const
 
size_t alloced_length () const
 
const char & operator[] (size_t i) const
 
char & operator[] (size_t i)
 
void length (size_t len)
 
bool is_empty () const
 
void mark_as_const ()
 
const char * ptr () const
 
char * ptr ()
 
char * c_ptr ()
 
char * c_ptr_quick ()
 
char * c_ptr_safe ()
 Returns a pointer to a C-style null-terminated string. More...
 
LEX_STRING lex_string ()
 
LEX_CSTRING lex_cstring () const
 
void set (String &str, size_t offset, size_t arg_length)
 
void set (char *str, size_t arg_length, const CHARSET_INFO *cs)
 Points the internal buffer to the supplied one. More...
 
void set (const char *str, size_t arg_length, const CHARSET_INFO *cs)
 
bool set_ascii (const char *str, size_t arg_length)
 
void set_quick (char *str, size_t arg_length, const CHARSET_INFO *cs)
 
bool set_int (longlong num, bool unsigned_flag, const CHARSET_INFO *cs)
 
bool set (longlong num, const CHARSET_INFO *cs)
 
bool set (ulonglong num, const CHARSET_INFO *cs)
 
bool set_real (double num, uint decimals, const CHARSET_INFO *cs)
 Sets the contents of this string to the string representation of the given double value. More...
 
void chop ()
 
void mem_claim (bool claim)
 
void mem_free ()
 
bool alloc (size_t arg_length)
 
bool real_alloc (size_t arg_length)
 
bool mem_realloc (size_t arg_length, bool force_on_heap=false)
 Allocates a new buffer on the heap for this String. More...
 
void shrink (size_t arg_length)
 
bool is_alloced () const
 
Stringoperator= (const String &s)
 
Stringoperator= (String &&s) noexcept
 
void takeover (String &s)
 Takeover the buffer owned by another string. More...
 
bool copy ()
 
bool copy (const String &s)
 Copies the internal buffer from str. More...
 
bool copy (const char *s, size_t arg_length, const CHARSET_INFO *cs)
 
bool copy (const char *s, size_t arg_length, const CHARSET_INFO *from_cs, const CHARSET_INFO *to_cs, uint *errors)
 Copies the character data into this String, with optional character set conversion. More...
 
bool needs_conversion (const CHARSET_INFO *cs_to) const
 
bool is_valid_string (const CHARSET_INFO *cs_to) const
 
bool copy_aligned (const char *s, size_t arg_length, size_t offset, const CHARSET_INFO *cs)
 
bool set_or_copy_aligned (const char *s, size_t arg_length, const CHARSET_INFO *cs)
 
bool append (const String &s)
 
bool append (std::string_view s)
 
bool append (LEX_STRING *ls)
 
bool append (Simple_cstring str)
 
bool append (const char *s, size_t arg_length)
 
bool append (const char *s, size_t arg_length, const CHARSET_INFO *cs)
 
bool append_ulonglong (ulonglong val)
 Append an unsigned longlong to the string. More...
 
bool append_longlong (longlong val)
 Append a signed longlong to the string. More...
 
bool append_with_prefill (const char *s, size_t arg_length, size_t full_length, char fill_char)
 
bool append_parenthesized (int64_t nr)
 Append a parenthesized number to String. More...
 
int strstr (const String &search, size_t offset=0) const
 Search for a substring. More...
 
int strrstr (const String &search, size_t offset=0) const
 Reverse search for a substring. More...
 
String substr (int offset, int count) const
 Returns substring of given characters length, starting at given character offset. More...
 
bool replace (size_t offset, size_t arg_length, const char *to, size_t length)
 
bool replace (size_t offset, size_t arg_length, const String &to)
 
bool append (char chr)
 
bool fill (size_t max_length, char fill)
 
size_t numchars () const
 
size_t charpos (size_t i, size_t offset=0) const
 
bool reserve (size_t space_needed)
 
bool reserve (size_t space_needed, size_t grow_by)
 
char * prep_append (size_t arg_length, size_t step_alloc)
 
bool append (const char *s, size_t arg_length, size_t step_alloc)
 
void print (String *print) const
 
void swap (String &s) noexcept
 
bool uses_buffer_owned_by (const String *s) const
 
bool is_ascii () const
 
char * dup (MEM_ROOT *root) const
 Make a zero-terminated copy of our value,allocated in the specified MEM_ROOT. More...
 

Private Attributes

char buff [buff_sz]
 

Additional Inherited Members

- Static Public Member Functions inherited from String
static void * operator new (size_t size, MEM_ROOT *mem_root, const std::nothrow_t &arg=std::nothrow) noexcept
 
static void operator delete (void *ptr_arg, size_t size)
 
static void operator delete (void *, MEM_ROOT *, const std::nothrow_t &) noexcept
 
static bool needs_conversion (size_t arg_length, const CHARSET_INFO *cs_from, const CHARSET_INFO *cs_to, size_t *offset)
 Checks that the source string can be just copied to the destination string without conversion. More...
 
static bool needs_conversion_on_storage (size_t arg_length, const CHARSET_INFO *cs_from, const CHARSET_INFO *cs_to)
 

Detailed Description

template<size_t buff_sz>
class StringBuffer< buff_sz >

String class wrapper with a preallocated buffer of size buff_sz.

This class allows to replace sequences of: char buff[12345]; String str(buff, sizeof(buff)); str.length(0); with a simple equivalent declaration: StringBuffer<12345> str;

Constructor & Destructor Documentation

◆ StringBuffer() [1/3]

template<size_t buff_sz>
StringBuffer< buff_sz >::StringBuffer ( )
inline

◆ StringBuffer() [2/3]

template<size_t buff_sz>
StringBuffer< buff_sz >::StringBuffer ( const CHARSET_INFO cs)
inlineexplicit

◆ StringBuffer() [3/3]

template<size_t buff_sz>
StringBuffer< buff_sz >::StringBuffer ( const char *  str,
size_t  length,
const CHARSET_INFO cs 
)
inline

Member Data Documentation

◆ buff

template<size_t buff_sz>
char StringBuffer< buff_sz >::buff[buff_sz]
private

The documentation for this class was generated from the following file: