diff --git a/doc/backends.html b/doc/backends.html index 73ec4be77..869fd5ca6 100644 --- a/doc/backends.html +++ b/doc/backends.html @@ -104,14 +104,13 @@

Backends reference

class standard_into_type_backend { public: + standard_into_type_backend() {} virtual ~standard_into_type_backend() {} - virtual void define_by_pos(int & position, - void * data, exchange_type type) = 0; + virtual void define_by_pos(int& position, void* data, exchange_type type) = 0; virtual void pre_fetch() = 0; - virtual void post_fetch(bool gotData, bool calledFromFetch, - indicator * ind) = 0; + virtual void post_fetch(bool gotData, bool calledFromFetch, indicator* ind) = 0; virtual void clean_up() = 0; }; @@ -160,13 +159,13 @@

Backends reference

class vector_into_type_backend { public: + vector_into_type_backend() {} virtual ~vector_into_type_backend() {} - virtual void define_by_pos(int & position, - void * data, exchange_type type) = 0; + virtual void define_by_pos(int& position, void* data, exchange_type type) = 0; virtual void pre_fetch() = 0; - virtual void post_fetch(bool gotData, indicator * ind) = 0; + virtual void post_fetch(bool gotData, indicator* ind) = 0; virtual void resize(std::size_t sz) = 0; virtual std::size_t size() = 0; @@ -194,13 +193,13 @@

Backends reference

public: virtual ~standard_use_type_backend() {} - virtual void bind_by_pos(int & position, - void * data, exchange_type type, bool readOnly) = 0; - virtual void bind_by_name(std::string const & name, - void * data, exchange_type type, bool readOnly) = 0; + virtual void bind_by_pos(int& position, + void* data, exchange_type type, bool readOnly) = 0; + virtual void bind_by_name(std::string const& name, + void* data, exchange_type type, bool readOnly) = 0; - virtual void pre_use(indicator const * ind) = 0; - virtual void post_use(bool gotData, indicator * ind) = 0; + virtual void pre_use(indicator const* ind) = 0; + virtual void post_use(bool gotData, indicator* ind) = 0; virtual void clean_up() = 0; }; @@ -236,12 +235,12 @@

Backends reference

public: virtual ~vector_use_type_backend() {} - virtual void bind_by_pos(int & position, - void * data, exchange_type type) = 0; - virtual void bind_by_name(std::string const & name, - void * data, exchange_type type) = 0; + virtual void bind_by_pos(int& position, + void* data, exchange_type type) = 0; + virtual void bind_by_name(std::string const& name, + void* data, exchange_type type) = 0; - virtual void pre_use(indicator const * ind) = 0; + virtual void pre_use(indicator const* ind) = 0; virtual std::size_t size() = 0; @@ -262,29 +261,36 @@

Backends reference

class statement_backend { public: + statement_backend() {} virtual ~statement_backend() {} virtual void alloc() = 0; virtual void clean_up() = 0; - virtual void prepare(std::string const & query, statement_type eType) = 0; + virtual void prepare(std::string const& query, statement_type eType) = 0; + + enum exec_fetch_result + { + ef_success, + ef_no_data + }; - enum exec_fetch_result { ef_success, ef_no_data }; virtual exec_fetch_result execute(int number) = 0; virtual exec_fetch_result fetch(int number) = 0; + virtual long long get_affected_rows() = 0; virtual int get_number_of_rows() = 0; - virtual std::string rewrite_for_procedure_call(std::string const & query) = 0; + virtual std::string rewrite_for_procedure_call(std::string const& query) = 0; virtual int prepare_for_describe() = 0; - virtual void describe_column(int colNum, data_type & dtype, - std::string & column_name) = 0; + virtual void describe_column(int colNum, data_type& dtype, + std::string& column_name) = 0; - virtual standard_into_type_backend * make_into_type_backend() = 0; - virtual standard_use_type_backend * make_use_type_backend() = 0; - virtual vector_into_type_backend * make_vector_into_type_backend() = 0; - virtual vector_use_type_backend * make_vector_use_type_backend() = 0; + virtual standard_into_type_backend* make_into_type_backend() = 0; + virtual standard_use_type_backend* make_use_type_backend() = 0; + virtual vector_into_type_backend* make_vector_into_type_backend() = 0; + virtual vector_use_type_backend* make_vector_use_type_backend() = 0; }; @@ -307,6 +313,8 @@

