Dv::Sql::Object Class Reference

A class that represents a row in a database table or in a query result. More...

#include <object.h>

Inheritance diagram for Dv::Sql::Object:
Inheritance graph
[legend]
Collaboration diagram for Dv::Sql::Object:
Collaboration graph
[legend]

List of all members.

Classes

class  ColumnRef
 A class that represents a reference to a column value in an Object. More...

Public Types

typedef Dv::Sql::Set
< Dv::Sql::Object
Set
 Type representing a set of rows.
typedef Dv::shared_ptr< ObjectRef
 Type of (reference counted) pointer to Object.

Public Member Functions

 Object (Dv::Sql::Db &db, size_t arity)
 Create an empty object with a given arity.
 Object (Table::Ref table) throw (std::logic_error)
 Create an empty object associated with a given table.
 Object (Table::Ref table, SelectExp select_exp, const std::string &rest="") throw (std::logic_error, std::runtime_error)
 Create an object containing the first row of a "select *" statement from a database table.
 Object (Dv::Sql::Command &q, unsigned int r=0, const Table::Ref &table=Table::Ref(0)) throw (std::logic_error, std::runtime_error)
 Create an object containing the r'th row of the answer of a query.
 Object (Dv::Sql::Db &db, const std::string &prefix, SelectExp select_exp, const std::string &rest="") throw (std::logic_error, std::runtime_error)
 Create an object containing the first row of the answer of a query.
 Object (Dv::Sql::Db &db, const std::string &query) throw (std::logic_error, std::runtime_error)
 Create an object containing the first row of the answer of a query for which the complete text is provided.
 Object (const Dv::Sql::Object &source, const Dv::Sql::Reference &ref) throw (std::runtime_error, std::logic_error)
 Create an object from the result of following a reference.
virtual ~Object ()
 Destructor.
bool set (Dv::Sql::Command &q, unsigned int r=0) throw (std::logic_error)
 Set the column values of this object to those of the r'th row of the result of a query.
size_t arity () const
 Number of column values in this object.
ColumnRef operator[] (size_t i) throw (std::logic_error)
 Return a reference to the i'th column in this object.
ColumnRef operator[] (const std::string &col_name) throw (std::logic_error)
 Return a reference to a named column in this object.
ColumnRef operator[] (const Table::Column &column) throw (std::logic_error)
 Return a reference to a column in this object.
virtual std::ostream & print (std::ostream &os) const
 Print a readable representation of this object to a stream.
Dv::Sql::Dbdb () const
 The database connection of this object.
Objectoperator= (const Object &o) throw (std::logic_error)
 Assignment operator.
const Dv::Sql::Table::Ref table () const throw (std::logic_error)
 Return a reference to the associated Dv::Sql::Table of this object.
bool has_db_table () const
 Is this object associated with a database table?
Dv::Sql::Table::Ref db_table () const throw (std::logic_error)
 Return a reference to the associated database Dv::Sql::Table of this object.
const Dv::Sql::Table::Columncolumn (size_t i) const throw (std::logic_error)
 Retrieve column information for this object.
size_t match_first () throw (std::logic_error)
 Retrieve the first row, if any, that matches the dirty column values in this object.
bool refresh () throw (std::logic_error)
 Retrieve the unique row, if any, that matches the primary key column values of this object.
void insert () throw (std::runtime_error)
 Insert the present object into a database, using an Sql 'insert' statement.
void update () throw (std::runtime_error)
 Save dirty column values of an object to the database.
void replace () throw (std::runtime_error)
 Save current state of the object to the database.
void erase () throw (std::runtime_error)
 Remove the object from the database.
void erase (const Dv::Sql::SelectExp &exp) const
 Remove all objects from the table that satisfy some select expression.
Dv::Sql::Command::Ref match_query (const std::string &rest="") const throw (std::logic_error)
 Create (and execute) a 'select' query out of the dirty columns of this object.
Dv::Sql::SelectExp match_exp () const throw (std::logic_error)
 Return a boolean expression that expresses a match with the dirty columns of this object.
