Dv::Sql::Command::iterator Class Reference

A logical pointer (input iterator) inside the query result of a Dv::Sql::Command. More...

#include <sqldb.h>

Collaboration diagram for Dv::Sql::Command::iterator:
Collaboration graph
[legend]

List of all members.

Public Member Functions

iteratoroperator++ () throw (std::logic_error)
 Make the iterator point to the next row in the result: prefix version.
iterator operator++ (int) throw (std::logic_error)
 Make the iterator point to the next row in the result: postfix version.
std::vector< std::string > operator* () const throw (std::logic_error)
 Dereference to the current row.
bool operator== (const iterator &j) const
 Compare two iterators.
bool operator!= (const iterator &j) const
 Compare two iterators.
std::string operator() (unsigned int c) const throw (std::logic_error)
 Get the c'th column of the current row.
Commandcommand () const
 The command associated with this iterator.

Private Types

enum  { END = -1, BEGIN = 0 }

Private Member Functions

 iterator (Command &command, int row)
 Constructor.

Private Attributes

Commandcmd_
int row_
 Current row number, may be BEGIN, END or any number in [0,cmd_.nrows_[.

Friends

class Command

Detailed Description

A logical pointer (input iterator) inside the query result of a Dv::Sql::Command.

A valid iterator in the range [begin,end[ points to a row of the query result.

Its value type is the type of a row in the query result, i.e. a vector of strings.

Definition at line 566 of file sqldb.h.


Member Enumeration Documentation

anonymous enum [private]
Enumerator:
END 
BEGIN 

Definition at line 612 of file sqldb.h.


Constructor & Destructor Documentation

Dv::Sql::Command::iterator::iterator ( Command command,
int  row 
) [inline, private]

Constructor.

Parameters:
command associated with this iterator
row to which iterator will refer

Definition at line 620 of file sqldb.h.


Member Function Documentation

iterator& Dv::Sql::Command::iterator::operator++ (  )  throw (std::logic_error)

Make the iterator point to the next row in the result: prefix version.

iterator Dv::Sql::Command::iterator::operator++ ( int   )  throw (std::logic_error) [inline]

Make the iterator point to the next row in the result: postfix version.

Definition at line 573 of file sqldb.h.

std::vector<std::string> Dv::Sql::Command::iterator::operator* (  )  const throw (std::logic_error)

Dereference to the current row.

Warning:
NULL is represented by the std::string "NULL".
bool Dv::Sql::Command::iterator::operator== ( const iterator j  )  const [inline]

Compare two iterators.

Two iterators are equal if they point to the same row in the query result of the same Dv::Sql::Command.

Parameters:
j operator to compare with.
Returns:
true iff this iterator is equal to j

Definition at line 584 of file sqldb.h.

References cmd_, and row_.

bool Dv::Sql::Command::iterator::operator!= ( const iterator j  )  const [inline]

Compare two iterators.

Parameters:
j operator to compare with.
Returns:
true iff this iterator is not equal to j
See also:
Dv::Sql::Command::iterator::operator==

Definition at line 590 of file sqldb.h.

std::string Dv::Sql::Command::iterator::operator() ( unsigned int  c  )  const throw (std::logic_error)

Get the c'th column of the current row.

Example

 MySql::Db db(...);
        
 std::string name;
 Sql::Command query("select * from person where name = ");
 query << name;
 if (q.exec())
   for (Sql::Command::iterator i=q.begin(); i!=q.end(); ++i) 
     cout << i(0) << "\t" << i(1) << endl;
Command& Dv::Sql::Command::iterator::command (  )  const [inline]

The command associated with this iterator.

Returns:
the command associated with this iterator.

Definition at line 610 of file sqldb.h.

References cmd_.


Friends And Related Function Documentation

friend class Command [friend]

Definition at line 567 of file sqldb.h.


Member Data Documentation

Definition at line 613 of file sqldb.h.

Referenced by command(), and operator==().

Current row number, may be BEGIN, END or any number in [0,cmd_.nrows_[.

Definition at line 615 of file sqldb.h.

Referenced by operator==().


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

dvmysql-1.0.3 [17 November, 2010]