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

21
Data/SQLite/Makefile Normal file
View File

@@ -0,0 +1,21 @@
#
# Makefile
#
# $Id: //poco/Main/Data/SQLite/Makefile#2 $
#
# Makefile for Poco SQLite
#
include $(POCO_BASE)/build/rules/global
SYSFLAGS += -DTHREADSAFE -DNO_TCL
objects = Binder Extractor SessionImpl SessionInstantiator \
SQLiteException SQLiteStatementImpl Utility \
sqlite3
target = PocoSQLite
target_version = $(LIBVERSION)
target_libs = PocoData PocoFoundation
include $(POCO_BASE)/build/rules/lib

View File

@@ -0,0 +1,30 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SQLite", "SQLite_VS71.vcproj", "{1B29820D-375F-11DB-837B-00123FC423B5}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_VS71.vcproj", "{1B30A91B-375F-11DB-837B-00123FC423B5}"
ProjectSection(ProjectDependencies) = postProject
{1B29820D-375F-11DB-837B-00123FC423B5} = {1B29820D-375F-11DB-837B-00123FC423B5}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
debug_shared = debug_shared
release_shared = release_shared
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{1B29820D-375F-11DB-837B-00123FC423B5}.debug_shared.ActiveCfg = debug_shared|Win32
{1B29820D-375F-11DB-837B-00123FC423B5}.debug_shared.Build.0 = debug_shared|Win32
{1B29820D-375F-11DB-837B-00123FC423B5}.release_shared.ActiveCfg = release_shared|Win32
{1B29820D-375F-11DB-837B-00123FC423B5}.release_shared.Build.0 = release_shared|Win32
{1B30A91B-375F-11DB-837B-00123FC423B5}.debug_shared.ActiveCfg = debug_shared|Win32
{1B30A91B-375F-11DB-837B-00123FC423B5}.debug_shared.Build.0 = debug_shared|Win32
{1B30A91B-375F-11DB-837B-00123FC423B5}.release_shared.ActiveCfg = release_shared|Win32
{1B30A91B-375F-11DB-837B-00123FC423B5}.release_shared.Build.0 = release_shared|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,223 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="SQLite"
ProjectGUID="{1b29820d-375f-11db-837b-00123fc423b5}"
RootNamespace="SQLite"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\include;.\src;..\..\Foundation\include;..\..\Data\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;SQLite_EXPORTS;NO_TCL;THREADSAFE"
StringPooling="TRUE"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
BufferSecurityCheck="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="4"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoDatad.lib"
OutputFile="..\..\bin\PocoSQLited.dll"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="..\..\bin\PocoSQLited.pdb"
SubSystem="1"
OptimizeForWindows98="1"
ImportLibrary="..\..\lib\PocoSQLited.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="release_shared|Win32"
OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared"
ConfigurationType="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="4"
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OmitFramePointers="TRUE"
OptimizeForProcessor="3"
AdditionalIncludeDirectories=".\include;.\src;..\..\Foundation\include;..\..\Data\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;SQLite_EXPORTS;NO_TCL;THREADSAFE"
GeneratePreprocessedFile="0"
KeepComments="FALSE"
StringPooling="TRUE"
RuntimeLibrary="2"
BufferSecurityCheck="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="FALSE"
DebugInformationFormat="0"
CompileAs="0"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoData.lib"
OutputFile="..\..\bin\PocoSQLite.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\..\lib"
GenerateDebugInformation="FALSE"
ProgramDatabaseFile=""
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
OptimizeForWindows98="1"
ImportLibrary="..\..\lib\PocoSQLite.lib"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="SQLite"
Filter="">
<Filter
Name="Header Files"
Filter="">
<File
RelativePath=".\include\Poco\Data\SQLite\Binder.h">
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\Extractor.h">
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\SessionImpl.h">
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\SessionInstantiator.h">
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\SQLite.h">
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\SQLiteException.h">
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\SQLiteStatementImpl.h">
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\Utility.h">
</File>
</Filter>
<Filter
Name="Source Files"
Filter="">
<File
RelativePath=".\src\Binder.cpp">
</File>
<File
RelativePath=".\src\Extractor.cpp">
</File>
<File
RelativePath=".\src\SessionImpl.cpp">
</File>
<File
RelativePath=".\src\SessionInstantiator.cpp">
</File>
<File
RelativePath=".\src\SQLiteException.cpp">
</File>
<File
RelativePath=".\src\SQLiteStatementImpl.cpp">
</File>
<File
RelativePath=".\src\Utility.cpp">
</File>
</Filter>
</Filter>
<Filter
Name="3rdparty"
Filter="">
<Filter
Name="Header Files"
Filter="">
<File
RelativePath=".\src\sqlite3.h">
</File>
</Filter>
<Filter
Name="Source Files"
Filter="">
<File
RelativePath=".\src\sqlite3.c">
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,28 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# Visual Studio 2005
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SQLite", "SQLite_VS80.vcproj", "{1B29820D-375F-11DB-837B-00123FC423B5}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_VS80.vcproj", "{1B30A91B-375F-11DB-837B-00123FC423B5}"
ProjectSection(ProjectDependencies) = postProject
{1B29820D-375F-11DB-837B-00123FC423B5} = {1B29820D-375F-11DB-837B-00123FC423B5}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
debug_shared|Win32 = debug_shared|Win32
release_shared|Win32 = release_shared|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{1B29820D-375F-11DB-837B-00123FC423B5}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{1B29820D-375F-11DB-837B-00123FC423B5}.debug_shared|Win32.Build.0 = debug_shared|Win32
{1B29820D-375F-11DB-837B-00123FC423B5}.release_shared|Win32.ActiveCfg = release_shared|Win32
{1B29820D-375F-11DB-837B-00123FC423B5}.release_shared|Win32.Build.0 = release_shared|Win32
{1B30A91B-375F-11DB-837B-00123FC423B5}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{1B30A91B-375F-11DB-837B-00123FC423B5}.debug_shared|Win32.Build.0 = debug_shared|Win32
{1B30A91B-375F-11DB-837B-00123FC423B5}.release_shared|Win32.ActiveCfg = release_shared|Win32
{1B30A91B-375F-11DB-837B-00123FC423B5}.release_shared|Win32.Build.0 = release_shared|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,301 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="SQLite"
ProjectGUID="{1B29820D-375F-11DB-837B-00123FC423B5}"
RootNamespace="SQLite"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared"
ConfigurationType="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories=".\include;.\src;..\..\Foundation\include;..\..\Data\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;SQLite_EXPORTS;NO_TCL;THREADSAFE"
StringPooling="true"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
BufferSecurityCheck="true"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="4"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoDatad.lib"
OutputFile="..\..\bin\PocoSQLited.dll"
LinkIncremental="2"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\lib"
GenerateDebugInformation="true"
ProgramDatabaseFile="..\..\bin\PocoSQLited.pdb"
SubSystem="1"
OptimizeForWindows98="1"
ImportLibrary="..\..\lib\PocoSQLited.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="release_shared|Win32"
OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared"
ConfigurationType="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="4"
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories=".\include;.\src;..\..\Foundation\include;..\..\Data\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;SQLite_EXPORTS;NO_TCL;THREADSAFE"
GeneratePreprocessedFile="0"
KeepComments="false"
StringPooling="true"
RuntimeLibrary="2"
BufferSecurityCheck="false"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="false"
DebugInformationFormat="0"
CompileAs="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoData.lib"
OutputFile="..\..\bin\PocoSQLite.dll"
LinkIncremental="1"
SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\..\lib"
GenerateDebugInformation="false"
ProgramDatabaseFile=""
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
OptimizeForWindows98="1"
ImportLibrary="..\..\lib\PocoSQLite.lib"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="SQLite"
>
<Filter
Name="Header Files"
>
<File
RelativePath=".\include\Poco\Data\SQLite\Binder.h"
>
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\Extractor.h"
>
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\SessionImpl.h"
>
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\SessionInstantiator.h"
>
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\SQLite.h"
>
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\SQLiteException.h"
>
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\SQLiteStatementImpl.h"
>
</File>
<File
RelativePath=".\include\Poco\Data\SQLite\Utility.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\Binder.cpp"
>
</File>
<File
RelativePath=".\src\Extractor.cpp"
>
</File>
<File
RelativePath=".\src\SessionImpl.cpp"
>
</File>
<File
RelativePath=".\src\SessionInstantiator.cpp"
>
</File>
<File
RelativePath=".\src\SQLiteException.cpp"
>
</File>
<File
RelativePath=".\src\SQLiteStatementImpl.cpp"
>
</File>
<File
RelativePath=".\src\Utility.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="3rdparty"
>
<Filter
Name="Header Files"
>
<File
RelativePath=".\src\sqlite3.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\sqlite3.c"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

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

