mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
synced 2025-12-08 04:55:36 +00:00
more bugfixes
This commit is contained in:
28
Data/Data_vs90.sln
Normal file
28
Data/Data_vs90.sln
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
|
# Visual Studio 2008
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Data", "Data_vs90.vcproj", "{240E83C3-368D-11DB-9FBC-00123FC423B5}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs90.vcproj", "{24134877-368D-11DB-9FBC-00123FC423B5}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{240E83C3-368D-11DB-9FBC-00123FC423B5} = {240E83C3-368D-11DB-9FBC-00123FC423B5}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
debug_shared|Win32 = debug_shared|Win32
|
||||||
|
release_shared|Win32 = release_shared|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{240E83C3-368D-11DB-9FBC-00123FC423B5}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
|
{240E83C3-368D-11DB-9FBC-00123FC423B5}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
|
{240E83C3-368D-11DB-9FBC-00123FC423B5}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
|
{240E83C3-368D-11DB-9FBC-00123FC423B5}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
|
{24134877-368D-11DB-9FBC-00123FC423B5}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
|
{24134877-368D-11DB-9FBC-00123FC423B5}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
|
{24134877-368D-11DB-9FBC-00123FC423B5}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
|
{24134877-368D-11DB-9FBC-00123FC423B5}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
449
Data/Data_vs90.vcproj
Normal file
449
Data/Data_vs90.vcproj
Normal file
@@ -0,0 +1,449 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="Data"
|
||||||
|
ProjectGUID="{240E83C3-368D-11DB-9FBC-00123FC423B5}"
|
||||||
|
RootNamespace="Data"
|
||||||
|
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;..\Foundation\include"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;Data_EXPORTS"
|
||||||
|
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"
|
||||||
|
OutputFile="..\bin\PocoDatad.dll"
|
||||||
|
LinkIncremental="2"
|
||||||
|
SuppressStartupBanner="true"
|
||||||
|
AdditionalLibraryDirectories="..\lib"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
ProgramDatabaseFile="..\bin\PocoDatad.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeForWindows98="0"
|
||||||
|
ImportLibrary="..\lib\PocoDatad.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;..\Foundation\include"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;Data_EXPORTS"
|
||||||
|
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"
|
||||||
|
OutputFile="..\bin\PocoData.dll"
|
||||||
|
LinkIncremental="1"
|
||||||
|
SuppressStartupBanner="true"
|
||||||
|
AdditionalLibraryDirectories="..\lib"
|
||||||
|
GenerateDebugInformation="false"
|
||||||
|
ProgramDatabaseFile=""
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
OptimizeForWindows98="0"
|
||||||
|
ImportLibrary="..\lib\PocoData.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="DataCore"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\AbstractBinder.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\AbstractBinding.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\AbstractExtraction.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\AbstractExtractor.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\AbstractPreparation.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\AbstractPrepare.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\AbstractSessionImpl.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\Binding.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\BLOB.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\BLOBStream.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\Column.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\Common.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\Connector.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\Data.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\DataException.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\Extraction.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\Limit.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\MetaColumn.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\Prepare.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\Range.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\RecordSet.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\Session.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\SessionFactory.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\SessionImpl.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\Statement.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\StatementCreator.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\StatementImpl.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\TypeHandler.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\AbstractBinder.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\AbstractBinding.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\AbstractExtraction.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\AbstractExtractor.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\AbstractPreparation.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\AbstractPrepare.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\BLOB.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\BLOBStream.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Connector.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\DataException.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Limit.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\MetaColumn.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Range.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\RecordSet.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Session.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SessionFactory.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SessionImpl.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Statement.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\StatementCreator.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\StatementImpl.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="SessionPooling"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\PooledSessionHolder.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\PooledSessionImpl.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\SessionPool.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\PooledSessionHolder.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\PooledSessionImpl.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SessionPool.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
29
Data/MySQL/MySQL_vs90.sln
Normal file
29
Data/MySQL/MySQL_vs90.sln
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
|
# Visual Studio 2008
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs90.vcproj", "{1B30A91B-375F-11DB-837B-00123FC423B5}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{73E19FDE-1570-488C-B3DB-72A60FADD408} = {73E19FDE-1570-488C-B3DB-72A60FADD408}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MySQL", "MySQL_vs90.vcproj", "{73E19FDE-1570-488C-B3DB-72A60FADD408}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
debug_shared|Win32 = debug_shared|Win32
|
||||||
|
release_shared|Win32 = release_shared|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{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
|
||||||
|
{73E19FDE-1570-488C-B3DB-72A60FADD408}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
|
{73E19FDE-1570-488C-B3DB-72A60FADD408}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
|
{73E19FDE-1570-488C-B3DB-72A60FADD408}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
|
{73E19FDE-1570-488C-B3DB-72A60FADD408}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
279
Data/MySQL/MySQL_vs90.vcproj
Normal file
279
Data/MySQL/MySQL_vs90.vcproj
Normal file
@@ -0,0 +1,279 @@
|
|||||||
|
<?xml version="1.0" encoding="windows-1251"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="MySQL"
|
||||||
|
ProjectGUID="{73E19FDE-1570-488C-B3DB-72A60FADD408}"
|
||||||
|
RootNamespace="MySQL"
|
||||||
|
Keyword="Win32Proj"
|
||||||
|
>
|
||||||
|
<Platforms>
|
||||||
|
<Platform
|
||||||
|
Name="Win32"
|
||||||
|
/>
|
||||||
|
</Platforms>
|
||||||
|
<ToolFiles>
|
||||||
|
</ToolFiles>
|
||||||
|
<Configurations>
|
||||||
|
<Configuration
|
||||||
|
Name="debug_shared|Win32"
|
||||||
|
OutputDirectory="obj\$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="obj\$(ConfigurationName)"
|
||||||
|
ConfigurationType="2"
|
||||||
|
CharacterSet="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
Optimization="0"
|
||||||
|
AdditionalIncludeDirectories="../../Foundation/include;../../Data/include;./include;"
|
||||||
|
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;MYSQL_EXPORTS;POCO_DLL;NO_TCL;THREADSAFE;__LCC__"
|
||||||
|
MinimalRebuild="true"
|
||||||
|
BasicRuntimeChecks="3"
|
||||||
|
RuntimeLibrary="3"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="false"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="libmysql.lib"
|
||||||
|
OutputFile="../../bin/PocoMySQLd.dll"
|
||||||
|
LinkIncremental="2"
|
||||||
|
AdditionalLibraryDirectories="../../lib"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="2"
|
||||||
|
ImportLibrary="../../lib/PocoMySQLd.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\$(ConfigurationName)"
|
||||||
|
IntermediateDirectory="obj\$(ConfigurationName)"
|
||||||
|
ConfigurationType="2"
|
||||||
|
CharacterSet="1"
|
||||||
|
WholeProgramOptimization="1"
|
||||||
|
>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreBuildEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCustomBuildTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCXMLDataGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCWebServiceProxyGeneratorTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCMIDLTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCCLCompilerTool"
|
||||||
|
AdditionalIncludeDirectories="../../Foundation/include;../../Data/include;./include;"
|
||||||
|
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;MYSQL_EXPORTS;POCO_DLL;NO_TCL;THREADSAFE;__LCC__"
|
||||||
|
RuntimeLibrary="2"
|
||||||
|
UsePrecompiledHeader="0"
|
||||||
|
WarningLevel="3"
|
||||||
|
Detect64BitPortabilityProblems="false"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="libmysql.lib"
|
||||||
|
OutputFile="../../bin/PocoMySQL.dll"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="../../lib"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
SubSystem="2"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
ImportLibrary="../../lib/PocoMySQL.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="Source Files"
|
||||||
|
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||||
|
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Binder.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Connector.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Extractor.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\MySQLException.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\MySQLStatementImpl.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ResultMetadata.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SessionHandle.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SessionImpl.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\StatementExecutor.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||||
|
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\MySQL\Binder.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\MySQL\Connector.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\MySQL\Extractor.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\MySQL\MySQL.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\MySQL\MySQLException.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\MySQL\MySQLStatementImpl.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\MySQL\ResultMetadata.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\MySQL\SessionHandle.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\MySQL\SessionImpl.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\MySQL\StatementExecutor.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Resource Files"
|
||||||
|
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||||
|
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
@@ -1,132 +1,132 @@
|
|||||||
//
|
//
|
||||||
// Binder.h
|
// Binder.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/Binder.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/Binder.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: Binder
|
// Module: Binder
|
||||||
//
|
//
|
||||||
// Definition of the Binder class.
|
// Definition of the Binder class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Data_MySQL_Binder_INCLUDED
|
#ifndef Data_MySQL_Binder_INCLUDED
|
||||||
#define Data_MySQL_Binder_INCLUDED
|
#define Data_MySQL_Binder_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Data/MySQL/MySQL.h"
|
#include "Poco/Data/MySQL/MySQL.h"
|
||||||
#include "Poco/Data/AbstractBinder.h"
|
#include "Poco/Data/AbstractBinder.h"
|
||||||
#include "Poco/Data/BLOB.h"
|
#include "Poco/Data/BLOB.h"
|
||||||
#include "Poco/Data/MySQL/MySQLException.h"
|
#include "Poco/Data/MySQL/MySQLException.h"
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
class MySQL_API Binder: public Poco::Data::AbstractBinder
|
class MySQL_API Binder: public Poco::Data::AbstractBinder
|
||||||
/// Binds placeholders in the sql query to the provided values. Performs data types mapping.
|
/// Binds placeholders in the sql query to the provided values. Performs data types mapping.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Binder();
|
Binder();
|
||||||
/// Creates the Binder.
|
/// Creates the Binder.
|
||||||
|
|
||||||
virtual ~Binder();
|
virtual ~Binder();
|
||||||
/// Destroys the Binder.
|
/// Destroys the Binder.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const Poco::Int8& val);
|
virtual void bind(std::size_t pos, const Poco::Int8& val);
|
||||||
/// Binds an Int8.
|
/// Binds an Int8.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const Poco::UInt8& val);
|
virtual void bind(std::size_t pos, const Poco::UInt8& val);
|
||||||
/// Binds an UInt8.
|
/// Binds an UInt8.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const Poco::Int16& val);
|
virtual void bind(std::size_t pos, const Poco::Int16& val);
|
||||||
/// Binds an Int16.
|
/// Binds an Int16.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const Poco::UInt16& val);
|
virtual void bind(std::size_t pos, const Poco::UInt16& val);
|
||||||
/// Binds an UInt16.
|
/// Binds an UInt16.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const Poco::Int32& val);
|
virtual void bind(std::size_t pos, const Poco::Int32& val);
|
||||||
/// Binds an Int32.
|
/// Binds an Int32.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const Poco::UInt32& val);
|
virtual void bind(std::size_t pos, const Poco::UInt32& val);
|
||||||
/// Binds an UInt32.
|
/// Binds an UInt32.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const Poco::Int64& val);
|
virtual void bind(std::size_t pos, const Poco::Int64& val);
|
||||||
/// Binds an Int64.
|
/// Binds an Int64.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const Poco::UInt64& val);
|
virtual void bind(std::size_t pos, const Poco::UInt64& val);
|
||||||
/// Binds an UInt64.
|
/// Binds an UInt64.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const bool& val);
|
virtual void bind(std::size_t pos, const bool& val);
|
||||||
/// Binds a boolean.
|
/// Binds a boolean.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const float& val);
|
virtual void bind(std::size_t pos, const float& val);
|
||||||
/// Binds a float.
|
/// Binds a float.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const double& val);
|
virtual void bind(std::size_t pos, const double& val);
|
||||||
/// Binds a double.
|
/// Binds a double.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const char& val);
|
virtual void bind(std::size_t pos, const char& val);
|
||||||
/// Binds a single character.
|
/// Binds a single character.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const std::string& val);
|
virtual void bind(std::size_t pos, const std::string& val);
|
||||||
/// Binds a string.
|
/// Binds a string.
|
||||||
|
|
||||||
virtual void bind(std::size_t pos, const Poco::Data::BLOB& val);
|
virtual void bind(std::size_t pos, const Poco::Data::BLOB& val);
|
||||||
/// Binds a BLOB.
|
/// Binds a BLOB.
|
||||||
|
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
/// Return count of binded parameters
|
/// Return count of binded parameters
|
||||||
|
|
||||||
MYSQL_BIND* getBindArray() const;
|
MYSQL_BIND* getBindArray() const;
|
||||||
/// Return array
|
/// Return array
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void bind(std::size_t, const char* const&)
|
virtual void bind(std::size_t, const char* const&)
|
||||||
/// Binds a const char ptr.
|
/// Binds a const char ptr.
|
||||||
/// This is a private no-op in this implementation
|
/// This is a private no-op in this implementation
|
||||||
/// due to security risk.
|
/// due to security risk.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void realBind(std::size_t pos, enum_field_types type, const void* buffer, int length);
|
void realBind(std::size_t pos, enum_field_types type, const void* buffer, int length);
|
||||||
/// Common bind implementation
|
/// Common bind implementation
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<MYSQL_BIND> _bindArray;
|
std::vector<MYSQL_BIND> _bindArray;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|
||||||
|
|
||||||
#endif // Data_MySQL_Binder_INCLUDED
|
#endif // Data_MySQL_Binder_INCLUDED
|
||||||
|
|||||||
@@ -1,78 +1,78 @@
|
|||||||
//
|
//
|
||||||
// Connector.h
|
// Connector.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/Connector.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/Connector.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: Connector
|
// Module: Connector
|
||||||
//
|
//
|
||||||
// Definition of the Connector class.
|
// Definition of the Connector class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Data_MySQL_Connector_INCLUDED
|
#ifndef Data_MySQL_Connector_INCLUDED
|
||||||
#define Data_MySQL_Connector_INCLUDED
|
#define Data_MySQL_Connector_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "MySQL.h"
|
#include "MySQL.h"
|
||||||
#include "Poco/Data/Connector.h"
|
#include "Poco/Data/Connector.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
class MySQL_API Connector: public Poco::Data::Connector
|
class MySQL_API Connector: public Poco::Data::Connector
|
||||||
/// Connector instantiates MySQL SessionImpl objects.
|
/// Connector instantiates MySQL SessionImpl objects.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::string KEY;
|
static std::string KEY;
|
||||||
|
|
||||||
Connector();
|
Connector();
|
||||||
/// Creates the Connector.
|
/// Creates the Connector.
|
||||||
|
|
||||||
virtual ~Connector();
|
virtual ~Connector();
|
||||||
/// Destroys the Connector.
|
/// Destroys the Connector.
|
||||||
|
|
||||||
virtual Poco::AutoPtr<Poco::Data::SessionImpl> createSession(const std::string& connectionString);
|
virtual Poco::AutoPtr<Poco::Data::SessionImpl> createSession(const std::string& connectionString);
|
||||||
/// Creates a MySQL SessionImpl object and initializes it with the given connectionString.
|
/// Creates a MySQL SessionImpl object and initializes it with the given connectionString.
|
||||||
|
|
||||||
static void registerConnector();
|
static void registerConnector();
|
||||||
/// Registers the Connector under the Keyword Connector::KEY at the Poco::Data::SessionFactory.
|
/// Registers the Connector under the Keyword Connector::KEY at the Poco::Data::SessionFactory.
|
||||||
|
|
||||||
static void unregisterConnector();
|
static void unregisterConnector();
|
||||||
/// Unregisters the Connector under the Keyword Connector::KEY at the Poco::Data::SessionFactory.
|
/// Unregisters the Connector under the Keyword Connector::KEY at the Poco::Data::SessionFactory.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|
||||||
|
|
||||||
#endif // Data_MySQL_Connector_INCLUDED
|
#endif // Data_MySQL_Connector_INCLUDED
|
||||||
|
|||||||
@@ -1,123 +1,123 @@
|
|||||||
//
|
//
|
||||||
// Extractor.h
|
// Extractor.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/Extractor.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/Extractor.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: Extractor
|
// Module: Extractor
|
||||||
//
|
//
|
||||||
// Definition of the Extractor class.
|
// Definition of the Extractor class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Data_MySQL_Extractor_INCLUDED
|
#ifndef Data_MySQL_Extractor_INCLUDED
|
||||||
#define Data_MySQL_Extractor_INCLUDED
|
#define Data_MySQL_Extractor_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Data/MySQL/MySQL.h"
|
#include "Poco/Data/MySQL/MySQL.h"
|
||||||
#include "Poco/Data/MySQL/StatementExecutor.h"
|
#include "Poco/Data/MySQL/StatementExecutor.h"
|
||||||
#include "Poco/Data/MySQL/ResultMetadata.h"
|
#include "Poco/Data/MySQL/ResultMetadata.h"
|
||||||
#include "Poco/Data/AbstractExtractor.h"
|
#include "Poco/Data/AbstractExtractor.h"
|
||||||
#include "Poco/Data/BLOB.h"
|
#include "Poco/Data/BLOB.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
class MySQL_API Extractor: public Poco::Data::AbstractExtractor
|
class MySQL_API Extractor: public Poco::Data::AbstractExtractor
|
||||||
/// Extracts and converts data values from the result row returned by MySQL.
|
/// Extracts and converts data values from the result row returned by MySQL.
|
||||||
/// If NULL is received, the incoming val value is not changed and false is returned
|
/// If NULL is received, the incoming val value is not changed and false is returned
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Extractor(StatementExecutor& st, ResultMetadata& md);
|
Extractor(StatementExecutor& st, ResultMetadata& md);
|
||||||
/// Creates the Extractor.
|
/// Creates the Extractor.
|
||||||
|
|
||||||
virtual ~Extractor();
|
virtual ~Extractor();
|
||||||
/// Destroys the Extractor.
|
/// Destroys the Extractor.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, Poco::Int8& val);
|
virtual bool extract(std::size_t pos, Poco::Int8& val);
|
||||||
/// Extracts an Int8.
|
/// Extracts an Int8.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, Poco::UInt8& val);
|
virtual bool extract(std::size_t pos, Poco::UInt8& val);
|
||||||
/// Extracts an UInt8.
|
/// Extracts an UInt8.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, Poco::Int16& val);
|
virtual bool extract(std::size_t pos, Poco::Int16& val);
|
||||||
/// Extracts an Int16.
|
/// Extracts an Int16.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, Poco::UInt16& val);
|
virtual bool extract(std::size_t pos, Poco::UInt16& val);
|
||||||
/// Extracts an UInt16.
|
/// Extracts an UInt16.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, Poco::Int32& val);
|
virtual bool extract(std::size_t pos, Poco::Int32& val);
|
||||||
/// Extracts an Int32.
|
/// Extracts an Int32.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, Poco::UInt32& val);
|
virtual bool extract(std::size_t pos, Poco::UInt32& val);
|
||||||
/// Extracts an UInt32.
|
/// Extracts an UInt32.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, Poco::Int64& val);
|
virtual bool extract(std::size_t pos, Poco::Int64& val);
|
||||||
/// Extracts an Int64.
|
/// Extracts an Int64.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, Poco::UInt64& val);
|
virtual bool extract(std::size_t pos, Poco::UInt64& val);
|
||||||
/// Extracts an UInt64.
|
/// Extracts an UInt64.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, bool& val);
|
virtual bool extract(std::size_t pos, bool& val);
|
||||||
/// Extracts a boolean.
|
/// Extracts a boolean.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, float& val);
|
virtual bool extract(std::size_t pos, float& val);
|
||||||
/// Extracts a float.
|
/// Extracts a float.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, double& val);
|
virtual bool extract(std::size_t pos, double& val);
|
||||||
/// Extracts a double.
|
/// Extracts a double.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, char& val);
|
virtual bool extract(std::size_t pos, char& val);
|
||||||
/// Extracts a single character.
|
/// Extracts a single character.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, std::string& val);
|
virtual bool extract(std::size_t pos, std::string& val);
|
||||||
/// Extracts a string.
|
/// Extracts a string.
|
||||||
|
|
||||||
virtual bool extract(std::size_t pos, Poco::Data::BLOB& val);
|
virtual bool extract(std::size_t pos, Poco::Data::BLOB& val);
|
||||||
/// Extracts a BLOB.
|
/// Extracts a BLOB.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, size_t length = 0);
|
bool realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, size_t length = 0);
|
||||||
|
|
||||||
// Prevent VC8 warning "operator= could not be generated"
|
// Prevent VC8 warning "operator= could not be generated"
|
||||||
Extractor& operator=(const Extractor&);
|
Extractor& operator=(const Extractor&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StatementExecutor& _stmt;
|
StatementExecutor& _stmt;
|
||||||
ResultMetadata& _metadata;
|
ResultMetadata& _metadata;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|
||||||
|
|
||||||
#endif // Data_MySQL_Extractor_INCLUDED
|
#endif // Data_MySQL_Extractor_INCLUDED
|
||||||
|
|||||||
@@ -1,90 +1,90 @@
|
|||||||
//
|
//
|
||||||
// MySQL.h
|
// MySQL.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/MySQL.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/MySQL.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: MySQL
|
// Module: MySQL
|
||||||
//
|
//
|
||||||
// Basic definitions for the MySQL library.
|
// Basic definitions for the MySQL library.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef MySQL_MySQL_INCLUDED
|
#ifndef MySQL_MySQL_INCLUDED
|
||||||
#define MySQL_MySQL_INCLUDED
|
#define MySQL_MySQL_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// The following block is the standard way of creating macros which make exporting
|
// 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 ODBC_EXPORTS
|
// from a DLL simpler. All files within this DLL are compiled with the ODBC_EXPORTS
|
||||||
// symbol defined on the command line. this symbol should not be defined on any project
|
// 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
|
// that uses this DLL. This way any other project whose source files include this file see
|
||||||
// ODBC_API functions as being imported from a DLL, wheras this DLL sees symbols
|
// ODBC_API functions as being imported from a DLL, wheras this DLL sees symbols
|
||||||
// defined with this macro as being exported.
|
// defined with this macro as being exported.
|
||||||
//
|
//
|
||||||
#if defined(_WIN32) && defined(POCO_DLL)
|
#if defined(_WIN32) && defined(POCO_DLL)
|
||||||
#if defined(MYSQL_EXPORTS)
|
#if defined(MYSQL_EXPORTS)
|
||||||
#define MySQL_API __declspec(dllexport)
|
#define MySQL_API __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define MySQL_API __declspec(dllimport)
|
#define MySQL_API __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if !defined(MySQL_API)
|
#if !defined(MySQL_API)
|
||||||
#define MySQL_API
|
#define MySQL_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Automatically link Data library.
|
// Automatically link Data library.
|
||||||
//
|
//
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(MYSQL_EXPORTS)
|
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(MYSQL_EXPORTS)
|
||||||
#if defined(POCO_DLL)
|
#if defined(POCO_DLL)
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
#pragma comment(lib, "PocoMySQLd.lib")
|
#pragma comment(lib, "PocoMySQLd.lib")
|
||||||
#else
|
#else
|
||||||
#pragma comment(lib, "PocoMySQL.lib")
|
#pragma comment(lib, "PocoMySQL.lib")
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
#pragma comment(lib, "PocoMySQLmtd.lib")
|
#pragma comment(lib, "PocoMySQLmtd.lib")
|
||||||
#else
|
#else
|
||||||
#pragma comment(lib, "PocoMySQLmt.lib")
|
#pragma comment(lib, "PocoMySQLmt.lib")
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif // MySQL_MySQL_INCLUDED
|
#endif // MySQL_MySQL_INCLUDED
|
||||||
|
|||||||
@@ -1,163 +1,163 @@
|
|||||||
//
|
//
|
||||||
// MySQLException.h
|
// MySQLException.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/MySQLException.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/MySQLException.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: MySQLException
|
// Module: MySQLException
|
||||||
//
|
//
|
||||||
// Definition of the MySQLException class.
|
// Definition of the MySQLException class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Data_MySQL_MySQLException_INCLUDED
|
#ifndef Data_MySQL_MySQLException_INCLUDED
|
||||||
#define Data_MySQL_MySQLException_INCLUDED
|
#define Data_MySQL_MySQLException_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Data/MySQL/MySQL.h"
|
#include "Poco/Data/MySQL/MySQL.h"
|
||||||
#include "Poco/Data/DataException.h"
|
#include "Poco/Data/DataException.h"
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
typedef struct st_mysql MYSQL;
|
typedef struct st_mysql MYSQL;
|
||||||
typedef struct st_mysql_stmt MYSQL_STMT;
|
typedef struct st_mysql_stmt MYSQL_STMT;
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
class MySQL_API MySQLException: public Poco::Data::DataException
|
class MySQL_API MySQLException: public Poco::Data::DataException
|
||||||
/// Base class for all MySQL exceptions
|
/// Base class for all MySQL exceptions
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MySQLException(const std::string& msg);
|
MySQLException(const std::string& msg);
|
||||||
/// Creates MySQLException.
|
/// Creates MySQLException.
|
||||||
|
|
||||||
MySQLException(const MySQLException& exc);
|
MySQLException(const MySQLException& exc);
|
||||||
/// Creates MySQLException.
|
/// Creates MySQLException.
|
||||||
|
|
||||||
~MySQLException() throw();
|
~MySQLException() throw();
|
||||||
/// Destroys MySQLexception.
|
/// Destroys MySQLexception.
|
||||||
|
|
||||||
MySQLException& operator=(const MySQLException& exc);
|
MySQLException& operator=(const MySQLException& exc);
|
||||||
/// Assignment operator.
|
/// Assignment operator.
|
||||||
|
|
||||||
const char* name() const throw();
|
const char* name() const throw();
|
||||||
/// Returns exception name.
|
/// Returns exception name.
|
||||||
|
|
||||||
const char* className() const throw();
|
const char* className() const throw();
|
||||||
/// Returns the name of the exception class.
|
/// Returns the name of the exception class.
|
||||||
|
|
||||||
Poco::Exception* clone() const;
|
Poco::Exception* clone() const;
|
||||||
/// Creates an exact copy of the exception.
|
/// Creates an exact copy of the exception.
|
||||||
///
|
///
|
||||||
/// The copy can later be thrown again by
|
/// The copy can later be thrown again by
|
||||||
/// invoking rethrow() on it.
|
/// invoking rethrow() on it.
|
||||||
|
|
||||||
void rethrow() const;
|
void rethrow() const;
|
||||||
/// (Re)Throws the exception.
|
/// (Re)Throws the exception.
|
||||||
///
|
///
|
||||||
/// This is useful for temporarily storing a
|
/// This is useful for temporarily storing a
|
||||||
/// copy of an exception (see clone()), then
|
/// copy of an exception (see clone()), then
|
||||||
/// throwing it again.
|
/// throwing it again.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class ConnectionException : public MySQLException
|
class ConnectionException : public MySQLException
|
||||||
/// ConnectionException
|
/// ConnectionException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConnectionException(const std::string& msg);
|
ConnectionException(const std::string& msg);
|
||||||
/// Creates ConnectionException.
|
/// Creates ConnectionException.
|
||||||
|
|
||||||
ConnectionException(const std::string& text, MYSQL* h);
|
ConnectionException(const std::string& text, MYSQL* h);
|
||||||
/// Destroys ConnectionException.
|
/// Destroys ConnectionException.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::string compose(const std::string& text, MYSQL* h);
|
static std::string compose(const std::string& text, MYSQL* h);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class StatementException : public MySQLException
|
class StatementException : public MySQLException
|
||||||
/// StatementException
|
/// StatementException
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StatementException(const std::string& msg);
|
StatementException(const std::string& msg);
|
||||||
/// Creates StatementException.
|
/// Creates StatementException.
|
||||||
|
|
||||||
StatementException(const std::string& text, MYSQL_STMT* h, const std::string& stmt = "");
|
StatementException(const std::string& text, MYSQL_STMT* h, const std::string& stmt = "");
|
||||||
/// Destroys StatementException.
|
/// Destroys StatementException.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static std::string compose(const std::string& text, MYSQL_STMT* h, const std::string& stmt);
|
static std::string compose(const std::string& text, MYSQL_STMT* h, const std::string& stmt);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline MySQLException& MySQLException::operator=(const MySQLException& exc)
|
inline MySQLException& MySQLException::operator=(const MySQLException& exc)
|
||||||
{
|
{
|
||||||
Poco::Data::DataException::operator=(exc);
|
Poco::Data::DataException::operator=(exc);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const char* MySQLException::name() const throw()
|
inline const char* MySQLException::name() const throw()
|
||||||
{
|
{
|
||||||
return "MySQL";
|
return "MySQL";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const char* MySQLException::className() const throw()
|
inline const char* MySQLException::className() const throw()
|
||||||
{
|
{
|
||||||
return typeid(*this).name();
|
return typeid(*this).name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Poco::Exception* MySQLException::clone() const
|
inline Poco::Exception* MySQLException::clone() const
|
||||||
{
|
{
|
||||||
return new MySQLException(*this);
|
return new MySQLException(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void MySQLException::rethrow() const
|
inline void MySQLException::rethrow() const
|
||||||
{
|
{
|
||||||
throw *this;
|
throw *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|
||||||
|
|
||||||
#endif //Data_MySQL_MySQLException_INCLUDED
|
#endif //Data_MySQL_MySQLException_INCLUDED
|
||||||
|
|||||||
@@ -1,117 +1,117 @@
|
|||||||
//
|
//
|
||||||
// MySQLstatementImpl.h
|
// MySQLstatementImpl.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/MySQLStatementImpl.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/MySQLStatementImpl.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: MySQLstatementImpl
|
// Module: MySQLstatementImpl
|
||||||
//
|
//
|
||||||
// Definition of the MySQLStatementImpl class.
|
// Definition of the MySQLStatementImpl class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Data_MySQL_MySQLStatementImpl_INCLUDED
|
#ifndef Data_MySQL_MySQLStatementImpl_INCLUDED
|
||||||
#define Data_MySQL_MySQLStatementImpl_INCLUDED
|
#define Data_MySQL_MySQLStatementImpl_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Data/MySQL/MySQL.h"
|
#include "Poco/Data/MySQL/MySQL.h"
|
||||||
#include "Poco/Data/MySQL/SessionImpl.h"
|
#include "Poco/Data/MySQL/SessionImpl.h"
|
||||||
#include "Poco/Data/MySQL/Binder.h"
|
#include "Poco/Data/MySQL/Binder.h"
|
||||||
#include "Poco/Data/MySQL/Extractor.h"
|
#include "Poco/Data/MySQL/Extractor.h"
|
||||||
#include "Poco/Data/MySQL/StatementExecutor.h"
|
#include "Poco/Data/MySQL/StatementExecutor.h"
|
||||||
#include "Poco/Data/MySQL/ResultMetadata.h"
|
#include "Poco/Data/MySQL/ResultMetadata.h"
|
||||||
#include "Poco/Data/StatementImpl.h"
|
#include "Poco/Data/StatementImpl.h"
|
||||||
#include "Poco/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include "Poco/Format.h"
|
#include "Poco/Format.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
class MySQL_API MySQLStatementImpl: public Poco::Data::StatementImpl
|
class MySQL_API MySQLStatementImpl: public Poco::Data::StatementImpl
|
||||||
/// Implements statement functionality needed for MySQL
|
/// Implements statement functionality needed for MySQL
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MySQLStatementImpl(SessionHandle& h);
|
MySQLStatementImpl(SessionHandle& h);
|
||||||
/// Creates the MySQLStatementImpl.
|
/// Creates the MySQLStatementImpl.
|
||||||
|
|
||||||
~MySQLStatementImpl();
|
~MySQLStatementImpl();
|
||||||
/// Destroys the MySQLStatementImpl.
|
/// Destroys the MySQLStatementImpl.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual Poco::UInt32 columnsReturned() const;
|
virtual Poco::UInt32 columnsReturned() const;
|
||||||
/// Returns number of columns returned by query.
|
/// Returns number of columns returned by query.
|
||||||
|
|
||||||
virtual const MetaColumn& metaColumn(Poco::UInt32 pos) const;
|
virtual const MetaColumn& metaColumn(Poco::UInt32 pos) const;
|
||||||
/// Returns column meta data.
|
/// Returns column meta data.
|
||||||
|
|
||||||
virtual bool hasNext();
|
virtual bool hasNext();
|
||||||
/// Returns true if a call to next() will return data.
|
/// Returns true if a call to next() will return data.
|
||||||
|
|
||||||
virtual void next();
|
virtual void next();
|
||||||
/// Retrieves the next row from the resultset.
|
/// Retrieves the next row from the resultset.
|
||||||
/// Will throw, if the resultset is empty.
|
/// Will throw, if the resultset is empty.
|
||||||
|
|
||||||
virtual bool canBind() const;
|
virtual bool canBind() const;
|
||||||
/// Returns true if a valid statement is set and we can bind.
|
/// Returns true if a valid statement is set and we can bind.
|
||||||
|
|
||||||
virtual void compileImpl();
|
virtual void compileImpl();
|
||||||
/// Compiles the statement, doesn't bind yet
|
/// Compiles the statement, doesn't bind yet
|
||||||
|
|
||||||
virtual void bindImpl();
|
virtual void bindImpl();
|
||||||
/// Binds parameters
|
/// Binds parameters
|
||||||
|
|
||||||
virtual AbstractExtractor& extractor();
|
virtual AbstractExtractor& extractor();
|
||||||
/// Returns the concrete extractor used by the statement.
|
/// Returns the concrete extractor used by the statement.
|
||||||
|
|
||||||
virtual AbstractBinder& binder();
|
virtual AbstractBinder& binder();
|
||||||
/// Returns the concrete binder used by the statement.
|
/// Returns the concrete binder used by the statement.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
NEXT_DONTKNOW,
|
NEXT_DONTKNOW,
|
||||||
NEXT_TRUE,
|
NEXT_TRUE,
|
||||||
NEXT_FALSE
|
NEXT_FALSE
|
||||||
};
|
};
|
||||||
|
|
||||||
StatementExecutor _stmt;
|
StatementExecutor _stmt;
|
||||||
ResultMetadata _metadata;
|
ResultMetadata _metadata;
|
||||||
Binder _binder;
|
Binder _binder;
|
||||||
Extractor _extractor;
|
Extractor _extractor;
|
||||||
int _hasNext;
|
int _hasNext;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|
||||||
|
|
||||||
#endif // Data_MySQL_MySQLStatementImpl_INCLUDED
|
#endif // Data_MySQL_MySQLStatementImpl_INCLUDED
|
||||||
|
|||||||
@@ -1,93 +1,93 @@
|
|||||||
//
|
//
|
||||||
// ResultMetadata.h
|
// ResultMetadata.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/ResultMetadata.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/ResultMetadata.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: ResultMetadata
|
// Module: ResultMetadata
|
||||||
//
|
//
|
||||||
// Definition of the ResultMetadata class.
|
// Definition of the ResultMetadata class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Data_MySQL_ResultMetadata_INCLUDED
|
#ifndef Data_MySQL_ResultMetadata_INCLUDED
|
||||||
#define Data_MySQL_ResultMetadata_INCLUDED
|
#define Data_MySQL_ResultMetadata_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "Poco/Data/MetaColumn.h"
|
#include "Poco/Data/MetaColumn.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
class ResultMetadata
|
class ResultMetadata
|
||||||
/// MySQL result metadata
|
/// MySQL result metadata
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void reset();
|
void reset();
|
||||||
/// Resets the metadata.
|
/// Resets the metadata.
|
||||||
|
|
||||||
void init(MYSQL_STMT* stmt);
|
void init(MYSQL_STMT* stmt);
|
||||||
/// Initializes the metadata.
|
/// Initializes the metadata.
|
||||||
|
|
||||||
Poco::UInt32 columnsReturned() const;
|
Poco::UInt32 columnsReturned() const;
|
||||||
/// Returns the number of columns in resultset.
|
/// Returns the number of columns in resultset.
|
||||||
|
|
||||||
const MetaColumn& metaColumn(Poco::UInt32 pos) const;
|
const MetaColumn& metaColumn(Poco::UInt32 pos) const;
|
||||||
/// Returns the reference to the specified metacolumn.
|
/// Returns the reference to the specified metacolumn.
|
||||||
|
|
||||||
MYSQL_BIND* row();
|
MYSQL_BIND* row();
|
||||||
/// Returns pointer to native row.
|
/// Returns pointer to native row.
|
||||||
|
|
||||||
std::size_t length(std::size_t pos) const;
|
std::size_t length(std::size_t pos) const;
|
||||||
/// Returns the length.
|
/// Returns the length.
|
||||||
|
|
||||||
const char* rawData(std::size_t pos) const;
|
const char* rawData(std::size_t pos) const;
|
||||||
/// Returns raw data.
|
/// Returns raw data.
|
||||||
|
|
||||||
bool isNull(std::size_t pos) const;
|
bool isNull(std::size_t pos) const;
|
||||||
/// Returns true if value at pos is null.
|
/// Returns true if value at pos is null.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector<MetaColumn> _columns;
|
std::vector<MetaColumn> _columns;
|
||||||
std::vector<MYSQL_BIND> _row;
|
std::vector<MYSQL_BIND> _row;
|
||||||
std::vector<char> _buffer;
|
std::vector<char> _buffer;
|
||||||
std::vector<unsigned long> _lengths;
|
std::vector<unsigned long> _lengths;
|
||||||
std::vector<my_bool> _isNull;
|
std::vector<my_bool> _isNull;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|
||||||
|
|
||||||
#endif //Data_MySQL_ResultMetadata_INCLUDED
|
#endif //Data_MySQL_ResultMetadata_INCLUDED
|
||||||
|
|||||||
@@ -1,94 +1,94 @@
|
|||||||
//
|
//
|
||||||
// SesssionHandle.h
|
// SesssionHandle.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/SessionHandle.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/SessionHandle.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: SessionHandle
|
// Module: SessionHandle
|
||||||
//
|
//
|
||||||
// Definition of the SessionHandle class.
|
// Definition of the SessionHandle class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Data_MySQL_SessionHandle_INCLUDED
|
#ifndef Data_MySQL_SessionHandle_INCLUDED
|
||||||
#define Data_MySQL_SessionHandle_INCLUDED
|
#define Data_MySQL_SessionHandle_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
#include "Poco/Data/MySQL/MySQLException.h"
|
#include "Poco/Data/MySQL/MySQLException.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
class SessionHandle
|
class SessionHandle
|
||||||
/// MySQL session handle
|
/// MySQL session handle
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
explicit SessionHandle(MYSQL* mysql);
|
explicit SessionHandle(MYSQL* mysql);
|
||||||
|
|
||||||
~SessionHandle();
|
~SessionHandle();
|
||||||
|
|
||||||
void options(mysql_option opt);
|
void options(mysql_option opt);
|
||||||
|
|
||||||
void options(mysql_option opt, bool b);
|
void options(mysql_option opt, bool b);
|
||||||
|
|
||||||
void connect(const char* host, const char* user, const char* password, const char* db, unsigned int port);
|
void connect(const char* host, const char* user, const char* password, const char* db, unsigned int port);
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
void query(const char* str);
|
void query(const char* str);
|
||||||
|
|
||||||
operator MYSQL* ();
|
operator MYSQL* ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SessionHandle(const SessionHandle&);
|
SessionHandle(const SessionHandle&);
|
||||||
SessionHandle& operator=(const SessionHandle&);
|
SessionHandle& operator=(const SessionHandle&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MYSQL* h;
|
MYSQL* h;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline SessionHandle::operator MYSQL* ()
|
inline SessionHandle::operator MYSQL* ()
|
||||||
{
|
{
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|
||||||
|
|
||||||
#endif // Data_MySQL_SessionHandle_INCLUDED
|
#endif // Data_MySQL_SessionHandle_INCLUDED
|
||||||
|
|||||||
@@ -1,124 +1,124 @@
|
|||||||
//
|
//
|
||||||
// SessionImpl.h
|
// SessionImpl.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/SessionImpl.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/SessionImpl.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: SessionImpl
|
// Module: SessionImpl
|
||||||
//
|
//
|
||||||
// Definition of the SessionImpl class.
|
// Definition of the SessionImpl class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Data_MySQL_SessionImpl_INCLUDED
|
#ifndef Data_MySQL_SessionImpl_INCLUDED
|
||||||
#define Data_MySQL_SessionImpl_INCLUDED
|
#define Data_MySQL_SessionImpl_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Data/MySQL/MySQL.h"
|
#include "Poco/Data/MySQL/MySQL.h"
|
||||||
#include "Poco/Data/AbstractSessionImpl.h"
|
#include "Poco/Data/AbstractSessionImpl.h"
|
||||||
#include "Poco/Data/MySQL/SessionHandle.h"
|
#include "Poco/Data/MySQL/SessionHandle.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
class MySQL_API SessionImpl: public Poco::Data::AbstractSessionImpl<SessionImpl>
|
class MySQL_API SessionImpl: public Poco::Data::AbstractSessionImpl<SessionImpl>
|
||||||
/// Implements SessionImpl interface
|
/// Implements SessionImpl interface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SessionImpl(const std::string& connectionString);
|
SessionImpl(const std::string& connectionString);
|
||||||
/// Creates the SessionImpl. Opens a connection to the database
|
/// Creates the SessionImpl. Opens a connection to the database
|
||||||
///
|
///
|
||||||
/// Connection string format:
|
/// Connection string format:
|
||||||
/// <str> == <assignment> | <assignment> ';' <str>
|
/// <str> == <assignment> | <assignment> ';' <str>
|
||||||
/// <assignment> == <name> '=' <value>
|
/// <assignment> == <name> '=' <value>
|
||||||
/// <name> == 'host' | 'port' | 'user' | 'password' | 'db' } 'compress' | 'auto-reconnect'
|
/// <name> == 'host' | 'port' | 'user' | 'password' | 'db' } 'compress' | 'auto-reconnect'
|
||||||
/// <value> == [~;]*
|
/// <value> == [~;]*
|
||||||
///
|
///
|
||||||
/// for compress and auto-reconnect correct values are true/false
|
/// for compress and auto-reconnect correct values are true/false
|
||||||
/// for port - numeric in decimal notation
|
/// for port - numeric in decimal notation
|
||||||
///
|
///
|
||||||
|
|
||||||
~SessionImpl();
|
~SessionImpl();
|
||||||
/// Destroys the SessionImpl.
|
/// Destroys the SessionImpl.
|
||||||
|
|
||||||
virtual Poco::Data::StatementImpl* createStatementImpl();
|
virtual Poco::Data::StatementImpl* createStatementImpl();
|
||||||
/// Returns an MySQL StatementImpl
|
/// Returns an MySQL StatementImpl
|
||||||
|
|
||||||
virtual void begin();
|
virtual void begin();
|
||||||
/// Starts a transaction
|
/// Starts a transaction
|
||||||
|
|
||||||
virtual void commit();
|
virtual void commit();
|
||||||
/// Commits and ends a transaction
|
/// Commits and ends a transaction
|
||||||
|
|
||||||
virtual void rollback();
|
virtual void rollback();
|
||||||
/// Aborts a transaction
|
/// Aborts a transaction
|
||||||
|
|
||||||
virtual void close();
|
virtual void close();
|
||||||
/// Closes the connection
|
/// Closes the connection
|
||||||
|
|
||||||
virtual bool isConnected();
|
virtual bool isConnected();
|
||||||
/// Returns true iff session is connected.
|
/// Returns true iff session is connected.
|
||||||
|
|
||||||
virtual bool isTransaction();
|
virtual bool isTransaction();
|
||||||
/// Returns true iff a transaction is in progress.
|
/// Returns true iff a transaction is in progress.
|
||||||
|
|
||||||
void setInsertId(const std::string&, const Poco::Any&);
|
void setInsertId(const std::string&, const Poco::Any&);
|
||||||
/// Try to set insert id - do nothing.
|
/// Try to set insert id - do nothing.
|
||||||
|
|
||||||
Poco::Any getInsertId(const std::string&);
|
Poco::Any getInsertId(const std::string&);
|
||||||
/// Get insert id
|
/// Get insert id
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SessionHandle _mysql;
|
SessionHandle _mysql;
|
||||||
bool _connected;
|
bool _connected;
|
||||||
int _inTransaction;
|
int _inTransaction;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline void SessionImpl::setInsertId(const std::string&, const Poco::Any&)
|
inline void SessionImpl::setInsertId(const std::string&, const Poco::Any&)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Poco::Any SessionImpl::getInsertId(const std::string&)
|
inline Poco::Any SessionImpl::getInsertId(const std::string&)
|
||||||
{
|
{
|
||||||
return Poco::Any(Poco::UInt64(mysql_insert_id(_mysql)));
|
return Poco::Any(Poco::UInt64(mysql_insert_id(_mysql)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|
||||||
|
|
||||||
#endif // Data_MySQL_SessionImpl_INCLUDED
|
#endif // Data_MySQL_SessionImpl_INCLUDED
|
||||||
|
|||||||
@@ -1,117 +1,117 @@
|
|||||||
//
|
//
|
||||||
// StatementExecutor.h
|
// StatementExecutor.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/StatementExecutor.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/include/Poco/Data/MySQL/StatementExecutor.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: StatementExecutor
|
// Module: StatementExecutor
|
||||||
//
|
//
|
||||||
// Definition of the StatementExecutor class.
|
// Definition of the StatementExecutor class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Data_MySQL_StatementHandle_INCLUDED
|
#ifndef Data_MySQL_StatementHandle_INCLUDED
|
||||||
#define Data_MySQL_StatementHandle_INCLUDED
|
#define Data_MySQL_StatementHandle_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
#include "Poco/Data/MySQL/MySQLException.h"
|
#include "Poco/Data/MySQL/MySQLException.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
class StatementExecutor
|
class StatementExecutor
|
||||||
/// MySQL statement executor.
|
/// MySQL statement executor.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum State
|
enum State
|
||||||
{
|
{
|
||||||
STMT_INITED,
|
STMT_INITED,
|
||||||
STMT_COMPILED,
|
STMT_COMPILED,
|
||||||
STMT_EXECUTED
|
STMT_EXECUTED
|
||||||
};
|
};
|
||||||
|
|
||||||
explicit StatementExecutor(MYSQL* mysql);
|
explicit StatementExecutor(MYSQL* mysql);
|
||||||
/// Creates the StatementExecutor.
|
/// Creates the StatementExecutor.
|
||||||
|
|
||||||
~StatementExecutor();
|
~StatementExecutor();
|
||||||
/// Destroys the StatementExecutor.
|
/// Destroys the StatementExecutor.
|
||||||
|
|
||||||
int state() const;
|
int state() const;
|
||||||
/// Returns the current state.
|
/// Returns the current state.
|
||||||
|
|
||||||
void prepare(const std::string& query);
|
void prepare(const std::string& query);
|
||||||
/// Prepares the statement for execution.
|
/// Prepares the statement for execution.
|
||||||
|
|
||||||
void bindParams(MYSQL_BIND* params, size_t count);
|
void bindParams(MYSQL_BIND* params, size_t count);
|
||||||
/// Binds the params.
|
/// Binds the params.
|
||||||
|
|
||||||
void bindResult(MYSQL_BIND* result);
|
void bindResult(MYSQL_BIND* result);
|
||||||
/// Binds result.
|
/// Binds result.
|
||||||
|
|
||||||
void execute();
|
void execute();
|
||||||
/// Executes the statement.
|
/// Executes the statement.
|
||||||
|
|
||||||
bool fetch();
|
bool fetch();
|
||||||
/// Fetches the data.
|
/// Fetches the data.
|
||||||
|
|
||||||
bool fetchColumn(size_t n, MYSQL_BIND *bind);
|
bool fetchColumn(size_t n, MYSQL_BIND *bind);
|
||||||
/// Fetches the column.
|
/// Fetches the column.
|
||||||
|
|
||||||
operator MYSQL_STMT* ();
|
operator MYSQL_STMT* ();
|
||||||
/// Cast operator to native handle type.
|
/// Cast operator to native handle type.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
StatementExecutor(const StatementExecutor&);
|
StatementExecutor(const StatementExecutor&);
|
||||||
StatementExecutor& operator=(const StatementExecutor&);
|
StatementExecutor& operator=(const StatementExecutor&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MYSQL_STMT* h;
|
MYSQL_STMT* h;
|
||||||
int _state;
|
int _state;
|
||||||
std::string _query;
|
std::string _query;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline StatementExecutor::operator MYSQL_STMT* ()
|
inline StatementExecutor::operator MYSQL_STMT* ()
|
||||||
{
|
{
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|
||||||
|
|
||||||
#endif // Data_MySQL_StatementHandle_INCLUDED
|
#endif // Data_MySQL_StatementHandle_INCLUDED
|
||||||
|
|||||||
@@ -1,181 +1,181 @@
|
|||||||
//
|
//
|
||||||
// MySQLException.cpp
|
// MySQLException.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/src/Binder.cpp#1 $
|
// $Id: //poco/1.3/Data/MySQL/src/Binder.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: Binder
|
// Module: Binder
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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/MySQL/Binder.h"
|
#include "Poco/Data/MySQL/Binder.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
Binder::Binder()
|
Binder::Binder()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Binder::~Binder()
|
Binder::~Binder()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const Poco::Int8& val)
|
void Binder::bind(std::size_t pos, const Poco::Int8& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
|
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const Poco::UInt8& val)
|
void Binder::bind(std::size_t pos, const Poco::UInt8& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
|
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const Poco::Int16& val)
|
void Binder::bind(std::size_t pos, const Poco::Int16& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_SHORT, &val, 0);
|
realBind(pos, MYSQL_TYPE_SHORT, &val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const Poco::UInt16& val)
|
void Binder::bind(std::size_t pos, const Poco::UInt16& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_SHORT, &val, 0);
|
realBind(pos, MYSQL_TYPE_SHORT, &val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const Poco::Int32& val)
|
void Binder::bind(std::size_t pos, const Poco::Int32& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_LONG, &val, 0);
|
realBind(pos, MYSQL_TYPE_LONG, &val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const Poco::UInt32& val)
|
void Binder::bind(std::size_t pos, const Poco::UInt32& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_LONG, &val, 0);
|
realBind(pos, MYSQL_TYPE_LONG, &val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const Poco::Int64& val)
|
void Binder::bind(std::size_t pos, const Poco::Int64& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0);
|
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const Poco::UInt64& val)
|
void Binder::bind(std::size_t pos, const Poco::UInt64& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0);
|
realBind(pos, MYSQL_TYPE_LONGLONG, &val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const bool& val)
|
void Binder::bind(std::size_t pos, const bool& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
|
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const float& val)
|
void Binder::bind(std::size_t pos, const float& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_FLOAT, &val, 0);
|
realBind(pos, MYSQL_TYPE_FLOAT, &val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const double& val)
|
void Binder::bind(std::size_t pos, const double& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_DOUBLE, &val, 0);
|
realBind(pos, MYSQL_TYPE_DOUBLE, &val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const char& val)
|
void Binder::bind(std::size_t pos, const char& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
|
realBind(pos, MYSQL_TYPE_TINY, &val, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const std::string& val)
|
void Binder::bind(std::size_t pos, const std::string& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_STRING, val.c_str(), static_cast<int>(val.length()));
|
realBind(pos, MYSQL_TYPE_STRING, val.c_str(), static_cast<int>(val.length()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::bind(std::size_t pos, const Poco::Data::BLOB& val)
|
void Binder::bind(std::size_t pos, const Poco::Data::BLOB& val)
|
||||||
{
|
{
|
||||||
realBind(pos, MYSQL_TYPE_STRING, val.rawContent(), static_cast<int>(val.size()));
|
realBind(pos, MYSQL_TYPE_STRING, val.rawContent(), static_cast<int>(val.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t Binder::size() const
|
size_t Binder::size() const
|
||||||
{
|
{
|
||||||
return _bindArray.size();
|
return _bindArray.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MYSQL_BIND* Binder::getBindArray() const
|
MYSQL_BIND* Binder::getBindArray() const
|
||||||
{
|
{
|
||||||
if (_bindArray.size() == 0)
|
if (_bindArray.size() == 0)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
return const_cast<MYSQL_BIND*>(&_bindArray[0]);
|
return const_cast<MYSQL_BIND*>(&_bindArray[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Binder::realBind(std::size_t pos, enum_field_types type, const void* buffer, int length)
|
void Binder::realBind(std::size_t pos, enum_field_types type, const void* buffer, int length)
|
||||||
{
|
{
|
||||||
if (pos > 1024)
|
if (pos > 1024)
|
||||||
{
|
{
|
||||||
throw StatementException("too many bind parameters");
|
throw StatementException("too many bind parameters");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pos >= _bindArray.size())
|
if (pos >= _bindArray.size())
|
||||||
{
|
{
|
||||||
size_t s = _bindArray.size();
|
size_t s = _bindArray.size();
|
||||||
_bindArray.resize(pos + 1);
|
_bindArray.resize(pos + 1);
|
||||||
|
|
||||||
memset(&_bindArray[s], 0, sizeof(MYSQL_BIND) * (_bindArray.size() - s));
|
memset(&_bindArray[s], 0, sizeof(MYSQL_BIND) * (_bindArray.size() - s));
|
||||||
}
|
}
|
||||||
|
|
||||||
MYSQL_BIND b = {0};
|
MYSQL_BIND b = {0};
|
||||||
|
|
||||||
b.buffer_type = type;
|
b.buffer_type = type;
|
||||||
b.buffer = const_cast<void*>(buffer);
|
b.buffer = const_cast<void*>(buffer);
|
||||||
b.buffer_length = length;
|
b.buffer_length = length;
|
||||||
|
|
||||||
_bindArray[pos] = b;
|
_bindArray[pos] = b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|||||||
@@ -1,87 +1,87 @@
|
|||||||
//
|
//
|
||||||
// MySQLException.cpp
|
// MySQLException.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/src/Connector.cpp#1 $
|
// $Id: //poco/1.3/Data/MySQL/src/Connector.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: Connector
|
// Module: Connector
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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/MySQL/Connector.h"
|
#include "Poco/Data/MySQL/Connector.h"
|
||||||
#include "Poco/Data/MySQL/SessionImpl.h"
|
#include "Poco/Data/MySQL/SessionImpl.h"
|
||||||
#include "Poco/Data/SessionFactory.h"
|
#include "Poco/Data/SessionFactory.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
std::string Connector::KEY("MySQL");
|
std::string Connector::KEY("MySQL");
|
||||||
|
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
return Poco::AutoPtr<Poco::Data::SessionImpl>(new SessionImpl(connectionString));
|
return Poco::AutoPtr<Poco::Data::SessionImpl>(new SessionImpl(connectionString));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Connector::registerConnector()
|
void Connector::registerConnector()
|
||||||
{
|
{
|
||||||
if (mysql_library_init(0, 0, 0) != 0)
|
if (mysql_library_init(0, 0, 0) != 0)
|
||||||
{
|
{
|
||||||
throw Exception("mysql_library_init error");
|
throw Exception("mysql_library_init error");
|
||||||
}
|
}
|
||||||
|
|
||||||
Poco::Data::SessionFactory::instance().add(KEY, new Connector());
|
Poco::Data::SessionFactory::instance().add(KEY, new Connector());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Connector::unregisterConnector()
|
void Connector::unregisterConnector()
|
||||||
{
|
{
|
||||||
Poco::Data::SessionFactory::instance().remove(KEY);
|
Poco::Data::SessionFactory::instance().remove(KEY);
|
||||||
mysql_library_end();
|
mysql_library_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|
||||||
|
|||||||
@@ -1,177 +1,177 @@
|
|||||||
//
|
//
|
||||||
// MySQLException.cpp
|
// MySQLException.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/src/Extractor.cpp#1 $
|
// $Id: //poco/1.3/Data/MySQL/src/Extractor.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: Extractor
|
// Module: Extractor
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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/MySQL/Extractor.h"
|
#include "Poco/Data/MySQL/Extractor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
Extractor::Extractor(StatementExecutor& st, ResultMetadata& md): _stmt(st), _metadata(md)
|
Extractor::Extractor(StatementExecutor& st, ResultMetadata& md): _stmt(st), _metadata(md)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Extractor::~Extractor()
|
Extractor::~Extractor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::Int8& val)
|
bool Extractor::extract(std::size_t pos, Poco::Int8& val)
|
||||||
{
|
{
|
||||||
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
|
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::UInt8& val)
|
bool Extractor::extract(std::size_t pos, Poco::UInt8& val)
|
||||||
{
|
{
|
||||||
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
|
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::Int16& val)
|
bool Extractor::extract(std::size_t pos, Poco::Int16& val)
|
||||||
{
|
{
|
||||||
return realExtractFixed(pos, MYSQL_TYPE_SHORT, &val);
|
return realExtractFixed(pos, MYSQL_TYPE_SHORT, &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::UInt16& val)
|
bool Extractor::extract(std::size_t pos, Poco::UInt16& val)
|
||||||
{
|
{
|
||||||
return realExtractFixed(pos, MYSQL_TYPE_SHORT, &val);
|
return realExtractFixed(pos, MYSQL_TYPE_SHORT, &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::Int32& val)
|
bool Extractor::extract(std::size_t pos, Poco::Int32& val)
|
||||||
{
|
{
|
||||||
return realExtractFixed(pos, MYSQL_TYPE_LONG, &val);
|
return realExtractFixed(pos, MYSQL_TYPE_LONG, &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::UInt32& val)
|
bool Extractor::extract(std::size_t pos, Poco::UInt32& val)
|
||||||
{
|
{
|
||||||
return realExtractFixed(pos, MYSQL_TYPE_LONG, &val);
|
return realExtractFixed(pos, MYSQL_TYPE_LONG, &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::Int64& val)
|
bool Extractor::extract(std::size_t pos, Poco::Int64& val)
|
||||||
{
|
{
|
||||||
return realExtractFixed(pos, MYSQL_TYPE_LONGLONG, &val);
|
return realExtractFixed(pos, MYSQL_TYPE_LONGLONG, &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::UInt64& val)
|
bool Extractor::extract(std::size_t pos, Poco::UInt64& val)
|
||||||
{
|
{
|
||||||
return realExtractFixed(pos, MYSQL_TYPE_LONGLONG, &val);
|
return realExtractFixed(pos, MYSQL_TYPE_LONGLONG, &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, bool& val)
|
bool Extractor::extract(std::size_t pos, bool& val)
|
||||||
{
|
{
|
||||||
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
|
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, float& val)
|
bool Extractor::extract(std::size_t pos, float& val)
|
||||||
{
|
{
|
||||||
return realExtractFixed(pos, MYSQL_TYPE_FLOAT, &val);
|
return realExtractFixed(pos, MYSQL_TYPE_FLOAT, &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, double& val)
|
bool Extractor::extract(std::size_t pos, double& val)
|
||||||
{
|
{
|
||||||
return realExtractFixed(pos, MYSQL_TYPE_DOUBLE, &val);
|
return realExtractFixed(pos, MYSQL_TYPE_DOUBLE, &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, char& val)
|
bool Extractor::extract(std::size_t pos, char& val)
|
||||||
{
|
{
|
||||||
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
|
return realExtractFixed(pos, MYSQL_TYPE_TINY, &val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, std::string& val)
|
bool Extractor::extract(std::size_t pos, std::string& val)
|
||||||
{
|
{
|
||||||
if (_metadata.columnsReturned() <= pos)
|
if (_metadata.columnsReturned() <= pos)
|
||||||
throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");
|
throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");
|
||||||
|
|
||||||
if (_metadata.isNull(static_cast<Poco::UInt32>(pos)))
|
if (_metadata.isNull(static_cast<Poco::UInt32>(pos)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type() != Poco::Data::MetaColumn::FDT_STRING)
|
if (_metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type() != Poco::Data::MetaColumn::FDT_STRING)
|
||||||
throw MySQLException("Extractor: not a string");
|
throw MySQLException("Extractor: not a string");
|
||||||
|
|
||||||
val.assign(_metadata.rawData(pos), _metadata.length(pos));
|
val.assign(_metadata.rawData(pos), _metadata.length(pos));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::Data::BLOB& val)
|
bool Extractor::extract(std::size_t pos, Poco::Data::BLOB& val)
|
||||||
{
|
{
|
||||||
if (_metadata.columnsReturned() <= pos)
|
if (_metadata.columnsReturned() <= pos)
|
||||||
throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");
|
throw MySQLException("Extractor: attempt to extract more paremeters, than query result contain");
|
||||||
|
|
||||||
if (_metadata.isNull(static_cast<Poco::UInt32>(pos)))
|
if (_metadata.isNull(static_cast<Poco::UInt32>(pos)))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (_metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type() != Poco::Data::MetaColumn::FDT_BLOB)
|
if (_metadata.metaColumn(static_cast<Poco::UInt32>(pos)).type() != Poco::Data::MetaColumn::FDT_BLOB)
|
||||||
throw MySQLException("Extractor: not a blob");
|
throw MySQLException("Extractor: not a blob");
|
||||||
|
|
||||||
|
|
||||||
val.assignRaw(_metadata.rawData(pos), _metadata.length(pos));
|
val.assignRaw(_metadata.rawData(pos), _metadata.length(pos));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, size_t length)
|
bool Extractor::realExtractFixed(std::size_t pos, enum_field_types type, void* buffer, size_t length)
|
||||||
{
|
{
|
||||||
MYSQL_BIND bind = {0};
|
MYSQL_BIND bind = {0};
|
||||||
my_bool isNull = 0;
|
my_bool isNull = 0;
|
||||||
|
|
||||||
bind.is_null = &isNull;
|
bind.is_null = &isNull;
|
||||||
bind.buffer_type = type;
|
bind.buffer_type = type;
|
||||||
bind.buffer = buffer;
|
bind.buffer = buffer;
|
||||||
bind.buffer_length = static_cast<unsigned long>(length);
|
bind.buffer_length = static_cast<unsigned long>(length);
|
||||||
|
|
||||||
if (!_stmt.fetchColumn(pos, &bind))
|
if (!_stmt.fetchColumn(pos, &bind))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return isNull == 0;
|
return isNull == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|||||||
@@ -1,129 +1,129 @@
|
|||||||
//
|
//
|
||||||
// MySQLException.cpp
|
// MySQLException.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/src/MySQLException.cpp#1 $
|
// $Id: //poco/1.3/Data/MySQL/src/MySQLException.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: MySQLException
|
// Module: MySQLException
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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/MySQL/MySQLException.h"
|
#include "Poco/Data/MySQL/MySQLException.h"
|
||||||
#include <mysql.h>
|
#include <mysql.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
MySQLException::MySQLException(const std::string& msg) : Poco::Data::DataException(std::string("[MySQL]: ") + msg)
|
MySQLException::MySQLException(const std::string& msg) : Poco::Data::DataException(std::string("[MySQL]: ") + msg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MySQLException::MySQLException(const MySQLException& exc) : Poco::Data::DataException(exc)
|
MySQLException::MySQLException(const MySQLException& exc) : Poco::Data::DataException(exc)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MySQLException::~MySQLException() throw()
|
MySQLException::~MySQLException() throw()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ConnectionException::ConnectionException(const std::string& msg) : MySQLException(msg)
|
ConnectionException::ConnectionException(const std::string& msg) : MySQLException(msg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ConnectionException::ConnectionException(const std::string& text, MYSQL* h) : MySQLException(compose(text, h))
|
ConnectionException::ConnectionException(const std::string& text, MYSQL* h) : MySQLException(compose(text, h))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StatementException::StatementException(const std::string& msg) : MySQLException(msg)
|
StatementException::StatementException(const std::string& msg) : MySQLException(msg)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StatementException::StatementException(const std::string& text, MYSQL_STMT* h, const std::string& stmt) : MySQLException(compose(text, h, stmt))
|
StatementException::StatementException(const std::string& text, MYSQL_STMT* h, const std::string& stmt) : MySQLException(compose(text, h, stmt))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string ConnectionException::compose(const std::string& text, MYSQL* h)
|
std::string ConnectionException::compose(const std::string& text, MYSQL* h)
|
||||||
{
|
{
|
||||||
std::string str;
|
std::string str;
|
||||||
str += "[Comment]: ";
|
str += "[Comment]: ";
|
||||||
str += text;
|
str += text;
|
||||||
str += "\t[mysql_error]: ";
|
str += "\t[mysql_error]: ";
|
||||||
str += mysql_error(h);
|
str += mysql_error(h);
|
||||||
|
|
||||||
str += "\t[mysql_errno]: ";
|
str += "\t[mysql_errno]: ";
|
||||||
char buff[30];
|
char buff[30];
|
||||||
sprintf(buff, "%d", mysql_errno(h));
|
sprintf(buff, "%d", mysql_errno(h));
|
||||||
str += buff;
|
str += buff;
|
||||||
|
|
||||||
str += "\t[mysql_sqlstate]: ";
|
str += "\t[mysql_sqlstate]: ";
|
||||||
str += mysql_sqlstate(h);
|
str += mysql_sqlstate(h);
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string StatementException::compose(const std::string& text, MYSQL_STMT* h, const std::string& stmt)
|
std::string StatementException::compose(const std::string& text, MYSQL_STMT* h, const std::string& stmt)
|
||||||
{
|
{
|
||||||
std::string str;
|
std::string str;
|
||||||
str += "[Comment]: ";
|
str += "[Comment]: ";
|
||||||
str += text;
|
str += text;
|
||||||
|
|
||||||
if (h != 0)
|
if (h != 0)
|
||||||
{
|
{
|
||||||
str += "\t[mysql_stmt_error]: ";
|
str += "\t[mysql_stmt_error]: ";
|
||||||
str += mysql_stmt_error(h);
|
str += mysql_stmt_error(h);
|
||||||
|
|
||||||
str += "\t[mysql_stmt_errno]: ";
|
str += "\t[mysql_stmt_errno]: ";
|
||||||
char buff[30];
|
char buff[30];
|
||||||
sprintf(buff, "%d", mysql_stmt_errno(h));
|
sprintf(buff, "%d", mysql_stmt_errno(h));
|
||||||
str += buff;
|
str += buff;
|
||||||
|
|
||||||
str += "\t[mysql_stmt_sqlstate]: ";
|
str += "\t[mysql_stmt_sqlstate]: ";
|
||||||
str += mysql_stmt_sqlstate(h);
|
str += mysql_stmt_sqlstate(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stmt.length() > 0)
|
if (stmt.length() > 0)
|
||||||
{
|
{
|
||||||
str += "\t[statemnt]: ";
|
str += "\t[statemnt]: ";
|
||||||
str += stmt;
|
str += stmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|||||||
@@ -1,175 +1,175 @@
|
|||||||
//
|
//
|
||||||
// MySQLException.cpp
|
// MySQLException.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/src/MySQLStatementImpl.cpp#1 $
|
// $Id: //poco/1.3/Data/MySQL/src/MySQLStatementImpl.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: MySQLStatementImpl
|
// Module: MySQLStatementImpl
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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/MySQL/MySQLStatementImpl.h"
|
#include "Poco/Data/MySQL/MySQLStatementImpl.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
MySQLStatementImpl::MySQLStatementImpl(SessionHandle& h):
|
MySQLStatementImpl::MySQLStatementImpl(SessionHandle& h):
|
||||||
_stmt(h),
|
_stmt(h),
|
||||||
_extractor(_stmt, _metadata),
|
_extractor(_stmt, _metadata),
|
||||||
_hasNext(NEXT_DONTKNOW)
|
_hasNext(NEXT_DONTKNOW)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MySQLStatementImpl::~MySQLStatementImpl()
|
MySQLStatementImpl::~MySQLStatementImpl()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Poco::UInt32 MySQLStatementImpl::columnsReturned() const
|
Poco::UInt32 MySQLStatementImpl::columnsReturned() const
|
||||||
{
|
{
|
||||||
return _metadata.columnsReturned();
|
return _metadata.columnsReturned();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const MetaColumn& MySQLStatementImpl::metaColumn(Poco::UInt32 pos) const
|
const MetaColumn& MySQLStatementImpl::metaColumn(Poco::UInt32 pos) const
|
||||||
{
|
{
|
||||||
return _metadata.metaColumn(pos);
|
return _metadata.metaColumn(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MySQLStatementImpl::hasNext()
|
bool MySQLStatementImpl::hasNext()
|
||||||
{
|
{
|
||||||
if (_hasNext == NEXT_DONTKNOW)
|
if (_hasNext == NEXT_DONTKNOW)
|
||||||
{
|
{
|
||||||
if (_metadata.columnsReturned() == 0)
|
if (_metadata.columnsReturned() == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_stmt.fetch())
|
if (_stmt.fetch())
|
||||||
{
|
{
|
||||||
_hasNext = NEXT_TRUE;
|
_hasNext = NEXT_TRUE;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
_hasNext = NEXT_FALSE;
|
_hasNext = NEXT_FALSE;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else if (_hasNext == NEXT_TRUE)
|
else if (_hasNext == NEXT_TRUE)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MySQLStatementImpl::next()
|
void MySQLStatementImpl::next()
|
||||||
{
|
{
|
||||||
if (!hasNext())
|
if (!hasNext())
|
||||||
throw StatementException("No data received");
|
throw StatementException("No data received");
|
||||||
|
|
||||||
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
|
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
|
||||||
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
|
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
|
||||||
std::size_t pos = 0;
|
std::size_t pos = 0;
|
||||||
|
|
||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
(*it)->extract(pos);
|
(*it)->extract(pos);
|
||||||
pos += (*it)->numOfColumnsHandled();
|
pos += (*it)->numOfColumnsHandled();
|
||||||
}
|
}
|
||||||
|
|
||||||
_hasNext = NEXT_DONTKNOW;
|
_hasNext = NEXT_DONTKNOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool MySQLStatementImpl::canBind() const
|
bool MySQLStatementImpl::canBind() const
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
if ((_stmt.state() >= StatementExecutor::STMT_COMPILED) && !bindings().empty())
|
if ((_stmt.state() >= StatementExecutor::STMT_COMPILED) && !bindings().empty())
|
||||||
ret = (*bindings().begin())->canBind();
|
ret = (*bindings().begin())->canBind();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MySQLStatementImpl::compileImpl()
|
void MySQLStatementImpl::compileImpl()
|
||||||
{
|
{
|
||||||
_metadata.reset();
|
_metadata.reset();
|
||||||
_stmt.prepare(toString());
|
_stmt.prepare(toString());
|
||||||
_metadata.init(_stmt);
|
_metadata.init(_stmt);
|
||||||
|
|
||||||
if (_metadata.columnsReturned() > 0)
|
if (_metadata.columnsReturned() > 0)
|
||||||
{
|
{
|
||||||
_stmt.bindResult(_metadata.row());
|
_stmt.bindResult(_metadata.row());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MySQLStatementImpl::bindImpl()
|
void MySQLStatementImpl::bindImpl()
|
||||||
{
|
{
|
||||||
{
|
{
|
||||||
Poco::Data::AbstractBindingVec& binds = bindings();
|
Poco::Data::AbstractBindingVec& binds = bindings();
|
||||||
size_t pos = 0;
|
size_t pos = 0;
|
||||||
Poco::Data::AbstractBindingVec::iterator it = binds.begin();
|
Poco::Data::AbstractBindingVec::iterator it = binds.begin();
|
||||||
Poco::Data::AbstractBindingVec::iterator itEnd = binds.end();
|
Poco::Data::AbstractBindingVec::iterator itEnd = binds.end();
|
||||||
|
|
||||||
for (; it != itEnd && (*it)->canBind(); ++it)
|
for (; it != itEnd && (*it)->canBind(); ++it)
|
||||||
{
|
{
|
||||||
(*it)->bind(pos);
|
(*it)->bind(pos);
|
||||||
pos += (*it)->numOfColumnsHandled();
|
pos += (*it)->numOfColumnsHandled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_stmt.bindParams(_binder.getBindArray(), _binder.size());
|
_stmt.bindParams(_binder.getBindArray(), _binder.size());
|
||||||
|
|
||||||
_stmt.execute();
|
_stmt.execute();
|
||||||
|
|
||||||
_hasNext = NEXT_DONTKNOW;
|
_hasNext = NEXT_DONTKNOW;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AbstractExtractor& MySQLStatementImpl::extractor()
|
AbstractExtractor& MySQLStatementImpl::extractor()
|
||||||
{
|
{
|
||||||
return _extractor;
|
return _extractor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
AbstractBinder& MySQLStatementImpl::binder()
|
AbstractBinder& MySQLStatementImpl::binder()
|
||||||
{
|
{
|
||||||
return _binder;
|
return _binder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|||||||
@@ -1,279 +1,279 @@
|
|||||||
//
|
//
|
||||||
// MySQLException.cpp
|
// MySQLException.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/src/ResultMetadata.cpp#1 $
|
// $Id: //poco/1.3/Data/MySQL/src/ResultMetadata.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: ResultMetadata
|
// Module: ResultMetadata
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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/MySQL/ResultMetadata.h"
|
#include "Poco/Data/MySQL/ResultMetadata.h"
|
||||||
#include "Poco/Data/MySQL/MySQLException.h"
|
#include "Poco/Data/MySQL/MySQLException.h"
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
class ResultMetadataHandle
|
class ResultMetadataHandle
|
||||||
/// Simple exception-safe wrapper
|
/// Simple exception-safe wrapper
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
explicit ResultMetadataHandle(MYSQL_STMT* stmt)
|
explicit ResultMetadataHandle(MYSQL_STMT* stmt)
|
||||||
{
|
{
|
||||||
h = mysql_stmt_result_metadata(stmt);
|
h = mysql_stmt_result_metadata(stmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
~ResultMetadataHandle()
|
~ResultMetadataHandle()
|
||||||
{
|
{
|
||||||
if (h)
|
if (h)
|
||||||
{
|
{
|
||||||
mysql_free_result(h);
|
mysql_free_result(h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
operator MYSQL_RES* ()
|
operator MYSQL_RES* ()
|
||||||
{
|
{
|
||||||
return h;
|
return h;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
MYSQL_RES* h;
|
MYSQL_RES* h;
|
||||||
};
|
};
|
||||||
|
|
||||||
size_t fieldSize(const MYSQL_FIELD& field)
|
size_t fieldSize(const MYSQL_FIELD& field)
|
||||||
/// Convert field MySQL-type and field MySQL-length to actual field length
|
/// Convert field MySQL-type and field MySQL-length to actual field length
|
||||||
{
|
{
|
||||||
switch (field.type)
|
switch (field.type)
|
||||||
{
|
{
|
||||||
case MYSQL_TYPE_TINY: return sizeof(char);
|
case MYSQL_TYPE_TINY: return sizeof(char);
|
||||||
case MYSQL_TYPE_SHORT: return sizeof(short);
|
case MYSQL_TYPE_SHORT: return sizeof(short);
|
||||||
case MYSQL_TYPE_LONG: return sizeof(Poco::Int32);
|
case MYSQL_TYPE_LONG: return sizeof(Poco::Int32);
|
||||||
case MYSQL_TYPE_FLOAT: return sizeof(float);
|
case MYSQL_TYPE_FLOAT: return sizeof(float);
|
||||||
case MYSQL_TYPE_DOUBLE: return sizeof(double);
|
case MYSQL_TYPE_DOUBLE: return sizeof(double);
|
||||||
case MYSQL_TYPE_LONGLONG: return sizeof(Poco::Int64);
|
case MYSQL_TYPE_LONGLONG: return sizeof(Poco::Int64);
|
||||||
|
|
||||||
case MYSQL_TYPE_DECIMAL:
|
case MYSQL_TYPE_DECIMAL:
|
||||||
case MYSQL_TYPE_NEWDECIMAL:
|
case MYSQL_TYPE_NEWDECIMAL:
|
||||||
case MYSQL_TYPE_STRING:
|
case MYSQL_TYPE_STRING:
|
||||||
case MYSQL_TYPE_VAR_STRING:
|
case MYSQL_TYPE_VAR_STRING:
|
||||||
case MYSQL_TYPE_TINY_BLOB:
|
case MYSQL_TYPE_TINY_BLOB:
|
||||||
case MYSQL_TYPE_MEDIUM_BLOB:
|
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||||
case MYSQL_TYPE_LONG_BLOB:
|
case MYSQL_TYPE_LONG_BLOB:
|
||||||
case MYSQL_TYPE_BLOB:
|
case MYSQL_TYPE_BLOB:
|
||||||
case MYSQL_TYPE_NULL:
|
case MYSQL_TYPE_NULL:
|
||||||
case MYSQL_TYPE_TIMESTAMP:
|
case MYSQL_TYPE_TIMESTAMP:
|
||||||
case MYSQL_TYPE_INT24:
|
case MYSQL_TYPE_INT24:
|
||||||
case MYSQL_TYPE_DATE:
|
case MYSQL_TYPE_DATE:
|
||||||
case MYSQL_TYPE_TIME:
|
case MYSQL_TYPE_TIME:
|
||||||
case MYSQL_TYPE_DATETIME:
|
case MYSQL_TYPE_DATETIME:
|
||||||
case MYSQL_TYPE_YEAR:
|
case MYSQL_TYPE_YEAR:
|
||||||
case MYSQL_TYPE_NEWDATE:
|
case MYSQL_TYPE_NEWDATE:
|
||||||
case MYSQL_TYPE_VARCHAR:
|
case MYSQL_TYPE_VARCHAR:
|
||||||
case MYSQL_TYPE_BIT:
|
case MYSQL_TYPE_BIT:
|
||||||
case MYSQL_TYPE_ENUM:
|
case MYSQL_TYPE_ENUM:
|
||||||
case MYSQL_TYPE_SET:
|
case MYSQL_TYPE_SET:
|
||||||
case MYSQL_TYPE_GEOMETRY:
|
case MYSQL_TYPE_GEOMETRY:
|
||||||
default:
|
default:
|
||||||
return field.length;
|
return field.length;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw Poco::Data::MySQL::StatementException("unknown field type");
|
throw Poco::Data::MySQL::StatementException("unknown field type");
|
||||||
}
|
}
|
||||||
|
|
||||||
Poco::Data::MetaColumn::ColumnDataType fieldType(const MYSQL_FIELD& field)
|
Poco::Data::MetaColumn::ColumnDataType fieldType(const MYSQL_FIELD& field)
|
||||||
/// Convert field MySQL-type to Poco-type
|
/// Convert field MySQL-type to Poco-type
|
||||||
{
|
{
|
||||||
bool unsig = ((field.flags & UNSIGNED_FLAG) == UNSIGNED_FLAG);
|
bool unsig = ((field.flags & UNSIGNED_FLAG) == UNSIGNED_FLAG);
|
||||||
|
|
||||||
switch (field.type)
|
switch (field.type)
|
||||||
{
|
{
|
||||||
case MYSQL_TYPE_TINY:
|
case MYSQL_TYPE_TINY:
|
||||||
if (unsig) return Poco::Data::MetaColumn::FDT_UINT8;
|
if (unsig) return Poco::Data::MetaColumn::FDT_UINT8;
|
||||||
return Poco::Data::MetaColumn::FDT_INT8;
|
return Poco::Data::MetaColumn::FDT_INT8;
|
||||||
|
|
||||||
case MYSQL_TYPE_SHORT:
|
case MYSQL_TYPE_SHORT:
|
||||||
if (unsig) return Poco::Data::MetaColumn::FDT_UINT16;
|
if (unsig) return Poco::Data::MetaColumn::FDT_UINT16;
|
||||||
return Poco::Data::MetaColumn::FDT_INT16;
|
return Poco::Data::MetaColumn::FDT_INT16;
|
||||||
|
|
||||||
case MYSQL_TYPE_LONG:
|
case MYSQL_TYPE_LONG:
|
||||||
if (unsig) return Poco::Data::MetaColumn::FDT_UINT32;
|
if (unsig) return Poco::Data::MetaColumn::FDT_UINT32;
|
||||||
return Poco::Data::MetaColumn::FDT_INT32;
|
return Poco::Data::MetaColumn::FDT_INT32;
|
||||||
|
|
||||||
case MYSQL_TYPE_FLOAT:
|
case MYSQL_TYPE_FLOAT:
|
||||||
return Poco::Data::MetaColumn::FDT_FLOAT;
|
return Poco::Data::MetaColumn::FDT_FLOAT;
|
||||||
|
|
||||||
case MYSQL_TYPE_DOUBLE:
|
case MYSQL_TYPE_DOUBLE:
|
||||||
return Poco::Data::MetaColumn::FDT_DOUBLE;
|
return Poco::Data::MetaColumn::FDT_DOUBLE;
|
||||||
|
|
||||||
case MYSQL_TYPE_LONGLONG:
|
case MYSQL_TYPE_LONGLONG:
|
||||||
if (unsig) return Poco::Data::MetaColumn::FDT_UINT64;
|
if (unsig) return Poco::Data::MetaColumn::FDT_UINT64;
|
||||||
return Poco::Data::MetaColumn::FDT_INT64;
|
return Poco::Data::MetaColumn::FDT_INT64;
|
||||||
|
|
||||||
case MYSQL_TYPE_STRING:
|
case MYSQL_TYPE_STRING:
|
||||||
case MYSQL_TYPE_VAR_STRING:
|
case MYSQL_TYPE_VAR_STRING:
|
||||||
return Poco::Data::MetaColumn::FDT_STRING;
|
return Poco::Data::MetaColumn::FDT_STRING;
|
||||||
|
|
||||||
case MYSQL_TYPE_TINY_BLOB:
|
case MYSQL_TYPE_TINY_BLOB:
|
||||||
case MYSQL_TYPE_MEDIUM_BLOB:
|
case MYSQL_TYPE_MEDIUM_BLOB:
|
||||||
case MYSQL_TYPE_LONG_BLOB:
|
case MYSQL_TYPE_LONG_BLOB:
|
||||||
case MYSQL_TYPE_BLOB:
|
case MYSQL_TYPE_BLOB:
|
||||||
return Poco::Data::MetaColumn::FDT_BLOB;
|
return Poco::Data::MetaColumn::FDT_BLOB;
|
||||||
|
|
||||||
case MYSQL_TYPE_DECIMAL:
|
case MYSQL_TYPE_DECIMAL:
|
||||||
case MYSQL_TYPE_NEWDECIMAL:
|
case MYSQL_TYPE_NEWDECIMAL:
|
||||||
case MYSQL_TYPE_NULL:
|
case MYSQL_TYPE_NULL:
|
||||||
case MYSQL_TYPE_TIMESTAMP:
|
case MYSQL_TYPE_TIMESTAMP:
|
||||||
case MYSQL_TYPE_INT24:
|
case MYSQL_TYPE_INT24:
|
||||||
case MYSQL_TYPE_DATE:
|
case MYSQL_TYPE_DATE:
|
||||||
case MYSQL_TYPE_TIME:
|
case MYSQL_TYPE_TIME:
|
||||||
case MYSQL_TYPE_DATETIME:
|
case MYSQL_TYPE_DATETIME:
|
||||||
case MYSQL_TYPE_YEAR:
|
case MYSQL_TYPE_YEAR:
|
||||||
case MYSQL_TYPE_NEWDATE:
|
case MYSQL_TYPE_NEWDATE:
|
||||||
case MYSQL_TYPE_VARCHAR:
|
case MYSQL_TYPE_VARCHAR:
|
||||||
case MYSQL_TYPE_BIT:
|
case MYSQL_TYPE_BIT:
|
||||||
case MYSQL_TYPE_ENUM:
|
case MYSQL_TYPE_ENUM:
|
||||||
case MYSQL_TYPE_SET:
|
case MYSQL_TYPE_SET:
|
||||||
case MYSQL_TYPE_GEOMETRY:
|
case MYSQL_TYPE_GEOMETRY:
|
||||||
default:
|
default:
|
||||||
return Poco::Data::MetaColumn::FDT_UNKNOWN;
|
return Poco::Data::MetaColumn::FDT_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Poco::Data::MetaColumn::FDT_UNKNOWN;
|
return Poco::Data::MetaColumn::FDT_UNKNOWN;
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
void ResultMetadata::reset()
|
void ResultMetadata::reset()
|
||||||
{
|
{
|
||||||
_columns.resize(0);
|
_columns.resize(0);
|
||||||
_row.resize(0);
|
_row.resize(0);
|
||||||
_buffer.resize(0);
|
_buffer.resize(0);
|
||||||
_lengths.resize(0);
|
_lengths.resize(0);
|
||||||
_isNull.resize(0);
|
_isNull.resize(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ResultMetadata::init(MYSQL_STMT* stmt)
|
void ResultMetadata::init(MYSQL_STMT* stmt)
|
||||||
{
|
{
|
||||||
ResultMetadataHandle h(stmt);
|
ResultMetadataHandle h(stmt);
|
||||||
|
|
||||||
if (!h)
|
if (!h)
|
||||||
{
|
{
|
||||||
// all right, it is normal
|
// all right, it is normal
|
||||||
// querys such an "INSERT INTO" just does not have result at all
|
// querys such an "INSERT INTO" just does not have result at all
|
||||||
reset();
|
reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t count = mysql_num_fields(h);
|
size_t count = mysql_num_fields(h);
|
||||||
MYSQL_FIELD* fields = mysql_fetch_fields(h);
|
MYSQL_FIELD* fields = mysql_fetch_fields(h);
|
||||||
|
|
||||||
size_t commonSize = 0;
|
size_t commonSize = 0;
|
||||||
_columns.reserve(count);
|
_columns.reserve(count);
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++)
|
for (size_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
_columns.push_back(MetaColumn(
|
_columns.push_back(MetaColumn(
|
||||||
i, // position
|
i, // position
|
||||||
fields[i].name, // name
|
fields[i].name, // name
|
||||||
fieldType(fields[i]), // type
|
fieldType(fields[i]), // type
|
||||||
fieldSize(fields[i]), // length
|
fieldSize(fields[i]), // length
|
||||||
0, // TODO: precision (Now I dont know how to get it)
|
0, // TODO: precision (Now I dont know how to get it)
|
||||||
!IS_NOT_NULL(fields[i].flags) // nullable
|
!IS_NOT_NULL(fields[i].flags) // nullable
|
||||||
));
|
));
|
||||||
|
|
||||||
commonSize += _columns[i].length();
|
commonSize += _columns[i].length();
|
||||||
}
|
}
|
||||||
|
|
||||||
_buffer.resize(commonSize);
|
_buffer.resize(commonSize);
|
||||||
_row.resize(count);
|
_row.resize(count);
|
||||||
_lengths.resize(count);
|
_lengths.resize(count);
|
||||||
_isNull.resize(count);
|
_isNull.resize(count);
|
||||||
|
|
||||||
size_t offset = 0;
|
size_t offset = 0;
|
||||||
|
|
||||||
for (size_t i = 0; i < count; i++)
|
for (size_t i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
memset(&_row[i], 0, sizeof(MYSQL_BIND));
|
memset(&_row[i], 0, sizeof(MYSQL_BIND));
|
||||||
|
|
||||||
_row[i].buffer_type = fields[i].type;
|
_row[i].buffer_type = fields[i].type;
|
||||||
_row[i].buffer_length = static_cast<unsigned int>(_columns[i].length());
|
_row[i].buffer_length = static_cast<unsigned int>(_columns[i].length());
|
||||||
_row[i].buffer = &_buffer[0] + offset;
|
_row[i].buffer = &_buffer[0] + offset;
|
||||||
_row[i].length = &_lengths[i];
|
_row[i].length = &_lengths[i];
|
||||||
_row[i].is_null = &_isNull[i];
|
_row[i].is_null = &_isNull[i];
|
||||||
|
|
||||||
offset += _row[i].buffer_length;
|
offset += _row[i].buffer_length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Poco::UInt32 ResultMetadata::columnsReturned() const
|
Poco::UInt32 ResultMetadata::columnsReturned() const
|
||||||
{
|
{
|
||||||
return static_cast<Poco::UInt32>(_columns.size());
|
return static_cast<Poco::UInt32>(_columns.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const MetaColumn& ResultMetadata::metaColumn(Poco::UInt32 pos) const
|
const MetaColumn& ResultMetadata::metaColumn(Poco::UInt32 pos) const
|
||||||
{
|
{
|
||||||
return _columns[pos];
|
return _columns[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
MYSQL_BIND* ResultMetadata::row()
|
MYSQL_BIND* ResultMetadata::row()
|
||||||
{
|
{
|
||||||
return &_row[0];
|
return &_row[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t ResultMetadata::length(size_t pos) const
|
size_t ResultMetadata::length(size_t pos) const
|
||||||
{
|
{
|
||||||
return _lengths[pos];
|
return _lengths[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const char* ResultMetadata::rawData(size_t pos) const
|
const char* ResultMetadata::rawData(size_t pos) const
|
||||||
{
|
{
|
||||||
return reinterpret_cast<const char*>(_row[pos].buffer);
|
return reinterpret_cast<const char*>(_row[pos].buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool ResultMetadata::isNull(size_t pos) const
|
bool ResultMetadata::isNull(size_t pos) const
|
||||||
{
|
{
|
||||||
return (_isNull[pos] != 0);
|
return (_isNull[pos] != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|||||||
@@ -1,119 +1,119 @@
|
|||||||
//
|
//
|
||||||
// SesssionHandle.cpp
|
// SesssionHandle.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/src/SessionHandle.cpp#1 $
|
// $Id: //poco/1.3/Data/MySQL/src/SessionHandle.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: SessionHandle
|
// Module: SessionHandle
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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/MySQL/SessionHandle.h"
|
#include "Poco/Data/MySQL/SessionHandle.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
SessionHandle::SessionHandle(MYSQL* mysql)
|
SessionHandle::SessionHandle(MYSQL* mysql)
|
||||||
{
|
{
|
||||||
h = mysql_init(mysql);
|
h = mysql_init(mysql);
|
||||||
|
|
||||||
if (!h)
|
if (!h)
|
||||||
{
|
{
|
||||||
throw ConnectionException("mysql_init error");
|
throw ConnectionException("mysql_init error");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SessionHandle::~SessionHandle()
|
SessionHandle::~SessionHandle()
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionHandle::options(mysql_option opt)
|
void SessionHandle::options(mysql_option opt)
|
||||||
{
|
{
|
||||||
int res = mysql_options(h, opt, 0);
|
int res = mysql_options(h, opt, 0);
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
throw ConnectionException("mysql_options error", h);
|
throw ConnectionException("mysql_options error", h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionHandle::options(mysql_option opt, bool b)
|
void SessionHandle::options(mysql_option opt, bool b)
|
||||||
{
|
{
|
||||||
my_bool tmp = b;
|
my_bool tmp = b;
|
||||||
int res = mysql_options(h, opt, &tmp);
|
int res = mysql_options(h, opt, &tmp);
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
throw ConnectionException("mysql_options error", h);
|
throw ConnectionException("mysql_options error", h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionHandle::connect(const char* host, const char* user, const char* password, const char* db, unsigned int port)
|
void SessionHandle::connect(const char* host, const char* user, const char* password, const char* db, unsigned int port)
|
||||||
{
|
{
|
||||||
if (!mysql_real_connect(h, host, user, password, db, port, 0, 0))
|
if (!mysql_real_connect(h, host, user, password, db, port, 0, 0))
|
||||||
{
|
{
|
||||||
throw ConnectionException("create session: mysql_real_connect error", h);
|
throw ConnectionException("create session: mysql_real_connect error", h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionHandle::close()
|
void SessionHandle::close()
|
||||||
{
|
{
|
||||||
if (h)
|
if (h)
|
||||||
{
|
{
|
||||||
mysql_close(h);
|
mysql_close(h);
|
||||||
h = 0;
|
h = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionHandle::query(const char* str)
|
void SessionHandle::query(const char* str)
|
||||||
{
|
{
|
||||||
int res = mysql_real_query(h, str, static_cast<unsigned long>(strlen(str)));
|
int res = mysql_real_query(h, str, static_cast<unsigned long>(strlen(str)));
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
std::string msg;
|
std::string msg;
|
||||||
msg += "mysql_real_query('";
|
msg += "mysql_real_query('";
|
||||||
msg += str;
|
msg += str;
|
||||||
msg += "') error";
|
msg += "') error";
|
||||||
throw ConnectionException(msg, h);
|
throw ConnectionException(msg, h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|||||||
@@ -1,232 +1,232 @@
|
|||||||
//
|
//
|
||||||
// MySQLException.cpp
|
// MySQLException.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/src/SessionImpl.cpp#1 $
|
// $Id: //poco/1.3/Data/MySQL/src/SessionImpl.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: SessionImpl
|
// Module: SessionImpl
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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/MySQL/SessionImpl.h"
|
#include "Poco/Data/MySQL/SessionImpl.h"
|
||||||
#include "Poco/Data/MySQL/MySQLStatementImpl.h"
|
#include "Poco/Data/MySQL/MySQLStatementImpl.h"
|
||||||
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::string copyStripped(std::string::const_iterator from, std::string::const_iterator to)
|
std::string copyStripped(std::string::const_iterator from, std::string::const_iterator to)
|
||||||
{
|
{
|
||||||
// skip leading spaces
|
// skip leading spaces
|
||||||
while ((from != to) && isspace(*from)) from++;
|
while ((from != to) && isspace(*from)) from++;
|
||||||
// skip trailing spaces
|
// skip trailing spaces
|
||||||
while ((from != to) && isspace(*(to - 1))) to--;
|
while ((from != to) && isspace(*(to - 1))) to--;
|
||||||
|
|
||||||
return std::string(from, to);
|
return std::string(from, to);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
SessionImpl::SessionImpl(const std::string& connectionString) : _mysql(0), _connected(false), _inTransaction(0)
|
SessionImpl::SessionImpl(const std::string& connectionString) : _mysql(0), _connected(false), _inTransaction(0)
|
||||||
{
|
{
|
||||||
addProperty("insertId",
|
addProperty("insertId",
|
||||||
&SessionImpl::setInsertId,
|
&SessionImpl::setInsertId,
|
||||||
&SessionImpl::getInsertId);
|
&SessionImpl::getInsertId);
|
||||||
|
|
||||||
std::map<std::string, std::string> options;
|
std::map<std::string, std::string> options;
|
||||||
|
|
||||||
// Default values
|
// Default values
|
||||||
options["host"] = "localhost";
|
options["host"] = "localhost";
|
||||||
options["port"] = "3306";
|
options["port"] = "3306";
|
||||||
options["user"] = "";
|
options["user"] = "";
|
||||||
options["password"] = "";
|
options["password"] = "";
|
||||||
options["db"] = "";
|
options["db"] = "";
|
||||||
options["compress"] = "";
|
options["compress"] = "";
|
||||||
options["auto-reconnect"] = "";
|
options["auto-reconnect"] = "";
|
||||||
|
|
||||||
//
|
//
|
||||||
// Parse string
|
// Parse string
|
||||||
//
|
//
|
||||||
|
|
||||||
for (std::string::const_iterator start = connectionString.begin();;)
|
for (std::string::const_iterator start = connectionString.begin();;)
|
||||||
{
|
{
|
||||||
// find next ';'
|
// find next ';'
|
||||||
std::string::const_iterator finish = std::find(start, connectionString.end(), ';');
|
std::string::const_iterator finish = std::find(start, connectionString.end(), ';');
|
||||||
|
|
||||||
// find '='
|
// find '='
|
||||||
std::string::const_iterator middle = std::find(start, finish, '=');
|
std::string::const_iterator middle = std::find(start, finish, '=');
|
||||||
|
|
||||||
if (middle == finish)
|
if (middle == finish)
|
||||||
{
|
{
|
||||||
throw MySQLException("create session: bad connection string format, can not find '='");
|
throw MySQLException("create session: bad connection string format, can not find '='");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parse name and value, skip all spaces
|
// Parse name and value, skip all spaces
|
||||||
options[copyStripped(start, middle)] = copyStripped(middle + 1, finish);
|
options[copyStripped(start, middle)] = copyStripped(middle + 1, finish);
|
||||||
|
|
||||||
if (finish == connectionString.end())
|
if (finish == connectionString.end())
|
||||||
{
|
{
|
||||||
// end of parse
|
// end of parse
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// move start position after ';'
|
// move start position after ';'
|
||||||
start = finish + 1;
|
start = finish + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Checking
|
// Checking
|
||||||
//
|
//
|
||||||
|
|
||||||
if (options["user"] == "")
|
if (options["user"] == "")
|
||||||
{
|
{
|
||||||
throw MySQLException("create session: specify user name");
|
throw MySQLException("create session: specify user name");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options["db"] == "")
|
if (options["db"] == "")
|
||||||
{
|
{
|
||||||
throw MySQLException("create session: specify database");
|
throw MySQLException("create session: specify database");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (atoi(options["port"].c_str()) == 0)
|
if (atoi(options["port"].c_str()) == 0)
|
||||||
{
|
{
|
||||||
throw MySQLException("create session: specify correct port (numeric in decimal notation)");
|
throw MySQLException("create session: specify correct port (numeric in decimal notation)");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Options
|
// Options
|
||||||
//
|
//
|
||||||
|
|
||||||
if (options["compress"] == "true")
|
if (options["compress"] == "true")
|
||||||
{
|
{
|
||||||
_mysql.options(MYSQL_OPT_COMPRESS);
|
_mysql.options(MYSQL_OPT_COMPRESS);
|
||||||
}
|
}
|
||||||
else if (options["compress"] == "false")
|
else if (options["compress"] == "false")
|
||||||
{
|
{
|
||||||
// do nothing
|
// do nothing
|
||||||
}
|
}
|
||||||
else if (options["compress"] != "")
|
else if (options["compress"] != "")
|
||||||
{
|
{
|
||||||
throw MySQLException("create session: specify correct compress option (true or false) or skip it");
|
throw MySQLException("create session: specify correct compress option (true or false) or skip it");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (options["auto-reconnect"] == "true")
|
if (options["auto-reconnect"] == "true")
|
||||||
{
|
{
|
||||||
_mysql.options(MYSQL_OPT_RECONNECT, true);
|
_mysql.options(MYSQL_OPT_RECONNECT, true);
|
||||||
}
|
}
|
||||||
else if (options["auto-reconnect"] == "false")
|
else if (options["auto-reconnect"] == "false")
|
||||||
{
|
{
|
||||||
_mysql.options(MYSQL_OPT_RECONNECT, false);
|
_mysql.options(MYSQL_OPT_RECONNECT, false);
|
||||||
}
|
}
|
||||||
else if (options["auto-reconnect"] != "")
|
else if (options["auto-reconnect"] != "")
|
||||||
{
|
{
|
||||||
throw MySQLException("create session: specify correct auto-reconnect option (true or false) or skip it");
|
throw MySQLException("create session: specify correct auto-reconnect option (true or false) or skip it");
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Real connect
|
// Real connect
|
||||||
//
|
//
|
||||||
|
|
||||||
_mysql.connect(
|
_mysql.connect(
|
||||||
options["host"].c_str(),
|
options["host"].c_str(),
|
||||||
options["user"].c_str(),
|
options["user"].c_str(),
|
||||||
options["password"].c_str(),
|
options["password"].c_str(),
|
||||||
options["db"].c_str(),
|
options["db"].c_str(),
|
||||||
atoi(options["port"].c_str()));
|
atoi(options["port"].c_str()));
|
||||||
|
|
||||||
_connected = true;
|
_connected = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SessionImpl::~SessionImpl()
|
SessionImpl::~SessionImpl()
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Poco::Data::StatementImpl* SessionImpl::createStatementImpl()
|
Poco::Data::StatementImpl* SessionImpl::createStatementImpl()
|
||||||
{
|
{
|
||||||
return new MySQLStatementImpl(_mysql);
|
return new MySQLStatementImpl(_mysql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionImpl::begin()
|
void SessionImpl::begin()
|
||||||
{
|
{
|
||||||
_mysql.query("START TRANSACTION");
|
_mysql.query("START TRANSACTION");
|
||||||
_inTransaction++;
|
_inTransaction++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionImpl::commit()
|
void SessionImpl::commit()
|
||||||
{
|
{
|
||||||
_mysql.query("COMMIT");
|
_mysql.query("COMMIT");
|
||||||
_inTransaction--;
|
_inTransaction--;
|
||||||
|
|
||||||
// ?
|
// ?
|
||||||
// mysql_commit(fMysql);
|
// mysql_commit(fMysql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionImpl::rollback()
|
void SessionImpl::rollback()
|
||||||
{
|
{
|
||||||
_mysql.query("ROLLBACK");
|
_mysql.query("ROLLBACK");
|
||||||
_inTransaction--;
|
_inTransaction--;
|
||||||
|
|
||||||
// ?
|
// ?
|
||||||
// mysql_commit(fMysql);
|
// mysql_commit(fMysql);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionImpl::close()
|
void SessionImpl::close()
|
||||||
{
|
{
|
||||||
if (_connected)
|
if (_connected)
|
||||||
{
|
{
|
||||||
_mysql.close();
|
_mysql.close();
|
||||||
_connected = false;
|
_connected = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SessionImpl::isConnected()
|
bool SessionImpl::isConnected()
|
||||||
{
|
{
|
||||||
return _connected;
|
return _connected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SessionImpl::isTransaction()
|
bool SessionImpl::isTransaction()
|
||||||
{
|
{
|
||||||
return (_inTransaction > 0);
|
return (_inTransaction > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|||||||
@@ -1,195 +1,195 @@
|
|||||||
//
|
//
|
||||||
// StatementExecutor.cpp
|
// StatementExecutor.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/src/StatementExecutor.cpp#1 $
|
// $Id: //poco/1.3/Data/MySQL/src/StatementExecutor.cpp#2 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: MySQL
|
// Package: MySQL
|
||||||
// Module: StatementExecutor
|
// Module: StatementExecutor
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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 <mysql.h>
|
#include <mysql.h>
|
||||||
#include "Poco/Data/MySQL/StatementExecutor.h"
|
#include "Poco/Data/MySQL/StatementExecutor.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace MySQL {
|
namespace MySQL {
|
||||||
|
|
||||||
|
|
||||||
StatementExecutor::StatementExecutor(MYSQL* mysql)
|
StatementExecutor::StatementExecutor(MYSQL* mysql)
|
||||||
{
|
{
|
||||||
h = mysql_stmt_init(mysql);
|
h = mysql_stmt_init(mysql);
|
||||||
|
|
||||||
if (!h)
|
if (!h)
|
||||||
{
|
{
|
||||||
throw StatementException("mysql_stmt_init error");
|
throw StatementException("mysql_stmt_init error");
|
||||||
}
|
}
|
||||||
|
|
||||||
_state = STMT_INITED;
|
_state = STMT_INITED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StatementExecutor::~StatementExecutor()
|
StatementExecutor::~StatementExecutor()
|
||||||
{
|
{
|
||||||
mysql_stmt_close(h);
|
mysql_stmt_close(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int StatementExecutor::state() const
|
int StatementExecutor::state() const
|
||||||
{
|
{
|
||||||
return _state;
|
return _state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementExecutor::prepare(const std::string& query)
|
void StatementExecutor::prepare(const std::string& query)
|
||||||
{
|
{
|
||||||
if (_state >= STMT_COMPILED)
|
if (_state >= STMT_COMPILED)
|
||||||
{
|
{
|
||||||
throw StatementException("Satement is already compiled");
|
throw StatementException("Satement is already compiled");
|
||||||
}
|
}
|
||||||
|
|
||||||
// compile
|
// compile
|
||||||
int res = mysql_stmt_prepare(h, query.c_str(), static_cast<unsigned int>(query.length()));
|
int res = mysql_stmt_prepare(h, query.c_str(), static_cast<unsigned int>(query.length()));
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
throw StatementException("mysql_stmt_prepare error", h, query);
|
throw StatementException("mysql_stmt_prepare error", h, query);
|
||||||
}
|
}
|
||||||
|
|
||||||
_query = query;
|
_query = query;
|
||||||
_state = STMT_COMPILED;
|
_state = STMT_COMPILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementExecutor::bindParams(MYSQL_BIND* params, size_t count)
|
void StatementExecutor::bindParams(MYSQL_BIND* params, size_t count)
|
||||||
{
|
{
|
||||||
if (_state < STMT_COMPILED)
|
if (_state < STMT_COMPILED)
|
||||||
{
|
{
|
||||||
throw StatementException("Satement is not compiled yet");
|
throw StatementException("Satement is not compiled yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count != mysql_stmt_param_count(h))
|
if (count != mysql_stmt_param_count(h))
|
||||||
{
|
{
|
||||||
throw StatementException("wrong bind parameters count", 0, _query);
|
throw StatementException("wrong bind parameters count", 0, _query);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count == 0)
|
if (count == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = mysql_stmt_bind_param(h, params);
|
int res = mysql_stmt_bind_param(h, params);
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
throw StatementException("mysql_stmt_bind_param() error ", h, _query);
|
throw StatementException("mysql_stmt_bind_param() error ", h, _query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementExecutor::bindResult(MYSQL_BIND* result)
|
void StatementExecutor::bindResult(MYSQL_BIND* result)
|
||||||
{
|
{
|
||||||
if (_state < STMT_COMPILED)
|
if (_state < STMT_COMPILED)
|
||||||
{
|
{
|
||||||
throw StatementException("Satement is not compiled yet");
|
throw StatementException("Satement is not compiled yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = mysql_stmt_bind_result(h, result);
|
int res = mysql_stmt_bind_result(h, result);
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
throw StatementException("mysql_stmt_bind_result error ", h, _query);
|
throw StatementException("mysql_stmt_bind_result error ", h, _query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementExecutor::execute()
|
void StatementExecutor::execute()
|
||||||
{
|
{
|
||||||
if (_state < STMT_COMPILED)
|
if (_state < STMT_COMPILED)
|
||||||
{
|
{
|
||||||
throw StatementException("Satement is not compiled yet");
|
throw StatementException("Satement is not compiled yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = mysql_stmt_execute(h);
|
int res = mysql_stmt_execute(h);
|
||||||
|
|
||||||
if (res != 0)
|
if (res != 0)
|
||||||
{
|
{
|
||||||
throw StatementException("mysql_stmt_execute error", h, _query);
|
throw StatementException("mysql_stmt_execute error", h, _query);
|
||||||
}
|
}
|
||||||
|
|
||||||
_state = STMT_EXECUTED;
|
_state = STMT_EXECUTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool StatementExecutor::fetch()
|
bool StatementExecutor::fetch()
|
||||||
{
|
{
|
||||||
if (_state < STMT_EXECUTED)
|
if (_state < STMT_EXECUTED)
|
||||||
{
|
{
|
||||||
throw StatementException("Satement is not executed yet");
|
throw StatementException("Satement is not executed yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = mysql_stmt_fetch(h);
|
int res = mysql_stmt_fetch(h);
|
||||||
|
|
||||||
if ((res != 0) && (res != MYSQL_NO_DATA))
|
if ((res != 0) && (res != MYSQL_NO_DATA))
|
||||||
{
|
{
|
||||||
throw StatementException("mysql_stmt_fetch error", h, _query);
|
throw StatementException("mysql_stmt_fetch error", h, _query);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (res == 0);
|
return (res == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool StatementExecutor::fetchColumn(size_t n, MYSQL_BIND *bind)
|
bool StatementExecutor::fetchColumn(size_t n, MYSQL_BIND *bind)
|
||||||
{
|
{
|
||||||
if (_state < STMT_EXECUTED)
|
if (_state < STMT_EXECUTED)
|
||||||
{
|
{
|
||||||
throw StatementException("Satement is not executed yet");
|
throw StatementException("Satement is not executed yet");
|
||||||
}
|
}
|
||||||
|
|
||||||
int res = mysql_stmt_fetch_column(h, bind, static_cast<unsigned int>(n), 0);
|
int res = mysql_stmt_fetch_column(h, bind, static_cast<unsigned int>(n), 0);
|
||||||
|
|
||||||
if ((res != 0) && (res != MYSQL_NO_DATA))
|
if ((res != 0) && (res != MYSQL_NO_DATA))
|
||||||
{
|
{
|
||||||
std::string msg;
|
std::string msg;
|
||||||
msg += "mysql_stmt_fetch_column(";
|
msg += "mysql_stmt_fetch_column(";
|
||||||
|
|
||||||
char buff[30];
|
char buff[30];
|
||||||
sprintf(buff, "%d", n);
|
sprintf(buff, "%d", n);
|
||||||
msg += buff;
|
msg += buff;
|
||||||
|
|
||||||
msg += ") error";
|
msg += ") error";
|
||||||
throw StatementException(msg, h, _query);
|
throw StatementException(msg, h, _query);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (res == 0);
|
return (res == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::MySQL
|
} } } // namespace Poco::Data::MySQL
|
||||||
|
|||||||
259
Data/MySQL/testsuite/TestSuite_vs90.vcproj
Normal file
259
Data/MySQL/testsuite/TestSuite_vs90.vcproj
Normal file
@@ -0,0 +1,259 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.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="false"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="CppUnitd.lib WinTestRunnerd.lib PocoFoundationd.lib PocoDatad.lib libmysql.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="false"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="CppUnit.lib WinTestRunner.lib PocoFoundation.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="MySQL"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\MySQLTest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SQLExecutor.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\MySQLTest.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SQLExecutor.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="_Suite"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\MySQLTestSuite.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\MySQLTestSuite.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="_Driver"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\WinDriver.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
@@ -1,39 +1,39 @@
|
|||||||
//
|
//
|
||||||
// Driver.cpp
|
// Driver.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/testsuite/src/Driver.cpp#1 $
|
// $Id: //poco/1.3/Data/MySQL/testsuite/src/Driver.cpp#2 $
|
||||||
//
|
//
|
||||||
// Console-based test driver for Poco SQLite.
|
// Console-based test driver for Poco SQLite.
|
||||||
//
|
//
|
||||||
// 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 "CppUnit/TestRunner.h"
|
#include "CppUnit/TestRunner.h"
|
||||||
#include "MySQLTestSuite.h"
|
#include "MySQLTestSuite.h"
|
||||||
|
|
||||||
|
|
||||||
CppUnitMain(MySQLTestSuite)
|
CppUnitMain(MySQLTestSuite)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,132 +1,132 @@
|
|||||||
//
|
//
|
||||||
// ODBCMySQLTest.h
|
// ODBCMySQLTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/testsuite/src/MySQLTest.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/testsuite/src/MySQLTest.h#2 $
|
||||||
//
|
//
|
||||||
// Definition of the MySQLTest class.
|
// Definition of the MySQLTest class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef MySQLTest_INCLUDED
|
#ifndef MySQLTest_INCLUDED
|
||||||
#define MySQLTest_INCLUDED
|
#define MySQLTest_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Data/MySQL/MySQL.h"
|
#include "Poco/Data/MySQL/MySQL.h"
|
||||||
#include "Poco/Data/Session.h"
|
#include "Poco/Data/Session.h"
|
||||||
#include "Poco/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include "CppUnit/TestCase.h"
|
#include "CppUnit/TestCase.h"
|
||||||
#include "SQLExecutor.h"
|
#include "SQLExecutor.h"
|
||||||
|
|
||||||
|
|
||||||
class MySQLTest: public CppUnit::TestCase
|
class MySQLTest: public CppUnit::TestCase
|
||||||
/// MySQL test class
|
/// MySQL test class
|
||||||
/// Tested:
|
/// Tested:
|
||||||
///
|
///
|
||||||
/// Driver | DB | OS
|
/// Driver | DB | OS
|
||||||
/// ----------------+---------------------------+------------------------------------------
|
/// ----------------+---------------------------+------------------------------------------
|
||||||
/// 03.51.12.00 | MySQL 5.0.27-community-nt | MS Windows XP Professional x64 v.2003/SP1
|
/// 03.51.12.00 | MySQL 5.0.27-community-nt | MS Windows XP Professional x64 v.2003/SP1
|
||||||
///
|
///
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
MySQLTest(const std::string& name);
|
MySQLTest(const std::string& name);
|
||||||
~MySQLTest();
|
~MySQLTest();
|
||||||
|
|
||||||
void testBareboneMySQL();
|
void testBareboneMySQL();
|
||||||
|
|
||||||
void testSimpleAccess();
|
void testSimpleAccess();
|
||||||
void testComplexType();
|
void testComplexType();
|
||||||
void testSimpleAccessVector();
|
void testSimpleAccessVector();
|
||||||
void testComplexTypeVector();
|
void testComplexTypeVector();
|
||||||
void testInsertVector();
|
void testInsertVector();
|
||||||
void testInsertEmptyVector();
|
void testInsertEmptyVector();
|
||||||
|
|
||||||
void testInsertSingleBulk();
|
void testInsertSingleBulk();
|
||||||
void testInsertSingleBulkVec();
|
void testInsertSingleBulkVec();
|
||||||
|
|
||||||
void testLimit();
|
void testLimit();
|
||||||
void testLimitOnce();
|
void testLimitOnce();
|
||||||
void testLimitPrepare();
|
void testLimitPrepare();
|
||||||
void testLimitZero();
|
void testLimitZero();
|
||||||
void testPrepare();
|
void testPrepare();
|
||||||
|
|
||||||
void testSetSimple();
|
void testSetSimple();
|
||||||
void testSetComplex();
|
void testSetComplex();
|
||||||
void testSetComplexUnique();
|
void testSetComplexUnique();
|
||||||
void testMultiSetSimple();
|
void testMultiSetSimple();
|
||||||
void testMultiSetComplex();
|
void testMultiSetComplex();
|
||||||
void testMapComplex();
|
void testMapComplex();
|
||||||
void testMapComplexUnique();
|
void testMapComplexUnique();
|
||||||
void testMultiMapComplex();
|
void testMultiMapComplex();
|
||||||
void testSelectIntoSingle();
|
void testSelectIntoSingle();
|
||||||
void testSelectIntoSingleStep();
|
void testSelectIntoSingleStep();
|
||||||
void testSelectIntoSingleFail();
|
void testSelectIntoSingleFail();
|
||||||
void testLowerLimitOk();
|
void testLowerLimitOk();
|
||||||
void testLowerLimitFail();
|
void testLowerLimitFail();
|
||||||
void testCombinedLimits();
|
void testCombinedLimits();
|
||||||
void testCombinedIllegalLimits();
|
void testCombinedIllegalLimits();
|
||||||
void testRange();
|
void testRange();
|
||||||
void testIllegalRange();
|
void testIllegalRange();
|
||||||
void testSingleSelect();
|
void testSingleSelect();
|
||||||
void testEmptyDB();
|
void testEmptyDB();
|
||||||
|
|
||||||
void testBLOB();
|
void testBLOB();
|
||||||
void testBLOBStmt();
|
void testBLOBStmt();
|
||||||
|
|
||||||
void testFloat();
|
void testFloat();
|
||||||
void testDouble();
|
void testDouble();
|
||||||
|
|
||||||
void testTuple();
|
void testTuple();
|
||||||
void testTupleVector();
|
void testTupleVector();
|
||||||
|
|
||||||
void testInternalExtraction();
|
void testInternalExtraction();
|
||||||
void testNull();
|
void testNull();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
|
||||||
static CppUnit::Test* suite();
|
static CppUnit::Test* suite();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void dropTable(const std::string& tableName);
|
void dropTable(const std::string& tableName);
|
||||||
void recreatePersonTable();
|
void recreatePersonTable();
|
||||||
void recreatePersonBLOBTable();
|
void recreatePersonBLOBTable();
|
||||||
void recreateStringsTable();
|
void recreateStringsTable();
|
||||||
void recreateIntsTable();
|
void recreateIntsTable();
|
||||||
void recreateFloatsTable();
|
void recreateFloatsTable();
|
||||||
void recreateTuplesTable();
|
void recreateTuplesTable();
|
||||||
void recreateVectorsTable();
|
void recreateVectorsTable();
|
||||||
|
|
||||||
static std::string _dbConnString;
|
static std::string _dbConnString;
|
||||||
static Poco::SharedPtr<Poco::Data::Session> _pSession;
|
static Poco::SharedPtr<Poco::Data::Session> _pSession;
|
||||||
static Poco::SharedPtr<SQLExecutor> _pExecutor;
|
static Poco::SharedPtr<SQLExecutor> _pExecutor;
|
||||||
static const bool bindValues[8];
|
static const bool bindValues[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // MySQLTest_INCLUDED
|
#endif // MySQLTest_INCLUDED
|
||||||
|
|||||||
@@ -1,42 +1,42 @@
|
|||||||
//
|
//
|
||||||
// ODBCTestSuite.cpp
|
// ODBCTestSuite.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/testsuite/src/MySQLTestSuite.cpp#1 $
|
// $Id: //poco/1.3/Data/MySQL/testsuite/src/MySQLTestSuite.cpp#2 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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 "MySQLTestSuite.h"
|
#include "MySQLTestSuite.h"
|
||||||
#include "MySQLTest.h"
|
#include "MySQLTest.h"
|
||||||
|
|
||||||
|
|
||||||
CppUnit::Test* MySQLTestSuite::suite()
|
CppUnit::Test* MySQLTestSuite::suite()
|
||||||
{
|
{
|
||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MySQLTestSuite");
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MySQLTestSuite");
|
||||||
pSuite->addTest(MySQLTest::suite());
|
pSuite->addTest(MySQLTest::suite());
|
||||||
return pSuite;
|
return pSuite;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,49 +1,49 @@
|
|||||||
//
|
//
|
||||||
// ODBCTestSuite.h
|
// ODBCTestSuite.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/testsuite/src/MySQLTestSuite.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/testsuite/src/MySQLTestSuite.h#2 $
|
||||||
//
|
//
|
||||||
// Definition of the ODBCTestSuite class.
|
// Definition of the ODBCTestSuite class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef MySQLTestSuite_INCLUDED
|
#ifndef MySQLTestSuite_INCLUDED
|
||||||
#define MySQLTestSuite_INCLUDED
|
#define MySQLTestSuite_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "CppUnit/TestSuite.h"
|
#include "CppUnit/TestSuite.h"
|
||||||
|
|
||||||
|
|
||||||
class MySQLTestSuite
|
class MySQLTestSuite
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static CppUnit::Test* suite();
|
static CppUnit::Test* suite();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // MySQLTestSuite_INCLUDED
|
#endif // MySQLTestSuite_INCLUDED
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,119 +1,119 @@
|
|||||||
//
|
//
|
||||||
// SQLExecutor.h
|
// SQLExecutor.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/testsuite/src/SQLExecutor.h#1 $
|
// $Id: //poco/1.3/Data/MySQL/testsuite/src/SQLExecutor.h#2 $
|
||||||
//
|
//
|
||||||
// Definition of the SQLExecutor class.
|
// Definition of the SQLExecutor class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef SQLExecutor_INCLUDED
|
#ifndef SQLExecutor_INCLUDED
|
||||||
#define SQLExecutor_INCLUDED
|
#define SQLExecutor_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Data/MySQL/MySQL.h"
|
#include "Poco/Data/MySQL/MySQL.h"
|
||||||
#include "Poco/Data/Session.h"
|
#include "Poco/Data/Session.h"
|
||||||
|
|
||||||
|
|
||||||
class SQLExecutor: public CppUnit::TestCase
|
class SQLExecutor: public CppUnit::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum DataBinding
|
enum DataBinding
|
||||||
{
|
{
|
||||||
PB_IMMEDIATE,
|
PB_IMMEDIATE,
|
||||||
PB_AT_EXEC
|
PB_AT_EXEC
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DataExtraction
|
enum DataExtraction
|
||||||
{
|
{
|
||||||
DE_MANUAL,
|
DE_MANUAL,
|
||||||
DE_BOUND
|
DE_BOUND
|
||||||
};
|
};
|
||||||
|
|
||||||
SQLExecutor(const std::string& name, Poco::Data::Session* _pSession);
|
SQLExecutor(const std::string& name, Poco::Data::Session* _pSession);
|
||||||
~SQLExecutor();
|
~SQLExecutor();
|
||||||
|
|
||||||
void bareboneMySQLTest(const char* host, const char* user, const char* pwd, const char* db, int port, const char* tableCreateString);
|
void bareboneMySQLTest(const char* host, const char* user, const char* pwd, const char* db, int port, const char* tableCreateString);
|
||||||
/// This function uses "bare bone" MySQL API calls (i.e. calls are not
|
/// This function uses "bare bone" MySQL API calls (i.e. calls are not
|
||||||
/// "wrapped" in PocoData framework structures).
|
/// "wrapped" in PocoData framework structures).
|
||||||
/// The purpose of the function is to verify that driver behaves
|
/// The purpose of the function is to verify that driver behaves
|
||||||
/// correctly. If this test passes, subsequent tests failures are likely ours.
|
/// correctly. If this test passes, subsequent tests failures are likely ours.
|
||||||
|
|
||||||
void simpleAccess();
|
void simpleAccess();
|
||||||
void complexType();
|
void complexType();
|
||||||
void simpleAccessVector();
|
void simpleAccessVector();
|
||||||
void complexTypeVector();
|
void complexTypeVector();
|
||||||
void insertVector();
|
void insertVector();
|
||||||
void insertEmptyVector();
|
void insertEmptyVector();
|
||||||
|
|
||||||
void insertSingleBulk();
|
void insertSingleBulk();
|
||||||
void insertSingleBulkVec();
|
void insertSingleBulkVec();
|
||||||
|
|
||||||
void limits();
|
void limits();
|
||||||
void limitOnce();
|
void limitOnce();
|
||||||
void limitPrepare();
|
void limitPrepare();
|
||||||
void limitZero();
|
void limitZero();
|
||||||
void prepare();
|
void prepare();
|
||||||
|
|
||||||
void setSimple();
|
void setSimple();
|
||||||
void setComplex();
|
void setComplex();
|
||||||
void setComplexUnique();
|
void setComplexUnique();
|
||||||
void multiSetSimple();
|
void multiSetSimple();
|
||||||
void multiSetComplex();
|
void multiSetComplex();
|
||||||
void mapComplex();
|
void mapComplex();
|
||||||
void mapComplexUnique();
|
void mapComplexUnique();
|
||||||
void multiMapComplex();
|
void multiMapComplex();
|
||||||
void selectIntoSingle();
|
void selectIntoSingle();
|
||||||
void selectIntoSingleStep();
|
void selectIntoSingleStep();
|
||||||
void selectIntoSingleFail();
|
void selectIntoSingleFail();
|
||||||
void lowerLimitOk();
|
void lowerLimitOk();
|
||||||
void lowerLimitFail();
|
void lowerLimitFail();
|
||||||
void combinedLimits();
|
void combinedLimits();
|
||||||
void combinedIllegalLimits();
|
void combinedIllegalLimits();
|
||||||
void ranges();
|
void ranges();
|
||||||
void illegalRange();
|
void illegalRange();
|
||||||
void singleSelect();
|
void singleSelect();
|
||||||
void emptyDB();
|
void emptyDB();
|
||||||
|
|
||||||
void blob(int bigSize = 1024);
|
void blob(int bigSize = 1024);
|
||||||
void blobStmt();
|
void blobStmt();
|
||||||
|
|
||||||
void floats();
|
void floats();
|
||||||
void doubles();
|
void doubles();
|
||||||
void tuples();
|
void tuples();
|
||||||
void tupleVector();
|
void tupleVector();
|
||||||
|
|
||||||
void internalExtraction();
|
void internalExtraction();
|
||||||
void doNull();
|
void doNull();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Poco::Data::Session* _pSession;
|
Poco::Data::Session* _pSession;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // SQLExecutor_INCLUDED
|
#endif // SQLExecutor_INCLUDED
|
||||||
|
|||||||
@@ -1,50 +1,50 @@
|
|||||||
//
|
//
|
||||||
// WinDriver.cpp
|
// WinDriver.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/MySQL/testsuite/src/WinDriver.cpp#1 $
|
// $Id: //poco/1.3/Data/MySQL/testsuite/src/WinDriver.cpp#2 $
|
||||||
//
|
//
|
||||||
// Windows test driver for Poco MySQL.
|
// Windows test driver for Poco MySQL.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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 "WinTestRunner/WinTestRunner.h"
|
#include "WinTestRunner/WinTestRunner.h"
|
||||||
#include "MySQLTestSuite.h"
|
#include "MySQLTestSuite.h"
|
||||||
|
|
||||||
|
|
||||||
class TestDriver: public CppUnit::WinTestRunnerApp
|
class TestDriver: public CppUnit::WinTestRunnerApp
|
||||||
{
|
{
|
||||||
void TestMain()
|
void TestMain()
|
||||||
{
|
{
|
||||||
CppUnit::WinTestRunner runner;
|
CppUnit::WinTestRunner runner;
|
||||||
runner.addTest(MySQLTestSuite::suite());
|
runner.addTest(MySQLTestSuite::suite());
|
||||||
runner.run();
|
runner.run();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
TestDriver theDriver;
|
TestDriver theDriver;
|
||||||
|
|||||||
28
Data/ODBC/ODBC_vs90.sln
Normal file
28
Data/ODBC/ODBC_vs90.sln
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
|
# Visual Studio 2008
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs90.vcproj", "{1B30A91B-375F-11DB-837B-00123FC423B5}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{1B29820D-375F-11DB-837B-00123FC423B5} = {1B29820D-375F-11DB-837B-00123FC423B5}
|
||||||
|
EndProjectSection
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ODBC", "ODBC_vs90.vcproj", "{1B29820D-375F-11DB-837B-00123FC423B5}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
debug_shared|Win32 = debug_shared|Win32
|
||||||
|
release_shared|Win32 = release_shared|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{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
|
||||||
|
{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
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
341
Data/ODBC/ODBC_vs90.vcproj
Normal file
341
Data/ODBC/ODBC_vs90.vcproj
Normal file
@@ -0,0 +1,341 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="ODBC"
|
||||||
|
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;ODBC_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\PocoODBCd.dll"
|
||||||
|
LinkIncremental="2"
|
||||||
|
SuppressStartupBanner="true"
|
||||||
|
AdditionalLibraryDirectories="..\..\lib"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
ProgramDatabaseFile="..\..\bin\PocoODBCd.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeForWindows98="0"
|
||||||
|
ImportLibrary="..\..\lib\PocoODBCd.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;ODBC_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\PocoODBC.dll"
|
||||||
|
LinkIncremental="1"
|
||||||
|
SuppressStartupBanner="true"
|
||||||
|
AdditionalLibraryDirectories="..\..\lib"
|
||||||
|
GenerateDebugInformation="false"
|
||||||
|
ProgramDatabaseFile=""
|
||||||
|
SubSystem="1"
|
||||||
|
OptimizeReferences="2"
|
||||||
|
EnableCOMDATFolding="2"
|
||||||
|
OptimizeForWindows98="0"
|
||||||
|
ImportLibrary="..\..\lib\PocoODBC.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="ODBC"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\Binder.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\ConnectionHandle.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\Connector.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\DataTypes.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\Diagnostics.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\EnvironmentHandle.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\Error.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\Extractor.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\Handle.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\ODBC.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\ODBCColumn.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\ODBCException.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\ODBCStatementImpl.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\Parameter.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\Preparation.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\SessionImpl.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\include\Poco\Data\ODBC\Utility.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Binder.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ConnectionHandle.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Connector.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\DataTypes.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\EnvironmentHandle.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Extractor.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCColumn.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCException.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCStatementImpl.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Parameter.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Preparation.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SessionImpl.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Utility.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
@@ -1,118 +1,118 @@
|
|||||||
//
|
//
|
||||||
// DataTypes.cpp
|
// DataTypes.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/ODBC/src/DataTypes.cpp#3 $
|
// $Id: //poco/1.3/Data/ODBC/src/DataTypes.cpp#4 $
|
||||||
//
|
//
|
||||||
// Library: ODBC
|
// Library: ODBC
|
||||||
// Package: ODBC
|
// Package: ODBC
|
||||||
// Module: DataTypes
|
// Module: DataTypes
|
||||||
//
|
//
|
||||||
// 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/ODBC/DataTypes.h"
|
#include "Poco/Data/ODBC/DataTypes.h"
|
||||||
#include "Poco/Format.h"
|
#include "Poco/Format.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace ODBC {
|
namespace ODBC {
|
||||||
|
|
||||||
|
|
||||||
DataTypes::DataTypes()
|
DataTypes::DataTypes()
|
||||||
{
|
{
|
||||||
_cDataTypes.insert(ValueType(SQL_CHAR, SQL_C_CHAR));
|
_cDataTypes.insert(ValueType(SQL_CHAR, SQL_C_CHAR));
|
||||||
_cDataTypes.insert(ValueType(SQL_VARCHAR, SQL_C_CHAR));
|
_cDataTypes.insert(ValueType(SQL_VARCHAR, SQL_C_CHAR));
|
||||||
_cDataTypes.insert(ValueType(SQL_LONGVARCHAR, SQL_C_CHAR));
|
_cDataTypes.insert(ValueType(SQL_LONGVARCHAR, SQL_C_CHAR));
|
||||||
_cDataTypes.insert(ValueType(SQL_DECIMAL, SQL_C_DOUBLE));
|
_cDataTypes.insert(ValueType(SQL_DECIMAL, SQL_C_DOUBLE));
|
||||||
_cDataTypes.insert(ValueType(SQL_NUMERIC, SQL_C_DOUBLE));
|
_cDataTypes.insert(ValueType(SQL_NUMERIC, SQL_C_DOUBLE));
|
||||||
_cDataTypes.insert(ValueType(SQL_BIT, SQL_C_BIT));
|
_cDataTypes.insert(ValueType(SQL_BIT, SQL_C_BIT));
|
||||||
_cDataTypes.insert(ValueType(SQL_TINYINT, SQL_C_STINYINT));
|
_cDataTypes.insert(ValueType(SQL_TINYINT, SQL_C_STINYINT));
|
||||||
_cDataTypes.insert(ValueType(SQL_SMALLINT, SQL_C_SSHORT));
|
_cDataTypes.insert(ValueType(SQL_SMALLINT, SQL_C_SSHORT));
|
||||||
_cDataTypes.insert(ValueType(SQL_INTEGER, SQL_C_SLONG));
|
_cDataTypes.insert(ValueType(SQL_INTEGER, SQL_C_SLONG));
|
||||||
_cDataTypes.insert(ValueType(SQL_BIGINT, SQL_C_SBIGINT));
|
_cDataTypes.insert(ValueType(SQL_BIGINT, SQL_C_SBIGINT));
|
||||||
_cDataTypes.insert(ValueType(SQL_REAL, SQL_C_FLOAT));
|
_cDataTypes.insert(ValueType(SQL_REAL, SQL_C_FLOAT));
|
||||||
_cDataTypes.insert(ValueType(SQL_FLOAT, SQL_C_DOUBLE));
|
_cDataTypes.insert(ValueType(SQL_FLOAT, SQL_C_DOUBLE));
|
||||||
_cDataTypes.insert(ValueType(SQL_DOUBLE, SQL_C_DOUBLE));
|
_cDataTypes.insert(ValueType(SQL_DOUBLE, SQL_C_DOUBLE));
|
||||||
_cDataTypes.insert(ValueType(SQL_BINARY, SQL_C_BINARY));
|
_cDataTypes.insert(ValueType(SQL_BINARY, SQL_C_BINARY));
|
||||||
_cDataTypes.insert(ValueType(SQL_VARBINARY, SQL_C_BINARY));
|
_cDataTypes.insert(ValueType(SQL_VARBINARY, SQL_C_BINARY));
|
||||||
_cDataTypes.insert(ValueType(SQL_LONGVARBINARY, SQL_C_BINARY));
|
_cDataTypes.insert(ValueType(SQL_LONGVARBINARY, SQL_C_BINARY));
|
||||||
_cDataTypes.insert(ValueType(SQL_TYPE_DATE, SQL_C_TYPE_DATE));
|
_cDataTypes.insert(ValueType(SQL_TYPE_DATE, SQL_C_TYPE_DATE));
|
||||||
_cDataTypes.insert(ValueType(SQL_TYPE_TIME, SQL_C_TYPE_TIME));
|
_cDataTypes.insert(ValueType(SQL_TYPE_TIME, SQL_C_TYPE_TIME));
|
||||||
_cDataTypes.insert(ValueType(SQL_TYPE_TIMESTAMP, SQL_C_TYPE_TIMESTAMP));
|
_cDataTypes.insert(ValueType(SQL_TYPE_TIMESTAMP, SQL_C_TYPE_TIMESTAMP));
|
||||||
|
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_CHAR, SQL_LONGVARCHAR));
|
_sqlDataTypes.insert(ValueType(SQL_C_CHAR, SQL_LONGVARCHAR));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_BIT, SQL_BIT));
|
_sqlDataTypes.insert(ValueType(SQL_C_BIT, SQL_BIT));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_TINYINT, SQL_TINYINT));
|
_sqlDataTypes.insert(ValueType(SQL_C_TINYINT, SQL_TINYINT));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_STINYINT, SQL_TINYINT));
|
_sqlDataTypes.insert(ValueType(SQL_C_STINYINT, SQL_TINYINT));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_UTINYINT, SQL_TINYINT));
|
_sqlDataTypes.insert(ValueType(SQL_C_UTINYINT, SQL_TINYINT));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_SHORT, SQL_SMALLINT));
|
_sqlDataTypes.insert(ValueType(SQL_C_SHORT, SQL_SMALLINT));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_SSHORT, SQL_SMALLINT));
|
_sqlDataTypes.insert(ValueType(SQL_C_SSHORT, SQL_SMALLINT));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_USHORT, SQL_SMALLINT));
|
_sqlDataTypes.insert(ValueType(SQL_C_USHORT, SQL_SMALLINT));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_LONG, SQL_INTEGER));
|
_sqlDataTypes.insert(ValueType(SQL_C_LONG, SQL_INTEGER));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_SLONG, SQL_INTEGER));
|
_sqlDataTypes.insert(ValueType(SQL_C_SLONG, SQL_INTEGER));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_ULONG, SQL_INTEGER));
|
_sqlDataTypes.insert(ValueType(SQL_C_ULONG, SQL_INTEGER));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_SBIGINT, SQL_BIGINT));
|
_sqlDataTypes.insert(ValueType(SQL_C_SBIGINT, SQL_BIGINT));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_UBIGINT, SQL_BIGINT));
|
_sqlDataTypes.insert(ValueType(SQL_C_UBIGINT, SQL_BIGINT));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_FLOAT, SQL_REAL));
|
_sqlDataTypes.insert(ValueType(SQL_C_FLOAT, SQL_REAL));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_DOUBLE, SQL_DOUBLE));
|
_sqlDataTypes.insert(ValueType(SQL_C_DOUBLE, SQL_DOUBLE));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_BINARY, SQL_LONGVARBINARY));
|
_sqlDataTypes.insert(ValueType(SQL_C_BINARY, SQL_LONGVARBINARY));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_TYPE_DATE, SQL_TYPE_DATE));
|
_sqlDataTypes.insert(ValueType(SQL_C_TYPE_DATE, SQL_TYPE_DATE));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_TYPE_TIME, SQL_TYPE_TIME));
|
_sqlDataTypes.insert(ValueType(SQL_C_TYPE_TIME, SQL_TYPE_TIME));
|
||||||
_sqlDataTypes.insert(ValueType(SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP));
|
_sqlDataTypes.insert(ValueType(SQL_C_TYPE_TIMESTAMP, SQL_TYPE_TIMESTAMP));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
DataTypes::~DataTypes()
|
DataTypes::~DataTypes()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int DataTypes::cDataType(int sqlDataType) const
|
int DataTypes::cDataType(int sqlDataType) const
|
||||||
{
|
{
|
||||||
DataTypeMap::const_iterator it = _cDataTypes.find(sqlDataType);
|
DataTypeMap::const_iterator it = _cDataTypes.find(sqlDataType);
|
||||||
|
|
||||||
if (_cDataTypes.end() == it)
|
if (_cDataTypes.end() == it)
|
||||||
throw NotFoundException(format("C data type not found for SQL data type: %d", sqlDataType));
|
throw NotFoundException(format("C data type not found for SQL data type: %d", sqlDataType));
|
||||||
|
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int DataTypes::sqlDataType(int cDataType) const
|
int DataTypes::sqlDataType(int cDataType) const
|
||||||
{
|
{
|
||||||
DataTypeMap::const_iterator it = _sqlDataTypes.find(cDataType);
|
DataTypeMap::const_iterator it = _sqlDataTypes.find(cDataType);
|
||||||
|
|
||||||
if (_sqlDataTypes.end() == it)
|
if (_sqlDataTypes.end() == it)
|
||||||
throw NotFoundException(format("SQL data type not found for C data type: %d", cDataType));
|
throw NotFoundException(format("SQL data type not found for C data type: %d", cDataType));
|
||||||
|
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::ODBC
|
} } } // namespace Poco::Data::ODBC
|
||||||
|
|||||||
@@ -1,383 +1,383 @@
|
|||||||
//
|
//
|
||||||
// Extractor.cpp
|
// Extractor.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/ODBC/src/Extractor.cpp#4 $
|
// $Id: //poco/1.3/Data/ODBC/src/Extractor.cpp#5 $
|
||||||
//
|
//
|
||||||
// Library: ODBC
|
// Library: ODBC
|
||||||
// Package: ODBC
|
// Package: ODBC
|
||||||
// Module: Extractor
|
// Module: Extractor
|
||||||
//
|
//
|
||||||
// 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/ODBC/Extractor.h"
|
#include "Poco/Data/ODBC/Extractor.h"
|
||||||
#include "Poco/Data/ODBC/ODBCColumn.h"
|
#include "Poco/Data/ODBC/ODBCColumn.h"
|
||||||
#include "Poco/Data/ODBC/Utility.h"
|
#include "Poco/Data/ODBC/Utility.h"
|
||||||
#include "Poco/Data/ODBC/ODBCException.h"
|
#include "Poco/Data/ODBC/ODBCException.h"
|
||||||
#include "Poco/Data/BLOB.h"
|
#include "Poco/Data/BLOB.h"
|
||||||
#include "Poco/Buffer.h"
|
#include "Poco/Buffer.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace ODBC {
|
namespace ODBC {
|
||||||
|
|
||||||
|
|
||||||
const std::string Extractor::FLD_SIZE_EXCEEDED_FMT = "Specified data size (%z bytes) "
|
const std::string Extractor::FLD_SIZE_EXCEEDED_FMT = "Specified data size (%z bytes) "
|
||||||
"exceeds maximum value (%z).\n"
|
"exceeds maximum value (%z).\n"
|
||||||
"Use Session.setProperty(\"maxFieldSize\", value) "
|
"Use Session.setProperty(\"maxFieldSize\", value) "
|
||||||
"to increase the maximum allowed data size\n";
|
"to increase the maximum allowed data size\n";
|
||||||
|
|
||||||
|
|
||||||
Extractor::Extractor(const StatementHandle& rStmt,
|
Extractor::Extractor(const StatementHandle& rStmt,
|
||||||
Preparation& rPreparation):
|
Preparation& rPreparation):
|
||||||
_rStmt(rStmt),
|
_rStmt(rStmt),
|
||||||
_rPreparation(rPreparation),
|
_rPreparation(rPreparation),
|
||||||
_dataExtraction(rPreparation.getDataExtraction())
|
_dataExtraction(rPreparation.getDataExtraction())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Extractor::~Extractor()
|
Extractor::~Extractor()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
bool Extractor::extractBoundImpl<std::string>(std::size_t pos, std::string& val)
|
bool Extractor::extractBoundImpl<std::string>(std::size_t pos, std::string& val)
|
||||||
{
|
{
|
||||||
std::size_t dataSize = _rPreparation.actualDataSize(pos);
|
std::size_t dataSize = _rPreparation.actualDataSize(pos);
|
||||||
char*& sp = RefAnyCast<char*>(_rPreparation[pos]);
|
char*& sp = RefAnyCast<char*>(_rPreparation[pos]);
|
||||||
poco_check_ptr (sp);
|
poco_check_ptr (sp);
|
||||||
std::size_t len = strlen(sp);
|
std::size_t len = strlen(sp);
|
||||||
if (len < dataSize) dataSize = len;
|
if (len < dataSize) dataSize = len;
|
||||||
checkDataSize(dataSize);
|
checkDataSize(dataSize);
|
||||||
val.assign(sp, dataSize);
|
val.assign(sp, dataSize);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
bool Extractor::extractBoundImpl<Poco::Data::BLOB>(std::size_t pos, Poco::Data::BLOB& val)
|
bool Extractor::extractBoundImpl<Poco::Data::BLOB>(std::size_t pos, Poco::Data::BLOB& val)
|
||||||
{
|
{
|
||||||
std::size_t dataSize = _rPreparation.actualDataSize(pos);
|
std::size_t dataSize = _rPreparation.actualDataSize(pos);
|
||||||
checkDataSize(dataSize);
|
checkDataSize(dataSize);
|
||||||
char*& sp = RefAnyCast<char*>(_rPreparation[pos]);
|
char*& sp = RefAnyCast<char*>(_rPreparation[pos]);
|
||||||
poco_check_ptr (sp);
|
poco_check_ptr (sp);
|
||||||
val.assignRaw(sp, dataSize);
|
val.assignRaw(sp, dataSize);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
bool Extractor::extractManualImpl<std::string>(std::size_t pos, std::string& val, SQLSMALLINT cType)
|
bool Extractor::extractManualImpl<std::string>(std::size_t pos, std::string& val, SQLSMALLINT cType)
|
||||||
{
|
{
|
||||||
std::size_t maxSize = _rPreparation.getMaxFieldSize();
|
std::size_t maxSize = _rPreparation.getMaxFieldSize();
|
||||||
std::size_t fetchedSize = 0;
|
std::size_t fetchedSize = 0;
|
||||||
std::size_t totalSize = 0;
|
std::size_t totalSize = 0;
|
||||||
|
|
||||||
SQLLEN len;
|
SQLLEN len;
|
||||||
Poco::Buffer<char> apChar(CHUNK_SIZE);
|
Poco::Buffer<char> apChar(CHUNK_SIZE);
|
||||||
char* pChar = apChar.begin();
|
char* pChar = apChar.begin();
|
||||||
SQLRETURN rc = 0;
|
SQLRETURN rc = 0;
|
||||||
val.clear();
|
val.clear();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
memset(pChar, 0, CHUNK_SIZE);
|
memset(pChar, 0, CHUNK_SIZE);
|
||||||
len = 0;
|
len = 0;
|
||||||
rc = SQLGetData(_rStmt,
|
rc = SQLGetData(_rStmt,
|
||||||
(SQLUSMALLINT) pos + 1,
|
(SQLUSMALLINT) pos + 1,
|
||||||
cType, //C data type
|
cType, //C data type
|
||||||
pChar, //returned value
|
pChar, //returned value
|
||||||
CHUNK_SIZE, //buffer length
|
CHUNK_SIZE, //buffer length
|
||||||
&len); //length indicator
|
&len); //length indicator
|
||||||
|
|
||||||
if (SQL_NO_DATA != rc && Utility::isError(rc))
|
if (SQL_NO_DATA != rc && Utility::isError(rc))
|
||||||
throw StatementException(_rStmt, "SQLGetData()");
|
throw StatementException(_rStmt, "SQLGetData()");
|
||||||
|
|
||||||
if (SQL_NO_TOTAL == len)//unknown length, throw
|
if (SQL_NO_TOTAL == len)//unknown length, throw
|
||||||
throw UnknownDataLengthException("Could not determine returned data length.");
|
throw UnknownDataLengthException("Could not determine returned data length.");
|
||||||
|
|
||||||
if (SQL_NO_DATA == rc || SQL_NULL_DATA == len || !len)
|
if (SQL_NO_DATA == rc || SQL_NULL_DATA == len || !len)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
fetchedSize = len > CHUNK_SIZE ? CHUNK_SIZE : len;
|
fetchedSize = len > CHUNK_SIZE ? CHUNK_SIZE : len;
|
||||||
totalSize += fetchedSize;
|
totalSize += fetchedSize;
|
||||||
if (totalSize <= maxSize) val.append(pChar, fetchedSize);
|
if (totalSize <= maxSize) val.append(pChar, fetchedSize);
|
||||||
else throw DataException(format(FLD_SIZE_EXCEEDED_FMT,
|
else throw DataException(format(FLD_SIZE_EXCEEDED_FMT,
|
||||||
fetchedSize,
|
fetchedSize,
|
||||||
maxSize));
|
maxSize));
|
||||||
|
|
||||||
}while (true);
|
}while (true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<>
|
template<>
|
||||||
bool Extractor::extractManualImpl<Poco::Data::BLOB>(std::size_t pos,
|
bool Extractor::extractManualImpl<Poco::Data::BLOB>(std::size_t pos,
|
||||||
Poco::Data::BLOB& val,
|
Poco::Data::BLOB& val,
|
||||||
SQLSMALLINT cType)
|
SQLSMALLINT cType)
|
||||||
{
|
{
|
||||||
std::size_t maxSize = _rPreparation.getMaxFieldSize();
|
std::size_t maxSize = _rPreparation.getMaxFieldSize();
|
||||||
std::size_t fetchedSize = 0;
|
std::size_t fetchedSize = 0;
|
||||||
std::size_t totalSize = 0;
|
std::size_t totalSize = 0;
|
||||||
|
|
||||||
SQLLEN len;
|
SQLLEN len;
|
||||||
Poco::Buffer<char> apChar(CHUNK_SIZE);
|
Poco::Buffer<char> apChar(CHUNK_SIZE);
|
||||||
char* pChar = apChar.begin();
|
char* pChar = apChar.begin();
|
||||||
SQLRETURN rc = 0;
|
SQLRETURN rc = 0;
|
||||||
val.clear();
|
val.clear();
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
memset(pChar, 0, CHUNK_SIZE);
|
memset(pChar, 0, CHUNK_SIZE);
|
||||||
len = 0;
|
len = 0;
|
||||||
rc = SQLGetData(_rStmt,
|
rc = SQLGetData(_rStmt,
|
||||||
(SQLUSMALLINT) pos + 1,
|
(SQLUSMALLINT) pos + 1,
|
||||||
cType, //C data type
|
cType, //C data type
|
||||||
pChar, //returned value
|
pChar, //returned value
|
||||||
CHUNK_SIZE, //buffer length
|
CHUNK_SIZE, //buffer length
|
||||||
&len); //length indicator
|
&len); //length indicator
|
||||||
|
|
||||||
if (SQL_NO_DATA != rc && Utility::isError(rc))
|
if (SQL_NO_DATA != rc && Utility::isError(rc))
|
||||||
throw StatementException(_rStmt, "SQLGetData()");
|
throw StatementException(_rStmt, "SQLGetData()");
|
||||||
|
|
||||||
if (SQL_NO_TOTAL == len)//unknown length, throw
|
if (SQL_NO_TOTAL == len)//unknown length, throw
|
||||||
throw UnknownDataLengthException("Could not determine returned data length.");
|
throw UnknownDataLengthException("Could not determine returned data length.");
|
||||||
|
|
||||||
if (SQL_NO_DATA == rc || SQL_NULL_DATA == len || !len)
|
if (SQL_NO_DATA == rc || SQL_NULL_DATA == len || !len)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
fetchedSize = len > CHUNK_SIZE ? CHUNK_SIZE : len;
|
fetchedSize = len > CHUNK_SIZE ? CHUNK_SIZE : len;
|
||||||
totalSize += fetchedSize;
|
totalSize += fetchedSize;
|
||||||
if (totalSize <= maxSize) val.appendRaw(pChar, fetchedSize);
|
if (totalSize <= maxSize) val.appendRaw(pChar, fetchedSize);
|
||||||
else throw DataException(format(FLD_SIZE_EXCEEDED_FMT,
|
else throw DataException(format(FLD_SIZE_EXCEEDED_FMT,
|
||||||
fetchedSize,
|
fetchedSize,
|
||||||
maxSize));
|
maxSize));
|
||||||
|
|
||||||
}while (true);
|
}while (true);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::Int32& val)
|
bool Extractor::extract(std::size_t pos, Poco::Int32& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_SLONG);
|
return extractManualImpl(pos, val, SQL_C_SLONG);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::Int64& val)
|
bool Extractor::extract(std::size_t pos, Poco::Int64& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_SBIGINT);
|
return extractManualImpl(pos, val, SQL_C_SBIGINT);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, double& val)
|
bool Extractor::extract(std::size_t pos, double& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_DOUBLE);
|
return extractManualImpl(pos, val, SQL_C_DOUBLE);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, std::string& val)
|
bool Extractor::extract(std::size_t pos, std::string& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_CHAR);
|
return extractManualImpl(pos, val, SQL_C_CHAR);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::Data::BLOB& val)
|
bool Extractor::extract(std::size_t pos, Poco::Data::BLOB& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_BINARY);
|
return extractManualImpl(pos, val, SQL_C_BINARY);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::Int8& val)
|
bool Extractor::extract(std::size_t pos, Poco::Int8& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_STINYINT);
|
return extractManualImpl(pos, val, SQL_C_STINYINT);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::UInt8& val)
|
bool Extractor::extract(std::size_t pos, Poco::UInt8& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_UTINYINT);
|
return extractManualImpl(pos, val, SQL_C_UTINYINT);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::Int16& val)
|
bool Extractor::extract(std::size_t pos, Poco::Int16& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_SSHORT);
|
return extractManualImpl(pos, val, SQL_C_SSHORT);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::UInt16& val)
|
bool Extractor::extract(std::size_t pos, Poco::UInt16& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_USHORT);
|
return extractManualImpl(pos, val, SQL_C_USHORT);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::UInt32& val)
|
bool Extractor::extract(std::size_t pos, Poco::UInt32& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_ULONG);
|
return extractManualImpl(pos, val, SQL_C_ULONG);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::UInt64& val)
|
bool Extractor::extract(std::size_t pos, Poco::UInt64& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_SBIGINT);
|
return extractManualImpl(pos, val, SQL_C_SBIGINT);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, bool& val)
|
bool Extractor::extract(std::size_t pos, bool& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, Utility::boolDataType);
|
return extractManualImpl(pos, val, Utility::boolDataType);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, float& val)
|
bool Extractor::extract(std::size_t pos, float& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_FLOAT);
|
return extractManualImpl(pos, val, SQL_C_FLOAT);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, char& val)
|
bool Extractor::extract(std::size_t pos, char& val)
|
||||||
{
|
{
|
||||||
if (Preparation::DE_MANUAL == _dataExtraction)
|
if (Preparation::DE_MANUAL == _dataExtraction)
|
||||||
return extractManualImpl(pos, val, SQL_C_STINYINT);
|
return extractManualImpl(pos, val, SQL_C_STINYINT);
|
||||||
else
|
else
|
||||||
return extractBoundImpl(pos, val);
|
return extractBoundImpl(pos, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool Extractor::extract(std::size_t pos, Poco::Any& val)
|
bool Extractor::extract(std::size_t pos, Poco::Any& val)
|
||||||
{
|
{
|
||||||
ODBCColumn column(_rStmt, pos);
|
ODBCColumn column(_rStmt, pos);
|
||||||
|
|
||||||
switch (column.type())
|
switch (column.type())
|
||||||
{
|
{
|
||||||
case MetaColumn::FDT_INT8:
|
case MetaColumn::FDT_INT8:
|
||||||
{ Poco::Int8 i = 0; extract(pos, i); val = i; return true; }
|
{ Poco::Int8 i = 0; extract(pos, i); val = i; return true; }
|
||||||
|
|
||||||
case MetaColumn::FDT_UINT8:
|
case MetaColumn::FDT_UINT8:
|
||||||
{ Poco::UInt8 i = 0; extract(pos, i); val = i; return true; }
|
{ Poco::UInt8 i = 0; extract(pos, i); val = i; return true; }
|
||||||
|
|
||||||
case MetaColumn::FDT_INT16:
|
case MetaColumn::FDT_INT16:
|
||||||
{ Poco::Int16 i = 0; extract(pos, i); val = i; return true; }
|
{ Poco::Int16 i = 0; extract(pos, i); val = i; return true; }
|
||||||
|
|
||||||
case MetaColumn::FDT_UINT16:
|
case MetaColumn::FDT_UINT16:
|
||||||
{ Poco::UInt16 i = 0; extract(pos, i); val = i; return true; }
|
{ Poco::UInt16 i = 0; extract(pos, i); val = i; return true; }
|
||||||
|
|
||||||
case MetaColumn::FDT_INT32:
|
case MetaColumn::FDT_INT32:
|
||||||
{ Poco::Int32 i = 0; extract(pos, i); val = i; return true; }
|
{ Poco::Int32 i = 0; extract(pos, i); val = i; return true; }
|
||||||
|
|
||||||
case MetaColumn::FDT_UINT32:
|
case MetaColumn::FDT_UINT32:
|
||||||
{ Poco::UInt32 i = 0; extract(pos, i); val = i; return true; }
|
{ Poco::UInt32 i = 0; extract(pos, i); val = i; return true; }
|
||||||
|
|
||||||
case MetaColumn::FDT_INT64:
|
case MetaColumn::FDT_INT64:
|
||||||
{ Poco::Int64 i = 0; extract(pos, i); val = i; return true; }
|
{ Poco::Int64 i = 0; extract(pos, i); val = i; return true; }
|
||||||
|
|
||||||
case MetaColumn::FDT_UINT64:
|
case MetaColumn::FDT_UINT64:
|
||||||
{ Poco::UInt64 i = 0; extract(pos, i); val = i; return true; }
|
{ Poco::UInt64 i = 0; extract(pos, i); val = i; return true; }
|
||||||
|
|
||||||
case MetaColumn::FDT_BOOL:
|
case MetaColumn::FDT_BOOL:
|
||||||
{ bool b; extract(pos, b); val = b; return true; }
|
{ bool b; extract(pos, b); val = b; return true; }
|
||||||
|
|
||||||
case MetaColumn::FDT_FLOAT:
|
case MetaColumn::FDT_FLOAT:
|
||||||
{ float f; extract(pos, f); val = f; return true; }
|
{ float f; extract(pos, f); val = f; return true; }
|
||||||
|
|
||||||
case MetaColumn::FDT_DOUBLE:
|
case MetaColumn::FDT_DOUBLE:
|
||||||
{ double d; extract(pos, d); val = d; return true; }
|
{ double d; extract(pos, d); val = d; return true; }
|
||||||
|
|
||||||
case MetaColumn::FDT_STRING:
|
case MetaColumn::FDT_STRING:
|
||||||
{ std::string s; extract(pos, s); val = s; return true; }
|
{ std::string s; extract(pos, s); val = s; return true; }
|
||||||
|
|
||||||
case MetaColumn::FDT_BLOB:
|
case MetaColumn::FDT_BLOB:
|
||||||
{ Poco::Data::BLOB b; extract(pos, b); val = b; return true; }
|
{ Poco::Data::BLOB b; extract(pos, b); val = b; return true; }
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw DataFormatException("Unsupported data type.");
|
throw DataFormatException("Unsupported data type.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Extractor::checkDataSize(std::size_t size)
|
void Extractor::checkDataSize(std::size_t size)
|
||||||
{
|
{
|
||||||
std::size_t maxSize = _rPreparation.getMaxFieldSize();
|
std::size_t maxSize = _rPreparation.getMaxFieldSize();
|
||||||
if (size > maxSize)
|
if (size > maxSize)
|
||||||
{
|
{
|
||||||
throw DataException(format(FLD_SIZE_EXCEEDED_FMT,
|
throw DataException(format(FLD_SIZE_EXCEEDED_FMT,
|
||||||
size,
|
size,
|
||||||
maxSize));
|
maxSize));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::ODBC
|
} } } // namespace Poco::Data::ODBC
|
||||||
|
|||||||
@@ -1,145 +1,145 @@
|
|||||||
//
|
//
|
||||||
// ODBCColumn.cpp
|
// ODBCColumn.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/ODBC/src/ODBCColumn.cpp#5 $
|
// $Id: //poco/1.3/Data/ODBC/src/ODBCColumn.cpp#6 $
|
||||||
//
|
//
|
||||||
// Library: ODBC
|
// Library: ODBC
|
||||||
// Package: ODBC
|
// Package: ODBC
|
||||||
// Module: ODBCColumn
|
// Module: ODBCColumn
|
||||||
//
|
//
|
||||||
// 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/ODBC/ODBCColumn.h"
|
#include "Poco/Data/ODBC/ODBCColumn.h"
|
||||||
#include "Poco/Data/ODBC/Utility.h"
|
#include "Poco/Data/ODBC/Utility.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace ODBC {
|
namespace ODBC {
|
||||||
|
|
||||||
|
|
||||||
ODBCColumn::ODBCColumn(const StatementHandle& rStmt, std::size_t position) :
|
ODBCColumn::ODBCColumn(const StatementHandle& rStmt, std::size_t position) :
|
||||||
MetaColumn(position),
|
MetaColumn(position),
|
||||||
_rStmt(rStmt)
|
_rStmt(rStmt)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ODBCColumn::~ODBCColumn()
|
ODBCColumn::~ODBCColumn()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ODBCColumn::getDescription()
|
void ODBCColumn::getDescription()
|
||||||
{
|
{
|
||||||
memset(_columnDesc.name, 0, NAME_BUFFER_LENGTH);
|
memset(_columnDesc.name, 0, NAME_BUFFER_LENGTH);
|
||||||
_columnDesc.nameBufferLength = 0;
|
_columnDesc.nameBufferLength = 0;
|
||||||
_columnDesc.dataType = 0;
|
_columnDesc.dataType = 0;
|
||||||
_columnDesc.size = 0;
|
_columnDesc.size = 0;
|
||||||
_columnDesc.decimalDigits = 0;
|
_columnDesc.decimalDigits = 0;
|
||||||
_columnDesc.isNullable = 0;
|
_columnDesc.isNullable = 0;
|
||||||
|
|
||||||
if (Utility::isError(SQLDescribeCol(_rStmt,
|
if (Utility::isError(SQLDescribeCol(_rStmt,
|
||||||
(SQLUSMALLINT) position() + 1, // ODBC columns are 1-based
|
(SQLUSMALLINT) position() + 1, // ODBC columns are 1-based
|
||||||
_columnDesc.name,
|
_columnDesc.name,
|
||||||
NAME_BUFFER_LENGTH,
|
NAME_BUFFER_LENGTH,
|
||||||
&_columnDesc.nameBufferLength,
|
&_columnDesc.nameBufferLength,
|
||||||
&_columnDesc.dataType,
|
&_columnDesc.dataType,
|
||||||
&_columnDesc.size,
|
&_columnDesc.size,
|
||||||
&_columnDesc.decimalDigits,
|
&_columnDesc.decimalDigits,
|
||||||
&_columnDesc.isNullable)))
|
&_columnDesc.isNullable)))
|
||||||
{
|
{
|
||||||
throw StatementException(_rStmt);
|
throw StatementException(_rStmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void ODBCColumn::init()
|
void ODBCColumn::init()
|
||||||
{
|
{
|
||||||
getDescription();
|
getDescription();
|
||||||
|
|
||||||
if (Utility::isError(SQLColAttribute(_rStmt,
|
if (Utility::isError(SQLColAttribute(_rStmt,
|
||||||
(SQLUSMALLINT) position() + 1, // ODBC columns are 1-based
|
(SQLUSMALLINT) position() + 1, // ODBC columns are 1-based
|
||||||
SQL_DESC_LENGTH,
|
SQL_DESC_LENGTH,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
0,
|
0,
|
||||||
&_dataLength)))
|
&_dataLength)))
|
||||||
{
|
{
|
||||||
throw StatementException(_rStmt);
|
throw StatementException(_rStmt);
|
||||||
}
|
}
|
||||||
|
|
||||||
setName(std::string((char*) _columnDesc.name));
|
setName(std::string((char*) _columnDesc.name));
|
||||||
setLength(_columnDesc.size);
|
setLength(_columnDesc.size);
|
||||||
setPrecision(_columnDesc.decimalDigits);
|
setPrecision(_columnDesc.decimalDigits);
|
||||||
setNullable(SQL_NULLABLE == _columnDesc.isNullable);
|
setNullable(SQL_NULLABLE == _columnDesc.isNullable);
|
||||||
switch(_columnDesc.dataType)
|
switch(_columnDesc.dataType)
|
||||||
{
|
{
|
||||||
case SQL_CHAR:
|
case SQL_CHAR:
|
||||||
case SQL_VARCHAR:
|
case SQL_VARCHAR:
|
||||||
case SQL_LONGVARCHAR:
|
case SQL_LONGVARCHAR:
|
||||||
case -9:// SQL Server NVARCHAR
|
case -9:// SQL Server NVARCHAR
|
||||||
case -10:// PostgreSQL VARCHAR (without size specified)
|
case -10:// PostgreSQL VARCHAR (without size specified)
|
||||||
setType(MetaColumn::FDT_STRING); break;
|
setType(MetaColumn::FDT_STRING); break;
|
||||||
case SQL_TINYINT:
|
case SQL_TINYINT:
|
||||||
setType(MetaColumn::FDT_INT8); break;
|
setType(MetaColumn::FDT_INT8); break;
|
||||||
case SQL_SMALLINT:
|
case SQL_SMALLINT:
|
||||||
setType(MetaColumn::FDT_INT16); break;
|
setType(MetaColumn::FDT_INT16); break;
|
||||||
case SQL_INTEGER:
|
case SQL_INTEGER:
|
||||||
setType(MetaColumn::FDT_INT32); break;
|
setType(MetaColumn::FDT_INT32); break;
|
||||||
case SQL_BIGINT:
|
case SQL_BIGINT:
|
||||||
setType(MetaColumn::FDT_INT64); break;
|
setType(MetaColumn::FDT_INT64); break;
|
||||||
|
|
||||||
case SQL_DOUBLE:
|
case SQL_DOUBLE:
|
||||||
case SQL_FLOAT:
|
case SQL_FLOAT:
|
||||||
setType(MetaColumn::FDT_DOUBLE); break;
|
setType(MetaColumn::FDT_DOUBLE); break;
|
||||||
|
|
||||||
case SQL_NUMERIC:
|
case SQL_NUMERIC:
|
||||||
case SQL_DECIMAL:
|
case SQL_DECIMAL:
|
||||||
if (0 == _columnDesc.decimalDigits)
|
if (0 == _columnDesc.decimalDigits)
|
||||||
setType(MetaColumn::FDT_INT32);
|
setType(MetaColumn::FDT_INT32);
|
||||||
else
|
else
|
||||||
setType(MetaColumn::FDT_DOUBLE);
|
setType(MetaColumn::FDT_DOUBLE);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SQL_REAL:
|
case SQL_REAL:
|
||||||
setType(MetaColumn::FDT_FLOAT); break;
|
setType(MetaColumn::FDT_FLOAT); break;
|
||||||
case SQL_BINARY:
|
case SQL_BINARY:
|
||||||
case SQL_VARBINARY:
|
case SQL_VARBINARY:
|
||||||
case SQL_LONGVARBINARY:
|
case SQL_LONGVARBINARY:
|
||||||
case -98:// IBM DB2 non-standard type
|
case -98:// IBM DB2 non-standard type
|
||||||
setType(MetaColumn::FDT_BLOB); break;
|
setType(MetaColumn::FDT_BLOB); break;
|
||||||
default:
|
default:
|
||||||
throw DataFormatException("Unsupported data type.");
|
throw DataFormatException("Unsupported data type.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::ODBC
|
} } } // namespace Poco::Data::ODBC
|
||||||
|
|||||||
@@ -1,75 +1,75 @@
|
|||||||
//
|
//
|
||||||
// Parameter.cpp
|
// Parameter.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/ODBC/src/Parameter.cpp#3 $
|
// $Id: //poco/1.3/Data/ODBC/src/Parameter.cpp#4 $
|
||||||
//
|
//
|
||||||
// Library: ODBC
|
// Library: ODBC
|
||||||
// Package: ODBC
|
// Package: ODBC
|
||||||
// Module: Parameter
|
// Module: Parameter
|
||||||
//
|
//
|
||||||
// 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/ODBC/Parameter.h"
|
#include "Poco/Data/ODBC/Parameter.h"
|
||||||
#include "Poco/Data/ODBC/Utility.h"
|
#include "Poco/Data/ODBC/Utility.h"
|
||||||
#include "Poco/Data/ODBC/Error.h"
|
#include "Poco/Data/ODBC/Error.h"
|
||||||
#include "Poco/Data/ODBC/ODBCException.h"
|
#include "Poco/Data/ODBC/ODBCException.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace ODBC {
|
namespace ODBC {
|
||||||
|
|
||||||
|
|
||||||
Parameter::Parameter(const StatementHandle& rStmt, std::size_t colNum) :
|
Parameter::Parameter(const StatementHandle& rStmt, std::size_t colNum) :
|
||||||
_rStmt(rStmt),
|
_rStmt(rStmt),
|
||||||
_number(colNum)
|
_number(colNum)
|
||||||
{
|
{
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Parameter::~Parameter()
|
Parameter::~Parameter()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Parameter::init()
|
void Parameter::init()
|
||||||
{
|
{
|
||||||
if (Utility::isError(SQLDescribeParam(_rStmt,
|
if (Utility::isError(SQLDescribeParam(_rStmt,
|
||||||
(SQLUSMALLINT) _number + 1,
|
(SQLUSMALLINT) _number + 1,
|
||||||
&_dataType,
|
&_dataType,
|
||||||
&_columnSize,
|
&_columnSize,
|
||||||
&_decimalDigits,
|
&_decimalDigits,
|
||||||
&_isNullable)))
|
&_isNullable)))
|
||||||
{
|
{
|
||||||
throw StatementException(_rStmt);
|
throw StatementException(_rStmt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::ODBC
|
} } } // namespace Poco::Data::ODBC
|
||||||
|
|||||||
307
Data/ODBC/testsuite/TestSuite_vs90.vcproj
Normal file
307
Data/ODBC/testsuite/TestSuite_vs90.vcproj
Normal file
@@ -0,0 +1,307 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.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="false"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="CppUnitd.lib WinTestRunnerd.lib PocoFoundationd.lib PocoODBCd.lib PocoDatad.lib odbc32.lib odbccp32.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="false"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="CppUnit.lib WinTestRunner.lib PocoFoundation.lib PocoODBC.lib PocoData.lib odbc32.lib odbccp32.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="ODBC"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCAccessTest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCDB2Test.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCMySQLTest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCOracleTest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCPostgreSQLTest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCSQLiteTest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCSQLServerTest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SQLExecutor.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCAccessTest.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCDB2Test.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCMySQLTest.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCOracleTest.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCPostgreSQLTest.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCSQLiteTest.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCSQLServerTest.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SQLExecutor.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="_Suite"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCTestSuite.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\ODBCTestSuite.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="_Driver"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\WinDriver.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
28
Data/SQLite/SQLite_vs90.sln
Normal file
28
Data/SQLite/SQLite_vs90.sln
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
|
# Visual Studio 2008
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SQLite", "SQLite_vs90.vcproj", "{1B29820D-375F-11DB-837B-00123FC423B5}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs90.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
|
||||||
301
Data/SQLite/SQLite_vs90.vcproj
Normal file
301
Data/SQLite/SQLite_vs90.vcproj
Normal file
@@ -0,0 +1,301 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.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="0"
|
||||||
|
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="0"
|
||||||
|
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\Connector.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\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\Connector.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Extractor.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SessionImpl.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>
|
||||||
@@ -1,82 +1,82 @@
|
|||||||
//
|
//
|
||||||
// SQLiteException.h
|
// SQLiteException.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/SQLite/include/Poco/Data/SQLite/SQLiteException.h#3 $
|
// $Id: //poco/1.3/Data/SQLite/include/Poco/Data/SQLite/SQLiteException.h#4 $
|
||||||
//
|
//
|
||||||
// Library: SQLite
|
// Library: SQLite
|
||||||
// Package: SQLite
|
// Package: SQLite
|
||||||
// Module: SQLiteException
|
// Module: SQLiteException
|
||||||
//
|
//
|
||||||
// Definition of SQLiteException.
|
// Definition of SQLiteException.
|
||||||
//
|
//
|
||||||
// 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef SQLite_SQLiteException_INCLUDED
|
#ifndef SQLite_SQLiteException_INCLUDED
|
||||||
#define SQLite_SQLiteException_INCLUDED
|
#define SQLite_SQLiteException_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Data/SQLite/SQLite.h"
|
#include "Poco/Data/SQLite/SQLite.h"
|
||||||
#include "Poco/Data/DataException.h"
|
#include "Poco/Data/DataException.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace SQLite {
|
namespace SQLite {
|
||||||
|
|
||||||
|
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, SQLiteException, Poco::Data::DataException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, SQLiteException, Poco::Data::DataException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, InvalidSQLStatementException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, InvalidSQLStatementException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, InternalDBErrorException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, InternalDBErrorException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, DBAccessDeniedException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, DBAccessDeniedException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, ExecutionAbortedException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, ExecutionAbortedException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, DBLockedException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, DBLockedException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, TableLockedException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, TableLockedException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, NoMemoryException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, NoMemoryException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, ReadOnlyException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, ReadOnlyException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, InterruptException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, InterruptException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, IOErrorException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, IOErrorException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, CorruptImageException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, CorruptImageException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, TableNotFoundException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, TableNotFoundException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, DatabaseFullException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, DatabaseFullException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, CantOpenDBFileException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, CantOpenDBFileException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, LockProtocolException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, LockProtocolException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, SchemaDiffersException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, SchemaDiffersException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, RowTooBigException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, RowTooBigException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, ConstraintViolationException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, ConstraintViolationException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, DataTypeMismatchException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, DataTypeMismatchException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, ParameterCountMismatchException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, ParameterCountMismatchException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, InvalidLibraryUseException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, InvalidLibraryUseException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, OSFeaturesMissingException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, OSFeaturesMissingException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, AuthorizationDeniedException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, AuthorizationDeniedException, SQLiteException)
|
||||||
POCO_DECLARE_EXCEPTION(SQLite_API, TransactionException, SQLiteException)
|
POCO_DECLARE_EXCEPTION(SQLite_API, TransactionException, SQLiteException)
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::SQLite
|
} } } // namespace Poco::Data::SQLite
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,73 +1,73 @@
|
|||||||
//
|
//
|
||||||
// SQLiteException.cpp
|
// SQLiteException.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/SQLite/src/SQLiteException.cpp#3 $
|
// $Id: //poco/1.3/Data/SQLite/src/SQLiteException.cpp#4 $
|
||||||
//
|
//
|
||||||
// Library: SQLite
|
// Library: SQLite
|
||||||
// Package: SQLite
|
// Package: SQLite
|
||||||
// Module: SQLiteException
|
// Module: SQLiteException
|
||||||
//
|
//
|
||||||
// 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/SQLiteException.h"
|
#include "Poco/Data/SQLite/SQLiteException.h"
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace SQLite {
|
namespace SQLite {
|
||||||
|
|
||||||
|
|
||||||
POCO_IMPLEMENT_EXCEPTION(SQLiteException, Poco::Data::DataException, "Generic SQLite error")
|
POCO_IMPLEMENT_EXCEPTION(SQLiteException, Poco::Data::DataException, "Generic SQLite error")
|
||||||
POCO_IMPLEMENT_EXCEPTION(InvalidSQLStatementException, SQLiteException, "SQL Statement invalid")
|
POCO_IMPLEMENT_EXCEPTION(InvalidSQLStatementException, SQLiteException, "SQL Statement invalid")
|
||||||
POCO_IMPLEMENT_EXCEPTION(InternalDBErrorException, SQLiteException, "Internal error")
|
POCO_IMPLEMENT_EXCEPTION(InternalDBErrorException, SQLiteException, "Internal error")
|
||||||
POCO_IMPLEMENT_EXCEPTION(DBAccessDeniedException, SQLiteException, "Access permission denied")
|
POCO_IMPLEMENT_EXCEPTION(DBAccessDeniedException, SQLiteException, "Access permission denied")
|
||||||
POCO_IMPLEMENT_EXCEPTION(ExecutionAbortedException, SQLiteException, "Execution of SQL statement aborted")
|
POCO_IMPLEMENT_EXCEPTION(ExecutionAbortedException, SQLiteException, "Execution of SQL statement aborted")
|
||||||
POCO_IMPLEMENT_EXCEPTION(DBLockedException, SQLiteException, "The database is locked")
|
POCO_IMPLEMENT_EXCEPTION(DBLockedException, SQLiteException, "The database is locked")
|
||||||
POCO_IMPLEMENT_EXCEPTION(TableLockedException, SQLiteException, "A table in 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(NoMemoryException, SQLiteException, "Out of Memory")
|
||||||
POCO_IMPLEMENT_EXCEPTION(ReadOnlyException, SQLiteException, "Attempt to write a readonly database")
|
POCO_IMPLEMENT_EXCEPTION(ReadOnlyException, SQLiteException, "Attempt to write a readonly database")
|
||||||
POCO_IMPLEMENT_EXCEPTION(InterruptException, SQLiteException, "Operation terminated by an interrupt")
|
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(IOErrorException, SQLiteException, "Some kind of disk I/O error occurred")
|
||||||
POCO_IMPLEMENT_EXCEPTION(CorruptImageException, SQLiteException, "The database disk image is malformed")
|
POCO_IMPLEMENT_EXCEPTION(CorruptImageException, SQLiteException, "The database disk image is malformed")
|
||||||
POCO_IMPLEMENT_EXCEPTION(TableNotFoundException, SQLiteException, "Table not found")
|
POCO_IMPLEMENT_EXCEPTION(TableNotFoundException, SQLiteException, "Table not found")
|
||||||
POCO_IMPLEMENT_EXCEPTION(DatabaseFullException, SQLiteException, "Insertion failed because database is full")
|
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(CantOpenDBFileException, SQLiteException, "Unable to open the database file")
|
||||||
POCO_IMPLEMENT_EXCEPTION(LockProtocolException, SQLiteException, "Database lock protocol error")
|
POCO_IMPLEMENT_EXCEPTION(LockProtocolException, SQLiteException, "Database lock protocol error")
|
||||||
POCO_IMPLEMENT_EXCEPTION(SchemaDiffersException, SQLiteException, "The database schema changed")
|
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(RowTooBigException, SQLiteException, "Too much data for one row of a table")
|
||||||
POCO_IMPLEMENT_EXCEPTION(ConstraintViolationException, SQLiteException, "Abort due to constraint violation")
|
POCO_IMPLEMENT_EXCEPTION(ConstraintViolationException, SQLiteException, "Abort due to constraint violation")
|
||||||
POCO_IMPLEMENT_EXCEPTION(DataTypeMismatchException, SQLiteException, "Data type mismatch")
|
POCO_IMPLEMENT_EXCEPTION(DataTypeMismatchException, SQLiteException, "Data type mismatch")
|
||||||
POCO_IMPLEMENT_EXCEPTION(ParameterCountMismatchException, SQLiteException, "Parameter count mismatch")
|
POCO_IMPLEMENT_EXCEPTION(ParameterCountMismatchException, SQLiteException, "Parameter count mismatch")
|
||||||
POCO_IMPLEMENT_EXCEPTION(InvalidLibraryUseException, SQLiteException, "Library used incorrectly")
|
POCO_IMPLEMENT_EXCEPTION(InvalidLibraryUseException, SQLiteException, "Library used incorrectly")
|
||||||
POCO_IMPLEMENT_EXCEPTION(OSFeaturesMissingException, SQLiteException, "Uses OS features not supported on host")
|
POCO_IMPLEMENT_EXCEPTION(OSFeaturesMissingException, SQLiteException, "Uses OS features not supported on host")
|
||||||
POCO_IMPLEMENT_EXCEPTION(AuthorizationDeniedException, SQLiteException, "Authorization denied")
|
POCO_IMPLEMENT_EXCEPTION(AuthorizationDeniedException, SQLiteException, "Authorization denied")
|
||||||
POCO_IMPLEMENT_EXCEPTION(TransactionException, SQLiteException, "Transaction exception")
|
POCO_IMPLEMENT_EXCEPTION(TransactionException, SQLiteException, "Transaction exception")
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::SQLite
|
} } } // namespace Poco::Data::SQLite
|
||||||
|
|||||||
@@ -1,244 +1,244 @@
|
|||||||
//
|
//
|
||||||
// SQLiteStatementImpl.cpp
|
// SQLiteStatementImpl.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/SQLite/src/SQLiteStatementImpl.cpp#4 $
|
// $Id: //poco/1.3/Data/SQLite/src/SQLiteStatementImpl.cpp#5 $
|
||||||
//
|
//
|
||||||
// Library: SQLite
|
// Library: SQLite
|
||||||
// Package: SQLite
|
// Package: SQLite
|
||||||
// Module: SQLiteStatementImpl
|
// Module: SQLiteStatementImpl
|
||||||
//
|
//
|
||||||
// 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/SQLiteStatementImpl.h"
|
#include "Poco/Data/SQLite/SQLiteStatementImpl.h"
|
||||||
#include "Poco/Data/SQLite/Utility.h"
|
#include "Poco/Data/SQLite/Utility.h"
|
||||||
#include "Poco/Data/SQLite/SQLiteException.h"
|
#include "Poco/Data/SQLite/SQLiteException.h"
|
||||||
#include "Poco/String.h"
|
#include "Poco/String.h"
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include "sqlite3.h"
|
#include "sqlite3.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
namespace SQLite {
|
namespace SQLite {
|
||||||
|
|
||||||
|
|
||||||
SQLiteStatementImpl::SQLiteStatementImpl(sqlite3* pDB):
|
SQLiteStatementImpl::SQLiteStatementImpl(sqlite3* pDB):
|
||||||
_pDB(pDB),
|
_pDB(pDB),
|
||||||
_pStmt(0),
|
_pStmt(0),
|
||||||
_stepCalled(false),
|
_stepCalled(false),
|
||||||
_nextResponse(0)
|
_nextResponse(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SQLiteStatementImpl::~SQLiteStatementImpl()
|
SQLiteStatementImpl::~SQLiteStatementImpl()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SQLiteStatementImpl::compileImpl()
|
void SQLiteStatementImpl::compileImpl()
|
||||||
{
|
{
|
||||||
if (_pStmt) return;
|
if (_pStmt) return;
|
||||||
|
|
||||||
std::string statement(toString());
|
std::string statement(toString());
|
||||||
if (statement.empty())
|
if (statement.empty())
|
||||||
throw InvalidSQLStatementException("Empty statements are illegal");
|
throw InvalidSQLStatementException("Empty statements are illegal");
|
||||||
|
|
||||||
sqlite3_stmt* pStmt = 0;
|
sqlite3_stmt* pStmt = 0;
|
||||||
const char* pSql = statement.c_str(); // The SQL to be executed
|
const char* pSql = statement.c_str(); // The SQL to be executed
|
||||||
int rc = SQLITE_OK;
|
int rc = SQLITE_OK;
|
||||||
const char* pLeftover = 0;
|
const char* pLeftover = 0;
|
||||||
bool queryFound = false;
|
bool queryFound = false;
|
||||||
|
|
||||||
while (rc == SQLITE_OK && !pStmt && !queryFound)
|
while (rc == SQLITE_OK && !pStmt && !queryFound)
|
||||||
{
|
{
|
||||||
rc = sqlite3_prepare_v2(_pDB, pSql, -1, &pStmt, &pLeftover);
|
rc = sqlite3_prepare_v2(_pDB, pSql, -1, &pStmt, &pLeftover);
|
||||||
if (rc != SQLITE_OK)
|
if (rc != SQLITE_OK)
|
||||||
{
|
{
|
||||||
if (pStmt)
|
if (pStmt)
|
||||||
{
|
{
|
||||||
sqlite3_finalize(pStmt);
|
sqlite3_finalize(pStmt);
|
||||||
}
|
}
|
||||||
pStmt = 0;
|
pStmt = 0;
|
||||||
std::string errMsg = sqlite3_errmsg(_pDB);
|
std::string errMsg = sqlite3_errmsg(_pDB);
|
||||||
Utility::throwException(rc, errMsg);
|
Utility::throwException(rc, errMsg);
|
||||||
}
|
}
|
||||||
else if (rc == SQLITE_OK && pStmt)
|
else if (rc == SQLITE_OK && pStmt)
|
||||||
{
|
{
|
||||||
queryFound = true;
|
queryFound = true;
|
||||||
}
|
}
|
||||||
else if(rc == SQLITE_OK && !pStmt) // comment/whitespace ignore
|
else if(rc == SQLITE_OK && !pStmt) // comment/whitespace ignore
|
||||||
{
|
{
|
||||||
pSql = pLeftover;
|
pSql = pLeftover;
|
||||||
if (std::strlen(pSql) == 0)
|
if (std::strlen(pSql) == 0)
|
||||||
{
|
{
|
||||||
// empty statement or an conditional statement! like CREATE IF NOT EXISTS
|
// empty statement or an conditional statement! like CREATE IF NOT EXISTS
|
||||||
// this is valid
|
// this is valid
|
||||||
queryFound = true;
|
queryFound = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
clear();
|
clear();
|
||||||
_pStmt = pStmt;
|
_pStmt = pStmt;
|
||||||
|
|
||||||
// prepare binding
|
// prepare binding
|
||||||
_pBinder = new Binder(_pStmt);
|
_pBinder = new Binder(_pStmt);
|
||||||
_pExtractor = new Extractor(_pStmt);
|
_pExtractor = new Extractor(_pStmt);
|
||||||
|
|
||||||
int colCount = sqlite3_column_count(_pStmt);
|
int colCount = sqlite3_column_count(_pStmt);
|
||||||
|
|
||||||
for (int i = 0; i < colCount; ++i)
|
for (int i = 0; i < colCount; ++i)
|
||||||
{
|
{
|
||||||
MetaColumn mc(i, sqlite3_column_name(_pStmt, i), Utility::getColumnType(_pStmt, i));
|
MetaColumn mc(i, sqlite3_column_name(_pStmt, i), Utility::getColumnType(_pStmt, i));
|
||||||
_columns.push_back(mc);
|
_columns.push_back(mc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SQLiteStatementImpl::canBind() const
|
bool SQLiteStatementImpl::canBind() const
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
if (!bindings().empty() && _pStmt)
|
if (!bindings().empty() && _pStmt)
|
||||||
ret = (*bindings().begin())->canBind();
|
ret = (*bindings().begin())->canBind();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SQLiteStatementImpl::bindImpl()
|
void SQLiteStatementImpl::bindImpl()
|
||||||
{
|
{
|
||||||
_stepCalled = false;
|
_stepCalled = false;
|
||||||
_nextResponse = 0;
|
_nextResponse = 0;
|
||||||
if (_pStmt == 0) return;
|
if (_pStmt == 0) return;
|
||||||
|
|
||||||
sqlite3_reset(_pStmt);
|
sqlite3_reset(_pStmt);
|
||||||
|
|
||||||
// bind
|
// bind
|
||||||
Bindings& binds = bindings();
|
Bindings& binds = bindings();
|
||||||
int pc = sqlite3_bind_parameter_count(_pStmt);
|
int pc = sqlite3_bind_parameter_count(_pStmt);
|
||||||
if (binds.empty() && 0 == pc) return;
|
if (binds.empty() && 0 == pc) return;
|
||||||
else if (binds.empty() && pc > 0)
|
else if (binds.empty() && pc > 0)
|
||||||
throw ParameterCountMismatchException();
|
throw ParameterCountMismatchException();
|
||||||
else if (!binds.empty() && binds.size() * (*binds.begin())->numOfColumnsHandled() != pc)
|
else if (!binds.empty() && binds.size() * (*binds.begin())->numOfColumnsHandled() != pc)
|
||||||
throw ParameterCountMismatchException();
|
throw ParameterCountMismatchException();
|
||||||
|
|
||||||
std::size_t pos = 1; // sqlite starts with 1 not 0!
|
std::size_t pos = 1; // sqlite starts with 1 not 0!
|
||||||
|
|
||||||
Bindings::iterator it = binds.begin();
|
Bindings::iterator it = binds.begin();
|
||||||
Bindings::iterator itEnd = binds.end();
|
Bindings::iterator itEnd = binds.end();
|
||||||
for (; it != itEnd && (*it)->canBind(); ++it)
|
for (; it != itEnd && (*it)->canBind(); ++it)
|
||||||
{
|
{
|
||||||
(*it)->bind(pos);
|
(*it)->bind(pos);
|
||||||
pos += (*it)->numOfColumnsHandled();
|
pos += (*it)->numOfColumnsHandled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SQLiteStatementImpl::clear()
|
void SQLiteStatementImpl::clear()
|
||||||
{
|
{
|
||||||
_columns.clear();
|
_columns.clear();
|
||||||
|
|
||||||
if (_pStmt)
|
if (_pStmt)
|
||||||
{
|
{
|
||||||
sqlite3_finalize(_pStmt);
|
sqlite3_finalize(_pStmt);
|
||||||
_pStmt=0;
|
_pStmt=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool SQLiteStatementImpl::hasNext()
|
bool SQLiteStatementImpl::hasNext()
|
||||||
{
|
{
|
||||||
if (_stepCalled)
|
if (_stepCalled)
|
||||||
return (_nextResponse == SQLITE_ROW);
|
return (_nextResponse == SQLITE_ROW);
|
||||||
|
|
||||||
// _pStmt is allowed to be null for conditional SQL statements
|
// _pStmt is allowed to be null for conditional SQL statements
|
||||||
if (_pStmt == 0)
|
if (_pStmt == 0)
|
||||||
{
|
{
|
||||||
_stepCalled = true;
|
_stepCalled = true;
|
||||||
_nextResponse = SQLITE_DONE;
|
_nextResponse = SQLITE_DONE;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_stepCalled = true;
|
_stepCalled = true;
|
||||||
_nextResponse = sqlite3_step(_pStmt);
|
_nextResponse = sqlite3_step(_pStmt);
|
||||||
|
|
||||||
if (_nextResponse != SQLITE_ROW && _nextResponse != SQLITE_OK && _nextResponse != SQLITE_DONE)
|
if (_nextResponse != SQLITE_ROW && _nextResponse != SQLITE_OK && _nextResponse != SQLITE_DONE)
|
||||||
{
|
{
|
||||||
Utility::throwException(_nextResponse);
|
Utility::throwException(_nextResponse);
|
||||||
}
|
}
|
||||||
|
|
||||||
return (_nextResponse == SQLITE_ROW);
|
return (_nextResponse == SQLITE_ROW);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SQLiteStatementImpl::next()
|
void SQLiteStatementImpl::next()
|
||||||
{
|
{
|
||||||
if (SQLITE_ROW == _nextResponse)
|
if (SQLITE_ROW == _nextResponse)
|
||||||
{
|
{
|
||||||
poco_assert (columnsReturned() == sqlite3_column_count(_pStmt));
|
poco_assert (columnsReturned() == sqlite3_column_count(_pStmt));
|
||||||
|
|
||||||
Extractions& extracts = extractions();
|
Extractions& extracts = extractions();
|
||||||
Extractions::iterator it = extracts.begin();
|
Extractions::iterator it = extracts.begin();
|
||||||
Extractions::iterator itEnd = extracts.end();
|
Extractions::iterator itEnd = extracts.end();
|
||||||
std::size_t pos = 0; // sqlite starts with pos 0 for results!
|
std::size_t pos = 0; // sqlite starts with pos 0 for results!
|
||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
(*it)->extract(pos);
|
(*it)->extract(pos);
|
||||||
pos += (*it)->numOfColumnsHandled();
|
pos += (*it)->numOfColumnsHandled();
|
||||||
}
|
}
|
||||||
_stepCalled = false;
|
_stepCalled = false;
|
||||||
}
|
}
|
||||||
else if (SQLITE_DONE == _nextResponse)
|
else if (SQLITE_DONE == _nextResponse)
|
||||||
{
|
{
|
||||||
throw Poco::Data::DataException("No data received");
|
throw Poco::Data::DataException("No data received");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int rc = _nextResponse;
|
int rc = _nextResponse;
|
||||||
Utility::throwException(rc, std::string("Iterator Error: trying to access the next value"));
|
Utility::throwException(rc, std::string("Iterator Error: trying to access the next value"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Poco::UInt32 SQLiteStatementImpl::columnsReturned() const
|
Poco::UInt32 SQLiteStatementImpl::columnsReturned() const
|
||||||
{
|
{
|
||||||
return (Poco::UInt32) _columns.size();
|
return (Poco::UInt32) _columns.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const MetaColumn& SQLiteStatementImpl::metaColumn(Poco::UInt32 pos) const
|
const MetaColumn& SQLiteStatementImpl::metaColumn(Poco::UInt32 pos) const
|
||||||
{
|
{
|
||||||
poco_assert (pos >= 0 && pos <= _columns.size());
|
poco_assert (pos >= 0 && pos <= _columns.size());
|
||||||
return _columns[pos];
|
return _columns[pos];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } } // namespace Poco::Data::SQLite
|
} } } // namespace Poco::Data::SQLite
|
||||||
|
|||||||
251
Data/SQLite/testsuite/TestSuite_vs90.vcproj
Normal file
251
Data/SQLite/testsuite/TestSuite_vs90.vcproj
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.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="false"
|
||||||
|
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="false"
|
||||||
|
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>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,121 +1,121 @@
|
|||||||
//
|
//
|
||||||
// SQLiteTest.h
|
// SQLiteTest.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/SQLite/testsuite/src/SQLiteTest.h#4 $
|
// $Id: //poco/1.3/Data/SQLite/testsuite/src/SQLiteTest.h#5 $
|
||||||
//
|
//
|
||||||
// Definition of the SQLiteTest class.
|
// Definition of the SQLiteTest class.
|
||||||
//
|
//
|
||||||
// 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef SQLiteTest_INCLUDED
|
#ifndef SQLiteTest_INCLUDED
|
||||||
#define SQLiteTest_INCLUDED
|
#define SQLiteTest_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Data/SQLite/SQLite.h"
|
#include "Poco/Data/SQLite/SQLite.h"
|
||||||
#include "CppUnit/TestCase.h"
|
#include "CppUnit/TestCase.h"
|
||||||
|
|
||||||
|
|
||||||
class SQLiteTest: public CppUnit::TestCase
|
class SQLiteTest: public CppUnit::TestCase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
SQLiteTest(const std::string& name);
|
SQLiteTest(const std::string& name);
|
||||||
~SQLiteTest();
|
~SQLiteTest();
|
||||||
|
|
||||||
void testSimpleAccess();
|
void testSimpleAccess();
|
||||||
void testComplexType();
|
void testComplexType();
|
||||||
void testSimpleAccessVector();
|
void testSimpleAccessVector();
|
||||||
void testComplexTypeVector();
|
void testComplexTypeVector();
|
||||||
void testInsertVector();
|
void testInsertVector();
|
||||||
void testInsertEmptyVector();
|
void testInsertEmptyVector();
|
||||||
|
|
||||||
void testInsertSingleBulk();
|
void testInsertSingleBulk();
|
||||||
void testInsertSingleBulkVec();
|
void testInsertSingleBulkVec();
|
||||||
|
|
||||||
void testLimit();
|
void testLimit();
|
||||||
void testLimitOnce();
|
void testLimitOnce();
|
||||||
void testLimitPrepare();
|
void testLimitPrepare();
|
||||||
void testLimitZero();
|
void testLimitZero();
|
||||||
void testPrepare();
|
void testPrepare();
|
||||||
|
|
||||||
void testSetSimple();
|
void testSetSimple();
|
||||||
void testSetComplex();
|
void testSetComplex();
|
||||||
void testSetComplexUnique();
|
void testSetComplexUnique();
|
||||||
void testMultiSetSimple();
|
void testMultiSetSimple();
|
||||||
void testMultiSetComplex();
|
void testMultiSetComplex();
|
||||||
void testMapComplex();
|
void testMapComplex();
|
||||||
void testMapComplexUnique();
|
void testMapComplexUnique();
|
||||||
void testMultiMapComplex();
|
void testMultiMapComplex();
|
||||||
void testSelectIntoSingle();
|
void testSelectIntoSingle();
|
||||||
void testSelectIntoSingleStep();
|
void testSelectIntoSingleStep();
|
||||||
void testSelectIntoSingleFail();
|
void testSelectIntoSingleFail();
|
||||||
void testLowerLimitOk();
|
void testLowerLimitOk();
|
||||||
void testLowerLimitFail();
|
void testLowerLimitFail();
|
||||||
void testCombinedLimits();
|
void testCombinedLimits();
|
||||||
void testCombinedIllegalLimits();
|
void testCombinedIllegalLimits();
|
||||||
void testRange();
|
void testRange();
|
||||||
void testIllegalRange();
|
void testIllegalRange();
|
||||||
void testSingleSelect();
|
void testSingleSelect();
|
||||||
void testEmptyDB();
|
void testEmptyDB();
|
||||||
|
|
||||||
void testBLOB();
|
void testBLOB();
|
||||||
void testBLOBStmt();
|
void testBLOBStmt();
|
||||||
|
|
||||||
void testTuple1();
|
void testTuple1();
|
||||||
void testTupleVector1();
|
void testTupleVector1();
|
||||||
void testTuple2();
|
void testTuple2();
|
||||||
void testTupleVector2();
|
void testTupleVector2();
|
||||||
void testTuple3();
|
void testTuple3();
|
||||||
void testTupleVector3();
|
void testTupleVector3();
|
||||||
void testTuple4();
|
void testTuple4();
|
||||||
void testTupleVector4();
|
void testTupleVector4();
|
||||||
void testTuple5();
|
void testTuple5();
|
||||||
void testTupleVector5();
|
void testTupleVector5();
|
||||||
void testTuple6();
|
void testTuple6();
|
||||||
void testTupleVector6();
|
void testTupleVector6();
|
||||||
void testTuple7();
|
void testTuple7();
|
||||||
void testTupleVector7();
|
void testTupleVector7();
|
||||||
void testTuple8();
|
void testTuple8();
|
||||||
void testTupleVector8();
|
void testTupleVector8();
|
||||||
void testTuple9();
|
void testTuple9();
|
||||||
void testTupleVector9();
|
void testTupleVector9();
|
||||||
void testTuple10();
|
void testTuple10();
|
||||||
void testTupleVector10();
|
void testTupleVector10();
|
||||||
|
|
||||||
void testInternalExtraction();
|
void testInternalExtraction();
|
||||||
void testBindingCount();
|
void testBindingCount();
|
||||||
|
|
||||||
void setUp();
|
void setUp();
|
||||||
void tearDown();
|
void tearDown();
|
||||||
|
|
||||||
static CppUnit::Test* suite();
|
static CppUnit::Test* suite();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif // SQLiteTest_INCLUDED
|
#endif // SQLiteTest_INCLUDED
|
||||||
|
|||||||
@@ -1,314 +1,314 @@
|
|||||||
//
|
//
|
||||||
// BLOB.h
|
// BLOB.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/include/Poco/Data/BLOB.h#5 $
|
// $Id: //poco/1.3/Data/include/Poco/Data/BLOB.h#6 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: DataCore
|
// Package: DataCore
|
||||||
// Module: BLOB
|
// Module: BLOB
|
||||||
//
|
//
|
||||||
// Definition of the BLOB class.
|
// Definition of the BLOB class.
|
||||||
//
|
//
|
||||||
// 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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Data_BLOB_INCLUDED
|
#ifndef Data_BLOB_INCLUDED
|
||||||
#define Data_BLOB_INCLUDED
|
#define Data_BLOB_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Data/Data.h"
|
#include "Poco/Data/Data.h"
|
||||||
#include "Poco/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include "Poco/DynamicAnyHolder.h"
|
#include "Poco/DynamicAnyHolder.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
|
|
||||||
class Data_API BLOB
|
class Data_API BLOB
|
||||||
/// Representation of a Binary Large OBject.
|
/// Representation of a Binary Large OBject.
|
||||||
///
|
///
|
||||||
/// A BLOB can hold arbitrary binary data.
|
/// A BLOB can hold arbitrary binary data.
|
||||||
/// The maximum size depends on the underlying database.
|
/// The maximum size depends on the underlying database.
|
||||||
///
|
///
|
||||||
/// The BLOBInputStream and BLOBOutputStream classes provide
|
/// The BLOBInputStream and BLOBOutputStream classes provide
|
||||||
/// a convenient way to access the data in a BLOB.
|
/// a convenient way to access the data in a BLOB.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::vector<char>::const_iterator Iterator;
|
typedef std::vector<char>::const_iterator Iterator;
|
||||||
|
|
||||||
BLOB();
|
BLOB();
|
||||||
/// Creates an empty BLOB.
|
/// Creates an empty BLOB.
|
||||||
|
|
||||||
BLOB(const std::vector<char>& content);
|
BLOB(const std::vector<char>& content);
|
||||||
/// Creates the BLOB, content is deep-copied.
|
/// Creates the BLOB, content is deep-copied.
|
||||||
|
|
||||||
BLOB(const char* const pContent, std::size_t size);
|
BLOB(const char* const pContent, std::size_t size);
|
||||||
/// Creates the BLOB by deep-copying pContent.
|
/// Creates the BLOB by deep-copying pContent.
|
||||||
|
|
||||||
BLOB(const std::string& content);
|
BLOB(const std::string& content);
|
||||||
/// Creates a BLOB from a string.
|
/// Creates a BLOB from a string.
|
||||||
|
|
||||||
BLOB(const BLOB& other);
|
BLOB(const BLOB& other);
|
||||||
/// Creates a BLOB by copying another one.
|
/// Creates a BLOB by copying another one.
|
||||||
|
|
||||||
~BLOB();
|
~BLOB();
|
||||||
/// Destroys the BLOB.
|
/// Destroys the BLOB.
|
||||||
|
|
||||||
BLOB& operator = (const BLOB& other);
|
BLOB& operator = (const BLOB& other);
|
||||||
/// Assignment operator.
|
/// Assignment operator.
|
||||||
|
|
||||||
bool operator == (const BLOB& other) const;
|
bool operator == (const BLOB& other) const;
|
||||||
/// Compares for equality BLOB by value.
|
/// Compares for equality BLOB by value.
|
||||||
|
|
||||||
bool operator != (const BLOB& other) const;
|
bool operator != (const BLOB& other) const;
|
||||||
/// Compares for inequality BLOB by value.
|
/// Compares for inequality BLOB by value.
|
||||||
|
|
||||||
void swap(BLOB& other);
|
void swap(BLOB& other);
|
||||||
/// Swaps the BLOB with another one.
|
/// Swaps the BLOB with another one.
|
||||||
|
|
||||||
const std::vector<char>& content() const;
|
const std::vector<char>& content() const;
|
||||||
/// Returns the content.
|
/// Returns the content.
|
||||||
|
|
||||||
const char* rawContent() const;
|
const char* rawContent() const;
|
||||||
/// Returns the raw content.
|
/// Returns the raw content.
|
||||||
|
|
||||||
void assignRaw(const char* pChar, std::size_t count);
|
void assignRaw(const char* pChar, std::size_t count);
|
||||||
/// Assigns raw content to internal storage.
|
/// Assigns raw content to internal storage.
|
||||||
|
|
||||||
void appendRaw(const char* pChar, std::size_t count);
|
void appendRaw(const char* pChar, std::size_t count);
|
||||||
/// Assigns raw content to internal storage.
|
/// Assigns raw content to internal storage.
|
||||||
|
|
||||||
void clear(bool doCompact = false);
|
void clear(bool doCompact = false);
|
||||||
/// Clears the content of the blob.
|
/// Clears the content of the blob.
|
||||||
/// If doCompact is true, trims the excess capacity.
|
/// If doCompact is true, trims the excess capacity.
|
||||||
|
|
||||||
void compact();
|
void compact();
|
||||||
/// Trims the internal storage excess capacity.
|
/// Trims the internal storage excess capacity.
|
||||||
|
|
||||||
Iterator begin() const;
|
Iterator begin() const;
|
||||||
Iterator end() const;
|
Iterator end() const;
|
||||||
|
|
||||||
std::size_t size() const;
|
std::size_t size() const;
|
||||||
/// Returns the size of the BLOB in bytes.
|
/// Returns the size of the BLOB in bytes.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Poco::SharedPtr<std::vector<char> > _pContent;
|
Poco::SharedPtr<std::vector<char> > _pContent;
|
||||||
|
|
||||||
friend class BLOBStreamBuf;
|
friend class BLOBStreamBuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline const std::vector<char>& BLOB::content() const
|
inline const std::vector<char>& BLOB::content() const
|
||||||
{
|
{
|
||||||
return *_pContent;
|
return *_pContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const char* BLOB::rawContent() const
|
inline const char* BLOB::rawContent() const
|
||||||
{
|
{
|
||||||
return &(*_pContent)[0];
|
return &(*_pContent)[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::size_t BLOB::size() const
|
inline std::size_t BLOB::size() const
|
||||||
{
|
{
|
||||||
return _pContent->size();
|
return _pContent->size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool BLOB::operator == (const BLOB& other) const
|
inline bool BLOB::operator == (const BLOB& other) const
|
||||||
{
|
{
|
||||||
return *_pContent == *other._pContent;
|
return *_pContent == *other._pContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool BLOB::operator != (const BLOB& other) const
|
inline bool BLOB::operator != (const BLOB& other) const
|
||||||
{
|
{
|
||||||
return *_pContent != *other._pContent;
|
return *_pContent != *other._pContent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline BLOB::Iterator BLOB::begin() const
|
inline BLOB::Iterator BLOB::begin() const
|
||||||
{
|
{
|
||||||
return _pContent->begin();
|
return _pContent->begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline BLOB::Iterator BLOB::end() const
|
inline BLOB::Iterator BLOB::end() const
|
||||||
{
|
{
|
||||||
return _pContent->end();
|
return _pContent->end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void BLOB::assignRaw(const char* pChar, std::size_t count)
|
inline void BLOB::assignRaw(const char* pChar, std::size_t count)
|
||||||
{
|
{
|
||||||
poco_assert_dbg (pChar);
|
poco_assert_dbg (pChar);
|
||||||
BLOB tmp(pChar, count);
|
BLOB tmp(pChar, count);
|
||||||
swap(tmp);
|
swap(tmp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void BLOB::appendRaw(const char* pChar, std::size_t count)
|
inline void BLOB::appendRaw(const char* pChar, std::size_t count)
|
||||||
{
|
{
|
||||||
poco_assert_dbg (pChar);
|
poco_assert_dbg (pChar);
|
||||||
_pContent->insert(_pContent->end(), pChar, pChar+count);
|
_pContent->insert(_pContent->end(), pChar, pChar+count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void BLOB::swap(BLOB& other)
|
inline void BLOB::swap(BLOB& other)
|
||||||
{
|
{
|
||||||
using std::swap;
|
using std::swap;
|
||||||
swap(_pContent, other._pContent);
|
swap(_pContent, other._pContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void BLOB::clear(bool doCompact)
|
inline void BLOB::clear(bool doCompact)
|
||||||
{
|
{
|
||||||
_pContent->clear();
|
_pContent->clear();
|
||||||
if (doCompact) compact();
|
if (doCompact) compact();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void BLOB::compact()
|
inline void BLOB::compact()
|
||||||
{
|
{
|
||||||
std::vector<char>(*_pContent).swap(*_pContent);
|
std::vector<char>(*_pContent).swap(*_pContent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Data
|
} } // namespace Poco::Data
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// DynamicAnyHolderImpl<BLOB>
|
// DynamicAnyHolderImpl<BLOB>
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class DynamicAnyHolderImpl<Data::BLOB>: public DynamicAnyHolder
|
class DynamicAnyHolderImpl<Data::BLOB>: public DynamicAnyHolder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DynamicAnyHolderImpl(const Data::BLOB& val): _val(val)
|
DynamicAnyHolderImpl(const Data::BLOB& val): _val(val)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~DynamicAnyHolderImpl()
|
~DynamicAnyHolderImpl()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::type_info& type() const
|
const std::type_info& type() const
|
||||||
{
|
{
|
||||||
return typeid(Data::BLOB);
|
return typeid(Data::BLOB);
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int8& val) const
|
void convert(Int8& val) const
|
||||||
{
|
{
|
||||||
throw Poco::BadCastException();
|
throw Poco::BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int16& val) const
|
void convert(Int16& val) const
|
||||||
{
|
{
|
||||||
throw Poco::BadCastException();
|
throw Poco::BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int32& val) const
|
void convert(Int32& val) const
|
||||||
{
|
{
|
||||||
throw Poco::BadCastException();
|
throw Poco::BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(Int64& val) const
|
void convert(Int64& val) const
|
||||||
{
|
{
|
||||||
throw Poco::BadCastException();
|
throw Poco::BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(UInt8& val) const
|
void convert(UInt8& val) const
|
||||||
{
|
{
|
||||||
throw Poco::BadCastException();
|
throw Poco::BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(UInt16& val) const
|
void convert(UInt16& val) const
|
||||||
{
|
{
|
||||||
throw Poco::BadCastException();
|
throw Poco::BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(UInt32& val) const
|
void convert(UInt32& val) const
|
||||||
{
|
{
|
||||||
throw Poco::BadCastException();
|
throw Poco::BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(UInt64& val) const
|
void convert(UInt64& val) const
|
||||||
{
|
{
|
||||||
throw Poco::BadCastException();
|
throw Poco::BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(bool& val) const
|
void convert(bool& val) const
|
||||||
{
|
{
|
||||||
throw Poco::BadCastException();
|
throw Poco::BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(float& val) const
|
void convert(float& val) const
|
||||||
{
|
{
|
||||||
throw Poco::BadCastException();
|
throw Poco::BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(double& val) const
|
void convert(double& val) const
|
||||||
{
|
{
|
||||||
throw Poco::BadCastException();
|
throw Poco::BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(char& val) const
|
void convert(char& val) const
|
||||||
{
|
{
|
||||||
throw Poco::BadCastException();
|
throw Poco::BadCastException();
|
||||||
}
|
}
|
||||||
|
|
||||||
void convert(std::string& val) const
|
void convert(std::string& val) const
|
||||||
{
|
{
|
||||||
val.assign(_val.begin(), _val.end());
|
val.assign(_val.begin(), _val.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
DynamicAnyHolder* clone() const
|
DynamicAnyHolder* clone() const
|
||||||
{
|
{
|
||||||
return new DynamicAnyHolderImpl(_val);
|
return new DynamicAnyHolderImpl(_val);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Data::BLOB _val;
|
Data::BLOB _val;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Data_BLOB_INCLUDED
|
#endif // Data_BLOB_INCLUDED
|
||||||
|
|||||||
209
Data/samples/Binding/Binding_vs90.vcproj
Normal file
209
Data/samples/Binding/Binding_vs90.vcproj
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="Binding"
|
||||||
|
ProjectGUID="{F2972327-DCA7-49BB-B55D-66C554CF1205}"
|
||||||
|
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;..\..\..\Data\include;..\..\..\Data\SQLite\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="false"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="bin/Bindingd.exe"
|
||||||
|
LinkIncremental="2"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
ProgramDatabaseFile="bin/Bindingd.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
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;..\..\..\Data\include;..\..\..\Data\SQLite\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="false"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="bin/Binding.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="false"
|
||||||
|
ProgramDatabaseFile=""
|
||||||
|
SubSystem="1"
|
||||||
|
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="Header Files"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Binding.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
@@ -1,115 +1,115 @@
|
|||||||
//
|
//
|
||||||
// Binding.cpp
|
// Binding.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/samples/Binding/src/Binding.cpp#3 $
|
// $Id: //poco/1.3/Data/samples/Binding/src/Binding.cpp#4 $
|
||||||
//
|
//
|
||||||
// This sample demonstrates the Data library.
|
// This sample demonstrates the Data library.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include "Poco/Data/SessionFactory.h"
|
#include "Poco/Data/SessionFactory.h"
|
||||||
#include "Poco/Data/Session.h"
|
#include "Poco/Data/Session.h"
|
||||||
#include "Poco/Data/SQLite/Connector.h"
|
#include "Poco/Data/SQLite/Connector.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
using namespace Poco::Data;
|
using namespace Poco::Data;
|
||||||
|
|
||||||
|
|
||||||
struct Person
|
struct Person
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string address;
|
std::string address;
|
||||||
int age;
|
int age;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
// register SQLite connector
|
// register SQLite connector
|
||||||
Poco::Data::SQLite::Connector::registerConnector();
|
Poco::Data::SQLite::Connector::registerConnector();
|
||||||
|
|
||||||
// create a session
|
// create a session
|
||||||
Session session("SQLite", "sample.db");
|
Session session("SQLite", "sample.db");
|
||||||
|
|
||||||
// drop sample table, if it exists
|
// drop sample table, if it exists
|
||||||
session << "DROP TABLE IF EXISTS Person", now;
|
session << "DROP TABLE IF EXISTS Person", now;
|
||||||
|
|
||||||
// (re)create table
|
// (re)create table
|
||||||
session << "CREATE TABLE Person (Name VARCHAR(30), Address VARCHAR, Age INTEGER(3))", now;
|
session << "CREATE TABLE Person (Name VARCHAR(30), Address VARCHAR, Age INTEGER(3))", now;
|
||||||
|
|
||||||
// insert some rows
|
// insert some rows
|
||||||
Person person =
|
Person person =
|
||||||
{
|
{
|
||||||
"Bart Simpson",
|
"Bart Simpson",
|
||||||
"Springfield",
|
"Springfield",
|
||||||
12
|
12
|
||||||
};
|
};
|
||||||
|
|
||||||
Statement insert(session);
|
Statement insert(session);
|
||||||
insert << "INSERT INTO Person VALUES(?, ?, ?)",
|
insert << "INSERT INTO Person VALUES(?, ?, ?)",
|
||||||
use(person.name),
|
use(person.name),
|
||||||
use(person.address),
|
use(person.address),
|
||||||
use(person.age);
|
use(person.age);
|
||||||
|
|
||||||
insert.execute();
|
insert.execute();
|
||||||
|
|
||||||
person.name = "Lisa Simpson";
|
person.name = "Lisa Simpson";
|
||||||
person.address = "Springfield";
|
person.address = "Springfield";
|
||||||
person.age = 10;
|
person.age = 10;
|
||||||
|
|
||||||
insert.execute();
|
insert.execute();
|
||||||
|
|
||||||
// a simple query
|
// a simple query
|
||||||
Statement select(session);
|
Statement select(session);
|
||||||
select << "SELECT Name, Address, Age FROM Person",
|
select << "SELECT Name, Address, Age FROM Person",
|
||||||
into(person.name),
|
into(person.name),
|
||||||
into(person.address),
|
into(person.address),
|
||||||
into(person.age),
|
into(person.age),
|
||||||
range(0, 1); // iterate over result set one row at a time
|
range(0, 1); // iterate over result set one row at a time
|
||||||
|
|
||||||
while (!select.done())
|
while (!select.done())
|
||||||
{
|
{
|
||||||
select.execute();
|
select.execute();
|
||||||
std::cout << person.name << " " << person.address << " " << person.age << std::endl;
|
std::cout << person.name << " " << person.address << " " << person.age << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// another query - store the result in a container
|
// another query - store the result in a container
|
||||||
std::vector<std::string> names;
|
std::vector<std::string> names;
|
||||||
session << "SELECT Name FROM Person",
|
session << "SELECT Name FROM Person",
|
||||||
into(names),
|
into(names),
|
||||||
now;
|
now;
|
||||||
|
|
||||||
for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)
|
for (std::vector<std::string>::const_iterator it = names.begin(); it != names.end(); ++it)
|
||||||
{
|
{
|
||||||
std::cout << *it << std::endl;
|
std::cout << *it << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
209
Data/samples/RecordSet/RecordSet_vs90.vcproj
Normal file
209
Data/samples/RecordSet/RecordSet_vs90.vcproj
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="RecordSet"
|
||||||
|
ProjectGUID="{56F66D36-F11E-4AA1-AD37-4518A253059D}"
|
||||||
|
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;..\..\..\Data\include;..\..\..\Data\SQLite\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="false"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="bin/RecordSetd.exe"
|
||||||
|
LinkIncremental="2"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
ProgramDatabaseFile="bin/RecordSetd.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
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;..\..\..\Data\include;..\..\..\Data\SQLite\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="false"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="bin/RecordSet.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="false"
|
||||||
|
ProgramDatabaseFile=""
|
||||||
|
SubSystem="1"
|
||||||
|
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="Header Files"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\RecordSet.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
@@ -1,98 +1,98 @@
|
|||||||
//
|
//
|
||||||
// RecordSet.cpp
|
// RecordSet.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/samples/RecordSet/src/RecordSet.cpp#2 $
|
// $Id: //poco/1.3/Data/samples/RecordSet/src/RecordSet.cpp#3 $
|
||||||
//
|
//
|
||||||
// This sample demonstrates the Data library.
|
// This sample demonstrates the Data library.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include "Poco/Data/SessionFactory.h"
|
#include "Poco/Data/SessionFactory.h"
|
||||||
#include "Poco/Data/Session.h"
|
#include "Poco/Data/Session.h"
|
||||||
#include "Poco/Data/RecordSet.h"
|
#include "Poco/Data/RecordSet.h"
|
||||||
#include "Poco/Data/Column.h"
|
#include "Poco/Data/Column.h"
|
||||||
#include "Poco/Data/SQLite/Connector.h"
|
#include "Poco/Data/SQLite/Connector.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
using namespace Poco::Data;
|
using namespace Poco::Data;
|
||||||
|
|
||||||
|
|
||||||
struct Person
|
struct Person
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string address;
|
std::string address;
|
||||||
int age;
|
int age;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
// register SQLite connector
|
// register SQLite connector
|
||||||
Poco::Data::SQLite::Connector::registerConnector();
|
Poco::Data::SQLite::Connector::registerConnector();
|
||||||
|
|
||||||
// create a session
|
// create a session
|
||||||
Session session("SQLite", "sample.db");
|
Session session("SQLite", "sample.db");
|
||||||
|
|
||||||
// drop sample table, if it exists
|
// drop sample table, if it exists
|
||||||
session << "DROP TABLE IF EXISTS Person", now;
|
session << "DROP TABLE IF EXISTS Person", now;
|
||||||
|
|
||||||
// (re)create table
|
// (re)create table
|
||||||
session << "CREATE TABLE Person (Name VARCHAR(30), Address VARCHAR, Age INTEGER(3))", now;
|
session << "CREATE TABLE Person (Name VARCHAR(30), Address VARCHAR, Age INTEGER(3))", now;
|
||||||
|
|
||||||
// insert some rows
|
// insert some rows
|
||||||
session << "INSERT INTO Person VALUES('Bart Simpson', 'Springfield', 12)", now;
|
session << "INSERT INTO Person VALUES('Bart Simpson', 'Springfield', 12)", now;
|
||||||
session << "INSERT INTO Person VALUES('Lisa Simpson', 'Springfield', 10)", now;
|
session << "INSERT INTO Person VALUES('Lisa Simpson', 'Springfield', 10)", now;
|
||||||
|
|
||||||
// a simple query
|
// a simple query
|
||||||
Statement select(session);
|
Statement select(session);
|
||||||
select << "SELECT * FROM Person";
|
select << "SELECT * FROM Person";
|
||||||
select.execute();
|
select.execute();
|
||||||
|
|
||||||
// create a RecordSet
|
// create a RecordSet
|
||||||
RecordSet rs(select);
|
RecordSet rs(select);
|
||||||
std::size_t cols = rs.columnCount();
|
std::size_t cols = rs.columnCount();
|
||||||
// print all column names
|
// print all column names
|
||||||
for (std::size_t col = 0; col < cols; ++col)
|
for (std::size_t col = 0; col < cols; ++col)
|
||||||
{
|
{
|
||||||
std::cout << rs.columnName(col) << std::endl;
|
std::cout << rs.columnName(col) << std::endl;
|
||||||
}
|
}
|
||||||
// iterate over all rows and columns
|
// iterate over all rows and columns
|
||||||
bool more = rs.moveFirst();
|
bool more = rs.moveFirst();
|
||||||
while (more)
|
while (more)
|
||||||
{
|
{
|
||||||
for (std::size_t col = 0; col < cols; ++col)
|
for (std::size_t col = 0; col < cols; ++col)
|
||||||
{
|
{
|
||||||
std::cout << rs[col].convert<std::string>() << " ";
|
std::cout << rs[col].convert<std::string>() << " ";
|
||||||
}
|
}
|
||||||
std::cout << std::endl;
|
std::cout << std::endl;
|
||||||
more = rs.moveNext();
|
more = rs.moveNext();
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
209
Data/samples/Tuple/Tuple_vs90.vcproj
Normal file
209
Data/samples/Tuple/Tuple_vs90.vcproj
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="Tuple"
|
||||||
|
ProjectGUID="{08C81227-3322-4DBD-A83F-55CCC933A5F7}"
|
||||||
|
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;..\..\..\Data\include;..\..\..\Data\SQLite\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="false"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="bin/Tupled.exe"
|
||||||
|
LinkIncremental="2"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
ProgramDatabaseFile="bin/Tupled.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
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;..\..\..\Data\include;..\..\..\Data\SQLite\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="false"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="bin/Tuple.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="false"
|
||||||
|
ProgramDatabaseFile=""
|
||||||
|
SubSystem="1"
|
||||||
|
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="Header Files"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Tuple.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
@@ -1,88 +1,88 @@
|
|||||||
//
|
//
|
||||||
// Tuple.cpp
|
// Tuple.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/samples/Tuple/src/Tuple.cpp#3 $
|
// $Id: //poco/1.3/Data/samples/Tuple/src/Tuple.cpp#4 $
|
||||||
//
|
//
|
||||||
// This sample demonstrates the Data library.
|
// This sample demonstrates the Data library.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include "Poco/Tuple.h"
|
#include "Poco/Tuple.h"
|
||||||
#include "Poco/Data/SessionFactory.h"
|
#include "Poco/Data/SessionFactory.h"
|
||||||
#include "Poco/Data/Session.h"
|
#include "Poco/Data/Session.h"
|
||||||
#include "Poco/Data/SQLite/Connector.h"
|
#include "Poco/Data/SQLite/Connector.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
using namespace Poco::Data;
|
using namespace Poco::Data;
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
typedef Poco::Tuple<std::string, std::string, int> Person;
|
typedef Poco::Tuple<std::string, std::string, int> Person;
|
||||||
typedef std::vector<Person> People;
|
typedef std::vector<Person> People;
|
||||||
|
|
||||||
// register SQLite connector
|
// register SQLite connector
|
||||||
Poco::Data::SQLite::Connector::registerConnector();
|
Poco::Data::SQLite::Connector::registerConnector();
|
||||||
|
|
||||||
// create a session
|
// create a session
|
||||||
Session session("SQLite", "sample.db");
|
Session session("SQLite", "sample.db");
|
||||||
|
|
||||||
// drop sample table, if it exists
|
// drop sample table, if it exists
|
||||||
session << "DROP TABLE IF EXISTS Person", now;
|
session << "DROP TABLE IF EXISTS Person", now;
|
||||||
|
|
||||||
// (re)create table
|
// (re)create table
|
||||||
session << "CREATE TABLE Person (Name VARCHAR(30), Address VARCHAR, Age INTEGER(3))", now;
|
session << "CREATE TABLE Person (Name VARCHAR(30), Address VARCHAR, Age INTEGER(3))", now;
|
||||||
|
|
||||||
// insert some rows
|
// insert some rows
|
||||||
People people;
|
People people;
|
||||||
people.push_back(Person("Bart Simpson", "Springfield", 12));
|
people.push_back(Person("Bart Simpson", "Springfield", 12));
|
||||||
people.push_back(Person("Lisa Simpson", "Springfield", 10));
|
people.push_back(Person("Lisa Simpson", "Springfield", 10));
|
||||||
|
|
||||||
Statement insert(session);
|
Statement insert(session);
|
||||||
insert << "INSERT INTO Person VALUES(?, ?, ?)",
|
insert << "INSERT INTO Person VALUES(?, ?, ?)",
|
||||||
use(people), now;
|
use(people), now;
|
||||||
|
|
||||||
people.clear();
|
people.clear();
|
||||||
|
|
||||||
// a simple query
|
// a simple query
|
||||||
Statement select(session);
|
Statement select(session);
|
||||||
select << "SELECT Name, Address, Age FROM Person",
|
select << "SELECT Name, Address, Age FROM Person",
|
||||||
into(people),
|
into(people),
|
||||||
now;
|
now;
|
||||||
|
|
||||||
for (People::const_iterator it = people.begin(); it != people.end(); ++it)
|
for (People::const_iterator it = people.begin(); it != people.end(); ++it)
|
||||||
{
|
{
|
||||||
std::cout << "Name: " << it->get<0>() <<
|
std::cout << "Name: " << it->get<0>() <<
|
||||||
", Address: " << it->get<1>() <<
|
", Address: " << it->get<1>() <<
|
||||||
", Age: " << it->get<2>() <<std::endl;
|
", Age: " << it->get<2>() <<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
209
Data/samples/TypeHandler/TypeHandler_vs90.vcproj
Normal file
209
Data/samples/TypeHandler/TypeHandler_vs90.vcproj
Normal file
@@ -0,0 +1,209 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="TypeHandler"
|
||||||
|
ProjectGUID="{822AEE4A-48B6-4B45-AB04-5C3C21C365C5}"
|
||||||
|
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;..\..\..\Data\include;..\..\..\Data\SQLite\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="false"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="bin/TypeHandlerd.exe"
|
||||||
|
LinkIncremental="2"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="true"
|
||||||
|
ProgramDatabaseFile="bin/TypeHandlerd.pdb"
|
||||||
|
SubSystem="1"
|
||||||
|
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;..\..\..\Data\include;..\..\..\Data\SQLite\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="false"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
OutputFile="bin/TypeHandler.exe"
|
||||||
|
LinkIncremental="1"
|
||||||
|
AdditionalLibraryDirectories="..\..\..\lib"
|
||||||
|
GenerateDebugInformation="false"
|
||||||
|
ProgramDatabaseFile=""
|
||||||
|
SubSystem="1"
|
||||||
|
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="Header Files"
|
||||||
|
>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\TypeHandler.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
@@ -1,153 +1,153 @@
|
|||||||
//
|
//
|
||||||
// Binding.cpp
|
// Binding.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/samples/TypeHandler/src/TypeHandler.cpp#3 $
|
// $Id: //poco/1.3/Data/samples/TypeHandler/src/TypeHandler.cpp#4 $
|
||||||
//
|
//
|
||||||
// This sample demonstrates the Data library.
|
// This sample demonstrates the Data library.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2008, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2008, 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/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include "Poco/Data/SessionFactory.h"
|
#include "Poco/Data/SessionFactory.h"
|
||||||
#include "Poco/Data/Session.h"
|
#include "Poco/Data/Session.h"
|
||||||
#include "Poco/Data/TypeHandler.h"
|
#include "Poco/Data/TypeHandler.h"
|
||||||
#include "Poco/Data/SQLite/Connector.h"
|
#include "Poco/Data/SQLite/Connector.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
using namespace Poco::Data;
|
using namespace Poco::Data;
|
||||||
|
|
||||||
|
|
||||||
struct Person
|
struct Person
|
||||||
{
|
{
|
||||||
std::string name;
|
std::string name;
|
||||||
std::string address;
|
std::string address;
|
||||||
int age;
|
int age;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class TypeHandler<Person>
|
class TypeHandler<Person>
|
||||||
/// Defining a specialization of TypeHandler for Person allows us
|
/// Defining a specialization of TypeHandler for Person allows us
|
||||||
/// to use the Person struct in use and into clauses.
|
/// to use the Person struct in use and into clauses.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static std::size_t size()
|
static std::size_t size()
|
||||||
{
|
{
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void bind(std::size_t pos, const Person& person, AbstractBinder* pBinder)
|
static void bind(std::size_t pos, const Person& person, AbstractBinder* pBinder)
|
||||||
{
|
{
|
||||||
TypeHandler<std::string>::bind(pos++, person.name, pBinder);
|
TypeHandler<std::string>::bind(pos++, person.name, pBinder);
|
||||||
TypeHandler<std::string>::bind(pos++, person.address, pBinder);
|
TypeHandler<std::string>::bind(pos++, person.address, pBinder);
|
||||||
TypeHandler<int>::bind(pos++, person.age, pBinder);
|
TypeHandler<int>::bind(pos++, person.age, pBinder);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void extract(std::size_t pos, Person& person, const Person& deflt, AbstractExtractor* pExtr)
|
static void extract(std::size_t pos, Person& person, const Person& deflt, AbstractExtractor* pExtr)
|
||||||
{
|
{
|
||||||
TypeHandler<std::string>::extract(pos++, person.name, deflt.name, pExtr);
|
TypeHandler<std::string>::extract(pos++, person.name, deflt.name, pExtr);
|
||||||
TypeHandler<std::string>::extract(pos++, person.address, deflt.address, pExtr);
|
TypeHandler<std::string>::extract(pos++, person.address, deflt.address, pExtr);
|
||||||
TypeHandler<int>::extract(pos++, person.age, deflt.age, pExtr);
|
TypeHandler<int>::extract(pos++, person.age, deflt.age, pExtr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prepare(std::size_t pos, const Person& person, AbstractPreparation* pPrep)
|
static void prepare(std::size_t pos, const Person& person, AbstractPreparation* pPrep)
|
||||||
{
|
{
|
||||||
TypeHandler<std::string>::prepare(pos++, person.name, pPrep);
|
TypeHandler<std::string>::prepare(pos++, person.name, pPrep);
|
||||||
TypeHandler<std::string>::prepare(pos++, person.address, pPrep);
|
TypeHandler<std::string>::prepare(pos++, person.address, pPrep);
|
||||||
TypeHandler<int>::prepare(pos++, person.age, pPrep);
|
TypeHandler<int>::prepare(pos++, person.age, pPrep);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Data
|
} } // namespace Poco::Data
|
||||||
|
|
||||||
|
|
||||||
int main(int argc, char** argv)
|
int main(int argc, char** argv)
|
||||||
{
|
{
|
||||||
// register SQLite connector
|
// register SQLite connector
|
||||||
Poco::Data::SQLite::Connector::registerConnector();
|
Poco::Data::SQLite::Connector::registerConnector();
|
||||||
|
|
||||||
// create a session
|
// create a session
|
||||||
Session session("SQLite", "sample.db");
|
Session session("SQLite", "sample.db");
|
||||||
|
|
||||||
// drop sample table, if it exists
|
// drop sample table, if it exists
|
||||||
session << "DROP TABLE IF EXISTS Person", now;
|
session << "DROP TABLE IF EXISTS Person", now;
|
||||||
|
|
||||||
// (re)create table
|
// (re)create table
|
||||||
session << "CREATE TABLE Person (Name VARCHAR(30), Address VARCHAR, Age INTEGER(3))", now;
|
session << "CREATE TABLE Person (Name VARCHAR(30), Address VARCHAR, Age INTEGER(3))", now;
|
||||||
|
|
||||||
// insert some rows
|
// insert some rows
|
||||||
Person person =
|
Person person =
|
||||||
{
|
{
|
||||||
"Bart Simpson",
|
"Bart Simpson",
|
||||||
"Springfield",
|
"Springfield",
|
||||||
12
|
12
|
||||||
};
|
};
|
||||||
|
|
||||||
Statement insert(session);
|
Statement insert(session);
|
||||||
insert << "INSERT INTO Person VALUES(?, ?, ?)",
|
insert << "INSERT INTO Person VALUES(?, ?, ?)",
|
||||||
use(person);
|
use(person);
|
||||||
|
|
||||||
insert.execute();
|
insert.execute();
|
||||||
|
|
||||||
person.name = "Lisa Simpson";
|
person.name = "Lisa Simpson";
|
||||||
person.address = "Springfield";
|
person.address = "Springfield";
|
||||||
person.age = 10;
|
person.age = 10;
|
||||||
|
|
||||||
insert.execute();
|
insert.execute();
|
||||||
|
|
||||||
// a simple query
|
// a simple query
|
||||||
Statement select(session);
|
Statement select(session);
|
||||||
select << "SELECT Name, Address, Age FROM Person",
|
select << "SELECT Name, Address, Age FROM Person",
|
||||||
into(person),
|
into(person),
|
||||||
range(0, 1); // iterate over result set one row at a time
|
range(0, 1); // iterate over result set one row at a time
|
||||||
|
|
||||||
while (!select.done())
|
while (!select.done())
|
||||||
{
|
{
|
||||||
select.execute();
|
select.execute();
|
||||||
std::cout << person.name << " " << person.address << " " << person.age << std::endl;
|
std::cout << person.name << " " << person.address << " " << person.age << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// another query - store the result in a container
|
// another query - store the result in a container
|
||||||
std::vector<Person> persons;
|
std::vector<Person> persons;
|
||||||
session << "SELECT Name, Address, Age FROM Person",
|
session << "SELECT Name, Address, Age FROM Person",
|
||||||
into(persons),
|
into(persons),
|
||||||
now;
|
now;
|
||||||
|
|
||||||
for (std::vector<Person>::const_iterator it = persons.begin(); it != persons.end(); ++it)
|
for (std::vector<Person>::const_iterator it = persons.begin(); it != persons.end(); ++it)
|
||||||
{
|
{
|
||||||
std::cout << it->name << " " << it->address << " " << it->age << std::endl;
|
std::cout << it->name << " " << it->address << " " << it->age << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
38
Data/samples/samples_vs90.sln
Normal file
38
Data/samples/samples_vs90.sln
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
Microsoft Visual Studio Solution File, Format Version 10.00
|
||||||
|
# Visual Studio 2008
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Binding", "Binding\Binding_vs90.vcproj", "{F2972327-DCA7-49BB-B55D-66C554CF1205}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TypeHandler", "TypeHandler\TypeHandler_vs90.vcproj", "{822AEE4A-48B6-4B45-AB04-5C3C21C365C5}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RecordSet", "RecordSet\RecordSet_vs90.vcproj", "{56F66D36-F11E-4AA1-AD37-4518A253059D}"
|
||||||
|
EndProject
|
||||||
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tuple", "Tuple\Tuple_vs90.vcproj", "{08C81227-3322-4DBD-A83F-55CCC933A5F7}"
|
||||||
|
EndProject
|
||||||
|
Global
|
||||||
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
|
debug_shared|Win32 = debug_shared|Win32
|
||||||
|
release_shared|Win32 = release_shared|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
|
{F2972327-DCA7-49BB-B55D-66C554CF1205}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
|
{F2972327-DCA7-49BB-B55D-66C554CF1205}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
|
{F2972327-DCA7-49BB-B55D-66C554CF1205}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
|
{F2972327-DCA7-49BB-B55D-66C554CF1205}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
|
{822AEE4A-48B6-4B45-AB04-5C3C21C365C5}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
|
{822AEE4A-48B6-4B45-AB04-5C3C21C365C5}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
|
{822AEE4A-48B6-4B45-AB04-5C3C21C365C5}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
|
{822AEE4A-48B6-4B45-AB04-5C3C21C365C5}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
|
{56F66D36-F11E-4AA1-AD37-4518A253059D}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
|
{56F66D36-F11E-4AA1-AD37-4518A253059D}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
|
{56F66D36-F11E-4AA1-AD37-4518A253059D}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
|
{56F66D36-F11E-4AA1-AD37-4518A253059D}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
|
{08C81227-3322-4DBD-A83F-55CCC933A5F7}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
|
{08C81227-3322-4DBD-A83F-55CCC933A5F7}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
|
{08C81227-3322-4DBD-A83F-55CCC933A5F7}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
|
{08C81227-3322-4DBD-A83F-55CCC933A5F7}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
|
EndGlobalSection
|
||||||
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
|
HideSolutionNode = FALSE
|
||||||
|
EndGlobalSection
|
||||||
|
EndGlobal
|
||||||
@@ -1,208 +1,208 @@
|
|||||||
//
|
//
|
||||||
// SessionPool.cpp
|
// SessionPool.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/src/SessionPool.cpp#3 $
|
// $Id: //poco/1.3/Data/src/SessionPool.cpp#4 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: SessionPooling
|
// Package: SessionPooling
|
||||||
// Module: SessionPool
|
// Module: SessionPool
|
||||||
//
|
//
|
||||||
// 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/SessionPool.h"
|
#include "Poco/Data/SessionPool.h"
|
||||||
#include "Poco/Data/SessionFactory.h"
|
#include "Poco/Data/SessionFactory.h"
|
||||||
#include "Poco/Data/DataException.h"
|
#include "Poco/Data/DataException.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
|
|
||||||
SessionPool::SessionPool(const std::string& sessionKey, const std::string& connectionString, int minSessions, int maxSessions, int idleTime):
|
SessionPool::SessionPool(const std::string& sessionKey, const std::string& connectionString, int minSessions, int maxSessions, int idleTime):
|
||||||
_sessionKey(sessionKey),
|
_sessionKey(sessionKey),
|
||||||
_connectionString(connectionString),
|
_connectionString(connectionString),
|
||||||
_minSessions(minSessions),
|
_minSessions(minSessions),
|
||||||
_maxSessions(maxSessions),
|
_maxSessions(maxSessions),
|
||||||
_idleTime(idleTime),
|
_idleTime(idleTime),
|
||||||
_nSessions(0),
|
_nSessions(0),
|
||||||
_janitorTimer(1000*idleTime, 1000*idleTime/4)
|
_janitorTimer(1000*idleTime, 1000*idleTime/4)
|
||||||
{
|
{
|
||||||
Poco::TimerCallback<SessionPool> callback(*this, &SessionPool::onJanitorTimer);
|
Poco::TimerCallback<SessionPool> callback(*this, &SessionPool::onJanitorTimer);
|
||||||
_janitorTimer.start(callback);
|
_janitorTimer.start(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SessionPool::~SessionPool()
|
SessionPool::~SessionPool()
|
||||||
{
|
{
|
||||||
_janitorTimer.stop();
|
_janitorTimer.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Session SessionPool::get()
|
Session SessionPool::get()
|
||||||
{
|
{
|
||||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
purgeDeadSessions();
|
purgeDeadSessions();
|
||||||
|
|
||||||
if (_idleSessions.empty())
|
if (_idleSessions.empty())
|
||||||
{
|
{
|
||||||
if (_nSessions < _maxSessions)
|
if (_nSessions < _maxSessions)
|
||||||
{
|
{
|
||||||
Session newSession(SessionFactory::instance().create(_sessionKey, _connectionString));
|
Session newSession(SessionFactory::instance().create(_sessionKey, _connectionString));
|
||||||
PooledSessionHolderPtr pHolder(new PooledSessionHolder(*this, newSession.impl()));
|
PooledSessionHolderPtr pHolder(new PooledSessionHolder(*this, newSession.impl()));
|
||||||
_idleSessions.push_front(pHolder);
|
_idleSessions.push_front(pHolder);
|
||||||
++_nSessions;
|
++_nSessions;
|
||||||
}
|
}
|
||||||
else throw SessionPoolExhaustedException(_sessionKey, _connectionString);
|
else throw SessionPoolExhaustedException(_sessionKey, _connectionString);
|
||||||
}
|
}
|
||||||
PooledSessionHolderPtr pHolder(_idleSessions.front());
|
PooledSessionHolderPtr pHolder(_idleSessions.front());
|
||||||
PooledSessionImplPtr pPSI(new PooledSessionImpl(pHolder));
|
PooledSessionImplPtr pPSI(new PooledSessionImpl(pHolder));
|
||||||
_activeSessions.push_front(pHolder);
|
_activeSessions.push_front(pHolder);
|
||||||
_idleSessions.pop_front();
|
_idleSessions.pop_front();
|
||||||
return Session(pPSI);
|
return Session(pPSI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionPool::purgeDeadSessions()
|
void SessionPool::purgeDeadSessions()
|
||||||
{
|
{
|
||||||
SessionList::iterator it = _idleSessions.begin();
|
SessionList::iterator it = _idleSessions.begin();
|
||||||
for (; it != _idleSessions.end(); )
|
for (; it != _idleSessions.end(); )
|
||||||
{
|
{
|
||||||
if (!(*it)->session()->isConnected())
|
if (!(*it)->session()->isConnected())
|
||||||
{
|
{
|
||||||
it = _idleSessions.erase(it);
|
it = _idleSessions.erase(it);
|
||||||
--_nSessions;
|
--_nSessions;
|
||||||
}
|
}
|
||||||
else ++it;
|
else ++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SessionPool::capacity() const
|
int SessionPool::capacity() const
|
||||||
{
|
{
|
||||||
return _maxSessions;
|
return _maxSessions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SessionPool::used() const
|
int SessionPool::used() const
|
||||||
{
|
{
|
||||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
return (int) _activeSessions.size();
|
return (int) _activeSessions.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SessionPool::idle() const
|
int SessionPool::idle() const
|
||||||
{
|
{
|
||||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
return (int) _idleSessions.size();
|
return (int) _idleSessions.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SessionPool::dead()
|
int SessionPool::dead()
|
||||||
{
|
{
|
||||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
||||||
SessionList::iterator it = _activeSessions.begin();
|
SessionList::iterator it = _activeSessions.begin();
|
||||||
SessionList::iterator itEnd = _activeSessions.end();
|
SessionList::iterator itEnd = _activeSessions.end();
|
||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
if (!(*it)->session()->isConnected())
|
if (!(*it)->session()->isConnected())
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SessionPool::allocated() const
|
int SessionPool::allocated() const
|
||||||
{
|
{
|
||||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
return _nSessions;
|
return _nSessions;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int SessionPool::available() const
|
int SessionPool::available() const
|
||||||
{
|
{
|
||||||
return _maxSessions - used();
|
return _maxSessions - used();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionPool::putBack(PooledSessionHolderPtr pHolder)
|
void SessionPool::putBack(PooledSessionHolderPtr pHolder)
|
||||||
{
|
{
|
||||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
SessionList::iterator it = std::find(_activeSessions.begin(), _activeSessions.end(), pHolder);
|
SessionList::iterator it = std::find(_activeSessions.begin(), _activeSessions.end(), pHolder);
|
||||||
if (it != _activeSessions.end())
|
if (it != _activeSessions.end())
|
||||||
{
|
{
|
||||||
if (pHolder->session()->isConnected())
|
if (pHolder->session()->isConnected())
|
||||||
{
|
{
|
||||||
pHolder->access();
|
pHolder->access();
|
||||||
_idleSessions.push_front(pHolder);
|
_idleSessions.push_front(pHolder);
|
||||||
}
|
}
|
||||||
else --_nSessions;
|
else --_nSessions;
|
||||||
|
|
||||||
_activeSessions.erase(it);
|
_activeSessions.erase(it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
poco_bugcheck_msg("Unknown session passed to SessionPool::putBack()");
|
poco_bugcheck_msg("Unknown session passed to SessionPool::putBack()");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SessionPool::onJanitorTimer(Poco::Timer&)
|
void SessionPool::onJanitorTimer(Poco::Timer&)
|
||||||
{
|
{
|
||||||
Poco::FastMutex::ScopedLock lock(_mutex);
|
Poco::FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
SessionList::iterator it = _idleSessions.begin();
|
SessionList::iterator it = _idleSessions.begin();
|
||||||
while (_nSessions > _minSessions && it != _idleSessions.end())
|
while (_nSessions > _minSessions && it != _idleSessions.end())
|
||||||
{
|
{
|
||||||
if ((*it)->idle() > _idleTime || !(*it)->session()->isConnected())
|
if ((*it)->idle() > _idleTime || !(*it)->session()->isConnected())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
(*it)->session()->close();
|
(*it)->session()->close();
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
it = _idleSessions.erase(it);
|
it = _idleSessions.erase(it);
|
||||||
--_nSessions;
|
--_nSessions;
|
||||||
}
|
}
|
||||||
else ++it;
|
else ++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Data
|
} } // namespace Poco::Data
|
||||||
|
|||||||
@@ -1,322 +1,322 @@
|
|||||||
//
|
//
|
||||||
// StatementImpl.cpp
|
// StatementImpl.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Data/src/StatementImpl.cpp#4 $
|
// $Id: //poco/1.3/Data/src/StatementImpl.cpp#5 $
|
||||||
//
|
//
|
||||||
// Library: Data
|
// Library: Data
|
||||||
// Package: DataCore
|
// Package: DataCore
|
||||||
// Module: StatementImpl
|
// Module: StatementImpl
|
||||||
//
|
//
|
||||||
// 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/StatementImpl.h"
|
#include "Poco/Data/StatementImpl.h"
|
||||||
#include "Poco/Data/DataException.h"
|
#include "Poco/Data/DataException.h"
|
||||||
#include "Poco/Data/AbstractBinder.h"
|
#include "Poco/Data/AbstractBinder.h"
|
||||||
#include "Poco/Data/Extraction.h"
|
#include "Poco/Data/Extraction.h"
|
||||||
#include "Poco/Data/BLOB.h"
|
#include "Poco/Data/BLOB.h"
|
||||||
#include "Poco/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include "Poco/String.h"
|
#include "Poco/String.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
|
|
||||||
StatementImpl::StatementImpl():
|
StatementImpl::StatementImpl():
|
||||||
_state(ST_INITIALIZED),
|
_state(ST_INITIALIZED),
|
||||||
_extrLimit(upperLimit((Poco::UInt32) Limit::LIMIT_UNLIMITED, false)),
|
_extrLimit(upperLimit((Poco::UInt32) Limit::LIMIT_UNLIMITED, false)),
|
||||||
_lowerLimit(0),
|
_lowerLimit(0),
|
||||||
_columnsExtracted(0),
|
_columnsExtracted(0),
|
||||||
_ostr(),
|
_ostr(),
|
||||||
_bindings()
|
_bindings()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
StatementImpl::~StatementImpl()
|
StatementImpl::~StatementImpl()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Poco::UInt32 StatementImpl::execute()
|
Poco::UInt32 StatementImpl::execute()
|
||||||
{
|
{
|
||||||
resetExtraction();
|
resetExtraction();
|
||||||
Poco::UInt32 lim = 0;
|
Poco::UInt32 lim = 0;
|
||||||
if (_lowerLimit > _extrLimit.value())
|
if (_lowerLimit > _extrLimit.value())
|
||||||
throw LimitException("Illegal Statement state. Upper limit must not be smaller than the lower limit.");
|
throw LimitException("Illegal Statement state. Upper limit must not be smaller than the lower limit.");
|
||||||
|
|
||||||
if (_extrLimit.value() == Limit::LIMIT_UNLIMITED)
|
if (_extrLimit.value() == Limit::LIMIT_UNLIMITED)
|
||||||
lim = executeWithoutLimit();
|
lim = executeWithoutLimit();
|
||||||
else
|
else
|
||||||
lim = executeWithLimit();
|
lim = executeWithLimit();
|
||||||
|
|
||||||
if (lim < _lowerLimit)
|
if (lim < _lowerLimit)
|
||||||
{
|
{
|
||||||
throw LimitException("Did not receive enough data.");
|
throw LimitException("Did not receive enough data.");
|
||||||
}
|
}
|
||||||
return lim;
|
return lim;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Poco::UInt32 StatementImpl::executeWithLimit()
|
Poco::UInt32 StatementImpl::executeWithLimit()
|
||||||
{
|
{
|
||||||
poco_assert (_state != ST_DONE);
|
poco_assert (_state != ST_DONE);
|
||||||
|
|
||||||
compile();
|
compile();
|
||||||
|
|
||||||
Poco::UInt32 count = 0;
|
Poco::UInt32 count = 0;
|
||||||
Poco::UInt32 limit = _extrLimit.value();
|
Poco::UInt32 limit = _extrLimit.value();
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bind();
|
bind();
|
||||||
while (hasNext() && count < limit)
|
while (hasNext() && count < limit)
|
||||||
{
|
{
|
||||||
next();
|
next();
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (canBind() && count < limit);
|
while (canBind() && count < limit);
|
||||||
|
|
||||||
if (!canBind() && (!hasNext() || 0 == limit))
|
if (!canBind() && (!hasNext() || 0 == limit))
|
||||||
_state = ST_DONE;
|
_state = ST_DONE;
|
||||||
else if (hasNext() && limit == count && _extrLimit.isHardLimit())
|
else if (hasNext() && limit == count && _extrLimit.isHardLimit())
|
||||||
throw LimitException("HardLimit reached. We got more data than we asked for");
|
throw LimitException("HardLimit reached. We got more data than we asked for");
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
Poco::UInt32 StatementImpl::executeWithoutLimit()
|
Poco::UInt32 StatementImpl::executeWithoutLimit()
|
||||||
{
|
{
|
||||||
poco_assert (_state != ST_DONE);
|
poco_assert (_state != ST_DONE);
|
||||||
|
|
||||||
compile();
|
compile();
|
||||||
|
|
||||||
Poco::UInt32 count = 0;
|
Poco::UInt32 count = 0;
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
bind();
|
bind();
|
||||||
while (hasNext())
|
while (hasNext())
|
||||||
{
|
{
|
||||||
next();
|
next();
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (canBind());
|
while (canBind());
|
||||||
|
|
||||||
_state = ST_DONE;
|
_state = ST_DONE;
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementImpl::compile()
|
void StatementImpl::compile()
|
||||||
{
|
{
|
||||||
if (_state == ST_INITIALIZED)
|
if (_state == ST_INITIALIZED)
|
||||||
{
|
{
|
||||||
compileImpl();
|
compileImpl();
|
||||||
_state = ST_COMPILED;
|
_state = ST_COMPILED;
|
||||||
|
|
||||||
if (!extractions().size())
|
if (!extractions().size())
|
||||||
{
|
{
|
||||||
Poco::UInt32 cols = columnsReturned();
|
Poco::UInt32 cols = columnsReturned();
|
||||||
if (cols) makeExtractors(cols);
|
if (cols) makeExtractors(cols);
|
||||||
}
|
}
|
||||||
|
|
||||||
fixupExtraction();
|
fixupExtraction();
|
||||||
fixupBinding();
|
fixupBinding();
|
||||||
}
|
}
|
||||||
else if (_state == ST_RESET)
|
else if (_state == ST_RESET)
|
||||||
{
|
{
|
||||||
resetBinding();
|
resetBinding();
|
||||||
resetExtraction();
|
resetExtraction();
|
||||||
_state = ST_COMPILED;
|
_state = ST_COMPILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementImpl::bind()
|
void StatementImpl::bind()
|
||||||
{
|
{
|
||||||
if (_state == ST_COMPILED)
|
if (_state == ST_COMPILED)
|
||||||
{
|
{
|
||||||
bindImpl();
|
bindImpl();
|
||||||
_state = ST_BOUND;
|
_state = ST_BOUND;
|
||||||
}
|
}
|
||||||
else if (_state == ST_BOUND)
|
else if (_state == ST_BOUND)
|
||||||
{
|
{
|
||||||
if (!hasNext())
|
if (!hasNext())
|
||||||
{
|
{
|
||||||
if (canBind())
|
if (canBind())
|
||||||
{
|
{
|
||||||
bindImpl();
|
bindImpl();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
_state = ST_DONE;
|
_state = ST_DONE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementImpl::reset()
|
void StatementImpl::reset()
|
||||||
{
|
{
|
||||||
_state = ST_RESET;
|
_state = ST_RESET;
|
||||||
compile();
|
compile();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementImpl::setExtractionLimit(const Limit& extrLimit)
|
void StatementImpl::setExtractionLimit(const Limit& extrLimit)
|
||||||
{
|
{
|
||||||
if (!extrLimit.isLowerLimit())
|
if (!extrLimit.isLowerLimit())
|
||||||
_extrLimit = extrLimit;
|
_extrLimit = extrLimit;
|
||||||
else
|
else
|
||||||
_lowerLimit = extrLimit.value();
|
_lowerLimit = extrLimit.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementImpl::fixupExtraction()
|
void StatementImpl::fixupExtraction()
|
||||||
{
|
{
|
||||||
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
|
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
|
||||||
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
|
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
|
||||||
AbstractExtractor& ex = extractor();
|
AbstractExtractor& ex = extractor();
|
||||||
_columnsExtracted = 0;
|
_columnsExtracted = 0;
|
||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
(*it)->setExtractor(&ex);
|
(*it)->setExtractor(&ex);
|
||||||
(*it)->setLimit(_extrLimit.value()),
|
(*it)->setLimit(_extrLimit.value()),
|
||||||
_columnsExtracted += (int)(*it)->numOfColumnsHandled();
|
_columnsExtracted += (int)(*it)->numOfColumnsHandled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementImpl::fixupBinding()
|
void StatementImpl::fixupBinding()
|
||||||
{
|
{
|
||||||
// no need to call binder().reset(); here will be called before each bind anyway
|
// no need to call binder().reset(); here will be called before each bind anyway
|
||||||
AbstractBindingVec::iterator it = bindings().begin();
|
AbstractBindingVec::iterator it = bindings().begin();
|
||||||
AbstractBindingVec::iterator itEnd = bindings().end();
|
AbstractBindingVec::iterator itEnd = bindings().end();
|
||||||
AbstractBinder& bin = binder();
|
AbstractBinder& bin = binder();
|
||||||
std::size_t numRows = 0;
|
std::size_t numRows = 0;
|
||||||
if (it != itEnd)
|
if (it != itEnd)
|
||||||
numRows = (*it)->numOfRowsHandled();
|
numRows = (*it)->numOfRowsHandled();
|
||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
if (numRows != (*it)->numOfRowsHandled())
|
if (numRows != (*it)->numOfRowsHandled())
|
||||||
{
|
{
|
||||||
throw BindingException("Size mismatch in Bindings. All Bindings MUST have the same size");
|
throw BindingException("Size mismatch in Bindings. All Bindings MUST have the same size");
|
||||||
}
|
}
|
||||||
(*it)->setBinder(&bin);
|
(*it)->setBinder(&bin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementImpl::resetBinding()
|
void StatementImpl::resetBinding()
|
||||||
{
|
{
|
||||||
AbstractBindingVec::iterator it = bindings().begin();
|
AbstractBindingVec::iterator it = bindings().begin();
|
||||||
AbstractBindingVec::iterator itEnd = bindings().end();
|
AbstractBindingVec::iterator itEnd = bindings().end();
|
||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
(*it)->reset();
|
(*it)->reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementImpl::resetExtraction()
|
void StatementImpl::resetExtraction()
|
||||||
{
|
{
|
||||||
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
|
Poco::Data::AbstractExtractionVec::iterator it = extractions().begin();
|
||||||
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
|
Poco::Data::AbstractExtractionVec::iterator itEnd = extractions().end();
|
||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
{
|
{
|
||||||
(*it)->reset();
|
(*it)->reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void StatementImpl::makeExtractors(Poco::UInt32 count)
|
void StatementImpl::makeExtractors(Poco::UInt32 count)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < count; ++i)
|
for (int i = 0; i < count; ++i)
|
||||||
{
|
{
|
||||||
const MetaColumn& mc = metaColumn(i);
|
const MetaColumn& mc = metaColumn(i);
|
||||||
switch (mc.type())
|
switch (mc.type())
|
||||||
{
|
{
|
||||||
case MetaColumn::FDT_BOOL:
|
case MetaColumn::FDT_BOOL:
|
||||||
case MetaColumn::FDT_INT8:
|
case MetaColumn::FDT_INT8:
|
||||||
addInternalExtract<Int8, std::vector<Int8> >(mc);
|
addInternalExtract<Int8, std::vector<Int8> >(mc);
|
||||||
break;
|
break;
|
||||||
case MetaColumn::FDT_UINT8:
|
case MetaColumn::FDT_UINT8:
|
||||||
addInternalExtract<UInt8, std::vector<UInt8> >(mc);
|
addInternalExtract<UInt8, std::vector<UInt8> >(mc);
|
||||||
break;
|
break;
|
||||||
case MetaColumn::FDT_INT16:
|
case MetaColumn::FDT_INT16:
|
||||||
addInternalExtract<Int16, std::vector<Int16> >(mc);
|
addInternalExtract<Int16, std::vector<Int16> >(mc);
|
||||||
break;
|
break;
|
||||||
case MetaColumn::FDT_UINT16:
|
case MetaColumn::FDT_UINT16:
|
||||||
addInternalExtract<UInt16, std::vector<UInt16> >(mc);
|
addInternalExtract<UInt16, std::vector<UInt16> >(mc);
|
||||||
break;
|
break;
|
||||||
case MetaColumn::FDT_INT32:
|
case MetaColumn::FDT_INT32:
|
||||||
addInternalExtract<Int32, std::vector<Int32> >(mc);
|
addInternalExtract<Int32, std::vector<Int32> >(mc);
|
||||||
break;
|
break;
|
||||||
case MetaColumn::FDT_UINT32:
|
case MetaColumn::FDT_UINT32:
|
||||||
addInternalExtract<UInt32, std::vector<UInt32> >(mc);
|
addInternalExtract<UInt32, std::vector<UInt32> >(mc);
|
||||||
break;
|
break;
|
||||||
case MetaColumn::FDT_INT64:
|
case MetaColumn::FDT_INT64:
|
||||||
addInternalExtract<Int64, std::vector<Int64> >(mc);
|
addInternalExtract<Int64, std::vector<Int64> >(mc);
|
||||||
break;
|
break;
|
||||||
case MetaColumn::FDT_UINT64:
|
case MetaColumn::FDT_UINT64:
|
||||||
addInternalExtract<UInt64, std::vector<UInt64> >(mc);
|
addInternalExtract<UInt64, std::vector<UInt64> >(mc);
|
||||||
break;
|
break;
|
||||||
case MetaColumn::FDT_FLOAT:
|
case MetaColumn::FDT_FLOAT:
|
||||||
addInternalExtract<float, std::vector<float> >(mc);
|
addInternalExtract<float, std::vector<float> >(mc);
|
||||||
break;
|
break;
|
||||||
case MetaColumn::FDT_DOUBLE:
|
case MetaColumn::FDT_DOUBLE:
|
||||||
addInternalExtract<double, std::vector<double> >(mc);
|
addInternalExtract<double, std::vector<double> >(mc);
|
||||||
break;
|
break;
|
||||||
case MetaColumn::FDT_STRING:
|
case MetaColumn::FDT_STRING:
|
||||||
addInternalExtract<std::string, std::vector<std::string> >(mc);
|
addInternalExtract<std::string, std::vector<std::string> >(mc);
|
||||||
break;
|
break;
|
||||||
case MetaColumn::FDT_BLOB:
|
case MetaColumn::FDT_BLOB:
|
||||||
addInternalExtract<BLOB, std::vector<BLOB> >(mc);
|
addInternalExtract<BLOB, std::vector<BLOB> >(mc);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
throw Poco::InvalidArgumentException("Data type not supported.");
|
throw Poco::InvalidArgumentException("Data type not supported.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const MetaColumn& StatementImpl::metaColumn(const std::string& name) const
|
const MetaColumn& StatementImpl::metaColumn(const std::string& name) const
|
||||||
{
|
{
|
||||||
Poco::UInt32 cols = columnsReturned();
|
Poco::UInt32 cols = columnsReturned();
|
||||||
for (Poco::UInt32 i = 0; i < cols; ++i)
|
for (Poco::UInt32 i = 0; i < cols; ++i)
|
||||||
{
|
{
|
||||||
const MetaColumn& column = metaColumn(i);
|
const MetaColumn& column = metaColumn(i);
|
||||||
if (0 == icompare(column.name(), name)) return column;
|
if (0 == icompare(column.name(), name)) return column;
|
||||||
}
|
}
|
||||||
|
|
||||||
throw NotFoundException(format("Invalid column name: %s", name));
|
throw NotFoundException(format("Invalid column name: %s", name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} } // namespace Poco::Data
|
} } // namespace Poco::Data
|
||||||
|
|||||||
331
Data/testsuite/TestSuite_vs90.vcproj
Normal file
331
Data/testsuite/TestSuite_vs90.vcproj
Normal file
@@ -0,0 +1,331 @@
|
|||||||
|
<?xml version="1.0" encoding="Windows-1252"?>
|
||||||
|
<VisualStudioProject
|
||||||
|
ProjectType="Visual C++"
|
||||||
|
Version="9.00"
|
||||||
|
Name="TestSuite"
|
||||||
|
ProjectGUID="{24134877-368D-11DB-9FBC-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"
|
||||||
|
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="false"
|
||||||
|
DebugInformationFormat="4"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="CppUnitd.lib WinTestRunnerd.lib PocoFoundationd.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"
|
||||||
|
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="false"
|
||||||
|
DebugInformationFormat="3"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCManagedResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCResourceCompilerTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCPreLinkEventTool"
|
||||||
|
/>
|
||||||
|
<Tool
|
||||||
|
Name="VCLinkerTool"
|
||||||
|
AdditionalDependencies="CppUnit.lib WinTestRunner.lib PocoFoundation.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="DataCore"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\DataTest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\DataTest.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="_Suite"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\DataTestSuite.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\DataTestSuite.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="_Driver"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\WinDriver.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="TestSession"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Binder.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Connector.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Extractor.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Preparation.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SessionImpl.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\TestStatementImpl.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Binder.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Connector.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Extractor.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\Preparation.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SessionImpl.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\TestStatementImpl.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="SessionPooling"
|
||||||
|
>
|
||||||
|
<Filter
|
||||||
|
Name="Header Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SessionPoolTest.h"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
<Filter
|
||||||
|
Name="Source Files"
|
||||||
|
>
|
||||||
|
<File
|
||||||
|
RelativePath=".\src\SessionPoolTest.cpp"
|
||||||
|
>
|
||||||
|
</File>
|
||||||
|
</Filter>
|
||||||
|
</Filter>
|
||||||
|
</Files>
|
||||||
|
<Globals>
|
||||||
|
</Globals>
|
||||||
|
</VisualStudioProject>
|
||||||
@@ -1,124 +1,130 @@
|
|||||||
//
|
//
|
||||||
// Stopwatch.h
|
// Stopwatch.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Stopwatch.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Stopwatch.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: DateTime
|
// Package: DateTime
|
||||||
// Module: Stopwatch
|
// Module: Stopwatch
|
||||||
//
|
//
|
||||||
// Definition of the Stopwatch class.
|
// Definition of the Stopwatch class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2004-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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Foundation_Stopwatch_INCLUDED
|
#ifndef Foundation_Stopwatch_INCLUDED
|
||||||
#define Foundation_Stopwatch_INCLUDED
|
#define Foundation_Stopwatch_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Stopwatch
|
class Foundation_API Stopwatch
|
||||||
/// A simple facility to measure time intervals
|
/// A simple facility to measure time intervals
|
||||||
/// with microsecond resolution.
|
/// with microsecond resolution.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Stopwatch();
|
Stopwatch();
|
||||||
~Stopwatch();
|
~Stopwatch();
|
||||||
|
|
||||||
void start();
|
void start();
|
||||||
/// Starts (or restarts) the stopwatch.
|
/// Starts (or restarts) the stopwatch.
|
||||||
|
|
||||||
void stop();
|
void stop();
|
||||||
/// Stops or pauses the stopwatch.
|
/// Stops or pauses the stopwatch.
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
/// Resets the stopwatch.
|
/// Resets the stopwatch.
|
||||||
|
|
||||||
void restart();
|
void restart();
|
||||||
/// Resets and starts the stopwatch.
|
/// Resets and starts the stopwatch.
|
||||||
|
|
||||||
Timestamp::TimeDiff elapsed() const;
|
Timestamp::TimeDiff elapsed() const;
|
||||||
/// Returns the elapsed time in microseconds
|
/// Returns the elapsed time in microseconds
|
||||||
/// since the stopwatch started.
|
/// since the stopwatch started.
|
||||||
|
|
||||||
int elapsedSeconds() const;
|
int elapsedSeconds() const;
|
||||||
/// Returns the number of seconds elapsed
|
/// Returns the number of seconds elapsed
|
||||||
/// since the stopwatch started.
|
/// since the stopwatch started.
|
||||||
|
|
||||||
static Timestamp::TimeVal resolution();
|
static Timestamp::TimeVal resolution();
|
||||||
/// Returns the resolution of the stopwatch.
|
/// Returns the resolution of the stopwatch.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Stopwatch(const Stopwatch&);
|
Stopwatch(const Stopwatch&);
|
||||||
Stopwatch& operator = (const Stopwatch&);
|
Stopwatch& operator = (const Stopwatch&);
|
||||||
|
|
||||||
Timestamp _start;
|
Timestamp _start;
|
||||||
Timestamp::TimeDiff _elapsed;
|
Timestamp::TimeDiff _elapsed;
|
||||||
bool _running;
|
bool _running;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline void Stopwatch::start()
|
inline void Stopwatch::start()
|
||||||
{
|
{
|
||||||
_start.update();
|
if (!_running)
|
||||||
_running = true;
|
{
|
||||||
}
|
_start.update();
|
||||||
|
_running = true;
|
||||||
|
}
|
||||||
inline void Stopwatch::stop()
|
}
|
||||||
{
|
|
||||||
Timestamp current;
|
|
||||||
_elapsed += current - _start;
|
inline void Stopwatch::stop()
|
||||||
_running = false;
|
{
|
||||||
}
|
if (_running)
|
||||||
|
{
|
||||||
|
Timestamp current;
|
||||||
inline int Stopwatch::elapsedSeconds() const
|
_elapsed += current - _start;
|
||||||
{
|
_running = false;
|
||||||
return int(elapsed()/resolution());
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Timestamp::TimeVal Stopwatch::resolution()
|
inline int Stopwatch::elapsedSeconds() const
|
||||||
{
|
{
|
||||||
return Timestamp::resolution();
|
return int(elapsed()/resolution());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
inline Timestamp::TimeVal Stopwatch::resolution()
|
||||||
|
{
|
||||||
|
return Timestamp::resolution();
|
||||||
#endif // Foundation_Stopwatch_INCLUDED
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
|
#endif // Foundation_Stopwatch_INCLUDED
|
||||||
|
|||||||
@@ -1,315 +1,315 @@
|
|||||||
//
|
//
|
||||||
// EventLogChannel.cpp
|
// EventLogChannel.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/src/EventLogChannel.cpp#2 $
|
// $Id: //poco/1.3/Foundation/src/EventLogChannel.cpp#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Logging
|
// Package: Logging
|
||||||
// Module: EventLogChannel
|
// Module: EventLogChannel
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2004-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/EventLogChannel.h"
|
#include "Poco/EventLogChannel.h"
|
||||||
#include "Poco/Message.h"
|
#include "Poco/Message.h"
|
||||||
#include "Poco/String.h"
|
#include "Poco/String.h"
|
||||||
#include "pocomsg.h"
|
#include "pocomsg.h"
|
||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
#include "Poco/UnicodeConverter.h"
|
#include "Poco/UnicodeConverter.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
const std::string EventLogChannel::PROP_NAME = "name";
|
const std::string EventLogChannel::PROP_NAME = "name";
|
||||||
const std::string EventLogChannel::PROP_HOST = "host";
|
const std::string EventLogChannel::PROP_HOST = "host";
|
||||||
const std::string EventLogChannel::PROP_LOGHOST = "loghost";
|
const std::string EventLogChannel::PROP_LOGHOST = "loghost";
|
||||||
const std::string EventLogChannel::PROP_LOGFILE = "logfile";
|
const std::string EventLogChannel::PROP_LOGFILE = "logfile";
|
||||||
|
|
||||||
|
|
||||||
EventLogChannel::EventLogChannel():
|
EventLogChannel::EventLogChannel():
|
||||||
_logFile("Application"),
|
_logFile("Application"),
|
||||||
_h(0)
|
_h(0)
|
||||||
{
|
{
|
||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
wchar_t name[256];
|
wchar_t name[256];
|
||||||
int n = GetModuleFileNameW(NULL, name, sizeof(name));
|
int n = GetModuleFileNameW(NULL, name, sizeof(name));
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
{
|
||||||
wchar_t* end = name + n - 1;
|
wchar_t* end = name + n - 1;
|
||||||
while (end > name && *end != '\\') --end;
|
while (end > name && *end != '\\') --end;
|
||||||
if (*end == '\\') ++end;
|
if (*end == '\\') ++end;
|
||||||
std::wstring uname(end);
|
std::wstring uname(end);
|
||||||
UnicodeConverter::toUTF8(uname, _name);
|
UnicodeConverter::toUTF8(uname, _name);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
char name[256];
|
char name[256];
|
||||||
int n = GetModuleFileNameA(NULL, name, sizeof(name));
|
int n = GetModuleFileNameA(NULL, name, sizeof(name));
|
||||||
if (n > 0)
|
if (n > 0)
|
||||||
{
|
{
|
||||||
char* end = name + n - 1;
|
char* end = name + n - 1;
|
||||||
while (end > name && *end != '\\') --end;
|
while (end > name && *end != '\\') --end;
|
||||||
if (*end == '\\') ++end;
|
if (*end == '\\') ++end;
|
||||||
_name = end;
|
_name = end;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EventLogChannel::EventLogChannel(const std::string& name):
|
EventLogChannel::EventLogChannel(const std::string& name):
|
||||||
_name(name),
|
_name(name),
|
||||||
_logFile("Application"),
|
_logFile("Application"),
|
||||||
_h(0)
|
_h(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EventLogChannel::EventLogChannel(const std::string& name, const std::string& host):
|
EventLogChannel::EventLogChannel(const std::string& name, const std::string& host):
|
||||||
_name(name),
|
_name(name),
|
||||||
_host(host),
|
_host(host),
|
||||||
_logFile("Application"),
|
_logFile("Application"),
|
||||||
_h(0)
|
_h(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
EventLogChannel::~EventLogChannel()
|
EventLogChannel::~EventLogChannel()
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EventLogChannel::open()
|
void EventLogChannel::open()
|
||||||
{
|
{
|
||||||
setUpRegistry();
|
setUpRegistry();
|
||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
std::wstring uhost;
|
std::wstring uhost;
|
||||||
UnicodeConverter::toUTF16(_host, uhost);
|
UnicodeConverter::toUTF16(_host, uhost);
|
||||||
std::wstring uname;
|
std::wstring uname;
|
||||||
UnicodeConverter::toUTF16(_name, uname);
|
UnicodeConverter::toUTF16(_name, uname);
|
||||||
_h = RegisterEventSourceW(uhost.empty() ? NULL : uhost.c_str(), uname.c_str());
|
_h = RegisterEventSourceW(uhost.empty() ? NULL : uhost.c_str(), uname.c_str());
|
||||||
#else
|
#else
|
||||||
_h = RegisterEventSource(_host.empty() ? NULL : _host.c_str(), _name.c_str());
|
_h = RegisterEventSource(_host.empty() ? NULL : _host.c_str(), _name.c_str());
|
||||||
#endif
|
#endif
|
||||||
if (!_h) throw SystemException("cannot register event source");
|
if (!_h) throw SystemException("cannot register event source");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EventLogChannel::close()
|
void EventLogChannel::close()
|
||||||
{
|
{
|
||||||
if (_h) DeregisterEventSource(_h);
|
if (_h) DeregisterEventSource(_h);
|
||||||
_h = 0;
|
_h = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EventLogChannel::log(const Message& msg)
|
void EventLogChannel::log(const Message& msg)
|
||||||
{
|
{
|
||||||
if (!_h) open();
|
if (!_h) open();
|
||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
std::wstring utext;
|
std::wstring utext;
|
||||||
UnicodeConverter::toUTF16(msg.getText(), utext);
|
UnicodeConverter::toUTF16(msg.getText(), utext);
|
||||||
const wchar_t* pMsg = utext.c_str();
|
const wchar_t* pMsg = utext.c_str();
|
||||||
ReportEventW(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL);
|
ReportEventW(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL);
|
||||||
#else
|
#else
|
||||||
const char* pMsg = msg.getText().c_str();
|
const char* pMsg = msg.getText().c_str();
|
||||||
ReportEvent(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL);
|
ReportEvent(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EventLogChannel::setProperty(const std::string& name, const std::string& value)
|
void EventLogChannel::setProperty(const std::string& name, const std::string& value)
|
||||||
{
|
{
|
||||||
if (icompare(name, PROP_NAME) == 0)
|
if (icompare(name, PROP_NAME) == 0)
|
||||||
_name = value;
|
_name = value;
|
||||||
else if (icompare(name, PROP_HOST) == 0)
|
else if (icompare(name, PROP_HOST) == 0)
|
||||||
_host = value;
|
_host = value;
|
||||||
else if (icompare(name, PROP_LOGHOST) == 0)
|
else if (icompare(name, PROP_LOGHOST) == 0)
|
||||||
_host = value;
|
_host = value;
|
||||||
else if (icompare(name, PROP_LOGFILE) == 0)
|
else if (icompare(name, PROP_LOGFILE) == 0)
|
||||||
_logFile = value;
|
_logFile = value;
|
||||||
else
|
else
|
||||||
Channel::setProperty(name, value);
|
Channel::setProperty(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string EventLogChannel::getProperty(const std::string& name) const
|
std::string EventLogChannel::getProperty(const std::string& name) const
|
||||||
{
|
{
|
||||||
if (icompare(name, PROP_NAME) == 0)
|
if (icompare(name, PROP_NAME) == 0)
|
||||||
return _name;
|
return _name;
|
||||||
else if (icompare(name, PROP_HOST) == 0)
|
else if (icompare(name, PROP_HOST) == 0)
|
||||||
return _host;
|
return _host;
|
||||||
else if (icompare(name, PROP_LOGHOST) == 0)
|
else if (icompare(name, PROP_LOGHOST) == 0)
|
||||||
return _host;
|
return _host;
|
||||||
else if (icompare(name, PROP_LOGFILE) == 0)
|
else if (icompare(name, PROP_LOGFILE) == 0)
|
||||||
return _logFile;
|
return _logFile;
|
||||||
else
|
else
|
||||||
return Channel::getProperty(name);
|
return Channel::getProperty(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int EventLogChannel::getType(const Message& msg)
|
int EventLogChannel::getType(const Message& msg)
|
||||||
{
|
{
|
||||||
switch (msg.getPriority())
|
switch (msg.getPriority())
|
||||||
{
|
{
|
||||||
case Message::PRIO_TRACE:
|
case Message::PRIO_TRACE:
|
||||||
case Message::PRIO_DEBUG:
|
case Message::PRIO_DEBUG:
|
||||||
case Message::PRIO_INFORMATION:
|
case Message::PRIO_INFORMATION:
|
||||||
return EVENTLOG_INFORMATION_TYPE;
|
return EVENTLOG_INFORMATION_TYPE;
|
||||||
case Message::PRIO_NOTICE:
|
case Message::PRIO_NOTICE:
|
||||||
case Message::PRIO_WARNING:
|
case Message::PRIO_WARNING:
|
||||||
return EVENTLOG_WARNING_TYPE;
|
return EVENTLOG_WARNING_TYPE;
|
||||||
default:
|
default:
|
||||||
return EVENTLOG_ERROR_TYPE;
|
return EVENTLOG_ERROR_TYPE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int EventLogChannel::getCategory(const Message& msg)
|
int EventLogChannel::getCategory(const Message& msg)
|
||||||
{
|
{
|
||||||
switch (msg.getPriority())
|
switch (msg.getPriority())
|
||||||
{
|
{
|
||||||
case Message::PRIO_TRACE:
|
case Message::PRIO_TRACE:
|
||||||
return POCO_CTG_TRACE;
|
return POCO_CTG_TRACE;
|
||||||
case Message::PRIO_DEBUG:
|
case Message::PRIO_DEBUG:
|
||||||
return POCO_CTG_DEBUG;
|
return POCO_CTG_DEBUG;
|
||||||
case Message::PRIO_INFORMATION:
|
case Message::PRIO_INFORMATION:
|
||||||
return POCO_CTG_INFORMATION;
|
return POCO_CTG_INFORMATION;
|
||||||
case Message::PRIO_NOTICE:
|
case Message::PRIO_NOTICE:
|
||||||
return POCO_CTG_NOTICE;
|
return POCO_CTG_NOTICE;
|
||||||
case Message::PRIO_WARNING:
|
case Message::PRIO_WARNING:
|
||||||
return POCO_CTG_WARNING;
|
return POCO_CTG_WARNING;
|
||||||
case Message::PRIO_ERROR:
|
case Message::PRIO_ERROR:
|
||||||
return POCO_CTG_ERROR;
|
return POCO_CTG_ERROR;
|
||||||
case Message::PRIO_CRITICAL:
|
case Message::PRIO_CRITICAL:
|
||||||
return POCO_CTG_CRITICAL;
|
return POCO_CTG_CRITICAL;
|
||||||
case Message::PRIO_FATAL:
|
case Message::PRIO_FATAL:
|
||||||
return POCO_CTG_FATAL;
|
return POCO_CTG_FATAL;
|
||||||
default:
|
default:
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EventLogChannel::setUpRegistry() const
|
void EventLogChannel::setUpRegistry() const
|
||||||
{
|
{
|
||||||
std::string key = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\";
|
std::string key = "SYSTEM\\CurrentControlSet\\Services\\EventLog\\";
|
||||||
key.append(_logFile);
|
key.append(_logFile);
|
||||||
key.append("\\");
|
key.append("\\");
|
||||||
key.append(_name);
|
key.append(_name);
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
DWORD disp;
|
DWORD disp;
|
||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
std::wstring ukey;
|
std::wstring ukey;
|
||||||
UnicodeConverter::toUTF16(key, ukey);
|
UnicodeConverter::toUTF16(key, ukey);
|
||||||
DWORD rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, ukey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
|
DWORD rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, ukey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
|
||||||
#else
|
#else
|
||||||
DWORD rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE, key.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
|
DWORD rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE, key.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp);
|
||||||
#endif
|
#endif
|
||||||
if (rc != ERROR_SUCCESS) return;
|
if (rc != ERROR_SUCCESS) return;
|
||||||
|
|
||||||
if (disp == REG_CREATED_NEW_KEY)
|
if (disp == REG_CREATED_NEW_KEY)
|
||||||
{
|
{
|
||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
std::wstring path;
|
std::wstring path;
|
||||||
#if defined(POCO_DLL)
|
#if defined(POCO_DLL)
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
path = findLibrary(L"PocoFoundationd.dll");
|
path = findLibrary(L"PocoFoundationd.dll");
|
||||||
#else
|
#else
|
||||||
path = findLibrary(L"PocoFoundation.dll");
|
path = findLibrary(L"PocoFoundation.dll");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
path = findLibrary(L"PocoMsg.dll");
|
path = findLibrary(L"PocoMsg.dll");
|
||||||
#else
|
#else
|
||||||
std::string path;
|
std::string path;
|
||||||
#if defined(POCO_DLL)
|
#if defined(POCO_DLL)
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
path = findLibrary("PocoFoundationd.dll");
|
path = findLibrary("PocoFoundationd.dll");
|
||||||
#else
|
#else
|
||||||
path = findLibrary("PocoFoundation.dll");
|
path = findLibrary("PocoFoundation.dll");
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (path.empty())
|
if (path.empty())
|
||||||
path = findLibrary("PocoMsg.dll");
|
path = findLibrary("PocoMsg.dll");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (!path.empty())
|
if (!path.empty())
|
||||||
{
|
{
|
||||||
DWORD count = 8;
|
DWORD count = 8;
|
||||||
DWORD types = 7;
|
DWORD types = 7;
|
||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
RegSetValueExW(hKey, L"CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) path.size() + 1);
|
RegSetValueExW(hKey, L"CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) sizeof(wchar_t)*(path.size() + 1));
|
||||||
RegSetValueExW(hKey, L"EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) path.size() + 1);
|
RegSetValueExW(hKey, L"EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) sizeof(wchar_t)*(path.size() + 1));
|
||||||
RegSetValueExW(hKey, L"CategoryCount", 0, REG_DWORD, (const BYTE*) &count, (DWORD) sizeof(count));
|
RegSetValueExW(hKey, L"CategoryCount", 0, REG_DWORD, (const BYTE*) &count, (DWORD) sizeof(count));
|
||||||
RegSetValueExW(hKey, L"TypesSupported", 0, REG_DWORD, (const BYTE*) &types, (DWORD) sizeof(types));
|
RegSetValueExW(hKey, L"TypesSupported", 0, REG_DWORD, (const BYTE*) &types, (DWORD) sizeof(types));
|
||||||
#else
|
#else
|
||||||
RegSetValueEx(hKey, "CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) path.size() + 1);
|
RegSetValueEx(hKey, "CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) path.size() + 1);
|
||||||
RegSetValueEx(hKey, "EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) path.size() + 1);
|
RegSetValueEx(hKey, "EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), (DWORD) path.size() + 1);
|
||||||
RegSetValueEx(hKey, "CategoryCount", 0, REG_DWORD, (const BYTE*) &count, (DWORD) sizeof(count));
|
RegSetValueEx(hKey, "CategoryCount", 0, REG_DWORD, (const BYTE*) &count, (DWORD) sizeof(count));
|
||||||
RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, (const BYTE*) &types, (DWORD) sizeof(types));
|
RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, (const BYTE*) &types, (DWORD) sizeof(types));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RegCloseKey(hKey);
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
std::wstring EventLogChannel::findLibrary(const wchar_t* name)
|
std::wstring EventLogChannel::findLibrary(const wchar_t* name)
|
||||||
{
|
{
|
||||||
std::wstring path;
|
std::wstring path;
|
||||||
HMODULE dll = LoadLibraryW(name);
|
HMODULE dll = LoadLibraryW(name);
|
||||||
if (dll)
|
if (dll)
|
||||||
{
|
{
|
||||||
wchar_t name[MAX_PATH + 1];
|
wchar_t name[MAX_PATH + 1];
|
||||||
int n = GetModuleFileNameW(dll, name, sizeof(name));
|
int n = GetModuleFileNameW(dll, name, sizeof(name));
|
||||||
if (n > 0) path = name;
|
if (n > 0) path = name;
|
||||||
FreeLibrary(dll);
|
FreeLibrary(dll);
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
std::string EventLogChannel::findLibrary(const char* name)
|
std::string EventLogChannel::findLibrary(const char* name)
|
||||||
{
|
{
|
||||||
std::string path;
|
std::string path;
|
||||||
HMODULE dll = LoadLibraryA(name);
|
HMODULE dll = LoadLibraryA(name);
|
||||||
if (dll)
|
if (dll)
|
||||||
{
|
{
|
||||||
char name[MAX_PATH + 1];
|
char name[MAX_PATH + 1];
|
||||||
int n = GetModuleFileNameA(dll, name, sizeof(name));
|
int n = GetModuleFileNameA(dll, name, sizeof(name));
|
||||||
if (n > 0) path = name;
|
if (n > 0) path = name;
|
||||||
FreeLibrary(dll);
|
FreeLibrary(dll);
|
||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,165 +1,172 @@
|
|||||||
//
|
//
|
||||||
// NetworkInterface.h
|
// NetworkInterface.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Net/include/Poco/Net/NetworkInterface.h#2 $
|
// $Id: //poco/1.3/Net/include/Poco/Net/NetworkInterface.h#4 $
|
||||||
//
|
//
|
||||||
// Library: Net
|
// Library: Net
|
||||||
// Package: Sockets
|
// Package: Sockets
|
||||||
// Module: NetworkInterface
|
// Module: NetworkInterface
|
||||||
//
|
//
|
||||||
// Definition of the NetworkInterface class.
|
// Definition of the NetworkInterface class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2005-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.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Net_NetworkInterface_INCLUDED
|
#ifndef Net_NetworkInterface_INCLUDED
|
||||||
#define Net_NetworkInterface_INCLUDED
|
#define Net_NetworkInterface_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Net/Net.h"
|
#include "Poco/Net/Net.h"
|
||||||
#include "Poco/Net/IPAddress.h"
|
#include "Poco/Net/IPAddress.h"
|
||||||
#include "Poco/Mutex.h"
|
#include "Poco/Mutex.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
namespace Net {
|
namespace Net {
|
||||||
|
|
||||||
|
|
||||||
class NetworkInterfaceImpl;
|
class NetworkInterfaceImpl;
|
||||||
|
|
||||||
|
|
||||||
class Net_API NetworkInterface
|
class Net_API NetworkInterface
|
||||||
/// This class represents a network interface.
|
/// This class represents a network interface.
|
||||||
///
|
///
|
||||||
/// NetworkInterface is used with MulticastSocket to specify
|
/// NetworkInterface is used with MulticastSocket to specify
|
||||||
/// multicast interfaces for sending and receiving multicast
|
/// multicast interfaces for sending and receiving multicast
|
||||||
/// messages.
|
/// messages.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::vector<NetworkInterface> NetworkInterfaceList;
|
typedef std::vector<NetworkInterface> NetworkInterfaceList;
|
||||||
|
|
||||||
NetworkInterface();
|
NetworkInterface();
|
||||||
/// Creates a NetworkInterface representing the
|
/// Creates a NetworkInterface representing the
|
||||||
/// default interface.
|
/// default interface.
|
||||||
///
|
///
|
||||||
/// The name is empty, the IP address is the wildcard
|
/// The name is empty, the IP address is the wildcard
|
||||||
/// address and the index is zero.
|
/// address and the index is zero.
|
||||||
|
|
||||||
NetworkInterface(const NetworkInterface& interface);
|
NetworkInterface(const NetworkInterface& interface);
|
||||||
/// Creates the NetworkInterface by copying another one.
|
/// Creates the NetworkInterface by copying another one.
|
||||||
|
|
||||||
~NetworkInterface();
|
~NetworkInterface();
|
||||||
/// Destroys the NetworkInterface.
|
/// Destroys the NetworkInterface.
|
||||||
|
|
||||||
NetworkInterface& operator = (const NetworkInterface& interface);
|
NetworkInterface& operator = (const NetworkInterface& interface);
|
||||||
/// Assigns another NetworkInterface.
|
/// Assigns another NetworkInterface.
|
||||||
|
|
||||||
void swap(NetworkInterface& other);
|
void swap(NetworkInterface& other);
|
||||||
/// Swaps the NetworkInterface with another one.
|
/// Swaps the NetworkInterface with another one.
|
||||||
|
|
||||||
int index() const;
|
int index() const;
|
||||||
/// Returns the interface index.
|
/// Returns the interface index.
|
||||||
///
|
///
|
||||||
/// Only supported if IPv6 is available.
|
/// Only supported if IPv6 is available.
|
||||||
/// Returns -1 if IPv6 is not available.
|
/// Returns -1 if IPv6 is not available.
|
||||||
|
|
||||||
const std::string& name() const;
|
const std::string& name() const;
|
||||||
/// Returns the interface name.
|
/// Returns the interface name.
|
||||||
|
|
||||||
const IPAddress& address() const;
|
const std::string& displayName() const;
|
||||||
/// Returns the IP address bound to the interface.
|
/// Returns the interface display name.
|
||||||
|
///
|
||||||
const IPAddress& subnetMask() const;
|
/// On Windows platforms, this is the user-friendly interface
|
||||||
/// Returns the IPv4 subnet mask for this network interface.
|
/// name (e.g., "Local Area Connection"). On other platforms,
|
||||||
|
/// this is the same as name().
|
||||||
const IPAddress& broadcastAddress() const;
|
|
||||||
/// Returns the IPv4 broadcast address for this network interface.
|
const IPAddress& address() const;
|
||||||
|
/// Returns the IP address bound to the interface.
|
||||||
bool supportsIPv4() const;
|
|
||||||
/// Returns true if the interface supports IPv4.
|
const IPAddress& subnetMask() const;
|
||||||
|
/// Returns the IPv4 subnet mask for this network interface.
|
||||||
bool supportsIPv6() const;
|
|
||||||
/// Returns true if the interface supports IPv6.
|
const IPAddress& broadcastAddress() const;
|
||||||
|
/// Returns the IPv4 broadcast address for this network interface.
|
||||||
static NetworkInterface forName(const std::string& name, bool requireIPv6 = false);
|
|
||||||
/// Returns the NetworkInterface for the given name.
|
bool supportsIPv4() const;
|
||||||
///
|
/// Returns true if the interface supports IPv4.
|
||||||
/// If requireIPv6 is false, an IPv4 interface is returned.
|
|
||||||
/// Otherwise, an IPv6 interface is returned.
|
bool supportsIPv6() const;
|
||||||
///
|
/// Returns true if the interface supports IPv6.
|
||||||
/// Throws an InterfaceNotFoundException if an interface
|
|
||||||
/// with the give name does not exist.
|
static NetworkInterface forName(const std::string& name, bool requireIPv6 = false);
|
||||||
|
/// Returns the NetworkInterface for the given name.
|
||||||
static NetworkInterface forAddress(const IPAddress& address);
|
///
|
||||||
/// Returns the NetworkInterface for the given IP address.
|
/// If requireIPv6 is false, an IPv4 interface is returned.
|
||||||
///
|
/// Otherwise, an IPv6 interface is returned.
|
||||||
/// Throws an InterfaceNotFoundException if an interface
|
///
|
||||||
/// with the give address does not exist.
|
/// Throws an InterfaceNotFoundException if an interface
|
||||||
|
/// with the give name does not exist.
|
||||||
static NetworkInterface forIndex(int index);
|
|
||||||
/// Returns the NetworkInterface for the given interface index.
|
static NetworkInterface forAddress(const IPAddress& address);
|
||||||
/// If an index of 0 is specified, a NetworkInterface instance
|
/// Returns the NetworkInterface for the given IP address.
|
||||||
/// representing the default interface (empty name and
|
///
|
||||||
/// wildcard address) is returned.
|
/// Throws an InterfaceNotFoundException if an interface
|
||||||
///
|
/// with the give address does not exist.
|
||||||
/// Throws an InterfaceNotFoundException if an interface
|
|
||||||
/// with the given index does not exist (or IPv6 is not
|
static NetworkInterface forIndex(int index);
|
||||||
/// available).
|
/// Returns the NetworkInterface for the given interface index.
|
||||||
|
/// If an index of 0 is specified, a NetworkInterface instance
|
||||||
static NetworkInterfaceList list();
|
/// representing the default interface (empty name and
|
||||||
/// Returns a list with all network interfaces
|
/// wildcard address) is returned.
|
||||||
/// on the system.
|
///
|
||||||
///
|
/// Throws an InterfaceNotFoundException if an interface
|
||||||
/// If there are multiple addresses bound to one interface,
|
/// with the given index does not exist (or IPv6 is not
|
||||||
/// multiple NetworkInterface instances are created for
|
/// available).
|
||||||
/// the same interface.
|
|
||||||
|
static NetworkInterfaceList list();
|
||||||
protected:
|
/// Returns a list with all network interfaces
|
||||||
NetworkInterface(const std::string& name, const IPAddress& address, int index = -1);
|
/// on the system.
|
||||||
/// Creates the NetworkInterface.
|
///
|
||||||
|
/// If there are multiple addresses bound to one interface,
|
||||||
NetworkInterface(const std::string& name, const IPAddress& address, const IPAddress& subnetMask, const IPAddress& broadcastAddress, int index = -1);
|
/// multiple NetworkInterface instances are created for
|
||||||
/// Creates the NetworkInterface.
|
/// the same interface.
|
||||||
|
|
||||||
IPAddress interfaceNameToAddress(const std::string& interfaceName) const;
|
protected:
|
||||||
/// Determines the IPAddress bound to the interface with the given name.
|
NetworkInterface(const std::string& name, const std::string& displayName, const IPAddress& address, int index = -1);
|
||||||
|
/// Creates the NetworkInterface.
|
||||||
int interfaceNameToIndex(const std::string& interfaceName) const;
|
|
||||||
/// Determines the interface index of the interface with the given name.
|
NetworkInterface(const std::string& name, const std::string& displayName, const IPAddress& address, const IPAddress& subnetMask, const IPAddress& broadcastAddress, int index = -1);
|
||||||
|
/// Creates the NetworkInterface.
|
||||||
private:
|
|
||||||
NetworkInterfaceImpl* _pImpl;
|
IPAddress interfaceNameToAddress(const std::string& interfaceName) const;
|
||||||
|
/// Determines the IPAddress bound to the interface with the given name.
|
||||||
static Poco::FastMutex _mutex;
|
|
||||||
};
|
int interfaceNameToIndex(const std::string& interfaceName) const;
|
||||||
|
/// Determines the interface index of the interface with the given name.
|
||||||
|
|
||||||
} } // namespace Poco::Net
|
private:
|
||||||
|
NetworkInterfaceImpl* _pImpl;
|
||||||
|
|
||||||
#endif // Net_NetworkInterface_INCLUDED
|
static Poco::FastMutex _mutex;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
} } // namespace Poco::Net
|
||||||
|
|
||||||
|
|
||||||
|
#endif // Net_NetworkInterface_INCLUDED
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,123 +1,124 @@
|
|||||||
//
|
//
|
||||||
// NetworkInterfaceTest.cpp
|
// NetworkInterfaceTest.cpp
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Net/testsuite/src/NetworkInterfaceTest.cpp#2 $
|
// $Id: //poco/1.3/Net/testsuite/src/NetworkInterfaceTest.cpp#3 $
|
||||||
//
|
//
|
||||||
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2005-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 "NetworkInterfaceTest.h"
|
#include "NetworkInterfaceTest.h"
|
||||||
#include "CppUnit/TestCaller.h"
|
#include "CppUnit/TestCaller.h"
|
||||||
#include "CppUnit/TestSuite.h"
|
#include "CppUnit/TestSuite.h"
|
||||||
#include "Poco/Net/NetworkInterface.h"
|
#include "Poco/Net/NetworkInterface.h"
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
|
||||||
using Poco::Net::NetworkInterface;
|
using Poco::Net::NetworkInterface;
|
||||||
|
|
||||||
|
|
||||||
NetworkInterfaceTest::NetworkInterfaceTest(const std::string& name): CppUnit::TestCase(name)
|
NetworkInterfaceTest::NetworkInterfaceTest(const std::string& name): CppUnit::TestCase(name)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
NetworkInterfaceTest::~NetworkInterfaceTest()
|
NetworkInterfaceTest::~NetworkInterfaceTest()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void NetworkInterfaceTest::testList()
|
void NetworkInterfaceTest::testList()
|
||||||
{
|
{
|
||||||
NetworkInterface::NetworkInterfaceList list = NetworkInterface::list();
|
NetworkInterface::NetworkInterfaceList list = NetworkInterface::list();
|
||||||
assert (!list.empty());
|
assert (!list.empty());
|
||||||
for (NetworkInterface::NetworkInterfaceList::const_iterator it = list.begin(); it != list.end(); ++it)
|
for (NetworkInterface::NetworkInterfaceList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||||
{
|
{
|
||||||
std::cout << "Name: " << it->name() << std::endl;
|
std::cout << "Name: " << it->name() << std::endl;
|
||||||
std::cout << "Address: " << it->address().toString() << std::endl;
|
std::cout << "DisplayName: " << it->displayName() << std::endl;
|
||||||
std::cout << "Subnet: " << it->subnetMask().toString() << std::endl;
|
std::cout << "Address: " << it->address().toString() << std::endl;
|
||||||
std::cout << "Broadcast: " << it->broadcastAddress().toString() << std::endl;
|
std::cout << "Subnet: " << it->subnetMask().toString() << std::endl;
|
||||||
std::cout << "Index: " << it->index() << std::endl;
|
std::cout << "Broadcast: " << it->broadcastAddress().toString() << std::endl;
|
||||||
}
|
std::cout << "Index: " << it->index() << std::endl;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkInterfaceTest::testForName()
|
|
||||||
{
|
void NetworkInterfaceTest::testForName()
|
||||||
NetworkInterface::NetworkInterfaceList list = NetworkInterface::list();
|
{
|
||||||
for (NetworkInterface::NetworkInterfaceList::const_iterator it = list.begin(); it != list.end(); ++it)
|
NetworkInterface::NetworkInterfaceList list = NetworkInterface::list();
|
||||||
{
|
for (NetworkInterface::NetworkInterfaceList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||||
NetworkInterface ifc = NetworkInterface::forName(it->name());
|
{
|
||||||
assert (ifc.name() == it->name());
|
NetworkInterface ifc = NetworkInterface::forName(it->name());
|
||||||
}
|
assert (ifc.name() == it->name());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkInterfaceTest::testForAddress()
|
|
||||||
{
|
void NetworkInterfaceTest::testForAddress()
|
||||||
NetworkInterface::NetworkInterfaceList list = NetworkInterface::list();
|
{
|
||||||
for (NetworkInterface::NetworkInterfaceList::const_iterator it = list.begin(); it != list.end(); ++it)
|
NetworkInterface::NetworkInterfaceList list = NetworkInterface::list();
|
||||||
{
|
for (NetworkInterface::NetworkInterfaceList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||||
NetworkInterface ifc = NetworkInterface::forAddress(it->address());
|
{
|
||||||
assert (ifc.address() == it->address());
|
NetworkInterface ifc = NetworkInterface::forAddress(it->address());
|
||||||
}
|
assert (ifc.address() == it->address());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkInterfaceTest::testForIndex()
|
|
||||||
{
|
void NetworkInterfaceTest::testForIndex()
|
||||||
#if defined(POCO_HAVE_IPv6)
|
{
|
||||||
NetworkInterface::NetworkInterfaceList list = NetworkInterface::list();
|
#if defined(POCO_HAVE_IPv6)
|
||||||
for (NetworkInterface::NetworkInterfaceList::const_iterator it = list.begin(); it != list.end(); ++it)
|
NetworkInterface::NetworkInterfaceList list = NetworkInterface::list();
|
||||||
{
|
for (NetworkInterface::NetworkInterfaceList::const_iterator it = list.begin(); it != list.end(); ++it)
|
||||||
NetworkInterface ifc = NetworkInterface::forIndex(it->index());
|
{
|
||||||
assert (ifc.index() == it->index());
|
NetworkInterface ifc = NetworkInterface::forIndex(it->index());
|
||||||
}
|
assert (ifc.index() == it->index());
|
||||||
#endif
|
}
|
||||||
}
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkInterfaceTest::setUp()
|
|
||||||
{
|
void NetworkInterfaceTest::setUp()
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void NetworkInterfaceTest::tearDown()
|
|
||||||
{
|
void NetworkInterfaceTest::tearDown()
|
||||||
}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
CppUnit::Test* NetworkInterfaceTest::suite()
|
|
||||||
{
|
CppUnit::Test* NetworkInterfaceTest::suite()
|
||||||
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NetworkInterfaceTest");
|
{
|
||||||
|
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("NetworkInterfaceTest");
|
||||||
CppUnit_addTest(pSuite, NetworkInterfaceTest, testList);
|
|
||||||
CppUnit_addTest(pSuite, NetworkInterfaceTest, testForName);
|
CppUnit_addTest(pSuite, NetworkInterfaceTest, testList);
|
||||||
CppUnit_addTest(pSuite, NetworkInterfaceTest, testForAddress);
|
CppUnit_addTest(pSuite, NetworkInterfaceTest, testForName);
|
||||||
CppUnit_addTest(pSuite, NetworkInterfaceTest, testForIndex);
|
CppUnit_addTest(pSuite, NetworkInterfaceTest, testForAddress);
|
||||||
|
CppUnit_addTest(pSuite, NetworkInterfaceTest, testForIndex);
|
||||||
return pSuite;
|
|
||||||
}
|
return pSuite;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user