summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames H. Hill <hilljh82@gmail.com>2010-01-04 05:37:24 +0000
committerJames H. Hill <hilljh82@gmail.com>2010-01-04 05:37:24 +0000
commit642d0d9813dbc1f5757041fc1838f7b859a633d2 (patch)
tree435da8d65b7a79960687d04823b7f614f88b5c10
parent4605f5605cfefa8b2a61237ed2074c977ffe7a60 (diff)
downloadATCD-642d0d9813dbc1f5757041fc1838f7b859a633d2.tar.gz
Mon Jan 4 05:29:45 UTC 2010 James H. Hill <hillj at cs dot iupui dot edu>
-rw-r--r--ADBC/ADBC.mwc5
-rw-r--r--ADBC/ChangeLog61
-rw-r--r--ADBC/MPC/config/adbc_sqlite.mpb2
-rw-r--r--ADBC/MPC/config/adbclib.mpb2
-rw-r--r--ADBC/adbc/ADBC.mpc2
-rw-r--r--ADBC/adbc/Connection.h2
-rw-r--r--ADBC/adbc/Exception.h2
-rw-r--r--ADBC/adbc/Parameter.h22
-rw-r--r--ADBC/adbc/Parameter.inl56
-rw-r--r--ADBC/adbc/Parameter_List.h2
-rw-r--r--ADBC/adbc/Query.h2
-rw-r--r--ADBC/adbc/Record.h7
-rw-r--r--ADBC/adbc/SQLite/Parameter.cpp25
-rw-r--r--ADBC/adbc/SQLite/Parameter.h15
-rw-r--r--ADBC/adbc/SQLite/Parameter.inl28
-rw-r--r--ADBC/adbc/SQLite/Query.cpp79
-rw-r--r--ADBC/adbc/SQLite/Query.h8
-rw-r--r--ADBC/adbc/SQLite/Query.inl41
-rw-r--r--ADBC/adbc/SQLite/Record.cpp109
-rw-r--r--ADBC/adbc/SQLite/Record.h8
-rw-r--r--ADBC/adbc/SQLite/Record.inl99
-rw-r--r--ADBC/adbc/SQLite/Types.h2
-rw-r--r--ADBC/default.features.tmpl26
-rw-r--r--ADBC/examples/SQLite/simple/simple.cpp2
24 files changed, 323 insertions, 284 deletions
diff --git a/ADBC/ADBC.mwc b/ADBC/ADBC.mwc
index 3c2c07a459f..85a72d6d24d 100644
--- a/ADBC/ADBC.mwc
+++ b/ADBC/ADBC.mwc
@@ -1,5 +1,8 @@
// $Id$
workspace (ADBC) {
- cmdline += -include $ADBC_ROOT/MPC/config
+ cmdline += -include $ADBC_ROOT/MPC/config \
+ -feature_file $ADBC_ROOT/default.features
+
+ ./adbc
}
diff --git a/ADBC/ChangeLog b/ADBC/ChangeLog
index e8cbc87a4d5..9c4f453a60e 100644
--- a/ADBC/ChangeLog
+++ b/ADBC/ChangeLog
@@ -1,3 +1,64 @@
+Mon Jan 4 05:29:45 UTC 2010 James H. Hill <hillj at cs dot iupui dot edu>
+
+ * ADBC.mwc:
+
+ Explicitly specified the directories to include in
+ the workspace.
+
+ * MPC/config/adbc_sqlite.mpb:
+
+ Added the sqlite3 base project.
+
+ * MPC/config/adbclib.mpb:
+
+ Fixed errors in the base project specification.
+
+ * adbc/ADBC.mpc:
+ * adbc/Connection.h:
+ * adbc/Exception.h:
+ * adbc/Parameter.h:
+ * adbc/Parameter.inl:
+ * adbc/Parameter_List.h:
+ * adbc/Query.h:
+ * adbc/SQLite/Types.h:
+
+ Changed all instances of CUTS to ADBC.
+
+ * adbc/Record.h:
+
+ Added a pure virtual reset () method.
+
+ * adbc/SQLite/Parameter.h:
+ * adbc/SQLite/Parameter.inl:
+ * adbc/SQLite/Parameter.cpp:
+
+ Removed the length (size_t) function since this must be set
+ when a parameter is bound.
+
+ Re-implemented the is_null () so that is not implemented in
+ terms of its base class.
+
+ * adbc/SQLite/Query.h:
+ * adbc/SQLite/Query.inl:
+ * adbc/SQLite/Query.cpp:
+ * adbc/SQLite/Record.h:
+ * adbc/SQLite/Record.inl:
+ * adbc/SQLite/Record.cpp:
+
+ Improved the implementation of the Record class so that its
+ semantics are more in line with its specification. This also
+ simplified the execute* () methods on the Query class since
+ the Record handles reseting the cursor for each execution of
+ a statement.
+
+ * default.features.tmpl:
+
+ Template of all possible features for MPC.
+
+ * examples/SQLite/simple/simple.cpp:
+
+ Fixed build errors in the example.
+
Sat Jan 2 16:23:29 UTC 2010 James H. Hill <hillj at cs dot iupui dot edu>
* adbc/Query.h:
diff --git a/ADBC/MPC/config/adbc_sqlite.mpb b/ADBC/MPC/config/adbc_sqlite.mpb
index 0d0f47701b4..a7060efd5fa 100644
--- a/ADBC/MPC/config/adbc_sqlite.mpb
+++ b/ADBC/MPC/config/adbc_sqlite.mpb
@@ -1,6 +1,6 @@
// $Id$
-project : adbc_defaults {
+project : sqlite3, adbc_defaults {
libs += ADBC_SQLite
after += ADBC_SQLite
}
diff --git a/ADBC/MPC/config/adbclib.mpb b/ADBC/MPC/config/adbclib.mpb
index 928ef6e5a71..14f02457ced 100644
--- a/ADBC/MPC/config/adbclib.mpb
+++ b/ADBC/MPC/config/adbclib.mpb
@@ -1,6 +1,6 @@
// $Id$
-project : ace_lib, adbc_defaults {
+project : adbc_defaults {
after += ADBC
libs += ADBC
}
diff --git a/ADBC/adbc/ADBC.mpc b/ADBC/adbc/ADBC.mpc
index 45a12e9519e..d2c692ccd55 100644
--- a/ADBC/adbc/ADBC.mpc
+++ b/ADBC/adbc/ADBC.mpc
@@ -1,6 +1,6 @@
// $Id$
-project (ADBC) : adbc_defaults {
+project (ADBC) : acelib, adbc_defaults {
sharedname += ADBC
dynamicflags += ADBC_BUILD_DLL
diff --git a/ADBC/adbc/Connection.h b/ADBC/adbc/Connection.h
index 10e46bb7f07..2955617bbe4 100644
--- a/ADBC/adbc/Connection.h
+++ b/ADBC/adbc/Connection.h
@@ -81,4 +81,4 @@ private:
#include "Connection.inl"
#endif
-#endif // !defined _CUTS_DB_CONNECTION_H_
+#endif // !defined _ADBC_DB_CONNECTION_H_
diff --git a/ADBC/adbc/Exception.h b/ADBC/adbc/Exception.h
index 9d51318e91b..a3832574215 100644
--- a/ADBC/adbc/Exception.h
+++ b/ADBC/adbc/Exception.h
@@ -92,4 +92,4 @@ protected:
#include "Exception.inl"
#endif
-#endif // !defined _CUTS_DB_EXCEPTION_H_
+#endif // !defined _ADBC_DB_EXCEPTION_H_
diff --git a/ADBC/adbc/Parameter.h b/ADBC/adbc/Parameter.h
index 02db8118ff7..e491c6772d2 100644
--- a/ADBC/adbc/Parameter.h
+++ b/ADBC/adbc/Parameter.h
@@ -84,6 +84,11 @@ public:
*/
Parameter (void);
+ /**
+ * Copy constructor.
+ *
+ * @param[in] p Source parameter.
+ */
Parameter (const Parameter & p);
/// Destructor.
@@ -117,7 +122,7 @@ public:
* @retval 1 The parameter is null.
* @retval 0 The parameter is not null.
*/
- virtual bool is_null (void) const;
+ virtual bool is_null (void) const = 0;
/// Make the parameter a NULL value.
virtual void null (void) = 0;
@@ -196,15 +201,6 @@ public:
virtual void bind (Date_Time * dt) = 0;
/**
- * Set the length of the parameter. This is necessary of the
- * parameter is already bound to a buffer, and the length of the
- * input buffer has changed.
- *
- * @param[in] len Length of the buffer.
- */
- virtual void length (long len) = 0;
-
- /**
* Get the current length/size of the parameter.
*
* @return The length/size of the parameter.
@@ -215,15 +211,11 @@ protected:
/// The index of the parameter.
int index_;
-private:
/// The parameter type.
Parameter_Type type_;
/// The direction of the parameter.
Direction_Type direction_;
-
- /// Null flags for the parameter.
- bool is_null_;
};
}
@@ -231,4 +223,4 @@ private:
#include "Parameter.inl"
#endif
-#endif // !defined _CUTS_DB_PARAMETER_H_
+#endif // !defined _ADBC_DB_PARAMETER_H_
diff --git a/ADBC/adbc/Parameter.inl b/ADBC/adbc/Parameter.inl
index 06f047b4d5f..282ee271a2c 100644
--- a/ADBC/adbc/Parameter.inl
+++ b/ADBC/adbc/Parameter.inl
@@ -9,8 +9,7 @@ namespace ADBC
ADBC_INLINE
Parameter::Parameter (void)
: index_ (-1),
- type_ (PT_UNKNOWN),
- is_null_ (true)
+ type_ (PT_UNKNOWN)
{
}
@@ -21,8 +20,7 @@ Parameter::Parameter (void)
ADBC_INLINE
Parameter::Parameter (const Parameter & p)
: index_ (p.index_),
- type_ (p.type_),
- is_null_ (p.is_null_)
+ type_ (p.type_)
{
}
@@ -40,13 +38,21 @@ Parameter::~Parameter (void)
// type
//
ADBC_INLINE
-Parameter::Parameter_Type
-Parameter::type (void) const
+Parameter::Parameter_Type Parameter::type (void) const
{
return this->type_;
}
//
+// direction
+//
+ADBC_INLINE
+Parameter::Direction_Type Parameter::direction (void) const
+{
+ return this->direction_;
+}
+
+//
// index
//
ADBC_INLINE
@@ -62,7 +68,6 @@ ADBC_INLINE
void Parameter::bind (char *, size_t)
{
this->type_ = Parameter::PT_CHAR;
- this->is_null_ = false;
}
//
@@ -72,7 +77,6 @@ ADBC_INLINE
void Parameter::bind (const char *, size_t)
{
this->type_ = Parameter::PT_CHAR;
- this->is_null_ = false;
}
//
@@ -82,7 +86,6 @@ ADBC_INLINE
void Parameter::bind (ACE_INT16 *)
{
this->type_ = Parameter::PT_SHORT;
- this->is_null_ = false;
}
//
@@ -92,7 +95,6 @@ ADBC_INLINE
void Parameter::bind (ACE_UINT16 *)
{
this->type_ = Parameter::PT_USHORT;
- this->is_null_ = false;
}
//
@@ -102,7 +104,6 @@ ADBC_INLINE
void Parameter::bind (ACE_INT32 *)
{
this->type_ = Parameter::PT_LONG;
- this->is_null_ = false;
}
//
@@ -112,7 +113,6 @@ ADBC_INLINE
void Parameter::bind (ACE_UINT32 *)
{
this->type_ = Parameter::PT_ULONG;
- this->is_null_ = false;
}
//
@@ -122,7 +122,6 @@ ADBC_INLINE
void Parameter::bind (ACE_INT64 *)
{
this->type_ = Parameter::PT_LONGLONG;
- this->is_null_ = false;
}
//
@@ -132,7 +131,6 @@ ADBC_INLINE
void Parameter::bind (ACE_UINT64 *)
{
this->type_ = Parameter::PT_ULONGLONG;
- this->is_null_ = false;
}
//
@@ -142,7 +140,6 @@ ADBC_INLINE
void Parameter::bind (double *)
{
this->type_ = Parameter::PT_DOUBLE;
- this->is_null_ = false;
}
//
@@ -152,7 +149,6 @@ ADBC_INLINE
void Parameter::bind (float *)
{
this->type_ = Parameter::PT_FLOAT;
- this->is_null_ = false;
}
//
@@ -162,34 +158,6 @@ ADBC_INLINE
void Parameter::bind (Date_Time *)
{
this->type_ = Parameter::PT_DATETIME;
- this->is_null_ = false;
-}
-
-//
-// is_null
-//
-ADBC_INLINE
-bool Parameter::is_null (void) const
-{
- return this->is_null_;
}
-//
-// null
-//
-ADBC_INLINE
-void Parameter::null (void)
-{
- this->is_null_ = true;
-}
-
-//
-// direction
-//
-ADBC_INLINE
-Parameter::Direction_Type
-Parameter::direction (void) const
-{
- return this->direction_;
-}
}
diff --git a/ADBC/adbc/Parameter_List.h b/ADBC/adbc/Parameter_List.h
index e3fd71bb275..33073662fc0 100644
--- a/ADBC/adbc/Parameter_List.h
+++ b/ADBC/adbc/Parameter_List.h
@@ -58,4 +58,4 @@ public:
#include "Parameter_List.inl"
#endif
-#endif // !defined _CUTS_DB_PARAMETER_LIST_H_
+#endif // !defined _ADBC_DB_PARAMETER_LIST_H_
diff --git a/ADBC/adbc/Query.h b/ADBC/adbc/Query.h
index f4c8c2bd819..01d7a443a32 100644
--- a/ADBC/adbc/Query.h
+++ b/ADBC/adbc/Query.h
@@ -129,4 +129,4 @@ private:
#include "Query.inl"
#endif
-#endif // !defined _CUTS_DB_QUERY_H_
+#endif // !defined _ADBC_DB_QUERY_H_
diff --git a/ADBC/adbc/Record.h b/ADBC/adbc/Record.h
index dcdba866434..af7729e9117 100644
--- a/ADBC/adbc/Record.h
+++ b/ADBC/adbc/Record.h
@@ -39,7 +39,7 @@ public:
/**
* Get the number of columns in the result.
*
- * @return Number of columns.
+ * @return Number of columns.
*/
virtual size_t columns (void) const = 0;
@@ -49,6 +49,9 @@ public:
/// Determine if the record iterator is done.
virtual bool done (void) const = 0;
+ /// Reset to the first row in the record.
+ virtual void reset (void) = 0;
+
/**
* Get a string data value at the specified column.
*
@@ -141,4 +144,4 @@ private:
#include "Record.inl"
#endif
-#endif // !defined _CUTS_DB_RECORD_H_
+#endif // !defined _ADBC_DB_RECORD_H_
diff --git a/ADBC/adbc/SQLite/Parameter.cpp b/ADBC/adbc/SQLite/Parameter.cpp
index 40b413da34d..049708b0dc9 100644
--- a/ADBC/adbc/SQLite/Parameter.cpp
+++ b/ADBC/adbc/SQLite/Parameter.cpp
@@ -16,18 +16,31 @@ namespace ADBC
namespace SQLite
{
//
+// operator =
+//
+const Parameter & Parameter::operator = (const Parameter & rhs)
+{
+ if (this == &rhs)
+ return *this;
+
+ this->owner_ = rhs.owner_;
+ this->index_ = rhs.index_;
+
+ return *this;
+}
+
+//
// null
//
void Parameter::null (void)
{
- int retval =
- ::sqlite3_bind_null (this->owner_->owner ().stmt_,
- this->index_);
+ int retval = ::sqlite3_bind_null (this->owner_->owner ().stmt_,
+ this->index_);
- if (retval == SQLITE_OK)
- ::ADBC::Parameter::null ();
- else
+ if (retval != SQLITE_OK)
throw Exception (this->owner_->owner ().parent_);
+
+ this->is_null_ = true;
}
//
diff --git a/ADBC/adbc/SQLite/Parameter.h b/ADBC/adbc/SQLite/Parameter.h
index bb2b70196b7..94a6b56b683 100644
--- a/ADBC/adbc/SQLite/Parameter.h
+++ b/ADBC/adbc/SQLite/Parameter.h
@@ -51,6 +51,9 @@ public:
/// Make the parameter a NULL value.
virtual void null (void);
+ // Test if the parameter is NULL.
+ virtual bool is_null (void) const;
+
/**
* Bind the parameter to a character buffer. If the size of
* the buffer is 0, then it is buffer is NULL terminated.
@@ -122,15 +125,6 @@ public:
void bind (::ADBC::SQLite::Date_Time * dt);
/**
- * Set the length of the parameter. This is necessary of the
- * parameter is already bound to a buffer, and the length of the
- * input buffer has changed.
- *
- * @param[in] len Length of the buffer.
- */
- virtual void length (long len);
-
- /**
* Get the current length/size of the parameter.
*
* @return The length/size of the parameter.
@@ -157,6 +151,9 @@ private:
/// List that owns the parameter.
const Parameter_List * owner_;
+
+ /// NULL state of the parameter.
+ bool is_null_;
};
}
}
diff --git a/ADBC/adbc/SQLite/Parameter.inl b/ADBC/adbc/SQLite/Parameter.inl
index 934bb5a1efc..88193cdd33f 100644
--- a/ADBC/adbc/SQLite/Parameter.inl
+++ b/ADBC/adbc/SQLite/Parameter.inl
@@ -10,7 +10,8 @@ namespace SQLite
//
ADBC_INLINE
Parameter::Parameter (void)
-: owner_ (0)
+: owner_ (0),
+ is_null_ (true)
{
}
@@ -21,8 +22,9 @@ Parameter::Parameter (void)
ADBC_INLINE
Parameter::
Parameter (const Parameter & p)
-: ::ADBC::Parameter (p),
- owner_ (p.owner_)
+: ADBC::Parameter (p),
+ owner_ (p.owner_),
+ is_null_ (p.is_null_)
{
}
@@ -37,16 +39,12 @@ Parameter::~Parameter (void)
}
//
-// operator =
+// is_null
//
ADBC_INLINE
-const Parameter &
-Parameter::operator = (const Parameter & rhs)
+bool Parameter::is_null (void) const
{
- this->owner_ = rhs.owner_;
- this->index_ = rhs.index_;
-
- return *this;
+ return this->is_null_;
}
//
@@ -133,18 +131,8 @@ void Parameter::bind (ACE_UINT64 * value)
// length
//
ADBC_INLINE
-void Parameter::length (long len)
-{
- // Ingore for now...
-}
-
-//
-// length
-//
-ADBC_INLINE
long Parameter::length (void)
{
- // Ingore for now...
return 0;
}
diff --git a/ADBC/adbc/SQLite/Query.cpp b/ADBC/adbc/SQLite/Query.cpp
index ce70a6453e6..3a47187c28f 100644
--- a/ADBC/adbc/SQLite/Query.cpp
+++ b/ADBC/adbc/SQLite/Query.cpp
@@ -16,6 +16,19 @@ namespace ADBC
namespace SQLite
{
//
+// Query
+//
+ADBC_INLINE
+Query::Query (Connection & parent)
+: parent_ (parent),
+ stmt_ (0),
+ params_ (*this),
+ record_ (*this)
+{
+
+}
+
+//
// prepare
//
void Query::prepare (const char * query)
@@ -25,6 +38,14 @@ void Query::prepare (const char * query)
}
//
+// cancel
+//
+void Query::cancel (void)
+{
+ ::sqlite3_interrupt (this->parent_.conn_);
+}
+
+//
// prepare
//
void Query::prepare (const char * query, size_t len)
@@ -53,21 +74,13 @@ void Query::prepare (const char * query, size_t len)
void Query::execute_no_record (void)
{
if (this->stmt_ == 0)
- throw Exception ();
-
- if (this->needs_reseting_)
- this->reset ();
-
- // Execute the SQL statement.
- int retval = ::sqlite3_step (this->stmt_);
+ throw Exception ("SQL statement is not prepared");
- if (retval == SQLITE_ERROR)
- throw Exception (this->parent_);
-
- this->needs_reseting_ = true;
+ // Reset the record, then execute the statement.
+ this->record_.reset ();
- if (retval != SQLITE_DONE)
- throw Exception (this->parent_);
+ if (!this->record_.done ())
+ throw Exception ("SQL statement was a SELECT statement");
}
//
@@ -76,32 +89,14 @@ void Query::execute_no_record (void)
Record & Query::execute (void)
{
if (this->stmt_ == 0)
- throw Exception ();
-
- if (this->needs_reseting_)
- this->reset ();
-
- // Initialize the cursor for the record.
- int retval = ::sqlite3_step (this->stmt_);
-
- if (retval == SQLITE_ERROR)
- throw Exception (this->parent_);
+ throw Exception ("SQL statement is not prepared");
// Update the record's state for the new query.
- this->record_.state_ = retval;
- this->needs_reseting_ = true;
+ this->record_.reset ();
return this->record_;
}
//
-// last_insert_id
-//
-long Query::last_insert_id (void)
-{
- return static_cast <long> (::sqlite3_last_insert_rowid (this->parent_.conn_));
-}
-
-//
// finalize
//
void Query::finalize (void)
@@ -111,10 +106,7 @@ void Query::finalize (void)
// Release the statements resources.
::sqlite3_finalize (this->stmt_);
-
- // Reset the variables.
this->stmt_ = 0;
- this->needs_reseting_ = false;
}
//
@@ -122,19 +114,8 @@ void Query::finalize (void)
//
void Query::reset (void)
{
- ::sqlite3_reset (this->stmt_);
- this->needs_reseting_ = false;
-}
-
-//
-// count
-//
-size_t Query::count (void) const
-{
- if (0 == this->parent_.conn_)
- throw Exception ("invalid database connection");
-
- return ::sqlite3_changes (this->parent_.conn_);
+ //::sqlite3_reset (this->stmt_);
+ //this->needs_reseting_ = false;
}
}
diff --git a/ADBC/adbc/SQLite/Query.h b/ADBC/adbc/SQLite/Query.h
index 6ef4cd16ece..315eae89a6e 100644
--- a/ADBC/adbc/SQLite/Query.h
+++ b/ADBC/adbc/SQLite/Query.h
@@ -13,12 +13,10 @@
#ifndef _ADBC_SQLITE_QUERY_H_
#define _ADBC_SQLITE_QUERY_H_
+#include "adbc/Query.h"
+#include "sqlite3.h"
#include "Record.h"
#include "Parameter_List.h"
-#include "adbc/Query.h"
-
-// Forward decl.
-struct sqlite3_stmt;
namespace ADBC
{
@@ -126,8 +124,6 @@ private:
/// Actual SQLite3 statement.
::sqlite3_stmt * stmt_;
- bool needs_reseting_;
-
/// Collection of parameters for this query.
Parameter_List params_;
diff --git a/ADBC/adbc/SQLite/Query.inl b/ADBC/adbc/SQLite/Query.inl
index 03b9d89fca6..6b470d0a9d6 100644
--- a/ADBC/adbc/SQLite/Query.inl
+++ b/ADBC/adbc/SQLite/Query.inl
@@ -1,25 +1,13 @@
// -*- C++ -*-
// $Id$
+#include "Connection.h"
+
namespace ADBC
{
namespace SQLite
{
//
-// Query
-//
-ADBC_INLINE
-Query::Query (Connection & parent)
-: parent_ (parent),
- stmt_ (0),
- needs_reseting_ (false),
- params_ (*this),
- record_ (*this)
-{
-
-}
-
-//
// ~Query
//
ADBC_INLINE
@@ -49,32 +37,41 @@ Record & Query::execute (const char * query)
return this->execute ();
}
-
//
-// cancel
+// parameters
//
ADBC_INLINE
-void Query::cancel (void)
+Parameter_List & Query::parameters (void)
{
- // no-op
+ return this->params_;
}
//
// parameters
//
ADBC_INLINE
-Parameter_List & Query::parameters (void)
+const Parameter_List & Query::parameters (void) const
{
return this->params_;
}
//
-// parameters
+// last_insert_id
//
ADBC_INLINE
-const Parameter_List & Query::parameters (void) const
+long Query::last_insert_id (void)
{
- return this->params_;
+ return static_cast <long> (::sqlite3_last_insert_rowid (this->parent_.conn_));
+}
+
+//
+// count
+//
+ADBC_INLINE
+size_t Query::count (void) const
+{
+ return ::sqlite3_changes (this->parent_.conn_);
}
+
}
}
diff --git a/ADBC/adbc/SQLite/Record.cpp b/ADBC/adbc/SQLite/Record.cpp
index 0d91368583e..bd333b5294a 100644
--- a/ADBC/adbc/SQLite/Record.cpp
+++ b/ADBC/adbc/SQLite/Record.cpp
@@ -10,7 +10,6 @@
#include "Exception.h"
#include "ace/Date_Time.h"
#include "ace/Array.h"
-#include "sqlite3.h"
#include <sstream>
namespace ADBC
@@ -18,24 +17,21 @@ namespace ADBC
namespace SQLite
{
//
-// count
-//
-size_t Record::columns (void) const
-{
- return ::sqlite3_column_count (this->query_.stmt_);
-}
-
-//
// reset
//
void Record::reset (void)
{
// Reset the cursor
- this->state_ = ::sqlite3_reset (this->query_.stmt_);
+ if (this->state_ != SQLITE_OK)
+ this->state_ = ::sqlite3_reset (this->query_.stmt_);
// Move the first element in the result.
if (this->state_ == SQLITE_OK)
this->state_ = ::sqlite3_step (this->query_.stmt_);
+
+ // Lastly, check for any errors.
+ if (this->state_ == SQLITE_ERROR || this->state_ == SQLITE_MISUSE)
+ throw Exception (this->query_.parent_);
}
//
@@ -43,18 +39,18 @@ void Record::reset (void)
//
void Record::advance (void)
{
- this->state_ = ::sqlite3_step (this->query_.stmt_);
+ if (this->state_ == SQLITE_ROW)
+ this->state_ = ::sqlite3_step (this->query_.stmt_);
- if (this->state_ != SQLITE_ROW && this->state_ != SQLITE_DONE)
+ // Lastly, check for any errors.
+ if (this->state_ == SQLITE_ERROR || this->state_ == SQLITE_MISUSE)
throw Exception (this->query_.parent_);
}
//
// get_data
//
-void Record::get_data (size_t column,
- char * buffer,
- size_t bufsize)
+void Record::get_data (size_t column, char * buffer, size_t bufsize)
{
// Get the size of the data in the column.
-- bufsize;
@@ -78,8 +74,7 @@ void Record::get_data (size_t column,
//
// get_data
//
-void Record::
-get_data (size_t column, ACE_CString & value)
+void Record::get_data (size_t column, ACE_CString & value)
{
size_t size = ::sqlite3_column_bytes (this->query_.stmt_, column);
@@ -92,24 +87,7 @@ get_data (size_t column, ACE_CString & value)
//
// get_data
//
-void Record::get_data (size_t column, char & value)
-{
- value = *::sqlite3_column_text (this->query_.stmt_, column);
-}
-
-//
-// get_data
-//
-void Record::get_data (size_t column, unsigned char & value)
-{
- value = *::sqlite3_column_text (this->query_.stmt_, column);
-}
-
-//
-// get_data
-//
-void Record::
-get_data (size_t column, ACE_Date_Time & datetime)
+void Record::get_data (size_t column, ACE_Date_Time & datetime)
{
long value;
const unsigned char * text = ::sqlite3_column_text (this->query_.stmt_,
@@ -147,67 +125,6 @@ get_data (size_t column, ACE_Date_Time & datetime)
}
//
-// get_data
-//
-void Record::get_data (size_t column, short & value)
-{
- int val = ::sqlite3_column_int (this->query_.stmt_, column);
- value = static_cast <short> (val);
-}
-
-//
-// get_data
-//
-void Record::get_data (size_t column, unsigned short & value)
-{
- int val = ::sqlite3_column_int (this->query_.stmt_, column);
- value = static_cast <unsigned short> (val);
-}
-
-//
-// get_data
-//
-void Record::get_data (size_t column, long & value)
-{
- int val = ::sqlite3_column_int (this->query_.stmt_, column);
- value = static_cast <long> (val);
-}
-
-//
-// get_data
-//
-void Record::get_data (size_t column, unsigned long & value)
-{
- int val = ::sqlite3_column_int (this->query_.stmt_, column);
- value = static_cast <unsigned long> (val);
-}
-
-//
-// get_data
-//
-void Record::get_data (size_t column, float & value)
-{
- double val = ::sqlite3_column_double (this->query_.stmt_, column);
- value = static_cast <float> (val);
-}
-
-//
-// get_data
-//
-void Record::get_data (size_t column, double & value)
-{
- value = ::sqlite3_column_double (this->query_.stmt_, column);
-}
-
-//
-// done
-//
-bool Record::done (void) const
-{
- return this->state_ == SQLITE_DONE;
-}
-
-//
// column_name
//
const char * Record::column_name (size_t index)
diff --git a/ADBC/adbc/SQLite/Record.h b/ADBC/adbc/SQLite/Record.h
index 2271c56e848..a1676db254f 100644
--- a/ADBC/adbc/SQLite/Record.h
+++ b/ADBC/adbc/SQLite/Record.h
@@ -10,11 +10,11 @@
*/
//=============================================================================
-#ifndef _CUTS_DB_SQLITE_RECORD_H_
-#define _CUTS_DB_SQLITE_RECORD_H_
+#ifndef _ADBC_DB_SQLITE_RECORD_H_
+#define _ADBC_DB_SQLITE_RECORD_H_
-#include "SQLite_export.h"
#include "adbc/Record.h"
+#include "SQLite_export.h"
namespace ADBC
{
@@ -106,4 +106,4 @@ private:
#include "Record.inl"
#endif
-#endif // !defined _CUTS_DB_SQLITE_RECORD_H_
+#endif // !defined _ADBC_DB_SQLITE_RECORD_H_
diff --git a/ADBC/adbc/SQLite/Record.inl b/ADBC/adbc/SQLite/Record.inl
index 4b9b861990b..0b690eb16ca 100644
--- a/ADBC/adbc/SQLite/Record.inl
+++ b/ADBC/adbc/SQLite/Record.inl
@@ -1,5 +1,7 @@
// $Id$
+#include "Query.h"
+
namespace ADBC
{
namespace SQLite
@@ -11,7 +13,7 @@ ADBC_INLINE
Record::
Record (const Query & query)
: query_ (query),
- state_ (101) /* SQLITE_DONE */
+ state_ (SQLITE_OK)
{
}
@@ -24,5 +26,100 @@ Record::~Record (void)
{
}
+
+//
+// count
+//
+ADBC_INLINE
+size_t Record::columns (void) const
+{
+ return ::sqlite3_column_count (this->query_.stmt_);
+}
+
+//
+// get_data
+//
+ADBC_INLINE
+void Record::get_data (size_t column, char & value)
+{
+ value = *::sqlite3_column_text (this->query_.stmt_, column);
+}
+
+//
+// get_data
+//
+ADBC_INLINE
+void Record::get_data (size_t column, unsigned char & value)
+{
+ value = *::sqlite3_column_text (this->query_.stmt_, column);
+}
+
+//
+// get_data
+//
+ADBC_INLINE
+void Record::get_data (size_t column, short & value)
+{
+ int val = ::sqlite3_column_int (this->query_.stmt_, column);
+ value = static_cast <short> (val);
+}
+
+//
+// get_data
+//
+ADBC_INLINE
+void Record::get_data (size_t column, unsigned short & value)
+{
+ int val = ::sqlite3_column_int (this->query_.stmt_, column);
+ value = static_cast <unsigned short> (val);
+}
+
+//
+// get_data
+//
+ADBC_INLINE
+void Record::get_data (size_t column, long & value)
+{
+ int val = ::sqlite3_column_int (this->query_.stmt_, column);
+ value = static_cast <long> (val);
+}
+
+//
+// get_data
+//
+ADBC_INLINE
+void Record::get_data (size_t column, unsigned long & value)
+{
+ int val = ::sqlite3_column_int (this->query_.stmt_, column);
+ value = static_cast <unsigned long> (val);
+}
+
+//
+// get_data
+//
+ADBC_INLINE
+void Record::get_data (size_t column, float & value)
+{
+ double val = ::sqlite3_column_double (this->query_.stmt_, column);
+ value = static_cast <float> (val);
+}
+
+//
+// get_data
+//
+ADBC_INLINE
+void Record::get_data (size_t column, double & value)
+{
+ value = ::sqlite3_column_double (this->query_.stmt_, column);
+}
+
+//
+// done
+//
+ADBC_INLINE
+bool Record::done (void) const
+{
+ return this->state_ == SQLITE_DONE;
+}
}
}
diff --git a/ADBC/adbc/SQLite/Types.h b/ADBC/adbc/SQLite/Types.h
index ac18212a82d..4367bacf58b 100644
--- a/ADBC/adbc/SQLite/Types.h
+++ b/ADBC/adbc/SQLite/Types.h
@@ -104,4 +104,4 @@ private:
#include "Types.inl"
#endif
-#endif // !defined _CUTS_DB_SQLITE_TYPES_H_
+#endif // !defined _ADBC_DB_SQLITE_TYPES_H_
diff --git a/ADBC/default.features.tmpl b/ADBC/default.features.tmpl
new file mode 100644
index 00000000000..15b861d666c
--- /dev/null
+++ b/ADBC/default.features.tmpl
@@ -0,0 +1,26 @@
+// $Id$
+
+// @feature sqlite3
+//
+// Enable this feature to build the SQLite3 backend.
+
+sqlite3=1
+
+// @feature unixodbc
+//
+// Enable this feature to build the UnixODBC backend. This should
+// be set to 0 when building on Windows platforms.
+
+unixodbc=0
+
+// @feature iodbc
+//
+// Enable this feature to build the iODBC backend. This should be
+// set to 0 when building on Windows platforms.
+
+iodbc=0
+
+// @feature boost
+//
+// Enable this feature to build projects that require Boost.
+boost=0 \ No newline at end of file
diff --git a/ADBC/examples/SQLite/simple/simple.cpp b/ADBC/examples/SQLite/simple/simple.cpp
index 5b5b77e1de1..756ebf20d20 100644
--- a/ADBC/examples/SQLite/simple/simple.cpp
+++ b/ADBC/examples/SQLite/simple/simple.cpp
@@ -50,7 +50,7 @@ int ACE_TMAIN (int argc, char * argv [])
// View the results of the query.
ACE_CString timeofday, firstname, middlename, surname;
- for ( ; !record.done (); record.dvance ())
+ for ( ; !record.done (); record.advance ())
{
record.get_data (1, timeofday);
record.get_data (2, firstname);