aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/libpq++/pgdatabase.h
blob: d529f5bae223a7b4ab0e370fd3338850fea50809 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*-------------------------------------------------------------------------
 *
 * pgdatabase.h
 *    
 *
 *   DESCRIPTION
 *		Postgres Database Class: 
 *		   Query Postgres backend to obtain query results
 *
 *   NOTES
 *      Currently under construction.
 *
 * Copyright (c) 1994, Regents of the University of California
 *
 *
 *  $Id: pgdatabase.h,v 1.2 1999/05/23 01:04:01 momjian Exp $
 *
 *-------------------------------------------------------------------------
 */
 
#ifndef PGDATABASE_H
#define PGDATABASE_H
 
#include "pgconnection.h"


// ****************************************************************
//
// PgDatabase - a class for accessing databases
//
// ****************************************************************
// This is the basic database access class.  Its interface should 
// be used only after a query has been sent to the backend and
// results are being received.
class PgDatabase : public PgConnection {
public:
  PgDatabase(const char* conninfo) : PgConnection(conninfo) {} // use reasonable defaults
  ~PgDatabase() {} ; // close connection and clean up
  
  // query result access
  int Tuples();
  int Fields();
  const char* FieldName(int field_num);
  int FieldNum(const char* field_name);
  Oid FieldType(int field_num);
  Oid FieldType(const char* field_name);
  short FieldSize(int field_num);
  short FieldSize(const char* field_name);
  const char* GetValue(int tup_num, int field_num);
  const char* GetValue(int tup_num, const char* field_name);
  int GetLength(int tup_num, int field_num);
  int GetLength(int tup_num, const char* field_name);
  void DisplayTuples(FILE *out = 0, int fillAlign = 1, 
	const char* fieldSep = "|",int printHeader = 1, int quiet = 0) ;
  void PrintTuples(FILE *out = 0, int printAttName = 1, 
	int terseOutput = 0, int width = 0) ;

  // copy command related access
  int GetLine(char* string, int length);
  void PutLine(const char* string);
  const char* OidStatus();
  int EndCopy();
    
protected:
  PgDatabase() : PgConnection() {}	// Do not connect
};

#endif	// PGDATABASE_H