]> granicus.if.org Git - postgresql/blob - src/interfaces/libpq++/pgdatabase.h
Here's a version of my suggested diffs transplanted to 7.1 beta 5. I'm
[postgresql] / src / interfaces / libpq++ / pgdatabase.h
1 /*-------------------------------------------------------------------------
2  *
3  * pgdatabase.h
4  *    
5  *
6  *   DESCRIPTION
7  *              Postgres Database Class: 
8  *                 Query Postgres backend to obtain query results
9  *
10  *   NOTES
11  *      Currently under construction.
12  *
13  * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
14  * Portions Copyright (c) 1994, Regents of the University of California
15  *
16  *
17  *  $Id: pgdatabase.h,v 1.10 2001/05/09 17:29:10 momjian Exp $
18  *
19  *-------------------------------------------------------------------------
20  */
21  
22 #ifndef PGDATABASE_H
23 #define PGDATABASE_H
24  
25 #ifndef PGCONNECTION_H
26 #include "pgconnection.h"
27 #endif
28
29 // ****************************************************************
30 //
31 // PgDatabase - a class for accessing databases
32 //
33 // ****************************************************************
34 // This is the basic database access class.  Its interface should 
35 // be used only after a query has been sent to the backend and
36 // results are being received.
37 class PgDatabase : public PgConnection {
38 public:
39   // connect to the database with conninfo
40   explicit PgDatabase(const char* conninfo) : PgConnection(conninfo) {}
41
42   ~PgDatabase() {}                              // close connection and clean up
43
44   typedef int size_type;
45   
46   // query result access
47   size_type Tuples() const;
48   size_type CmdTuples() const; 
49   int Fields();
50   const char* FieldName(int field_num) const;
51   int FieldNum(const char* field_name) const;
52   Oid FieldType(int field_num) const;
53   Oid FieldType(const char* field_name) const;
54   short FieldSize(int field_num) const;
55   short FieldSize(const char* field_name) const;
56   const char* GetValue(size_type tup_num, int field_num) const;
57   const char* GetValue(size_type tup_num, const char* field_name) const;
58   bool GetIsNull(size_type tup_num, int field_num) const;
59   bool GetIsNull(size_type tup_num, const char* field_name) const;
60   int GetLength(size_type tup_num, int field_num) const;
61   int GetLength(size_type tup_num, const char* field_name) const;
62
63   // OBSOLESCENT (use PQprint()):
64   void DisplayTuples(FILE *out=0, bool fillAlign=true, 
65         const char* fieldSep="|", bool printHeader=true, bool quiet=false) const;
66   void PrintTuples(FILE *out=0, bool printAttName=true, 
67         bool terseOutput=false, bool fillAlign=false) const;
68
69   // copy command related access
70   int GetLine(char str[], int length);
71   void PutLine(const char str[]);
72   const char* OidStatus() const;
73   int EndCopy();
74     
75 protected:
76   PgDatabase() : PgConnection() {}      // Do not connect
77
78 private:
79 // We don't support copying of PgDatabase objects,
80 // so make copy constructor and assignment op private.
81    PgDatabase(const PgDatabase&);
82    PgDatabase& operator= (const PgDatabase&);
83 };
84
85 #endif  // PGDATABASE_H