107
Data/SQLite/src/Binder.cpp Normal file
View File

@@ -0,0 +1,107 @@
//
// Binder.cpp
//
// $Id: //poco/Main/Data/SQLite/src/Binder.cpp#4 $
//
// Library: SQLite
// Package: SQLite
// Module: Binder
//
// 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.
//
#include "Poco/Data/SQLite/Binder.h"
#include "Poco/Data/SQLite/Utility.h"
#include "Poco/Data/BLOB.h"
#include "Poco/Exception.h"
#include "sqlite3.h"
#include <cstdlib>
namespace Poco {
namespace Data {
namespace SQLite {
Binder::Binder(sqlite3_stmt* pStmt):
_pStmt(pStmt)
{
}
Binder::~Binder()
{
}
void Binder::bind(std::size_t pos, const Poco::Int32 &val)
{
int rc = sqlite3_bind_int(_pStmt, (int) pos, val);
checkReturn(rc);
}
void Binder::bind(std::size_t pos, const Poco::Int64 &val)
{
int rc = sqlite3_bind_int64(_pStmt, (int) pos, val);
checkReturn(rc);
}
void Binder::bind(std::size_t pos, const double &val)
{
int rc = sqlite3_bind_double(_pStmt, (int) pos, val);
checkReturn(rc);
}
void Binder::bind(std::size_t pos, const std::string& val)
{
int rc = sqlite3_bind_text(_pStmt, (int) pos, val.c_str(), (int) val.size()*sizeof(char), SQLITE_TRANSIENT);
checkReturn(rc);
}
void Binder::bind(std::size_t pos, const Poco::Data::BLOB& val)
{
// convert a blob to a an unsigned char* array
const unsigned char* pData = reinterpret_cast<const unsigned char*>(val.rawContent());
int valSize = static_cast<int>(val.size());
int rc = sqlite3_bind_blob(_pStmt, static_cast<int>(pos), pData, valSize, SQLITE_STATIC); // no deep copy, do not free memory
checkReturn(rc);
}
void Binder::checkReturn(int rc)
{
if (rc != SQLITE_OK)
Utility::throwException(rc);
}
} } } // namespace Poco::Data::SQLite

