![]() |
MySQL 9.3.0
Source Code Documentation
|
#include <utils_sqlstring.h>
Classes | |
class | CustomContainerIterator |
Iterator wrapper, for serializing arrays of structures to string. More... | |
struct | sqlstringformat |
Public Member Functions | |
sqlstring () | |
sqlstring (const char *format_string, const sqlstringformat format=0) | |
sqlstring (const sqlstring ©) | |
sqlstring & | operator= (const sqlstring &)=default |
bool | done () const |
void | reset (const char *format_string, const sqlstringformat format=0) |
operator std::string () const | |
std::string | str () const |
bool | is_empty () const |
bool | operator== (const sqlstring &other) const |
sqlstring & | operator<< (const sqlstringformat) |
modifies formatting options More... | |
sqlstring & | operator<< (const float val) |
replaces a ? in the format string with a float numeric value More... | |
sqlstring & | operator<< (const double) |
replaces a ? in the format string with a double numeric value More... | |
sqlstring & | operator<< (const std::nullptr_t) |
replaces a ? in the format string with a NULL value. More... | |
sqlstring & | operator<< (const std::string &) |
replaces a ? in the format string with a quoted string value or ! with a back-quoted identifier value More... | |
sqlstring & | operator<< (const char *) |
replaces a ? in the format string with a quoted string value or ! with a back-quoted identifier value is the value is NULL, ? will be replaced with a NULL. More... | |
sqlstring & | operator<< (const sqlstring &) |
replaces a ? or ! with the content of the other string verbatim More... | |
sqlstring & | operator<< (const std::vector< uint8_t > &v) |
replaces a ? with an array of bytes More... | |
sqlstring & | append_preformatted (const sqlstring &s) |
appends a pre-formatted sqlstring to a pre-formatted sqlstring More... | |
sqlstring & | append_preformatted_sep (const std::string &separator, const sqlstring &s) |
template<typename T > | |
sqlstring & | operator<< (const std::pair< T, T > &iterators) |
Replace ? or ! with multiple values. More... | |
template<typename T > | |
sqlstring & | operator<< (const std::vector< T > &values) |
template<typename T > | |
sqlstring & | operator<< (const std::set< T > &values) |
template<typename T > | |
sqlstring & | operator<< (const T value) |
replaces a ? in the format string with any integer numeric value More... | |
Static Public Attributes | |
static const sqlstring | empty {""} |
static const sqlstring | null |
static const sqlstring | end |
Private Member Functions | |
std::string | consume_until_next_escape () |
int | next_escape () |
void | lock_escape (int esc) |
void | unlock_escape () |
sqlstring & | append (const std::string &s) |
sqlstring & | format (int esc, const char *v, int length) |
Private Attributes | |
std::string | _formatted |
std::string | _format_string_left |
sqlstringformat | _format |
int | _locked_escape {0} |
mysqlrouter::sqlstring::sqlstring | ( | ) |
mysqlrouter::sqlstring::sqlstring | ( | const char * | format_string, |
const sqlstringformat | format = 0 |
||
) |
|
default |
|
private |
appends a pre-formatted sqlstring to a pre-formatted sqlstring
sqlstring & mysqlrouter::sqlstring::append_preformatted_sep | ( | const std::string & | separator, |
const sqlstring & | s | ||
) |
|
private |
bool mysqlrouter::sqlstring::done | ( | ) | const |
|
inlineprivate |
bool mysqlrouter::sqlstring::is_empty | ( | ) | const |
|
private |
|
private |
mysqlrouter::sqlstring::operator std::string | ( | ) | const |
sqlstring & mysqlrouter::sqlstring::operator<< | ( | const char * | v | ) |
replaces a ? in the format string with a quoted string value or ! with a back-quoted identifier value is the value is NULL, ? will be replaced with a NULL.
! will raise an exception
sqlstring & mysqlrouter::sqlstring::operator<< | ( | const double | v | ) |
replaces a ? in the format string with a double numeric value
|
inline |
replaces a ? in the format string with a float numeric value
replaces a ? or ! with the content of the other string verbatim
sqlstring & mysqlrouter::sqlstring::operator<< | ( | const sqlstringformat | format | ) |
modifies formatting options
sqlstring & mysqlrouter::sqlstring::operator<< | ( | const std::nullptr_t | ) |
replaces a ? in the format string with a NULL value.
|
inline |
Replace ?
or !
with multiple values.
Each element of the container, is going to be applied to parameter type fetched at the start (either ?
or !
). Each iteam is going to be separated by comma.
Example 1:
sqlstring s{"First=(?) Second=(!)"}; s << std::vector<std::string>{"1","2","3"} << "a";
The resulting query: First=("1","2","3") Second=(A)
Example 2:
sqlstring s{"First=(!) Second=(?)"}; s << std::vector<std::string>{"1","2","3"} << "a";
The resulting query: First=(1,2,3) Second=("A")
|
inline |
sqlstring & mysqlrouter::sqlstring::operator<< | ( | const std::string & | v | ) |
replaces a ? in the format string with a quoted string value or ! with a back-quoted identifier value
|
inline |
sqlstring & mysqlrouter::sqlstring::operator<< | ( | const std::vector< uint8_t > & | v | ) |
replaces a ? with an array of bytes
replaces a ? in the format string with any integer numeric value
Import to_string
function which enables serialization to string, for standard types.
User can define to_string
function for serialization of custom type. Both the function and the type must be located in the same namespace
. Following this schema enables argument-dependent-lookup/ADL
in stream operator of sqlstring
(which uses the to_string
).
|
inline |
void mysqlrouter::sqlstring::reset | ( | const char * | format_string, |
const sqlstringformat | format = 0 |
||
) |
std::string mysqlrouter::sqlstring::str | ( | ) | const |
|
private |
|
private |
|
private |
|
private |
|
private |
|
static |
|
static |
|
static |