[gnome-db]Changes in c++ binding, if you don't mind
- From: Kuba <kpuchar poczta onet pl>
- To: gnome-db-list gnome org
- Subject: [gnome-db]Changes in c++ binding, if you don't mind
- Date: Mon, 2 Apr 2001 10:35:44 +0200
I recently started to play a little with gnome-db using its c++ binding. I made some changes and fixes. If you find it useful, please apply it. I don't have access to CVS (firewall).
Changes are as follows:
1. I have moved all of the class declarations into gda namespace and removed gda prefix from class names.
2. C header #includes are now in extern "C" section, so programs using C++ binding now links properly.
3. Command::execute () method now returns recordset returned from gda_command_execute () function, so now you can do something useful with it.
The patch made out of the whole bindings/c++ directory on libgda-0.2.3 version:
Only in c++: Makefile
diff -u c++.new/Makefile.in c++/Makefile.in
--- c++.new/Makefile.in Mon Jan 1 15:31:40 2001
+++ c++/Makefile.in Thu Feb 15 01:43:40 2001
@@ -72,7 +72,7 @@
GDA_CLIENT_LIBS = @GDA_CLIENT_LIBS@
GDA_PROVIDER_CFLAGS = @GDA_PROVIDER_CFLAGS@
GDA_PROVIDER_LIBS = @GDA_PROVIDER_LIBS@
-GDA_oafinfodir = @GDA_oafinfodir@
+GDA_oafdir = @GDA_oafdir@
GENCAT = @GENCAT@
GLIB_CFLAGS = @GLIB_CFLAGS@
GLIB_CONFIG = @GLIB_CONFIG@
@@ -129,6 +129,10 @@
USE_INCLUDED_LIBINTL = @USE_INCLUDED_LIBINTL@
USE_NLS = @USE_NLS@
VERSION = @VERSION@
+XML_I18N_EXTRACT = @XML_I18N_EXTRACT@
+XML_I18N_MERGE = @XML_I18N_MERGE@
+XML_I18N_TOOLS_PERL = @XML_I18N_TOOLS_PERL@
+XML_I18N_UPDATE = @XML_I18N_UPDATE@
l = @l@
perl_val = @perl_val@
diff -u c++.new/gdaBatch.cpp c++/gdaBatch.cpp
--- c++.new/gdaBatch.cpp Sun Nov 5 20:12:37 2000
+++ c++/gdaBatch.cpp Wed Mar 21 22:08:20 2001
@@ -19,63 +19,65 @@
#include "config.h"
#include "gdaBatch.h"
-gdaBatch::gdaBatch() {
+using namespace gda;
+
+Batch::Batch() {
_gda_batch = gda_batch_new();
}
-gdaBatch::gdaBatch(Gda_Batch *a) {
+Batch::Batch(Gda_Batch *a) {
_gda_batch = a;
}
-gdaBatch::~gdaBatch() {
+Batch::~Batch() {
if (_gda_batch) gda_batch_free(_gda_batch);
}
-void gdaBatch::setCStruct(Gda_Batch *job) {
+void Batch::setCStruct(Gda_Batch *job) {
_gda_batch = job;
}
-Gda_Batch *gdaBatch::getCStruct() {
+Gda_Batch *Batch::getCStruct() {
return _gda_batch;
}
-gboolean gdaBatch::loadFile(const gchar *filename, gboolean clean) {
+gboolean Batch::loadFile(const gchar *filename, gboolean clean) {
return gda_batch_load_file(_gda_batch,filename,clean);
}
-void gdaBatch::addCommand(const gchar *cmd) {
+void Batch::addCommand(const gchar *cmd) {
gda_batch_add_command(_gda_batch,cmd);
}
-void gdaBatch::clear() {
+void Batch::clear() {
gda_batch_clear(_gda_batch);
}
-gboolean gdaBatch::start() {
+gboolean Batch::start() {
return gda_batch_start(_gda_batch);
}
-void gdaBatch::stop() {
+void Batch::stop() {
gda_batch_stop(_gda_batch);
}
-gboolean gdaBatch::isRunning() {
+gboolean Batch::isRunning() {
return gda_batch_is_running(_gda_batch);
}
-gdaConnection* gdaBatch::getConnection() {
+Connection* Batch::getConnection() {
return cnc;
}
-void gdaBatch::setConnection(gdaConnection *a) {
+void Batch::setConnection(Connection *a) {
cnc = a;
}
-gboolean gdaBatch::getTransactionMode() {
+gboolean Batch::getTransactionMode() {
return gda_batch_get_transaction_mode(_gda_batch);
}
-void gdaBatch::setTransactionMode(gboolean mode) {
+void Batch::setTransactionMode(gboolean mode) {
gda_batch_set_transaction_mode(_gda_batch,mode);
}
diff -u c++.new/gdaBatch.h c++/gdaBatch.h
--- c++.new/gdaBatch.h Thu Aug 10 11:32:53 2000
+++ c++/gdaBatch.h Wed Mar 21 22:08:20 2001
@@ -21,11 +21,13 @@
#include "gdaIncludes.h"
-class gdaBatch {
+namespace gda {
+
+class Batch {
public:
- gdaBatch();
- gdaBatch(Gda_Batch *a);
- ~gdaBatch();
+ Batch();
+ Batch(Gda_Batch *a);
+ ~Batch();
Gda_Batch *getCStruct();
void setCStruct(Gda_Batch *job);
@@ -38,15 +40,15 @@
void stop();
gboolean isRunning();
- gdaConnection* getConnection();
- void setConnection(gdaConnection *cnc);
+ Connection* getConnection();
+ void setConnection(Connection *cnc);
gboolean getTransactionMode();
void setTransactionMode(gboolean mode);
private:
Gda_Batch* _gda_batch;
- gdaConnection *cnc;
-
-};
+ Connection *cnc;
-#endif
+}; // class Batch
+}; // namespace gda
+#endif // __gda_bindings_cpp_gdaBatchH
diff -u c++.new/gdaCommand.cpp c++/gdaCommand.cpp
--- c++.new/gdaCommand.cpp Thu Dec 21 00:21:01 2000
+++ c++/gdaCommand.cpp Thu Mar 22 21:33:02 2001
@@ -19,61 +19,74 @@
#include "config.h"
#include "gdaCommand.h"
-gdaCommand::gdaCommand() {
+using namespace gda;
+
+Command::Command() {
_gda_command = gda_command_new();
}
-gdaCommand::~gdaCommand() {
+Command::~Command() {
if (_gda_command) gda_command_free(_gda_command);
}
-Gda_Command *gdaCommand::getCStruct() {
+Gda_Command *Command::getCStruct() {
return _gda_command;
}
-void gdaCommand::setCStruct(Gda_Command *cmd) {
+void Command::setCStruct(Gda_Command *cmd) {
_gda_command = cmd;
}
-gdaConnection *gdaCommand::getConnection() {
+Connection *Command::getConnection() {
return cnc;
}
-gint gdaCommand::setConnection(gdaConnection *a) {
+gint Command::setConnection(Connection *a) {
cnc = a;
return gda_command_set_connection(_gda_command,cnc->getCStruct());
}
-gchar* gdaCommand::getText() {
+gchar* Command::getText() {
return gda_command_get_text(_gda_command);
}
-void gdaCommand::setText(gchar *text) {
+void Command::setText(gchar *text) {
gda_command_set_text(_gda_command,text);
}
-GDA_CommandType gdaCommand::getCmdType() {
+GDA_CommandType Command::getCmdType() {
return gda_command_get_cmd_type(_gda_command);
}
-void gdaCommand::setCmdType(GDA_CommandType type) {
+void Command::setCmdType(GDA_CommandType type) {
gda_command_set_cmd_type(_gda_command, type);
}
-gdaRecordset* gdaCommand::execute(gulong* reccount, gulong flags) {
- gda_command_execute(_gda_command,reccount,flags);
+Recordset* Command::execute(gulong* reccount, gulong flags) {
+
+ Gda_Recordset *pGdaRecordset = NULL;
+ pGdaRecordset = gda_command_execute(_gda_command,reccount,flags);
+
+ Recordset* pRecordset = NULL;
+ if (pGdaRecordset != NULL) {
+ pRecordset = new Recordset (pGdaRecordset, cnc);
+ } else {
+ pRecordset = new Recordset ();
+ }
+
+ return pRecordset;
}
-//void gdaCommand::createParameter(gchar* name, GDA_ParameterDirection inout, gdaValue *value) {
+//void Command::createParameter(gchar* name, GDA_ParameterDirection inout, gdaValue *value) {
// FIXME If we don't use GDA_Value, how do use use the c function gda_command_create_parameter?
// GDA_Value v(value->getCValue());
// gda_command_create_parameter(_gda_command,name,inout,&v);
//}
-glong gdaCommand::getTimeout() {
+glong Command::getTimeout() {
return gda_command_get_timeout(_gda_command);
}
-void gdaCommand::setTimeout(glong timeout) {
+void Command::setTimeout(glong timeout) {
gda_command_set_timeout(_gda_command,timeout);
}
diff -u c++.new/gdaCommand.h c++/gdaCommand.h
--- c++.new/gdaCommand.h Thu Dec 21 00:20:10 2000
+++ c++/gdaCommand.h Wed Mar 21 22:08:20 2001
@@ -21,29 +21,32 @@
#include "gdaIncludes.h"
-class gdaCommand {
+namespace gda {
+
+class Command {
public:
- gdaCommand();
- gdaCommand(Gda_Command *cmd);
- ~gdaCommand();
+ Command();
+ Command(Gda_Command *cmd);
+ ~Command();
Gda_Command *getCStruct();
void setCStruct(Gda_Command *cmd);
- gdaConnection *getConnection();
- gint setConnection(gdaConnection *a);
+ Connection *getConnection();
+ gint setConnection(Connection *a);
gchar *getText();
void setText(gchar *text);
GDA_CommandType getCmdType();
void setCmdType(GDA_CommandType type);
- gdaRecordset *execute(gulong* reccount, gulong flags);
- void createParameter(gchar* name, GDA_ParameterDirection inout, gdaValue *value);
+ Recordset *execute(gulong* reccount, gulong flags);
+ void createParameter(gchar* name, GDA_ParameterDirection inout, Value *value);
glong getTimeout();
void setTimeout(glong timeout);
private:
- gdaConnection *cnc;
+ Connection *cnc;
Gda_Command* _gda_command;
-};
+}; // class Command
+}; // namespace gda
-#endif
+#endif // __gda_bindings_cpp_gdaCommandH
diff -u c++.new/gdaConnection.cpp c++/gdaConnection.cpp
--- c++.new/gdaConnection.cpp Thu Dec 21 01:13:41 2000
+++ c++/gdaConnection.cpp Wed Mar 21 22:08:20 2001
@@ -20,141 +20,143 @@
#include "config.h"
#include "gdaConnection.h"
-gdaConnection::gdaConnection() {
+using namespace gda;
+
+Connection::Connection() {
_gda_connection = NULL;
}
-gdaConnection::gdaConnection(Gda_Connection *a) {
+Connection::Connection(Gda_Connection *a) {
_gda_connection = a;
}
-gdaConnection::gdaConnection(CORBA_ORB orb) {
+Connection::Connection(CORBA_ORB orb) {
_gda_connection = gda_connection_new(orb);
}
-gdaConnection::~gdaConnection() {
+Connection::~Connection() {
if (_gda_connection) gda_connection_free(_gda_connection);
}
-Gda_Connection* gdaConnection::getCStruct() {
+Gda_Connection* Connection::getCStruct() {
return _gda_connection;
}
-void gdaConnection::setCStruct(Gda_Connection *cnc) {
+void Connection::setCStruct(Gda_Connection *cnc) {
_gda_connection = cnc;
}
-void gdaConnection::setProvider(gchar* name) {
+void Connection::setProvider(gchar* name) {
gda_connection_set_provider(_gda_connection,name);
}
-const gchar* gdaConnection::getProvider() {
+const gchar* Connection::getProvider() {
return gda_connection_get_provider(_gda_connection);
}
-gboolean gdaConnection::supports(GDA_Connection_Feature feature) {
+gboolean Connection::supports(GDA_Connection_Feature feature) {
return gda_connection_supports(_gda_connection,feature);
}
-void gdaConnection::setDefaultDB(gchar* dsn) {
+void Connection::setDefaultDB(gchar* dsn) {
gda_connection_set_default_db(_gda_connection,dsn);
}
-gint gdaConnection::open(gchar* dsn, gchar* user,gchar* pwd ) {
+gint Connection::open(gchar* dsn, gchar* user,gchar* pwd ) {
return gda_connection_open(_gda_connection,dsn,user,pwd);
}
-void gdaConnection::close() {
+void Connection::close() {
gda_connection_close(_gda_connection);
}
-gdaErrorList* gdaConnection::getErrors() {
- gdaErrorList *a = NULL;
- a = new gdaErrorList(gda_connection_get_errors(_gda_connection));
+ErrorList* Connection::getErrors() {
+ ErrorList *a = NULL;
+ a = new ErrorList(gda_connection_get_errors(_gda_connection));
return a;
}
-gint gdaConnection::beginTransaction() {
+gint Connection::beginTransaction() {
return gda_connection_begin_transaction(_gda_connection);
}
-gint gdaConnection::commitTransaction() {
+gint Connection::commitTransaction() {
return gda_connection_commit_transaction(_gda_connection);
}
-gint gdaConnection::rollbackTransaction() {
+gint Connection::rollbackTransaction() {
return gda_connection_rollback_transaction(_gda_connection);
}
-gdaRecordset* gdaConnection::execute(gchar* txt, gulong* reccount, gulong flags) {
+Recordset* Connection::execute(gchar* txt, gulong* reccount, gulong flags) {
Gda_Recordset *b = NULL;
- gdaRecordset *a = NULL;
+ Recordset *a = NULL;
b = gda_connection_execute(_gda_connection,txt,reccount,flags);
- a = new gdaRecordset(b,this);
+ a = new Recordset(b,this);
return a;
}
-gint gdaConnection::startLogging(gchar* filename) {
+gint Connection::startLogging(gchar* filename) {
return gda_connection_start_logging(_gda_connection,filename);
}
-gint gdaConnection::stopLogging() {
+gint Connection::stopLogging() {
return gda_connection_stop_logging(_gda_connection);
}
-void gdaConnection::addSingleError(gdaError* error) {
+void Connection::addSingleError(Error* error) {
gda_connection_add_single_error(_gda_connection,error->getCStruct());
}
-void gdaConnection::addErrorlist(gdaErrorList* list) {
+void Connection::addErrorlist(ErrorList* list) {
gda_connection_add_errorlist(_gda_connection,list->errors());
}
-gboolean gdaConnection::isOpen() {
+gboolean Connection::isOpen() {
return gda_connection_is_open(_gda_connection);
}
-gchar* gdaConnection::getDSN() {
+gchar* Connection::getDSN() {
return gda_connection_get_dsn(_gda_connection);
}
-gchar* gdaConnection::getUser() {
+gchar* Connection::getUser() {
return gda_connection_get_user(_gda_connection);
}
-glong gdaConnection::getFlags() {
+glong Connection::getFlags() {
return gda_connection_get_flags(_gda_connection);
}
-void gdaConnection::setFlags(glong flags) {
+void Connection::setFlags(glong flags) {
gda_connection_set_flags(_gda_connection,flags);
}
-glong gdaConnection::getCmdTimeout() {
+glong Connection::getCmdTimeout() {
return gda_connection_get_cmd_timeout(_gda_connection);
}
-void gdaConnection::setCmdTimeout(glong cmd_timeout) {
+void Connection::setCmdTimeout(glong cmd_timeout) {
gda_connection_set_cmd_timeout(_gda_connection,cmd_timeout);
}
-glong gdaConnection::getConnectTimeout() {
+glong Connection::getConnectTimeout() {
return gda_connection_get_connect_timeout(_gda_connection);
}
-void gdaConnection::setConnectTimeout(glong timeout) {
+void Connection::setConnectTimeout(glong timeout) {
gda_connection_set_connect_timeout(_gda_connection,timeout);
}
-GDA_CursorLocation gdaConnection::getCursorLocation() {
+GDA_CursorLocation Connection::getCursorLocation() {
return gda_connection_get_cursor_location(_gda_connection);
}
-void gdaConnection::setCursorLocation(GDA_CursorLocation cursor) {
+void Connection::setCursorLocation(GDA_CursorLocation cursor) {
gda_connection_set_cursor_location(_gda_connection,cursor);
}
-gchar* gdaConnection::getVersion() {
+gchar* Connection::getVersion() {
return gda_connection_get_version(_gda_connection);
}
diff -u c++.new/gdaConnection.h c++/gdaConnection.h
--- c++.new/gdaConnection.h Thu Dec 21 01:13:55 2000
+++ c++/gdaConnection.h Wed Mar 21 22:08:20 2001
@@ -22,12 +22,14 @@
#include "gdaIncludes.h"
-class gdaConnection {
+namespace gda {
+
+class Connection {
public:
- gdaConnection();
- gdaConnection(Gda_Connection *a);
- gdaConnection(CORBA_ORB orb);
- ~gdaConnection();
+ Connection();
+ Connection(Gda_Connection *a);
+ Connection(CORBA_ORB orb);
+ ~Connection();
Gda_Connection* getCStruct();
void setCStruct(Gda_Connection *cnc);
@@ -38,16 +40,16 @@
void setDefaultDB(gchar* dsn);
gint open(gchar* dsn, gchar* user,gchar* pwd);
void close();
- gdaErrorList *getErrors();
+ ErrorList *getErrors();
gint beginTransaction();
gint commitTransaction();
gint rollbackTransaction();
- gdaRecordset* execute(gchar* txt, gulong* reccount, gulong flags);
+ Recordset* execute(gchar* txt, gulong* reccount, gulong flags);
gint startLogging(gchar* filename);
gint stopLogging();
- void addSingleError(gdaError* error);
- void addErrorlist(gdaErrorList* list);
+ void addSingleError(Error* error);
+ void addErrorlist(ErrorList* list);
gboolean isOpen();
gchar* getDSN();
@@ -65,6 +67,7 @@
private:
Gda_Connection* _gda_connection;
-};
+}; // class Connection
+}; // namespace gda
#endif // __gda_bindings_cpp_gdaConnectionH
diff -u c++.new/gdaError.cpp c++/gdaError.cpp
--- c++.new/gdaError.cpp Sun Nov 5 20:12:37 2000
+++ c++/gdaError.cpp Wed Mar 21 22:08:20 2001
@@ -19,55 +19,53 @@
#include "config.h"
#include "gdaError.h"
-gdaError::gdaError() {
+using namespace gda;
+
+Error::Error() {
_gda_error = gda_error_new();
}
-gdaError::gdaError(Gda_Error *e) {
+Error::Error(Gda_Error *e) {
_gda_error = e;
}
-gdaError::~gdaError() {
+Error::~Error() {
if (_gda_error) gda_error_free(_gda_error);
}
-Gda_Error *gdaError::getCStruct() {
+Gda_Error *Error::getCStruct() {
return _gda_error;
}
-void gdaError::setCStruct(Gda_Error *e) {
+void Error::setCStruct(Gda_Error *e) {
_gda_error = e;
}
-const gchar* gdaError::description() {
+const gchar* Error::description() {
return gda_error_description(_gda_error);
}
-const glong gdaError::number() {
+const glong Error::number() {
return gda_error_number(_gda_error);
}
-const gchar* gdaError::source() {
+const gchar* Error::source() {
return gda_error_source(_gda_error);
}
-const gchar* gdaError::helpurl() {
+const gchar* Error::helpurl() {
return gda_error_helpurl(_gda_error);
}
-const gchar* gdaError::sqlstate() {
+const gchar* Error::sqlstate() {
return gda_error_sqlstate(_gda_error);
}
-const gchar* gdaError::nativeMsg() {
+const gchar* Error::nativeMsg() {
return gda_error_nativeMsg(_gda_error);
}
-const gchar* gdaError::realcommand() {
+const gchar* Error::realcommand() {
return gda_error_realcommand(_gda_error);
}
-
-
-
-
diff -u c++.new/gdaError.h c++/gdaError.h
--- c++.new/gdaError.h Thu Aug 10 11:32:53 2000
+++ c++/gdaError.h Wed Mar 21 22:08:20 2001
@@ -21,11 +21,13 @@
#include "gdaIncludes.h"
-class gdaError {
+namespace gda {
+
+class Error {
public:
- gdaError();
- gdaError(Gda_Error *e);
- ~gdaError();
+ Error();
+ Error(Gda_Error *e);
+ ~Error();
Gda_Error *getCStruct();
void setCStruct(Gda_Error *e);
@@ -40,9 +42,7 @@
private:
Gda_Error* _gda_error;
-};
+}; // class Error
+}; // namespace gda
-#endif
-
-
-
+#endif // __gda_bindings_cpp_gdaErrorH
diff -u c++.new/gdaErrorList.cpp c++/gdaErrorList.cpp
--- c++.new/gdaErrorList.cpp Sun Nov 5 20:12:37 2000
+++ c++/gdaErrorList.cpp Wed Mar 21 22:08:20 2001
@@ -25,30 +25,32 @@
// a list of gdaErrors would make more sense under C++. You *can* do it
// the other way.. -- cdw
-gdaErrorList::gdaErrorList(CORBA_Environment* ev) {
+using namespace gda;
+
+ErrorList::ErrorList(CORBA_Environment* ev) {
_errors = gda_errors_from_exception(ev);
}
-gdaErrorList::gdaErrorList(GList *errorList) {
+ErrorList::ErrorList(GList *errorList) {
_errors = errorList;
}
-gdaErrorList::~gdaErrorList() {
+ErrorList::~ErrorList() {
if (_errors) gda_error_list_free(_errors);
}
-GList* gdaErrorList::getCStruct() {
+GList* ErrorList::getCStruct() {
return _errors;
}
-GList *gdaErrorList::errors() {
+GList *ErrorList::errors() {
return _errors;
}
-void gdaErrorList::setCStruct(GList *errorList) {
+void ErrorList::setCStruct(GList *errorList) {
_errors = errorList;
}
-
-
+
+
diff -u c++.new/gdaErrorList.h c++/gdaErrorList.h
--- c++.new/gdaErrorList.h Thu Aug 10 11:32:53 2000
+++ c++/gdaErrorList.h Wed Mar 21 22:08:20 2001
@@ -21,11 +21,13 @@
#include "gdaIncludes.h"
-class gdaErrorList {
+namespace gda {
+
+class ErrorList {
public:
- gdaErrorList(CORBA_Environment* ev);
- gdaErrorList(GList *errorList);
- ~gdaErrorList();
+ ErrorList(CORBA_Environment* ev);
+ ErrorList(GList *errorList);
+ ~ErrorList();
GList *getCStruct();
void setCStruct(GList *errorList);
@@ -33,7 +35,7 @@
private:
GList* _errors;
-};
-
-#endif
-
+}; // class ErrorList
+}; // namespace gda
+
+#endif // __gda_bindings_cpp_gdaErrorListH
diff -u c++.new/gdaField.cpp c++/gdaField.cpp
--- c++.new/gdaField.cpp Sun Nov 5 20:12:37 2000
+++ c++/gdaField.cpp Wed Mar 21 22:08:20 2001
@@ -19,46 +19,48 @@
#include "config.h"
#include "gdaField.h"
-gdaField::gdaField() {
+using namespace gda;
+
+Field::Field() {
_gda_field = NULL;
}
-gdaField::gdaField(Gda_Field *f) {
+Field::Field(Gda_Field *f) {
_gda_field = f;
}
-gdaField::~gdaField() {
+Field::~Field() {
// if (_gda_field) gda_field_free(_gda_field);
// FIXME What?! no gda_field_free?!?!
}
-Gda_Field *gdaField::getCStruct() {
+Gda_Field *Field::getCStruct() {
return _gda_field;
}
-void gdaField::setCStruct(Gda_Field *f) {
+void Field::setCStruct(Gda_Field *f) {
_gda_field = f;
}
-bool gdaField::isNull() {
+bool Field::isNull() {
return gda_field_isnull(_gda_field);
}
-gdaValue *gdaField::realValue() {
- gdaValue *v = new gdaValue(_gda_field->real_value);
+Value *Field::realValue() {
+ Value *v = new Value(_gda_field->real_value);
return v;
}
-gdaValue *gdaField::origValue() {
- gdaValue *v = new gdaValue(_gda_field->original_value);
+Value *Field::origValue() {
+ Value *v = new Value(_gda_field->original_value);
return v;
}
-GDA_ValueType gdaField::typeCode() {
+GDA_ValueType Field::typeCode() {
return _gda_field->real_value->_u.v._d;
}
-gchar *gdaField::typeCodeString() {
+gchar *Field::typeCodeString() {
// Convenience function to get the string of the field's value type
// without resorting to the C commands...
gchar *a = 0;
@@ -72,76 +74,76 @@
return a;
}
-gchar gdaField::getTinyint() {
+gchar Field::getTinyint() {
return gda_field_tinyint(_gda_field);
}
-glong gdaField::getBigint() {
+glong Field::getBigint() {
return gda_field_bigint(_gda_field);
}
-bool gdaField::getBoolean() {
+bool Field::getBoolean() {
return gda_field_boolean(_gda_field);
}
-GDA_Date gdaField::getDate() {
+GDA_Date Field::getDate() {
return gda_field_date(_gda_field);
}
-GDA_DbDate gdaField::getDBdate() {
+GDA_DbDate Field::getDBdate() {
return gda_field_dbdate(_gda_field);
}
-GDA_DbTime gdaField::getDBtime() {
+GDA_DbTime Field::getDBtime() {
return gda_field_dbtime(_gda_field);
}
-GDA_DbTimestamp gdaField::getDBtstamp() {
+GDA_DbTimestamp Field::getDBtstamp() {
return gda_field_timestamp(_gda_field);
}
-gdouble gdaField::getDouble() {
+gdouble Field::getDouble() {
return gda_field_double(_gda_field);
}
-glong gdaField::getInteger() {
+glong Field::getInteger() {
return gda_field_integer(_gda_field);
}
-// GDA_VarBinString gdaField::getVarLenString() {
+// GDA_VarBinString Field::getVarLenString() {
// return gda_field_varbin(_gda_field);
// }
-// GDA_VarBinString gdaField::getFixLenString() {
+// GDA_VarBinString Field::getFixLenString() {
// return gda_field_fixbin(_gda_field);
// }
-gchar *gdaField::getLongVarChar() {
+gchar *Field::getLongVarChar() {
return gda_field_longvarchar(_gda_field);
}
-gfloat gdaField::getFloat() {
+gfloat Field::getFloat() {
return gda_field_single(_gda_field);
// return _gda_field->real_value->_u.v._u.f;
}
-gint gdaField::getSmallInt() {
+gint Field::getSmallInt() {
return gda_field_smallint(_gda_field);
}
-gulong gdaField::getULongLongInt() {
+gulong Field::getULongLongInt() {
return gda_field_ubingint(_gda_field);
}
-guint gdaField::getUSmallInt() {
+guint Field::getUSmallInt() {
return gda_field_usmallint(_gda_field);
}
-//gchar *gdaField::getText() {
+//gchar *Field::getText() {
// return getNewString();
//}
//
-//gchar *gdaField::getNewString() {
+//gchar *Field::getNewString() {
// // Find the size of the value, then make a string that big
// // then put it into the string.
// // FIXME: Can we use getLongVarChar instead of this? -- cdw
@@ -153,35 +155,35 @@
// return a;
//}
-gchar *gdaField::putInString(gchar *bfr, gint maxLength) {
+gchar *Field::putInString(gchar *bfr, gint maxLength) {
return gda_stringify_value(bfr,maxLength,_gda_field);
}
-gint gdaField::actualSize() {
+gint Field::actualSize() {
return gda_field_actual_size(_gda_field);
}
-glong gdaField::definedSize() {
+glong Field::definedSize() {
return gda_field_defined_size(_gda_field);
}
-gchar *gdaField::name() {
+gchar *Field::name() {
return gda_field_name(_gda_field);
}
-glong gdaField::scale() {
+glong Field::scale() {
return gda_field_scale(_gda_field);
}
-GDA_ValueType gdaField::type() {
+GDA_ValueType Field::type() {
return gda_field_type(_gda_field);
}
-glong gdaField::cType() {
+glong Field::cType() {
return gda_field_cType(_gda_field);
}
-glong gdaField::nativeType() {
+glong Field::nativeType() {
return gda_field_nativeType(_gda_field);
}
diff -u c++.new/gdaField.h c++/gdaField.h
--- c++.new/gdaField.h Thu Aug 10 11:32:53 2000
+++ c++/gdaField.h Wed Mar 21 22:08:20 2001
@@ -21,17 +21,19 @@
#include "gdaIncludes.h"
-class gdaField {
+namespace gda {
+
+class Field {
public:
- gdaField();
- gdaField(Gda_Field *f);
- ~gdaField();
+ Field();
+ Field(Gda_Field *f);
+ ~Field();
Gda_Field *getCStruct();
void setCStruct(Gda_Field *f);
- gdaValue *realValue();
- gdaValue *origValue();
+ Value *realValue();
+ Value *origValue();
// What's shadowValue for? FIXME
bool isNull();
@@ -46,7 +48,7 @@
GDA_DbTime getDBtime();
GDA_DbTimestamp getDBtstamp();
gdouble getDouble();
- glong getInteger();
+ glong getInteger();
// GDA_VarBinString getVarLenString();
// GDA_VarBinString getFixLenString();
gchar *getLongVarChar();
@@ -69,6 +71,7 @@
private:
Gda_Field *_gda_field;
-};
+}; // class Field
+}; // namespace gda
-#endif
+#endif // __gda_bindings_cpp_gdaFieldH
diff -u c++.new/gdaIncludes.h c++/gdaIncludes.h
--- c++.new/gdaIncludes.h Thu Aug 10 11:32:53 2000
+++ c++/gdaIncludes.h Thu Mar 22 21:03:11 2001
@@ -15,16 +15,20 @@
* License along with this library; if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+
+namespace gda {
+ class Batch;
+ class Command;
+ class Connection;
+ class Error;
+ class ErrorList;
+ class Field;
+ class Recordset;
+ class Value;
+}; // namespace gda
-class gdaBatch;
-class gdaCommand;
-class gdaConnection;
-class gdaError;
-class gdaErrorList;
-class gdaField;
-class gdaRecordset;
-class gdaValue;
-
+extern "C"
+{
#include "glib.h"
#include "gda-client.h"
@@ -34,6 +38,7 @@
#include "gda-error.h"
#include "gda-field.h"
#include "gda-recordset.h"
+}
#include "gdaBatch.h"
#include "gdaCommand.h"
diff -u c++.new/gdaRecordset.cpp c++/gdaRecordset.cpp
--- c++.new/gdaRecordset.cpp Sun Nov 5 20:12:37 2000
+++ c++/gdaRecordset.cpp Thu Mar 22 21:30:34 2001
@@ -19,138 +19,140 @@
#include "config.h"
#include "gdaRecordset.h"
-gdaRecordset::gdaRecordset() {
+using namespace gda;
+
+Recordset::Recordset() {
_gda_recordset = (Gda_Recordset *) gda_recordset_new();
cnc = NULL;
}
-gdaRecordset::gdaRecordset(Gda_Recordset *rst, gdaConnection *cnca) {
+Recordset::Recordset(Gda_Recordset *rst, Connection *cnca) {
_gda_recordset = rst;
cnc = cnca;
}
-gdaRecordset::gdaRecordset(Gda_Recordset *rst, Gda_Connection *cnca) {
+Recordset::Recordset(Gda_Recordset *rst, Gda_Connection *cnca) {
_gda_recordset = rst;
- cnc = new gdaConnection();
+ cnc = new Connection();
cnc->setCStruct(cnca);
}
-gdaRecordset::~gdaRecordset() {
+Recordset::~Recordset() {
if (_gda_recordset) gda_recordset_free(_gda_recordset);
}
-Gda_Recordset* gdaRecordset::getCStruct() {
+Gda_Recordset* Recordset::getCStruct() {
return _gda_recordset;
}
-void gdaRecordset::setCStruct(Gda_Recordset *rst) {
+void Recordset::setCStruct(Gda_Recordset *rst) {
_gda_recordset = rst;
}
-void gdaRecordset::setName(gchar* name) {
- gda_recordset_set_name(_gda_recordset,name);
+void Recordset::setName(gchar* name) {
+// gda_recordset_set_name(_gda_recordset,name);
}
-void gdaRecordset::getName(gchar* name) {
- gda_recordset_get_name(_gda_recordset,name);
+void Recordset::getName(gchar* name) {
+// gda_recordset_get_name(_gda_recordset,name);
}
-void gdaRecordset::close() {
+void Recordset::close() {
gda_recordset_close(_gda_recordset);
}
-gdaField* gdaRecordset::field(gchar* name) {
- gdaField *a = NULL;
- a = new gdaField(gda_recordset_field_name(_gda_recordset,name));
+Field* Recordset::field(gchar* name) {
+ Field *a = NULL;
+ a = new Field(gda_recordset_field_name(_gda_recordset,name));
return a;
}
-gdaField* gdaRecordset::field(gint idx) {
- gdaField *a = NULL;
- a = new gdaField(gda_recordset_field_idx(_gda_recordset,idx));
+Field* Recordset::field(gint idx) {
+ Field *a = NULL;
+ a = new Field(gda_recordset_field_idx(_gda_recordset,idx));
return a;
}
-gint gdaRecordset::bof() {
+gint Recordset::bof() {
return gda_recordset_bof(_gda_recordset);
}
-gint gdaRecordset::eof() {
+gint Recordset::eof() {
return gda_recordset_eof(_gda_recordset);
}
-gulong gdaRecordset::move (gint count, gpointer bookmark) {
+gulong Recordset::move (gint count, gpointer bookmark) {
return gda_recordset_move(_gda_recordset,count,bookmark);
}
-gulong gdaRecordset::moveFirst() {
+gulong Recordset::moveFirst() {
return gda_recordset_move_first(_gda_recordset);
}
-gulong gdaRecordset::moveLast() {
+gulong Recordset::moveLast() {
return gda_recordset_move_last(_gda_recordset);
}
-gulong gdaRecordset::moveNext() {
+gulong Recordset::moveNext() {
return gda_recordset_move_next(_gda_recordset);
}
-gulong gdaRecordset::movePrev() {
+gulong Recordset::movePrev() {
return gda_recordset_move_prev(_gda_recordset);
}
-gint gdaRecordset::rowsize() {
+gint Recordset::rowsize() {
return gda_recordset_rowsize(_gda_recordset);
}
-gulong gdaRecordset::affectedRows() {
+gulong Recordset::affectedRows() {
return gda_recordset_affected_rows(_gda_recordset);
}
-gint gdaRecordset::open(gdaCommand* cmd, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options) {
+gint Recordset::open(Command* cmd, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options) {
return gda_recordset_open(_gda_recordset,cmd->getCStruct(),cursor_type,lock_type,options);
}
-gint gdaRecordset::open(gchar* txt, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options) {
+gint Recordset::open(gchar* txt, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options) {
return gda_recordset_open_txt(_gda_recordset,txt,cursor_type,lock_type,options);
}
-gint gdaRecordset::open(gdaCommand* cmd, gdaConnection *cnac, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options) {
+gint Recordset::open(Command* cmd, Connection *cnac, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options) {
if (cnac) setConnection(cnac);
return gda_recordset_open(_gda_recordset,cmd->getCStruct(),cursor_type,lock_type,options);
}
-gint gdaRecordset::open(gchar* txt, gdaConnection *cnac, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options) {
+gint Recordset::open(gchar* txt, Connection *cnac, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options) {
if (cnac) setConnection(cnac);
return gda_recordset_open_txt(_gda_recordset,txt,cursor_type,lock_type,options);
}
-gint gdaRecordset::setConnection(gdaConnection *a) {
+gint Recordset::setConnection(Connection *a) {
cnc = a;
return gda_recordset_set_connection(_gda_recordset,cnc->getCStruct());
}
-gdaConnection* gdaRecordset::getConnection() {
+Connection* Recordset::getConnection() {
return cnc;
}
-gint gdaRecordset::addField(Gda_Field* field) {
+gint Recordset::addField(Gda_Field* field) {
return gda_recordset_add_field(_gda_recordset,field);
}
-GDA_CursorLocation gdaRecordset::getCursorloc() {
+GDA_CursorLocation Recordset::getCursorloc() {
return gda_recordset_get_cursorloc(_gda_recordset);
}
-void gdaRecordset::setCursorloc(GDA_CursorLocation loc) {
+void Recordset::setCursorloc(GDA_CursorLocation loc) {
gda_recordset_set_cursorloc(_gda_recordset,loc);
}
-GDA_CursorType gdaRecordset::getCursortype() {
+GDA_CursorType Recordset::getCursortype() {
return gda_recordset_get_cursortype(_gda_recordset);
}
-void gdaRecordset::setCursortype(GDA_CursorType type) {
+void Recordset::setCursortype(GDA_CursorType type) {
gda_recordset_set_cursortype(_gda_recordset,type);
}
diff -u c++.new/gdaRecordset.h c++/gdaRecordset.h
--- c++.new/gdaRecordset.h Thu Aug 10 11:32:54 2000
+++ c++/gdaRecordset.h Wed Mar 21 22:08:20 2001
@@ -21,12 +21,14 @@
#include "gdaIncludes.h"
-class gdaRecordset {
+namespace gda {
+
+class Recordset {
public:
- gdaRecordset();
- gdaRecordset(Gda_Recordset *rst, gdaConnection *cnc); // convenience functions!
- gdaRecordset(Gda_Recordset *rst, Gda_Connection *cnc); // convenience functions!
- ~gdaRecordset();
+ Recordset();
+ Recordset(Gda_Recordset *rst, Connection *cnc); // convenience functions!
+ Recordset(Gda_Recordset *rst, Gda_Connection *cnc); // convenience functions!
+ ~Recordset();
Gda_Recordset* getCStruct();
void setCStruct(Gda_Recordset *rst);
@@ -34,9 +36,9 @@
void setName(gchar* name);
void getName(gchar* name);
void close();
- gdaField* field(gchar* name);
+ Field* field(gchar* name);
// FIXME: possibly add a fieldText() func?
- gdaField* field(gint idx);
+ Field* field(gint idx);
gint bof();
gint eof();
gulong move (gint count, gpointer bookmark);
@@ -46,12 +48,12 @@
gulong movePrev();
gint rowsize();
gulong affectedRows();
- gint open(gdaCommand* cmd, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options); // FIXME: defaults
+ gint open(Command* cmd, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options); // FIXME: defaults
gint open(gchar* txt, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options);
- gint open(gdaCommand* cmd, gdaConnection *cnc, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options); // FIXME: defaults
- gint open(gchar* txt, gdaConnection *cnc, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options);
- gint setConnection(gdaConnection *cnc);
- gdaConnection *getConnection();
+ gint open(Command* cmd, Connection *cnc, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options); // FIXME: defaults
+ gint open(gchar* txt, Connection *cnc, GDA_CursorType cursor_type, GDA_LockType lock_type, gulong options);
+ gint setConnection(Connection *cnc);
+ Connection *getConnection();
gint addField(Gda_Field* field);
GDA_CursorLocation getCursorloc();
void setCursorloc(GDA_CursorLocation loc );
@@ -59,9 +61,10 @@
void setCursortype(GDA_CursorType type);
private:
- gdaConnection *cnc;
+ Connection *cnc;
Gda_Recordset* _gda_recordset;
-};
+}; // class Recordset
+}; // namespace gda
#endif // __gda_bindings_cpp_gdaRecordsetH
diff -u c++.new/gdaValue.cpp c++/gdaValue.cpp
--- c++.new/gdaValue.cpp Sun Nov 5 20:12:37 2000
+++ c++/gdaValue.cpp Wed Mar 21 22:08:20 2001
@@ -19,155 +19,157 @@
#include "config.h"
#include "gdaValue.h"
-gdaValue::gdaValue() {
+using namespace gda;
+
+Value::Value() {
_gda_fieldvalue = NULL;
}
-gdaValue::gdaValue(GDA_FieldValue *fv) {
+Value::Value(GDA_FieldValue *fv) {
_gda_fieldvalue = fv;
}
-gdaValue::~gdaValue() {
+Value::~Value() {
// no free function!
}
-GDA_FieldValue *gdaValue::getCStruct() {
+GDA_FieldValue *Value::getCStruct() {
return _gda_fieldvalue;
}
-//GDA_Value gdaValue::getCValue() {
+//GDA_Value Value::getCValue() {
// return _gda_fieldvalue->_u.v;
//}
-void gdaValue::setCStruct(GDA_FieldValue *v) {
+void Value::setCStruct(GDA_FieldValue *v) {
_gda_fieldvalue = v;
}
-gchar gdaValue::getTinyint() {
+gchar Value::getTinyint() {
return _gda_fieldvalue->_u.v._u.c;
}
-glong gdaValue::getBigint() {
+glong Value::getBigint() {
return _gda_fieldvalue->_u.v._u.ll;
}
-bool gdaValue::getBoolean() {
+bool Value::getBoolean() {
return _gda_fieldvalue->_u.v._u.b;
}
-GDA_Date gdaValue::getDate() {
+GDA_Date Value::getDate() {
return _gda_fieldvalue->_u.v._u.d;
}
-GDA_DbDate gdaValue::getDBdate() {
+GDA_DbDate Value::getDBdate() {
return _gda_fieldvalue->_u.v._u.dbd;
}
-GDA_DbTime gdaValue::getDBtime() {
+GDA_DbTime Value::getDBtime() {
return _gda_fieldvalue->_u.v._u.dbt;
}
-GDA_DbTimestamp gdaValue::getDBtstamp() {
+GDA_DbTimestamp Value::getDBtstamp() {
return _gda_fieldvalue->_u.v._u.dbtstamp;
}
-gdouble gdaValue::getDouble() {
+gdouble Value::getDouble() {
return _gda_fieldvalue->_u.v._u.dp;
}
-glong gdaValue::getInteger() {
+glong Value::getInteger() {
return _gda_fieldvalue->_u.v._u.i;
}
-GDA_VarBinString gdaValue::getVarLenString() {
+GDA_VarBinString Value::getVarLenString() {
return _gda_fieldvalue->_u.v._u.lvb;
}
-GDA_VarBinString gdaValue::getFixLenString() {
+GDA_VarBinString Value::getFixLenString() {
return _gda_fieldvalue->_u.v._u.fb;
}
-gchar *gdaValue::getLongVarChar() {
+gchar *Value::getLongVarChar() {
return g_strdup(_gda_fieldvalue->_u.v._u.lvc);
}
-gfloat gdaValue::getFloat() {
+gfloat Value::getFloat() {
return _gda_fieldvalue->_u.v._u.f;
}
-gint gdaValue::getSmallInt() {
+gint Value::getSmallInt() {
return _gda_fieldvalue->_u.v._u.si;
}
-gulong gdaValue::getULongLongInt() {
+gulong Value::getULongLongInt() {
return _gda_fieldvalue->_u.v._u.ull;
}
-guint gdaValue::getUSmallInt() {
+guint Value::getUSmallInt() {
return _gda_fieldvalue->_u.v._u.us;
}
-void gdaValue::set(gchar a) {
+void Value::set(gchar a) {
_gda_fieldvalue->_u.v._u.c = a;
}
-//void gdaValue::set(glong a) {
+//void Value::set(glong a) {
// _gda_fieldvalue->_u.v._u.ll = a;
//}
-void gdaValue::set(bool a) {
+void Value::set(bool a) {
_gda_fieldvalue->_u.v._u.b = a;
}
-void gdaValue::set(GDA_Date a) {
+void Value::set(GDA_Date a) {
_gda_fieldvalue->_u.v._u.d = a;
}
-void gdaValue::set(GDA_DbDate a) {
+void Value::set(GDA_DbDate a) {
_gda_fieldvalue->_u.v._u.dbd = a;
}
-void gdaValue::set(GDA_DbTime a) {
+void Value::set(GDA_DbTime a) {
_gda_fieldvalue->_u.v._u.dbt = a;
}
-void gdaValue::set(GDA_DbTimestamp a) {
+void Value::set(GDA_DbTimestamp a) {
_gda_fieldvalue->_u.v._u.dbtstamp = a;
}
-void gdaValue::set(gdouble a) {
+void Value::set(gdouble a) {
_gda_fieldvalue->_u.v._u.dp = a;
}
-void gdaValue::set(glong a) {
+void Value::set(glong a) {
_gda_fieldvalue->_u.v._u.i = a;
}
-void gdaValue::set(GDA_VarBinString a) {
+void Value::set(GDA_VarBinString a) {
_gda_fieldvalue->_u.v._u.lvb = a;
}
-// void gdaValue::set(GDA_VarBinString a) {
+// void Value::set(GDA_VarBinString a) {
// _gda_fieldvalue->_u.v._u.fb = a;
// }
-void gdaValue::set(gchar *a) {
+void Value::set(gchar *a) {
_gda_fieldvalue->_u.v._u.lvc = g_strdup(a);
}
-void gdaValue::set(gfloat a) {
+void Value::set(gfloat a) {
_gda_fieldvalue->_u.v._u.f = a;
}
-// void gdaValue::set(gint a) {
+// void Value::set(gint a) {
// _gda_fieldvalue->_u.v._u.ull = a;
// }
-void gdaValue::set(gulong a) {
+void Value::set(gulong a) {
_gda_fieldvalue->_u.v._u.us = a;
}
-void gdaValue::set(guint a) {
+void Value::set(guint a) {
_gda_fieldvalue->_u.v._u.c = a;
}
diff -u c++.new/gdaValue.h c++/gdaValue.h
--- c++.new/gdaValue.h Thu Aug 10 11:32:54 2000
+++ c++/gdaValue.h Wed Mar 21 22:08:20 2001
@@ -21,11 +21,13 @@
#include "gdaIncludes.h"
-class gdaValue {
+namespace gda {
+
+class Value {
public:
- gdaValue();
- gdaValue(GDA_FieldValue *fv);
- ~gdaValue();
+ Value();
+ Value(GDA_FieldValue *fv);
+ ~Value();
GDA_FieldValue *getCStruct();
// GDA_Value getCValue();
@@ -67,6 +69,7 @@
private:
GDA_FieldValue *_gda_fieldvalue;
-};
+}; // class Value
+}; // namespace gda
#endif
Only in c++: libgda-clientcpp.la
Best regards,
Kuba
--
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]