View File

@@ -0,0 +1,306 @@
//
// Extractor.cpp
//
// $Id: //poco/Main/Data/SQLite/src/Extractor.cpp#4 $
//
// Library: SQLite
// Package: SQLite
// Module: Extractor
//
// 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.
//
#include "Poco/Data/SQLite/Extractor.h"
#include "Poco/Data/SQLite/Utility.h"
#include "Poco/Data/BLOB.h"
#include "Poco/Data/DataException.h"
#include "Poco/Exception.h"
#include "sqlite3.h"
#include <cstdlib>
namespace Poco {
namespace Data {
namespace SQLite {
Extractor::Extractor(sqlite3_stmt* pStmt):
_pStmt(pStmt)
{
}
Extractor::~Extractor()
{
}
bool Extractor::extract(std::size_t pos, Poco::Int32& val)
{
if (isNull(pos))
return false;
val = sqlite3_column_int(_pStmt, (int) pos);
return true;
}
bool Extractor::extract(std::size_t pos, Poco::Int64& val)
{
if (isNull(pos))
return false;
val = sqlite3_column_int64(_pStmt, (int) pos);
return true;
}
bool Extractor::extract(std::size_t pos, double& val)
{
if (isNull(pos))
return false;
val = sqlite3_column_double(_pStmt, (int) pos);
return true;
}
bool Extractor::extract(std::size_t pos, std::string& val)
{
if (isNull(pos))
return false;
const char *pBuf = reinterpret_cast<const char*>(sqlite3_column_text(_pStmt, (int) pos));
if (!pBuf)
val.clear();
else
val = std::string(pBuf);
return true;
}
bool Extractor::extract(std::size_t pos, Poco::Data::BLOB& val)
{
if (isNull(pos))
return false;
int size = sqlite3_column_bytes(_pStmt, (int) pos);
const char* pTmp = reinterpret_cast<const char*>(sqlite3_column_blob(_pStmt, (int) pos));
val = Poco::Data::BLOB(pTmp, size);
return true;
}
bool Extractor::extract(std::size_t pos, Poco::Int8& val)
{
if (isNull(pos))
return false;
val = sqlite3_column_int(_pStmt, (int) pos);
return true;
}
bool Extractor::extract(std::size_t pos, Poco::UInt8& val)
{
if (isNull(pos))
return false;
val = sqlite3_column_int(_pStmt, (int) pos);
return true;
}
bool Extractor::extract(std::size_t pos, Poco::Int16& val)
{
if (isNull(pos))
return false;
val = sqlite3_column_int(_pStmt, (int) pos);
return true;
}
bool Extractor::extract(std::size_t pos, Poco::UInt16& val)
{
if (isNull(pos))
return false;
val = sqlite3_column_int(_pStmt, (int) pos);
return true;
}
bool Extractor::extract(std::size_t pos, Poco::UInt32& val)
{
if (isNull(pos))
return false;
val = sqlite3_column_int(_pStmt, (int) pos);
return true;
}
bool Extractor::extract(std::size_t pos, Poco::UInt64& val)
{
if (isNull(pos))
return false;
val = sqlite3_column_int64(_pStmt, (int) pos);
return true;
}
bool Extractor::extract(std::size_t pos, bool& val)
{
if (isNull(pos))
return false;
val = (0 != sqlite3_column_int(_pStmt, (int) pos));
return true;
}
bool Extractor::extract(std::size_t pos, float& val)
{
if (isNull(pos))
return false;
val = static_cast<float>(sqlite3_column_double(_pStmt, (int) pos));
return true;
}
bool Extractor::extract(std::size_t pos, char& val)
{
if (isNull(pos)) return false;
val = sqlite3_column_int(_pStmt, (int) pos);
return true;
}
bool Extractor::extract(std::size_t pos, Poco::Any& val)
{
if (isNull(pos)) return false;
bool ret = false;
switch (Utility::getColumnType(_pStmt, pos))
{
case MetaColumn::FDT_BOOL:
{
bool i = false;
ret = extract(pos, i);
val = i;
break;
}
case MetaColumn::FDT_INT8:
{
Poco::Int8 i = 0;
ret = extract(pos, i);
val = i;
break;
}
case MetaColumn::FDT_UINT8:
{
Poco::UInt8 i = 0;
ret = extract(pos, i);
val = i;
break;
}
case MetaColumn::FDT_INT16:
{
Poco::Int16 i = 0;
ret = extract(pos, i);
val = i;
break;
}
case MetaColumn::FDT_UINT16:
{
Poco::UInt16 i = 0;
ret = extract(pos, i);
val = i;
break;
}
case MetaColumn::FDT_INT32:
{
Poco::Int32 i = 0;
ret = extract(pos, i);
val = i;
break;
}
case MetaColumn::FDT_UINT32:
{
Poco::UInt32 i = 0;
ret = extract(pos, i);
val = i;
break;
}
case MetaColumn::FDT_INT64:
{
Poco::Int64 i = 0;
ret = extract(pos, i);
val = i;
break;
}
case MetaColumn::FDT_UINT64:
{
Poco::UInt64 i = 0;
ret = extract(pos, i);
val = i;
break;
}
case MetaColumn::FDT_STRING:
{
std::string s;
ret = extract(pos, s);
val = s;
break;
}
case MetaColumn::FDT_DOUBLE:
{
double d(0.0);
ret = extract(pos, d);
val = d;
break;
}
case MetaColumn::FDT_FLOAT:
{
float f(0.0);
ret = extract(pos, f);
val = f;
break;
}
case MetaColumn::FDT_BLOB:
{
BLOB b;
ret = extract(pos, b);
val = b;
break;
}
default:
throw Poco::Data::UnknownTypeException("Unknown type during extraction");
}
return ret;
}
bool Extractor::isNull(std::size_t pos)
{
return sqlite3_column_type(_pStmt, (int) pos) == SQLITE_NULL;
}
} } } // namespace Poco::Data::SQLite

