1 /*-------------------------------------------------------------------------
7 * Postgres Database Class:
8 * Query Postgres backend to obtain query results
11 * Currently under construction.
13 * Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
14 * Portions Copyright (c) 1994, Regents of the University of California
17 * $Id: pgdatabase.h,v 1.10 2001/05/09 17:29:10 momjian Exp $
19 *-------------------------------------------------------------------------
25 #ifndef PGCONNECTION_H
26 #include "pgconnection.h"
29 // ****************************************************************
31 // PgDatabase - a class for accessing databases
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 {
39 // connect to the database with conninfo
40 explicit PgDatabase(const char* conninfo) : PgConnection(conninfo) {}
42 ~PgDatabase() {} // close connection and clean up
44 typedef int size_type;
46 // query result access
47 size_type Tuples() const;
48 size_type CmdTuples() const;
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;
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;
69 // copy command related access
70 int GetLine(char str[], int length);
71 void PutLine(const char str[]);
72 const char* OidStatus() const;
76 PgDatabase() : PgConnection() {} // Do not connect
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&);
85 #endif // PGDATABASE_H