Dv::Sql::Command::Ref select (const Dv::Sql::SelectExp &where_exp, const std::string &rest="") const throw (std::logic_error)
 Create (and execute) a query.
template<typename T >
Objectset (size_t i, const T &t) throw (std::logic_error)
 Set a column value for this object.
template<typename T >
Objectset (const Table::Column &c, const T &t) throw (std::logic_error)
 Set a column value for this object.
template<typename T >
Objectset (const std::string &col_name, const T &t) throw (std::logic_error)
 Set a column value for this object.
template<typename T >
get (size_t i) const throw (std::logic_error)
 Retrieve a column value for this object.
template<typename T >
get (const Table::Column &c) const throw (std::logic_error)
 Retrieve a column value for this object.
template<typename T >
get (const std::string &col_name) const throw (std::logic_error)
 Retrieve a column value for this object.
Set::Ref references (const Reference &ref) const throw (std::logic_error)
 Return a reference to the set of objects obtained by following a given reference in reverse.
Objectcopy_data (size_t to_i, const Object &from, size_t from_i, bool dirty) throw (std::logic_error)
 Copy a column value from another object to this one.
const std::string & get_data (const Table::Column &c) const
 Obtain the data value associated with this object.

Protected Member Functions

Objectset_data (size_t i, const std::string &value, bool dirty) throw (std::logic_error)
 Set the value of column i in this object to value.
const std::string & data (size_t i) const
 Obtain the data value associated with this object.
void set_null (size_t i, bool new_value) throw ()
 Set the null status of a column.
bool null (size_t i) const throw ()
 Is a column value null?
void set_dirty (size_t i, bool new_value) throw ()
 Set the dirty status of a column.
bool dirty (size_t i) const throw ()
 Is a column value dirty?

Private Member Functions

void set_table (Dv::Sql::Table::Ref table) throw (std::logic_error)
 Change the associated table of this object.

Private Attributes

Dv::Sql::Dbdb_
 Database connection associated with this object.
std::vector< bool > dirty_
 Dirty flags for each column value in this object.
std::vector< bool > null_
 Null flags for each column value in this object.
std::vector< std::string > data_
 Actual column data.
const Dv::Sql::Table::Ref table_
 Table of this object.

Friends

bool operator== (const Object &o1, const Object &o2)
 Test two objects for equality.
bool operator!= (const Object &o1, const Object &o2)
 Test two objects for inequality.

Detailed Description

A class that represents a row in a database table or in a query result.

Objects represent an intermediate abstraction level between the low level interface provided by Dv::Sql::Command and the slightly higher level interface provided by Dv::Sql::Row. Nevertheless, objects may be useful for ad-hoc queries that e.g. apply sql aggregate functions.

An instance of Object can be thought of as a vector of named columns, each column representing a value. In addition, a column my be null and/or dirty. A null column corresponds to a database NULL value. A dirty column value represents the assumption that the value was not retrieved from the database, but was set explicitly by the user.
An object is also associated with a table, either a database table or a query table. The former have a name and correspond to the actual relations in the database. The latter have the empty string as name and correspond to the layout of a query result. An object's table is used to translate column names to indexes in the data array of the Object. If the table is a database table, it can also be used to e.g. insert, erase, etc. the object.
See also:
Dv::Sql::Row
Examples:

example-row.C.

Definition at line 45 of file object.h.


Member Typedef Documentation

Type representing a set of rows.

Examples:
example-database.C.

Definition at line 48 of file object.h.

Type of (reference counted) pointer to Object.

Definition at line 389 of file object.h.


Constructor & Destructor Documentation

Dv::Sql::Object::Object ( Dv::Sql::Db db,
size_t  arity 
)

Create an empty object with a given arity.

Parameters:
db database connection to be used in further SQL statements with this object
arity number of column values that may be stored in this object
Dv::Sql::Object::Object ( Table::Ref  table  )  throw (std::logic_error)

Create an empty object associated with a given table.

The object will be copy the database connection from the table.

