A class that represents a reference to a column value in an Object. More...
#include <object.h>
Public Member Functions | |
template<typename T > | |
T | convert () const throw (std::logic_error) |
Obtain the associated column value as a value of type T. | |
template<typename T > | |
operator T () const throw (std::logic_error) | |
Obtain the associated column value as a value of type T. | |
template<typename T > | |
Object & | operator= (const T &t) throw (std::logic_error) |
Assign a new value to the referenced object column. | |
Object & | operator= (const ColumnRef &r) throw (std::logic_error) |
Copy one column value to another. | |
template<typename T > | |
bool | operator== (const T &t) const throw (std::logic_error) |
Check whether the column value referred to equals the parameter. | |
bool | operator== (const char *t) const throw (std::logic_error) |
Special case of check whether the column value referred to equals the parameter. | |
bool | operator== (const ColumnRef &r) throw (std::logic_error) |
Check whether the column value referred to equals the column value referred to by the parameter. | |
template<typename T > | |
bool | operator!= (const T &t) const throw (std::logic_error) |
Check whether the column value referred to is different from the parameter. | |
bool | operator!= (const char *t) const throw (std::logic_error) |
Special case of check whether the column value referred to is different from the parameter. | |
bool | operator!= (const ColumnRef &r) throw (std::logic_error) |
Check whether the column value referred to is different from the column value referred to by the parameter. | |
Object & | set_null (bool new_value) |
Set the corresponding value to null (or not). | |
bool | null () const |
Check null status of the underlying column value. | |
Object & | set_dirty (bool new_value) |
Set the dirty status of the underlying column value. | |
Object & | touch () |
Set the dirty status of the underlying column value to true. | |
bool | dirty () const |
Check dirty status of the underlying column value. | |
Private Member Functions | |
ColumnRef (Object &o, size_t i) throw (std::logic_error) | |
Construcor. | |
Private Attributes | |
Object & | object_ |
This ColumnRef refers to a column value in this object. | |
size_t | index_ |
Index of column to which this ColumnRef refers (in object_ ). | |
Friends | |
class | Object |
template<typename T > | |
bool | operator!= (const T &t, const ColumnRef &c) throw (std::logic_error) |
Check whether the column value referred to by the second parameter is different from the first parameter. | |
template<typename T > | |
bool | operator== (const T &t, const ColumnRef &c) throw (std::logic_error) |
Check whether the column value referred to by the second parameter equals the first parameter. |
A class that represents a reference to a column value in an Object.
ColumnRef objects result from calling operator[] on an object. Such objects can convert to actual data values or be assigned to to change the value of a column in an object.
Definition at line 56 of file object.h.
Dv::Sql::Object::ColumnRef::ColumnRef | ( | Object & | o, | |
size_t | i | |||
) | throw (std::logic_error) [private] |
Construcor.
o | referenced object | |
i | number of referenced column |
std::logic_error | if i exceeds the arity of the object |
T Dv::Sql::Object::ColumnRef::convert | ( | ) | const throw (std::logic_error) [inline] |
Obtain the associated column value as a value of type T.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); Dv::Util::Date birth_date = cust["birth_date"]; // will convert
std::logic_error | if the conversion failed. |
Definition at line 69 of file object.h.
References Dv::Sql::Object::data_, index_, and object_.
Dv::Sql::Object::ColumnRef::operator T | ( | ) | const throw (std::logic_error) [inline] |
Obtain the associated column value as a value of type T.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); Dv::Util::Date birth_date = cust["birth_date"]; // will convert
std::logic_error | if the conversion failed. |
Object& Dv::Sql::Object::ColumnRef::operator= | ( | const T & | t | ) | throw (std::logic_error) [inline] |
Assign a new value to the referenced object column.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); cust["id"] = 123;
t | value to be assigned |
std::logic_error | if the ColumnRef object refers to a nonexisting colum in the associated Object |
Definition at line 105 of file object.h.
References index_, object_, and Dv::Sql::Object::set_data().
Object& Dv::Sql::Object::ColumnRef::operator= | ( | const ColumnRef & | r | ) | throw (std::logic_error) [inline] |
Copy one column value to another.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); Dv::Sql::Table::Ref account; Dv::Sql::Object acct(account); cust["id"] = acct["customer_id"]
r | the ColumnRef for which the associated column value is to be assigned to the column value associated with this ColumnRef |
std::logic_error | if this or ColumnRef object refers to a nonexisting colum in the associated Object |
Definition at line 126 of file object.h.
References index_, object_, and Dv::Sql::Object::set_data().
bool Dv::Sql::Object::ColumnRef::operator== | ( | const T & | t | ) | const throw (std::logic_error) [inline] |
Check whether the column value referred to equals the parameter.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); if ( cust["id"] == 123) { .. }
t | the value to compare with |
std::logic_error | if the conversion fails |
bool Dv::Sql::Object::ColumnRef::operator== | ( | const char * | t | ) | const throw (std::logic_error) [inline] |
Special case of check whether the column value referred to equals the parameter.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); if ( cust["name"] == "Jones") { .. }
t | the value to compare with |
std::logic_error | if the conversion fails |
bool Dv::Sql::Object::ColumnRef::operator== | ( | const ColumnRef & | r | ) | throw (std::logic_error) [inline] |
Check whether the column value referred to equals the column value referred to by the parameter.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); Dv::Sql::Table::Ref account; Dv::Sql::Object acct(account); if (cust["id"] == acct["customer_id"]) { .. }
r | the ColumnRef to compare with |
std::logic_error | if the conversion fails |
Definition at line 187 of file object.h.
References Dv::Sql::Object::data_, index_, Dv::Sql::Object::null_, and object_.
bool Dv::Sql::Object::ColumnRef::operator!= | ( | const T & | t | ) | const throw (std::logic_error) [inline] |
Check whether the column value referred to is different from the parameter.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); if ( cust["id"] != 123) { .. }
t | the value to compare with |
std::logic_error | if the conversion fails |
bool Dv::Sql::Object::ColumnRef::operator!= | ( | const char * | t | ) | const throw (std::logic_error) [inline] |
Special case of check whether the column value referred to is different from the parameter.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); if ( cust["name"] != "Jones") { .. }
t | the value to compare with |
std::logic_error | if the conversion fails |
bool Dv::Sql::Object::ColumnRef::operator!= | ( | const ColumnRef & | r | ) | throw (std::logic_error) [inline] |
Check whether the column value referred to is different from the column value referred to by the parameter.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); Dv::Sql::Table::Ref account; Dv::Sql::Object acct(account); if (cust["id"] != acct["customer_id"]) { .. }
r | the ColumnRef to compare with |
std::logic_error | if the conversion fails |
Object& Dv::Sql::Object::ColumnRef::set_null | ( | bool | new_value | ) |
Set the corresponding value to null (or not).
A null column corresponds to a database NULL value.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); cust["id"].set_null(true);
new_value | if true, the column value will be set to null, if false, it will be set to non-null. |
bool Dv::Sql::Object::ColumnRef::null | ( | ) | const |
Check null status of the underlying column value.
A null column corresponds to a database NULL value.
Object& Dv::Sql::Object::ColumnRef::set_dirty | ( | bool | new_value | ) |
Set the dirty status of the underlying column value.
A dirty column value represents the assumption that the value was not retrieved from the database, but was set explicitly by the user.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); cust["id"] = 123; std::cout << cust.dirty("id"); // prints 1 cust["id"].set_dirty(false); std::cout << cust.dirty("id"); // prints 0
new_value | if true, the dirty status will be set to true |
Referenced by touch().
Object& Dv::Sql::Object::ColumnRef::touch | ( | ) | [inline] |
Set the dirty status of the underlying column value to true.
A dirty column value represents the assumption that the value was not retrieved from the database, but was set explicitly by the user.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); cust["id"].touch(); std::cout << cust.dirty("id"); // prints 1
Definition at line 353 of file object.h.
References set_dirty().
bool Dv::Sql::Object::ColumnRef::dirty | ( | ) | const |
Check dirty status of the underlying column value.
A dirty column value represents the assumption that the value was not retrieved from the database, but was set explicitly by the user.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); cust["id"] = 123; std::cout << cust.dirty("id"); // prints 1 cust["id"].set_dirty(false); std::cout << cust.dirty("id"); // prints 0
bool operator!= | ( | const T & | t, | |
const ColumnRef & | c | |||
) | throw (std::logic_error) [friend] |
Check whether the column value referred to by the second parameter is different from the first parameter.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); if ( 123 != cust["id"] ) { .. }
t | the value to compare with | |
c | the ColumnRef referring to the column value to compare t with |
std::logic_error | if the conversion fails |
bool operator== | ( | const T & | t, | |
const ColumnRef & | c | |||
) | throw (std::logic_error) [friend] |
Check whether the column value referred to by the second parameter equals the first parameter.
This is an ordinary function.
Dv::Sql::Table::Ref customer; Dv::Sql::Object cust(customer); if ( 123 == cust["id"] ) { .. }
t | the value to compare with | |
c | the ColumnRef referring to the column value to compare t with |
std::logic_error | if the conversion fails |
Object& Dv::Sql::Object::ColumnRef::object_ [private] |
This ColumnRef refers to a column value in this object.
Definition at line 383 of file object.h.
Referenced by convert(), operator=(), and operator==().
size_t Dv::Sql::Object::ColumnRef::index_ [private] |
Index of column to which this ColumnRef refers (in object_
).
Definition at line 385 of file object.h.
Referenced by convert(), operator=(), and operator==().
dvmysql-1.0.3 | [17 November, 2010] |