committed Data

This commit is contained in:
Guenter Obiltschnig
2007-05-12 14:41:03 +00:00
parent cf80f255be
commit 01bcb63000
177 changed files with 100448 additions and 0 deletions

View File

@@ -0,0 +1,196 @@
//
// Binder.h
//
// $Id: //poco/Main/Data/SQLite/include/Poco/Data/SQLite/Binder.h#3 $
//
// Library: SQLite
// Package: SQLite
// Module: Binder
//
// Definition of the Binder class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef DataConnectors_SQLite_Binder_INCLUDED
#define DataConnectors_SQLite_Binder_INCLUDED
#include "Poco/Data/SQLite/SQLite.h"
#include "Poco/Data/AbstractBinder.h"
#include "Poco/Any.h"
struct sqlite3_stmt;
namespace Poco {
namespace Data {
namespace SQLite {
class SQLite_API Binder: public Poco::Data::AbstractBinder
/// Binds placeholders in the sql query to the provided values. Performs data types mapping.
{
public:
Binder(sqlite3_stmt* pStmt);
/// Creates the Binder.
~Binder();
/// Destroys the Binder.
void bind(std::size_t pos, const Poco::Int8 &val);
/// Binds an Int8.
void bind(std::size_t pos, const Poco::UInt8 &val);
/// Binds an UInt8.
void bind(std::size_t pos, const Poco::Int16 &val);
/// Binds an Int16.
void bind(std::size_t pos, const Poco::UInt16 &val);
/// Binds an UInt16.
void bind(std::size_t pos, const Poco::Int32 &val);
/// Binds an Int32.
void bind(std::size_t pos, const Poco::UInt32 &val);
/// Binds an UInt32.
void bind(std::size_t pos, const Poco::Int64 &val);
/// Binds an Int64.
void bind(std::size_t pos, const Poco::UInt64 &val);
/// Binds an UInt64.
void bind(std::size_t pos, const bool &val);
/// Binds a boolean.
void bind(std::size_t pos, const float &val);
/// Binds a float.
void bind(std::size_t pos, const double &val);
/// Binds a double.
void bind(std::size_t pos, const char &val);
/// Binds a single character.
void bind(std::size_t pos, const char* const &pVal);
/// Binds a const char ptr.
void bind(std::size_t pos, const std::string& val);
/// Binds a string.
void bind(std::size_t pos, const Poco::Data::BLOB& val);
/// Binds a BLOB.
private:
void checkReturn(int rc);
/// Checks the SQLite return code and throws an appropriate exception.
private:
sqlite3_stmt* _pStmt;
};
//
// inlines
//
inline void Binder::bind(std::size_t pos, const Poco::Int8 &val)
{
Poco::Int32 tmp = val;
bind(pos, tmp);
}
inline void Binder::bind(std::size_t pos, const Poco::UInt8 &val)
{
Poco::Int32 tmp = val;
bind(pos, tmp);
}
inline void Binder::bind(std::size_t pos, const Poco::Int16 &val)
{
Poco::Int32 tmp = val;
bind(pos, tmp);
}
inline void Binder::bind(std::size_t pos, const Poco::UInt16 &val)
{
Poco::Int32 tmp = val;
bind(pos, tmp);
}
inline void Binder::bind(std::size_t pos, const Poco::UInt32 &val)
{
Poco::Int32 tmp = static_cast<Poco::Int32>(val);
bind(pos, tmp);
}
inline void Binder::bind(std::size_t pos, const Poco::UInt64 &val)
{
Poco::Int64 tmp = static_cast<Poco::Int64>(val);
bind(pos, tmp);
}
inline void Binder::bind(std::size_t pos, const bool &val)
{
Poco::Int32 tmp = (val ? 1 : 0);
bind(pos, tmp);
}
inline void Binder::bind(std::size_t pos, const float &val)
{
double tmp = val;
bind(pos, tmp);
}
inline void Binder::bind(std::size_t pos, const char &val)
{
Poco::Int32 tmp = val;
bind(pos, tmp);
}
inline void Binder::bind(std::size_t pos, const char* const &pVal)
{
std::string val(pVal);
bind(pos, val);
}
} } } // namespace Poco::Data::SQLite
#endif // DataConnectors_SQLite_Binder_INCLUDED

View File