Parameters:
table reference
Exceptions:
std::logic_error if table is a null reference
See also:
Dv::Sql::Object::table
Dv::Sql::Object::Object ( Table::Ref  table,
SelectExp  select_exp,
const std::string &  rest = "" 
) throw (std::logic_error, std::runtime_error)

Create an object containing the first row of a "select *" statement from a database table.

The select statement has the form

 select * from table->name() where select_exp rest
Parameters:
table to associate with this object
select_exp where clause of the query
rest of the query
Example
 // y is the youngest customer older than 21 (and younger than 100)
 Dv::Sql::Object y(customer, Customer::age > 21 && Customer::age < 100, "order by age");
Exceptions:
std::logic_error if the query fails or table is a null reference
std::runtime_error if the query does not return any answers
See also:
Dv::Sql::Object::table
Dv::Sql::Object::Object ( Dv::Sql::Command q,
unsigned int  r = 0,
const Table::Ref table = Table::Ref(0) 
) throw (std::logic_error, std::runtime_error)

Create an object containing the r'th row of the answer of a query.

Example
 Dv::Sql::Command(db, "select amount from transaction", 
                   Transaction::acct_code = code, "order by amount");
 // retrieve the amount of the transaction on the account
 // with the largest amount
 Dv::Sql::Object max_amount(q, q.nrows()-1);
Parameters:
q query from whose answer the r'th row will be retrieved
r number of row in query answer to be retrieved
table optional database table to associate with this object If table is null, the object will be associated with the table of the query result.
Exceptions:
std::logic_error if execution of the query failed
std::logic_error if the table is non-null and does not have the same arity as the query answer
std::runtime_error if the query answer contains less than r rows
See also:
Dv::Sql::Command::table
Dv::Sql::Object::table
Dv::Sql::Object::Object ( Dv::Sql::Db db,
const std::string &  prefix,
SelectExp  select_exp,
const std::string &  rest = "" 
) throw (std::logic_error, std::runtime_error)

Create an object containing the first row of the answer of a query.

The query is composed by prefix followed by the select expression, followed by the optional rest. Example

 Object p(db, "select * from person where", Person::age > 3, "order by age");
Parameters:
db database connection to be used in further queries
prefix of query string
select_exp condition to follow "where"
rest of query string
Exceptions:
std::logic_error if mysql rejects the query
std::runtime_error if the query returns 0 rows
See also:
Dv::Sql::SelectExp
Dv::Sql::Command
Dv::Sql::Object::Object ( Dv::Sql::Db db,
const std::string &  query 
) throw (std::logic_error, std::runtime_error)

Create an object containing the first row of the answer of a query for which the complete text is provided.

Example

 Object p(db, "select sum(amount)" + select_exp.from_where(db));
Parameters:
db database connection to be used in further queries
query text of query
Exceptions:
std::logic_error if mysql rejects the query
std::runtime_error if the query returns 0 rows
See also:
Dv::Sql::SelectExp
Dv::Sql::Command
Dv::Sql::Object::Object ( const Dv::Sql::Object source,
const Dv::Sql::Reference ref 
) throw (std::runtime_error, std::logic_error)

Create an object from the result of following a reference.

Specifically, a query of the following form will be constructed:

 select * from ref.to_table where (match source_data according to ref)
Example
 const Dv::Sql::Reference acct_cust(
           Database::account, (cols = &Account::customer_id), 
           Database::customer, (cols = &Customer::id)
           );
 Object acct(..); 
 Object cust(acct, acct_cust); // customer owning the account
 // the executed query is
 // select * from customer where customer.id = account.customer_id
Exceptions:
std::logic_error if there is an error executing the query
std::logic_error if the arities of the source object does not match the arity of ref.from_table
std::runtime_error if the query does not return any answers
See also:
Dv::Sql::Reference
Dv::Sql::Table
virtual Dv::Sql::Object::~Object (  )  [virtual]

Destructor.


Member Function Documentation

bool Dv::Sql::Object::set ( Dv::Sql::Command q,
unsigned int  r = 0 
) throw (std::logic_error)

Set the column values of this object to those of the r'th row of the result of a query.