View File

@@ -0,0 +1,72 @@
//
// SQLiteException.cpp
//
// $Id: //poco/Main/Data/SQLite/src/SQLiteException.cpp#2 $
//
// Library: SQLite
// Package: SQLite
// Module: 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.
//
#include "Poco/Data/SQLite/SQLiteException.h"
#include <typeinfo>
namespace Poco {
namespace Data {
namespace SQLite {
POCO_IMPLEMENT_EXCEPTION(SQLiteException, Poco::Data::DataException, "Generic SQLite error")
POCO_IMPLEMENT_EXCEPTION(InvalidSQLStatementException, SQLiteException, "SQL Statement invalid")
POCO_IMPLEMENT_EXCEPTION(InternalDBErrorException, SQLiteException, "Internal error")
POCO_IMPLEMENT_EXCEPTION(DBAccessDeniedException, SQLiteException, "Access permission denied")
POCO_IMPLEMENT_EXCEPTION(ExecutionAbortedException, SQLiteException, "Execution of SQL statement aborted")
POCO_IMPLEMENT_EXCEPTION(DBLockedException, SQLiteException, "The database is locked")
POCO_IMPLEMENT_EXCEPTION(TableLockedException, SQLiteException, "A table in the database is locked")
POCO_IMPLEMENT_EXCEPTION(NoMemoryException, SQLiteException, "Out of Memory")
POCO_IMPLEMENT_EXCEPTION(ReadOnlyException, SQLiteException, "Attempt to write a readonly database")
POCO_IMPLEMENT_EXCEPTION(InterruptException, SQLiteException, "Operation terminated by an interrupt")
POCO_IMPLEMENT_EXCEPTION(IOErrorException, SQLiteException, "Some kind of disk I/O error occurred")
POCO_IMPLEMENT_EXCEPTION(CorruptImageException, SQLiteException, "The database disk image is malformed")
POCO_IMPLEMENT_EXCEPTION(TableNotFoundException, SQLiteException, "Table not found")
POCO_IMPLEMENT_EXCEPTION(DatabaseFullException, SQLiteException, "Insertion failed because database is full")
POCO_IMPLEMENT_EXCEPTION(CantOpenDBFileException, SQLiteException, "Unable to open the database file")
POCO_IMPLEMENT_EXCEPTION(LockProtocolException, SQLiteException, "Database lock protocol error")
POCO_IMPLEMENT_EXCEPTION(SchemaDiffersException, SQLiteException, "The database schema changed")
POCO_IMPLEMENT_EXCEPTION(RowTooBigException, SQLiteException, "Too much data for one row of a table")
POCO_IMPLEMENT_EXCEPTION(ConstraintViolationException, SQLiteException, "Abort due to constraint violation")
POCO_IMPLEMENT_EXCEPTION(DataTypeMismatchException, SQLiteException, "Data type mismatch")
POCO_IMPLEMENT_EXCEPTION(InvalidLibraryUseException, SQLiteException, "Library used incorrectly")
POCO_IMPLEMENT_EXCEPTION(OSFeaturesMissingException, SQLiteException, "Uses OS features not supported on host")
POCO_IMPLEMENT_EXCEPTION(AuthorizationDeniedException, SQLiteException, "Authorization denied")
POCO_IMPLEMENT_EXCEPTION(TransactionException, SQLiteException, "Transaction exception")
} } } // namespace Poco::Data::SQLite

View File

