diff options
author | Bruce Momjian <bruce@momjian.us> | 1999-05-23 01:04:07 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 1999-05-23 01:04:07 +0000 |
commit | b14c99d8d6bdb3155fe54e6f24e8aac32a09ed81 (patch) | |
tree | 0b63fc00dfff28c643cfafe587777ab11e5733c5 /src/interfaces/libpq++/pgdatabase.cc | |
parent | 795f6ca66ab734559e6eed7a9466eb19b58f3166 (diff) |
Here it is. Remove or rename the current interfaces/libpq++ and untar
this file in interfaces/
It will all need to be checked in. I used the char *rcsid[] method for
cvs ids so it can be strings | grep'd to find version numbers. The new
version for the library is 3.0.
Run configure from src/ to create the Makefile and it should be good to
go.
I did minimal documentation references in the README, I'll see if I can
get something to Tom Lockhart rather quickly.
Vince.
Diffstat (limited to 'src/interfaces/libpq++/pgdatabase.cc')
-rw-r--r-- | src/interfaces/libpq++/pgdatabase.cc | 152 |
1 files changed, 152 insertions, 0 deletions
diff --git a/src/interfaces/libpq++/pgdatabase.cc b/src/interfaces/libpq++/pgdatabase.cc new file mode 100644 index 00000000000..10fcdd0e92d --- /dev/null +++ b/src/interfaces/libpq++/pgdatabase.cc @@ -0,0 +1,152 @@ +/*------------------------------------------------------------------------- + * + * FILE + * pgdatabase.cpp + * + * DESCRIPTION + * implementation of the PgDatabase class. + * PgDatabase encapsulates some utility routines + * + * Copyright (c) 1994, Regents of the University of California + * + * IDENTIFICATION + * + *------------------------------------------------------------------------- + */ + +#include "pgdatabase.h" + +static char rcsid[] = "$Id: pgdatabase.cc,v 1.1 1999/05/23 01:04:01 momjian Exp $"; + +void PgDatabase::DisplayTuples(FILE *out = 0, int fillAlign = 1, + const char* fieldSep = "|",int printHeader = 1, int quiet = 0) +{ +PQprintOpt po; + + memset(&po,0,sizeof(po)); + + po.align = (pqbool)fillAlign; + po.fieldSep = (char *)fieldSep; + po.header = (pqbool)printHeader; + + PQprint(out,pgResult,&po); + +} + + + + +void PgDatabase::PrintTuples(FILE *out = 0, int printAttName = 1, int terseOutput = 0, int width = 0) +{ +PQprintOpt po; + + memset(&po,0,sizeof(po)); + + po.align = (pqbool)width; + + if(terseOutput) po.fieldSep = strdup("|"); + else po.fieldSep = ""; + + po.header = (pqbool)printAttName; + + PQprint(out,pgResult,&po); + +} + + + +int PgDatabase::Tuples() +{ +return PQntuples(pgResult); +} + + +int PgDatabase::Fields() +{ +return PQnfields(pgResult); +} + + +const char* PgDatabase::FieldName(int field_num) +{ +return PQfname(pgResult, field_num); +} + + +int PgDatabase::FieldNum(const char* field_name) +{ +return PQfnumber(pgResult, field_name); +} + + +Oid PgDatabase::FieldType(int field_num) +{ +return PQftype(pgResult, field_num); +} + + +Oid PgDatabase::FieldType(const char* field_name) +{ +return PQftype(pgResult, FieldNum(field_name)); +} + + +short PgDatabase::FieldSize(int field_num) +{ +return PQfsize(pgResult, field_num); +} + + +short PgDatabase::FieldSize(const char* field_name) +{ +return PQfsize(pgResult, FieldNum(field_name)); +} + + +const char* PgDatabase::GetValue(int tup_num, int field_num) +{ +return PQgetvalue(pgResult, tup_num, field_num); +} + + +const char* PgDatabase::GetValue(int tup_num, const char* field_name) +{ +return PQgetvalue(pgResult, tup_num, FieldNum(field_name)); +} + + +int PgDatabase::GetLength(int tup_num, int field_num) +{ +return PQgetlength(pgResult, tup_num, field_num); +} + + +int PgDatabase::GetLength(int tup_num, const char* field_name) +{ +return PQgetlength(pgResult, tup_num, FieldNum(field_name)); +} + +int PgDatabase::GetLine(char* string, int length) +{ +return PQgetline(pgConn, string, length); +} + + +void PgDatabase::PutLine(const char* string) +{ +PQputline(pgConn, string); +} + + +const char* PgDatabase::OidStatus() +{ +return PQoidStatus(pgResult); +} + + +int PgDatabase::EndCopy() +{ +return PQendcopy(pgConn); +} + + |