@@ -0,0 +1,123 @@
//
// Extractor.h
//
// $Id: //poco/Main/Data/SQLite/include/Poco/Data/SQLite/Extractor.h#3 $
//
// Library: SQLite
// Package: SQLite
// Module: Extractor
//
// Definition of the Extractor class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef DataConnectors_SQLite_Extractor_INCLUDED
#define DataConnectors_SQLite_Extractor_INCLUDED
#include "Poco/Data/SQLite/SQLite.h"
#include "Poco/Data/AbstractExtractor.h"
#include "Poco/Any.h"
struct sqlite3_stmt;
namespace Poco {
namespace Data {
namespace SQLite {
class SQLite_API Extractor: public Poco::Data::AbstractExtractor
/// Extracts and converts data values form the result row returned by SQLite.
/// If NULL is received, the incoming val value is not changed and false is returned
{
public:
Extractor(sqlite3_stmt* pStmt);
/// Creates the Extractor.
~Extractor();
/// Destroys the Extractor.
bool extract(std::size_t pos, Poco::Int8& val);
/// Extracts an Int8.
bool extract(std::size_t pos, Poco::UInt8& val);
/// Extracts an UInt8.
bool extract(std::size_t pos, Poco::Int16& val);
/// Extracts an Int16.
bool extract(std::size_t pos, Poco::UInt16& val);
/// Extracts an UInt16.
bool extract(std::size_t pos, Poco::Int32& val);
/// Extracts an Int32.
bool extract(std::size_t pos, Poco::UInt32& val);
/// Extracts an UInt32.
bool extract(std::size_t pos, Poco::Int64& val);
/// Extracts an Int64.
bool extract(std::size_t pos, Poco::UInt64& val);
/// Extracts an UInt64.
bool extract(std::size_t pos, bool& val);
/// Extracts a boolean.
bool extract(std::size_t pos, float& val);
/// Extracts a float.
bool extract(std::size_t pos, double& val);
/// Extracts a double.
bool extract(std::size_t pos, char& val);
/// Extracts a single character.
bool extract(std::size_t pos, std::string& val);
/// Extracts a string.
bool extract(std::size_t pos, Poco::Data::BLOB& val);
/// Extracts a BLOB.
bool extract(std::size_t pos, Poco::Any& val);
/// Extracts an Any.
private:
bool isNull(std::size_t pos);
/// Returns true if a non null value can be extracted
sqlite3_stmt* _pStmt;
};
} } } // namespace Poco::Data::SQLite
#endif // DataConnectors_SQLite_Extractor_INCLUDED

View File

@@ -0,0 +1,92 @@
//
// SQLite.h
//
// $Id: //poco/Main/Data/SQLite/include/Poco/Data/SQLite/SQLite.h#3 $
//
// Library: SQLite
// Package: SQLIte
// Module: SQLite
//
// Basic definitions for the Poco SQLite library.
// This file must be the first file included by every other SQLite
// header file.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef SQLite_SQLite_INCLUDED
#define SQLite_SQLite_INCLUDED
#include "Poco/Foundation.h"
//
// The following block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the SQLite_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// SQLite_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
//
#if defined(_WIN32) && defined(POCO_DLL)
#if defined(SQLite_EXPORTS)
#define SQLite_API __declspec(dllexport)
#else
#define SQLite_API __declspec(dllimport)
#endif
#endif
#if !defined(SQLite_API)
#define SQLite_API
#endif
//
// Automatically link Data library.
//
#if defined(_MSC_VER)
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(SQLite_EXPORTS)
#if defined(POCO_DLL)
#if defined(_DEBUG)
#pragma comment(lib, "PocoSQLited.lib")
#else
#pragma comment(lib, "PocoSQLite.lib")
#endif
#else
#if defined(_DEBUG)
#pragma comment(lib, "PocoSQLitemtd.lib")
#else
#pragma comment(lib, "PocoSQLitemt.lib")
#endif
#endif
#endif
#endif
#endif // SQLite_SQLite_INCLUDED

View File