@@ -0,0 +1,233 @@
//
// SQLiteStatementImpl.cpp
//
// $Id: //poco/Main/Data/SQLite/src/SQLiteStatementImpl.cpp#4 $
//
// Library: SQLite
// Package: SQLite
// Module: SQLiteStatementImpl
//
// 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.
//
#include "Poco/Data/SQLite/SQLiteStatementImpl.h"
#include "Poco/Data/SQLite/Utility.h"
#include "Poco/Data/SQLite/SQLiteException.h"
#include "Poco/String.h"
#include "sqlite3.h"
#include <cstdlib>
namespace Poco {
namespace Data {
namespace SQLite {
SQLiteStatementImpl::SQLiteStatementImpl(sqlite3* pDB):
_pDB(pDB),
_pStmt(0),
_stepCalled(false),
_nextResponse(0)
{
}
SQLiteStatementImpl::~SQLiteStatementImpl()
{
clear();
}
void SQLiteStatementImpl::compileImpl()
{
if (_pStmt) return;
std::string statement(toString());
if (statement.empty())
throw InvalidSQLStatementException("Empty statements are illegal");
sqlite3_stmt* pStmt = 0;
const char* pSql = statement.c_str(); // The SQL to be executed
int rc = SQLITE_OK;
const char* pLeftover = 0;
bool queryFound = false;
while (rc == SQLITE_OK && !pStmt && !queryFound)
{
rc = sqlite3_prepare(_pDB, pSql, -1, &pStmt, &pLeftover);
if (rc != SQLITE_OK)
{
if (pStmt)
{
sqlite3_finalize(pStmt);
}
pStmt = 0;
std::string errMsg = sqlite3_errmsg(_pDB);
Utility::throwException(rc, errMsg);
}
else if (rc == SQLITE_OK && pStmt)
{
queryFound = true;
}
else if(rc == SQLITE_OK && !pStmt) // comment/whitespace ignore
{
pSql = pLeftover;
if (strlen(pSql) == 0)
{
// empty statement or an conditional statement! like CREATE IF NOT EXISTS
// this is valid
queryFound = true;
}
}
}
clear();
_pStmt = pStmt;
// prepare binding
_pBinder = new Binder(_pStmt);
_pExtractor = new Extractor(_pStmt);
int colCount = sqlite3_column_count(_pStmt);
for (int i = 0; i < colCount; ++i)
{
MetaColumn mc(i + 1, sqlite3_column_name(_pStmt, i), Utility::getColumnType(_pStmt, i));
_columns.push_back(mc);
}
}
bool SQLiteStatementImpl::canBind() const
{
bool ret = false;
if (!bindings().empty() && _pStmt)
ret = (*bindings().begin())->canBind();
return ret;
}
void SQLiteStatementImpl::bindImpl()
{
_stepCalled = false;
_nextResponse = 0;
if (_pStmt == 0) return;
sqlite3_reset(_pStmt);
// bind
Bindings& binds = bindings();
if (binds.empty()) return;
std::size_t pos = 1; // sqlite starts with 1 not 0!
Bindings::iterator it = binds.begin();
Bindings::iterator itEnd = binds.end();
for (; it != itEnd && (*it)->canBind(); ++it)
{
(*it)->bind(pos);
pos += (*it)->numOfColumnsHandled();
}
}
void SQLiteStatementImpl::clear()
{
_columns.clear();
if (_pStmt)
{
sqlite3_finalize(_pStmt);
_pStmt=0;
}
}
bool SQLiteStatementImpl::hasNext()
{
if (_stepCalled)
return (_nextResponse == SQLITE_ROW);
// _pStmt is allowed to be null for conditional SQL statements
if (_pStmt == 0)
{
_stepCalled = true;
_nextResponse = SQLITE_DONE;
return false;
}
_stepCalled = true;
_nextResponse = sqlite3_step(_pStmt);
return (_nextResponse == SQLITE_ROW);
}
void SQLiteStatementImpl::next()
{
if (SQLITE_ROW == _nextResponse)
{
poco_assert (columnsReturned() == sqlite3_column_count(_pStmt));
Extractions& extracts = extractions();
Extractions::iterator it = extracts.begin();
Extractions::iterator itEnd = extracts.end();
std::size_t pos = 0; // sqlite starts with pos 0 for results!
for (; it != itEnd; ++it)
{
(*it)->extract(pos);
pos += (*it)->numOfColumnsHandled();
}
_stepCalled = false;
}
else if (SQLITE_DONE == _nextResponse)
{
throw Poco::Data::DataException("No data received");
}
else
{
int rc = _nextResponse;
Utility::throwException(rc, std::string("Iterator Error: trying to access the next value"));
}
}
Poco::UInt32 SQLiteStatementImpl::columnsReturned() const
{
return (Poco::UInt32) _columns.size();
}
const MetaColumn& SQLiteStatementImpl::metaColumn(Poco::UInt32 pos) const
{
poco_assert (pos > 0 && pos <= _columns.size());
return _columns[pos-1];
}
} } } // namespace Poco::Data::SQLite

View File

@@ -0,0 +1,132 @@
//
// SessionImpl.cpp
//
// $Id: //poco/Main/Data/SQLite/src/SessionImpl.cpp#4 $
//
// Library: SQLite
// Package: SQLite
// Module: SessionImpl
//
// 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.
//
#include "Poco/Data/SQLite/SessionImpl.h"
#include "Poco/Data/SQLite/Utility.h"
#include "Poco/Data/SQLite/SQLiteStatementImpl.h"
#include "sqlite3.h"
#include <cstdlib>
namespace Poco {
namespace Data {
namespace SQLite {
const std::string SessionImpl::DEFERRED_BEGIN_TRANSACTION("BEGIN DEFERRED");
const std::string SessionImpl::COMMIT_TRANSACTION("COMMIT");
const std::string SessionImpl::ABORT_TRANSACTION("ROLLBACK");
SessionImpl::SessionImpl(const std::string& fileName):
_dbFileName(fileName),
_pDB(0),
_connected(false)
{
open();
}
SessionImpl::~SessionImpl()
{
close();
}
Poco::Data::StatementImpl* SessionImpl::createStatementImpl()
{
poco_check_ptr (_pDB);
return new SQLiteStatementImpl(_pDB);
}
void SessionImpl::begin()
{
SQLiteStatementImpl tmp(_pDB);
tmp.add(DEFERRED_BEGIN_TRANSACTION);
tmp.execute();
}
void SessionImpl::commit()
{
SQLiteStatementImpl tmp(_pDB);
tmp.add(COMMIT_TRANSACTION);
tmp.execute();
}
void SessionImpl::rollback()
{
SQLiteStatementImpl tmp(_pDB);
tmp.add(ABORT_TRANSACTION);
tmp.execute();
}
void SessionImpl::open()
{
int rc = sqlite3_open(_dbFileName.c_str(), &_pDB);
if (rc != 0)
{
close();
Utility::throwException(rc);
}
_connected = true;
}
void SessionImpl::close()
{
if (_pDB)
{
sqlite3_close(_pDB);
_pDB = 0;
}
_connected = false;
}
bool SessionImpl::isConnected()
{
return _connected;
}
} } } // namespace Poco::Data::SQLite

