MySQL++
3.3.0
|
Manages rows from a result set. More...
#include <row.h>
Public Types | |
typedef std::vector< String > | list_type |
type of our internal data list More... | |
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 More... | |
typedef const_reference | reference |
reference type More... | |
typedef const_reverse_iterator | reverse_iterator |
mutable reverse iterator type More... | |
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. More... | |
~Row () | |
Destroy object. | |
const_reference | at (size_type i) const |
Get a const reference to the field given its index. More... | |
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. More... | |
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. More... | |
value_list_ba< FieldNames, do_nothing_type0 > | field_list (const char *d=",") const |
Get a list of the field names in this row. More... | |
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. More... | |
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. More... | |
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. More... | |
value_list_b< FieldNames, quote_type0 > | field_list (const std::vector< bool > &vb) const |
Get a list of the field names in this row. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
const_reference | operator[] (int i) const |
Get the value of a field given its index. More... | |
operator private_bool_type () const | |
Returns true if row object was fully initialized and has data. More... | |
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. More... | |
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. More... | |
value_list_b< Row, quote_type0 > | value_list (const std::vector< bool > &vb) const |
Get a list of the values in this row. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
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. More... | |
Public Member Functions inherited from mysqlpp::OptionalExceptions | |
OptionalExceptions (bool e=true) | |
Default constructor. More... | |
virtual | ~OptionalExceptions () |
Destroy object. | |
void | enable_exceptions () const |
Enable exceptions from the object. | |
void | disable_exceptions () const |
Disable exceptions from the object. | |
bool | throw_exceptions () const |
Returns true if exceptions are enabled. | |
Additional Inherited Members | |
Protected Member Functions inherited from mysqlpp::OptionalExceptions | |
void | set_exceptions (bool e) const |
Sets the exception state to a particular value. More... | |
Manages rows from a result set.
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.
reference type
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 |
References mysqlpp::ResultBase::field_names(), mysqlpp::ResultBase::field_type(), mysqlpp::ResultBase::num_fields(), size(), and mysqlpp::OptionalExceptions::throw_exceptions().
Row::const_reference mysqlpp::Row::at | ( | size_type | i | ) | const |
Get a const reference to the field given its index.
mysqlpp::BadIndex | if the row is not initialized or there are less than i fields in the row. |
References size().
Referenced by operator[]().
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 |
For example, if d is ",", e is " = ", and m is the quote manipulator, then the field and value lists (a, b) (c, d'e) will yield an equal list that gives the following when inserted into a C++ stream:
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.
References mysqlpp::quote.
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.
References mysqlpp::quote.
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.
References mysqlpp::quote.
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 |
Field names will be quoted and escaped when inserted into a C++ stream.
References mysqlpp::quote.
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_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, 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, 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.
References mysqlpp::do_nothing.
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 |
Field names will be quoted and escaped when inserted into a C++ stream, and a comma will be placed between them as a delimiter.
References mysqlpp::quote.
|
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 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 if exceptions are enabled, or an empty row if not. An empty row tests as false in bool context.
This operator is fairly inefficient. operator[](int) is faster.
References at(), empty(), field_num(), size(), and mysqlpp::OptionalExceptions::throw_exceptions().
|
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.
mysqlpp::BadIndex | if the row is not initialized or there are less than i fields in the row. |
|
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.
References mysqlpp::quote.
|
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.
References mysqlpp::quote.
|
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 |
|
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.
|
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.
|
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.
References mysqlpp::quote.
|
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 |
|
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 |
Items will be quoted and escaped when inserted into a C++ stream, and a comma will be used as a delimiter between the items.
References mysqlpp::quote.
|
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.
References mysqlpp::quote.