Backends reference

  • fetch - Called to fetch next bunch of rows; number is positive and determines the requested number of rows (more than 1 is used only for bulk operations).
  • +
  • get_affected_rows - Called to determine the actual +number of rows affected by data modifying statement.
  • get_number_of_rows - Called to determine the actual number of rows retrieved by the previous call to execute or fetch.
  • @@ -383,6 +391,9 @@

    Backends reference

    virtual void commit() = 0; virtual void rollback() = 0; + virtual bool get_next_sequence_value(session&, std::string const&, long&); + virtual bool get_last_insert_id(session&, std::string const&, long&); + virtual std::string get_backend_name() const = 0; virtual statement_backend * make_statement_backend() = 0; @@ -397,6 +408,10 @@

    Backends reference

  • begin, commit, rollback - Forward-called when the same functions of session are called by user.
  • +
  • get_next_sequence_value, get_last_insert_id +- Called to retrieve sequences or auto-generated values and every backend should +define at least one of them to allow the code using auto-generated values to work. +
  • make_statement_backend, make_rowid_backend, make_blob_backend - Called to create respective implementations for the statement, rowid @@ -410,7 +425,7 @@

    Backends reference

    virtual ~backend_factory() {} virtual details::session_backend * make_session( - std::string const & connectString) const = 0; + std::string const& connectString) const = 0; }; @@ -432,8 +447,8 @@

    Backends reference

     struct postgresql_backend_factory : backend_factory
     {
    -    virtual postgresql_session_backend * make_session(
    -        std::string const & connectString) const;
    +    virtual postgresql_session_backend* make_session(
    +        std::string const& connectString) const;
     };
     
     extern postgresql_backend_factory const postgresql;
    diff --git a/doc/backends/odbc.html b/doc/backends/odbc.html
    index 9d6ed9f7b..33f38b124 100644
    --- a/doc/backends/odbc.html
    +++ b/doc/backends/odbc.html
    @@ -34,7 +34,7 @@ 

    ODBC Backend Reference

    Accessing the Native Database API
    Backend-specific Extensions
    Configuration options
    @@ -49,9 +49,13 @@

    Tested Platforms

    + + + + - +
    ODBC versionOperating SystemCompiler
    3Linux (Ubuntu 12.04)g++ 4.6.3
    3Linux (Ubuntu 12.04)clang 3.2
    3.8Windows 8Visual Studio 2012
    3Windows 7Visual Studio 2010
    3Windows XPVisual Studio 2005 (express)
    3Windows XPVisual C++ 8.0 Professional
    3Windows XP(cygwin) g++ 3.3.4
    3Windows XPg++ 3.3.4 (Cygwin)
    @@ -65,68 +69,68 @@

    Connecting to the Database

    using the ODBC backend factory together with a connection string:

    -BackEndFactory const &backEnd = odbc;
    -Session sql(backEnd, "filedsn=c:\\my.dsn");
    +backend_factory const& backEnd = odbc;
    +session sql(backEnd, "filedsn=c:\\my.dsn");
     

    or simply:

    -Session sql(odbc, "filedsn=c:\\my.dsn");
    +session sql(odbc, "filedsn=c:\\my.dsn");
     

    The set of parameters used in the connection string for ODBC is the same as accepted by the SQLDriverConnect function from the ODBC library.

    -

    Once you have created a Session object as shown above, you can use it to access the database, for example:

    +

    Once you have created a session object as shown above, you can use it to access the database, for example:

     int count;
     sql << "select count(*) from invoices", into(count);
     
    -

    (See the SOCI basics and exchanging data documentation for general information on using the Session class.)

    +

    (See the SOCI basics and exchanging data documentation for general information on using the session class.)

    SOCI Feature Support

    Dynamic Binding

    -

    The ODBC backend supports the use of the SOCI Row class, which facilitates retrieval of data whose type is not known at compile time.

    +

    The ODBC backend supports the use of the SOCI row class, which facilitates retrieval of data whose type is not known at compile time.

    -

    When calling Row::get<T>(), the type you should pass as T depends upon the underlying database type.
    For the ODBC backend, this type mapping is:

    +

    When calling row::get<T>(), the type you should pass as T depends upon the underlying database type.
    For the ODBC backend, this type mapping is:

    - + - + , SQL_DECIMAL + , SQL_REAL + , SQL_FLOAT + , SQL_NUMERIC + + - + , SQL_SMALLINT + , SQL_INTEGER + , SQL_BIGINT + - + - + , SQL_TYPE_TIME + , SQL_TYPE_TIMESTAMP + @@ -134,7 +138,7 @@

    Dynamic Binding

    Not all ODBC drivers support all datatypes

    -

    (See the dynamic resultset binding documentation for general information on using the Row class.)

    +

    (See the dynamic resultset binding documentation for general information on using the row class.)

    Binding by Name

    @@ -165,25 +169,25 @@

    Bulk Operations

    - - - - + + + + - - - - + + + + - - - - + + + + - - - - + + + +
    ODBC Data Type SOCI Data TypeRow::get<T> specializationsrow::get<T> specializations
    SQL_DOUBLE - , SQL_DECIMAL - , SQL_REAL - , SQL_FLOAT - , SQL_NUMERIC - eDoubledt_double double
    SQL_TINYINT - , SQL_SMALLINT - , SQL_INTEGER - , SQL_BIGINTeIntegerdt_integer int
    SQL_CHAR, SQL_VARCHAReStringdt_string std::string
    SQL_TYPE_DATE - , SQL_TYPE_TIME - , SQL_TYPE_TIMESTAMPeDatedt_date std::tm
    Bulk Insert
    MS SQL Server 2005YESYES
    MS SQL Server 2005YESYES
    MS Access 2003YESNO
    MS Access 2003YESNO
    PostgresQL 8.1YESYES
    PostgresQL 8.1YESYES
    MySQL 4.1NONO
    MySQL 4.1NONO
    @@ -220,27 +224,28 @@

    Acessing the native database API

    Concrete Class - SessionBackEnd* Session::getBackEnd() - ODBCSessionBackEnd + session_backend* session::get_backend() + odbc_statement_backend - StatementBackEnd* Statement::getBackEnd() - ODBCStatementBackEnd + statement_backend* statement::get_backend() + odbc_statement_backend - RowIDBackEnd* RowID::getBackEnd() - ODBCRowIDBackEnd + rowid_backend* rowid::get_backend() + odbc_rowid_backend

    Backend-specific extensions

    -

    ODBCSOCIError

    +

    odbc_soci_error

    -

    The ODBC backend can throw instances of class ODBCSOCIError, -which is publicly derived from SOCIError and has -additional public members containing the ODBC error code, the Native database error code, and the message returned from ODBC:

    +

    The ODBC backend can throw instances of class odbc_soci_error, +which is publicly derived from soci_error and has +additional public members containing the ODBC error code, the Native database +error code, and the message returned from ODBC:

     int main()
    @@ -249,12 +254,12 @@ 

    ODBCSOCIError

    { // regular code } - catch (SOCI::ODBCSOCIError const & e) + catch (soci::odbc_soci_error const& e) { - cerr << "ODBC Error Code: " << e.odbcErrorCode() << endl - << "Native Error Code: " << e.nativeErrorCode() << endl + cerr << "ODBC Error Code: " << e.odbc_error_code() << endl + << "Native Error Code: " << e.native_error_code() << endl << "SOCI Message: " << e.what() << std::endl - << "ODBC Message: " << e.odbcErrorMessage() << endl; + << "ODBC Message: " << e.odbc_error_message() << endl; } catch (exception const &e) { @@ -271,6 +276,7 @@

    Configuration options

    None

    + diff --git a/doc/backends/sqlite3.html b/doc/backends/sqlite3.html index 88b753cc6..51221123a 100644 --- a/doc/backends/sqlite3.html +++ b/doc/backends/sqlite3.html @@ -73,20 +73,20 @@

    Connecting to the Database

    The only option for the connection string is the name of the file to use as a database.

    -

    Once you have created a Session object as shown above, you can use it to access the database, for example:

    +

    Once you have created a session object as shown above, you can use it to access the database, for example:

     int count;
     sql << "select count(*) from invoices", into(count);
     
    -

    (See the SOCI basics and exchanging data documentation for general information on using the Session class.)

    +

    (See the SOCI basics and exchanging data documentation for general information on using the session class.)

    SOCI Feature Support

    Dynamic Binding

    -

    The SQLite3 backend supports the use of the SOCI Row class, which facilitates retrieval of data whose type is not known at compile time.

    +

    The SQLite3 backend supports the use of the SOCI row class, which facilitates retrieval of data whose type is not known at compile time.

    -

    When calling Row::get<T>(), the type you should pass as T depends upon the underlying database type.

    +

    When calling row::get<T>(), the type you should pass as T depends upon the underlying database type.

    For the SQLite3 backend, this type mapping is complicated by the fact the SQLite3 does not enforce types *, and makes no attempt to validate the type names used in table creation or alteration statements. SQLite3 will return the type as a string, SOCI will recognize the following strings and match them the corresponding SOCI types:

    @@ -95,26 +95,26 @@

    Dynamic Binding

    SQLite3 Data Type SOCI Data Type - Row::get<T> specializations + row::get<T> specializations *float* - eDouble + dt_ouble double *int* - eInteger + dt_integer int *char* - eString + dt_string std::string *date*, *time* - eDate + dt_date std::tm @@ -122,7 +122,7 @@

    Dynamic Binding

    * There is one case where SQLite3 enforces type. If a column is declared as "integer primary key", then SQLite3 uses that as an alias to the internal ROWID column that exists for every table. Only integers are allowed in this column.

    -

    (See the dynamic resultset binding documentation for general information on using the Row class.)

    +

    (See the dynamic resultset binding documentation for general information on using the row class.)

    Binding by Name

    @@ -166,7 +166,9 @@

    Stored Procedures

    Acessing the native database API

    -

    SOCI provides access to underlying datbabase APIs via several getBackEnd() functions, as described in the beyond SOCI documentation.

    +

    SOCI provides access to underlying datbabase APIs via several +get_backend() functions, as described in the +beyond SOCI documentation.

    The SQLite3 backend provides the following concrete classes for navite API access:

    @@ -177,16 +179,16 @@

    Acessing the native database API

    Concrete Class - SessionBackEnd* Session::getBackEnd() - SQLite3SessionBackEnd + session_backend* session::get_backend() + sqlie3_session_backend - StatementBackEnd* Statement::getBackEnd() - SQLite3StatementBackEnd + statement_backend* statement::get_backend() + sqlite3_statement_backend - RowIDBackEnd* RowID::getBackEnd() - SQLite3RowIDBackEnd + rowid_backend* rowid::get_backend() + sqlite3_rowid_backend diff --git a/doc/beyond.html b/doc/beyond.html index f057a1a12..14a661e0d 100644 --- a/doc/beyond.html +++ b/doc/beyond.html @@ -28,7 +28,8 @@

    Getting the number of rows affected by an operation

    statement st = (sql.prepare << "update some_table ..."); st.execute(true); -if ( !st.get_affected_rows() ) { +if ( !st.get_affected_rows() ) +{ ... investigate why no rows were modified ... }
    @@ -67,11 +68,13 @@

    Working with sequences

     long id;
     statement st;
    -if ( sql.get_next_sequence_value("table_sequence", id) ) {
    +if ( sql.get_next_sequence_value("table_sequence", id) )
    +{
         st << "insert into table(id, f1, f2) values(:id, :f1, :f2)",
             use(id), use(f1), use(f2);
     }
    -else {
    +else
    +{
         // We're not using sequences, so don't specify the value,
         // it will be automatically generated by the database on insert.
         st << "insert into table(f1, f2) value(:f1, :f2)",
    diff --git a/doc/errors.html b/doc/errors.html
    index 2bed5bccc..ed59640de 100644
    --- a/doc/errors.html
    +++ b/doc/errors.html
    @@ -23,7 +23,7 @@ 

    Errors

    { // regular code } - catch (exception const & e) + catch (std::exception const & e) { cerr << "Bang! " << e.what() << endl; } @@ -44,12 +44,12 @@

    Errors

    { // regular code } - catch (oracle_soci_error const & e) + catch (soci::oracle_soci_error const & e) { cerr << "Oracle error: " << e.err_num_ << " " << e.what() << endl; } - catch (exception const & e) + catch (soci::exception const & e) { cerr << "Some other error: " << e.what() << endl; } @@ -72,12 +72,12 @@

    Errors

    { // regular code } - catch (mysql_soci_error const & e) + catch (soci::mysql_soci_error const & e) { cerr << "MySQL error: " << e.err_num_ << " " << e.what() << endl; } - catch (exception const & e) + catch (soci::exception const & e) { cerr << "Some other error: " << e.what() << endl; } @@ -99,12 +99,12 @@

    Errors

    { // regular code } - catch (postgresql_soci_error const & e) + catch (soci::postgresql_soci_error const & e) { cerr << "PostgreSQL error: " << e.sqlstate() << " " << e.what() << endl; } - catch (exception const & e) + catch (soci::exception const & e) { cerr << "Some other error: " << e.what() << endl; } @@ -123,6 +123,6 @@

    Errors

    - + diff --git a/doc/index.html b/doc/index.html index e74bdca14..77f66368c 100644 --- a/doc/index.html +++ b/doc/index.html @@ -44,7 +44,7 @@

    Documentation and tutorial

    using namespace soci; using namespace std; -bool getName(string &name) +bool get_name(string &name) { cout << "Enter name: "; return cin >> name; @@ -62,7 +62,7 @@

    Documentation and tutorial

    cout << "We have " << count << " entries in the phonebook.\n"; string name; - while (getName(name)) + while (get_name(name)) { string phone; indicator ind; diff --git a/src/core/soci-backend.h b/src/core/soci-backend.h index fbbae7ef5..b39b9cde7 100644 --- a/src/core/soci-backend.h +++ b/src/core/soci-backend.h @@ -235,11 +235,11 @@ class session_backend // versions of them in the derived classes. However every backend should // define at least one of them to allow the code using auto-generated values // to work. - virtual bool get_next_sequence_value(session&, std::string const &, long &) + virtual bool get_next_sequence_value(session&, std::string const&, long&) { return false; } - virtual bool get_last_insert_id(session&, std::string const &, long &) + virtual bool get_last_insert_id(session&, std::string const&, long&) { return false; }