MySQL++  3.3.0
Public Types | Public Member Functions | List of all members
mysqlpp::SQLBuffer Class Reference

Holds SQL data in string form plus type information for use in converting the string to compatible C++ data types. More...

#include <sql_buffer.h>

Public Types

typedef size_t size_type
 Type of length values.
 

Public Member Functions

 SQLBuffer (const char *data, size_type length, mysql_type_info type, bool is_null)
 Initialize object as a copy of a raw data buffer. More...
 
 SQLBuffer (const std::string &s, mysql_type_info type, bool is_null)
 Initialize object as a copy of a C++ string object.
 
 ~SQLBuffer ()
 Destructor.
 
SQLBufferassign (const char *data, size_type length, mysql_type_info type=mysql_type_info::string_type, bool is_null=false)
 Replace contents of buffer with copy of given C string.
 
SQLBufferassign (const std::string &s, mysql_type_info type=mysql_type_info::string_type, bool is_null=false)
 Replace contents of buffer with copy of given C++ string.
 
const char * data () const
 Return pointer to raw data buffer.
 
bool escape_q () const
 Returns true if we were initialized with a data type that must be escaped when used in a SQL query.
 
size_type length () const
 Return number of bytes in data buffer. More...
 
bool is_string ()
 Returns true if type of buffer's contents is string.
 
bool is_null () const
 Return true if buffer's contents represent a SQL null. More...
 
bool quote_q () const
 Returns true if we were initialized with a data type that must be quoted when used in a SQL query.
 
void set_null ()
 Sets the internal SQL null flag.
 
const mysql_type_infotype () const
 Return the SQL type of the data held in the buffer.
 

Detailed Description

Holds SQL data in string form plus type information for use in converting the string to compatible C++ data types.

Constructor & Destructor Documentation

◆ SQLBuffer()

mysqlpp::SQLBuffer::SQLBuffer ( const char *  data,
size_type  length,
mysql_type_info  type,
bool  is_null 
)
inline

Initialize object as a copy of a raw data buffer.

Copies the string into a new buffer one byte longer than the length value given, using that to hold a C string null terminator, just for safety. The length value we keep does not include this extra byte, allowing this same mechanism to work for both C strings and binary data.

References data(), and length().

Member Function Documentation

◆ is_null()

bool mysqlpp::SQLBuffer::is_null ( ) const
inline

Return true if buffer's contents represent a SQL null.

The buffer's actual content will probably be "NULL" or something like it, but in the SQL data type system, a SQL null is distinct from a plain string with value "NULL".

Referenced by assign(), and mysqlpp::String::is_null().

◆ length()

size_type mysqlpp::SQLBuffer::length ( ) const
inline

Return number of bytes in data buffer.

Count does not include the trailing null we tack on to our copy of the buffer for ease of use in C string contexts. We do this because we can be holding binary data just as easily as a C string.

Referenced by assign(), mysqlpp::String::end(), mysqlpp::String::length(), mysqlpp::SQLTypeAdapter::length(), SQLBuffer(), and mysqlpp::String::to_string().


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