View File

@@ -0,0 +1,78 @@
//
// SessionInstantiator.cpp
//
// $Id: //poco/Main/Data/SQLite/src/SessionInstantiator.cpp#2 $
//
// Library: SQLite
// Package: SQLite
// Module: SessionInstantiator
//
// 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.
//
#include "Poco/Data/SQLite/SessionInstantiator.h"
#include "Poco/Data/SQLite/SessionImpl.h"
#include "Poco/Data/SessionFactory.h"
namespace Poco {
namespace Data {
namespace SQLite {
const std::string SessionInstantiator::KEY("sqlite");
SessionInstantiator::SessionInstantiator()
{
}
SessionInstantiator::~SessionInstantiator()
{
}
Poco::AutoPtr<Poco::Data::SessionImpl> SessionInstantiator::create(const std::string& initString)
{
return Poco::AutoPtr<Poco::Data::SessionImpl>(new SessionImpl(initString));
}
void SessionInstantiator::addToFactory()
{
Poco::Data::SessionFactory::instance().add(KEY, new SessionInstantiator());
}
void SessionInstantiator::removeFromFactory()
{
Poco::Data::SessionFactory::instance().remove(KEY);
}
} } } // namespace Poco::Data::SQLite

152
Data/SQLite/src/Utility.cpp Normal file
View File

@@ -0,0 +1,152 @@
//
// Utility.cpp
//
// $Id: //poco/Main/Data/SQLite/src/Utility.cpp#4 $
//
// Library: SQLite
// Package: SQLite
// Module: Utility
//
// Implementation 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.
//
#include "Poco/Data/SQLite/Utility.h"
#include "Poco/Data/SQLite/SQLiteException.h"
#include "Poco/NumberFormatter.h"
#include "Poco/String.h"
#include "Poco/Exception.h"
#include "sqlite3.h"
namespace Poco {
namespace Data {
namespace SQLite {
std::string Utility::lastError(sqlite3 *pDB)
{
return std::string(sqlite3_errmsg(pDB));
}
MetaColumn::ColumnDataType Utility::getColumnType(sqlite3_stmt* pStmt, std::size_t pos)
{
poco_assert_dbg (pStmt);
const char* pc = sqlite3_column_decltype(pStmt, (int)pos);
std::string sqliteType = pc ? pc : "";
Poco::toUpperInPlace(sqliteType);
if (sqliteType.npos != sqliteType.find("INT"))
return MetaColumn::FDT_INT32;
else if (sqliteType.empty() ||
sqliteType.npos != sqliteType.find("CHAR") ||
sqliteType.npos != sqliteType.find("CLOB") ||
sqliteType.npos != sqliteType.find("TEXT"))
return MetaColumn::FDT_STRING;
else if (sqliteType.npos != sqliteType.find("REAL") ||
sqliteType.npos != sqliteType.find("FLOA") ||
sqliteType.npos != sqliteType.find("DOUB"))
return MetaColumn::FDT_DOUBLE;
else if (sqliteType.npos != sqliteType.find("BLOB"))
return MetaColumn::FDT_BLOB;
throw Poco::NotFoundException();
}
void Utility::throwException(int rc, const std::string& addErrMsg)
{
switch (rc)
{
case SQLITE_OK:
break;
case SQLITE_ERROR:
throw InvalidSQLStatementException(std::string("SQL error or missing database"), addErrMsg);
case SQLITE_INTERNAL:
throw InternalDBErrorException(std::string("An internal logic error in SQLite"), addErrMsg);
case SQLITE_PERM:
throw DBAccessDeniedException(std::string("Access permission denied"), addErrMsg);
case SQLITE_ABORT:
throw ExecutionAbortedException(std::string("Callback routine requested an abort"), addErrMsg);
case SQLITE_BUSY:
throw DBLockedException(std::string("The database file is locked"), addErrMsg);
case SQLITE_LOCKED:
throw TableLockedException(std::string("A table in the database is locked"), addErrMsg);
case SQLITE_NOMEM:
throw NoMemoryException(std::string("A malloc() failed"), addErrMsg);
case SQLITE_READONLY:
throw ReadOnlyException(std::string("Attempt to write a readonly database"), addErrMsg);
case SQLITE_INTERRUPT:
throw InterruptException(std::string("Operation terminated by sqlite_interrupt()"), addErrMsg);
case SQLITE_IOERR:
throw IOErrorException(std::string("Some kind of disk I/O error occurred"), addErrMsg);
case SQLITE_CORRUPT:
throw CorruptImageException(std::string("The database disk image is malformed"), addErrMsg);
case SQLITE_NOTFOUND:
throw TableNotFoundException(std::string("Table or record not found"), addErrMsg);
case SQLITE_FULL:
throw DatabaseFullException(std::string("Insertion failed because database is full"), addErrMsg);
case SQLITE_CANTOPEN:
throw CantOpenDBFileException(std::string("Unable to open the database file"), addErrMsg);
case SQLITE_PROTOCOL:
throw LockProtocolException(std::string("Database lock protocol error"), addErrMsg);
case SQLITE_EMPTY:
throw InternalDBErrorException(std::string("(Internal Only) Database table is empty"), addErrMsg);
case SQLITE_SCHEMA:
throw SchemaDiffersException(std::string("The database schema changed"), addErrMsg);
case SQLITE_TOOBIG:
throw RowTooBigException(std::string("Too much data for one row of a table"), addErrMsg);
case SQLITE_CONSTRAINT:
throw ConstraintViolationException(std::string("Abort due to constraint violation"), addErrMsg);
case SQLITE_MISMATCH:
throw DataTypeMismatchException(std::string("Data type mismatch"), addErrMsg);
case SQLITE_MISUSE:
throw InvalidLibraryUseException(std::string("Library used incorrectly"), addErrMsg);
case SQLITE_NOLFS:
throw OSFeaturesMissingException(std::string("Uses OS features not supported on host"), addErrMsg);
case SQLITE_AUTH:
throw AuthorizationDeniedException(std::string("Authorization denied"), addErrMsg);
case SQLITE_FORMAT:
throw CorruptImageException(std::string("Auxiliary database format error"), addErrMsg);
case SQLITE_NOTADB:
throw CorruptImageException(std::string("File opened that is not a database file"), addErrMsg);
case SQLITE_RANGE:
throw InvalidSQLStatementException(std::string("Bind Parameter out of range (Access of invalid position 0? bind starts with 1!)"), addErrMsg);
case SQLITE_ROW:
break; // sqlite_step() has another row ready
case SQLITE_DONE:
break; // sqlite_step() has finished executing
default:
throw SQLiteException(std::string("Unkown error code: ") + Poco::NumberFormatter::format(rc), addErrMsg);
}
}
} } } // namespace Poco::Data::SQLite

