From 941ea94e219b6642207d4d477ca8156572bfc061 Mon Sep 17 00:00:00 2001 From: Constantin Michael Date: Thu, 29 Sep 2011 09:04:58 +0200 Subject: Add character set and national character set arguments to database constructor --- odb/oracle/database.cxx | 30 +++++++++++++++++++++--------- odb/oracle/database.hxx | 22 ++++++++++++++++++++++ 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/odb/oracle/database.cxx b/odb/oracle/database.cxx index 239fa0d..8c20faa 100644 --- a/odb/oracle/database.cxx +++ b/odb/oracle/database.cxx @@ -23,22 +23,26 @@ namespace odb database (const string& user, const string& password, const string& db, + ub2 charset, + ub2 ncharset, OCIEnv* environment, auto_ptr factory) : user_ (user), password_ (password), db_ (db), port_ (0), + charset_ (charset), + ncharset_ (ncharset_), environment_ (environment), factory_ (factory) { if (environment_ == 0) { - // @@ Be aware of encoding caveats. - // sword s (OCIEnvNlsCreate (&environment_, OCI_THREADED, - 0, 0, 0, 0, 0, 0, 0, 0)); + 0, 0, 0, 0, 0, 0, + charset, + ncharset)); if (s == OCI_ERROR) translate_error (environment_); @@ -53,6 +57,8 @@ namespace odb const string& service, const string& host, unsigned int port, + ub2 charset, + ub2 ncharset, OCIEnv* environment, auto_ptr factory) : user_ (user), @@ -60,16 +66,18 @@ namespace odb service_ (service), host_ (host), port_ (port), + charset_ (charset), + ncharset_ (ncharset), environment_ (environment), factory_ (factory) { if (environment_ == 0) { - // @@ Be aware of encoding caveats. - // sword s (OCIEnvNlsCreate (&environment_, OCI_THREADED, - 0, 0, 0, 0, 0, 0, 0, 0)); + 0, 0, 0, 0, 0, 0, + charset, + ncharset)); if (s == OCI_ERROR) translate_error (environment_); @@ -109,19 +117,23 @@ namespace odb database (int& argc, char* argv[], bool erase, + ub2 charset, + ub2 ncharset, OCIEnv* environment, auto_ptr factory) : port_ (0), + charset_ (charset), + ncharset_ (ncharset), environment_ (environment), factory_ (factory) { if (environment_ == 0) { - // @@ Be aware of encoding caveats. - // sword s (OCIEnvNlsCreate (&environment_, OCI_THREADED, - 0, 0, 0, 0, 0, 0, 0, 0)); + 0, 0, 0, 0, 0, 0, + charset, + ncharset)); if (s == OCI_ERROR) translate_error (environment_); diff --git a/odb/oracle/database.hxx b/odb/oracle/database.hxx index a9be13d..80b6fba 100644 --- a/odb/oracle/database.hxx +++ b/odb/oracle/database.hxx @@ -21,6 +21,7 @@ #include #include #include +#include #include @@ -36,6 +37,8 @@ namespace odb database (const std::string& user, const std::string& password, const std::string& db, + ub2 charset = 0, + ub2 ncharset = 0, OCIEnv* environment = 0, std::auto_ptr factory = std::auto_ptr (0)); @@ -45,6 +48,8 @@ namespace odb const std::string& service, const std::string& host = "", unsigned int port = 0, + ub2 charset = 0, + ub2 ncharset = 0, OCIEnv* environment = 0, std::auto_ptr factory = std::auto_ptr (0)); @@ -68,6 +73,8 @@ namespace odb database (int& argc, char* argv[], bool erase = false, + ub2 charset = 0, + ub2 ncharset = 0, OCIEnv* environment = 0, std::auto_ptr = std::auto_ptr (0)); @@ -120,6 +127,18 @@ namespace odb return port_; } + ub2 + charset () const + { + return charset_; + } + + ub2 + ncharset () const + { + return ncharset_; + } + OCIEnv* environment () { @@ -144,6 +163,9 @@ namespace odb std::string host_; unsigned int port_; + ub2 charset_; + ub2 ncharset_; + auto_handle auto_environment_; OCIEnv* environment_; -- cgit v1.1