MySQL 9.6.0
Source Code Documentation
mysql::strconv::String_writer Class Reference

Class that serves as the target for encode(..., Is_string_target), which writes to a char * buffer without bounds checking. More...

#include <string_writer.h>

Inheritance diagram for mysql::strconv::String_writer:
[legend]

Public Member Functions

 String_writer (const String_writer &)=delete
 
 String_writer (String_writer &&) noexcept=default
 
String_writeroperator= (const String_writer &)=delete
 
String_writeroperator= (String_writer &&) noexcept=default
 
 ~String_writer ()=default
 
void write_raw (const std::string_view &sv)
 Append a string_view to the buffer, unformatted. More...
 
void write_char (int ch)
 Append a single character to the buffer. More...
 
void write (const Is_format auto &format, const auto &object)
 Write the given object to this String_writer. More...
 
void write (const Is_format auto &format, const std::string_view &sv)
 Write the given string_view to this String_writer. More...
 
void advance (std::size_t size)
 Move the position size bytes forward without writing anything. More...
 
char * pos ()
 Return the current write position as a char *. More...
 
const char * pos () const
 Return the current write position as a const char *. More...
 
unsigned char * upos ()
 Return the current write position as an unsigned char *. More...
 
const unsigned char * upos () const
 Return the current write position as a const unsigned char *. More...
 
std::bytebpos ()
 Return the current write position as a std::byte *. More...
 
const std::bytebpos () const
 Return the current write position as a const std::byte *. More...
 
char * end ()
 Return the buffer end as a char *. More...
 
const char * end () const
 Return the buffer end as a const char *. More...
 
unsigned char * uend ()
 Return the buffer end as an unsigned char *. More...
 
const unsigned char * uend () const
 Return the buffer end as a const unsigned char *. More...
 
std::bytebend ()
 Return the buffer end as a std::byte *. More...
 
const std::bytebend () const
 Return the buffer end as a const std::byte *. More...
 
std::size_t remaining_size () const
 
- Public Member Functions inherited from mysql::strconv::detail::String_target_interface< String_writer >
void concat (const Is_format auto &format, const Args_t &...args)
 Depending on the subclass, write or compute the size of multiple objects to this String_target. More...
 

Static Public Attributes

static constexpr Target_type target_type = Target_type::writer
 

Protected Member Functions

 String_writer (char *first, char *last)
 Construct a new object backed by the given buffer. More...
 
- Protected Member Functions inherited from mysql::strconv::detail::String_target_interface< String_writer >
void resolve_format_and_write (const Is_format auto &format, const Object_t &object)
 Resolve the format, using the rules to deduce format based on default format and parent format, and write the given object using the resolved format. More...
 

Private Attributes

char * m_pos
 The current write position. More...
 
char * m_end
 End of buffer. More...
 

Detailed Description

Class that serves as the target for encode(..., Is_string_target), which writes to a char * buffer without bounds checking.

Constructor & Destructor Documentation

◆ String_writer() [1/3]

mysql::strconv::String_writer::String_writer ( char *  first,
char *  last 
)
inlineprotected

Construct a new object backed by the given buffer.

The caller must ensure that the buffer has space for everything that will be written to it.

This is hidden from user code. These objects are only meant to be created internally by the framework.

Parameters
firstPointer to the first character of the output buffer.
lastPointer to the one-past-last character of the output buffer.

◆ String_writer() [2/3]

mysql::strconv::String_writer::String_writer ( const String_writer )
delete

◆ String_writer() [3/3]

mysql::strconv::String_writer::String_writer ( String_writer &&  )
defaultnoexcept

◆ ~String_writer()

mysql::strconv::String_writer::~String_writer ( )
default

Member Function Documentation

◆ advance()

void mysql::strconv::String_writer::advance ( std::size_t  size)
inline

Move the position size bytes forward without writing anything.

Note
The characters are left uninitialized. The caller must initialize them.

◆ bend() [1/2]

std::byte * mysql::strconv::String_writer::bend ( )
inline

Return the buffer end as a std::byte *.

◆ bend() [2/2]

const std::byte * mysql::strconv::String_writer::bend ( ) const
inline

Return the buffer end as a const std::byte *.

◆ bpos() [1/2]

std::byte * mysql::strconv::String_writer::bpos ( )
inline

Return the current write position as a std::byte *.

◆ bpos() [2/2]

const std::byte * mysql::strconv::String_writer::bpos ( ) const
inline

Return the current write position as a const std::byte *.

◆ end() [1/2]

char * mysql::strconv::String_writer::end ( )
inline

Return the buffer end as a char *.

◆ end() [2/2]

const char * mysql::strconv::String_writer::end ( ) const
inline

Return the buffer end as a const char *.

◆ operator=() [1/2]

String_writer & mysql::strconv::String_writer::operator= ( const String_writer )
delete

◆ operator=() [2/2]

String_writer & mysql::strconv::String_writer::operator= ( String_writer &&  )
defaultnoexcept

◆ pos() [1/2]

char * mysql::strconv::String_writer::pos ( )
inline

Return the current write position as a char *.

◆ pos() [2/2]

const char * mysql::strconv::String_writer::pos ( ) const
inline

Return the current write position as a const char *.

◆ remaining_size()

std::size_t mysql::strconv::String_writer::remaining_size ( ) const
inline

◆ uend() [1/2]

unsigned char * mysql::strconv::String_writer::uend ( )
inline

Return the buffer end as an unsigned char *.

◆ uend() [2/2]

const unsigned char * mysql::strconv::String_writer::uend ( ) const
inline

Return the buffer end as a const unsigned char *.

◆ upos() [1/2]

unsigned char * mysql::strconv::String_writer::upos ( )
inline

Return the current write position as an unsigned char *.

◆ upos() [2/2]

const unsigned char * mysql::strconv::String_writer::upos ( ) const
inline

Return the current write position as a const unsigned char *.

◆ write() [1/2]

void mysql::strconv::String_writer::write ( const Is_format auto &  format,
const auto &  object 
)
inline

Write the given object to this String_writer.

◆ write() [2/2]

void mysql::strconv::String_writer::write ( const Is_format auto &  format,
const std::string_view &  sv 
)
inline

Write the given string_view to this String_writer.

◆ write_char()

void mysql::strconv::String_writer::write_char ( int  ch)
inline

Append a single character to the buffer.

Parameters
chCharacter to write.

◆ write_raw()

void mysql::strconv::String_writer::write_raw ( const std::string_view &  sv)
inline

Append a string_view to the buffer, unformatted.

Parameters
svString to write.

Member Data Documentation

◆ m_end

char* mysql::strconv::String_writer::m_end
private

End of buffer.

◆ m_pos

char* mysql::strconv::String_writer::m_pos
private

The current write position.

◆ target_type

constexpr Target_type mysql::strconv::String_writer::target_type = Target_type::writer
staticconstexpr

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