mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
synced 2025-12-02 18:23:33 +00:00
convert space indentations to tabs
This commit is contained in:
@@ -1,96 +1,96 @@
|
|||||||
//
|
//
|
||||||
// Connector.cpp
|
// Connector.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/Main/Data/SQLite/src/Connector.cpp#2 $
|
// $Id: //poco/Main/Data/SQLite/src/Connector.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: SQLite
|
// Library: SQLite
|
||||||
// Package: SQLite
|
// Package: SQLite
|
||||||
// Module: Connector
|
// Module: Connector
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// and Contributors.
|
// and Contributors.
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person or organization
|
// Permission is hereby granted, free of charge, to any person or organization
|
||||||
// obtaining a copy of the software and accompanying documentation covered by
|
// obtaining a copy of the software and accompanying documentation covered by
|
||||||
// this license (the "Software") to use, reproduce, display, distribute,
|
// this license (the "Software") to use, reproduce, display, distribute,
|
||||||
// execute, and transmit the Software, and to prepare derivative works of the
|
// 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
|
// Software, and to permit third-parties to whom the Software is furnished to
|
||||||
// do so, all subject to the following:
|
// do so, all subject to the following:
|
||||||
//
|
//
|
||||||
// The copyright notices in the Software and this entire statement, including
|
// The copyright notices in the Software and this entire statement, including
|
||||||
// the above license grant, this restriction and the following disclaimer,
|
// 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
|
// 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
|
// all derivative works of the Software, unless such copies or derivative
|
||||||
// works are solely in the form of machine-executable object code generated by
|
// works are solely in the form of machine-executable object code generated by
|
||||||
// a source language processor.
|
// a source language processor.
|
||||||
//
|
//
|
||||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
// 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
|
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||||
// DEALINGS IN THE SOFTWARE.
|
// DEALINGS IN THE SOFTWARE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Data/SQLite/Connector.h"
|
#include "Poco/Data/SQLite/Connector.h"
|
||||||
#include "Poco/Data/SQLite/SessionImpl.h"
|
#include "Poco/Data/SQLite/SessionImpl.h"
|
||||||
#include "Poco/Data/SessionFactory.h"
|
#include "Poco/Data/SessionFactory.h"
|
||||||
#if defined(POCO_UNBUNDLED)
|
#if defined(POCO_UNBUNDLED)
|
||||||
#include <sqlite3.h>
|
#include <sqlite3.h>
|
||||||
#else
|
#else
|
||||||
#include "sqlite3.h"
|
#include "sqlite3.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace SQLite {
|
namespace SQLite {
|
||||||
|
|
||||||
|
|
||||||
const std::string Connector::KEY("sqlite");
|
const std::string Connector::KEY("sqlite");
|
||||||
|
|
||||||
|
|
||||||
Connector::Connector()
|
Connector::Connector()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Connector::~Connector()
|
Connector::~Connector()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Poco::AutoPtr<Poco::Data::SessionImpl> Connector::createSession(const std::string& connectionString,
|
Poco::AutoPtr<Poco::Data::SessionImpl> Connector::createSession(const std::string& connectionString,
|
||||||
std::size_t timeout)
|
std::size_t timeout)
|
||||||
{
|
{
|
||||||
return Poco::AutoPtr<Poco::Data::SessionImpl>(new SessionImpl(connectionString, timeout));
|
return Poco::AutoPtr<Poco::Data::SessionImpl>(new SessionImpl(connectionString, timeout));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Connector::registerConnector()
|
void Connector::registerConnector()
|
||||||
{
|
{
|
||||||
Poco::Data::SessionFactory::instance().add(new Connector());
|
Poco::Data::SessionFactory::instance().add(new Connector());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Connector::unregisterConnector()
|
void Connector::unregisterConnector()
|
||||||
{
|
{
|
||||||
Poco::Data::SessionFactory::instance().remove(KEY);
|
Poco::Data::SessionFactory::instance().remove(KEY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Connector::enableSharedCache(bool flag)
|
void Connector::enableSharedCache(bool flag)
|
||||||
{
|
{
|
||||||
sqlite3_enable_shared_cache(flag ? 1 : 0);
|
sqlite3_enable_shared_cache(flag ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Connector::enableSoftHeapLimit(int limit)
|
void Connector::enableSoftHeapLimit(int limit)
|
||||||
{
|
{
|
||||||
sqlite3_soft_heap_limit(limit);
|
sqlite3_soft_heap_limit(limit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::SQLite
|
} } } // namespace Poco::Data::SQLite
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ Utility::TypeMap Utility::_types;
|
|||||||
|
|
||||||
Utility::Utility()
|
Utility::Utility()
|
||||||
{
|
{
|
||||||
Poco::FastMutex::ScopedLock l(_mutex);
|
Poco::FastMutex::ScopedLock l(_mutex);
|
||||||
|
|
||||||
if (_types.empty())
|
if (_types.empty())
|
||||||
{
|
{
|
||||||
_types.insert(TypeMap::value_type("", MetaColumn::FDT_STRING));
|
_types.insert(TypeMap::value_type("", MetaColumn::FDT_STRING));
|
||||||
_types.insert(TypeMap::value_type("BOOL", MetaColumn::FDT_BOOL));
|
_types.insert(TypeMap::value_type("BOOL", MetaColumn::FDT_BOOL));
|
||||||
_types.insert(TypeMap::value_type("BOOLEAN", MetaColumn::FDT_BOOL));
|
_types.insert(TypeMap::value_type("BOOLEAN", MetaColumn::FDT_BOOL));
|
||||||
@@ -106,14 +106,14 @@ Utility::Utility()
|
|||||||
_types.insert(TypeMap::value_type("VARCHAR", MetaColumn::FDT_STRING));
|
_types.insert(TypeMap::value_type("VARCHAR", MetaColumn::FDT_STRING));
|
||||||
_types.insert(TypeMap::value_type("NCHAR", MetaColumn::FDT_STRING));
|
_types.insert(TypeMap::value_type("NCHAR", MetaColumn::FDT_STRING));
|
||||||
_types.insert(TypeMap::value_type("NCLOB", MetaColumn::FDT_STRING));
|
_types.insert(TypeMap::value_type("NCLOB", MetaColumn::FDT_STRING));
|
||||||
_types.insert(TypeMap::value_type("NTEXT", MetaColumn::FDT_STRING));
|
_types.insert(TypeMap::value_type("NTEXT", MetaColumn::FDT_STRING));
|
||||||
_types.insert(TypeMap::value_type("NVARCHAR", MetaColumn::FDT_STRING));
|
_types.insert(TypeMap::value_type("NVARCHAR", MetaColumn::FDT_STRING));
|
||||||
_types.insert(TypeMap::value_type("BLOB", MetaColumn::FDT_BLOB));
|
_types.insert(TypeMap::value_type("BLOB", MetaColumn::FDT_BLOB));
|
||||||
_types.insert(TypeMap::value_type("DATE", MetaColumn::FDT_DATE));
|
_types.insert(TypeMap::value_type("DATE", MetaColumn::FDT_DATE));
|
||||||
_types.insert(TypeMap::value_type("TIME", MetaColumn::FDT_TIME));
|
_types.insert(TypeMap::value_type("TIME", MetaColumn::FDT_TIME));
|
||||||
_types.insert(TypeMap::value_type("DATETIME", MetaColumn::FDT_TIMESTAMP));
|
_types.insert(TypeMap::value_type("DATETIME", MetaColumn::FDT_TIMESTAMP));
|
||||||
_types.insert(TypeMap::value_type("TIMESTAMP", MetaColumn::FDT_TIMESTAMP));
|
_types.insert(TypeMap::value_type("TIMESTAMP", MetaColumn::FDT_TIMESTAMP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -125,12 +125,12 @@ std::string Utility::lastError(sqlite3 *pDB)
|
|||||||
|
|
||||||
MetaColumn::ColumnDataType Utility::getColumnType(sqlite3_stmt* pStmt, std::size_t pos)
|
MetaColumn::ColumnDataType Utility::getColumnType(sqlite3_stmt* pStmt, std::size_t pos)
|
||||||
{
|
{
|
||||||
poco_assert_dbg (pStmt);
|
poco_assert_dbg (pStmt);
|
||||||
|
|
||||||
static Utility u;
|
static Utility u;
|
||||||
|
|
||||||
const char* pc = sqlite3_column_decltype(pStmt, (int) pos);
|
const char* pc = sqlite3_column_decltype(pStmt, (int) pos);
|
||||||
std::string sqliteType = pc ? pc : "";
|
std::string sqliteType = pc ? pc : "";
|
||||||
Poco::toUpperInPlace(sqliteType);
|
Poco::toUpperInPlace(sqliteType);
|
||||||
sqliteType = sqliteType.substr(0, sqliteType.find_first_of(" ("));
|
sqliteType = sqliteType.substr(0, sqliteType.find_first_of(" ("));
|
||||||
|
|
||||||
@@ -145,63 +145,63 @@ void Utility::throwException(int rc, const std::string& addErrMsg)
|
|||||||
{
|
{
|
||||||
switch (rc)
|
switch (rc)
|
||||||
{
|
{
|
||||||
case SQLITE_OK:
|
case SQLITE_OK:
|
||||||
break;
|
break;
|
||||||
case SQLITE_ERROR:
|
case SQLITE_ERROR:
|
||||||
throw InvalidSQLStatementException(std::string("SQL error or missing database"), addErrMsg);
|
throw InvalidSQLStatementException(std::string("SQL error or missing database"), addErrMsg);
|
||||||
case SQLITE_INTERNAL:
|
case SQLITE_INTERNAL:
|
||||||
throw InternalDBErrorException(std::string("An internal logic error in SQLite"), addErrMsg);
|
throw InternalDBErrorException(std::string("An internal logic error in SQLite"), addErrMsg);
|
||||||
case SQLITE_PERM:
|
case SQLITE_PERM:
|
||||||
throw DBAccessDeniedException(std::string("Access permission denied"), addErrMsg);
|
throw DBAccessDeniedException(std::string("Access permission denied"), addErrMsg);
|
||||||
case SQLITE_ABORT:
|
case SQLITE_ABORT:
|
||||||
throw ExecutionAbortedException(std::string("Callback routine requested an abort"), addErrMsg);
|
throw ExecutionAbortedException(std::string("Callback routine requested an abort"), addErrMsg);
|
||||||
case SQLITE_BUSY:
|
case SQLITE_BUSY:
|
||||||
throw DBLockedException(std::string("The database file is locked"), addErrMsg);
|
throw DBLockedException(std::string("The database file is locked"), addErrMsg);
|
||||||
case SQLITE_LOCKED:
|
case SQLITE_LOCKED:
|
||||||
throw TableLockedException(std::string("A table in the database is locked"), addErrMsg);
|
throw TableLockedException(std::string("A table in the database is locked"), addErrMsg);
|
||||||
case SQLITE_NOMEM:
|
case SQLITE_NOMEM:
|
||||||
throw NoMemoryException(std::string("A malloc() failed"), addErrMsg);
|
throw NoMemoryException(std::string("A malloc() failed"), addErrMsg);
|
||||||
case SQLITE_READONLY:
|
case SQLITE_READONLY:
|
||||||
throw ReadOnlyException(std::string("Attempt to write a readonly database"), addErrMsg);
|
throw ReadOnlyException(std::string("Attempt to write a readonly database"), addErrMsg);
|
||||||
case SQLITE_INTERRUPT:
|
case SQLITE_INTERRUPT:
|
||||||
throw InterruptException(std::string("Operation terminated by sqlite_interrupt()"), addErrMsg);
|
throw InterruptException(std::string("Operation terminated by sqlite_interrupt()"), addErrMsg);
|
||||||
case SQLITE_IOERR:
|
case SQLITE_IOERR:
|
||||||
throw IOErrorException(std::string("Some kind of disk I/O error occurred"), addErrMsg);
|
throw IOErrorException(std::string("Some kind of disk I/O error occurred"), addErrMsg);
|
||||||
case SQLITE_CORRUPT:
|
case SQLITE_CORRUPT:
|
||||||
throw CorruptImageException(std::string("The database disk image is malformed"), addErrMsg);
|
throw CorruptImageException(std::string("The database disk image is malformed"), addErrMsg);
|
||||||
case SQLITE_NOTFOUND:
|
case SQLITE_NOTFOUND:
|
||||||
throw TableNotFoundException(std::string("Table or record not found"), addErrMsg);
|
throw TableNotFoundException(std::string("Table or record not found"), addErrMsg);
|
||||||
case SQLITE_FULL:
|
case SQLITE_FULL:
|
||||||
throw DatabaseFullException(std::string("Insertion failed because database is full"), addErrMsg);
|
throw DatabaseFullException(std::string("Insertion failed because database is full"), addErrMsg);
|
||||||
case SQLITE_CANTOPEN:
|
case SQLITE_CANTOPEN:
|
||||||
throw CantOpenDBFileException(std::string("Unable to open the database file"), addErrMsg);
|
throw CantOpenDBFileException(std::string("Unable to open the database file"), addErrMsg);
|
||||||
case SQLITE_PROTOCOL:
|
case SQLITE_PROTOCOL:
|
||||||
throw LockProtocolException(std::string("Database lock protocol error"), addErrMsg);
|
throw LockProtocolException(std::string("Database lock protocol error"), addErrMsg);
|
||||||
case SQLITE_EMPTY:
|
case SQLITE_EMPTY:
|
||||||
throw InternalDBErrorException(std::string("(Internal Only) Database table is empty"), addErrMsg);
|
throw InternalDBErrorException(std::string("(Internal Only) Database table is empty"), addErrMsg);
|
||||||
case SQLITE_SCHEMA:
|
case SQLITE_SCHEMA:
|
||||||
throw SchemaDiffersException(std::string("The database schema changed"), addErrMsg);
|
throw SchemaDiffersException(std::string("The database schema changed"), addErrMsg);
|
||||||
case SQLITE_TOOBIG:
|
case SQLITE_TOOBIG:
|
||||||
throw RowTooBigException(std::string("Too much data for one row of a table"), addErrMsg);
|
throw RowTooBigException(std::string("Too much data for one row of a table"), addErrMsg);
|
||||||
case SQLITE_CONSTRAINT:
|
case SQLITE_CONSTRAINT:
|
||||||
throw ConstraintViolationException(std::string("Abort due to constraint violation"), addErrMsg);
|
throw ConstraintViolationException(std::string("Abort due to constraint violation"), addErrMsg);
|
||||||
case SQLITE_MISMATCH:
|
case SQLITE_MISMATCH:
|
||||||
throw DataTypeMismatchException(std::string("Data type mismatch"), addErrMsg);
|
throw DataTypeMismatchException(std::string("Data type mismatch"), addErrMsg);
|
||||||
case SQLITE_MISUSE:
|
case SQLITE_MISUSE:
|
||||||
throw InvalidLibraryUseException(std::string("Library used incorrectly"), addErrMsg);
|
throw InvalidLibraryUseException(std::string("Library used incorrectly"), addErrMsg);
|
||||||
case SQLITE_NOLFS:
|
case SQLITE_NOLFS:
|
||||||
throw OSFeaturesMissingException(std::string("Uses OS features not supported on host"), addErrMsg);
|
throw OSFeaturesMissingException(std::string("Uses OS features not supported on host"), addErrMsg);
|
||||||
case SQLITE_AUTH:
|
case SQLITE_AUTH:
|
||||||
throw AuthorizationDeniedException(std::string("Authorization denied"), addErrMsg);
|
throw AuthorizationDeniedException(std::string("Authorization denied"), addErrMsg);
|
||||||
case SQLITE_FORMAT:
|
case SQLITE_FORMAT:
|
||||||
throw CorruptImageException(std::string("Auxiliary database format error"), addErrMsg);
|
throw CorruptImageException(std::string("Auxiliary database format error"), addErrMsg);
|
||||||
case SQLITE_NOTADB:
|
case SQLITE_NOTADB:
|
||||||
throw CorruptImageException(std::string("File opened that is not a database file"), addErrMsg);
|
throw CorruptImageException(std::string("File opened that is not a database file"), addErrMsg);
|
||||||
case SQLITE_RANGE:
|
case SQLITE_RANGE:
|
||||||
throw InvalidSQLStatementException(std::string("Bind Parameter out of range (Access of invalid position 0? bind starts with 1!)"), addErrMsg);
|
throw InvalidSQLStatementException(std::string("Bind Parameter out of range (Access of invalid position 0? bind starts with 1!)"), addErrMsg);
|
||||||
case SQLITE_ROW:
|
case SQLITE_ROW:
|
||||||
break; // sqlite_step() has another row ready
|
break; // sqlite_step() has another row ready
|
||||||
case SQLITE_DONE:
|
case SQLITE_DONE:
|
||||||
break; // sqlite_step() has finished executing
|
break; // sqlite_step() has finished executing
|
||||||
default:
|
default:
|
||||||
throw SQLiteException(std::string("Unkown error code: ") + Poco::NumberFormatter::format(rc), addErrMsg);
|
throw SQLiteException(std::string("Unkown error code: ") + Poco::NumberFormatter::format(rc), addErrMsg);
|
||||||
|
|||||||
Reference in New Issue
Block a user