64901
Data/SQLite/src/sqlite3.c Normal file

File diff suppressed because it is too large Load Diff

1885
Data/SQLite/src/sqlite3.h Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,18 @@
#
# Makefile
#
# $Id: //poco/Main/Data/SQLite/testsuite/Makefile#1 $
#
# Makefile for Poco SQLite testsuite
#
include $(POCO_BASE)/build/rules/global
objects = SQLiteTestSuite Driver \
SQLiteTest
target = testrunner
target_version = 1
target_libs = PocoSQLite PocoData PocoFoundation CppUnit
include $(POCO_BASE)/build/rules/exec

View File

@@ -0,0 +1,185 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="TestSuite"
ProjectGUID="{1b30a91b-375f-11db-837b-00123fc423b5}"
Keyword="Win32Proj">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\include;..\..\..\Foundation\include;..\..\..\CppUnit\include;..\..\..\CppUnit\WinTestRunner\include;..\..\..\Data\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="TRUE"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
BufferSecurityCheck="TRUE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="CppUnitd.lib WinTestRunnerd.lib PocoFoundationd.lib PocoDatad.lib PocoSQLited.lib"
OutputFile="bin/TestSuited.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile="bin/TestSuited.pdb"
SubSystem="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="release_shared|Win32"
OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="4"
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1"
OmitFramePointers="TRUE"
OptimizeForWindowsApplication="TRUE"
AdditionalIncludeDirectories="..\include;..\..\..\Foundation\include;..\..\..\CppUnit\include;..\..\..\CppUnit\WinTestRunner\include;..\..\..\Data\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="TRUE"
RuntimeLibrary="2"
BufferSecurityCheck="FALSE"
TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="CppUnit.lib WinTestRunner.lib PocoFoundation.lib PocoData.lib PocoSQLite.lib"
OutputFile="bin/TestSuite.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="FALSE"
ProgramDatabaseFile=""
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="SQLite"
Filter="">
<Filter
Name="Header Files"
Filter="">
<File
RelativePath=".\src\SQLiteTest.h">
</File>
</Filter>
<Filter
Name="Source Files"
Filter="">
<File
RelativePath=".\src\SQLiteTest.cpp">
</File>
</Filter>
</Filter>
<Filter
Name="_Suite"
Filter="">
<Filter
Name="Header Files"
Filter="">
<File
RelativePath=".\src\SQLiteTestSuite.h">
</File>
</Filter>
<Filter
Name="Source Files"
Filter="">
<File
RelativePath=".\src\SQLiteTestSuite.cpp">
</File>
</Filter>
</Filter>
<Filter
Name="_Driver"
Filter="">
<Filter
Name="Source Files"
Filter="">
<File
RelativePath=".\src\WinDriver.cpp">
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,251 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8,00"
Name="TestSuite"
ProjectGUID="{1B30A91B-375F-11DB-837B-00123FC423B5}"
Keyword="Win32Proj"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\include;..\..\..\Foundation\include;..\..\..\CppUnit\include;..\..\..\CppUnit\WinTestRunner\include;..\..\..\Data\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
BufferSecurityCheck="true"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="CppUnitd.lib WinTestRunnerd.lib PocoFoundationd.lib PocoSQLited.lib PocoDatad.lib"
OutputFile="bin/TestSuited.exe"
LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="true"
ProgramDatabaseFile="bin/TestSuited.pdb"
SubSystem="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="release_shared|Win32"
OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared"
ConfigurationType="1"
UseOfMFC="2"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="4"
InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1"
OmitFramePointers="true"
AdditionalIncludeDirectories="..\include;..\..\..\Foundation\include;..\..\..\CppUnit\include;..\..\..\CppUnit\WinTestRunner\include;..\..\..\Data\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="true"
RuntimeLibrary="2"
BufferSecurityCheck="false"
TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true"
UsePrecompiledHeader="0"
WarningLevel="3"
Detect64BitPortabilityProblems="true"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="CppUnit.lib WinTestRunner.lib PocoFoundation.lib PocoSQLite.lib PocoData.lib"
OutputFile="bin/TestSuite.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="false"
ProgramDatabaseFile=""
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="SQLite"
>
<Filter
Name="Header Files"
>
<File
RelativePath=".\src\SQLiteTest.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\SQLiteTest.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="_Suite"
>
<Filter
Name="Header Files"
>
<File
RelativePath=".\src\SQLiteTestSuite.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\SQLiteTestSuite.cpp"
>
</File>
</Filter>
</Filter>
<Filter
Name="_Driver"
>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\WinDriver.cpp"
>
</File>
</Filter>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@@ -0,0 +1,39 @@
//
// Driver.cpp
//
// $Id: //poco/Main/Data/SQLite/testsuite/src/Driver.cpp#2 $
//
// Console-based test driver for Poco SQLite.
//
// 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.
//
#include "CppUnit/TestRunner.h"
#include "SQLiteTestSuite.h"
CppUnitMain(SQLiteTestSuite)

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,124 @@
//
// SQLiteTest.h
//
// $Id: //poco/Main/Data/SQLite/testsuite/src/SQLiteTest.h#2 $
//
// Definition of the SQLiteTest 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 SQLiteTest_INCLUDED
#define SQLiteTest_INCLUDED
#include "Poco/Data/SQLite/SQLite.h"
#include "CppUnit/TestCase.h"
class SQLiteTest: public CppUnit::TestCase
{
public:
SQLiteTest(const std::string& name);
~SQLiteTest();
void testSimpleAccess();
void testInsertCharPointer();
void testInsertCharPointer2();
void testComplexType();
void testSimpleAccessVector();
void testComplexTypeVector();
void testInsertVector();
void testInsertEmptyVector();
void testInsertSingleBulk();
void testInsertSingleBulkVec();
void testLimit();
void testLimitOnce();
void testLimitPrepare();
void testLimitZero();
void testPrepare();
void testSetSimple();
void testSetComplex();
void testSetComplexUnique();
void testMultiSetSimple();
void testMultiSetComplex();
void testMapComplex();
void testMapComplexUnique();
void testMultiMapComplex();
void testSelectIntoSingle();
void testSelectIntoSingleStep();
void testSelectIntoSingleFail();
void testLowerLimitOk();
void testLowerLimitFail();
void testCombinedLimits();
void testCombinedIllegalLimits();
void testRange();
void testIllegalRange();
void testSingleSelect();
void testEmptyDB();
void testBLOB();
void testBLOBStmt();
void testTuple1();
void testTupleVector1();
void testTuple2();
void testTupleVector2();
void testTuple3();
void testTupleVector3();
void testTuple4();
void testTupleVector4();
void testTuple5();
void testTupleVector5();
void testTuple6();
void testTupleVector6();
void testTuple7();
void testTupleVector7();
void testTuple8();
void testTupleVector8();
void testTuple9();
void testTupleVector9();
void testTuple10();
void testTupleVector10();
void testInternalExtraction();
void testTAC();
void setUp();
void tearDown();
static CppUnit::Test* suite();
private:
};
#endif // SQLiteTest_INCLUDED