In addition, the object's table will be set to the table associated with the query, unless the object already has an associated database table. In the latter case, the arity of the query result must match the arity of the database table. The function will set all column values to dirty, and null values as appropriate.

Parameters:
q query from which the r'th answer row will be used to set the column values of this object
r the number of the row in the query result that will be used to set this object's column values.
Exceptions:
std::logic_error if the object is associated with a database table and the arity of the query result does not match this table's arity.
See also:
Dv::Sql::Object::table
size_t Dv::Sql::Object::arity (  )  const [inline]

Number of column values in this object.

Returns:
the number of column values in this object

Definition at line 546 of file object.h.

References data_.

Referenced by get().

ColumnRef Dv::Sql::Object::operator[] ( size_t  i  )  throw (std::logic_error)

Return a reference to the i'th column in this object.

Parameters:
i the number (0-based) of the column to refer to
Exceptions:
std::logic_error if i exceeds this object's arity
ColumnRef Dv::Sql::Object::operator[] ( const std::string &  col_name  )  throw (std::logic_error)

Return a reference to a named column in this object.

Parameters:
col_name the name of the column to retrieve
Exceptions:
std::logic_error if the table associated with this object does not contain a column with this name
See also:
Dv::Sql::Object::table
ColumnRef Dv::Sql::Object::operator[] ( const Table::Column column  )  throw (std::logic_error)

Return a reference to a column in this object.

Parameters:
column the column to retrieve. Normally, a column from the table associated with this object.
Exceptions:
std::logic_error if column.index exceeds the arity of this object.
See also:
Dv::Sql::Object::table
virtual std::ostream& Dv::Sql::Object::print ( std::ostream &  os  )  const [virtual]

Print a readable representation of this object to a stream.

Parameters:
os stream to print to.
Returns:
os
Dv::Sql::Db& Dv::Sql::Object::db (  )  const [inline]

The database connection of this object.

Returns:
the database connection of this object.

Definition at line 580 of file object.h.

References db_.

Object& Dv::Sql::Object::operator= ( const Object o  )  throw (std::logic_error)

Assignment operator.

Note that both objects must have the same associated table.

Parameters:
o object to be assigned
Returns:
*this
Exceptions:
std::logic_error if the table of o does not match the table associated with this object.
See also:
Dv::Sql::Object::table
const Dv::Sql::Table::Ref Dv::Sql::Object::table (  )  const throw (std::logic_error)

Return a reference to the associated Dv::Sql::Table of this object.

There are two kinds of table: database tables and query tables. The former have a name and correspond to the actual relations in the database. The latter have the empty string as name and correspond to the layout of a query result. An object's table is used to translate column names to indexes in the data array of the Object. If the table is a database table, it can also be used to e.g. insert, erase, etc. the object.

Exceptions:
std::logic_error if the object has no associated table.
See also:
Dv::Sql::Table

Referenced by get(), and set().

bool Dv::Sql::Object::has_db_table (  )  const

Is this object associated with a database table?

Returns:
true iff this object is associated with a database table
See also:
Dv::Sql::Object::table
Dv::Sql::Table::Ref Dv::Sql::Object::db_table (  )  const throw (std::logic_error)

Return a reference to the associated database Dv::Sql::Table of this object.

Exceptions:
std::logic_error if the object has no associated table or if the associated table is a query table.
See also:
Dv::Sql::Object::table
Dv::Sql::Table
const Dv::Sql::Table::Column* Dv::Sql::Object::column ( size_t  i  )  const throw (std::logic_error)

Retrieve column information for this object.

Parameters:
i the index (0-based) of the column for which info is to be retrieved
Returns:
a pointer to the column information, alwasy nonzero
Exceptions:
std::logic_error if the associated table is null
std::logic_error if i exceeds the object's arity.
size_t Dv::Sql::Object::match_first (  )  throw (std::logic_error)

Retrieve the first row, if any, that matches the dirty column values in this object.

Example
 Dv::Sql::Object cust;
 cust["name"] = "fred"; // will set dirty for "name"
 cust.match_first(); // first customer called "fred"
