|
8 | 8 | * used for building front-end applications |
9 | 9 | * |
10 | 10 | * NOTES |
11 | | - * Currently under construction. |
| 11 | + * This is intended to be included by client applications. |
| 12 | + * It will not work as an inclusion in the libpq++ sources, since |
| 13 | + * in the build environment the individual include files are not |
| 14 | + * yet installed in a subdirectory. |
12 | 15 | * |
13 | 16 | * Portions Copyright (c) 1996-2000, PostgreSQL, Inc |
14 | 17 | * Portions Copyright (c) 1994, Regents of the University of California |
15 | 18 | * |
16 | | - * $Id: libpq++.h,v 1.8 2000/04/14 01:00:16 tgl Exp $ |
| 19 | + * $Id: libpq++.h,v 1.9 2000/04/22 22:39:15 tgl Exp $ |
17 | 20 | * |
18 | 21 | *------------------------------------------------------------------------- |
19 | 22 | */ |
20 | 23 |
|
21 | 24 | #ifndefLIBPQXX_H |
22 | 25 | #defineLIBPQXX_H |
23 | 26 |
|
24 | | -extern"C" { |
25 | | -#include"config.h" |
26 | | -} |
27 | | - |
28 | | -/* We assume that the C++ compiler will have these keywords, even though |
29 | | - * config.h may have #define'd them to empty because C compiler doesn't. |
30 | | -*/ |
31 | | -#undef const |
32 | | -#undef inline |
33 | | -#undef signed |
34 | | -#undef volatile |
35 | | - |
36 | | -#ifdef HAVE_CXX_STRING_HEADER |
37 | | -#include<string> |
38 | | -#endif |
39 | | - |
40 | | -extern"C" { |
41 | | -#include"postgres.h" |
42 | | -#include"libpq-fe.h" |
43 | | -} |
44 | | - |
45 | | -#ifdef HAVE_NAMESPACE_STD |
46 | | -usingnamespacestd; |
47 | | -#endif |
48 | | - |
49 | | - |
50 | | -// **************************************************************** |
51 | | -// |
52 | | -// PgConnection - a connection made to a postgres backend |
53 | | -// |
54 | | -// **************************************************************** |
55 | | -classPgConnection { |
56 | | -protected: |
57 | | - PGconn* pgConn;// Connection Structures |
58 | | - PGresult* pgResult;// Query Result |
59 | | -int pgCloseConnection;// Flag indicating whether the connection should be closed |
60 | | - ConnStatusTypeConnect(constchar* conninfo); |
61 | | - stringIntToString(int); |
62 | | -PgConnection(); |
63 | | - |
64 | | -public: |
65 | | -PgConnection(constchar* conninfo);// use reasonable and environment defaults |
66 | | -~PgConnection();// close connection and clean up |
67 | | - |
68 | | - ConnStatusTypeStatus(); |
69 | | -intConnectionBad(); |
70 | | -constchar*ErrorMessage(); |
71 | | - |
72 | | -// returns the database name of the connection |
73 | | -constchar*DBName(); |
74 | | - |
75 | | - ExecStatusTypeExec(constchar* query);// send a query to the backend |
76 | | -intExecCommandOk(constchar* query);// send a command and check if it's |
77 | | -intExecTuplesOk(constchar* query);// send a command and check if tuple |
78 | | - PGnotify*Notifies(); |
79 | | -}; |
80 | | - |
81 | | -// **************************************************************** |
82 | | -// |
83 | | -// PgDatabase - a class for accessing databases |
84 | | -// |
85 | | -// **************************************************************** |
86 | | -classPgDatabase :publicPgConnection { |
87 | | -protected: |
88 | | -PgDatabase() : PgConnection() {}// Do not connect |
89 | | - |
90 | | -public: |
91 | | -// connect to the database with conninfo |
92 | | -PgDatabase(constchar *conninfo) : PgConnection(conninfo) {}; |
93 | | -~PgDatabase() {};// close connection and clean up |
94 | | -// query result access |
95 | | -intTuples(); |
96 | | -intCmdTuples(); |
97 | | -intFields(); |
98 | | -constchar*FieldName(int field_num); |
99 | | -intFieldNum(constchar *field_name); |
100 | | - OidFieldType(int field_num); |
101 | | - OidFieldType(constchar *field_name); |
102 | | -shortFieldSize(int field_num); |
103 | | -shortFieldSize(constchar *field_name); |
104 | | -constchar*GetValue(int tup_num,int field_num); |
105 | | -constchar*GetValue(int tup_num,constchar *field_name); |
106 | | -intGetIsNull(int tup_num,int field_num); |
107 | | -intGetIsNull(int tup_num,constchar* field_name); |
108 | | -intGetLength(int tup_num,int field_num); |
109 | | -intGetLength(int tup_num,constchar* field_name); |
110 | | -voidDisplayTuples(FILE *out =0,int fillAlign =1, |
111 | | -constchar* fieldSep ="|",int printHeader =1,int quiet =0) ; |
112 | | -voidPrintTuples(FILE *out =0,int printAttName =1, |
113 | | -int terseOutput =0,int width =0) ; |
114 | | - |
115 | | -// copy command related access |
116 | | -intGetLine(char* string,int length); |
117 | | -voidPutLine(constchar* string); |
118 | | -constchar *OidStatus(); |
119 | | -intEndCopy(); |
120 | | -}; |
121 | | - |
122 | | - |
123 | | - |
124 | | -// **************************************************************** |
125 | | -// |
126 | | -// PGLargeObject - a class for accessing Large Object in a database |
127 | | -// |
128 | | -// **************************************************************** |
129 | | -classPgLargeObject :publicPgConnection { |
130 | | -private: |
131 | | -int pgFd; |
132 | | - Oid pgObject; |
133 | | - string loStatus; |
134 | | - |
135 | | -public: |
136 | | -PgLargeObject(constchar* conninfo =0);// use reasonable defaults and create large object |
137 | | -PgLargeObject(Oid lobjId,constchar* conninfo =0);// use reasonable defaults and open large object |
138 | | -~PgLargeObject();// close connection and clean up |
139 | | - |
140 | | -voidCreate(); |
141 | | -voidOpen(); |
142 | | -voidClose(); |
143 | | -intRead(char* buf,int len); |
144 | | -intWrite(constchar* buf,int len); |
145 | | -intLSeek(int offset,int whence); |
146 | | -intTell(); |
147 | | -intUnlink(); |
148 | | - OidLOid(); |
149 | | - OidImport(constchar* filename); |
150 | | -intExport(constchar* filename); |
151 | | - stringStatus(); |
152 | | -}; |
153 | | - |
154 | | - |
155 | | -// **************************************************************** |
156 | | -// |
157 | | -// PgTransaction - a class for running transactions against databases |
158 | | -// |
159 | | -// **************************************************************** |
160 | | -classPgTransaction :publicPgDatabase { |
161 | | -protected: |
162 | | - ExecStatusTypeBeginTransaction(); |
163 | | - ExecStatusTypeEndTransaction(); |
164 | | -PgTransaction() : PgDatabase() {}// Do not connect |
165 | | - |
166 | | -public: |
167 | | -PgTransaction(constchar* conninfo);// use reasonable & environment defaults |
168 | | -// connect to the database with given environment and database name |
169 | | -PgTransaction(const PgConnection&); |
170 | | -virtual~PgTransaction();// close connection and clean up |
171 | | - |
172 | | -}; |
173 | | - |
174 | | - |
175 | | -// **************************************************************** |
176 | | -// |
177 | | -// PgCursor - a class for querying databases using a cursor |
178 | | -// |
179 | | -// **************************************************************** |
180 | | -classPgCursor :publicPgTransaction { |
181 | | -protected: |
182 | | -intFetch(const string& num,const string& dir); |
183 | | - string pgCursor; |
184 | | -PgCursor() : PgTransaction() {}// Do not connect |
185 | | - |
186 | | -public: |
187 | | -PgCursor(constchar* dbName,constchar* cursor);// use reasonable & environment defaults |
188 | | -// connect to the database with given environment and database name |
189 | | -PgCursor(const PgConnection&,constchar* cursor); |
190 | | -virtual~PgCursor();// close connection and clean up |
191 | | - |
192 | | -// Commands associated with cursor interface |
193 | | -intDeclare(const string& query,int binary =0);// Declare a cursor with given name |
194 | | -intFetch(constchar* dir ="FORWARD");// Fetch ALL tuples in given direction |
195 | | -intFetch(unsigned num,constchar* dir ="FORWARD");// Fetch specified amount of tuples |
196 | | -intClose();// Close the cursor |
197 | | - |
198 | | -// Accessors to the cursor name |
199 | | -constchar*Cursor(); |
200 | | -voidCursor(const string& cursor); |
201 | | -}; |
202 | | - |
203 | | - |
204 | | - |
205 | | -// buffer size |
206 | | -#defineBUFSIZE1024 |
| 27 | +#include"libpq++/pgconnection.h" |
| 28 | +#include"libpq++/pgdatabase.h" |
| 29 | +#include"libpq++/pglobject.h" |
| 30 | +#include"libpq++/pgtransdb.h" |
| 31 | +#include"libpq++/pgcursordb.h" |
207 | 32 |
|
208 | 33 | #endif/* LIBPQXX_H */ |