@@ -0,0 +1,81 @@
//
// SQLiteException.h
//
// $Id: //poco/Main/Data/SQLite/include/Poco/Data/SQLite/SQLiteException.h#2 $
//
// Library: SQLite
// Package: SQLite
// Module: SQLiteException
//
// Definition of SQLiteException.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef SQLite_SQLiteException_INCLUDED
#define SQLite_SQLiteException_INCLUDED
#include "Poco/Data/SQLite/SQLite.h"
#include "Poco/Data/DataException.h"
namespace Poco {
namespace Data {
namespace SQLite {
POCO_DECLARE_EXCEPTION(SQLite_API, SQLiteException, Poco::Data::DataException)
POCO_DECLARE_EXCEPTION(SQLite_API, InvalidSQLStatementException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, InternalDBErrorException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, DBAccessDeniedException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, ExecutionAbortedException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, DBLockedException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, TableLockedException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, NoMemoryException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, ReadOnlyException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, InterruptException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, IOErrorException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, CorruptImageException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, TableNotFoundException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, DatabaseFullException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, CantOpenDBFileException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, LockProtocolException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, SchemaDiffersException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, RowTooBigException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, ConstraintViolationException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, DataTypeMismatchException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, InvalidLibraryUseException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, OSFeaturesMissingException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, AuthorizationDeniedException, SQLiteException)
POCO_DECLARE_EXCEPTION(SQLite_API, TransactionException, SQLiteException)
} } } // namespace Poco::Data::SQLite
#endif

View File

@@ -0,0 +1,134 @@
//
// SQLiteStatementImpl.h
//
// $Id: //poco/Main/Data/SQLite/include/Poco/Data/SQLite/SQLiteStatementImpl.h#3 $
//
// Library: SQLite
// Package: SQLite
// Module: SQLiteStatementImpl
//
// Definition of the SQLiteStatementImpl class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef DataConnectors_SQLite_SQLiteStatementImpl_INCLUDED
#define DataConnectors_SQLite_SQLiteStatementImpl_INCLUDED
#include "Poco/Data/SQLite/SQLite.h"
#include "Poco/Data/SQLite/Binder.h"
#include "Poco/Data/SQLite/Extractor.h"
#include "Poco/Data/StatementImpl.h"
#include "Poco/Data/MetaColumn.h"
#include "Poco/SharedPtr.h"
struct sqlite3;
struct sqlite3_stmt;
namespace Poco {
namespace Data {
namespace SQLite {
class SQLite_API SQLiteStatementImpl: public Poco::Data::StatementImpl
/// Implements statement functionality needed for SQLite
{
public:
SQLiteStatementImpl(sqlite3* pDB);
/// Creates the SQLiteStatementImpl.
~SQLiteStatementImpl();
/// Destroys the SQLiteStatementImpl.
protected:
Poco::UInt32 columnsReturned() const;
/// Returns number of columns returned by query.
const MetaColumn& metaColumn(Poco::UInt32 pos) const;
/// Returns column meta data.
bool hasNext();
/// Returns true if a call to next() will return data.
void next();
/// Retrieves the next row from the resultset.
/// Will throw, if the resultset is empty.
bool canBind() const;
/// Returns true if a valid statement is set and we can bind.
void compileImpl();
/// Compiles the statement, doesn't bind yet
void bindImpl();
/// Binds parameters
AbstractExtractor& extractor();
/// Returns the concrete extractor used by the statement.
AbstractBinder& binder();
/// Returns the concrete binder used by the statement.
private:
void clear();
/// Removes the _pStmt
typedef Poco::Data::AbstractBindingVec Bindings;
typedef Poco::Data::AbstractExtractionVec Extractions;
sqlite3* _pDB;
sqlite3_stmt* _pStmt;
bool _stepCalled;
int _nextResponse;
Poco::SharedPtr<Binder> _pBinder;
Poco::SharedPtr<Extractor> _pExtractor;
std::vector<Poco::Data::MetaColumn> _columns;
};
//
// inlines
//
inline AbstractExtractor& SQLiteStatementImpl::extractor()
{
return *_pExtractor;
}
inline AbstractBinder& SQLiteStatementImpl::binder()
{
return *_pBinder;
}
} } } // namespace Poco::Data::SQLite
#endif // DataConnectors_SQLite_SQLiteStatementImpl_INCLUDED

View File

