DB::Query Class Reference

#include <db.h>

List of all members.

Public Member Functions

 Query (Connection &conn)
 ~Query ()
ACE_INLINE Queryoperator<< (const char *sql)
ACE_INLINE Queryoperator<< (const int val)
ACE_INLINE Queryoperator<< (const long val)
ACE_INLINE Queryoperator<< (const double val)
ACE_INLINE Queryoperator<< (const float val)
ACE_INLINE Queryoperator<< (const short val)
ACE_INLINE Queryoperator<< (const unsigned char *sql)
ACE_INLINE Queryoperator<< (const unsigned int val)
ACE_INLINE Queryoperator<< (const unsigned long val)
ACE_INLINE Queryoperator<< (const unsigned short val)
ACE_INLINE const char * str (void)

Private Attributes

Connectionconn_
std::ostrstream sql_

Friends

Queryunixtime_impl (Query &Out, const time_t ut)
Queryqstr_impl (Query &Out, const char *str)


Detailed Description

The Query object allows for portable SQL query generation by allowing abstract usage of escaping and date manipulations in addition to easier SQL query generation by the user. An example of usage is:

Query q(connection); // Connection is a pointer

q << "SELECT fld FROM table WHERE fld=" << qstr("rand'data");

std::cout << "SQL: " << q.str() << std::endl;

Definition at line 283 of file db.h.


Constructor & Destructor Documentation

DB::Query::Query ( Connection conn  )  [inline]

Buffer used to store the SQL query

Definition at line 290 of file db.h.

00290 : conn_(conn) {}

DB::Query::~Query (  )  [inline]

Definition at line 291 of file db.h.

References sql_.

00291 { sql_.freeze(false); }


Member Function Documentation

ACE_INLINE Query& DB::Query::operator<< ( const unsigned short  val  )  [inline]

Definition at line 347 of file db.h.

References sql_.

00348         {
00349             sql_ << val;
00350             return (*this);
00351         }

ACE_INLINE Query& DB::Query::operator<< ( const unsigned long  val  )  [inline]

Definition at line 341 of file db.h.

References sql_.

00342         {
00343             sql_ << val;
00344             return (*this);
00345         }

ACE_INLINE Query& DB::Query::operator<< ( const unsigned int  val  )  [inline]

Definition at line 335 of file db.h.

References sql_.

00336         {
00337             sql_ << val;
00338             return (*this);
00339         }

ACE_INLINE Query& DB::Query::operator<< ( const unsigned char *  sql  )  [inline]

Definition at line 329 of file db.h.

References sql_.

00330         {
00331             sql_ << sql;
00332             return (*this);
00333         }

ACE_INLINE Query& DB::Query::operator<< ( const short  val  )  [inline]

Definition at line 323 of file db.h.

References sql_.

00324         {
00325             sql_ << val;
00326             return (*this);
00327         }

ACE_INLINE Query& DB::Query::operator<< ( const float  val  )  [inline]

Definition at line 317 of file db.h.

References sql_.

00318         {
00319             sql_ << val;
00320             return (*this);
00321         }

ACE_INLINE Query& DB::Query::operator<< ( const double  val  )  [inline]

Definition at line 311 of file db.h.

References sql_.

00312         {
00313             sql_ << val;
00314             return (*this);
00315         }

ACE_INLINE Query& DB::Query::operator<< ( const long  val  )  [inline]

Definition at line 305 of file db.h.

References sql_.

00306         {
00307             sql_ << val;
00308             return (*this);
00309         }

ACE_INLINE Query& DB::Query::operator<< ( const int  val  )  [inline]

Definition at line 299 of file db.h.

References sql_.

00300         {
00301             sql_ << val;
00302             return (*this);
00303         }

ACE_INLINE Query& DB::Query::operator<< ( const char *  sql  )  [inline]

Definition at line 293 of file db.h.

References sql_.

00294         {
00295             sql_ << sql;
00296             return (*this);
00297         }

ACE_INLINE const char* DB::Query::str ( void   )  [inline]

Get the SQL statement string

Returns:
const char*

Definition at line 358 of file db.h.

References sql_.

00359         {
00360             sql_ << std::ends;
00361             return (sql_.str());
00362         }


Friends And Related Function Documentation

Query& qstr_impl ( Query Out,
const char *  str 
) [friend]

Definition at line 377 of file db.h.

00378     {
00379         const char *buf = Out.conn_.escape(str);
00380         Out << buf;
00381         delete [] buf;
00382         return (Out);
00383     }

Query& unixtime_impl ( Query Out,
const time_t  ut 
) [friend]

Definition at line 369 of file db.h.

00370     {
00371         const char *buf = Out.conn_.unixtimeToSql(ut);
00372         Out << buf;
00373         delete [] buf;
00374         return (Out);
00375     }


Member Data Documentation

Connection& DB::Query::conn_ [private]

Definition at line 286 of file db.h.

Referenced by DB::qstr_impl(), and DB::unixtime_impl().

std::ostrstream DB::Query::sql_ [private]

Internal connection object reference

Definition at line 287 of file db.h.

Referenced by operator<<(), str(), and ~Query().


The documentation for this class was generated from the following file:
Generated on Tue Apr 24 18:59:42 2007 for DbAbstract by  doxygen 1.4.7