Returns:
the number of rows, possibly 0, retrieved by the underlying query.
Exceptions:
std::logic_error iff the query execution failed
See also:
Object::dirty
bool Dv::Sql::Object::refresh (  )  throw (std::logic_error)

Retrieve the unique row, if any, that matches the primary key column values of this object.

The primary key information is obtained from the object's table.

Example
 Dv::Sql::Object cust;
 cust["name"] = "fred"; // will set dirty for "name"
 cust.match_first(); // first customer called "fred"
 cust["name"] = "jane";
 cust,refresh(); // name will be "fred" again
Returns:
true iff the object was found in the database
Exceptions:
std::logic_error iff the query execution failed
Warning:
upon failure, dirty(c) iff c in primary key
See also:
Dv::Sql::Object::table
void Dv::Sql::Object::insert (  )  throw (std::runtime_error)

Insert the present object into a database, using an Sql 'insert' statement.

All non-null column values will be stored except for auto_inc columns. After the insert operation, the object will be refreshed thus causing auto_inc and default values to be available, as appropriate.

Example
 Dv::Sql::Object cust;
 cust.set("last_name",  last_nm)
     .set("first_name", first_nm)
     .set("birth_date", Dv::Util::Date(1970, 8, 20))
     .set("sex", "M")
     .set("email", "dvermeir@vub.ac.be")
     .insert();
Exceptions:
std::runtime_error iff executing the insert statement failed.
See also:
Object::null()
Object::refresh()
Dv::Sql::Column::auto_inc
void Dv::Sql::Object::update (  )  throw (std::runtime_error)

Save dirty column values of an object to the database.

This function will execute an update statement using all dirty columns. The update statement will be executed on the row in the database that has the same primary key as the current object. See the Mysql documentation for the precise semantics.

Example
 Customer::Row cust(..);
 cust["id"] = cust_id;
 cust["last_name"] = new_name;
 cust.update();
Exceptions:
std::runtime_error iff the corresponding sql statement failed.
Warning:
if there are no dirty columns, the operation is quietly canceled.
void Dv::Sql::Object::replace (  )  throw (std::runtime_error)

Save current state of the object to the database.

This function will execute a replace statement using all dirty columns as well as the columns in all unique keys. See the Mysql documentation for the precise semantics.

Exceptions:
std::runtime_error iff the corresponding sql statement failed.
void Dv::Sql::Object::erase (  )  throw (std::runtime_error)

Remove the object from the database.

This function will execute a delete statement using the primary key columns. See the Mysql documentation for the precise semantics.

Exceptions:
std::runtime_error iff the corresponding sql statement failed.
void Dv::Sql::Object::erase ( const Dv::Sql::SelectExp exp  )  const

Remove all objects from the table that satisfy some select expression.

The constructed sql statement uses the object's database and associated (database) table (only).

Dv::Sql::Command::Ref Dv::Sql::Object::match_query ( const std::string &  rest = ""  )  const throw (std::logic_error)

Create (and execute) a 'select' query out of the dirty columns of this object.

Parameters:
rest optional suffix of the query
Returns:
a (reference counted) pointer to a newly allocated query
Exceptions:
std::logic_error iff executing the query fails.
See also:
Object::match_first
Dv::Sql::SelectExp Dv::Sql::Object::match_exp (  )  const throw (std::logic_error)

Return a boolean expression that expresses a match with the dirty columns of this object.

Returns:
a boolean expression (a conjunction of equalities) asserting a match between dirty columns and their current values.
Example
 Dv::Sql::Table::Ref customer;
 Dv::Sql::Object cust(customer);
 cust["first_name"] = "fred";
 Dv::Sql::SelectExp e = cust.match_exp();
 // Get all customers called "fred" that are older than 21
 Dv::Sql::Object::Set freds(customer, e && (customer.age > 21));
Dv::Sql::Command::Ref Dv::Sql::Object::select ( const Dv::Sql::SelectExp where_exp,
const std::string &  rest = "" 
) const throw (std::logic_error)

Create (and execute) a query.

