#include <row.h>
Inheritance diagram for mysqlpp::Row:
Public Types | |
typedef std::vector< String > | list_type |
type of our internal data list | |
typedef list_type::const_iterator | const_iterator |
constant iterator type | |
typedef list_type::const_reference | const_reference |
constant reference type | |
typedef list_type::const_reverse_iterator | const_reverse_iterator |
const reverse iterator type | |
typedef list_type::difference_type | difference_type |
type for index differences | |
typedef const_iterator | iterator |
iterator type | |
typedef const_reference | reference |
reference type | |
typedef const_reverse_iterator | reverse_iterator |
mutable reverse iterator type | |
typedef list_type::size_type | size_type |
type of returned sizes | |
typedef list_type::value_type | value_type |
type of data in container | |
Public Member Functions | |
Row () | |
Default constructor. | |
Row (const Row &r) | |
Copy constructor. | |
Row (MYSQL_ROW row, const ResultBase *res, const unsigned long *lengths, bool te=true) | |
Create a row object. | |
~Row () | |
Destroy object. | |
const_reference | at (size_type i) const |
Get a const reference to the field given its index. | |
const_reference | back () const |
Get a reference to the last element of the vector. | |
const_iterator | begin () const |
Return a const iterator pointing to first element in the container. | |
bool | empty () const |
Returns true if container is empty. | |
const_iterator | end () const |
Return a const iterator pointing to one past the last element in the container. | |
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. | |
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. | |
size_type | field_num (const char *name) const |
Returns a field's index given its name. | |
const_reference | front () const |
Get a reference to the first element of the vector. | |
size_type | max_size () const |
Return maximum number of elements that can be stored in container without resizing. | |
Row & | operator= (const Row &rhs) |
Assignment operator. | |
const_reference | operator[] (const char *field) const |
Get the value of a field given its name. | |
const_reference | operator[] (int i) const |
Get the value of a field given its index. | |
operator private_bool_type () const | |
Returns true if row object was fully initialized and has data. | |
const_reverse_iterator | rbegin () const |
Return reverse iterator pointing to first element in the container. | |
const_reverse_iterator | rend () const |
Return reverse iterator pointing to one past the last element in the container. | |
size_type | size () const |
Get the number of fields 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. |
This class is like an extended version of a const
std::vector
of mysqlpp::String. It adds stuff for populating the vector. As for why it's const
, what would it mean to modify a Row? If we ever did support such semantics, it should probably actually modify the database. We can't do that if we just derive from std::vector.
Not that we could derive from std::vector even if we wanted to: vector::operator[](size_type)
would interfere with our operator[]
(const char*
). We can avoid this only by maintaining our own public inteface independent of that of vector
.
typedef const_iterator mysqlpp::Row::iterator |
iterator type
Note that this is just an alias for the const iterator. Row is immutable, but people are in the habit of saying 'iterator' even when they don't intend to use the iterator to modify the container, so we provide this as a convenience.
typedef std::vector<String> mysqlpp::Row::list_type |
type of our internal data list
This is public because all other typedefs we have for mirroring std::vector's public interface depend on it.
mutable reverse iterator type
mysqlpp::Row::Row | ( | MYSQL_ROW | row, | |
const ResultBase * | res, | |||
const unsigned long * | lengths, | |||
bool | te = true | |||
) |
Create a row object.
row | MySQL C API row data | |
res | result set that the row comes from | |
lengths | length of each item in row | |
te | if true, throw exceptions on errors |
const_reference mysqlpp::Row::at | ( | size_type | i | ) | const [inline] |
Get a const reference to the field given its index.
If the index value is bad, the underlying std::vector is supposed to throw an exception, according to the Standard.
equal_list_ba< FieldNames, Row, Manip > mysqlpp::Row::equal_list | ( | const char * | d, | |
const char * | e, | |||
Manip | m | |||
) | const |
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 |
///
Notice how the single quote was 'escaped' in the SQL way to avoid a syntax error.
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.
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.
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, 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 |
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 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, 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, Manip > mysqlpp::Row::field_list | ( | const char * | d, | |
Manip | m, | |||
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 | |
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_ba< FieldNames, Manip > mysqlpp::Row::field_list | ( | const char * | d, | |
Manip | m | |||
) | 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 | |
m | manipulator to use before each item when the list is inserted into a C++ stream |
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.
mysqlpp::Row::operator private_bool_type | ( | ) | const [inline] |
Returns true if row object was fully initialized and has data.
This operator lets you use Row in bool context, which lets you do things like tell when you've run off the end of a "use" query's result set:
///
const_reference mysqlpp::Row::operator[] | ( | int | i | ) | const [inline] |
Get the value of a field given its index.
This function is just syntactic sugar, wrapping the at() method.
It's critical that the parameter type be int
, not size_type
, because it will interfere with the const
char*
overload otherwise. row[0] is ambiguous when there isn't an int overload.
const Row::value_type & 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.
This operator is fairly inefficient. operator[](int) is faster.
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_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, 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 | ( | 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, 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, 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 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, | |
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_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 |