View File

@@ -0,0 +1,44 @@
//
// SQLiteTestSuite.cpp
//
// $Id: //poco/Main/Data/SQLite/testsuite/src/SQLiteTestSuite.cpp#2 $
//
// 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.
//
#include "SQLiteTestSuite.h"
#include "SQLiteTest.h"
CppUnit::Test* SQLiteTestSuite::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("SQLiteTestSuite");
pSuite->addTest(SQLiteTest::suite());
return pSuite;
}

View File

@@ -0,0 +1,49 @@
//
// SQLiteTestSuite.h
//
// $Id: //poco/Main/Data/SQLite/testsuite/src/SQLiteTestSuite.h#2 $
//
// Definition of the SQLiteTestSuite 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 SQLiteTestSuite_INCLUDED
#define SQLiteTestSuite_INCLUDED
#include "CppUnit/TestSuite.h"
class SQLiteTestSuite
{
public:
static CppUnit::Test* suite();
};
#endif // SQLiteTestSuite_INCLUDED

View File

@@ -0,0 +1,50 @@
//
// WinDriver.cpp
//
// $Id: //poco/Main/Data/SQLite/testsuite/src/WinDriver.cpp#2 $
//
// Windows test driver for Poco SQLite.
//
// 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.
//
#include "WinTestRunner/WinTestRunner.h"
#include "SQLiteTestSuite.h"
class TestDriver: public CppUnit::WinTestRunnerApp
{
void TestMain()
{
CppUnit::WinTestRunner runner;
runner.addTest(SQLiteTestSuite::suite());
runner.run();
}
};
TestDriver theDriver;