The query has the form

 select * from table_name where where_exp rest
Parameters:
where_exp to use in the query
rest of the text of the query
Exceptions:
std::logic_error iff executing the query fails.
template<typename T >
Object& Dv::Sql::Object::set ( size_t  i,
const T &  t 
) throw (std::logic_error) [inline]

Set a column value for this object.

Parameters:
i index (0-based) of the column
t value to store
Returns:
a reference to this object
Exceptions:
std::logic_error if i exceeds the object's arity
std::logic_error if t cannot be converted to a string using Dv::Util::tostring

Definition at line 801 of file object.h.

References set_data().

template<typename T >
Object& Dv::Sql::Object::set ( const Table::Column c,
const T &  t 
) throw (std::logic_error) [inline]

Set a column value for this object.

Parameters:
c the column to set
t value to store
Returns:
a reference to this object
Exceptions:
std::logic_error if the index of c exceeds the object's arity
std::logic_error if t cannot be converted to a string using Dv::Util::tostring

Definition at line 815 of file object.h.

template<typename T >
Object& Dv::Sql::Object::set ( const std::string &  col_name,
const T &  t 
) throw (std::logic_error) [inline]

Set a column value for this object.

Parameters:
col_name name of the column to set
t value to store
Returns:
a reference to this object
Exceptions:
std::logic_error if the object has no column with the given name
std::logic_error if t cannot be converted to a string using Dv::Util::tostring
See also:
Dv::Sql::Object::table

Definition at line 830 of file object.h.

References table().

template<typename T >
T Dv::Sql::Object::get ( size_t  i  )  const throw (std::logic_error) [inline]

Retrieve a column value for this object.

Parameters:
i index (0-based) of the column value to retrieve
Returns:
the (converted) column value
Exceptions:
std::logic_error if i exceeds the object's arity
std::logic_error if the conversion from a string fails

Definition at line 843 of file object.h.

References arity(), and data_.

template<typename T >
T Dv::Sql::Object::get ( const Table::Column c  )  const throw (std::logic_error) [inline]

Retrieve a column value for this object.

Parameters:
c the column to set
Returns:
the (converted) column value
Exceptions:
std::logic_error if the index of c exceeds the object's arity
std::logic_error if the conversion from a string fails

Definition at line 863 of file object.h.

template<typename T >
T Dv::Sql::Object::get ( const std::string &  col_name  )  const throw (std::logic_error) [inline]

Retrieve a column value for this object.

Parameters:
col_name name of the column to retrieve
Returns:
the (converted) column value
Exceptions:
std::logic_error if the object has no column with the given name
std::logic_error if the conversion from a string fails

Definition at line 876 of file object.h.

References table().

Set::Ref Dv::Sql::Object::references ( const Reference ref  )  const throw (std::logic_error)

Return a reference to the set of objects obtained by following a given reference in reverse.

Example
 const Dv::Sql::Reference acct_cust(
           Database::account, (cols = &Account::customer_id), 
           Database::customer, (cols = &Customer::id)
           );
 Object cust(..); 
 // all accounts of this customer
 Object::Set::Ref accounts =  cust.references(acct_cust);
See also:
Dv::Sql::Set(const Source&,const Dv::Sql::Reference&)
Object& Dv::Sql::Object::copy_data ( size_t  to_i,
const Object from,
size_t  from_i,
bool  dirty 
) throw (std::logic_error)

Copy a column value from another object to this one.

If the source column is null, the target column in this object will be null.

Parameters:
to_i index of target column in this object
from source object for copy
from_i index of source column in source object
dirty the dirty attribute of the target column will be set to this value
Exceptions:
std::logic_error if one of the column indexes is out of range
See also:
Object::set_dirty
const std::string& Dv::Sql::Object::get_data ( const Table::Column c  )  const [inline]

Obtain the data value associated with this object.

This function does not do any checking, it also does not take into account the null status of this column.

Parameters:
i index (0-based) of the column to retrieve the value of
Returns:
the value of the column

Definition at line 917 of file object.h.

References data_, Dv::Sql::Column::index(), and null().

