#include <row.h>
Inheritance diagram for mysqlpp::Row:
Public Member Functions | |
Row () | |
Default constructor. | |
Row (const MYSQL_ROW &d, const ResUse *r, unsigned long *jj, bool te=true) | |
Create a row object. | |
~Row () | |
Destroy object. | |
const ResUse & | parent () const |
Get a reference to our parent class. | |
size_type | size () const |
Get the number of fields in the row. | |
const ColData | operator[] (const char *field) const |
Get the value of a field given its name. | |
const ColData | operator[] (size_type i) const |
Get the value of a field given its index. | |
const ColData | at (size_type i) const |
Get the value of a field given its index. | |
const char * | raw_data (int i) const |
Return the value of a field as a C string given its index, in raw form. | |
const std::string & | raw_string (int i) const |
Return the value of a field as a C++ string given its index, in raw form. | |
operator bool () const | |
Returns true if there is data in the row. | |
template<class Manip> | |
value_list_ba< Row, Manip > | value_list (const char *d=",", Manip m=quote) const |
Get a list of the values in this row. | |
template<class Manip> | |
value_list_b< Row, Manip > | value_list (const char *d, const std::vector< bool > &vb, Manip m=quote) const |
Get a list of the values in this row. | |
value_list_b< Row, quote_type0 > | value_list (const std::vector< bool > &vb) const |
Get a list of the values in this row. | |
template<class Manip> | |
value_list_b< Row, Manip > | value_list (const char *d, Manip m, bool t0, bool t1=false, bool t2=false, bool t3=false, bool t4=false, bool t5=false, bool t6=false, bool t7=false, bool t8=false, bool t9=false, bool ta=false, bool tb=false, bool tc=false) const |
Get a list of the values in this row. | |
value_list_b< Row, quote_type0 > | value_list (const char *d, bool t0, bool t1=false, bool t2=false, bool t3=false, bool t4=false, bool t5=false, bool t6=false, bool t7=false, bool t8=false, bool t9=false, bool ta=false, bool tb=false, bool tc=false) const |
Get a list of the values in this row. | |
value_list_b< Row, quote_type0 > | value_list (bool t0, bool t1=false, bool t2=false, bool t3=false, bool t4=false, bool t5=false, bool t6=false, bool t7=false, bool t8=false, bool t9=false, bool ta=false, bool tb=false, bool tc=false) const |
Get a list of the values in this row. | |
template<class Manip> | |
value_list_b< Row, Manip > | value_list (const char *d, Manip m, std::string s0, std::string s1="", std::string s2="", std::string s3="", std::string s4="", std::string s5="", std::string s6="", std::string s7="", std::string s8="", std::string s9="", std::string sa="", std::string sb="", std::string sc="") const |
Get a list of the values in this row. | |
value_list_b< Row, quote_type0 > | value_list (const char *d, std::string s0, std::string s1="", std::string s2="", std::string s3="", std::string s4="", std::string s5="", std::string s6="", std::string s7="", std::string s8="", std::string s9="", std::string sa="", std::string sb="", std::string sc="") const |
Get a list of the values in this row. | |
value_list_b< Row, quote_type0 > | value_list (std::string s0, std::string s1="", std::string s2="", std::string s3="", std::string s4="", std::string s5="", std::string s6="", std::string s7="", std::string s8="", std::string s9="", std::string sa="", std::string sb="", std::string sc="") const |
Get a list of the values in this row. | |
value_list_ba< FieldNames, do_nothing_type0 > | field_list (const char *d=",") const |
Get a list of the field names in this row. | |
template<class Manip> | |
value_list_ba< FieldNames, Manip > | field_list (const char *d, Manip m) const |
Get a list of the field names in this row. | |
template<class Manip> | |
value_list_b< FieldNames, Manip > | field_list (const char *d, Manip m, const std::vector< bool > &vb) const |
Get a list of the field names in this row. | |
value_list_b< FieldNames, quote_type0 > | field_list (const char *d, const std::vector< bool > &vb) const |
Get a list of the field names in this row. | |
value_list_b< FieldNames, quote_type0 > | field_list (const std::vector< bool > &vb) const |
Get a list of the field names in this row. | |
template<class Manip> | |
value_list_b< FieldNames, Manip > | field_list (const char *d, Manip m, bool t0, bool t1=false, bool t2=false, bool t3=false, bool t4=false, bool t5=false, bool t6=false, bool t7=false, bool t8=false, bool t9=false, bool ta=false, bool tb=false, bool tc=false) const |
Get a list of the field names in this row. | |
value_list_b< FieldNames, quote_type0 > | field_list (const char *d, bool t0, bool t1=false, bool t2=false, bool t3=false, bool t4=false, bool t5=false, bool t6=false, bool t7=false, bool t8=false, bool t9=false, bool ta=false, bool tb=false, bool tc=false) const |
Get a list of the field names in this row. | |
value_list_b< FieldNames, quote_type0 > | field_list (bool t0, bool t1=false, bool t2=false, bool t3=false, bool t4=false, bool t5=false, bool t6=false, bool t7=false, bool t8=false, bool t9=false, bool ta=false, bool tb=false, bool tc=false) const |
Get a list of the field names in this row. | |
equal_list_ba< FieldNames, Row, quote_type0 > | equal_list (const char *d=",", const char *e=" = ") const |
Get an "equal list" of the fields and values in this row. | |
template<class Manip> | |
equal_list_ba< FieldNames, Row, Manip > | equal_list (const char *d, const char *e, Manip m) const |
Get an "equal list" of the fields and values in this row. |
mysqlpp::Row::Row | ( | const MYSQL_ROW & | d, | |
const ResUse * | r, | |||
unsigned long * | jj, | |||
bool | te = true | |||
) |
Create a row object.
d | MySQL C API row data | |
r | result set that the row comes from | |
jj | length of each item in d | |
te | if true, throw exceptions on errors |
const ColData mysqlpp::Row::operator[] | ( | const char * | field | ) | const |
Get the value of a field given its name.
If the field does not exist in this row, we throw a BadFieldName exception.
For this operator to work, the Result or ResUse object that created this object must still exist. In other words, you cannot re-use or destroy the result object until you are done retrieving data from this row object.
Note that we return the ColData object by value. The purpose of ColData is to make it easy to convert the string data returned by the MySQL server to some more appropriate type, so you're almost certain to use this operator in a construct like this:
string s = row["myfield"];
That accesses myfield within the row, returns a temporary ColData object, which is then automatically converted to a std::string
and copied into s
. That works fine, but beware of this similar but incorrect construct:
const char* pc = row["myfield"];
This one line of code does what you expect, but pc
is then a dangling pointer: it points to memory owned by the temporary ColData object, which will have been destroyed by the time you get around to actually using the pointer.
This function is rather inefficient. If that is a concern for you, use at(), operator[](size_type) or the SSQLS mechanism' instead.
Get the value of a field given its index.
This function is just syntactic sugar, wrapping the at() method. The at() method is the only way to get at the first field in a result set by index, as row
[0] is ambiguous: it could call either operator[]
overload.
Get the value of a field given its index.
If the index value is bad, the underlying std::vector is supposed to throw an exception, according to the Standard.
For this function to work, the Result or ResUse object that created this object must still exist. In other words, you cannot re-use or destroy the result object until you are done retrieving data from this row object.
See operator[](const char*) for more caveats.
const char* mysqlpp::Row::raw_data | ( | int | i | ) | const [inline] |
Return the value of a field as a C string given its index, in raw form.
This is the same thing as operator[], except that the data isn't converted to a ColData object first. Also, this method does not check for out-of-bounds array indices.
const std::string& mysqlpp::Row::raw_string | ( | int | i | ) | const [inline] |
Return the value of a field as a C++ string given its index, in raw form.
This is the same thing as operator[], except that the data isn't converted to a ColData object first.
value_list_ba<Row, Manip> mysqlpp::Row::value_list | ( | const char * | d = "," , |
|
Manip | m = quote | |||
) | const [inline] |
Get a list of the values in this row.
When inserted into a C++ stream, the delimiter 'd' will be used between the items, and the quoting and escaping rules will be set by the manipulator 'm' you choose.
d | delimiter to use between values | |
m | manipulator to use when inserting values into a stream |
value_list_b<Row, Manip> mysqlpp::Row::value_list | ( | const char * | d, | |
const std::vector< bool > & | vb, | |||
Manip | m = quote | |||
) | const [inline] |
Get a list of the values in this row.
d | delimiter to use between values | |
vb | for each true item in this list, add that value to the returned list; ignore the others | |
m | manipulator to use when inserting values into a stream |
value_list_b<Row, quote_type0> mysqlpp::Row::value_list | ( | const std::vector< bool > & | vb | ) | const [inline] |
Get a list of the values in this row.
vb | for each true item in this list, add that value to the returned list; ignore the others |
value_list_b<Row, Manip> mysqlpp::Row::value_list | ( | const char * | d, | |
Manip | m, | |||
bool | t0, | |||
bool | t1 = false , |
|||
bool | t2 = false , |
|||
bool | t3 = false , |
|||
bool | t4 = false , |
|||
bool | t5 = false , |
|||
bool | t6 = false , |
|||
bool | t7 = false , |
|||
bool | t8 = false , |
|||
bool | t9 = false , |
|||
bool | ta = false , |
|||
bool | tb = false , |
|||
bool | tc = false | |||
) | const [inline] |
Get a list of the values in this row.
For each true parameter, the value in that position within the row is added to the returned list. When the list is inserted into a C++ stream, the delimiter 'd' will be placed between the items, and the manipulator 'm' used before each item.
value_list_b<Row, quote_type0> mysqlpp::Row::value_list | ( | const char * | d, | |
bool | t0, | |||
bool | t1 = false , |
|||
bool | t2 = false , |
|||
bool | t3 = false , |
|||
bool | t4 = false , |
|||
bool | t5 = false , |
|||
bool | t6 = false , |
|||
bool | t7 = false , |
|||
bool | t8 = false , |
|||
bool | t9 = false , |
|||
bool | ta = false , |
|||
bool | tb = false , |
|||
bool | tc = false | |||
) | const [inline] |
Get a list of the values in this row.
For each true parameter, the value in that position within the row is added to the returned list. When the list is inserted into a C++ stream, the delimiter 'd' will be placed between the items, and items will be quoted and escaped.
value_list_b<Row, quote_type0> mysqlpp::Row::value_list | ( | bool | t0, | |
bool | t1 = false , |
|||
bool | t2 = false , |
|||
bool | t3 = false , |
|||
bool | t4 = false , |
|||
bool | t5 = false , |
|||
bool | t6 = false , |
|||
bool | t7 = false , |
|||
bool | t8 = false , |
|||
bool | t9 = false , |
|||
bool | ta = false , |
|||
bool | tb = false , |
|||
bool | tc = false | |||
) | const [inline] |
Get a list of the values in this row.
For each true parameter, the value in that position within the row is added to the returned list. When the list is inserted into a C++ stream, the a comma will be placed between the items, as a delimiter, and items will be quoted and escaped.
value_list_b<Row, Manip> mysqlpp::Row::value_list | ( | const char * | d, | |
Manip | m, | |||
std::string | s0, | |||
std::string | s1 = "" , |
|||
std::string | s2 = "" , |
|||
std::string | s3 = "" , |
|||
std::string | s4 = "" , |
|||
std::string | s5 = "" , |
|||
std::string | s6 = "" , |
|||
std::string | s7 = "" , |
|||
std::string | s8 = "" , |
|||
std::string | s9 = "" , |
|||
std::string | sa = "" , |
|||
std::string | sb = "" , |
|||
std::string | sc = "" | |||
) | const [inline] |
Get a list of the values in this row.
The 's' parameters name the fields that will be added to the returned list. When inserted into a C++ stream, the delimiter 'd' will be placed between the items, and the manipulator 'm' will be inserted before each item.
value_list_b<Row, quote_type0> mysqlpp::Row::value_list | ( | const char * | d, | |
std::string | s0, | |||
std::string | s1 = "" , |
|||
std::string | s2 = "" , |
|||
std::string | s3 = "" , |
|||
std::string | s4 = "" , |
|||
std::string | s5 = "" , |
|||
std::string | s6 = "" , |
|||
std::string | s7 = "" , |
|||
std::string | s8 = "" , |
|||
std::string | s9 = "" , |
|||
std::string | sa = "" , |
|||
std::string | sb = "" , |
|||
std::string | sc = "" | |||
) | const [inline] |
Get a list of the values in this row.
The 's' parameters name the fields that will be added to the returned list. When inserted into a C++ stream, the delimiter 'd' will be placed between the items, and items will be quoted and escaped.
value_list_b<Row, quote_type0> mysqlpp::Row::value_list | ( | std::string | s0, | |
std::string | s1 = "" , |
|||
std::string | s2 = "" , |
|||
std::string | s3 = "" , |
|||
std::string | s4 = "" , |
|||
std::string | s5 = "" , |
|||
std::string | s6 = "" , |
|||
std::string | s7 = "" , |
|||
std::string | s8 = "" , |
|||
std::string | s9 = "" , |
|||
std::string | sa = "" , |
|||
std::string | sb = "" , |
|||
std::string | sc = "" | |||
) | const [inline] |
Get a list of the values in this row.
The 's' parameters name the fields that will be added to the returned list. When inserted into a C++ stream, a comma will be placed between the items as a delimiter, and items will be quoted and escaped.
value_list_ba< FieldNames, do_nothing_type0 > mysqlpp::Row::field_list | ( | const char * | d = "," |
) | const |
Get a list of the field names in this row.
When inserted into a C++ stream, the delimiter 'd' will be used between the items, and no manipulator will be used on the items.
value_list_ba< FieldNames, Manip > mysqlpp::Row::field_list | ( | const char * | d, | |
Manip | m | |||
) | const [inline] |
Get a list of the field names in this row.
d | delimiter to place between the items when the list is inserted into a C++ stream | |
m | manipulator to use before each item when the list is inserted into a C++ stream |
value_list_b< FieldNames, Manip > mysqlpp::Row::field_list | ( | const char * | d, | |
Manip | m, | |||
const std::vector< bool > & | vb | |||
) | const [inline] |
Get a list of the field names in this row.
d | delimiter to place between the items when the list is inserted into a C++ stream | |
m | manipulator to use before each item when the list is inserted into a C++ stream | |
vb | for each true item in this list, add that field name to the returned list; ignore the others |
value_list_b< FieldNames, quote_type0 > mysqlpp::Row::field_list | ( | const char * | d, | |
const std::vector< bool > & | vb | |||
) | const |
Get a list of the field names in this row.
d | delimiter to place between the items when the list is inserted into a C++ stream | |
vb | for each true item in this list, add that field name to the returned list; ignore the others |
value_list_b< FieldNames, quote_type0 > mysqlpp::Row::field_list | ( | const std::vector< bool > & | vb | ) | const |
Get a list of the field names in this row.
vb | for each true item in this list, add that field name to the returned list; ignore the others |
value_list_b< FieldNames, Manip > mysqlpp::Row::field_list | ( | const char * | d, | |
Manip | m, | |||
bool | t0, | |||
bool | t1 = false , |
|||
bool | t2 = false , |
|||
bool | t3 = false , |
|||
bool | t4 = false , |
|||
bool | t5 = false , |
|||
bool | t6 = false , |
|||
bool | t7 = false , |
|||
bool | t8 = false , |
|||
bool | t9 = false , |
|||
bool | ta = false , |
|||
bool | tb = false , |
|||
bool | tc = false | |||
) | const [inline] |
Get a list of the field names in this row.
For each true parameter, the field name in that position within the row is added to the returned list. When the list is inserted into a C++ stream, the delimiter 'd' will be placed between the items as a delimiter, and the manipulator 'm' used before each item.
value_list_b< FieldNames, quote_type0 > mysqlpp::Row::field_list | ( | const char * | d, | |
bool | t0, | |||
bool | t1 = false , |
|||
bool | t2 = false , |
|||
bool | t3 = false , |
|||
bool | t4 = false , |
|||
bool | t5 = false , |
|||
bool | t6 = false , |
|||
bool | t7 = false , |
|||
bool | t8 = false , |
|||
bool | t9 = false , |
|||
bool | ta = false , |
|||
bool | tb = false , |
|||
bool | tc = false | |||
) | const |
Get a list of the field names in this row.
For each true parameter, the field name in that position within the row is added to the returned list. When the list is inserted into a C++ stream, the delimiter 'd' will be placed between the items as a delimiter, and the items will be quoted and escaped.
value_list_b< FieldNames, quote_type0 > mysqlpp::Row::field_list | ( | bool | t0, | |
bool | t1 = false , |
|||
bool | t2 = false , |
|||
bool | t3 = false , |
|||
bool | t4 = false , |
|||
bool | t5 = false , |
|||
bool | t6 = false , |
|||
bool | t7 = false , |
|||
bool | t8 = false , |
|||
bool | t9 = false , |
|||
bool | ta = false , |
|||
bool | tb = false , |
|||
bool | tc = false | |||
) | const |
Get a list of the field names in this row.
For each true parameter, the field name in that position within the row is added to the returned list. When the list is inserted into a C++ stream, a comma will be placed between the items as a delimiter, and the items will be quoted and escaped.
equal_list_ba< FieldNames, Row, quote_type0 > mysqlpp::Row::equal_list | ( | const char * | d = "," , |
|
const char * | e = " = " | |||
) | const |
Get an "equal list" of the fields and values in this row.
When inserted into a C++ stream, the delimiter 'd' will be used between the items, " = " is the relationship operator, and items will be quoted and escaped.
equal_list_ba< FieldNames, Row, Manip > mysqlpp::Row::equal_list | ( | const char * | d, | |
const char * | e, | |||
Manip | m | |||
) | const [inline] |
Get an "equal list" of the fields and values in this row.
This method's parameters govern how the returned list will behave when you insert it into a C++ stream:
d | delimiter to use between items | |
e | the operator to use between elements | |
m | the manipulator to use for each element |
'a' = 'c', 'b' = 'd''e'
Notice how the single quote was 'escaped' in the SQL way to avoid a syntax error.