@@ -0,0 +1,103 @@
//
// SessionImpl.h
//
// $Id: //poco/Main/Data/SQLite/include/Poco/Data/SQLite/SessionImpl.h#2 $
//
// Library: SQLite
// Package: SQLite
// Module: SessionImpl
//
// Definition of the SessionImpl class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef DataConnectors_SQLite_SessionImpl_INCLUDED
#define DataConnectors_SQLite_SessionImpl_INCLUDED
#include "Poco/Data/SQLite/SQLite.h"
#include "Poco/Data/SQLite/Binder.h"
#include "Poco/Data/AbstractSessionImpl.h"
#include "Poco/SharedPtr.h"
struct sqlite3;
struct sqlite3_stmt;
namespace Poco {
namespace Data {
namespace SQLite {
class SQLite_API SessionImpl: public Poco::Data::AbstractSessionImpl<SessionImpl>
/// Implements SessionImpl interface.
{
public:
SessionImpl(const std::string& fileName);
/// Creates the SessionImpl. Opens a connection to the database.
~SessionImpl();
/// Destroys the SessionImpl.
Poco::Data::StatementImpl* createStatementImpl();
/// Returns an SQLite StatementImpl.
void begin();
/// Starts a transaction.
void commit();
/// Commits and ends a transaction.
void rollback();
/// Aborts a transaction.
void close();
/// Closes the session.
bool isConnected();
/// Returns true if connected, false otherwise.
private:
void open();
/// Opens a connection to the Database.
std::string _dbFileName;
sqlite3* _pDB;
bool _connected;
static const std::string DEFERRED_BEGIN_TRANSACTION;
static const std::string COMMIT_TRANSACTION;
static const std::string ABORT_TRANSACTION;
};
} } } // namespace Poco::Data::SQLite
#endif // DataConnectors_SQLite_SessionImpl_INCLUDED

View File

@@ -0,0 +1,79 @@
//
// SessionInstantiator.h
//
// $Id: //poco/Main/Data/SQLite/include/Poco/Data/SQLite/SessionInstantiator.h#2 $
//
// Library: SQLite
// Package: SQLite
// Module: SessionInstantiator
//
// Definition of the SessionInstantiator class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef DataConnectors_SQLite_SessionInstantiator_INCLUDED
#define DataConnectors_SQLite_SessionInstantiator_INCLUDED
#include "Poco/Data/SQLite/SQLite.h"
#include "Poco/Data/SessionInstantiator.h"
namespace Poco {
namespace Data {
namespace SQLite {
class SQLite_API SessionInstantiator: public Poco::Data::SessionInstantiator
/// SessionInstantiator instantiates SqLite SessionImpl objects.
{
public:
static const std::string KEY;
/// Keyword for creating SQLite sessions.
SessionInstantiator();
/// Creates the SessionInstantiator.
~SessionInstantiator();
/// Destroys the SessionInstantiator.
Poco::AutoPtr<Poco::Data::SessionImpl> create(const std::string& initString);
/// Creates a SQLite SessionImpl object and initializes it with the given initString.
static void addToFactory();
/// Registers the SessionInstantiator under the Keyword SessionInstantiator::KEY at the Poco::Data::SessionFactory.
static void removeFromFactory();
/// Unregisters the SessionInstantiator under the Keyword SessionInstantiator::KEY at the Poco::Data::SessionFactory.
};
} } } // namespace Poco::Data::SQLite
#endif // DataConnectors_SQLite_SessionInstantiator_INCLUDED

View File

@@ -0,0 +1,74 @@
//
// Utility.h
//
// $Id: //poco/Main/Data/SQLite/include/Poco/Data/SQLite/Utility.h#2 $
//
// Library: SQLite
// Package: SQLite
// Module: Utility
//
// Definition of Utility.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef SQLite_Utility_INCLUDED
#define SQLite_Utility_INCLUDED
#include "Poco/Data/SQLite/SQLite.h"
#include "Poco/Data/MetaColumn.h"
struct sqlite3;
struct sqlite3_stmt;
namespace Poco {
namespace Data {
namespace SQLite {
class SQLite_API Utility
/// Various utility functions for SQLite, mostly return code handling
{
public:
static std::string lastError(sqlite3* pDb);
/// Retreives the last error code from sqlite and converts it to a string
static void throwException(int rc, const std::string& addErrMsg = std::string());
/// Throws for an error code the appropriate exception
static MetaColumn::ColumnDataType getColumnType(sqlite3_stmt* pStmt, std::size_t pos);
/// Returns column data type.
};
} } } // namespace Poco::Data::SQLite
#endif