Object& Dv::Sql::Object::set_data ( size_t  i,
const std::string &  value,
bool  dirty 
) throw (std::logic_error) [protected]

Set the value of column i in this object to value.

This function checks the validity of i.

Parameters:
i index (0-based) of the column to set the value of
value to store in the column
dirty new value of the dirty attribute of the column
Returns:
a reference to this object
Exceptions:
std::logic_error if i exceeds the object's arity

Referenced by Dv::Sql::Object::ColumnRef::operator=(), and set().

const std::string& Dv::Sql::Object::data ( size_t  i  )  const [inline, protected]

Obtain the data value associated with this object.

This function does not do any checking, it also does not take into account the null status of this column.

Parameters:
i index (0-based) of the column to retrieve the value of
Returns:
the value of the column

Definition at line 945 of file object.h.

References data_.

void Dv::Sql::Object::set_null ( size_t  i,
bool  new_value 
) throw () [protected]

Set the null status of a column.

This function does not verify the validity of its parameters.

Parameters:
i index (0-based) of the column to set the null status for
new_value new null status
Precondition:
i < arity()
bool Dv::Sql::Object::null ( size_t  i  )  const throw () [inline, protected]

Is a column value null?

Parameters:
i index (0-based) of the column to retrieve the null status for
Returns:
true iff the column value is null
Precondition:
i < arity()

Definition at line 959 of file object.h.

References null_.

Referenced by get_data().

void Dv::Sql::Object::set_dirty ( size_t  i,
bool  new_value 
) throw () [protected]

Set the dirty status of a column.

This function does not verify the validity of its parameters.

Parameters:
i index (0-based) of the column to set the dirty status for
new_value new dirty status
Precondition:
i < arity()
bool Dv::Sql::Object::dirty ( size_t  i  )  const throw () [inline, protected]

Is a column value dirty?

Parameters:
i index (0-based) of the column to retrieve the dirty status for
Returns:
true iff the column value is dirty
Precondition:
i < arity()

Definition at line 973 of file object.h.

References dirty_.

void Dv::Sql::Object::set_table ( Dv::Sql::Table::Ref  table  )  throw (std::logic_error) [private]

Change the associated table of this object.

Note that if the object currently has a database table, this function will throw an exception.

Parameters:
table new table
Exceptions:
std::logic_error if the object is currently associated with a database table.

Friends And Related Function Documentation

bool operator== ( const Object o1,
const Object o2 
) [friend]

Test two objects for equality.

The objects are equal iff they have the same associated table, their null_ arrays are equal and the corresponding non-null data_ values are also equal.

Parameters:
o1 object to test for equality with o2
o2 object to test for equality with o1
Returns:
true iff both objects are equal
See also:
Dv::Sql::Object::table
bool operator!= ( const Object o1,
const Object o2 
) [friend]

Test two objects for inequality.

The objects are equal iff they have the same associated table, their null_ arrays are equal and the corresponding non-null data_ values are also equal.

Parameters:
o1 object to test for inequality with o2
o2 object to test for inequality with o1
Returns:
true iff the objects are not equal
See also:
Dv::Sql::Object::table

Member Data Documentation

Database connection associated with this object.

Definition at line 977 of file object.h.

Referenced by db().

std::vector<bool> Dv::Sql::Object::dirty_ [private]

Dirty flags for each column value in this object.

Definition at line 979 of file object.h.

Referenced by dirty().

std::vector<bool> Dv::Sql::Object::null_ [private]

Null flags for each column value in this object.

Definition at line 981 of file object.h.

Referenced by null(), and Dv::Sql::Object::ColumnRef::operator==().

std::vector<std::string> Dv::Sql::Object::data_ [private]

Actual column data.

Definition at line 983 of file object.h.

Referenced by arity(), Dv::Sql::Object::ColumnRef::convert(), data(), get(), get_data(), and Dv::Sql::Object::ColumnRef::operator==().

Table of this object.

Definition at line 985 of file object.h.


The documentation for this class was generated from the following file:

dvmysql-1.0.3 [17 November, 2010]