Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

cursor.h

Go to the documentation of this file.
00001 /*-------------------------------------------------------------------------
00002  *
00003  *   FILE
00004  *      pqxx/cursor.h
00005  *
00006  *   DESCRIPTION
00007  *      definition of the pqxx::Cursor class.
00008  *   pqxx::Cursor represents a database cursor.
00009  *
00010  * Copyright (c) 2001-2002, Jeroen T. Vermeulen <jtv@xs4all.nl>
00011  *
00012  *-------------------------------------------------------------------------
00013  */
00014 #ifndef PQXX_CURSOR_H
00015 #define PQXX_CURSOR_H
00016 
00017 #include "pqxx/util.h"
00018 
00019 /* (A quick note on binary cursors:
00020  * These will require a lot of work.  First off, conversion to C++ datatypes
00021  * becomes more complex.  Second, some tradeoffs will need to be made between
00022  * dynamic (flexible) type handling and static (fast) type handling.)
00023  */
00024 
00025 /* Methods tested in eg. self-test program test1 are marked with "//[t1]"
00026  */
00027 
00028 namespace pqxx
00029 {
00030 class Result;
00031 class Transaction;
00032 
00034 
00041 class PQXX_LIBEXPORT Cursor
00042 {
00043 public:
00045 
00053   Cursor(Transaction &T,
00054          const char Query[], 
00055          PGSTD::string BaseName="cur",
00056          Result_size_type Count=NEXT());                                //[t3]
00057 
00059   Result_size_type SetCount(Result_size_type);                          //[t19]
00060 
00062 
00064   Result Fetch(Result_size_type Count);                                 //[t19]
00065 
00067   void Move(Result_size_type Count);                                    //[t3]
00068 
00070 
00074   static Result_size_type ALL() { return Result_size_type_max; }        //[t3]
00075 
00077   static Result_size_type NEXT() { return 1; }                          //[t19]
00078 
00080   static Result_size_type PRIOR() { return -1; }                        //[t19]
00081 
00084 
00088   static Result_size_type BACKWARD_ALL()                                //[t19]
00089         { return Result_size_type_min + 1; }
00090 
00092 
00099   Cursor &operator>>(Result &);                                         //[t3]
00100 
00102   operator bool() const { return !m_Done; }                             //[t3]
00104   bool operator!() const { return m_Done; }                             //[t3]
00105 
00107   Cursor &operator+=(Result_size_type N) { Move(N); return *this;}      //[t19]
00109   Cursor &operator-=(Result_size_type N) { Move(-N); return *this;}     //[t19]
00110 
00111 private:
00112   PGSTD::string MakeFetchCmd(Result_size_type) const;
00113 
00114   Transaction &m_Trans;
00115   PGSTD::string m_Name;
00116   Result_size_type m_Count;
00117   bool m_Done;
00118 
00119   // Not allowed:
00120   Cursor(const Cursor &);
00121   Cursor &operator=(const Cursor &);
00122 };
00123 
00124 }
00125 
00126 #endif
00127 

Generated on Sat Oct 5 15:55:44 2002 for libpqxx by doxygen1.2.18