mirror of
https://github.com/Telecominfraproject/wlan-cloud-lib-poco.git
synced 2025-11-02 03:27:56 +00:00
fixed line endings
This commit is contained in:
@@ -1,63 +1,63 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<?eclipse-cdt version="2.0"?>
|
<?eclipse-cdt version="2.0"?>
|
||||||
|
|
||||||
<cdtproject id="org.eclipse.cdt.make.core.make">
|
<cdtproject id="org.eclipse.cdt.make.core.make">
|
||||||
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser">
|
<extension id="org.eclipse.cdt.core.Cygwin_PE" point="org.eclipse.cdt.core.BinaryParser">
|
||||||
<attribute key="addr2line" value="addr2line"/>
|
<attribute key="addr2line" value="addr2line"/>
|
||||||
<attribute key="cygpath" value="cygpath"/>
|
<attribute key="cygpath" value="cygpath"/>
|
||||||
<attribute key="c++filt" value="c++filt"/>
|
<attribute key="c++filt" value="c++filt"/>
|
||||||
<attribute key="nm" value="nm"/>
|
<attribute key="nm" value="nm"/>
|
||||||
</extension>
|
</extension>
|
||||||
<data>
|
<data>
|
||||||
<item id="scannerConfiguration">
|
<item id="scannerConfiguration">
|
||||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
|
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
|
||||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||||
<buildOutputProvider>
|
<buildOutputProvider>
|
||||||
<openAction enabled="true" filePath=""/>
|
<openAction enabled="true" filePath=""/>
|
||||||
<parser enabled="true"/>
|
<parser enabled="true"/>
|
||||||
</buildOutputProvider>
|
</buildOutputProvider>
|
||||||
<scannerInfoProvider id="specsFile">
|
<scannerInfoProvider id="specsFile">
|
||||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||||
<parser enabled="true"/>
|
<parser enabled="true"/>
|
||||||
</scannerInfoProvider>
|
</scannerInfoProvider>
|
||||||
</profile>
|
</profile>
|
||||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||||
<buildOutputProvider>
|
<buildOutputProvider>
|
||||||
<openAction enabled="false" filePath=""/>
|
<openAction enabled="false" filePath=""/>
|
||||||
<parser enabled="true"/>
|
<parser enabled="true"/>
|
||||||
</buildOutputProvider>
|
</buildOutputProvider>
|
||||||
<scannerInfoProvider id="makefileGenerator">
|
<scannerInfoProvider id="makefileGenerator">
|
||||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||||
<parser enabled="false"/>
|
<parser enabled="false"/>
|
||||||
</scannerInfoProvider>
|
</scannerInfoProvider>
|
||||||
</profile>
|
</profile>
|
||||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||||
<buildOutputProvider>
|
<buildOutputProvider>
|
||||||
<openAction enabled="false" filePath=""/>
|
<openAction enabled="false" filePath=""/>
|
||||||
<parser enabled="true"/>
|
<parser enabled="true"/>
|
||||||
</buildOutputProvider>
|
</buildOutputProvider>
|
||||||
<scannerInfoProvider id="specsFile">
|
<scannerInfoProvider id="specsFile">
|
||||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||||
<parser enabled="false"/>
|
<parser enabled="false"/>
|
||||||
</scannerInfoProvider>
|
</scannerInfoProvider>
|
||||||
</profile>
|
</profile>
|
||||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||||
<buildOutputProvider>
|
<buildOutputProvider>
|
||||||
<openAction enabled="false" filePath=""/>
|
<openAction enabled="false" filePath=""/>
|
||||||
<parser enabled="true"/>
|
<parser enabled="true"/>
|
||||||
</buildOutputProvider>
|
</buildOutputProvider>
|
||||||
<scannerInfoProvider id="specsFile">
|
<scannerInfoProvider id="specsFile">
|
||||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||||
<parser enabled="false"/>
|
<parser enabled="false"/>
|
||||||
</scannerInfoProvider>
|
</scannerInfoProvider>
|
||||||
</profile>
|
</profile>
|
||||||
</item>
|
</item>
|
||||||
<item id="org.eclipse.cdt.core.pathentry">
|
<item id="org.eclipse.cdt.core.pathentry">
|
||||||
<pathentry excluding="*.vmsbuild|*.sln|*.vcproj|*.ncb|*.suo|*.vcproj.*|include/|src/|testsuite/src/" kind="src" path=""/>
|
<pathentry excluding="*.vmsbuild|*.sln|*.vcproj|*.ncb|*.suo|*.vcproj.*|include/|src/|testsuite/src/" kind="src" path=""/>
|
||||||
<pathentry kind="src" path="include"/>
|
<pathentry kind="src" path="include"/>
|
||||||
<pathentry kind="src" path="src"/>
|
<pathentry kind="src" path="src"/>
|
||||||
<pathentry kind="out" path=""/>
|
<pathentry kind="out" path=""/>
|
||||||
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
|
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
|
||||||
</item>
|
</item>
|
||||||
</data>
|
</data>
|
||||||
</cdtproject>
|
</cdtproject>
|
||||||
|
|||||||
@@ -1,86 +1,86 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<projectDescription>
|
<projectDescription>
|
||||||
<name>Foundation</name>
|
<name>Foundation</name>
|
||||||
<comment></comment>
|
<comment></comment>
|
||||||
<projects>
|
<projects>
|
||||||
</projects>
|
</projects>
|
||||||
<buildSpec>
|
<buildSpec>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.cdt.make.core.makeBuilder</name>
|
<name>org.eclipse.cdt.make.core.makeBuilder</name>
|
||||||
<triggers>clean,full,incremental,</triggers>
|
<triggers>clean,full,incremental,</triggers>
|
||||||
<arguments>
|
<arguments>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.build.arguments</key>
|
<key>org.eclipse.cdt.make.core.build.arguments</key>
|
||||||
<value></value>
|
<value></value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.core.errorOutputParser</key>
|
<key>org.eclipse.cdt.core.errorOutputParser</key>
|
||||||
<value>org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;</value>
|
<value>org.eclipse.cdt.core.MakeErrorParser;org.eclipse.cdt.core.GCCErrorParser;org.eclipse.cdt.core.GASErrorParser;org.eclipse.cdt.core.GLDErrorParser;org.eclipse.cdt.core.VCErrorParser;</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.environment</key>
|
<key>org.eclipse.cdt.make.core.environment</key>
|
||||||
<value></value>
|
<value></value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
<key>org.eclipse.cdt.make.core.enableAutoBuild</key>
|
||||||
<value>false</value>
|
<value>false</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.build.target.inc</key>
|
<key>org.eclipse.cdt.make.core.build.target.inc</key>
|
||||||
<value>-s</value>
|
<value>-s</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
<key>org.eclipse.cdt.make.core.enableFullBuild</key>
|
||||||
<value>true</value>
|
<value>true</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>
|
<key>org.eclipse.cdt.make.core.enabledIncrementalBuild</key>
|
||||||
<value>true</value>
|
<value>true</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.build.location</key>
|
<key>org.eclipse.cdt.make.core.build.location</key>
|
||||||
<value></value>
|
<value></value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.build.command</key>
|
<key>org.eclipse.cdt.make.core.build.command</key>
|
||||||
<value>make</value>
|
<value>make</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.build.target.clean</key>
|
<key>org.eclipse.cdt.make.core.build.target.clean</key>
|
||||||
<value>clean</value>
|
<value>clean</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
<key>org.eclipse.cdt.make.core.enableCleanBuild</key>
|
||||||
<value>true</value>
|
<value>true</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.append_environment</key>
|
<key>org.eclipse.cdt.make.core.append_environment</key>
|
||||||
<value>true</value>
|
<value>true</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
<key>org.eclipse.cdt.make.core.useDefaultBuildCmd</key>
|
||||||
<value>true</value>
|
<value>true</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.build.target.auto</key>
|
<key>org.eclipse.cdt.make.core.build.target.auto</key>
|
||||||
<value>all</value>
|
<value>all</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
<dictionary>
|
<dictionary>
|
||||||
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
<key>org.eclipse.cdt.make.core.stopOnError</key>
|
||||||
<value>true</value>
|
<value>true</value>
|
||||||
</dictionary>
|
</dictionary>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
<buildCommand>
|
<buildCommand>
|
||||||
<name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name>
|
<name>org.eclipse.cdt.make.core.ScannerConfigBuilder</name>
|
||||||
<arguments>
|
<arguments>
|
||||||
</arguments>
|
</arguments>
|
||||||
</buildCommand>
|
</buildCommand>
|
||||||
</buildSpec>
|
</buildSpec>
|
||||||
<natures>
|
<natures>
|
||||||
<nature>org.eclipse.cdt.core.cnature</nature>
|
<nature>org.eclipse.cdt.core.cnature</nature>
|
||||||
<nature>org.eclipse.cdt.make.core.makeNature</nature>
|
<nature>org.eclipse.cdt.make.core.makeNature</nature>
|
||||||
<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>
|
<nature>org.eclipse.cdt.make.core.ScannerConfigNature</nature>
|
||||||
<nature>org.eclipse.cdt.core.ccnature</nature>
|
<nature>org.eclipse.cdt.core.ccnature</nature>
|
||||||
</natures>
|
</natures>
|
||||||
</projectDescription>
|
</projectDescription>
|
||||||
|
|||||||
@@ -1,66 +1,66 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 8.00
|
Microsoft Visual Studio Solution File, Format Version 8.00
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Foundation", "Foundation_vs71.vcproj", "{8164D41D-B053-405B-826C-CF37AC0EF176}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Foundation", "Foundation_vs71.vcproj", "{8164D41D-B053-405B-826C-CF37AC0EF176}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs71.vcproj", "{F1EE93DF-347F-4CB3-B191-C4E63F38E972}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs71.vcproj", "{F1EE93DF-347F-4CB3-B191-C4E63F38E972}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F} = {0955EB03-544B-4BD4-9C10-89CF38078F5F}
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F} = {0955EB03-544B-4BD4-9C10-89CF38078F5F}
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176} = {8164D41D-B053-405B-826C-CF37AC0EF176}
|
{8164D41D-B053-405B-826C-CF37AC0EF176} = {8164D41D-B053-405B-826C-CF37AC0EF176}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLibrary", "testsuite\TestLibrary_vs71.vcproj", "{0955EB03-544B-4BD4-9C10-89CF38078F5F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLibrary", "testsuite\TestLibrary_vs71.vcproj", "{0955EB03-544B-4BD4-9C10-89CF38078F5F}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176} = {8164D41D-B053-405B-826C-CF37AC0EF176}
|
{8164D41D-B053-405B-826C-CF37AC0EF176} = {8164D41D-B053-405B-826C-CF37AC0EF176}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestApp", "testsuite\TestApp_vs71.vcproj", "{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestApp", "testsuite\TestApp_vs71.vcproj", "{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfiguration) = preSolution
|
GlobalSection(SolutionConfiguration) = preSolution
|
||||||
debug_shared = debug_shared
|
debug_shared = debug_shared
|
||||||
debug_static = debug_static
|
debug_static = debug_static
|
||||||
release_shared = release_shared
|
release_shared = release_shared
|
||||||
release_static = release_static
|
release_static = release_static
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfiguration) = postSolution
|
GlobalSection(ProjectConfiguration) = postSolution
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_shared.ActiveCfg = debug_shared|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_shared.ActiveCfg = debug_shared|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_shared.Build.0 = debug_shared|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_shared.Build.0 = debug_shared|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_static.ActiveCfg = debug_static|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_static.ActiveCfg = debug_static|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_static.Build.0 = debug_static|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_static.Build.0 = debug_static|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_shared.ActiveCfg = release_shared|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_shared.ActiveCfg = release_shared|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_shared.Build.0 = release_shared|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_shared.Build.0 = release_shared|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_static.ActiveCfg = release_static|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_static.ActiveCfg = release_static|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_static.Build.0 = release_static|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_static.Build.0 = release_static|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_shared.ActiveCfg = debug_shared|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_shared.ActiveCfg = debug_shared|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_shared.Build.0 = debug_shared|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_shared.Build.0 = debug_shared|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static.ActiveCfg = debug_static|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static.ActiveCfg = debug_static|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static.Build.0 = debug_static|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static.Build.0 = debug_static|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_shared.ActiveCfg = release_shared|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_shared.ActiveCfg = release_shared|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_shared.Build.0 = release_shared|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_shared.Build.0 = release_shared|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static.ActiveCfg = release_static|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static.ActiveCfg = release_static|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static.Build.0 = release_static|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static.Build.0 = release_static|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_shared.ActiveCfg = debug_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_shared.ActiveCfg = debug_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_shared.Build.0 = debug_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_shared.Build.0 = debug_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_static.ActiveCfg = debug_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_static.ActiveCfg = debug_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_static.Build.0 = debug_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_static.Build.0 = debug_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_shared.ActiveCfg = release_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_shared.ActiveCfg = release_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_shared.Build.0 = release_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_shared.Build.0 = release_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_static.ActiveCfg = release_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_static.ActiveCfg = release_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_static.Build.0 = release_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_static.Build.0 = release_shared|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_shared.ActiveCfg = debug_shared|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_shared.ActiveCfg = debug_shared|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_shared.Build.0 = debug_shared|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_shared.Build.0 = debug_shared|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_static.ActiveCfg = debug_static|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_static.ActiveCfg = debug_static|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_static.Build.0 = debug_static|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_static.Build.0 = debug_static|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_shared.ActiveCfg = release_shared|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_shared.ActiveCfg = release_shared|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_shared.Build.0 = release_shared|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_shared.Build.0 = release_shared|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_static.ActiveCfg = release_static|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_static.ActiveCfg = release_static|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_static.Build.0 = release_static|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_static.Build.0 = release_static|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityAddIns) = postSolution
|
GlobalSection(ExtensibilityAddIns) = postSolution
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -1,63 +1,63 @@
|
|||||||
Microsoft Visual Studio Solution File, Format Version 9.00
|
Microsoft Visual Studio Solution File, Format Version 9.00
|
||||||
# Visual Studio 2005
|
# Visual Studio 2005
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Foundation", "Foundation_vs80.vcproj", "{8164D41D-B053-405B-826C-CF37AC0EF176}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Foundation", "Foundation_vs80.vcproj", "{8164D41D-B053-405B-826C-CF37AC0EF176}"
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs80.vcproj", "{F1EE93DF-347F-4CB3-B191-C4E63F38E972}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs80.vcproj", "{F1EE93DF-347F-4CB3-B191-C4E63F38E972}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F} = {0955EB03-544B-4BD4-9C10-89CF38078F5F}
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F} = {0955EB03-544B-4BD4-9C10-89CF38078F5F}
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176} = {8164D41D-B053-405B-826C-CF37AC0EF176}
|
{8164D41D-B053-405B-826C-CF37AC0EF176} = {8164D41D-B053-405B-826C-CF37AC0EF176}
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A} = {6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A} = {6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLibrary", "testsuite\TestLibrary_vs80.vcproj", "{0955EB03-544B-4BD4-9C10-89CF38078F5F}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestLibrary", "testsuite\TestLibrary_vs80.vcproj", "{0955EB03-544B-4BD4-9C10-89CF38078F5F}"
|
||||||
ProjectSection(ProjectDependencies) = postProject
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176} = {8164D41D-B053-405B-826C-CF37AC0EF176}
|
{8164D41D-B053-405B-826C-CF37AC0EF176} = {8164D41D-B053-405B-826C-CF37AC0EF176}
|
||||||
EndProjectSection
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestApp", "testsuite\TestApp_vs80.vcproj", "{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}"
|
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestApp", "testsuite\TestApp_vs80.vcproj", "{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}"
|
||||||
EndProject
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
debug_shared|Win32 = debug_shared|Win32
|
debug_shared|Win32 = debug_shared|Win32
|
||||||
debug_static|Win32 = debug_static|Win32
|
debug_static|Win32 = debug_static|Win32
|
||||||
release_shared|Win32 = release_shared|Win32
|
release_shared|Win32 = release_shared|Win32
|
||||||
release_static|Win32 = release_static|Win32
|
release_static|Win32 = release_static|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_static|Win32.ActiveCfg = debug_static|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_static|Win32.ActiveCfg = debug_static|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_static|Win32.Build.0 = debug_static|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.debug_static|Win32.Build.0 = debug_static|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_shared|Win32.Build.0 = release_shared|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_static|Win32.ActiveCfg = release_static|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_static|Win32.ActiveCfg = release_static|Win32
|
||||||
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_static|Win32.Build.0 = release_static|Win32
|
{8164D41D-B053-405B-826C-CF37AC0EF176}.release_static|Win32.Build.0 = release_static|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static|Win32.ActiveCfg = debug_static|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static|Win32.ActiveCfg = debug_static|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static|Win32.Build.0 = debug_static|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.debug_static|Win32.Build.0 = debug_static|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_shared|Win32.Build.0 = release_shared|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static|Win32.ActiveCfg = release_static|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static|Win32.ActiveCfg = release_static|Win32
|
||||||
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static|Win32.Build.0 = release_static|Win32
|
{F1EE93DF-347F-4CB3-B191-C4E63F38E972}.release_static|Win32.Build.0 = release_static|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_static|Win32.ActiveCfg = debug_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_static|Win32.ActiveCfg = debug_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_static|Win32.Build.0 = debug_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.debug_static|Win32.Build.0 = debug_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_shared|Win32.Build.0 = release_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_static|Win32.ActiveCfg = release_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_static|Win32.ActiveCfg = release_shared|Win32
|
||||||
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_static|Win32.Build.0 = release_shared|Win32
|
{0955EB03-544B-4BD4-9C10-89CF38078F5F}.release_static|Win32.Build.0 = release_shared|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_shared|Win32.Build.0 = debug_shared|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_static|Win32.ActiveCfg = debug_static|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_static|Win32.ActiveCfg = debug_static|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_static|Win32.Build.0 = debug_static|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.debug_static|Win32.Build.0 = debug_static|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_shared|Win32.ActiveCfg = release_shared|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_shared|Win32.Build.0 = release_shared|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_shared|Win32.Build.0 = release_shared|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_static|Win32.ActiveCfg = release_static|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_static|Win32.ActiveCfg = release_static|Win32
|
||||||
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_static|Win32.Build.0 = release_static|Win32
|
{6C41E55D-C0FC-4E01-AA8D-B7DA40E31D3A}.release_static|Win32.Build.0 = release_static|Win32
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|||||||
@@ -1,127 +1,127 @@
|
|||||||
#
|
#
|
||||||
# Foundation.vmsbuild
|
# Foundation.vmsbuild
|
||||||
#
|
#
|
||||||
# $Id: //poco/Foundation/foundation.vmsbuild#8 $
|
# $Id: //poco/Foundation/foundation.vmsbuild#8 $
|
||||||
#
|
#
|
||||||
LIB=PocoFoundation
|
LIB=PocoFoundation
|
||||||
ASCIIEncoding
|
ASCIIEncoding
|
||||||
AsyncChannel
|
AsyncChannel
|
||||||
Base64Decoder
|
Base64Decoder
|
||||||
Base64Encoder
|
Base64Encoder
|
||||||
BinaryReader
|
BinaryReader
|
||||||
BinaryWriter
|
BinaryWriter
|
||||||
Bugcheck
|
Bugcheck
|
||||||
ByteOrder
|
ByteOrder
|
||||||
Channel
|
Channel
|
||||||
Checksum
|
Checksum
|
||||||
Configurable
|
Configurable
|
||||||
ConsoleChannel
|
ConsoleChannel
|
||||||
CountingStream
|
CountingStream
|
||||||
DateTime
|
DateTime
|
||||||
LocalDateTime
|
LocalDateTime
|
||||||
DateTimeFormat
|
DateTimeFormat
|
||||||
DateTimeFormatter
|
DateTimeFormatter
|
||||||
DateTimeParser
|
DateTimeParser
|
||||||
Debugger
|
Debugger
|
||||||
DeflatingStream
|
DeflatingStream
|
||||||
DigestEngine
|
DigestEngine
|
||||||
DigestStream
|
DigestStream
|
||||||
DirectoryIterator
|
DirectoryIterator
|
||||||
Environment
|
Environment
|
||||||
Event
|
Event
|
||||||
EventArgs
|
EventArgs
|
||||||
Exception
|
Exception
|
||||||
FPEnvironment
|
FPEnvironment
|
||||||
File
|
File
|
||||||
Glob
|
Glob
|
||||||
FileChannel
|
FileChannel
|
||||||
Formatter
|
Formatter
|
||||||
FormattingChannel
|
FormattingChannel
|
||||||
HashStatistic
|
HashStatistic
|
||||||
HexBinaryDecoder
|
HexBinaryDecoder
|
||||||
HexBinaryEncoder
|
HexBinaryEncoder
|
||||||
InflatingStream
|
InflatingStream
|
||||||
Latin1Encoding
|
Latin1Encoding
|
||||||
Latin9Encoding
|
Latin9Encoding
|
||||||
Logger
|
Logger
|
||||||
LoggingFactory
|
LoggingFactory
|
||||||
LoggingRegistry
|
LoggingRegistry
|
||||||
NamedEvent
|
NamedEvent
|
||||||
NamedMutex
|
NamedMutex
|
||||||
NullChannel
|
NullChannel
|
||||||
MD2Engine
|
MD2Engine
|
||||||
MD4Engine
|
MD4Engine
|
||||||
MD5Engine
|
MD5Engine
|
||||||
Manifest
|
Manifest
|
||||||
Message
|
Message
|
||||||
Mutex
|
Mutex
|
||||||
NestedDiagnosticContext
|
NestedDiagnosticContext
|
||||||
Notification
|
Notification
|
||||||
NotificationCenter
|
NotificationCenter
|
||||||
NotificationQueue
|
NotificationQueue
|
||||||
NullStream
|
NullStream
|
||||||
NumberFormatter
|
NumberFormatter
|
||||||
NumberParser
|
NumberParser
|
||||||
Observer
|
Observer
|
||||||
Path
|
Path
|
||||||
PatternFormatter
|
PatternFormatter
|
||||||
Process
|
Process
|
||||||
RWLock
|
RWLock
|
||||||
Random
|
Random
|
||||||
RandomStream
|
RandomStream
|
||||||
RegularExpression
|
RegularExpression
|
||||||
RefCountedObject
|
RefCountedObject
|
||||||
Runnable
|
Runnable
|
||||||
SHA1Engine
|
SHA1Engine
|
||||||
Semaphore
|
Semaphore
|
||||||
SharedLibrary
|
SharedLibrary
|
||||||
SignalHandler
|
SignalHandler
|
||||||
SplitterChannel
|
SplitterChannel
|
||||||
Stopwatch
|
Stopwatch
|
||||||
StreamChannel
|
StreamChannel
|
||||||
StreamConverter
|
StreamConverter
|
||||||
StreamCopier
|
StreamCopier
|
||||||
StreamTokenizer
|
StreamTokenizer
|
||||||
String
|
String
|
||||||
StringTokenizer
|
StringTokenizer
|
||||||
SynchronizedObject
|
SynchronizedObject
|
||||||
SyslogChannel
|
SyslogChannel
|
||||||
Task
|
Task
|
||||||
TaskManager
|
TaskManager
|
||||||
TaskNotification
|
TaskNotification
|
||||||
TemporaryFile
|
TemporaryFile
|
||||||
TextConverter
|
TextConverter
|
||||||
TextEncoding
|
TextEncoding
|
||||||
TextIterator
|
TextIterator
|
||||||
Thread
|
Thread
|
||||||
ThreadLocal
|
ThreadLocal
|
||||||
ThreadPool
|
ThreadPool
|
||||||
Timer
|
Timer
|
||||||
Timespan
|
Timespan
|
||||||
Timestamp
|
Timestamp
|
||||||
Timezone
|
Timezone
|
||||||
Token
|
Token
|
||||||
URI
|
URI
|
||||||
URIFileStreamFactory
|
URIFileStreamFactory
|
||||||
URIStreamFactory
|
URIStreamFactory
|
||||||
URIStreamOpener
|
URIStreamOpener
|
||||||
UTF16Encoding
|
UTF16Encoding
|
||||||
UTF8Encoding
|
UTF8Encoding
|
||||||
UUID
|
UUID
|
||||||
UUIDGenerator
|
UUIDGenerator
|
||||||
adler32
|
adler32
|
||||||
chartables
|
chartables
|
||||||
compress
|
compress
|
||||||
crc32
|
crc32
|
||||||
deflate
|
deflate
|
||||||
get
|
get
|
||||||
gzio
|
gzio
|
||||||
infback
|
infback
|
||||||
inffast
|
inffast
|
||||||
inflate
|
inflate
|
||||||
inftrees
|
inftrees
|
||||||
maketables
|
maketables
|
||||||
pcre
|
pcre
|
||||||
study
|
study
|
||||||
trees
|
trees
|
||||||
zutil
|
zutil
|
||||||
|
|||||||
@@ -1,71 +1,71 @@
|
|||||||
//
|
//
|
||||||
// ASCIIEncoding.h
|
// ASCIIEncoding.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ASCIIEncoding.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ASCIIEncoding.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Text
|
// Package: Text
|
||||||
// Module: ASCIIEncoding
|
// Module: ASCIIEncoding
|
||||||
//
|
//
|
||||||
// Definition of the ASCIIEncoding class.
|
// Definition of the ASCIIEncoding class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2004-2007, 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_ASCIIEncoding_INCLUDED
|
#ifndef Foundation_ASCIIEncoding_INCLUDED
|
||||||
#define Foundation_ASCIIEncoding_INCLUDED
|
#define Foundation_ASCIIEncoding_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/TextEncoding.h"
|
#include "Poco/TextEncoding.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API ASCIIEncoding: public TextEncoding
|
class Foundation_API ASCIIEncoding: public TextEncoding
|
||||||
/// 7-bit ASCII text encoding.
|
/// 7-bit ASCII text encoding.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ASCIIEncoding();
|
ASCIIEncoding();
|
||||||
~ASCIIEncoding();
|
~ASCIIEncoding();
|
||||||
const char* canonicalName() const;
|
const char* canonicalName() const;
|
||||||
bool isA(const std::string& encodingName) const;
|
bool isA(const std::string& encodingName) const;
|
||||||
const CharacterMap& characterMap() const;
|
const CharacterMap& characterMap() const;
|
||||||
int convert(const unsigned char* bytes) const;
|
int convert(const unsigned char* bytes) const;
|
||||||
int convert(int ch, unsigned char* bytes, int length) const;
|
int convert(int ch, unsigned char* bytes, int length) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const char* _names[];
|
static const char* _names[];
|
||||||
static const CharacterMap _charMap;
|
static const CharacterMap _charMap;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_ASCIIEncoding_INCLUDED
|
#endif // Foundation_ASCIIEncoding_INCLUDED
|
||||||
|
|||||||
@@ -1,315 +1,315 @@
|
|||||||
//
|
//
|
||||||
// AbstractCache.h
|
// AbstractCache.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/AbstractCache.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/AbstractCache.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
// Module: AbstractCache
|
// Module: AbstractCache
|
||||||
//
|
//
|
||||||
// Definition of the AbstractCache class.
|
// Definition of the AbstractCache 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 Foundation_AbstractCache_INCLUDED
|
#ifndef Foundation_AbstractCache_INCLUDED
|
||||||
#define Foundation_AbstractCache_INCLUDED
|
#define Foundation_AbstractCache_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/KeyValueArgs.h"
|
#include "Poco/KeyValueArgs.h"
|
||||||
#include "Poco/ValidArgs.h"
|
#include "Poco/ValidArgs.h"
|
||||||
#include "Poco/Mutex.h"
|
#include "Poco/Mutex.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include "Poco/FIFOEvent.h"
|
#include "Poco/FIFOEvent.h"
|
||||||
#include "Poco/EventArgs.h"
|
#include "Poco/EventArgs.h"
|
||||||
#include "Poco/Delegate.h"
|
#include "Poco/Delegate.h"
|
||||||
#include "Poco/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TKey, class TValue, class TStrategy>
|
template <class TKey, class TValue, class TStrategy>
|
||||||
class AbstractCache
|
class AbstractCache
|
||||||
/// An AbstractCache is the interface of all caches.
|
/// An AbstractCache is the interface of all caches.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FIFOEvent<const KeyValueArgs<TKey, TValue > > Add;
|
FIFOEvent<const KeyValueArgs<TKey, TValue > > Add;
|
||||||
FIFOEvent<const TKey> Remove;
|
FIFOEvent<const TKey> Remove;
|
||||||
FIFOEvent<const TKey> Get;
|
FIFOEvent<const TKey> Get;
|
||||||
FIFOEvent<const EventArgs> Clear;
|
FIFOEvent<const EventArgs> Clear;
|
||||||
|
|
||||||
typedef std::map<TKey, SharedPtr<TValue > > DataHolder;
|
typedef std::map<TKey, SharedPtr<TValue > > DataHolder;
|
||||||
typedef typename DataHolder::iterator Iterator;
|
typedef typename DataHolder::iterator Iterator;
|
||||||
typedef typename DataHolder::const_iterator ConstIterator;
|
typedef typename DataHolder::const_iterator ConstIterator;
|
||||||
typedef std::set<TKey> KeySet;
|
typedef std::set<TKey> KeySet;
|
||||||
|
|
||||||
AbstractCache()
|
AbstractCache()
|
||||||
{
|
{
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractCache(const TStrategy& strat): _strategy(strat)
|
AbstractCache(const TStrategy& strat): _strategy(strat)
|
||||||
{
|
{
|
||||||
initialize();
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~AbstractCache()
|
virtual ~AbstractCache()
|
||||||
{
|
{
|
||||||
uninitialize();
|
uninitialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(const TKey& key, const TValue& val)
|
void add(const TKey& key, const TValue& val)
|
||||||
/// Adds the key value pair to the cache.
|
/// Adds the key value pair to the cache.
|
||||||
/// If for the key already an entry exists, it will be overwritten.
|
/// If for the key already an entry exists, it will be overwritten.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
doAdd(key, val);
|
doAdd(key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(const TKey& key, SharedPtr<TValue > val)
|
void add(const TKey& key, SharedPtr<TValue > val)
|
||||||
/// Adds the key value pair to the cache. Note that adding a NULL SharedPtr will fail!
|
/// Adds the key value pair to the cache. Note that adding a NULL SharedPtr will fail!
|
||||||
/// If for the key already an entry exists, it will be overwritten.
|
/// If for the key already an entry exists, it will be overwritten.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
doAdd(key, val);
|
doAdd(key, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(const TKey& key)
|
void remove(const TKey& key)
|
||||||
/// Removes an entry from the cache. If the entry is not found,
|
/// Removes an entry from the cache. If the entry is not found,
|
||||||
/// the remove is ignored.
|
/// the remove is ignored.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
Iterator it = _data.find(key);
|
Iterator it = _data.find(key);
|
||||||
doRemove(it);
|
doRemove(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool has(const TKey& key) const
|
bool has(const TKey& key) const
|
||||||
/// Returns true if the cache contains a value for the key.
|
/// Returns true if the cache contains a value for the key.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
return doHas(key);
|
return doHas(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPtr<TValue> get(const TKey& key)
|
SharedPtr<TValue> get(const TKey& key)
|
||||||
/// Returns a SharedPtr of the value. The SharedPointer will remain valid
|
/// Returns a SharedPtr of the value. The SharedPointer will remain valid
|
||||||
/// even when cache replacement removes the element.
|
/// even when cache replacement removes the element.
|
||||||
/// If for the key no value exists, an empty SharedPtr is returned.
|
/// If for the key no value exists, an empty SharedPtr is returned.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
return doGet (key);
|
return doGet (key);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
/// Removes all elements from the cache.
|
/// Removes all elements from the cache.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
doClear();
|
doClear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t size()
|
std::size_t size()
|
||||||
/// Returns the number of cached elements
|
/// Returns the number of cached elements
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
doReplace();
|
doReplace();
|
||||||
return _data.size();
|
return _data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void forceReplace()
|
void forceReplace()
|
||||||
/// Forces cache replacement. Note that Poco's cache strategy use for efficiency reason no background thread
|
/// Forces cache replacement. Note that Poco's cache strategy use for efficiency reason no background thread
|
||||||
/// which periodically triggers cache replacement. Cache Replacement is only started when the cache is modified
|
/// which periodically triggers cache replacement. Cache Replacement is only started when the cache is modified
|
||||||
/// from outside, i.e. add is called, or when a user tries to access an cache element via get.
|
/// from outside, i.e. add is called, or when a user tries to access an cache element via get.
|
||||||
/// In some cases, i.e. expire based caching where for a long time no access to the cache happens,
|
/// In some cases, i.e. expire based caching where for a long time no access to the cache happens,
|
||||||
/// it might be desirable to be able to trigger cache replacement manually.
|
/// it might be desirable to be able to trigger cache replacement manually.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
doReplace();
|
doReplace();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<TKey> getAllKeys()
|
std::set<TKey> getAllKeys()
|
||||||
/// Returns a copy of all keys stored in the cache
|
/// Returns a copy of all keys stored in the cache
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
doReplace();
|
doReplace();
|
||||||
ConstIterator it = _data.begin();
|
ConstIterator it = _data.begin();
|
||||||
ConstIterator itEnd = _data.end();
|
ConstIterator itEnd = _data.end();
|
||||||
std::set<TKey> result;
|
std::set<TKey> result;
|
||||||
for (; it != itEnd; ++it)
|
for (; it != itEnd; ++it)
|
||||||
result.insert(it->first);
|
result.insert(it->first);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mutable FIFOEvent<ValidArgs<TKey> > IsValid;
|
mutable FIFOEvent<ValidArgs<TKey> > IsValid;
|
||||||
mutable FIFOEvent<KeySet> Replace;
|
mutable FIFOEvent<KeySet> Replace;
|
||||||
|
|
||||||
void initialize()
|
void initialize()
|
||||||
/// Sets up event registration.
|
/// Sets up event registration.
|
||||||
{
|
{
|
||||||
Add += Delegate<TStrategy, const KeyValueArgs<TKey, TValue> >(&_strategy, &TStrategy::onAdd);
|
Add += Delegate<TStrategy, const KeyValueArgs<TKey, TValue> >(&_strategy, &TStrategy::onAdd);
|
||||||
Remove += Delegate<TStrategy, const TKey>(&_strategy, &TStrategy::onRemove);
|
Remove += Delegate<TStrategy, const TKey>(&_strategy, &TStrategy::onRemove);
|
||||||
Get += Delegate<TStrategy, const TKey>(&_strategy, &TStrategy::onGet);
|
Get += Delegate<TStrategy, const TKey>(&_strategy, &TStrategy::onGet);
|
||||||
Clear += Delegate<TStrategy, const EventArgs>(&_strategy, &TStrategy::onClear);
|
Clear += Delegate<TStrategy, const EventArgs>(&_strategy, &TStrategy::onClear);
|
||||||
IsValid += Delegate<TStrategy, ValidArgs<TKey> >(&_strategy, &TStrategy::onIsValid);
|
IsValid += Delegate<TStrategy, ValidArgs<TKey> >(&_strategy, &TStrategy::onIsValid);
|
||||||
Replace += Delegate<TStrategy, KeySet>(&_strategy, &TStrategy::onReplace);
|
Replace += Delegate<TStrategy, KeySet>(&_strategy, &TStrategy::onReplace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uninitialize()
|
void uninitialize()
|
||||||
/// Reverts event registration.
|
/// Reverts event registration.
|
||||||
{
|
{
|
||||||
Add -= Delegate<TStrategy, const KeyValueArgs<TKey, TValue> >(&_strategy, &TStrategy::onAdd );
|
Add -= Delegate<TStrategy, const KeyValueArgs<TKey, TValue> >(&_strategy, &TStrategy::onAdd );
|
||||||
Remove -= Delegate<TStrategy, const TKey>(&_strategy, &TStrategy::onRemove);
|
Remove -= Delegate<TStrategy, const TKey>(&_strategy, &TStrategy::onRemove);
|
||||||
Get -= Delegate<TStrategy, const TKey>(&_strategy, &TStrategy::onGet);
|
Get -= Delegate<TStrategy, const TKey>(&_strategy, &TStrategy::onGet);
|
||||||
Clear -= Delegate<TStrategy, const EventArgs>(&_strategy, &TStrategy::onClear);
|
Clear -= Delegate<TStrategy, const EventArgs>(&_strategy, &TStrategy::onClear);
|
||||||
IsValid -= Delegate<TStrategy, ValidArgs<TKey> >(&_strategy, &TStrategy::onIsValid);
|
IsValid -= Delegate<TStrategy, ValidArgs<TKey> >(&_strategy, &TStrategy::onIsValid);
|
||||||
Replace -= Delegate<TStrategy, KeySet>(&_strategy, &TStrategy::onReplace);
|
Replace -= Delegate<TStrategy, KeySet>(&_strategy, &TStrategy::onReplace);
|
||||||
}
|
}
|
||||||
|
|
||||||
void doAdd(const TKey& key, const TValue& val)
|
void doAdd(const TKey& key, const TValue& val)
|
||||||
/// Adds the key value pair to the cache.
|
/// Adds the key value pair to the cache.
|
||||||
/// If for the key already an entry exists, it will be overwritten.
|
/// If for the key already an entry exists, it will be overwritten.
|
||||||
{
|
{
|
||||||
Iterator it = _data.find(key);
|
Iterator it = _data.find(key);
|
||||||
doRemove(it);
|
doRemove(it);
|
||||||
|
|
||||||
KeyValueArgs<TKey, TValue> args(key, val);
|
KeyValueArgs<TKey, TValue> args(key, val);
|
||||||
Add.notify(this, args);
|
Add.notify(this, args);
|
||||||
_data.insert(std::make_pair(key, SharedPtr<TValue>(new TValue(val))));
|
_data.insert(std::make_pair(key, SharedPtr<TValue>(new TValue(val))));
|
||||||
|
|
||||||
doReplace();
|
doReplace();
|
||||||
}
|
}
|
||||||
|
|
||||||
void doAdd(const TKey& key, SharedPtr<TValue>& val)
|
void doAdd(const TKey& key, SharedPtr<TValue>& val)
|
||||||
/// Adds the key value pair to the cache.
|
/// Adds the key value pair to the cache.
|
||||||
/// If for the key already an entry exists, it will be overwritten.
|
/// If for the key already an entry exists, it will be overwritten.
|
||||||
{
|
{
|
||||||
Iterator it = _data.find(key);
|
Iterator it = _data.find(key);
|
||||||
doRemove(it);
|
doRemove(it);
|
||||||
|
|
||||||
KeyValueArgs<TKey, TValue> args(key, *val);
|
KeyValueArgs<TKey, TValue> args(key, *val);
|
||||||
Add.notify(this, args);
|
Add.notify(this, args);
|
||||||
_data.insert(std::make_pair(key, val));
|
_data.insert(std::make_pair(key, val));
|
||||||
|
|
||||||
doReplace();
|
doReplace();
|
||||||
}
|
}
|
||||||
|
|
||||||
void doRemove(Iterator it)
|
void doRemove(Iterator it)
|
||||||
/// Removes an entry from the cache. If the entry is not found
|
/// Removes an entry from the cache. If the entry is not found
|
||||||
/// the remove is ignored.
|
/// the remove is ignored.
|
||||||
{
|
{
|
||||||
if (it != _data.end())
|
if (it != _data.end())
|
||||||
{
|
{
|
||||||
Remove.notify(this, it->first);
|
Remove.notify(this, it->first);
|
||||||
_data.erase(it);
|
_data.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doHas(const TKey& key) const
|
bool doHas(const TKey& key) const
|
||||||
/// Returns true if the cache contains a value for the key
|
/// Returns true if the cache contains a value for the key
|
||||||
{
|
{
|
||||||
// ask the strategy if the key is valid
|
// ask the strategy if the key is valid
|
||||||
ConstIterator it = _data.find(key);
|
ConstIterator it = _data.find(key);
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
if (it != _data.end())
|
if (it != _data.end())
|
||||||
{
|
{
|
||||||
ValidArgs<TKey> args(key);
|
ValidArgs<TKey> args(key);
|
||||||
IsValid.notify(this, args);
|
IsValid.notify(this, args);
|
||||||
result = args.isValid();
|
result = args.isValid();
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
SharedPtr<TValue> doGet(const TKey& key)
|
SharedPtr<TValue> doGet(const TKey& key)
|
||||||
/// Returns a SharedPtr of the cache entry, returns 0 if for
|
/// Returns a SharedPtr of the cache entry, returns 0 if for
|
||||||
/// the key no value was found
|
/// the key no value was found
|
||||||
{
|
{
|
||||||
Iterator it = _data.find(key);
|
Iterator it = _data.find(key);
|
||||||
SharedPtr<TValue> result;
|
SharedPtr<TValue> result;
|
||||||
|
|
||||||
if (it != _data.end())
|
if (it != _data.end())
|
||||||
{
|
{
|
||||||
// inform all strategies that a read-access to an element happens
|
// inform all strategies that a read-access to an element happens
|
||||||
Get.notify(this, key);
|
Get.notify(this, key);
|
||||||
// ask all strategies if the key is valid
|
// ask all strategies if the key is valid
|
||||||
ValidArgs<TKey> args(key);
|
ValidArgs<TKey> args(key);
|
||||||
IsValid.notify(this, args);
|
IsValid.notify(this, args);
|
||||||
|
|
||||||
if (!args.isValid())
|
if (!args.isValid())
|
||||||
{
|
{
|
||||||
doRemove(it);
|
doRemove(it);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = it->second;
|
result = it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doClear()
|
void doClear()
|
||||||
{
|
{
|
||||||
static EventArgs _emptyArgs;
|
static EventArgs _emptyArgs;
|
||||||
Clear.notify(this, _emptyArgs);
|
Clear.notify(this, _emptyArgs);
|
||||||
_data.clear();
|
_data.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void doReplace()
|
void doReplace()
|
||||||
{
|
{
|
||||||
std::set<TKey> delMe;
|
std::set<TKey> delMe;
|
||||||
Replace.notify(this, delMe);
|
Replace.notify(this, delMe);
|
||||||
// delMe contains the to be removed elements
|
// delMe contains the to be removed elements
|
||||||
typename std::set<TKey>::const_iterator it = delMe.begin();
|
typename std::set<TKey>::const_iterator it = delMe.begin();
|
||||||
typename std::set<TKey>::const_iterator endIt = delMe.end();
|
typename std::set<TKey>::const_iterator endIt = delMe.end();
|
||||||
|
|
||||||
for (; it != endIt; ++it)
|
for (; it != endIt; ++it)
|
||||||
{
|
{
|
||||||
Iterator itH = _data.find(*it);
|
Iterator itH = _data.find(*it);
|
||||||
doRemove(itH);
|
doRemove(itH);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TStrategy _strategy;
|
TStrategy _strategy;
|
||||||
mutable DataHolder _data;
|
mutable DataHolder _data;
|
||||||
mutable FastMutex _mutex;
|
mutable FastMutex _mutex;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractCache(const AbstractCache& aCache);
|
AbstractCache(const AbstractCache& aCache);
|
||||||
AbstractCache& operator = (const AbstractCache& aCache);
|
AbstractCache& operator = (const AbstractCache& aCache);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,96 +1,96 @@
|
|||||||
//
|
//
|
||||||
// AbstractDelegate.h
|
// AbstractDelegate.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/AbstractDelegate.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/AbstractDelegate.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
// Module: AbstractDelegate
|
// Module: AbstractDelegate
|
||||||
//
|
//
|
||||||
// Implementation of the AbstractDelegate template.
|
// Implementation of the AbstractDelegate template.
|
||||||
//
|
//
|
||||||
// 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 Foundation_AbstractDelegate_INCLUDED
|
#ifndef Foundation_AbstractDelegate_INCLUDED
|
||||||
#define Foundation_AbstractDelegate_INCLUDED
|
#define Foundation_AbstractDelegate_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TArgs>
|
template <class TArgs>
|
||||||
class AbstractDelegate
|
class AbstractDelegate
|
||||||
/// Interface for Delegate and Expire
|
/// Interface for Delegate and Expire
|
||||||
/// Very similar to AbstractPriorityDelegate but having two separate files (no inheritance)
|
/// Very similar to AbstractPriorityDelegate but having two separate files (no inheritance)
|
||||||
/// allows one to have compile-time checks when registering an observer
|
/// allows one to have compile-time checks when registering an observer
|
||||||
/// instead of run-time checks.
|
/// instead of run-time checks.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AbstractDelegate(void* pTarget): _pTarget(pTarget)
|
AbstractDelegate(void* pTarget): _pTarget(pTarget)
|
||||||
{
|
{
|
||||||
poco_assert_dbg (_pTarget != 0);
|
poco_assert_dbg (_pTarget != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractDelegate(const AbstractDelegate& del):_pTarget(del._pTarget)
|
AbstractDelegate(const AbstractDelegate& del):_pTarget(del._pTarget)
|
||||||
{
|
{
|
||||||
poco_assert_dbg (_pTarget != 0);
|
poco_assert_dbg (_pTarget != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~AbstractDelegate()
|
virtual ~AbstractDelegate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool notify(const void* sender, TArgs& arguments) = 0;
|
virtual bool notify(const void* sender, TArgs& arguments) = 0;
|
||||||
/// Returns false, if the Delegate is no longer valid, thus indicating an expire
|
/// Returns false, if the Delegate is no longer valid, thus indicating an expire
|
||||||
|
|
||||||
virtual AbstractDelegate* clone() const = 0;
|
virtual AbstractDelegate* clone() const = 0;
|
||||||
/// Returns a deep-copy of the AbstractDelegate
|
/// Returns a deep-copy of the AbstractDelegate
|
||||||
|
|
||||||
bool operator < (const AbstractDelegate<TArgs>& other) const
|
bool operator < (const AbstractDelegate<TArgs>& other) const
|
||||||
/// For comparing AbstractDelegates in a collection.
|
/// For comparing AbstractDelegates in a collection.
|
||||||
{
|
{
|
||||||
return _pTarget < other._pTarget;
|
return _pTarget < other._pTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
void* target() const
|
void* target() const
|
||||||
{
|
{
|
||||||
return _pTarget;
|
return _pTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void* _pTarget;
|
void* _pTarget;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,312 +1,312 @@
|
|||||||
//
|
//
|
||||||
// AbstractEvent.h
|
// AbstractEvent.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/AbstractEvent.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/AbstractEvent.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
// Module: AbstractEvent
|
// Module: AbstractEvent
|
||||||
//
|
//
|
||||||
// Definition of the AbstractEvent class.
|
// Definition of the AbstractEvent 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 Foundation_AbstractFoundation_INCLUDED
|
#ifndef Foundation_AbstractFoundation_INCLUDED
|
||||||
#define Foundation_AbstractFoundation_INCLUDED
|
#define Foundation_AbstractFoundation_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/SingletonHolder.h"
|
#include "Poco/SingletonHolder.h"
|
||||||
#include "Poco/SharedPtr.h"
|
#include "Poco/SharedPtr.h"
|
||||||
#include "Poco/ActiveResult.h"
|
#include "Poco/ActiveResult.h"
|
||||||
#include "Poco/ActiveMethod.h"
|
#include "Poco/ActiveMethod.h"
|
||||||
#include "Poco/Mutex.h"
|
#include "Poco/Mutex.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TArgs, class TStrategy, class TDelegate>
|
template <class TArgs, class TStrategy, class TDelegate>
|
||||||
class AbstractEvent
|
class AbstractEvent
|
||||||
/// An abstractEvent is the super-class of all events.
|
/// An abstractEvent is the super-class of all events.
|
||||||
/// It works similar to the way C# handles notifications (aka events in C#).
|
/// It works similar to the way C# handles notifications (aka events in C#).
|
||||||
/// Events can be used to send information to a set of observers
|
/// Events can be used to send information to a set of observers
|
||||||
/// which are registered at the event. The type of the data is specified with
|
/// which are registered at the event. The type of the data is specified with
|
||||||
/// the template parameter TArgs. The TStrategy parameter must be a subclass
|
/// the template parameter TArgs. The TStrategy parameter must be a subclass
|
||||||
/// of NotificationStrategy. The parameter TDelegate can either be a subclass of AbstractDelegate
|
/// of NotificationStrategy. The parameter TDelegate can either be a subclass of AbstractDelegate
|
||||||
/// or of PriorityAbstractDelegate.
|
/// or of PriorityAbstractDelegate.
|
||||||
///
|
///
|
||||||
/// Note that AbstractEvent should never be used directly. One ought to use
|
/// Note that AbstractEvent should never be used directly. One ought to use
|
||||||
/// one of its subclasses which set the TStrategy and TDelegate template parameters
|
/// one of its subclasses which set the TStrategy and TDelegate template parameters
|
||||||
/// to fixed values. For most use-cases the BasicEvent template will be sufficient.
|
/// to fixed values. For most use-cases the BasicEvent template will be sufficient.
|
||||||
///
|
///
|
||||||
/// Use events by adding them as public members to the object which is throwing notifications:
|
/// Use events by adding them as public members to the object which is throwing notifications:
|
||||||
///
|
///
|
||||||
/// class MyData
|
/// class MyData
|
||||||
/// {
|
/// {
|
||||||
/// public:
|
/// public:
|
||||||
/// Poco::BasicEvent<int> AgeChanged;
|
/// Poco::BasicEvent<int> AgeChanged;
|
||||||
///
|
///
|
||||||
/// MyData();
|
/// MyData();
|
||||||
/// ...
|
/// ...
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
/// Throwing the event can be done either by the events notify() or notifyAsync() method:
|
/// Throwing the event can be done either by the events notify() or notifyAsync() method:
|
||||||
///
|
///
|
||||||
///
|
///
|
||||||
/// Alternatively, instead of notify(), operator () can be used.
|
/// Alternatively, instead of notify(), operator () can be used.
|
||||||
///
|
///
|
||||||
/// void MyData::setAge(int i)
|
/// void MyData::setAge(int i)
|
||||||
/// {
|
/// {
|
||||||
/// this->_age = i;
|
/// this->_age = i;
|
||||||
/// AgeChanged(this, this->_age);
|
/// AgeChanged(this, this->_age);
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// Note that notify and notifyAsync do not catch exceptions, i.e. in case a delegate
|
/// Note that notify and notifyAsync do not catch exceptions, i.e. in case a delegate
|
||||||
/// throws an exception, the notify is immediately aborted and the exception is thrown
|
/// throws an exception, the notify is immediately aborted and the exception is thrown
|
||||||
/// back to the caller.
|
/// back to the caller.
|
||||||
///
|
///
|
||||||
/// Delegates can register methods at the event. In the case of a BasicEvent or FIFOEvent
|
/// Delegates can register methods at the event. In the case of a BasicEvent or FIFOEvent
|
||||||
/// the Delegate template is used, in case of an PriorityEvent a PriorityDelegate is used.
|
/// the Delegate template is used, in case of an PriorityEvent a PriorityDelegate is used.
|
||||||
/// Mixing of observers, e.g. using a PriorityDelegate with a BasicEvent is not possible and
|
/// Mixing of observers, e.g. using a PriorityDelegate with a BasicEvent is not possible and
|
||||||
/// checked for during compile time.
|
/// checked for during compile time.
|
||||||
/// Events require the observers to follow the following method signature:
|
/// Events require the observers to follow the following method signature:
|
||||||
///
|
///
|
||||||
/// void onEvent(const void* pSender, TArgs& args);
|
/// void onEvent(const void* pSender, TArgs& args);
|
||||||
///
|
///
|
||||||
/// For performance reasons arguments are always sent by reference. This also allows observers
|
/// For performance reasons arguments are always sent by reference. This also allows observers
|
||||||
/// to modify the sent argument. To prevent that, use <const TArg> as template
|
/// to modify the sent argument. To prevent that, use <const TArg> as template
|
||||||
/// parameter. A non-conformant method signature leads to compile errors.
|
/// parameter. A non-conformant method signature leads to compile errors.
|
||||||
///
|
///
|
||||||
/// Assuming that the observer meets the method signature requirement, it can register
|
/// Assuming that the observer meets the method signature requirement, it can register
|
||||||
/// this method with the += operator:
|
/// this method with the += operator:
|
||||||
///
|
///
|
||||||
/// class MyController
|
/// class MyController
|
||||||
/// {
|
/// {
|
||||||
/// protected:
|
/// protected:
|
||||||
/// MyData _data;
|
/// MyData _data;
|
||||||
///
|
///
|
||||||
/// void onDataChanged(void* pSender, int& data);
|
/// void onDataChanged(void* pSender, int& data);
|
||||||
/// ...
|
/// ...
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
/// MyController::MyController()
|
/// MyController::MyController()
|
||||||
/// {
|
/// {
|
||||||
/// _data.AgeChanged += Delegate<MyController, int>(this, &MyController::onDataChanged);
|
/// _data.AgeChanged += Delegate<MyController, int>(this, &MyController::onDataChanged);
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// In some cases it might be desirable to work with automatically expiring registrations:
|
/// In some cases it might be desirable to work with automatically expiring registrations:
|
||||||
///
|
///
|
||||||
/// _data.DataChanged += Expire<int>(Delegate<MyController, int>(this, &MyController::onDataChanged), 1000);
|
/// _data.DataChanged += Expire<int>(Delegate<MyController, int>(this, &MyController::onDataChanged), 1000);
|
||||||
///
|
///
|
||||||
/// This will add a delegate to the event which will automatically be removed in 1000 millisecs.
|
/// This will add a delegate to the event which will automatically be removed in 1000 millisecs.
|
||||||
///
|
///
|
||||||
/// Unregistering happens via the -= operator. Forgetting to unregister a method will lead to
|
/// Unregistering happens via the -= operator. Forgetting to unregister a method will lead to
|
||||||
/// segmentation faults later, when one tries to send a notify to a no longer existing object.
|
/// segmentation faults later, when one tries to send a notify to a no longer existing object.
|
||||||
///
|
///
|
||||||
/// MyController::~MyController()
|
/// MyController::~MyController()
|
||||||
/// {
|
/// {
|
||||||
/// _data.DataChanged -= Delegate<MyController, int>(this, &MyController::onDataChanged);
|
/// _data.DataChanged -= Delegate<MyController, int>(this, &MyController::onDataChanged);
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// For further examples refer to the event testsuites.
|
/// For further examples refer to the event testsuites.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AbstractEvent():
|
AbstractEvent():
|
||||||
_executeAsync(this, &AbstractEvent::executeAsyncImpl),
|
_executeAsync(this, &AbstractEvent::executeAsyncImpl),
|
||||||
_enabled(true)
|
_enabled(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractEvent(const TStrategy& strat):
|
AbstractEvent(const TStrategy& strat):
|
||||||
_executeAsync(this, &AbstractEvent::executeAsyncImpl),
|
_executeAsync(this, &AbstractEvent::executeAsyncImpl),
|
||||||
_strategy(strat),
|
_strategy(strat),
|
||||||
_enabled(true)
|
_enabled(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~AbstractEvent()
|
virtual ~AbstractEvent()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator += (const TDelegate& aDelegate)
|
void operator += (const TDelegate& aDelegate)
|
||||||
/// Adds a delegate to the event. If the observer is equal to an
|
/// Adds a delegate to the event. If the observer is equal to an
|
||||||
/// already existing one (determined by the < operator),
|
/// already existing one (determined by the < operator),
|
||||||
/// it will simply replace the existing observer.
|
/// it will simply replace the existing observer.
|
||||||
/// This behavior is determined by the TStrategy. Current implementations
|
/// This behavior is determined by the TStrategy. Current implementations
|
||||||
/// (DefaultStrategy, FIFOStrategy) follow that guideline but future ones
|
/// (DefaultStrategy, FIFOStrategy) follow that guideline but future ones
|
||||||
/// can deviate.
|
/// can deviate.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
_strategy.add(aDelegate);
|
_strategy.add(aDelegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator -= (const TDelegate& aDelegate)
|
void operator -= (const TDelegate& aDelegate)
|
||||||
/// Removes a delegate from the event. If the delegate is equal to an
|
/// Removes a delegate from the event. If the delegate is equal to an
|
||||||
/// already existing one is determined by the < operator.
|
/// already existing one is determined by the < operator.
|
||||||
/// If the observer is not found, the unregister will be ignored
|
/// If the observer is not found, the unregister will be ignored
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
_strategy.remove(aDelegate);
|
_strategy.remove(aDelegate);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator () (const void* pSender, TArgs& args)
|
void operator () (const void* pSender, TArgs& args)
|
||||||
{
|
{
|
||||||
notify(pSender, args);
|
notify(pSender, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
void notify(const void* pSender, TArgs& args)
|
void notify(const void* pSender, TArgs& args)
|
||||||
/// Sends a notification to all registered delegates. The order is
|
/// Sends a notification to all registered delegates. The order is
|
||||||
/// determined by the TStrategy. This method is blocking. While executing,
|
/// determined by the TStrategy. This method is blocking. While executing,
|
||||||
/// other objects can change the list of delegates. These changes don't
|
/// other objects can change the list of delegates. These changes don't
|
||||||
/// influence the current active notifications but are activated with
|
/// influence the current active notifications but are activated with
|
||||||
/// the next notify. If one of the delegates throws an exception, the notify
|
/// the next notify. If one of the delegates throws an exception, the notify
|
||||||
/// method is immediately aborted and the exception is reported to the caller.
|
/// method is immediately aborted and the exception is reported to the caller.
|
||||||
{
|
{
|
||||||
SharedPtr<TStrategy> ptrStrat;
|
SharedPtr<TStrategy> ptrStrat;
|
||||||
bool enabled = false;
|
bool enabled = false;
|
||||||
|
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
enabled = _enabled;
|
enabled = _enabled;
|
||||||
if (_enabled)
|
if (_enabled)
|
||||||
{
|
{
|
||||||
// thread-safeness:
|
// thread-safeness:
|
||||||
// copy should be faster and safer than blocking until
|
// copy should be faster and safer than blocking until
|
||||||
// execution ends
|
// execution ends
|
||||||
ptrStrat = new TStrategy(_strategy);
|
ptrStrat = new TStrategy(_strategy);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enabled)
|
if (enabled)
|
||||||
{
|
{
|
||||||
ptrStrat->notify(pSender, args);
|
ptrStrat->notify(pSender, args);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveResult<TArgs> notifyAsync(const void* pSender, const TArgs& args)
|
ActiveResult<TArgs> notifyAsync(const void* pSender, const TArgs& args)
|
||||||
/// Sends a notification to all registered delegates. The order is
|
/// Sends a notification to all registered delegates. The order is
|
||||||
/// determined by the TStrategy. This method is not blocking and will
|
/// determined by the TStrategy. This method is not blocking and will
|
||||||
/// immediately return. The delegates are invoked in a seperate thread.
|
/// immediately return. The delegates are invoked in a seperate thread.
|
||||||
/// Call activeResult.wait() to wait until the notification has ended.
|
/// Call activeResult.wait() to wait until the notification has ended.
|
||||||
/// While executing, other objects can change the delegate list. These changes don't
|
/// While executing, other objects can change the delegate list. These changes don't
|
||||||
/// influence the current active notifications but are activated with
|
/// influence the current active notifications but are activated with
|
||||||
/// the next notify. If one of the delegates throws an exception, the execution
|
/// the next notify. If one of the delegates throws an exception, the execution
|
||||||
/// is aborted and the exception is reported to the caller.
|
/// is aborted and the exception is reported to the caller.
|
||||||
{
|
{
|
||||||
NotifyAsyncParams params(pSender, args);
|
NotifyAsyncParams params(pSender, args);
|
||||||
|
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
// thread-safeness:
|
// thread-safeness:
|
||||||
// copy should be faster and safer than blocking until
|
// copy should be faster and safer than blocking until
|
||||||
// execution ends
|
// execution ends
|
||||||
// make a copy of the strategy here to guarantee that
|
// make a copy of the strategy here to guarantee that
|
||||||
// between notifyAsync and the execution of the method no changes can occur
|
// between notifyAsync and the execution of the method no changes can occur
|
||||||
|
|
||||||
params.ptrStrat = SharedPtr<TStrategy>(new TStrategy(_strategy));
|
params.ptrStrat = SharedPtr<TStrategy>(new TStrategy(_strategy));
|
||||||
params.enabled = _enabled;
|
params.enabled = _enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveResult<TArgs> result = _executeAsync(params);
|
ActiveResult<TArgs> result = _executeAsync(params);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void enable()
|
void enable()
|
||||||
/// Enables the event
|
/// Enables the event
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
_enabled = true;
|
_enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void disable()
|
void disable()
|
||||||
/// Disables the event. notify and notifyAsnyc will be ignored,
|
/// Disables the event. notify and notifyAsnyc will be ignored,
|
||||||
/// but adding/removing delegates is still allowed.
|
/// but adding/removing delegates is still allowed.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
_enabled = false;
|
_enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isEnabled() const
|
bool isEnabled() const
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
return _enabled;
|
return _enabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
/// Removes all delegates.
|
/// Removes all delegates.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
_strategy.clear();
|
_strategy.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct NotifyAsyncParams
|
struct NotifyAsyncParams
|
||||||
{
|
{
|
||||||
SharedPtr<TStrategy> ptrStrat;
|
SharedPtr<TStrategy> ptrStrat;
|
||||||
const void* pSender;
|
const void* pSender;
|
||||||
TArgs args;
|
TArgs args;
|
||||||
bool enabled;
|
bool enabled;
|
||||||
|
|
||||||
NotifyAsyncParams(const void* pSend, const TArgs& a):ptrStrat(), pSender(pSend), args(a), enabled(true)
|
NotifyAsyncParams(const void* pSend, const TArgs& a):ptrStrat(), pSender(pSend), args(a), enabled(true)
|
||||||
/// default constructor reduces the need for TArgs to have an empty constructor, only copy constructor is needed.
|
/// default constructor reduces the need for TArgs to have an empty constructor, only copy constructor is needed.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
ActiveMethod<TArgs, NotifyAsyncParams, AbstractEvent> _executeAsync;
|
ActiveMethod<TArgs, NotifyAsyncParams, AbstractEvent> _executeAsync;
|
||||||
|
|
||||||
TArgs executeAsyncImpl(const NotifyAsyncParams& par)
|
TArgs executeAsyncImpl(const NotifyAsyncParams& par)
|
||||||
{
|
{
|
||||||
if (!par.enabled)
|
if (!par.enabled)
|
||||||
{
|
{
|
||||||
return par.args;
|
return par.args;
|
||||||
}
|
}
|
||||||
|
|
||||||
NotifyAsyncParams params = par;
|
NotifyAsyncParams params = par;
|
||||||
TArgs retArgs(params.args);
|
TArgs retArgs(params.args);
|
||||||
params.ptrStrat->notify(params.pSender, retArgs);
|
params.ptrStrat->notify(params.pSender, retArgs);
|
||||||
return retArgs;
|
return retArgs;
|
||||||
}
|
}
|
||||||
|
|
||||||
TStrategy _strategy; /// The strategy used to notify observers.
|
TStrategy _strategy; /// The strategy used to notify observers.
|
||||||
bool _enabled; /// Stores if an event is enabled. Notfies on disabled events have no effect
|
bool _enabled; /// Stores if an event is enabled. Notfies on disabled events have no effect
|
||||||
/// but it is possible to change the observers.
|
/// but it is possible to change the observers.
|
||||||
mutable FastMutex _mutex;
|
mutable FastMutex _mutex;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractEvent(const AbstractEvent& other);
|
AbstractEvent(const AbstractEvent& other);
|
||||||
AbstractEvent& operator = (const AbstractEvent& other);
|
AbstractEvent& operator = (const AbstractEvent& other);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,71 +1,71 @@
|
|||||||
//
|
//
|
||||||
// AbstractObserver.h
|
// AbstractObserver.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/AbstractObserver.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/AbstractObserver.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Notifications
|
// Package: Notifications
|
||||||
// Module: NotificationCenter
|
// Module: NotificationCenter
|
||||||
//
|
//
|
||||||
// Definition of the AbstractObserver class.
|
// Definition of the AbstractObserver 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_AbstractObserver_INCLUDED
|
#ifndef Foundation_AbstractObserver_INCLUDED
|
||||||
#define Foundation_AbstractObserver_INCLUDED
|
#define Foundation_AbstractObserver_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Notification.h"
|
#include "Poco/Notification.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API AbstractObserver
|
class Foundation_API AbstractObserver
|
||||||
/// The base class for all instantiations of
|
/// The base class for all instantiations of
|
||||||
/// the Observer and NObserver template classes.
|
/// the Observer and NObserver template classes.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AbstractObserver();
|
AbstractObserver();
|
||||||
AbstractObserver(const AbstractObserver& observer);
|
AbstractObserver(const AbstractObserver& observer);
|
||||||
virtual ~AbstractObserver();
|
virtual ~AbstractObserver();
|
||||||
|
|
||||||
AbstractObserver& operator = (const AbstractObserver& observer);
|
AbstractObserver& operator = (const AbstractObserver& observer);
|
||||||
|
|
||||||
virtual void notify(Notification* pNf) const = 0;
|
virtual void notify(Notification* pNf) const = 0;
|
||||||
virtual bool equals(const AbstractObserver& observer) const = 0;
|
virtual bool equals(const AbstractObserver& observer) const = 0;
|
||||||
virtual bool accepts(Notification* pNf) const = 0;
|
virtual bool accepts(Notification* pNf) const = 0;
|
||||||
virtual AbstractObserver* clone() const = 0;
|
virtual AbstractObserver* clone() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_AbstractObserver_INCLUDED
|
#endif // Foundation_AbstractObserver_INCLUDED
|
||||||
|
|||||||
@@ -1,109 +1,109 @@
|
|||||||
//
|
//
|
||||||
// AbstractPriorityDelegate.h
|
// AbstractPriorityDelegate.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/AbstractPriorityDelegate.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/AbstractPriorityDelegate.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
// Module: AbstractPriorityDelegate
|
// Module: AbstractPriorityDelegate
|
||||||
//
|
//
|
||||||
// Implementation of the AbstractPriorityDelegate template.
|
// Implementation of the AbstractPriorityDelegate template.
|
||||||
//
|
//
|
||||||
// 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 Foundation_AbstractPriorityDelegate_INCLUDED
|
#ifndef Foundation_AbstractPriorityDelegate_INCLUDED
|
||||||
#define Foundation_AbstractPriorityDelegate_INCLUDED
|
#define Foundation_AbstractPriorityDelegate_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TArgs>
|
template <class TArgs>
|
||||||
class AbstractPriorityDelegate
|
class AbstractPriorityDelegate
|
||||||
/// Interface for PriorityDelegate and PriorityExpire.
|
/// Interface for PriorityDelegate and PriorityExpire.
|
||||||
/// Very similar to AbstractDelegate but having two separate files (no inheritance)
|
/// Very similar to AbstractDelegate but having two separate files (no inheritance)
|
||||||
/// allows to have compile-time checks when registering an observer
|
/// allows to have compile-time checks when registering an observer
|
||||||
/// instead of run-time checks.
|
/// instead of run-time checks.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AbstractPriorityDelegate(void* pTarget, int prio):
|
AbstractPriorityDelegate(void* pTarget, int prio):
|
||||||
_pTarget(pTarget),
|
_pTarget(pTarget),
|
||||||
_priority(prio)
|
_priority(prio)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractPriorityDelegate(const AbstractPriorityDelegate& del):
|
AbstractPriorityDelegate(const AbstractPriorityDelegate& del):
|
||||||
_pTarget(del._pTarget),
|
_pTarget(del._pTarget),
|
||||||
_priority(del._priority)
|
_priority(del._priority)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~AbstractPriorityDelegate()
|
virtual ~AbstractPriorityDelegate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual bool notify(const void* sender, TArgs & arguments) = 0;
|
virtual bool notify(const void* sender, TArgs & arguments) = 0;
|
||||||
/// Returns false, if the Delegate is no longer valid, thus indicating an expire
|
/// Returns false, if the Delegate is no longer valid, thus indicating an expire
|
||||||
|
|
||||||
virtual AbstractPriorityDelegate* clone() const = 0;
|
virtual AbstractPriorityDelegate* clone() const = 0;
|
||||||
// Returns a deep-copy of the object.
|
// Returns a deep-copy of the object.
|
||||||
|
|
||||||
bool operator < (const AbstractPriorityDelegate<TArgs>& other) const
|
bool operator < (const AbstractPriorityDelegate<TArgs>& other) const
|
||||||
/// Operator used for comparing AbstractPriorityDelegates in a collection.
|
/// Operator used for comparing AbstractPriorityDelegates in a collection.
|
||||||
{
|
{
|
||||||
if (_priority == other._priority)
|
if (_priority == other._priority)
|
||||||
{
|
{
|
||||||
return _pTarget < other._pTarget;
|
return _pTarget < other._pTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (_priority < other._priority);
|
return (_priority < other._priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
void* target() const
|
void* target() const
|
||||||
{
|
{
|
||||||
return _pTarget;
|
return _pTarget;
|
||||||
}
|
}
|
||||||
|
|
||||||
int priority() const
|
int priority() const
|
||||||
{
|
{
|
||||||
return _priority;
|
return _priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void* _pTarget;
|
void* _pTarget;
|
||||||
int _priority;
|
int _priority;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,91 +1,91 @@
|
|||||||
//
|
//
|
||||||
// AbstractStrategy.h
|
// AbstractStrategy.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/AbstractStrategy.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/AbstractStrategy.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
// Module: AbstractCache
|
// Module: AbstractCache
|
||||||
//
|
//
|
||||||
// Definition of the AbstractStrategy class.
|
// Definition of the AbstractStrategy 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 Foundation_AbstractStrategy_INCLUDED
|
#ifndef Foundation_AbstractStrategy_INCLUDED
|
||||||
#define Foundation_AbstractStrategy_INCLUDED
|
#define Foundation_AbstractStrategy_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/KeyValueArgs.h"
|
#include "Poco/KeyValueArgs.h"
|
||||||
#include "Poco/ValidArgs.h"
|
#include "Poco/ValidArgs.h"
|
||||||
#include "Poco/EventArgs.h"
|
#include "Poco/EventArgs.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TKey, class TValue>
|
template <class TKey, class TValue>
|
||||||
class AbstractStrategy
|
class AbstractStrategy
|
||||||
/// An AbstractStrategy is the interface for all strategies.
|
/// An AbstractStrategy is the interface for all strategies.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AbstractStrategy()
|
AbstractStrategy()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~AbstractStrategy()
|
virtual ~AbstractStrategy()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void onAdd(const void* pSender, const KeyValueArgs <TKey, TValue>& key) = 0;
|
virtual void onAdd(const void* pSender, const KeyValueArgs <TKey, TValue>& key) = 0;
|
||||||
/// Adds the key to the strategy.
|
/// Adds the key to the strategy.
|
||||||
/// If for the key already an entry exists, an excpetion will be thrown.
|
/// If for the key already an entry exists, an excpetion will be thrown.
|
||||||
|
|
||||||
virtual void onRemove(const void* pSender, const TKey& key) = 0;
|
virtual void onRemove(const void* pSender, const TKey& key) = 0;
|
||||||
/// Removes an entry from the strategy. If the entry is not found
|
/// Removes an entry from the strategy. If the entry is not found
|
||||||
/// the remove is ignored.
|
/// the remove is ignored.
|
||||||
|
|
||||||
virtual void onGet(const void* pSender, const TKey& key) = 0;
|
virtual void onGet(const void* pSender, const TKey& key) = 0;
|
||||||
/// Informs the strategy that a read-access happens to an element.
|
/// Informs the strategy that a read-access happens to an element.
|
||||||
|
|
||||||
virtual void onClear(const void* pSender, const EventArgs& args) = 0;
|
virtual void onClear(const void* pSender, const EventArgs& args) = 0;
|
||||||
/// Removes all elements from the cache.
|
/// Removes all elements from the cache.
|
||||||
|
|
||||||
virtual void onIsValid(const void* pSender, ValidArgs<TKey>& key) = 0;
|
virtual void onIsValid(const void* pSender, ValidArgs<TKey>& key) = 0;
|
||||||
/// Used to query if a key is still valid (i.e. cached).
|
/// Used to query if a key is still valid (i.e. cached).
|
||||||
|
|
||||||
virtual void onReplace(const void* pSender, std::set<TKey>& elemsToRemove) = 0;
|
virtual void onReplace(const void* pSender, std::set<TKey>& elemsToRemove) = 0;
|
||||||
/// Used by the Strategy to indicate which elements should be removed from
|
/// Used by the Strategy to indicate which elements should be removed from
|
||||||
/// the cache. Note that onReplace does not change the current list of keys.
|
/// the cache. Note that onReplace does not change the current list of keys.
|
||||||
/// The cache object is reponsible to remove the elements.
|
/// The cache object is reponsible to remove the elements.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,138 +1,138 @@
|
|||||||
//
|
//
|
||||||
// ActiveDispatcher.h
|
// ActiveDispatcher.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ActiveDispatcher.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ActiveDispatcher.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
// Module: ActiveObjects
|
// Module: ActiveObjects
|
||||||
//
|
//
|
||||||
// Definition of the ActiveDispatcher class.
|
// Definition of the ActiveDispatcher class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006-2007, 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_ActiveDispatcher_INCLUDED
|
#ifndef Foundation_ActiveDispatcher_INCLUDED
|
||||||
#define Foundation_ActiveDispatcher_INCLUDED
|
#define Foundation_ActiveDispatcher_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Runnable.h"
|
#include "Poco/Runnable.h"
|
||||||
#include "Poco/Thread.h"
|
#include "Poco/Thread.h"
|
||||||
#include "Poco/ActiveStarter.h"
|
#include "Poco/ActiveStarter.h"
|
||||||
#include "Poco/ActiveRunnable.h"
|
#include "Poco/ActiveRunnable.h"
|
||||||
#include "Poco/NotificationQueue.h"
|
#include "Poco/NotificationQueue.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API ActiveDispatcher: protected Runnable
|
class Foundation_API ActiveDispatcher: protected Runnable
|
||||||
/// This class is used to implement an active object
|
/// This class is used to implement an active object
|
||||||
/// with strictly serialized method execution.
|
/// with strictly serialized method execution.
|
||||||
///
|
///
|
||||||
/// An active object, with is an ordinary object
|
/// An active object, with is an ordinary object
|
||||||
/// containing ActiveMethod members, executes all
|
/// containing ActiveMethod members, executes all
|
||||||
/// active methods in their own thread.
|
/// active methods in their own thread.
|
||||||
/// This behavior does not fit the "classic"
|
/// This behavior does not fit the "classic"
|
||||||
/// definition of an active object, which serializes
|
/// definition of an active object, which serializes
|
||||||
/// the execution of active methods (in other words,
|
/// the execution of active methods (in other words,
|
||||||
/// only one active method can be running at any given
|
/// only one active method can be running at any given
|
||||||
/// time).
|
/// time).
|
||||||
///
|
///
|
||||||
/// Using this class as a base class, the serializing
|
/// Using this class as a base class, the serializing
|
||||||
/// behavior for active objects can be implemented.
|
/// behavior for active objects can be implemented.
|
||||||
///
|
///
|
||||||
/// The following example shows how this is done:
|
/// The following example shows how this is done:
|
||||||
///
|
///
|
||||||
/// class ActiveObject: public ActiveDispatcher
|
/// class ActiveObject: public ActiveDispatcher
|
||||||
/// {
|
/// {
|
||||||
/// public:
|
/// public:
|
||||||
/// ActiveObject():
|
/// ActiveObject():
|
||||||
/// exampleActiveMethod(this, &ActiveObject::exampleActiveMethodImpl)
|
/// exampleActiveMethod(this, &ActiveObject::exampleActiveMethodImpl)
|
||||||
/// {
|
/// {
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// ActiveMethod<std::string, std::string, ActiveObject, ActiveStarter<ActiveDispatcher> > exampleActiveMethod;
|
/// ActiveMethod<std::string, std::string, ActiveObject, ActiveStarter<ActiveDispatcher> > exampleActiveMethod;
|
||||||
///
|
///
|
||||||
/// protected:
|
/// protected:
|
||||||
/// std::string exampleActiveMethodImpl(const std::string& arg)
|
/// std::string exampleActiveMethodImpl(const std::string& arg)
|
||||||
/// {
|
/// {
|
||||||
/// ...
|
/// ...
|
||||||
/// }
|
/// }
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
/// The only things different from the example in
|
/// The only things different from the example in
|
||||||
/// ActiveMethod is that the ActiveObject in this case
|
/// ActiveMethod is that the ActiveObject in this case
|
||||||
/// inherits from ActiveDispatcher, and that the ActiveMethod
|
/// inherits from ActiveDispatcher, and that the ActiveMethod
|
||||||
/// template for exampleActiveMethod has an additional parameter,
|
/// template for exampleActiveMethod has an additional parameter,
|
||||||
/// specifying the specialized ActiveStarter for ActiveDispatcher.
|
/// specifying the specialized ActiveStarter for ActiveDispatcher.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ActiveDispatcher();
|
ActiveDispatcher();
|
||||||
/// Creates the ActiveDispatcher.
|
/// Creates the ActiveDispatcher.
|
||||||
|
|
||||||
ActiveDispatcher(Thread::Priority prio);
|
ActiveDispatcher(Thread::Priority prio);
|
||||||
/// Creates the ActiveDispatcher and sets
|
/// Creates the ActiveDispatcher and sets
|
||||||
/// the priority of its thread.
|
/// the priority of its thread.
|
||||||
|
|
||||||
virtual ~ActiveDispatcher();
|
virtual ~ActiveDispatcher();
|
||||||
/// Destroys the ActiveDispatcher.
|
/// Destroys the ActiveDispatcher.
|
||||||
|
|
||||||
void start(ActiveRunnableBase::Ptr pRunnable);
|
void start(ActiveRunnableBase::Ptr pRunnable);
|
||||||
/// Adds the Runnable to the dispatch queue.
|
/// Adds the Runnable to the dispatch queue.
|
||||||
|
|
||||||
void cancel();
|
void cancel();
|
||||||
/// Cancels all queued methods.
|
/// Cancels all queued methods.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void run();
|
void run();
|
||||||
void stop();
|
void stop();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Thread _thread;
|
Thread _thread;
|
||||||
NotificationQueue _queue;
|
NotificationQueue _queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
class ActiveStarter<ActiveDispatcher>
|
class ActiveStarter<ActiveDispatcher>
|
||||||
/// A specialization of ActiveStarter
|
/// A specialization of ActiveStarter
|
||||||
/// for ActiveDispatcher.
|
/// for ActiveDispatcher.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void start(ActiveDispatcher* pOwner, ActiveRunnableBase::Ptr pRunnable)
|
static void start(ActiveDispatcher* pOwner, ActiveRunnableBase::Ptr pRunnable)
|
||||||
{
|
{
|
||||||
pOwner->start(pRunnable);
|
pOwner->start(pRunnable);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_ActiveDispatcher_INCLUDED
|
#endif // Foundation_ActiveDispatcher_INCLUDED
|
||||||
|
|||||||
@@ -1,240 +1,240 @@
|
|||||||
//
|
//
|
||||||
// ActiveMethod.h
|
// ActiveMethod.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ActiveMethod.h#3 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ActiveMethod.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
// Module: ActiveObjects
|
// Module: ActiveObjects
|
||||||
//
|
//
|
||||||
// Definition of the ActiveMethod class.
|
// Definition of the ActiveMethod class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2004-2007, 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_ActiveMethod_INCLUDED
|
#ifndef Foundation_ActiveMethod_INCLUDED
|
||||||
#define Foundation_ActiveMethod_INCLUDED
|
#define Foundation_ActiveMethod_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/ActiveResult.h"
|
#include "Poco/ActiveResult.h"
|
||||||
#include "Poco/ActiveRunnable.h"
|
#include "Poco/ActiveRunnable.h"
|
||||||
#include "Poco/ActiveStarter.h"
|
#include "Poco/ActiveStarter.h"
|
||||||
#include "Poco/AutoPtr.h"
|
#include "Poco/AutoPtr.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class ResultType, class ArgType, class OwnerType, class StarterType = ActiveStarter<OwnerType> >
|
template <class ResultType, class ArgType, class OwnerType, class StarterType = ActiveStarter<OwnerType> >
|
||||||
class ActiveMethod
|
class ActiveMethod
|
||||||
/// An active method is a method that, when called, executes
|
/// An active method is a method that, when called, executes
|
||||||
/// in its own thread. ActiveMethod's take exactly one
|
/// in its own thread. ActiveMethod's take exactly one
|
||||||
/// argument and can return a value. To pass more than one
|
/// argument and can return a value. To pass more than one
|
||||||
/// argument to the method, use a struct.
|
/// argument to the method, use a struct.
|
||||||
/// The following example shows how to add an ActiveMethod
|
/// The following example shows how to add an ActiveMethod
|
||||||
/// to a class:
|
/// to a class:
|
||||||
///
|
///
|
||||||
/// class ActiveObject
|
/// class ActiveObject
|
||||||
/// {
|
/// {
|
||||||
/// public:
|
/// public:
|
||||||
/// ActiveObject():
|
/// ActiveObject():
|
||||||
/// exampleActiveMethod(this, &ActiveObject::exampleActiveMethodImpl)
|
/// exampleActiveMethod(this, &ActiveObject::exampleActiveMethodImpl)
|
||||||
/// {
|
/// {
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// ActiveMethod<std::string, std::string, ActiveObject> exampleActiveMethod;
|
/// ActiveMethod<std::string, std::string, ActiveObject> exampleActiveMethod;
|
||||||
///
|
///
|
||||||
/// protected:
|
/// protected:
|
||||||
/// std::string exampleActiveMethodImpl(const std::string& arg)
|
/// std::string exampleActiveMethodImpl(const std::string& arg)
|
||||||
/// {
|
/// {
|
||||||
/// ...
|
/// ...
|
||||||
/// }
|
/// }
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
/// And following is an example that shows how to invoke an ActiveMethod.
|
/// And following is an example that shows how to invoke an ActiveMethod.
|
||||||
///
|
///
|
||||||
/// ActiveObject myActiveObject;
|
/// ActiveObject myActiveObject;
|
||||||
/// ActiveResult<std::string> result = myActiveObject.exampleActiveMethod("foo");
|
/// ActiveResult<std::string> result = myActiveObject.exampleActiveMethod("foo");
|
||||||
/// ...
|
/// ...
|
||||||
/// result.wait();
|
/// result.wait();
|
||||||
/// std::cout << result.data() << std::endl;
|
/// std::cout << result.data() << std::endl;
|
||||||
///
|
///
|
||||||
/// The way an ActiveMethod is started can be changed by passing a StarterType
|
/// The way an ActiveMethod is started can be changed by passing a StarterType
|
||||||
/// template argument with a corresponding class. The default ActiveStarter
|
/// template argument with a corresponding class. The default ActiveStarter
|
||||||
/// starts the method in its own thread, obtained from a thread pool.
|
/// starts the method in its own thread, obtained from a thread pool.
|
||||||
///
|
///
|
||||||
/// For an alternative implementation of StarterType, see ActiveDispatcher.
|
/// For an alternative implementation of StarterType, see ActiveDispatcher.
|
||||||
///
|
///
|
||||||
/// For methods that do not require an argument or a return value, the Void
|
/// For methods that do not require an argument or a return value, the Void
|
||||||
/// class can be used.
|
/// class can be used.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef ResultType (OwnerType::*Callback)(const ArgType&);
|
typedef ResultType (OwnerType::*Callback)(const ArgType&);
|
||||||
typedef ActiveResult<ResultType> ActiveResultType;
|
typedef ActiveResult<ResultType> ActiveResultType;
|
||||||
typedef ActiveRunnable<ResultType, ArgType, OwnerType> ActiveRunnableType;
|
typedef ActiveRunnable<ResultType, ArgType, OwnerType> ActiveRunnableType;
|
||||||
|
|
||||||
ActiveMethod(OwnerType* pOwner, Callback method):
|
ActiveMethod(OwnerType* pOwner, Callback method):
|
||||||
_pOwner(pOwner),
|
_pOwner(pOwner),
|
||||||
_method(method)
|
_method(method)
|
||||||
/// Creates an ActiveMethod object.
|
/// Creates an ActiveMethod object.
|
||||||
{
|
{
|
||||||
poco_check_ptr (pOwner);
|
poco_check_ptr (pOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveResultType operator () (const ArgType& arg)
|
ActiveResultType operator () (const ArgType& arg)
|
||||||
/// Invokes the ActiveMethod.
|
/// Invokes the ActiveMethod.
|
||||||
{
|
{
|
||||||
ActiveResultType result(new ActiveResultHolder<ResultType>());
|
ActiveResultType result(new ActiveResultHolder<ResultType>());
|
||||||
ActiveRunnableBase::Ptr pRunnable(new ActiveRunnableType(_pOwner, _method, arg, result));
|
ActiveRunnableBase::Ptr pRunnable(new ActiveRunnableType(_pOwner, _method, arg, result));
|
||||||
StarterType::start(_pOwner, pRunnable);
|
StarterType::start(_pOwner, pRunnable);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveMethod(const ActiveMethod& other):
|
ActiveMethod(const ActiveMethod& other):
|
||||||
_pOwner(other._pOwner),
|
_pOwner(other._pOwner),
|
||||||
_method(other._method)
|
_method(other._method)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveMethod& operator = (const ActiveMethod& other)
|
ActiveMethod& operator = (const ActiveMethod& other)
|
||||||
{
|
{
|
||||||
ActiveMethod tmp(other);
|
ActiveMethod tmp(other);
|
||||||
swap(tmp);
|
swap(tmp);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(ActiveMethod& other)
|
void swap(ActiveMethod& other)
|
||||||
{
|
{
|
||||||
std::swap(_pOwner, other._pOwner);
|
std::swap(_pOwner, other._pOwner);
|
||||||
std::swap(_method, other._method);
|
std::swap(_method, other._method);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ActiveMethod();
|
ActiveMethod();
|
||||||
|
|
||||||
OwnerType* _pOwner;
|
OwnerType* _pOwner;
|
||||||
Callback _method;
|
Callback _method;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
template <class ResultType, class OwnerType, class StarterType>
|
template <class ResultType, class OwnerType, class StarterType>
|
||||||
class ActiveMethod <ResultType, void, OwnerType, StarterType>
|
class ActiveMethod <ResultType, void, OwnerType, StarterType>
|
||||||
/// An active method is a method that, when called, executes
|
/// An active method is a method that, when called, executes
|
||||||
/// in its own thread. ActiveMethod's take exactly one
|
/// in its own thread. ActiveMethod's take exactly one
|
||||||
/// argument and can return a value. To pass more than one
|
/// argument and can return a value. To pass more than one
|
||||||
/// argument to the method, use a struct.
|
/// argument to the method, use a struct.
|
||||||
/// The following example shows how to add an ActiveMethod
|
/// The following example shows how to add an ActiveMethod
|
||||||
/// to a class:
|
/// to a class:
|
||||||
///
|
///
|
||||||
/// class ActiveObject
|
/// class ActiveObject
|
||||||
/// {
|
/// {
|
||||||
/// public:
|
/// public:
|
||||||
/// ActiveObject():
|
/// ActiveObject():
|
||||||
/// exampleActiveMethod(this, &ActiveObject::exampleActiveMethodImpl)
|
/// exampleActiveMethod(this, &ActiveObject::exampleActiveMethodImpl)
|
||||||
/// {
|
/// {
|
||||||
/// }
|
/// }
|
||||||
///
|
///
|
||||||
/// ActiveMethod<std::string, std::string, ActiveObject> exampleActiveMethod;
|
/// ActiveMethod<std::string, std::string, ActiveObject> exampleActiveMethod;
|
||||||
///
|
///
|
||||||
/// protected:
|
/// protected:
|
||||||
/// std::string exampleActiveMethodImpl(const std::string& arg)
|
/// std::string exampleActiveMethodImpl(const std::string& arg)
|
||||||
/// {
|
/// {
|
||||||
/// ...
|
/// ...
|
||||||
/// }
|
/// }
|
||||||
/// };
|
/// };
|
||||||
///
|
///
|
||||||
/// And following is an example that shows how to invoke an ActiveMethod.
|
/// And following is an example that shows how to invoke an ActiveMethod.
|
||||||
///
|
///
|
||||||
/// ActiveObject myActiveObject;
|
/// ActiveObject myActiveObject;
|
||||||
/// ActiveResult<std::string> result = myActiveObject.exampleActiveMethod("foo");
|
/// ActiveResult<std::string> result = myActiveObject.exampleActiveMethod("foo");
|
||||||
/// ...
|
/// ...
|
||||||
/// result.wait();
|
/// result.wait();
|
||||||
/// std::cout << result.data() << std::endl;
|
/// std::cout << result.data() << std::endl;
|
||||||
///
|
///
|
||||||
/// The way an ActiveMethod is started can be changed by passing a StarterType
|
/// The way an ActiveMethod is started can be changed by passing a StarterType
|
||||||
/// template argument with a corresponding class. The default ActiveStarter
|
/// template argument with a corresponding class. The default ActiveStarter
|
||||||
/// starts the method in its own thread, obtained from a thread pool.
|
/// starts the method in its own thread, obtained from a thread pool.
|
||||||
///
|
///
|
||||||
/// For an alternative implementation of StarterType, see ActiveDispatcher.
|
/// For an alternative implementation of StarterType, see ActiveDispatcher.
|
||||||
///
|
///
|
||||||
/// For methods that do not require an argument or a return value, simply use void.
|
/// For methods that do not require an argument or a return value, simply use void.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef ResultType (OwnerType::*Callback)(void);
|
typedef ResultType (OwnerType::*Callback)(void);
|
||||||
typedef ActiveResult<ResultType> ActiveResultType;
|
typedef ActiveResult<ResultType> ActiveResultType;
|
||||||
typedef ActiveRunnable<ResultType, void, OwnerType> ActiveRunnableType;
|
typedef ActiveRunnable<ResultType, void, OwnerType> ActiveRunnableType;
|
||||||
|
|
||||||
ActiveMethod(OwnerType* pOwner, Callback method):
|
ActiveMethod(OwnerType* pOwner, Callback method):
|
||||||
_pOwner(pOwner),
|
_pOwner(pOwner),
|
||||||
_method(method)
|
_method(method)
|
||||||
/// Creates an ActiveMethod object.
|
/// Creates an ActiveMethod object.
|
||||||
{
|
{
|
||||||
poco_check_ptr (pOwner);
|
poco_check_ptr (pOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveResultType operator () (void)
|
ActiveResultType operator () (void)
|
||||||
/// Invokes the ActiveMethod.
|
/// Invokes the ActiveMethod.
|
||||||
{
|
{
|
||||||
ActiveResultType result(new ActiveResultHolder<ResultType>());
|
ActiveResultType result(new ActiveResultHolder<ResultType>());
|
||||||
ActiveRunnableBase::Ptr pRunnable(new ActiveRunnableType(_pOwner, _method, result));
|
ActiveRunnableBase::Ptr pRunnable(new ActiveRunnableType(_pOwner, _method, result));
|
||||||
StarterType::start(_pOwner, pRunnable);
|
StarterType::start(_pOwner, pRunnable);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveMethod(const ActiveMethod& other):
|
ActiveMethod(const ActiveMethod& other):
|
||||||
_pOwner(other._pOwner),
|
_pOwner(other._pOwner),
|
||||||
_method(other._method)
|
_method(other._method)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ActiveMethod& operator = (const ActiveMethod& other)
|
ActiveMethod& operator = (const ActiveMethod& other)
|
||||||
{
|
{
|
||||||
ActiveMethod tmp(other);
|
ActiveMethod tmp(other);
|
||||||
swap(tmp);
|
swap(tmp);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(ActiveMethod& other)
|
void swap(ActiveMethod& other)
|
||||||
{
|
{
|
||||||
std::swap(_pOwner, other._pOwner);
|
std::swap(_pOwner, other._pOwner);
|
||||||
std::swap(_method, other._method);
|
std::swap(_method, other._method);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ActiveMethod();
|
ActiveMethod();
|
||||||
|
|
||||||
OwnerType* _pOwner;
|
OwnerType* _pOwner;
|
||||||
Callback _method;
|
Callback _method;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_ActiveMethod_INCLUDED
|
#endif // Foundation_ActiveMethod_INCLUDED
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,253 +1,253 @@
|
|||||||
//
|
//
|
||||||
// ActiveRunnable.h
|
// ActiveRunnable.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ActiveRunnable.h#3 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ActiveRunnable.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
// Module: ActiveObjects
|
// Module: ActiveObjects
|
||||||
//
|
//
|
||||||
// Definition of the ActiveRunnable class.
|
// Definition of the ActiveRunnable class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2004-2007, 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_ActiveRunnable_INCLUDED
|
#ifndef Foundation_ActiveRunnable_INCLUDED
|
||||||
#define Foundation_ActiveRunnable_INCLUDED
|
#define Foundation_ActiveRunnable_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/ActiveResult.h"
|
#include "Poco/ActiveResult.h"
|
||||||
#include "Poco/Runnable.h"
|
#include "Poco/Runnable.h"
|
||||||
#include "Poco/RefCountedObject.h"
|
#include "Poco/RefCountedObject.h"
|
||||||
#include "Poco/AutoPtr.h"
|
#include "Poco/AutoPtr.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class ActiveRunnableBase: public Runnable, public RefCountedObject
|
class ActiveRunnableBase: public Runnable, public RefCountedObject
|
||||||
/// The base class for all ActiveRunnable instantiations.
|
/// The base class for all ActiveRunnable instantiations.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef AutoPtr<ActiveRunnableBase> Ptr;
|
typedef AutoPtr<ActiveRunnableBase> Ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class ResultType, class ArgType, class OwnerType>
|
template <class ResultType, class ArgType, class OwnerType>
|
||||||
class ActiveRunnable: public ActiveRunnableBase
|
class ActiveRunnable: public ActiveRunnableBase
|
||||||
/// This class is used by ActiveMethod.
|
/// This class is used by ActiveMethod.
|
||||||
/// See the ActiveMethod class for more information.
|
/// See the ActiveMethod class for more information.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef ResultType (OwnerType::*Callback)(const ArgType&);
|
typedef ResultType (OwnerType::*Callback)(const ArgType&);
|
||||||
typedef ActiveResult<ResultType> ActiveResultType;
|
typedef ActiveResult<ResultType> ActiveResultType;
|
||||||
|
|
||||||
ActiveRunnable(OwnerType* pOwner, Callback method, const ArgType& arg, const ActiveResultType& result):
|
ActiveRunnable(OwnerType* pOwner, Callback method, const ArgType& arg, const ActiveResultType& result):
|
||||||
_pOwner(pOwner),
|
_pOwner(pOwner),
|
||||||
_method(method),
|
_method(method),
|
||||||
_arg(arg),
|
_arg(arg),
|
||||||
_result(result)
|
_result(result)
|
||||||
{
|
{
|
||||||
poco_check_ptr (pOwner);
|
poco_check_ptr (pOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
|
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_result.data(new ResultType((_pOwner->*_method)(_arg)));
|
_result.data(new ResultType((_pOwner->*_method)(_arg)));
|
||||||
}
|
}
|
||||||
catch (Exception& e)
|
catch (Exception& e)
|
||||||
{
|
{
|
||||||
_result.error(e);
|
_result.error(e);
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
_result.error(e.what());
|
_result.error(e.what());
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
_result.error("unknown exception");
|
_result.error("unknown exception");
|
||||||
}
|
}
|
||||||
_result.notify();
|
_result.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OwnerType* _pOwner;
|
OwnerType* _pOwner;
|
||||||
Callback _method;
|
Callback _method;
|
||||||
ArgType _arg;
|
ArgType _arg;
|
||||||
ActiveResultType _result;
|
ActiveResultType _result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class ArgType, class OwnerType>
|
template <class ArgType, class OwnerType>
|
||||||
class ActiveRunnable<void, ArgType, OwnerType>: public ActiveRunnableBase
|
class ActiveRunnable<void, ArgType, OwnerType>: public ActiveRunnableBase
|
||||||
/// This class is used by ActiveMethod.
|
/// This class is used by ActiveMethod.
|
||||||
/// See the ActiveMethod class for more information.
|
/// See the ActiveMethod class for more information.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef void (OwnerType::*Callback)(const ArgType&);
|
typedef void (OwnerType::*Callback)(const ArgType&);
|
||||||
typedef ActiveResult<void> ActiveResultType;
|
typedef ActiveResult<void> ActiveResultType;
|
||||||
|
|
||||||
ActiveRunnable(OwnerType* pOwner, Callback method, const ArgType& arg, const ActiveResultType& result):
|
ActiveRunnable(OwnerType* pOwner, Callback method, const ArgType& arg, const ActiveResultType& result):
|
||||||
_pOwner(pOwner),
|
_pOwner(pOwner),
|
||||||
_method(method),
|
_method(method),
|
||||||
_arg(arg),
|
_arg(arg),
|
||||||
_result(result)
|
_result(result)
|
||||||
{
|
{
|
||||||
poco_check_ptr (pOwner);
|
poco_check_ptr (pOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
|
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
(_pOwner->*_method)(_arg);
|
(_pOwner->*_method)(_arg);
|
||||||
}
|
}
|
||||||
catch (Exception& e)
|
catch (Exception& e)
|
||||||
{
|
{
|
||||||
_result.error(e);
|
_result.error(e);
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
_result.error(e.what());
|
_result.error(e.what());
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
_result.error("unknown exception");
|
_result.error("unknown exception");
|
||||||
}
|
}
|
||||||
_result.notify();
|
_result.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OwnerType* _pOwner;
|
OwnerType* _pOwner;
|
||||||
Callback _method;
|
Callback _method;
|
||||||
ArgType _arg;
|
ArgType _arg;
|
||||||
ActiveResultType _result;
|
ActiveResultType _result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class ResultType, class OwnerType>
|
template <class ResultType, class OwnerType>
|
||||||
class ActiveRunnable<ResultType, void, OwnerType>: public ActiveRunnableBase
|
class ActiveRunnable<ResultType, void, OwnerType>: public ActiveRunnableBase
|
||||||
/// This class is used by ActiveMethod.
|
/// This class is used by ActiveMethod.
|
||||||
/// See the ActiveMethod class for more information.
|
/// See the ActiveMethod class for more information.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef ResultType (OwnerType::*Callback)();
|
typedef ResultType (OwnerType::*Callback)();
|
||||||
typedef ActiveResult<ResultType> ActiveResultType;
|
typedef ActiveResult<ResultType> ActiveResultType;
|
||||||
|
|
||||||
ActiveRunnable(OwnerType* pOwner, Callback method, const ActiveResultType& result):
|
ActiveRunnable(OwnerType* pOwner, Callback method, const ActiveResultType& result):
|
||||||
_pOwner(pOwner),
|
_pOwner(pOwner),
|
||||||
_method(method),
|
_method(method),
|
||||||
_result(result)
|
_result(result)
|
||||||
{
|
{
|
||||||
poco_check_ptr (pOwner);
|
poco_check_ptr (pOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
|
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_result.data(new ResultType((_pOwner->*_method)()));
|
_result.data(new ResultType((_pOwner->*_method)()));
|
||||||
}
|
}
|
||||||
catch (Exception& e)
|
catch (Exception& e)
|
||||||
{
|
{
|
||||||
_result.error(e);
|
_result.error(e);
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
_result.error(e.what());
|
_result.error(e.what());
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
_result.error("unknown exception");
|
_result.error("unknown exception");
|
||||||
}
|
}
|
||||||
_result.notify();
|
_result.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OwnerType* _pOwner;
|
OwnerType* _pOwner;
|
||||||
Callback _method;
|
Callback _method;
|
||||||
ActiveResultType _result;
|
ActiveResultType _result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class OwnerType>
|
template <class OwnerType>
|
||||||
class ActiveRunnable<void, void, OwnerType>: public ActiveRunnableBase
|
class ActiveRunnable<void, void, OwnerType>: public ActiveRunnableBase
|
||||||
/// This class is used by ActiveMethod.
|
/// This class is used by ActiveMethod.
|
||||||
/// See the ActiveMethod class for more information.
|
/// See the ActiveMethod class for more information.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef void (OwnerType::*Callback)();
|
typedef void (OwnerType::*Callback)();
|
||||||
typedef ActiveResult<void> ActiveResultType;
|
typedef ActiveResult<void> ActiveResultType;
|
||||||
|
|
||||||
ActiveRunnable(OwnerType* pOwner, Callback method, const ActiveResultType& result):
|
ActiveRunnable(OwnerType* pOwner, Callback method, const ActiveResultType& result):
|
||||||
_pOwner(pOwner),
|
_pOwner(pOwner),
|
||||||
_method(method),
|
_method(method),
|
||||||
_result(result)
|
_result(result)
|
||||||
{
|
{
|
||||||
poco_check_ptr (pOwner);
|
poco_check_ptr (pOwner);
|
||||||
}
|
}
|
||||||
|
|
||||||
void run()
|
void run()
|
||||||
{
|
{
|
||||||
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
|
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
(_pOwner->*_method)();
|
(_pOwner->*_method)();
|
||||||
}
|
}
|
||||||
catch (Exception& e)
|
catch (Exception& e)
|
||||||
{
|
{
|
||||||
_result.error(e);
|
_result.error(e);
|
||||||
}
|
}
|
||||||
catch (std::exception& e)
|
catch (std::exception& e)
|
||||||
{
|
{
|
||||||
_result.error(e.what());
|
_result.error(e.what());
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
_result.error("unknown exception");
|
_result.error("unknown exception");
|
||||||
}
|
}
|
||||||
_result.notify();
|
_result.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
OwnerType* _pOwner;
|
OwnerType* _pOwner;
|
||||||
Callback _method;
|
Callback _method;
|
||||||
ActiveResultType _result;
|
ActiveResultType _result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_ActiveRunnable_INCLUDED
|
#endif // Foundation_ActiveRunnable_INCLUDED
|
||||||
|
|||||||
@@ -1,70 +1,70 @@
|
|||||||
//
|
//
|
||||||
// ActiveStarter.h
|
// ActiveStarter.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ActiveStarter.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ActiveStarter.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
// Module: ActiveObjects
|
// Module: ActiveObjects
|
||||||
//
|
//
|
||||||
// Definition of the ActiveStarter class.
|
// Definition of the ActiveStarter class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006-2007, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006-2007, 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_ActiveStarter_INCLUDED
|
#ifndef Foundation_ActiveStarter_INCLUDED
|
||||||
#define Foundation_ActiveStarter_INCLUDED
|
#define Foundation_ActiveStarter_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/ThreadPool.h"
|
#include "Poco/ThreadPool.h"
|
||||||
#include "Poco/ActiveRunnable.h"
|
#include "Poco/ActiveRunnable.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class OwnerType>
|
template <class OwnerType>
|
||||||
class ActiveStarter
|
class ActiveStarter
|
||||||
/// The default implementation of the StarterType
|
/// The default implementation of the StarterType
|
||||||
/// policy for ActiveMethod. It starts the method
|
/// policy for ActiveMethod. It starts the method
|
||||||
/// in its own thread, obtained from the default
|
/// in its own thread, obtained from the default
|
||||||
/// thread pool.
|
/// thread pool.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void start(OwnerType* pOwner, ActiveRunnableBase::Ptr pRunnable)
|
static void start(OwnerType* pOwner, ActiveRunnableBase::Ptr pRunnable)
|
||||||
{
|
{
|
||||||
ThreadPool::defaultPool().start(*pRunnable);
|
ThreadPool::defaultPool().start(*pRunnable);
|
||||||
pRunnable->duplicate(); // The runnable will release itself.
|
pRunnable->duplicate(); // The runnable will release itself.
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_ActiveStarter_INCLUDED
|
#endif // Foundation_ActiveStarter_INCLUDED
|
||||||
|
|||||||
@@ -1,286 +1,286 @@
|
|||||||
//
|
//
|
||||||
// Any.h
|
// Any.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Any.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Any.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: Any
|
// Module: Any
|
||||||
//
|
//
|
||||||
// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved.
|
// Copyright Kevlin Henney, 2000, 2001, 2002. All rights reserved.
|
||||||
// Extracted from Boost 1.33.1 lib and adapted for poco: Peter Schojer/AppliedInformatics 2006-02-02
|
// Extracted from Boost 1.33.1 lib and adapted for poco: Peter Schojer/AppliedInformatics 2006-02-02
|
||||||
//
|
//
|
||||||
// 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_Any_INCLUDED
|
#ifndef Foundation_Any_INCLUDED
|
||||||
#define Foundation_Any_INCLUDED
|
#define Foundation_Any_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Any
|
class Any
|
||||||
/// An Any class represents a general type and is capable of storing any type, supporting type-safe extraction
|
/// An Any class represents a general type and is capable of storing any type, supporting type-safe extraction
|
||||||
/// of the internally stored data.
|
/// of the internally stored data.
|
||||||
///
|
///
|
||||||
/// Code taken from the Boost 1.33.1 library. Original copyright by Kevlin Henney. Modified for Poco
|
/// Code taken from the Boost 1.33.1 library. Original copyright by Kevlin Henney. Modified for Poco
|
||||||
/// by Applied Informatics.
|
/// by Applied Informatics.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Any():
|
Any():
|
||||||
_content(0)
|
_content(0)
|
||||||
/// Creates an empty any type.
|
/// Creates an empty any type.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
Any(const ValueType& value):
|
Any(const ValueType& value):
|
||||||
_content(new Holder<ValueType>(value))
|
_content(new Holder<ValueType>(value))
|
||||||
/// Creates an any which stores the init parameter inside.
|
/// Creates an any which stores the init parameter inside.
|
||||||
///
|
///
|
||||||
/// Example:
|
/// Example:
|
||||||
/// Any a(13);
|
/// Any a(13);
|
||||||
/// Any a(string("12345"));
|
/// Any a(string("12345"));
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Any(const Any& other):
|
Any(const Any& other):
|
||||||
_content(other._content ? other._content->clone() : 0)
|
_content(other._content ? other._content->clone() : 0)
|
||||||
/// Copy constructor, works with empty Anys and initialized Any values.
|
/// Copy constructor, works with empty Anys and initialized Any values.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~Any()
|
~Any()
|
||||||
{
|
{
|
||||||
delete _content;
|
delete _content;
|
||||||
}
|
}
|
||||||
|
|
||||||
Any& swap(Any& rhs)
|
Any& swap(Any& rhs)
|
||||||
/// Swaps the content of the two Anys.
|
/// Swaps the content of the two Anys.
|
||||||
{
|
{
|
||||||
std::swap(_content, rhs._content);
|
std::swap(_content, rhs._content);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
Any& operator = (const ValueType& rhs)
|
Any& operator = (const ValueType& rhs)
|
||||||
/// Assignment operator for all types != Any.
|
/// Assignment operator for all types != Any.
|
||||||
///
|
///
|
||||||
/// Example:
|
/// Example:
|
||||||
/// Any a = 13;
|
/// Any a = 13;
|
||||||
/// Any a = string("12345");
|
/// Any a = string("12345");
|
||||||
{
|
{
|
||||||
Any(rhs).swap(*this);
|
Any(rhs).swap(*this);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
Any& operator = (const Any& rhs)
|
Any& operator = (const Any& rhs)
|
||||||
/// Assignment operator for Any.
|
/// Assignment operator for Any.
|
||||||
{
|
{
|
||||||
Any(rhs).swap(*this);
|
Any(rhs).swap(*this);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty() const
|
bool empty() const
|
||||||
/// returns true if the Any is empty
|
/// returns true if the Any is empty
|
||||||
{
|
{
|
||||||
return !_content;
|
return !_content;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::type_info& type() const
|
const std::type_info& type() const
|
||||||
/// Returns the type information of the stored content.
|
/// Returns the type information of the stored content.
|
||||||
/// If the Any is empty typeid(void) is returned.
|
/// If the Any is empty typeid(void) is returned.
|
||||||
/// It is suggested to always query an Any for its type info before trying to extract
|
/// It is suggested to always query an Any for its type info before trying to extract
|
||||||
/// data via an AnyCast/RefAnyCast.
|
/// data via an AnyCast/RefAnyCast.
|
||||||
{
|
{
|
||||||
return _content ? _content->type() : typeid(void);
|
return _content ? _content->type() : typeid(void);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
class Placeholder
|
class Placeholder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
virtual ~Placeholder()
|
virtual ~Placeholder()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const std::type_info& type() const = 0;
|
virtual const std::type_info& type() const = 0;
|
||||||
virtual Placeholder* clone() const = 0;
|
virtual Placeholder* clone() const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
class Holder: public Placeholder
|
class Holder: public Placeholder
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Holder(const ValueType& value):
|
Holder(const ValueType& value):
|
||||||
_held(value)
|
_held(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual const std::type_info& type() const
|
virtual const std::type_info& type() const
|
||||||
{
|
{
|
||||||
return typeid(ValueType);
|
return typeid(ValueType);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Placeholder* clone() const
|
virtual Placeholder* clone() const
|
||||||
{
|
{
|
||||||
return new Holder(_held);
|
return new Holder(_held);
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueType _held;
|
ValueType _held;
|
||||||
};
|
};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
friend ValueType* AnyCast(Any*);
|
friend ValueType* AnyCast(Any*);
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
friend ValueType* UnsafeAnyCast(Any*);
|
friend ValueType* UnsafeAnyCast(Any*);
|
||||||
|
|
||||||
Placeholder* _content;
|
Placeholder* _content;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
ValueType* AnyCast(Any* operand)
|
ValueType* AnyCast(Any* operand)
|
||||||
/// AnyCast operator used to extract the ValueType from an Any*. Will return a pointer
|
/// AnyCast operator used to extract the ValueType from an Any*. Will return a pointer
|
||||||
/// to the stored value.
|
/// to the stored value.
|
||||||
///
|
///
|
||||||
/// Example Usage:
|
/// Example Usage:
|
||||||
/// MyType* pTmp = AnyCast<MyType*>(pAny).
|
/// MyType* pTmp = AnyCast<MyType*>(pAny).
|
||||||
/// Will return NULL if the cast fails, i.e. types don't match.
|
/// Will return NULL if the cast fails, i.e. types don't match.
|
||||||
{
|
{
|
||||||
return operand && operand->type() == typeid(ValueType)
|
return operand && operand->type() == typeid(ValueType)
|
||||||
? &static_cast<Any::Holder<ValueType>*>(operand->_content)->_held
|
? &static_cast<Any::Holder<ValueType>*>(operand->_content)->_held
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
const ValueType* AnyCast(const Any* operand)
|
const ValueType* AnyCast(const Any* operand)
|
||||||
/// AnyCast operator used to extract a const ValueType pointer from an const Any*. Will return a const pointer
|
/// AnyCast operator used to extract a const ValueType pointer from an const Any*. Will return a const pointer
|
||||||
/// to the stored value.
|
/// to the stored value.
|
||||||
///
|
///
|
||||||
/// Example Usage:
|
/// Example Usage:
|
||||||
/// const MyType* pTmp = AnyCast<MyType*>(pAny).
|
/// const MyType* pTmp = AnyCast<MyType*>(pAny).
|
||||||
/// Will return NULL if the cast fails, i.e. types don't match.
|
/// Will return NULL if the cast fails, i.e. types don't match.
|
||||||
{
|
{
|
||||||
return AnyCast<ValueType>(const_cast<Any*>(operand));
|
return AnyCast<ValueType>(const_cast<Any*>(operand));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
ValueType AnyCast(const Any& operand)
|
ValueType AnyCast(const Any& operand)
|
||||||
/// AnyCast operator used to extract a copy of the ValueType from an const Any&.
|
/// AnyCast operator used to extract a copy of the ValueType from an const Any&.
|
||||||
///
|
///
|
||||||
/// Example Usage:
|
/// Example Usage:
|
||||||
/// MyType tmp = AnyCast<MyType>(anAny).
|
/// MyType tmp = AnyCast<MyType>(anAny).
|
||||||
/// Will throw a BadCastException if the cast fails.
|
/// Will throw a BadCastException if the cast fails.
|
||||||
/// Dont use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& = ...
|
/// Dont use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& = ...
|
||||||
/// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in
|
/// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in
|
||||||
/// these cases.
|
/// these cases.
|
||||||
{
|
{
|
||||||
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
|
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
|
||||||
if (!result) throw BadCastException("Failed to convert between const Any types");
|
if (!result) throw BadCastException("Failed to convert between const Any types");
|
||||||
return *result;
|
return *result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
ValueType AnyCast(Any& operand)
|
ValueType AnyCast(Any& operand)
|
||||||
/// AnyCast operator used to extract a copy of the ValueType from an Any&.
|
/// AnyCast operator used to extract a copy of the ValueType from an Any&.
|
||||||
///
|
///
|
||||||
/// Example Usage:
|
/// Example Usage:
|
||||||
/// MyType tmp = AnyCast<MyType>(anAny).
|
/// MyType tmp = AnyCast<MyType>(anAny).
|
||||||
/// Will throw a BadCastException if the cast fails.
|
/// Will throw a BadCastException if the cast fails.
|
||||||
/// Dont use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& tmp = ...
|
/// Dont use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& tmp = ...
|
||||||
/// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in
|
/// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in
|
||||||
/// these cases.
|
/// these cases.
|
||||||
{
|
{
|
||||||
ValueType* result = AnyCast<ValueType>(&operand);
|
ValueType* result = AnyCast<ValueType>(&operand);
|
||||||
if (!result) throw BadCastException("Failed to convert between Any types");
|
if (!result) throw BadCastException("Failed to convert between Any types");
|
||||||
return *result;
|
return *result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
const ValueType& RefAnyCast(const Any & operand)
|
const ValueType& RefAnyCast(const Any & operand)
|
||||||
/// AnyCast operator used to return a const reference to the internal data.
|
/// AnyCast operator used to return a const reference to the internal data.
|
||||||
///
|
///
|
||||||
/// Example Usage:
|
/// Example Usage:
|
||||||
/// const MyType& tmp = RefAnyCast<MyType>(anAny);
|
/// const MyType& tmp = RefAnyCast<MyType>(anAny);
|
||||||
{
|
{
|
||||||
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
|
ValueType* result = AnyCast<ValueType>(const_cast<Any*>(&operand));
|
||||||
if (!result) throw BadCastException("RefAnyCast: Failed to convert between const Any types");
|
if (!result) throw BadCastException("RefAnyCast: Failed to convert between const Any types");
|
||||||
return *result;
|
return *result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
ValueType& RefAnyCast(Any& operand)
|
ValueType& RefAnyCast(Any& operand)
|
||||||
/// AnyCast operator used to return a reference to the internal data.
|
/// AnyCast operator used to return a reference to the internal data.
|
||||||
///
|
///
|
||||||
/// Example Usage:
|
/// Example Usage:
|
||||||
/// MyType& tmp = RefAnyCast<MyType>(anAny);
|
/// MyType& tmp = RefAnyCast<MyType>(anAny);
|
||||||
{
|
{
|
||||||
ValueType* result = AnyCast<ValueType>(&operand);
|
ValueType* result = AnyCast<ValueType>(&operand);
|
||||||
if (!result) throw BadCastException("RefAnyCast: Failed to convert between Any types");
|
if (!result) throw BadCastException("RefAnyCast: Failed to convert between Any types");
|
||||||
return *result;
|
return *result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
ValueType* UnsafeAnyCast(Any* operand)
|
ValueType* UnsafeAnyCast(Any* operand)
|
||||||
/// The "unsafe" versions of AnyCast are not part of the
|
/// The "unsafe" versions of AnyCast are not part of the
|
||||||
/// public interface and may be removed at any time. They are
|
/// public interface and may be removed at any time. They are
|
||||||
/// required where we know what type is stored in the any and can't
|
/// required where we know what type is stored in the any and can't
|
||||||
/// use typeid() comparison, e.g., when our types may travel across
|
/// use typeid() comparison, e.g., when our types may travel across
|
||||||
/// different shared libraries.
|
/// different shared libraries.
|
||||||
{
|
{
|
||||||
return &static_cast<Any::Holder<ValueType>*>(operand->_content)->_held;
|
return &static_cast<Any::Holder<ValueType>*>(operand->_content)->_held;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template <typename ValueType>
|
template <typename ValueType>
|
||||||
const ValueType* UnsafeAnyCast(const Any* operand)
|
const ValueType* UnsafeAnyCast(const Any* operand)
|
||||||
/// The "unsafe" versions of AnyCast are not part of the
|
/// The "unsafe" versions of AnyCast are not part of the
|
||||||
/// public interface and may be removed at any time. They are
|
/// public interface and may be removed at any time. They are
|
||||||
/// required where we know what type is stored in the any and can't
|
/// required where we know what type is stored in the any and can't
|
||||||
/// use typeid() comparison, e.g., when our types may travel across
|
/// use typeid() comparison, e.g., when our types may travel across
|
||||||
/// different shared libraries.
|
/// different shared libraries.
|
||||||
{
|
{
|
||||||
return AnyCast<ValueType>(const_cast<Any*>(operand));
|
return AnyCast<ValueType>(const_cast<Any*>(operand));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,121 +1,121 @@
|
|||||||
//
|
//
|
||||||
// AsyncChannel.h
|
// AsyncChannel.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/AsyncChannel.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/AsyncChannel.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Logging
|
// Package: Logging
|
||||||
// Module: AsyncChannel
|
// Module: AsyncChannel
|
||||||
//
|
//
|
||||||
// Definition of the AsyncChannel class.
|
// Definition of the AsyncChannel class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2004-2007, 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_AsyncChannel_INCLUDED
|
#ifndef Foundation_AsyncChannel_INCLUDED
|
||||||
#define Foundation_AsyncChannel_INCLUDED
|
#define Foundation_AsyncChannel_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Channel.h"
|
#include "Poco/Channel.h"
|
||||||
#include "Poco/Thread.h"
|
#include "Poco/Thread.h"
|
||||||
#include "Poco/Mutex.h"
|
#include "Poco/Mutex.h"
|
||||||
#include "Poco/Runnable.h"
|
#include "Poco/Runnable.h"
|
||||||
#include "Poco/NotificationQueue.h"
|
#include "Poco/NotificationQueue.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API AsyncChannel: public Channel, public Runnable
|
class Foundation_API AsyncChannel: public Channel, public Runnable
|
||||||
/// A channel uses a separate thread for logging.
|
/// A channel uses a separate thread for logging.
|
||||||
///
|
///
|
||||||
/// Using this channel can help to improve the performance of
|
/// Using this channel can help to improve the performance of
|
||||||
/// applications that produce huge amounts of log messages or
|
/// applications that produce huge amounts of log messages or
|
||||||
/// that write log messages to multiple channels simultaneously.
|
/// that write log messages to multiple channels simultaneously.
|
||||||
///
|
///
|
||||||
/// All log messages are put into a queue and this queue is
|
/// All log messages are put into a queue and this queue is
|
||||||
/// then processed by a separate thread.
|
/// then processed by a separate thread.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AsyncChannel(Channel* pChannel = 0, Thread::Priority prio = Thread::PRIO_NORMAL);
|
AsyncChannel(Channel* pChannel = 0, Thread::Priority prio = Thread::PRIO_NORMAL);
|
||||||
/// Creates the AsyncChannel and connects it to
|
/// Creates the AsyncChannel and connects it to
|
||||||
/// the given channel.
|
/// the given channel.
|
||||||
|
|
||||||
void setChannel(Channel* pChannel);
|
void setChannel(Channel* pChannel);
|
||||||
/// Connects the AsyncChannel to the given target channel.
|
/// Connects the AsyncChannel to the given target channel.
|
||||||
/// All messages will be forwarded to this channel.
|
/// All messages will be forwarded to this channel.
|
||||||
|
|
||||||
Channel* getChannel() const;
|
Channel* getChannel() const;
|
||||||
/// Returns the target channel.
|
/// Returns the target channel.
|
||||||
|
|
||||||
void open();
|
void open();
|
||||||
/// Opens the channel and creates the
|
/// Opens the channel and creates the
|
||||||
/// background ;ogging thread.
|
/// background ;ogging thread.
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
/// Closes the channel and stops the background
|
/// Closes the channel and stops the background
|
||||||
/// logging thread.
|
/// logging thread.
|
||||||
|
|
||||||
void log(const Message& msg);
|
void log(const Message& msg);
|
||||||
/// Queues the message for processing by the
|
/// Queues the message for processing by the
|
||||||
/// background thread.
|
/// background thread.
|
||||||
|
|
||||||
void setProperty(const std::string& name, const std::string& value);
|
void setProperty(const std::string& name, const std::string& value);
|
||||||
/// Sets or changes a configuration property.
|
/// Sets or changes a configuration property.
|
||||||
///
|
///
|
||||||
/// The "channel" property allows setting the target
|
/// The "channel" property allows setting the target
|
||||||
/// channel via the LoggingRegistry.
|
/// channel via the LoggingRegistry.
|
||||||
/// The "channel" property is set-only.
|
/// The "channel" property is set-only.
|
||||||
///
|
///
|
||||||
/// The "priority" property allows setting the thread
|
/// The "priority" property allows setting the thread
|
||||||
/// priority. The following values are supported:
|
/// priority. The following values are supported:
|
||||||
/// * lowest
|
/// * lowest
|
||||||
/// * low
|
/// * low
|
||||||
/// * normal (default)
|
/// * normal (default)
|
||||||
/// * high
|
/// * high
|
||||||
/// * highest
|
/// * highest
|
||||||
///
|
///
|
||||||
/// The "priority" property is set-only.
|
/// The "priority" property is set-only.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~AsyncChannel();
|
~AsyncChannel();
|
||||||
void run();
|
void run();
|
||||||
void setPriority(const std::string& value);
|
void setPriority(const std::string& value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Channel* _pChannel;
|
Channel* _pChannel;
|
||||||
Thread _thread;
|
Thread _thread;
|
||||||
FastMutex _mutex;
|
FastMutex _mutex;
|
||||||
NotificationQueue _queue;
|
NotificationQueue _queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_AsyncChannel_INCLUDED
|
#endif // Foundation_AsyncChannel_INCLUDED
|
||||||
|
|||||||
@@ -1,378 +1,378 @@
|
|||||||
//
|
//
|
||||||
// AutoPtr.h
|
// AutoPtr.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/AutoPtr.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/AutoPtr.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: AutoPtr
|
// Module: AutoPtr
|
||||||
//
|
//
|
||||||
// Definition of the AutoPtr template class.
|
// Definition of the AutoPtr template 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_AutoPtr_INCLUDED
|
#ifndef Foundation_AutoPtr_INCLUDED
|
||||||
#define Foundation_AutoPtr_INCLUDED
|
#define Foundation_AutoPtr_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class C>
|
template <class C>
|
||||||
class AutoPtr
|
class AutoPtr
|
||||||
/// AutoPtr is a "smart" pointer for classes implementing
|
/// AutoPtr is a "smart" pointer for classes implementing
|
||||||
/// reference counting based garbage collection.
|
/// reference counting based garbage collection.
|
||||||
/// To be usable with the AutoPtr template, a class must
|
/// To be usable with the AutoPtr template, a class must
|
||||||
/// implement the following behaviour:
|
/// implement the following behaviour:
|
||||||
/// A class must maintain a reference count.
|
/// A class must maintain a reference count.
|
||||||
/// The constructors of the object initialize the reference
|
/// The constructors of the object initialize the reference
|
||||||
/// count to one.
|
/// count to one.
|
||||||
/// The class must implement a public duplicate() method:
|
/// The class must implement a public duplicate() method:
|
||||||
/// void duplicate();
|
/// void duplicate();
|
||||||
/// that increments the reference count by one.
|
/// that increments the reference count by one.
|
||||||
/// The class must implement a public release() method:
|
/// The class must implement a public release() method:
|
||||||
/// void release()
|
/// void release()
|
||||||
/// that decrements the reference count by one, and,
|
/// that decrements the reference count by one, and,
|
||||||
/// if the reference count reaches zero, deletes the
|
/// if the reference count reaches zero, deletes the
|
||||||
/// object.
|
/// object.
|
||||||
///
|
///
|
||||||
/// AutoPtr works in the following way:
|
/// AutoPtr works in the following way:
|
||||||
/// If an AutoPtr is assigned an ordinary pointer to
|
/// If an AutoPtr is assigned an ordinary pointer to
|
||||||
/// an object (via the constructor or the assignment operator),
|
/// an object (via the constructor or the assignment operator),
|
||||||
/// it takes ownership of the object and the object's reference
|
/// it takes ownership of the object and the object's reference
|
||||||
/// count remains unchanged.
|
/// count remains unchanged.
|
||||||
/// If the AutoPtr is assigned another AutoPtr, the
|
/// If the AutoPtr is assigned another AutoPtr, the
|
||||||
/// object's reference count is incremented by one by
|
/// object's reference count is incremented by one by
|
||||||
/// calling duplicate() on its object.
|
/// calling duplicate() on its object.
|
||||||
/// The destructor of AutoPtr calls release() on its
|
/// The destructor of AutoPtr calls release() on its
|
||||||
/// object.
|
/// object.
|
||||||
/// AutoPtr supports dereferencing with both the ->
|
/// AutoPtr supports dereferencing with both the ->
|
||||||
/// and the * operator. An attempt to dereference a null
|
/// and the * operator. An attempt to dereference a null
|
||||||
/// AutoPtr results in a NullPointerException being thrown.
|
/// AutoPtr results in a NullPointerException being thrown.
|
||||||
/// AutoPtr also implements all relational operators.
|
/// AutoPtr also implements all relational operators.
|
||||||
/// Note that AutoPtr allows casting of its encapsulated data types.
|
/// Note that AutoPtr allows casting of its encapsulated data types.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AutoPtr(): _ptr(0)
|
AutoPtr(): _ptr(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoPtr(C* ptr): _ptr(ptr)
|
AutoPtr(C* ptr): _ptr(ptr)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoPtr(C* ptr, bool shared): _ptr(ptr)
|
AutoPtr(C* ptr, bool shared): _ptr(ptr)
|
||||||
{
|
{
|
||||||
if (shared && _ptr) _ptr->duplicate();
|
if (shared && _ptr) _ptr->duplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoPtr(const AutoPtr& ptr): _ptr(ptr._ptr)
|
AutoPtr(const AutoPtr& ptr): _ptr(ptr._ptr)
|
||||||
{
|
{
|
||||||
if (_ptr) _ptr->duplicate();
|
if (_ptr) _ptr->duplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Other>
|
template <class Other>
|
||||||
AutoPtr(const AutoPtr<Other>& ptr): _ptr(const_cast<Other*>(ptr.get()))
|
AutoPtr(const AutoPtr<Other>& ptr): _ptr(const_cast<Other*>(ptr.get()))
|
||||||
{
|
{
|
||||||
if (_ptr) _ptr->duplicate();
|
if (_ptr) _ptr->duplicate();
|
||||||
}
|
}
|
||||||
|
|
||||||
~AutoPtr()
|
~AutoPtr()
|
||||||
{
|
{
|
||||||
if (_ptr) _ptr->release();
|
if (_ptr) _ptr->release();
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoPtr& assign(C* ptr)
|
AutoPtr& assign(C* ptr)
|
||||||
{
|
{
|
||||||
if (_ptr != ptr)
|
if (_ptr != ptr)
|
||||||
{
|
{
|
||||||
if (_ptr) _ptr->release();
|
if (_ptr) _ptr->release();
|
||||||
_ptr = ptr;
|
_ptr = ptr;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoPtr& assign(C* ptr, bool shared)
|
AutoPtr& assign(C* ptr, bool shared)
|
||||||
{
|
{
|
||||||
if (_ptr != ptr)
|
if (_ptr != ptr)
|
||||||
{
|
{
|
||||||
if (_ptr) _ptr->release();
|
if (_ptr) _ptr->release();
|
||||||
_ptr = ptr;
|
_ptr = ptr;
|
||||||
if (shared && _ptr) _ptr->duplicate();
|
if (shared && _ptr) _ptr->duplicate();
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoPtr& assign(const AutoPtr& ptr)
|
AutoPtr& assign(const AutoPtr& ptr)
|
||||||
{
|
{
|
||||||
if (&ptr != this)
|
if (&ptr != this)
|
||||||
{
|
{
|
||||||
if (_ptr) _ptr->release();
|
if (_ptr) _ptr->release();
|
||||||
_ptr = ptr._ptr;
|
_ptr = ptr._ptr;
|
||||||
if (_ptr) _ptr->duplicate();
|
if (_ptr) _ptr->duplicate();
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Other>
|
template <class Other>
|
||||||
AutoPtr& assign(const AutoPtr<Other>& ptr)
|
AutoPtr& assign(const AutoPtr<Other>& ptr)
|
||||||
{
|
{
|
||||||
if (ptr.get() != _ptr)
|
if (ptr.get() != _ptr)
|
||||||
{
|
{
|
||||||
if (_ptr) _ptr->release();
|
if (_ptr) _ptr->release();
|
||||||
_ptr = const_cast<Other*>(ptr.get());
|
_ptr = const_cast<Other*>(ptr.get());
|
||||||
if (_ptr) _ptr->duplicate();
|
if (_ptr) _ptr->duplicate();
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoPtr& operator = (C* ptr)
|
AutoPtr& operator = (C* ptr)
|
||||||
{
|
{
|
||||||
return assign(ptr);
|
return assign(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoPtr& operator = (const AutoPtr& ptr)
|
AutoPtr& operator = (const AutoPtr& ptr)
|
||||||
{
|
{
|
||||||
return assign(ptr);
|
return assign(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Other>
|
template <class Other>
|
||||||
AutoPtr& operator = (const AutoPtr<Other>& ptr)
|
AutoPtr& operator = (const AutoPtr<Other>& ptr)
|
||||||
{
|
{
|
||||||
return assign<Other>(ptr);
|
return assign<Other>(ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(AutoPtr& ptr)
|
void swap(AutoPtr& ptr)
|
||||||
{
|
{
|
||||||
std::swap(_ptr, ptr._ptr);
|
std::swap(_ptr, ptr._ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Other>
|
template <class Other>
|
||||||
AutoPtr<Other> cast() const
|
AutoPtr<Other> cast() const
|
||||||
/// Casts the AutoPtr via a dynamic cast to the given type.
|
/// Casts the AutoPtr via a dynamic cast to the given type.
|
||||||
/// Returns an AutoPtr containing NULL if the cast fails.
|
/// Returns an AutoPtr containing NULL if the cast fails.
|
||||||
/// Example: (assume class Sub: public Super)
|
/// Example: (assume class Sub: public Super)
|
||||||
/// AutoPtr<Super> super(new Sub());
|
/// AutoPtr<Super> super(new Sub());
|
||||||
/// AutoPtr<Sub> sub = super.cast<Sub>();
|
/// AutoPtr<Sub> sub = super.cast<Sub>();
|
||||||
/// poco_assert (sub.get());
|
/// poco_assert (sub.get());
|
||||||
{
|
{
|
||||||
Other* pOther = dynamic_cast<Other*>(_ptr);
|
Other* pOther = dynamic_cast<Other*>(_ptr);
|
||||||
return AutoPtr<Other>(pOther, true);
|
return AutoPtr<Other>(pOther, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Other>
|
template <class Other>
|
||||||
AutoPtr<Other> unsafeCast() const
|
AutoPtr<Other> unsafeCast() const
|
||||||
/// Casts the AutoPtr via a static cast to the given type.
|
/// Casts the AutoPtr via a static cast to the given type.
|
||||||
/// Example: (assume class Sub: public Super)
|
/// Example: (assume class Sub: public Super)
|
||||||
/// AutoPtr<Super> super(new Sub());
|
/// AutoPtr<Super> super(new Sub());
|
||||||
/// AutoPtr<Sub> sub = super.unsafeCast<Sub>();
|
/// AutoPtr<Sub> sub = super.unsafeCast<Sub>();
|
||||||
/// poco_assert (sub.get());
|
/// poco_assert (sub.get());
|
||||||
{
|
{
|
||||||
Other* pOther = static_cast<Other*>(_ptr);
|
Other* pOther = static_cast<Other*>(_ptr);
|
||||||
return AutoPtr<Other>(pOther, true);
|
return AutoPtr<Other>(pOther, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
C* operator -> ()
|
C* operator -> ()
|
||||||
{
|
{
|
||||||
if (_ptr)
|
if (_ptr)
|
||||||
return _ptr;
|
return _ptr;
|
||||||
else
|
else
|
||||||
throw NullPointerException();
|
throw NullPointerException();
|
||||||
}
|
}
|
||||||
|
|
||||||
const C* operator -> () const
|
const C* operator -> () const
|
||||||
{
|
{
|
||||||
if (_ptr)
|
if (_ptr)
|
||||||
return _ptr;
|
return _ptr;
|
||||||
else
|
else
|
||||||
throw NullPointerException();
|
throw NullPointerException();
|
||||||
}
|
}
|
||||||
|
|
||||||
C& operator * ()
|
C& operator * ()
|
||||||
{
|
{
|
||||||
if (_ptr)
|
if (_ptr)
|
||||||
return *_ptr;
|
return *_ptr;
|
||||||
else
|
else
|
||||||
throw NullPointerException();
|
throw NullPointerException();
|
||||||
}
|
}
|
||||||
|
|
||||||
const C& operator * () const
|
const C& operator * () const
|
||||||
{
|
{
|
||||||
if (_ptr)
|
if (_ptr)
|
||||||
return *_ptr;
|
return *_ptr;
|
||||||
else
|
else
|
||||||
throw NullPointerException();
|
throw NullPointerException();
|
||||||
}
|
}
|
||||||
|
|
||||||
C* get()
|
C* get()
|
||||||
{
|
{
|
||||||
return _ptr;
|
return _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const C* get() const
|
const C* get() const
|
||||||
{
|
{
|
||||||
return _ptr;
|
return _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator C* ()
|
operator C* ()
|
||||||
{
|
{
|
||||||
return _ptr;
|
return _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator const C* () const
|
operator const C* () const
|
||||||
{
|
{
|
||||||
return _ptr;
|
return _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator ! () const
|
bool operator ! () const
|
||||||
{
|
{
|
||||||
return _ptr == 0;
|
return _ptr == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isNull() const
|
bool isNull() const
|
||||||
{
|
{
|
||||||
return _ptr == 0;
|
return _ptr == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
C* duplicate()
|
C* duplicate()
|
||||||
{
|
{
|
||||||
if (_ptr) _ptr->duplicate();
|
if (_ptr) _ptr->duplicate();
|
||||||
return _ptr;
|
return _ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator == (const AutoPtr& ptr) const
|
bool operator == (const AutoPtr& ptr) const
|
||||||
{
|
{
|
||||||
return _ptr == ptr._ptr;
|
return _ptr == ptr._ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator == (const C* ptr) const
|
bool operator == (const C* ptr) const
|
||||||
{
|
{
|
||||||
return _ptr == ptr;
|
return _ptr == ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator == (C* ptr) const
|
bool operator == (C* ptr) const
|
||||||
{
|
{
|
||||||
return _ptr == ptr;
|
return _ptr == ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator != (const AutoPtr& ptr) const
|
bool operator != (const AutoPtr& ptr) const
|
||||||
{
|
{
|
||||||
return _ptr != ptr._ptr;
|
return _ptr != ptr._ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator != (const C* ptr) const
|
bool operator != (const C* ptr) const
|
||||||
{
|
{
|
||||||
return _ptr != ptr;
|
return _ptr != ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator != (C* ptr) const
|
bool operator != (C* ptr) const
|
||||||
{
|
{
|
||||||
return _ptr != ptr;
|
return _ptr != ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator < (const AutoPtr& ptr) const
|
bool operator < (const AutoPtr& ptr) const
|
||||||
{
|
{
|
||||||
return _ptr < ptr._ptr;
|
return _ptr < ptr._ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator < (const C* ptr) const
|
bool operator < (const C* ptr) const
|
||||||
{
|
{
|
||||||
return _ptr < ptr;
|
return _ptr < ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator < (C* ptr) const
|
bool operator < (C* ptr) const
|
||||||
{
|
{
|
||||||
return _ptr < ptr;
|
return _ptr < ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator <= (const AutoPtr& ptr) const
|
bool operator <= (const AutoPtr& ptr) const
|
||||||
{
|
{
|
||||||
return _ptr <= ptr._ptr;
|
return _ptr <= ptr._ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator <= (const C* ptr) const
|
bool operator <= (const C* ptr) const
|
||||||
{
|
{
|
||||||
return _ptr <= ptr;
|
return _ptr <= ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator <= (C* ptr) const
|
bool operator <= (C* ptr) const
|
||||||
{
|
{
|
||||||
return _ptr <= ptr;
|
return _ptr <= ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator > (const AutoPtr& ptr) const
|
bool operator > (const AutoPtr& ptr) const
|
||||||
{
|
{
|
||||||
return _ptr > ptr._ptr;
|
return _ptr > ptr._ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator > (const C* ptr) const
|
bool operator > (const C* ptr) const
|
||||||
{
|
{
|
||||||
return _ptr > ptr;
|
return _ptr > ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator > (C* ptr) const
|
bool operator > (C* ptr) const
|
||||||
{
|
{
|
||||||
return _ptr > ptr;
|
return _ptr > ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator >= (const AutoPtr& ptr) const
|
bool operator >= (const AutoPtr& ptr) const
|
||||||
{
|
{
|
||||||
return _ptr >= ptr._ptr;
|
return _ptr >= ptr._ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator >= (const C* ptr) const
|
bool operator >= (const C* ptr) const
|
||||||
{
|
{
|
||||||
return _ptr >= ptr;
|
return _ptr >= ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator >= (C* ptr) const
|
bool operator >= (C* ptr) const
|
||||||
{
|
{
|
||||||
return _ptr >= ptr;
|
return _ptr >= ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
C* _ptr;
|
C* _ptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class C>
|
template <class C>
|
||||||
inline void swap(AutoPtr<C>& p1, AutoPtr<C>& p2)
|
inline void swap(AutoPtr<C>& p1, AutoPtr<C>& p2)
|
||||||
{
|
{
|
||||||
p1.swap(p2);
|
p1.swap(p2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_AutoPtr_INCLUDED
|
#endif // Foundation_AutoPtr_INCLUDED
|
||||||
|
|||||||
@@ -1,108 +1,108 @@
|
|||||||
//
|
//
|
||||||
// AutoReleasePool.h
|
// AutoReleasePool.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/AutoReleasePool.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/AutoReleasePool.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: AutoReleasePool
|
// Module: AutoReleasePool
|
||||||
//
|
//
|
||||||
// Definition of the AutoReleasePool class.
|
// Definition of the AutoReleasePool 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_AutoReleasePool_INCLUDED
|
#ifndef Foundation_AutoReleasePool_INCLUDED
|
||||||
#define Foundation_AutoReleasePool_INCLUDED
|
#define Foundation_AutoReleasePool_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class C>
|
template <class C>
|
||||||
class AutoReleasePool
|
class AutoReleasePool
|
||||||
/// An AutoReleasePool implements simple garbage collection for
|
/// An AutoReleasePool implements simple garbage collection for
|
||||||
/// reference-counted objects.
|
/// reference-counted objects.
|
||||||
/// It temporarily takes ownwership of reference-counted objects that
|
/// It temporarily takes ownwership of reference-counted objects that
|
||||||
/// nobody else wants to take ownership of and releases them
|
/// nobody else wants to take ownership of and releases them
|
||||||
/// at a later, appropriate point in time.
|
/// at a later, appropriate point in time.
|
||||||
///
|
///
|
||||||
/// Note: The correct way to add an object hold by an AutoPtr<> to
|
/// Note: The correct way to add an object hold by an AutoPtr<> to
|
||||||
/// an AutoReleasePool is by invoking the AutoPtr's duplicate()
|
/// an AutoReleasePool is by invoking the AutoPtr's duplicate()
|
||||||
/// method. Example:
|
/// method. Example:
|
||||||
/// AutoReleasePool<C> arp;
|
/// AutoReleasePool<C> arp;
|
||||||
/// AutoPtr<C> ptr = new C;
|
/// AutoPtr<C> ptr = new C;
|
||||||
/// ...
|
/// ...
|
||||||
/// arp.add(ptr.duplicate());
|
/// arp.add(ptr.duplicate());
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AutoReleasePool()
|
AutoReleasePool()
|
||||||
/// Creates the AutoReleasePool.
|
/// Creates the AutoReleasePool.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~AutoReleasePool()
|
~AutoReleasePool()
|
||||||
/// Destroys the AutoReleasePool and releases
|
/// Destroys the AutoReleasePool and releases
|
||||||
/// all objects it currently holds.
|
/// all objects it currently holds.
|
||||||
{
|
{
|
||||||
release();
|
release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(C* pObject)
|
void add(C* pObject)
|
||||||
/// Adds the given object to the AutoReleasePool.
|
/// Adds the given object to the AutoReleasePool.
|
||||||
/// The object's reference count is not modified
|
/// The object's reference count is not modified
|
||||||
{
|
{
|
||||||
if (pObject)
|
if (pObject)
|
||||||
_list.push_back(pObject);
|
_list.push_back(pObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
void release()
|
void release()
|
||||||
/// Releases all objects the AutoReleasePool currently holds
|
/// Releases all objects the AutoReleasePool currently holds
|
||||||
/// by calling each object's release() method.
|
/// by calling each object's release() method.
|
||||||
{
|
{
|
||||||
while (!_list.empty())
|
while (!_list.empty())
|
||||||
{
|
{
|
||||||
_list.front()->release();
|
_list.front()->release();
|
||||||
_list.pop_front();
|
_list.pop_front();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef std::list<C*> ObjectList;
|
typedef std::list<C*> ObjectList;
|
||||||
|
|
||||||
ObjectList _list;
|
ObjectList _list;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_AutoReleasePool_INCLUDED
|
#endif // Foundation_AutoReleasePool_INCLUDED
|
||||||
|
|||||||
@@ -1,114 +1,114 @@
|
|||||||
//
|
//
|
||||||
// Base64Decoder.h
|
// Base64Decoder.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Base64Decoder.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Base64Decoder.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: Base64
|
// Module: Base64
|
||||||
//
|
//
|
||||||
// Definition of class Base64Decoder.
|
// Definition of class Base64Decoder.
|
||||||
//
|
//
|
||||||
// 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_Base64Decoder_INCLUDED
|
#ifndef Foundation_Base64Decoder_INCLUDED
|
||||||
#define Foundation_Base64Decoder_INCLUDED
|
#define Foundation_Base64Decoder_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/UnbufferedStreamBuf.h"
|
#include "Poco/UnbufferedStreamBuf.h"
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Base64DecoderBuf: public UnbufferedStreamBuf
|
class Foundation_API Base64DecoderBuf: public UnbufferedStreamBuf
|
||||||
/// This streambuf base64-decodes all data read
|
/// This streambuf base64-decodes all data read
|
||||||
/// from the istream connected to it.
|
/// from the istream connected to it.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Base64DecoderBuf(std::istream& istr);
|
Base64DecoderBuf(std::istream& istr);
|
||||||
~Base64DecoderBuf();
|
~Base64DecoderBuf();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int readFromDevice();
|
int readFromDevice();
|
||||||
int readOne();
|
int readOne();
|
||||||
|
|
||||||
unsigned char _group[3];
|
unsigned char _group[3];
|
||||||
int _groupLength;
|
int _groupLength;
|
||||||
int _groupIndex;
|
int _groupIndex;
|
||||||
std::istream& _istr;
|
std::istream& _istr;
|
||||||
|
|
||||||
static unsigned char IN_ENCODING[256];
|
static unsigned char IN_ENCODING[256];
|
||||||
static bool IN_ENCODING_INIT;
|
static bool IN_ENCODING_INIT;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Base64DecoderBuf(const Base64DecoderBuf&);
|
Base64DecoderBuf(const Base64DecoderBuf&);
|
||||||
Base64DecoderBuf& operator = (const Base64DecoderBuf&);
|
Base64DecoderBuf& operator = (const Base64DecoderBuf&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Base64DecoderIOS: public virtual std::ios
|
class Foundation_API Base64DecoderIOS: public virtual std::ios
|
||||||
/// The base class for Base64Decoder.
|
/// The base class for Base64Decoder.
|
||||||
///
|
///
|
||||||
/// This class is needed to ensure the correct initialization
|
/// This class is needed to ensure the correct initialization
|
||||||
/// order of the stream buffer and base classes.
|
/// order of the stream buffer and base classes.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Base64DecoderIOS(std::istream& istr);
|
Base64DecoderIOS(std::istream& istr);
|
||||||
~Base64DecoderIOS();
|
~Base64DecoderIOS();
|
||||||
Base64DecoderBuf* rdbuf();
|
Base64DecoderBuf* rdbuf();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Base64DecoderBuf _buf;
|
Base64DecoderBuf _buf;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Base64DecoderIOS(const Base64DecoderIOS&);
|
Base64DecoderIOS(const Base64DecoderIOS&);
|
||||||
Base64DecoderIOS& operator = (const Base64DecoderIOS&);
|
Base64DecoderIOS& operator = (const Base64DecoderIOS&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Base64Decoder: public Base64DecoderIOS, public std::istream
|
class Foundation_API Base64Decoder: public Base64DecoderIOS, public std::istream
|
||||||
/// This istream base64-decodes all data
|
/// This istream base64-decodes all data
|
||||||
/// read from the istream connected to it.
|
/// read from the istream connected to it.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Base64Decoder(std::istream& istr);
|
Base64Decoder(std::istream& istr);
|
||||||
~Base64Decoder();
|
~Base64Decoder();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Base64Decoder(const Base64Decoder&);
|
Base64Decoder(const Base64Decoder&);
|
||||||
Base64Decoder& operator = (const Base64Decoder&);
|
Base64Decoder& operator = (const Base64Decoder&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Base64Decoder_INCLUDED
|
#endif // Foundation_Base64Decoder_INCLUDED
|
||||||
|
|||||||
@@ -1,134 +1,134 @@
|
|||||||
//
|
//
|
||||||
// Base64Encoder.h
|
// Base64Encoder.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Base64Encoder.h#3 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Base64Encoder.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: Base64
|
// Module: Base64
|
||||||
//
|
//
|
||||||
// Definition of class Base64Encoder.
|
// Definition of class Base64Encoder.
|
||||||
//
|
//
|
||||||
// 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_Base64Encoder_INCLUDED
|
#ifndef Foundation_Base64Encoder_INCLUDED
|
||||||
#define Foundation_Base64Encoder_INCLUDED
|
#define Foundation_Base64Encoder_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/UnbufferedStreamBuf.h"
|
#include "Poco/UnbufferedStreamBuf.h"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Base64EncoderBuf: public UnbufferedStreamBuf
|
class Foundation_API Base64EncoderBuf: public UnbufferedStreamBuf
|
||||||
/// This streambuf base64-encodes all data written
|
/// This streambuf base64-encodes all data written
|
||||||
/// to it and forwards it to a connected
|
/// to it and forwards it to a connected
|
||||||
/// ostream.
|
/// ostream.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Base64EncoderBuf(std::ostream& ostr);
|
Base64EncoderBuf(std::ostream& ostr);
|
||||||
~Base64EncoderBuf();
|
~Base64EncoderBuf();
|
||||||
|
|
||||||
int close();
|
int close();
|
||||||
/// Closes the stream buffer.
|
/// Closes the stream buffer.
|
||||||
|
|
||||||
void setLineLength(int lineLength);
|
void setLineLength(int lineLength);
|
||||||
/// Specify the line length.
|
/// Specify the line length.
|
||||||
///
|
///
|
||||||
/// After the given number of characters have been written,
|
/// After the given number of characters have been written,
|
||||||
/// a newline character will be written.
|
/// a newline character will be written.
|
||||||
///
|
///
|
||||||
/// Specify 0 for an unlimited line length.
|
/// Specify 0 for an unlimited line length.
|
||||||
|
|
||||||
int getLineLength() const;
|
int getLineLength() const;
|
||||||
/// Returns the currently set line length.
|
/// Returns the currently set line length.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int writeToDevice(char c);
|
int writeToDevice(char c);
|
||||||
|
|
||||||
unsigned char _group[3];
|
unsigned char _group[3];
|
||||||
int _groupLength;
|
int _groupLength;
|
||||||
int _pos;
|
int _pos;
|
||||||
int _lineLength;
|
int _lineLength;
|
||||||
std::ostream& _ostr;
|
std::ostream& _ostr;
|
||||||
|
|
||||||
static const unsigned char OUT_ENCODING[64];
|
static const unsigned char OUT_ENCODING[64];
|
||||||
|
|
||||||
friend class Base64DecoderBuf;
|
friend class Base64DecoderBuf;
|
||||||
|
|
||||||
Base64EncoderBuf(const Base64EncoderBuf&);
|
Base64EncoderBuf(const Base64EncoderBuf&);
|
||||||
Base64EncoderBuf& operator = (const Base64EncoderBuf&);
|
Base64EncoderBuf& operator = (const Base64EncoderBuf&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Base64EncoderIOS: public virtual std::ios
|
class Foundation_API Base64EncoderIOS: public virtual std::ios
|
||||||
/// The base class for Base64Encoder.
|
/// The base class for Base64Encoder.
|
||||||
///
|
///
|
||||||
/// This class is needed to ensure the correct initialization
|
/// This class is needed to ensure the correct initialization
|
||||||
/// order of the stream buffer and base classes.
|
/// order of the stream buffer and base classes.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Base64EncoderIOS(std::ostream& ostr);
|
Base64EncoderIOS(std::ostream& ostr);
|
||||||
~Base64EncoderIOS();
|
~Base64EncoderIOS();
|
||||||
int close();
|
int close();
|
||||||
Base64EncoderBuf* rdbuf();
|
Base64EncoderBuf* rdbuf();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Base64EncoderBuf _buf;
|
Base64EncoderBuf _buf;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Base64EncoderIOS(const Base64EncoderIOS&);
|
Base64EncoderIOS(const Base64EncoderIOS&);
|
||||||
Base64EncoderIOS& operator = (const Base64EncoderIOS&);
|
Base64EncoderIOS& operator = (const Base64EncoderIOS&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Base64Encoder: public Base64EncoderIOS, public std::ostream
|
class Foundation_API Base64Encoder: public Base64EncoderIOS, public std::ostream
|
||||||
/// This ostream base64-encodes all data
|
/// This ostream base64-encodes all data
|
||||||
/// written to it and forwards it to
|
/// written to it and forwards it to
|
||||||
/// a connected ostream.
|
/// a connected ostream.
|
||||||
/// Always call close() when done
|
/// Always call close() when done
|
||||||
/// writing data, to ensure proper
|
/// writing data, to ensure proper
|
||||||
/// completion of the encoding operation.
|
/// completion of the encoding operation.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Base64Encoder(std::ostream& ostr);
|
Base64Encoder(std::ostream& ostr);
|
||||||
~Base64Encoder();
|
~Base64Encoder();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Base64Encoder(const Base64Encoder&);
|
Base64Encoder(const Base64Encoder&);
|
||||||
Base64Encoder& operator = (const Base64Encoder&);
|
Base64Encoder& operator = (const Base64Encoder&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Base64Encoder_INCLUDED
|
#endif // Foundation_Base64Encoder_INCLUDED
|
||||||
|
|||||||
@@ -1,88 +1,88 @@
|
|||||||
//
|
//
|
||||||
// BasicEvent.h
|
// BasicEvent.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/BasicEvent.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/BasicEvent.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
// Module: BasicEvent
|
// Module: BasicEvent
|
||||||
//
|
//
|
||||||
// Implementation of the BasicEvent template.
|
// Implementation of the BasicEvent template.
|
||||||
//
|
//
|
||||||
// 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 Foundation_BasicEvent_INCLUDED
|
#ifndef Foundation_BasicEvent_INCLUDED
|
||||||
#define Foundation_BasicEvent_INCLUDED
|
#define Foundation_BasicEvent_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/AbstractEvent.h"
|
#include "Poco/AbstractEvent.h"
|
||||||
#include "Poco/DefaultStrategy.h"
|
#include "Poco/DefaultStrategy.h"
|
||||||
#include "Poco/AbstractDelegate.h"
|
#include "Poco/AbstractDelegate.h"
|
||||||
#include "Poco/CompareFunctions.h"
|
#include "Poco/CompareFunctions.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TArgs>
|
template <class TArgs>
|
||||||
class BasicEvent: public AbstractEvent <
|
class BasicEvent: public AbstractEvent <
|
||||||
TArgs, DefaultStrategy<TArgs, AbstractDelegate<TArgs>, p_less<AbstractDelegate<TArgs> > >,
|
TArgs, DefaultStrategy<TArgs, AbstractDelegate<TArgs>, p_less<AbstractDelegate<TArgs> > >,
|
||||||
AbstractDelegate<TArgs>
|
AbstractDelegate<TArgs>
|
||||||
>
|
>
|
||||||
/// A BasicEvent uses internally a DefaultStrategy which
|
/// A BasicEvent uses internally a DefaultStrategy which
|
||||||
/// invokes delegates in an arbitrary manner.
|
/// invokes delegates in an arbitrary manner.
|
||||||
/// Note that one object can only register one method to a BasicEvent.
|
/// Note that one object can only register one method to a BasicEvent.
|
||||||
/// Subsequent registrations will overwrite the existing delegate.
|
/// Subsequent registrations will overwrite the existing delegate.
|
||||||
/// For example:
|
/// For example:
|
||||||
/// BasicEvent<int> event;
|
/// BasicEvent<int> event;
|
||||||
/// MyClass myObject;
|
/// MyClass myObject;
|
||||||
/// event += Delegate<MyClass, int>(&myObject, &MyClass::myMethod1);
|
/// event += Delegate<MyClass, int>(&myObject, &MyClass::myMethod1);
|
||||||
/// event += Delegate<MyClass, int>(&myObject, &MyClass::myMethod2);
|
/// event += Delegate<MyClass, int>(&myObject, &MyClass::myMethod2);
|
||||||
///
|
///
|
||||||
/// The second registration will overwrite the first one. The reason is simply that
|
/// The second registration will overwrite the first one. The reason is simply that
|
||||||
/// function pointers can only be compared by equality but not by lower than.
|
/// function pointers can only be compared by equality but not by lower than.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
BasicEvent()
|
BasicEvent()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~BasicEvent()
|
~BasicEvent()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
BasicEvent(const BasicEvent& e);
|
BasicEvent(const BasicEvent& e);
|
||||||
BasicEvent& operator = (const BasicEvent& e);
|
BasicEvent& operator = (const BasicEvent& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,187 +1,187 @@
|
|||||||
//
|
//
|
||||||
// BinaryReader.h
|
// BinaryReader.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/BinaryReader.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/BinaryReader.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: BinaryReaderWriter
|
// Module: BinaryReaderWriter
|
||||||
//
|
//
|
||||||
// Definition of the BinaryReader class.
|
// Definition of the BinaryReader 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_BinaryReader_INCLUDED
|
#ifndef Foundation_BinaryReader_INCLUDED
|
||||||
#define Foundation_BinaryReader_INCLUDED
|
#define Foundation_BinaryReader_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API BinaryReader
|
class Foundation_API BinaryReader
|
||||||
/// This class reads basic types in binary form into an input stream.
|
/// This class reads basic types in binary form into an input stream.
|
||||||
/// It provides an extractor-based interface similar to istream.
|
/// It provides an extractor-based interface similar to istream.
|
||||||
/// The reader also supports automatic conversion from big-endian
|
/// The reader also supports automatic conversion from big-endian
|
||||||
/// (network byte order) to little-endian and vice-versa.
|
/// (network byte order) to little-endian and vice-versa.
|
||||||
/// Use a BinaryWriter to create a stream suitable for a BinaryReader.
|
/// Use a BinaryWriter to create a stream suitable for a BinaryReader.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum StreamByteOrder
|
enum StreamByteOrder
|
||||||
{
|
{
|
||||||
NATIVE_BYTE_ORDER = 1, /// the host's native byte-order
|
NATIVE_BYTE_ORDER = 1, /// the host's native byte-order
|
||||||
BIG_ENDIAN_BYTE_ORDER = 2, /// big-endian (network) byte-order
|
BIG_ENDIAN_BYTE_ORDER = 2, /// big-endian (network) byte-order
|
||||||
NETWORK_BYTE_ORDER = 2, /// big-endian (network) byte-order
|
NETWORK_BYTE_ORDER = 2, /// big-endian (network) byte-order
|
||||||
LITTLE_ENDIAN_BYTE_ORDER = 3, /// little-endian byte-order
|
LITTLE_ENDIAN_BYTE_ORDER = 3, /// little-endian byte-order
|
||||||
UNSPECIFIED_BYTE_ORDER = 4 /// unknown, byte-order will be determined by reading the byte-order mark
|
UNSPECIFIED_BYTE_ORDER = 4 /// unknown, byte-order will be determined by reading the byte-order mark
|
||||||
};
|
};
|
||||||
|
|
||||||
BinaryReader(std::istream& istr, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER);
|
BinaryReader(std::istream& istr, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER);
|
||||||
/// Creates the BinaryReader.
|
/// Creates the BinaryReader.
|
||||||
|
|
||||||
~BinaryReader();
|
~BinaryReader();
|
||||||
/// Destroys the BinaryReader.
|
/// Destroys the BinaryReader.
|
||||||
|
|
||||||
BinaryReader& operator >> (bool& value);
|
BinaryReader& operator >> (bool& value);
|
||||||
BinaryReader& operator >> (char& value);
|
BinaryReader& operator >> (char& value);
|
||||||
BinaryReader& operator >> (unsigned char& value);
|
BinaryReader& operator >> (unsigned char& value);
|
||||||
BinaryReader& operator >> (signed char& value);
|
BinaryReader& operator >> (signed char& value);
|
||||||
BinaryReader& operator >> (short& value);
|
BinaryReader& operator >> (short& value);
|
||||||
BinaryReader& operator >> (unsigned short& value);
|
BinaryReader& operator >> (unsigned short& value);
|
||||||
BinaryReader& operator >> (int& value);
|
BinaryReader& operator >> (int& value);
|
||||||
BinaryReader& operator >> (unsigned int& value);
|
BinaryReader& operator >> (unsigned int& value);
|
||||||
BinaryReader& operator >> (long& value);
|
BinaryReader& operator >> (long& value);
|
||||||
BinaryReader& operator >> (unsigned long& value);
|
BinaryReader& operator >> (unsigned long& value);
|
||||||
BinaryReader& operator >> (float& value);
|
BinaryReader& operator >> (float& value);
|
||||||
BinaryReader& operator >> (double& value);
|
BinaryReader& operator >> (double& value);
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||||
BinaryReader& operator >> (Int64& value);
|
BinaryReader& operator >> (Int64& value);
|
||||||
BinaryReader& operator >> (UInt64& value);
|
BinaryReader& operator >> (UInt64& value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BinaryReader& operator >> (std::string& value);
|
BinaryReader& operator >> (std::string& value);
|
||||||
|
|
||||||
void read7BitEncoded(UInt32& value);
|
void read7BitEncoded(UInt32& value);
|
||||||
/// Reads a 32-bit unsigned integer in compressed format.
|
/// Reads a 32-bit unsigned integer in compressed format.
|
||||||
/// See BinaryWriter::write7BitEncoded() for a description
|
/// See BinaryWriter::write7BitEncoded() for a description
|
||||||
/// of the compression algorithm.
|
/// of the compression algorithm.
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
void read7BitEncoded(UInt64& value);
|
void read7BitEncoded(UInt64& value);
|
||||||
/// Reads a 64-bit unsigned integer in compressed format.
|
/// Reads a 64-bit unsigned integer in compressed format.
|
||||||
/// See BinaryWriter::write7BitEncoded() for a description
|
/// See BinaryWriter::write7BitEncoded() for a description
|
||||||
/// of the compression algorithm.
|
/// of the compression algorithm.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void readRaw(int length, std::string& value);
|
void readRaw(int length, std::string& value);
|
||||||
/// Reads length bytes of raw data into value.
|
/// Reads length bytes of raw data into value.
|
||||||
|
|
||||||
void readBOM();
|
void readBOM();
|
||||||
/// Reads a byte-order mark from the stream and configures
|
/// Reads a byte-order mark from the stream and configures
|
||||||
/// the reader for the encountered byte order.
|
/// the reader for the encountered byte order.
|
||||||
/// A byte-order mark is a 16-bit integer with a value of 0xFEFF,
|
/// A byte-order mark is a 16-bit integer with a value of 0xFEFF,
|
||||||
/// written in host byte order.
|
/// written in host byte order.
|
||||||
|
|
||||||
bool good();
|
bool good();
|
||||||
/// Returns _istr.good();
|
/// Returns _istr.good();
|
||||||
|
|
||||||
bool fail();
|
bool fail();
|
||||||
/// Returns _istr.fail();
|
/// Returns _istr.fail();
|
||||||
|
|
||||||
bool bad();
|
bool bad();
|
||||||
/// Returns _istr.bad();
|
/// Returns _istr.bad();
|
||||||
|
|
||||||
bool eof();
|
bool eof();
|
||||||
/// Returns _istr.eof();
|
/// Returns _istr.eof();
|
||||||
|
|
||||||
std::istream& stream() const;
|
std::istream& stream() const;
|
||||||
/// Returns the underlying stream.
|
/// Returns the underlying stream.
|
||||||
|
|
||||||
StreamByteOrder byteOrder() const;
|
StreamByteOrder byteOrder() const;
|
||||||
/// Returns the byte-order used by the reader, which is
|
/// Returns the byte-order used by the reader, which is
|
||||||
/// either BIG_ENDIAN_BYTE_ORDER or LITTLE_ENDIAN_BYTE_ORDER.
|
/// either BIG_ENDIAN_BYTE_ORDER or LITTLE_ENDIAN_BYTE_ORDER.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::istream& _istr;
|
std::istream& _istr;
|
||||||
bool _flipBytes;
|
bool _flipBytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
inline bool BinaryReader::good()
|
inline bool BinaryReader::good()
|
||||||
{
|
{
|
||||||
return _istr.good();
|
return _istr.good();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool BinaryReader::fail()
|
inline bool BinaryReader::fail()
|
||||||
{
|
{
|
||||||
return _istr.fail();
|
return _istr.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool BinaryReader::bad()
|
inline bool BinaryReader::bad()
|
||||||
{
|
{
|
||||||
return _istr.bad();
|
return _istr.bad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool BinaryReader::eof()
|
inline bool BinaryReader::eof()
|
||||||
{
|
{
|
||||||
return _istr.eof();
|
return _istr.eof();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::istream& BinaryReader::stream() const
|
inline std::istream& BinaryReader::stream() const
|
||||||
{
|
{
|
||||||
return _istr;
|
return _istr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline BinaryReader::StreamByteOrder BinaryReader::byteOrder() const
|
inline BinaryReader::StreamByteOrder BinaryReader::byteOrder() const
|
||||||
{
|
{
|
||||||
#if defined(POCO_ARCH_BIG_ENDIAN)
|
#if defined(POCO_ARCH_BIG_ENDIAN)
|
||||||
return _flipBytes ? LITTLE_ENDIAN_BYTE_ORDER : BIG_ENDIAN_BYTE_ORDER;
|
return _flipBytes ? LITTLE_ENDIAN_BYTE_ORDER : BIG_ENDIAN_BYTE_ORDER;
|
||||||
#else
|
#else
|
||||||
return _flipBytes ? BIG_ENDIAN_BYTE_ORDER : LITTLE_ENDIAN_BYTE_ORDER;
|
return _flipBytes ? BIG_ENDIAN_BYTE_ORDER : LITTLE_ENDIAN_BYTE_ORDER;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_BinaryReader_INCLUDED
|
#endif // Foundation_BinaryReader_INCLUDED
|
||||||
|
|||||||
@@ -1,199 +1,199 @@
|
|||||||
//
|
//
|
||||||
// BinaryWriter.h
|
// BinaryWriter.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/BinaryWriter.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/BinaryWriter.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: BinaryReaderWriter
|
// Module: BinaryReaderWriter
|
||||||
//
|
//
|
||||||
// Definition of the BinaryWriter class.
|
// Definition of the BinaryWriter 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_BinaryWriter_INCLUDED
|
#ifndef Foundation_BinaryWriter_INCLUDED
|
||||||
#define Foundation_BinaryWriter_INCLUDED
|
#define Foundation_BinaryWriter_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API BinaryWriter
|
class Foundation_API BinaryWriter
|
||||||
/// This class writes basic types in binary form into an output stream.
|
/// This class writes basic types in binary form into an output stream.
|
||||||
/// It provides an inserter-based interface similar to ostream.
|
/// It provides an inserter-based interface similar to ostream.
|
||||||
/// The writer also supports automatic conversion from big-endian
|
/// The writer also supports automatic conversion from big-endian
|
||||||
/// (network byte order) to little-endian and vice-versa.
|
/// (network byte order) to little-endian and vice-versa.
|
||||||
/// Use a BinaryReader to read from a stream created by a BinaryWriter.
|
/// Use a BinaryReader to read from a stream created by a BinaryWriter.
|
||||||
/// Be careful when exchanging data between systems with different
|
/// Be careful when exchanging data between systems with different
|
||||||
/// data type sizes (e.g., 32-bit and 64-bit architectures), as the sizes
|
/// data type sizes (e.g., 32-bit and 64-bit architectures), as the sizes
|
||||||
/// of some of the basic types may be different. For example, writing a
|
/// of some of the basic types may be different. For example, writing a
|
||||||
/// long integer on a 64-bit system and reading it on a 32-bit system
|
/// long integer on a 64-bit system and reading it on a 32-bit system
|
||||||
/// may yield an incorrent result. Use fixed-size types (Int32, Int64, etc.)
|
/// may yield an incorrent result. Use fixed-size types (Int32, Int64, etc.)
|
||||||
/// in such a case.
|
/// in such a case.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum StreamByteOrder
|
enum StreamByteOrder
|
||||||
{
|
{
|
||||||
NATIVE_BYTE_ORDER = 1, /// the host's native byte-order
|
NATIVE_BYTE_ORDER = 1, /// the host's native byte-order
|
||||||
BIG_ENDIAN_BYTE_ORDER = 2, /// big-endian (network) byte-order
|
BIG_ENDIAN_BYTE_ORDER = 2, /// big-endian (network) byte-order
|
||||||
NETWORK_BYTE_ORDER = 2, /// big-endian (network) byte-order
|
NETWORK_BYTE_ORDER = 2, /// big-endian (network) byte-order
|
||||||
LITTLE_ENDIAN_BYTE_ORDER = 3 /// little-endian byte-order
|
LITTLE_ENDIAN_BYTE_ORDER = 3 /// little-endian byte-order
|
||||||
};
|
};
|
||||||
|
|
||||||
BinaryWriter(std::ostream& ostr, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER);
|
BinaryWriter(std::ostream& ostr, StreamByteOrder byteOrder = NATIVE_BYTE_ORDER);
|
||||||
/// Creates the BinaryWriter.
|
/// Creates the BinaryWriter.
|
||||||
|
|
||||||
~BinaryWriter();
|
~BinaryWriter();
|
||||||
/// Destroys the BinaryWriter.
|
/// Destroys the BinaryWriter.
|
||||||
|
|
||||||
BinaryWriter& operator << (bool value);
|
BinaryWriter& operator << (bool value);
|
||||||
BinaryWriter& operator << (char value);
|
BinaryWriter& operator << (char value);
|
||||||
BinaryWriter& operator << (unsigned char value);
|
BinaryWriter& operator << (unsigned char value);
|
||||||
BinaryWriter& operator << (signed char value);
|
BinaryWriter& operator << (signed char value);
|
||||||
BinaryWriter& operator << (short value);
|
BinaryWriter& operator << (short value);
|
||||||
BinaryWriter& operator << (unsigned short value);
|
BinaryWriter& operator << (unsigned short value);
|
||||||
BinaryWriter& operator << (int value);
|
BinaryWriter& operator << (int value);
|
||||||
BinaryWriter& operator << (unsigned int value);
|
BinaryWriter& operator << (unsigned int value);
|
||||||
BinaryWriter& operator << (long value);
|
BinaryWriter& operator << (long value);
|
||||||
BinaryWriter& operator << (unsigned long value);
|
BinaryWriter& operator << (unsigned long value);
|
||||||
BinaryWriter& operator << (float value);
|
BinaryWriter& operator << (float value);
|
||||||
BinaryWriter& operator << (double value);
|
BinaryWriter& operator << (double value);
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
#if defined(POCO_HAVE_INT64) && !defined(POCO_LONG_IS_64_BIT)
|
||||||
BinaryWriter& operator << (Int64 value);
|
BinaryWriter& operator << (Int64 value);
|
||||||
BinaryWriter& operator << (UInt64 value);
|
BinaryWriter& operator << (UInt64 value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
BinaryWriter& operator << (const std::string& value);
|
BinaryWriter& operator << (const std::string& value);
|
||||||
BinaryWriter& operator << (const char* value);
|
BinaryWriter& operator << (const char* value);
|
||||||
|
|
||||||
void write7BitEncoded(UInt32 value);
|
void write7BitEncoded(UInt32 value);
|
||||||
/// Writes a 32-bit unsigned integer in a compressed format.
|
/// Writes a 32-bit unsigned integer in a compressed format.
|
||||||
/// The value is written out seven bits at a time, starting
|
/// The value is written out seven bits at a time, starting
|
||||||
/// with the seven least-significant bits.
|
/// with the seven least-significant bits.
|
||||||
/// The high bit of a byte indicates whether there are more bytes to be
|
/// The high bit of a byte indicates whether there are more bytes to be
|
||||||
/// written after this one.
|
/// written after this one.
|
||||||
/// If value will fit in seven bits, it takes only one byte of space.
|
/// If value will fit in seven bits, it takes only one byte of space.
|
||||||
/// If value will not fit in seven bits, the high bit is set on the first byte and
|
/// If value will not fit in seven bits, the high bit is set on the first byte and
|
||||||
/// written out. value is then shifted by seven bits and the next byte is written.
|
/// written out. value is then shifted by seven bits and the next byte is written.
|
||||||
/// This process is repeated until the entire integer has been written.
|
/// This process is repeated until the entire integer has been written.
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
void write7BitEncoded(UInt64 value);
|
void write7BitEncoded(UInt64 value);
|
||||||
/// Writes a 64-bit unsigned integer in a compressed format.
|
/// Writes a 64-bit unsigned integer in a compressed format.
|
||||||
/// The value written out seven bits at a time, starting
|
/// The value written out seven bits at a time, starting
|
||||||
/// with the seven least-significant bits.
|
/// with the seven least-significant bits.
|
||||||
/// The high bit of a byte indicates whether there are more bytes to be
|
/// The high bit of a byte indicates whether there are more bytes to be
|
||||||
/// written after this one.
|
/// written after this one.
|
||||||
/// If value will fit in seven bits, it takes only one byte of space.
|
/// If value will fit in seven bits, it takes only one byte of space.
|
||||||
/// If value will not fit in seven bits, the high bit is set on the first byte and
|
/// If value will not fit in seven bits, the high bit is set on the first byte and
|
||||||
/// written out. value is then shifted by seven bits and the next byte is written.
|
/// written out. value is then shifted by seven bits and the next byte is written.
|
||||||
/// This process is repeated until the entire integer has been written.
|
/// This process is repeated until the entire integer has been written.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void writeRaw(const std::string& rawData);
|
void writeRaw(const std::string& rawData);
|
||||||
/// Writes the string as-is to the stream.
|
/// Writes the string as-is to the stream.
|
||||||
|
|
||||||
void writeBOM();
|
void writeBOM();
|
||||||
/// Writes a byte-order mark to the stream. A byte order mark is
|
/// Writes a byte-order mark to the stream. A byte order mark is
|
||||||
/// a 16-bit integer with a value of 0xFEFF, written in host byte-order.
|
/// a 16-bit integer with a value of 0xFEFF, written in host byte-order.
|
||||||
/// A BinaryReader uses the byte-order mark to determine the byte-order
|
/// A BinaryReader uses the byte-order mark to determine the byte-order
|
||||||
/// of the stream.
|
/// of the stream.
|
||||||
|
|
||||||
void flush();
|
void flush();
|
||||||
/// Flushes the underlying stream.
|
/// Flushes the underlying stream.
|
||||||
|
|
||||||
bool good();
|
bool good();
|
||||||
/// Returns _ostr.good();
|
/// Returns _ostr.good();
|
||||||
|
|
||||||
bool fail();
|
bool fail();
|
||||||
/// Returns _ostr.fail();
|
/// Returns _ostr.fail();
|
||||||
|
|
||||||
bool bad();
|
bool bad();
|
||||||
/// Returns _ostr.bad();
|
/// Returns _ostr.bad();
|
||||||
|
|
||||||
std::ostream& stream() const;
|
std::ostream& stream() const;
|
||||||
/// Returns the underlying stream.
|
/// Returns the underlying stream.
|
||||||
|
|
||||||
StreamByteOrder byteOrder() const;
|
StreamByteOrder byteOrder() const;
|
||||||
/// Returns the byte ordering used by the writer, which is
|
/// Returns the byte ordering used by the writer, which is
|
||||||
/// either BIG_ENDIAN_BYTE_ORDER or LITTLE_ENDIAN_BYTE_ORDER.
|
/// either BIG_ENDIAN_BYTE_ORDER or LITTLE_ENDIAN_BYTE_ORDER.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::ostream& _ostr;
|
std::ostream& _ostr;
|
||||||
bool _flipBytes;
|
bool _flipBytes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
inline std::ostream& BinaryWriter::stream() const
|
inline std::ostream& BinaryWriter::stream() const
|
||||||
{
|
{
|
||||||
return _ostr;
|
return _ostr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool BinaryWriter::good()
|
inline bool BinaryWriter::good()
|
||||||
{
|
{
|
||||||
return _ostr.good();
|
return _ostr.good();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool BinaryWriter::fail()
|
inline bool BinaryWriter::fail()
|
||||||
{
|
{
|
||||||
return _ostr.fail();
|
return _ostr.fail();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool BinaryWriter::bad()
|
inline bool BinaryWriter::bad()
|
||||||
{
|
{
|
||||||
return _ostr.bad();
|
return _ostr.bad();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline BinaryWriter::StreamByteOrder BinaryWriter::byteOrder() const
|
inline BinaryWriter::StreamByteOrder BinaryWriter::byteOrder() const
|
||||||
{
|
{
|
||||||
#if defined(POCO_ARCH_BIG_ENDIAN)
|
#if defined(POCO_ARCH_BIG_ENDIAN)
|
||||||
return _flipBytes ? LITTLE_ENDIAN_BYTE_ORDER : BIG_ENDIAN_BYTE_ORDER;
|
return _flipBytes ? LITTLE_ENDIAN_BYTE_ORDER : BIG_ENDIAN_BYTE_ORDER;
|
||||||
#else
|
#else
|
||||||
return _flipBytes ? BIG_ENDIAN_BYTE_ORDER : LITTLE_ENDIAN_BYTE_ORDER;
|
return _flipBytes ? BIG_ENDIAN_BYTE_ORDER : LITTLE_ENDIAN_BYTE_ORDER;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_BinaryWriter_INCLUDED
|
#endif // Foundation_BinaryWriter_INCLUDED
|
||||||
|
|||||||
@@ -1,74 +1,74 @@
|
|||||||
//
|
//
|
||||||
// BufferAllocator.h
|
// BufferAllocator.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/BufferAllocator.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/BufferAllocator.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: BufferAllocator
|
// Module: BufferAllocator
|
||||||
//
|
//
|
||||||
// Definition of the BufferAllocator class.
|
// Definition of the BufferAllocator 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 Foundation_BufferAllocator_INCLUDED
|
#ifndef Foundation_BufferAllocator_INCLUDED
|
||||||
#define Foundation_BufferAllocator_INCLUDED
|
#define Foundation_BufferAllocator_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <ios>
|
#include <ios>
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <typename ch>
|
template <typename ch>
|
||||||
class BufferAllocator
|
class BufferAllocator
|
||||||
/// The BufferAllocator used if no specific
|
/// The BufferAllocator used if no specific
|
||||||
/// BufferAllocator has been specified.
|
/// BufferAllocator has been specified.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef ch char_type;
|
typedef ch char_type;
|
||||||
|
|
||||||
static char_type* allocate(std::streamsize size)
|
static char_type* allocate(std::streamsize size)
|
||||||
{
|
{
|
||||||
return new char_type[static_cast<std::size_t>(size)];
|
return new char_type[static_cast<std::size_t>(size)];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deallocate(char_type* ptr, std::streamsize size)
|
static void deallocate(char_type* ptr, std::streamsize size)
|
||||||
{
|
{
|
||||||
delete [] ptr;
|
delete [] ptr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_BufferAllocator_INCLUDED
|
#endif // Foundation_BufferAllocator_INCLUDED
|
||||||
|
|||||||
@@ -1,196 +1,196 @@
|
|||||||
//
|
//
|
||||||
// BufferedBidirectionalStreamBuf.h
|
// BufferedBidirectionalStreamBuf.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h#3 $
|
// $Id: //poco/1.3/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: StreamBuf
|
// Module: StreamBuf
|
||||||
//
|
//
|
||||||
// Definition of template BasicBufferedBidirectionalStreamBuf and class BufferedBidirectionalStreamBuf.
|
// Definition of template BasicBufferedBidirectionalStreamBuf and class BufferedBidirectionalStreamBuf.
|
||||||
//
|
//
|
||||||
// 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 Foundation_BufferedBidirectionalStreamBuf_INCLUDED
|
#ifndef Foundation_BufferedBidirectionalStreamBuf_INCLUDED
|
||||||
#define Foundation_BufferedBidirectionalStreamBuf_INCLUDED
|
#define Foundation_BufferedBidirectionalStreamBuf_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/BufferAllocator.h"
|
#include "Poco/BufferAllocator.h"
|
||||||
#include "Poco/StreamUtil.h"
|
#include "Poco/StreamUtil.h"
|
||||||
#include <streambuf>
|
#include <streambuf>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <ios>
|
#include <ios>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <typename ch, typename tr, typename ba = BufferAllocator<ch> >
|
template <typename ch, typename tr, typename ba = BufferAllocator<ch> >
|
||||||
class BasicBufferedBidirectionalStreamBuf: public std::basic_streambuf<ch, tr>
|
class BasicBufferedBidirectionalStreamBuf: public std::basic_streambuf<ch, tr>
|
||||||
/// This is an implementation of a buffered bidirectional
|
/// This is an implementation of a buffered bidirectional
|
||||||
/// streambuf that greatly simplifies the implementation of
|
/// streambuf that greatly simplifies the implementation of
|
||||||
/// custom streambufs of various kinds.
|
/// custom streambufs of various kinds.
|
||||||
/// Derived classes only have to override the methods
|
/// Derived classes only have to override the methods
|
||||||
/// readFromDevice() or writeToDevice().
|
/// readFromDevice() or writeToDevice().
|
||||||
///
|
///
|
||||||
/// In contrast to BasicBufferedStreambuf, this class supports
|
/// In contrast to BasicBufferedStreambuf, this class supports
|
||||||
/// simultaneous read and write access, so in addition to
|
/// simultaneous read and write access, so in addition to
|
||||||
/// istream and ostream this streambuf can also be used
|
/// istream and ostream this streambuf can also be used
|
||||||
/// for implementing an iostream.
|
/// for implementing an iostream.
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef std::basic_streambuf<ch, tr> Base;
|
typedef std::basic_streambuf<ch, tr> Base;
|
||||||
typedef std::basic_ios<ch, tr> IOS;
|
typedef std::basic_ios<ch, tr> IOS;
|
||||||
typedef ch char_type;
|
typedef ch char_type;
|
||||||
typedef tr char_traits;
|
typedef tr char_traits;
|
||||||
typedef ba Allocator;
|
typedef ba Allocator;
|
||||||
typedef typename Base::int_type int_type;
|
typedef typename Base::int_type int_type;
|
||||||
typedef typename Base::pos_type pos_type;
|
typedef typename Base::pos_type pos_type;
|
||||||
typedef typename Base::off_type off_type;
|
typedef typename Base::off_type off_type;
|
||||||
typedef typename IOS::openmode openmode;
|
typedef typename IOS::openmode openmode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BasicBufferedBidirectionalStreamBuf(std::streamsize bufferSize, openmode mode):
|
BasicBufferedBidirectionalStreamBuf(std::streamsize bufferSize, openmode mode):
|
||||||
_bufsize(bufferSize),
|
_bufsize(bufferSize),
|
||||||
_pReadBuffer(Allocator::allocate(_bufsize)),
|
_pReadBuffer(Allocator::allocate(_bufsize)),
|
||||||
_pWriteBuffer(Allocator::allocate(_bufsize)),
|
_pWriteBuffer(Allocator::allocate(_bufsize)),
|
||||||
_mode(mode)
|
_mode(mode)
|
||||||
{
|
{
|
||||||
resetBuffers();
|
resetBuffers();
|
||||||
}
|
}
|
||||||
|
|
||||||
~BasicBufferedBidirectionalStreamBuf()
|
~BasicBufferedBidirectionalStreamBuf()
|
||||||
{
|
{
|
||||||
Allocator::deallocate(_pReadBuffer, _bufsize);
|
Allocator::deallocate(_pReadBuffer, _bufsize);
|
||||||
Allocator::deallocate(_pWriteBuffer, _bufsize);
|
Allocator::deallocate(_pWriteBuffer, _bufsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int_type overflow(int_type c)
|
virtual int_type overflow(int_type c)
|
||||||
{
|
{
|
||||||
if (!(_mode & IOS::out)) return char_traits::eof();
|
if (!(_mode & IOS::out)) return char_traits::eof();
|
||||||
|
|
||||||
if (c != char_traits::eof())
|
if (c != char_traits::eof())
|
||||||
{
|
{
|
||||||
*this->pptr() = char_traits::to_char_type(c);
|
*this->pptr() = char_traits::to_char_type(c);
|
||||||
this->pbump(1);
|
this->pbump(1);
|
||||||
}
|
}
|
||||||
if (flushBuffer() == std::streamsize(-1)) return char_traits::eof();
|
if (flushBuffer() == std::streamsize(-1)) return char_traits::eof();
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int_type underflow()
|
virtual int_type underflow()
|
||||||
{
|
{
|
||||||
if (!(_mode & IOS::in)) return char_traits::eof();
|
if (!(_mode & IOS::in)) return char_traits::eof();
|
||||||
|
|
||||||
if (this->gptr() && (this->gptr() < this->egptr()))
|
if (this->gptr() && (this->gptr() < this->egptr()))
|
||||||
return char_traits::to_int_type(*this->gptr());
|
return char_traits::to_int_type(*this->gptr());
|
||||||
|
|
||||||
int putback = int(this->gptr() - this->eback());
|
int putback = int(this->gptr() - this->eback());
|
||||||
if (putback > 4) putback = 4;
|
if (putback > 4) putback = 4;
|
||||||
|
|
||||||
char_traits::copy(_pReadBuffer + (4 - putback), this->gptr() - putback, putback);
|
char_traits::copy(_pReadBuffer + (4 - putback), this->gptr() - putback, putback);
|
||||||
|
|
||||||
int n = readFromDevice(_pReadBuffer + 4, _bufsize - 4);
|
int n = readFromDevice(_pReadBuffer + 4, _bufsize - 4);
|
||||||
if (n <= 0) return char_traits::eof();
|
if (n <= 0) return char_traits::eof();
|
||||||
|
|
||||||
this->setg(_pReadBuffer + (4 - putback), _pReadBuffer + 4, _pReadBuffer + 4 + n);
|
this->setg(_pReadBuffer + (4 - putback), _pReadBuffer + 4, _pReadBuffer + 4 + n);
|
||||||
|
|
||||||
// return next character
|
// return next character
|
||||||
return char_traits::to_int_type(*this->gptr());
|
return char_traits::to_int_type(*this->gptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int sync()
|
virtual int sync()
|
||||||
{
|
{
|
||||||
if (this->pptr() && this->pptr() > this->pbase())
|
if (this->pptr() && this->pptr() > this->pbase())
|
||||||
{
|
{
|
||||||
if (flushBuffer() == -1) return -1;
|
if (flushBuffer() == -1) return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setMode(openmode mode)
|
void setMode(openmode mode)
|
||||||
{
|
{
|
||||||
_mode = mode;
|
_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
openmode getMode() const
|
openmode getMode() const
|
||||||
{
|
{
|
||||||
return _mode;
|
return _mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
void resetBuffers()
|
void resetBuffers()
|
||||||
{
|
{
|
||||||
this->setg(_pReadBuffer + 4, _pReadBuffer + 4, _pReadBuffer + 4);
|
this->setg(_pReadBuffer + 4, _pReadBuffer + 4, _pReadBuffer + 4);
|
||||||
this->setp(_pWriteBuffer, _pWriteBuffer + (_bufsize - 1));
|
this->setp(_pWriteBuffer, _pWriteBuffer + (_bufsize - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual int readFromDevice(char_type* buffer, std::streamsize length)
|
virtual int readFromDevice(char_type* buffer, std::streamsize length)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int writeToDevice(const char_type* buffer, std::streamsize length)
|
virtual int writeToDevice(const char_type* buffer, std::streamsize length)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int flushBuffer()
|
int flushBuffer()
|
||||||
{
|
{
|
||||||
int n = int(this->pptr() - this->pbase());
|
int n = int(this->pptr() - this->pbase());
|
||||||
if (writeToDevice(this->pbase(), n) == n)
|
if (writeToDevice(this->pbase(), n) == n)
|
||||||
{
|
{
|
||||||
this->pbump(-n);
|
this->pbump(-n);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::streamsize _bufsize;
|
std::streamsize _bufsize;
|
||||||
char_type* _pReadBuffer;
|
char_type* _pReadBuffer;
|
||||||
char_type* _pWriteBuffer;
|
char_type* _pWriteBuffer;
|
||||||
openmode _mode;
|
openmode _mode;
|
||||||
|
|
||||||
BasicBufferedBidirectionalStreamBuf(const BasicBufferedBidirectionalStreamBuf&);
|
BasicBufferedBidirectionalStreamBuf(const BasicBufferedBidirectionalStreamBuf&);
|
||||||
BasicBufferedBidirectionalStreamBuf& operator = (const BasicBufferedBidirectionalStreamBuf&);
|
BasicBufferedBidirectionalStreamBuf& operator = (const BasicBufferedBidirectionalStreamBuf&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// We provide an instantiation for char
|
// We provide an instantiation for char
|
||||||
//
|
//
|
||||||
typedef BasicBufferedBidirectionalStreamBuf<char, std::char_traits<char> > BufferedBidirectionalStreamBuf;
|
typedef BasicBufferedBidirectionalStreamBuf<char, std::char_traits<char> > BufferedBidirectionalStreamBuf;
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_BufferedBidirectionalStreamBuf_INCLUDED
|
#endif // Foundation_BufferedBidirectionalStreamBuf_INCLUDED
|
||||||
|
|||||||
@@ -1,188 +1,188 @@
|
|||||||
//
|
//
|
||||||
// BufferedStreamBuf.h
|
// BufferedStreamBuf.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/BufferedStreamBuf.h#3 $
|
// $Id: //poco/1.3/Foundation/include/Poco/BufferedStreamBuf.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: StreamBuf
|
// Module: StreamBuf
|
||||||
//
|
//
|
||||||
// Definition of template BasicBufferedStreamBuf and class BufferedStreamBuf.
|
// Definition of template BasicBufferedStreamBuf and class BufferedStreamBuf.
|
||||||
//
|
//
|
||||||
// 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_BufferedStreamBuf_INCLUDED
|
#ifndef Foundation_BufferedStreamBuf_INCLUDED
|
||||||
#define Foundation_BufferedStreamBuf_INCLUDED
|
#define Foundation_BufferedStreamBuf_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/BufferAllocator.h"
|
#include "Poco/BufferAllocator.h"
|
||||||
#include "Poco/StreamUtil.h"
|
#include "Poco/StreamUtil.h"
|
||||||
#include <streambuf>
|
#include <streambuf>
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
#include <ios>
|
#include <ios>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <typename ch, typename tr, typename ba = BufferAllocator<ch> >
|
template <typename ch, typename tr, typename ba = BufferAllocator<ch> >
|
||||||
class BasicBufferedStreamBuf: public std::basic_streambuf<ch, tr>
|
class BasicBufferedStreamBuf: public std::basic_streambuf<ch, tr>
|
||||||
/// This is an implementation of a buffered streambuf
|
/// This is an implementation of a buffered streambuf
|
||||||
/// that greatly simplifies the implementation of
|
/// that greatly simplifies the implementation of
|
||||||
/// custom streambufs of various kinds.
|
/// custom streambufs of various kinds.
|
||||||
/// Derived classes only have to override the methods
|
/// Derived classes only have to override the methods
|
||||||
/// readFromDevice() or writeToDevice().
|
/// readFromDevice() or writeToDevice().
|
||||||
///
|
///
|
||||||
/// This streambuf only supports unidirectional streams.
|
/// This streambuf only supports unidirectional streams.
|
||||||
/// In other words, the BasicBufferedStreamBuf can be
|
/// In other words, the BasicBufferedStreamBuf can be
|
||||||
/// used for the implementation of an istream or an
|
/// used for the implementation of an istream or an
|
||||||
/// ostream, but not for an iostream.
|
/// ostream, but not for an iostream.
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef std::basic_streambuf<ch, tr> Base;
|
typedef std::basic_streambuf<ch, tr> Base;
|
||||||
typedef std::basic_ios<ch, tr> IOS;
|
typedef std::basic_ios<ch, tr> IOS;
|
||||||
typedef ch char_type;
|
typedef ch char_type;
|
||||||
typedef tr char_traits;
|
typedef tr char_traits;
|
||||||
typedef ba Allocator;
|
typedef ba Allocator;
|
||||||
typedef typename Base::int_type int_type;
|
typedef typename Base::int_type int_type;
|
||||||
typedef typename Base::pos_type pos_type;
|
typedef typename Base::pos_type pos_type;
|
||||||
typedef typename Base::off_type off_type;
|
typedef typename Base::off_type off_type;
|
||||||
typedef typename IOS::openmode openmode;
|
typedef typename IOS::openmode openmode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BasicBufferedStreamBuf(std::streamsize bufferSize, openmode mode):
|
BasicBufferedStreamBuf(std::streamsize bufferSize, openmode mode):
|
||||||
_bufsize(bufferSize),
|
_bufsize(bufferSize),
|
||||||
_pBuffer(Allocator::allocate(_bufsize)),
|
_pBuffer(Allocator::allocate(_bufsize)),
|
||||||
_mode(mode)
|
_mode(mode)
|
||||||
{
|
{
|
||||||
this->setg(_pBuffer + 4, _pBuffer + 4, _pBuffer + 4);
|
this->setg(_pBuffer + 4, _pBuffer + 4, _pBuffer + 4);
|
||||||
this->setp(_pBuffer, _pBuffer + (_bufsize - 1));
|
this->setp(_pBuffer, _pBuffer + (_bufsize - 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
~BasicBufferedStreamBuf()
|
~BasicBufferedStreamBuf()
|
||||||
{
|
{
|
||||||
Allocator::deallocate(_pBuffer, _bufsize);
|
Allocator::deallocate(_pBuffer, _bufsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int_type overflow(int_type c)
|
virtual int_type overflow(int_type c)
|
||||||
{
|
{
|
||||||
if (!(_mode & IOS::out)) return char_traits::eof();
|
if (!(_mode & IOS::out)) return char_traits::eof();
|
||||||
|
|
||||||
if (c != char_traits::eof())
|
if (c != char_traits::eof())
|
||||||
{
|
{
|
||||||
*this->pptr() = char_traits::to_char_type(c);
|
*this->pptr() = char_traits::to_char_type(c);
|
||||||
this->pbump(1);
|
this->pbump(1);
|
||||||
}
|
}
|
||||||
if (flushBuffer() == std::streamsize(-1)) return char_traits::eof();
|
if (flushBuffer() == std::streamsize(-1)) return char_traits::eof();
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int_type underflow()
|
virtual int_type underflow()
|
||||||
{
|
{
|
||||||
if (!(_mode & IOS::in)) return char_traits::eof();
|
if (!(_mode & IOS::in)) return char_traits::eof();
|
||||||
|
|
||||||
if (this->gptr() && (this->gptr() < this->egptr()))
|
if (this->gptr() && (this->gptr() < this->egptr()))
|
||||||
return char_traits::to_int_type(*this->gptr());
|
return char_traits::to_int_type(*this->gptr());
|
||||||
|
|
||||||
int putback = int(this->gptr() - this->eback());
|
int putback = int(this->gptr() - this->eback());
|
||||||
if (putback > 4) putback = 4;
|
if (putback > 4) putback = 4;
|
||||||
|
|
||||||
char_traits::copy(_pBuffer + (4 - putback), this->gptr() - putback, putback);
|
char_traits::copy(_pBuffer + (4 - putback), this->gptr() - putback, putback);
|
||||||
|
|
||||||
int n = readFromDevice(_pBuffer + 4, _bufsize - 4);
|
int n = readFromDevice(_pBuffer + 4, _bufsize - 4);
|
||||||
if (n <= 0) return char_traits::eof();
|
if (n <= 0) return char_traits::eof();
|
||||||
|
|
||||||
this->setg(_pBuffer + (4 - putback), _pBuffer + 4, _pBuffer + 4 + n);
|
this->setg(_pBuffer + (4 - putback), _pBuffer + 4, _pBuffer + 4 + n);
|
||||||
|
|
||||||
// return next character
|
// return next character
|
||||||
return char_traits::to_int_type(*this->gptr());
|
return char_traits::to_int_type(*this->gptr());
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int sync()
|
virtual int sync()
|
||||||
{
|
{
|
||||||
if (this->pptr() && this->pptr() > this->pbase())
|
if (this->pptr() && this->pptr() > this->pbase())
|
||||||
{
|
{
|
||||||
if (flushBuffer() == -1) return -1;
|
if (flushBuffer() == -1) return -1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void setMode(openmode mode)
|
void setMode(openmode mode)
|
||||||
{
|
{
|
||||||
_mode = mode;
|
_mode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
openmode getMode() const
|
openmode getMode() const
|
||||||
{
|
{
|
||||||
return _mode;
|
return _mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual int readFromDevice(char_type* buffer, std::streamsize length)
|
virtual int readFromDevice(char_type* buffer, std::streamsize length)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int writeToDevice(const char_type* buffer, std::streamsize length)
|
virtual int writeToDevice(const char_type* buffer, std::streamsize length)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int flushBuffer()
|
int flushBuffer()
|
||||||
{
|
{
|
||||||
int n = int(this->pptr() - this->pbase());
|
int n = int(this->pptr() - this->pbase());
|
||||||
if (writeToDevice(this->pbase(), n) == n)
|
if (writeToDevice(this->pbase(), n) == n)
|
||||||
{
|
{
|
||||||
this->pbump(-n);
|
this->pbump(-n);
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::streamsize _bufsize;
|
std::streamsize _bufsize;
|
||||||
char_type* _pBuffer;
|
char_type* _pBuffer;
|
||||||
openmode _mode;
|
openmode _mode;
|
||||||
|
|
||||||
BasicBufferedStreamBuf(const BasicBufferedStreamBuf&);
|
BasicBufferedStreamBuf(const BasicBufferedStreamBuf&);
|
||||||
BasicBufferedStreamBuf& operator = (const BasicBufferedStreamBuf&);
|
BasicBufferedStreamBuf& operator = (const BasicBufferedStreamBuf&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// We provide an instantiation for char
|
// We provide an instantiation for char
|
||||||
//
|
//
|
||||||
typedef BasicBufferedStreamBuf<char, std::char_traits<char> > BufferedStreamBuf;
|
typedef BasicBufferedStreamBuf<char, std::char_traits<char> > BufferedStreamBuf;
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_BufferedStreamBuf_INCLUDED
|
#endif // Foundation_BufferedStreamBuf_INCLUDED
|
||||||
|
|||||||
@@ -1,165 +1,165 @@
|
|||||||
//
|
//
|
||||||
// Bugcheck.h
|
// Bugcheck.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Bugcheck.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Bugcheck.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: Bugcheck
|
// Module: Bugcheck
|
||||||
//
|
//
|
||||||
// Definition of the Bugcheck class and the self-testing macros.
|
// Definition of the Bugcheck class and the self-testing macros.
|
||||||
//
|
//
|
||||||
// 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_Bugcheck_INCLUDED
|
#ifndef Foundation_Bugcheck_INCLUDED
|
||||||
#define Foundation_Bugcheck_INCLUDED
|
#define Foundation_Bugcheck_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Bugcheck
|
class Foundation_API Bugcheck
|
||||||
/// This class provides some static methods that are
|
/// This class provides some static methods that are
|
||||||
/// used by the
|
/// used by the
|
||||||
/// poco_assert_dbg(), poco_assert(), poco_check_ptr()
|
/// poco_assert_dbg(), poco_assert(), poco_check_ptr()
|
||||||
/// and poco_bugcheck() macros.
|
/// and poco_bugcheck() macros.
|
||||||
/// You should not invoke these methods
|
/// You should not invoke these methods
|
||||||
/// directly. Use the macros instead, as they
|
/// directly. Use the macros instead, as they
|
||||||
/// automatically provide useful context information.
|
/// automatically provide useful context information.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void assertion(const char* cond, const char* file, int line);
|
static void assertion(const char* cond, const char* file, int line);
|
||||||
/// An assertion failed. Break into the debugger, if
|
/// An assertion failed. Break into the debugger, if
|
||||||
/// possible, then throw an AssertionViolationException.
|
/// possible, then throw an AssertionViolationException.
|
||||||
|
|
||||||
static void nullPointer(const char* ptr, const char* file, int line);
|
static void nullPointer(const char* ptr, const char* file, int line);
|
||||||
/// An null pointer was encountered. Break into the debugger, if
|
/// An null pointer was encountered. Break into the debugger, if
|
||||||
/// possible, then throw an NullPointerException.
|
/// possible, then throw an NullPointerException.
|
||||||
|
|
||||||
static void bugcheck(const char* file, int line);
|
static void bugcheck(const char* file, int line);
|
||||||
/// An internal error was encountered. Break into the debugger, if
|
/// An internal error was encountered. Break into the debugger, if
|
||||||
/// possible, then throw an BugcheckException.
|
/// possible, then throw an BugcheckException.
|
||||||
|
|
||||||
static void bugcheck(const char* msg, const char* file, int line);
|
static void bugcheck(const char* msg, const char* file, int line);
|
||||||
/// An internal error was encountered. Break into the debugger, if
|
/// An internal error was encountered. Break into the debugger, if
|
||||||
/// possible, then throw an BugcheckException.
|
/// possible, then throw an BugcheckException.
|
||||||
|
|
||||||
static void debugger(const char* file, int line);
|
static void debugger(const char* file, int line);
|
||||||
/// An internal error was encountered. Break into the debugger, if
|
/// An internal error was encountered. Break into the debugger, if
|
||||||
/// possible.
|
/// possible.
|
||||||
|
|
||||||
static void debugger(const char* msg, const char* file, int line);
|
static void debugger(const char* msg, const char* file, int line);
|
||||||
/// An internal error was encountered. Break into the debugger, if
|
/// An internal error was encountered. Break into the debugger, if
|
||||||
/// possible.
|
/// possible.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static std::string what(const char* msg, const char* file, int line);
|
static std::string what(const char* msg, const char* file, int line);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// useful macros (these automatically supply line number and file name)
|
// useful macros (these automatically supply line number and file name)
|
||||||
//
|
//
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
#define poco_assert_dbg(cond) \
|
#define poco_assert_dbg(cond) \
|
||||||
if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0
|
if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0
|
||||||
#else
|
#else
|
||||||
#define poco_assert_dbg(cond)
|
#define poco_assert_dbg(cond)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#define poco_assert(cond) \
|
#define poco_assert(cond) \
|
||||||
if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0
|
if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0
|
||||||
|
|
||||||
|
|
||||||
#define poco_check_ptr(ptr) \
|
#define poco_check_ptr(ptr) \
|
||||||
if (!(ptr)) Poco::Bugcheck::nullPointer(#ptr, __FILE__, __LINE__); else (void) 0
|
if (!(ptr)) Poco::Bugcheck::nullPointer(#ptr, __FILE__, __LINE__); else (void) 0
|
||||||
|
|
||||||
|
|
||||||
#define poco_bugcheck() \
|
#define poco_bugcheck() \
|
||||||
Poco::Bugcheck::bugcheck(__FILE__, __LINE__)
|
Poco::Bugcheck::bugcheck(__FILE__, __LINE__)
|
||||||
|
|
||||||
|
|
||||||
#define poco_bugcheck_msg(msg) \
|
#define poco_bugcheck_msg(msg) \
|
||||||
Poco::Bugcheck::bugcheck(msg, __FILE__, __LINE__)
|
Poco::Bugcheck::bugcheck(msg, __FILE__, __LINE__)
|
||||||
|
|
||||||
|
|
||||||
#define poco_debugger() \
|
#define poco_debugger() \
|
||||||
Poco::Bugcheck::debugger(__FILE__, __LINE__)
|
Poco::Bugcheck::debugger(__FILE__, __LINE__)
|
||||||
|
|
||||||
|
|
||||||
#define poco_debugger_msg(msg) \
|
#define poco_debugger_msg(msg) \
|
||||||
Poco::Bugcheck::debugger(msg, __FILE__, __LINE__)
|
Poco::Bugcheck::debugger(msg, __FILE__, __LINE__)
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// poco_static_assert
|
// poco_static_assert
|
||||||
//
|
//
|
||||||
// The following was ported from <boost/static_assert.hpp>
|
// The following was ported from <boost/static_assert.hpp>
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
template <bool x>
|
template <bool x>
|
||||||
struct POCO_STATIC_ASSERTION_FAILURE;
|
struct POCO_STATIC_ASSERTION_FAILURE;
|
||||||
|
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
struct POCO_STATIC_ASSERTION_FAILURE<true>
|
struct POCO_STATIC_ASSERTION_FAILURE<true>
|
||||||
{
|
{
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
value = 1
|
value = 1
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <int x>
|
template <int x>
|
||||||
struct poco_static_assert_test
|
struct poco_static_assert_test
|
||||||
{
|
{
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#if defined(__GNUC__) && (__GNUC__ == 3) && ((__GNUC_MINOR__ == 3) || (__GNUC_MINOR__ == 4))
|
#if defined(__GNUC__) && (__GNUC__ == 3) && ((__GNUC_MINOR__ == 3) || (__GNUC_MINOR__ == 4))
|
||||||
#define poco_static_assert(B) \
|
#define poco_static_assert(B) \
|
||||||
typedef char POCO_JOIN(poco_static_assert_typedef_, __LINE__) \
|
typedef char POCO_JOIN(poco_static_assert_typedef_, __LINE__) \
|
||||||
[POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>::value]
|
[POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>::value]
|
||||||
#else
|
#else
|
||||||
#define poco_static_assert(B) \
|
#define poco_static_assert(B) \
|
||||||
typedef poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>)> \
|
typedef poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>)> \
|
||||||
POCO_JOIN(poco_static_assert_typedef_, __LINE__)
|
POCO_JOIN(poco_static_assert_typedef_, __LINE__)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Bugcheck_INCLUDED
|
#endif // Foundation_Bugcheck_INCLUDED
|
||||||
|
|||||||
@@ -1,227 +1,227 @@
|
|||||||
//
|
//
|
||||||
// ByteOrder.h
|
// ByteOrder.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ByteOrder.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ByteOrder.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: ByteOrder
|
// Module: ByteOrder
|
||||||
//
|
//
|
||||||
// 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_ByteOrder_INCLUDED
|
#ifndef Foundation_ByteOrder_INCLUDED
|
||||||
#define Foundation_ByteOrder_INCLUDED
|
#define Foundation_ByteOrder_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Types.h"
|
#include "Poco/Types.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API ByteOrder
|
class Foundation_API ByteOrder
|
||||||
/// This class contains a number of static methods
|
/// This class contains a number of static methods
|
||||||
/// to convert between big-endian and little-endian
|
/// to convert between big-endian and little-endian
|
||||||
/// integers of various sizes.
|
/// integers of various sizes.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Int16 flipBytes(Int16 value);
|
static Int16 flipBytes(Int16 value);
|
||||||
static UInt16 flipBytes(UInt16 value);
|
static UInt16 flipBytes(UInt16 value);
|
||||||
static Int32 flipBytes(Int32 value);
|
static Int32 flipBytes(Int32 value);
|
||||||
static UInt32 flipBytes(UInt32 value);
|
static UInt32 flipBytes(UInt32 value);
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
static Int64 flipBytes(Int64 value);
|
static Int64 flipBytes(Int64 value);
|
||||||
static UInt64 flipBytes(UInt64 value);
|
static UInt64 flipBytes(UInt64 value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int16 toBigEndian(Int16 value);
|
static Int16 toBigEndian(Int16 value);
|
||||||
static UInt16 toBigEndian (UInt16 value);
|
static UInt16 toBigEndian (UInt16 value);
|
||||||
static Int32 toBigEndian(Int32 value);
|
static Int32 toBigEndian(Int32 value);
|
||||||
static UInt32 toBigEndian (UInt32 value);
|
static UInt32 toBigEndian (UInt32 value);
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
static Int64 toBigEndian(Int64 value);
|
static Int64 toBigEndian(Int64 value);
|
||||||
static UInt64 toBigEndian (UInt64 value);
|
static UInt64 toBigEndian (UInt64 value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int16 fromBigEndian(Int16 value);
|
static Int16 fromBigEndian(Int16 value);
|
||||||
static UInt16 fromBigEndian (UInt16 value);
|
static UInt16 fromBigEndian (UInt16 value);
|
||||||
static Int32 fromBigEndian(Int32 value);
|
static Int32 fromBigEndian(Int32 value);
|
||||||
static UInt32 fromBigEndian (UInt32 value);
|
static UInt32 fromBigEndian (UInt32 value);
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
static Int64 fromBigEndian(Int64 value);
|
static Int64 fromBigEndian(Int64 value);
|
||||||
static UInt64 fromBigEndian (UInt64 value);
|
static UInt64 fromBigEndian (UInt64 value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int16 toLittleEndian(Int16 value);
|
static Int16 toLittleEndian(Int16 value);
|
||||||
static UInt16 toLittleEndian (UInt16 value);
|
static UInt16 toLittleEndian (UInt16 value);
|
||||||
static Int32 toLittleEndian(Int32 value);
|
static Int32 toLittleEndian(Int32 value);
|
||||||
static UInt32 toLittleEndian (UInt32 value);
|
static UInt32 toLittleEndian (UInt32 value);
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
static Int64 toLittleEndian(Int64 value);
|
static Int64 toLittleEndian(Int64 value);
|
||||||
static UInt64 toLittleEndian (UInt64 value);
|
static UInt64 toLittleEndian (UInt64 value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int16 fromLittleEndian(Int16 value);
|
static Int16 fromLittleEndian(Int16 value);
|
||||||
static UInt16 fromLittleEndian (UInt16 value);
|
static UInt16 fromLittleEndian (UInt16 value);
|
||||||
static Int32 fromLittleEndian(Int32 value);
|
static Int32 fromLittleEndian(Int32 value);
|
||||||
static UInt32 fromLittleEndian (UInt32 value);
|
static UInt32 fromLittleEndian (UInt32 value);
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
static Int64 fromLittleEndian(Int64 value);
|
static Int64 fromLittleEndian(Int64 value);
|
||||||
static UInt64 fromLittleEndian (UInt64 value);
|
static UInt64 fromLittleEndian (UInt64 value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int16 toNetwork(Int16 value);
|
static Int16 toNetwork(Int16 value);
|
||||||
static UInt16 toNetwork (UInt16 value);
|
static UInt16 toNetwork (UInt16 value);
|
||||||
static Int32 toNetwork(Int32 value);
|
static Int32 toNetwork(Int32 value);
|
||||||
static UInt32 toNetwork (UInt32 value);
|
static UInt32 toNetwork (UInt32 value);
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
static Int64 toNetwork(Int64 value);
|
static Int64 toNetwork(Int64 value);
|
||||||
static UInt64 toNetwork (UInt64 value);
|
static UInt64 toNetwork (UInt64 value);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static Int16 fromNetwork(Int16 value);
|
static Int16 fromNetwork(Int16 value);
|
||||||
static UInt16 fromNetwork (UInt16 value);
|
static UInt16 fromNetwork (UInt16 value);
|
||||||
static Int32 fromNetwork(Int32 value);
|
static Int32 fromNetwork(Int32 value);
|
||||||
static UInt32 fromNetwork (UInt32 value);
|
static UInt32 fromNetwork (UInt32 value);
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
static Int64 fromNetwork(Int64 value);
|
static Int64 fromNetwork(Int64 value);
|
||||||
static UInt64 fromNetwork (UInt64 value);
|
static UInt64 fromNetwork (UInt64 value);
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline UInt16 ByteOrder::flipBytes(UInt16 value)
|
inline UInt16 ByteOrder::flipBytes(UInt16 value)
|
||||||
{
|
{
|
||||||
return ((value >> 8) & 0x00FF) | ((value << 8) & 0xFF00);
|
return ((value >> 8) & 0x00FF) | ((value << 8) & 0xFF00);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Int16 ByteOrder::flipBytes(Int16 value)
|
inline Int16 ByteOrder::flipBytes(Int16 value)
|
||||||
{
|
{
|
||||||
return Int16(flipBytes(UInt16(value)));
|
return Int16(flipBytes(UInt16(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline UInt32 ByteOrder::flipBytes(UInt32 value)
|
inline UInt32 ByteOrder::flipBytes(UInt32 value)
|
||||||
{
|
{
|
||||||
return ((value >> 24) & 0x000000FF) | ((value >> 8) & 0x0000FF00)
|
return ((value >> 24) & 0x000000FF) | ((value >> 8) & 0x0000FF00)
|
||||||
| ((value << 8) & 0x00FF0000) | ((value << 24) & 0xFF000000);
|
| ((value << 8) & 0x00FF0000) | ((value << 24) & 0xFF000000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Int32 ByteOrder::flipBytes(Int32 value)
|
inline Int32 ByteOrder::flipBytes(Int32 value)
|
||||||
{
|
{
|
||||||
return Int32(flipBytes(UInt32(value)));
|
return Int32(flipBytes(UInt32(value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
inline UInt64 ByteOrder::flipBytes(UInt64 value)
|
inline UInt64 ByteOrder::flipBytes(UInt64 value)
|
||||||
{
|
{
|
||||||
UInt32 hi = UInt32(value >> 32);
|
UInt32 hi = UInt32(value >> 32);
|
||||||
UInt32 lo = UInt32(value & 0xFFFFFFFF);
|
UInt32 lo = UInt32(value & 0xFFFFFFFF);
|
||||||
return UInt64(flipBytes(hi)) | (UInt64(flipBytes(lo)) << 32);
|
return UInt64(flipBytes(hi)) | (UInt64(flipBytes(lo)) << 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Int64 ByteOrder::flipBytes(Int64 value)
|
inline Int64 ByteOrder::flipBytes(Int64 value)
|
||||||
{
|
{
|
||||||
return Int64(flipBytes(UInt64(value)));
|
return Int64(flipBytes(UInt64(value)));
|
||||||
}
|
}
|
||||||
#endif // POCO_HAVE_INT64
|
#endif // POCO_HAVE_INT64
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// some macro trickery to automate the method implementation
|
// some macro trickery to automate the method implementation
|
||||||
//
|
//
|
||||||
#define POCO_IMPLEMENT_BYTEORDER_NOOP_(op, type) \
|
#define POCO_IMPLEMENT_BYTEORDER_NOOP_(op, type) \
|
||||||
inline type ByteOrder::op(type value) \
|
inline type ByteOrder::op(type value) \
|
||||||
{ \
|
{ \
|
||||||
return value; \
|
return value; \
|
||||||
}
|
}
|
||||||
#define POCO_IMPLEMENT_BYTEORDER_FLIP_(op, type) \
|
#define POCO_IMPLEMENT_BYTEORDER_FLIP_(op, type) \
|
||||||
inline type ByteOrder::op(type value) \
|
inline type ByteOrder::op(type value) \
|
||||||
{ \
|
{ \
|
||||||
return flipBytes(value); \
|
return flipBytes(value); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if defined(POCO_HAVE_INT64)
|
#if defined(POCO_HAVE_INT64)
|
||||||
#define POCO_IMPLEMENT_BYTEORDER_NOOP(op) \
|
#define POCO_IMPLEMENT_BYTEORDER_NOOP(op) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int16) \
|
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int16) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt16) \
|
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt16) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int32) \
|
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int32) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt32) \
|
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt32) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int64) \
|
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int64) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt64)
|
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt64)
|
||||||
#define POCO_IMPLEMENT_BYTEORDER_FLIP(op) \
|
#define POCO_IMPLEMENT_BYTEORDER_FLIP(op) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int16) \
|
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int16) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt16) \
|
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt16) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int32) \
|
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int32) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt32) \
|
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt32) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int64) \
|
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int64) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt64)
|
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt64)
|
||||||
#else
|
#else
|
||||||
#define POCO_IMPLEMENT_BYTEORDER_NOOP(op) \
|
#define POCO_IMPLEMENT_BYTEORDER_NOOP(op) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int16) \
|
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int16) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt16) \
|
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt16) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int32) \
|
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, Int32) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt32)
|
POCO_IMPLEMENT_BYTEORDER_NOOP_(op, UInt32)
|
||||||
#define POCO_IMPLEMENT_BYTEORDER_FLIP(op) \
|
#define POCO_IMPLEMENT_BYTEORDER_FLIP(op) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int16) \
|
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int16) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt16) \
|
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt16) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int32) \
|
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, Int32) \
|
||||||
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt32)
|
POCO_IMPLEMENT_BYTEORDER_FLIP_(op, UInt32)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(POCO_ARCH_BIG_ENDIAN)
|
#if defined(POCO_ARCH_BIG_ENDIAN)
|
||||||
#define POCO_IMPLEMENT_BYTEORDER_BIG POCO_IMPLEMENT_BYTEORDER_NOOP
|
#define POCO_IMPLEMENT_BYTEORDER_BIG POCO_IMPLEMENT_BYTEORDER_NOOP
|
||||||
#define POCO_IMPLEMENT_BYTEORDER_LIT POCO_IMPLEMENT_BYTEORDER_FLIP
|
#define POCO_IMPLEMENT_BYTEORDER_LIT POCO_IMPLEMENT_BYTEORDER_FLIP
|
||||||
#else
|
#else
|
||||||
#define POCO_IMPLEMENT_BYTEORDER_BIG POCO_IMPLEMENT_BYTEORDER_FLIP
|
#define POCO_IMPLEMENT_BYTEORDER_BIG POCO_IMPLEMENT_BYTEORDER_FLIP
|
||||||
#define POCO_IMPLEMENT_BYTEORDER_LIT POCO_IMPLEMENT_BYTEORDER_NOOP
|
#define POCO_IMPLEMENT_BYTEORDER_LIT POCO_IMPLEMENT_BYTEORDER_NOOP
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
POCO_IMPLEMENT_BYTEORDER_BIG(toBigEndian)
|
POCO_IMPLEMENT_BYTEORDER_BIG(toBigEndian)
|
||||||
POCO_IMPLEMENT_BYTEORDER_BIG(fromBigEndian)
|
POCO_IMPLEMENT_BYTEORDER_BIG(fromBigEndian)
|
||||||
POCO_IMPLEMENT_BYTEORDER_BIG(toNetwork)
|
POCO_IMPLEMENT_BYTEORDER_BIG(toNetwork)
|
||||||
POCO_IMPLEMENT_BYTEORDER_BIG(fromNetwork)
|
POCO_IMPLEMENT_BYTEORDER_BIG(fromNetwork)
|
||||||
POCO_IMPLEMENT_BYTEORDER_LIT(toLittleEndian)
|
POCO_IMPLEMENT_BYTEORDER_LIT(toLittleEndian)
|
||||||
POCO_IMPLEMENT_BYTEORDER_LIT(fromLittleEndian)
|
POCO_IMPLEMENT_BYTEORDER_LIT(fromLittleEndian)
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_ByteOrder_INCLUDED
|
#endif // Foundation_ByteOrder_INCLUDED
|
||||||
|
|||||||
@@ -1,100 +1,100 @@
|
|||||||
//
|
//
|
||||||
// Channel.h
|
// Channel.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Channel.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Channel.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Logging
|
// Package: Logging
|
||||||
// Module: Channel
|
// Module: Channel
|
||||||
//
|
//
|
||||||
// Definition of the Channel class.
|
// Definition of the Channel 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_Channel_INCLUDED
|
#ifndef Foundation_Channel_INCLUDED
|
||||||
#define Foundation_Channel_INCLUDED
|
#define Foundation_Channel_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Configurable.h"
|
#include "Poco/Configurable.h"
|
||||||
#include "Poco/Mutex.h"
|
#include "Poco/Mutex.h"
|
||||||
#include "Poco/RefCountedObject.h"
|
#include "Poco/RefCountedObject.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Message;
|
class Message;
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Channel: public Configurable, public RefCountedObject
|
class Foundation_API Channel: public Configurable, public RefCountedObject
|
||||||
/// The base class for all Channel classes.
|
/// The base class for all Channel classes.
|
||||||
///
|
///
|
||||||
/// Supports reference counting based garbage
|
/// Supports reference counting based garbage
|
||||||
/// collection and provides trivial implementations
|
/// collection and provides trivial implementations
|
||||||
/// of getProperty() and setProperty().
|
/// of getProperty() and setProperty().
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Channel();
|
Channel();
|
||||||
/// Creates the channel and initializes
|
/// Creates the channel and initializes
|
||||||
/// the reference count to one.
|
/// the reference count to one.
|
||||||
|
|
||||||
virtual void open();
|
virtual void open();
|
||||||
/// Does whatever is necessary to open the channel.
|
/// Does whatever is necessary to open the channel.
|
||||||
/// The default implementation does nothing.
|
/// The default implementation does nothing.
|
||||||
|
|
||||||
virtual void close();
|
virtual void close();
|
||||||
/// Does whatever is necessary to close the channel.
|
/// Does whatever is necessary to close the channel.
|
||||||
/// The default implementation does nothing.
|
/// The default implementation does nothing.
|
||||||
|
|
||||||
virtual void log(const Message& msg) = 0;
|
virtual void log(const Message& msg) = 0;
|
||||||
/// Logs the given message to the channel. Must be
|
/// Logs the given message to the channel. Must be
|
||||||
/// overridden by subclasses.
|
/// overridden by subclasses.
|
||||||
///
|
///
|
||||||
/// If the channel has not been opened yet, the log()
|
/// If the channel has not been opened yet, the log()
|
||||||
/// method will open it.
|
/// method will open it.
|
||||||
|
|
||||||
void setProperty(const std::string& name, const std::string& value);
|
void setProperty(const std::string& name, const std::string& value);
|
||||||
/// Throws a PropertyNotSupportedException.
|
/// Throws a PropertyNotSupportedException.
|
||||||
|
|
||||||
std::string getProperty(const std::string& name) const;
|
std::string getProperty(const std::string& name) const;
|
||||||
/// Throws a PropertyNotSupportedException.
|
/// Throws a PropertyNotSupportedException.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~Channel();
|
virtual ~Channel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Channel(const Channel&);
|
Channel(const Channel&);
|
||||||
Channel& operator = (const Channel&);
|
Channel& operator = (const Channel&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Channel_INCLUDED
|
#endif // Foundation_Channel_INCLUDED
|
||||||
|
|||||||
@@ -1,130 +1,130 @@
|
|||||||
//
|
//
|
||||||
// Checksum.h
|
// Checksum.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Checksum.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Checksum.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: Checksum
|
// Module: Checksum
|
||||||
//
|
//
|
||||||
// Definition of the Checksum class.
|
// Definition of the Checksum class.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2007, 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_Checksum_INCLUDED
|
#ifndef Foundation_Checksum_INCLUDED
|
||||||
#define Foundation_Checksum_INCLUDED
|
#define Foundation_Checksum_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Checksum
|
class Foundation_API Checksum
|
||||||
/// This class calculates CRC-32 or Adler-32 checksums
|
/// This class calculates CRC-32 or Adler-32 checksums
|
||||||
/// for arbitrary data.
|
/// for arbitrary data.
|
||||||
///
|
///
|
||||||
/// A cyclic redundancy check (CRC) is a type of hash function, which is used to produce a
|
/// A cyclic redundancy check (CRC) is a type of hash function, which is used to produce a
|
||||||
/// small, fixed-size checksum of a larger block of data, such as a packet of network
|
/// small, fixed-size checksum of a larger block of data, such as a packet of network
|
||||||
/// traffic or a computer file. CRC-32 is one of the most commonly used CRC algorithms.
|
/// traffic or a computer file. CRC-32 is one of the most commonly used CRC algorithms.
|
||||||
///
|
///
|
||||||
/// Adler-32 is a checksum algorithm which was invented by Mark Adler.
|
/// Adler-32 is a checksum algorithm which was invented by Mark Adler.
|
||||||
/// It is almost as reliable as a 32-bit cyclic redundancy check for protecting against
|
/// It is almost as reliable as a 32-bit cyclic redundancy check for protecting against
|
||||||
/// accidental modification of data, such as distortions occurring during a transmission,
|
/// accidental modification of data, such as distortions occurring during a transmission,
|
||||||
/// but is significantly faster to calculate in software.
|
/// but is significantly faster to calculate in software.
|
||||||
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Type
|
enum Type
|
||||||
{
|
{
|
||||||
TYPE_ADLER32 = 0,
|
TYPE_ADLER32 = 0,
|
||||||
TYPE_CRC32
|
TYPE_CRC32
|
||||||
};
|
};
|
||||||
|
|
||||||
Checksum();
|
Checksum();
|
||||||
/// Creates a CRC-32 checksum initialized to 0.
|
/// Creates a CRC-32 checksum initialized to 0.
|
||||||
|
|
||||||
Checksum(Type t);
|
Checksum(Type t);
|
||||||
/// Creates the Checksum, using the given type.
|
/// Creates the Checksum, using the given type.
|
||||||
|
|
||||||
~Checksum();
|
~Checksum();
|
||||||
/// Destroys the Checksum.
|
/// Destroys the Checksum.
|
||||||
|
|
||||||
void update(const char* data, unsigned length);
|
void update(const char* data, unsigned length);
|
||||||
/// Updates the checksum with the given data.
|
/// Updates the checksum with the given data.
|
||||||
|
|
||||||
void update(const std::string& data);
|
void update(const std::string& data);
|
||||||
/// Updates the checksum with the given data.
|
/// Updates the checksum with the given data.
|
||||||
|
|
||||||
void update(char data);
|
void update(char data);
|
||||||
/// Updates the checksum with the given data.
|
/// Updates the checksum with the given data.
|
||||||
|
|
||||||
Poco::UInt32 checksum() const;
|
Poco::UInt32 checksum() const;
|
||||||
/// Returns the calculated checksum.
|
/// Returns the calculated checksum.
|
||||||
|
|
||||||
Type type() const;
|
Type type() const;
|
||||||
/// Which type of checksum are we calulcating
|
/// Which type of checksum are we calulcating
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Type _type;
|
Type _type;
|
||||||
Poco::UInt32 _value;
|
Poco::UInt32 _value;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline void Checksum::update(const std::string& data)
|
inline void Checksum::update(const std::string& data)
|
||||||
{
|
{
|
||||||
update(data.c_str(), static_cast<unsigned int>(data.size()));
|
update(data.c_str(), static_cast<unsigned int>(data.size()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Checksum::update(char c)
|
inline void Checksum::update(char c)
|
||||||
{
|
{
|
||||||
update(&c, 1);
|
update(&c, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Poco::UInt32 Checksum::checksum() const
|
inline Poco::UInt32 Checksum::checksum() const
|
||||||
{
|
{
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Checksum::Type Checksum::type() const
|
inline Checksum::Type Checksum::type() const
|
||||||
{
|
{
|
||||||
return _type;
|
return _type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Checksum_INCLUDED
|
#endif // Foundation_Checksum_INCLUDED
|
||||||
|
|||||||
@@ -1,123 +1,123 @@
|
|||||||
//
|
//
|
||||||
// ClassLibrary.h
|
// ClassLibrary.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ClassLibrary.h#3 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ClassLibrary.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: SharedLibrary
|
// Package: SharedLibrary
|
||||||
// Module: ClassLoader
|
// Module: ClassLoader
|
||||||
//
|
//
|
||||||
// Definitions for class libraries.
|
// Definitions for class libraries.
|
||||||
//
|
//
|
||||||
// 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_ClassLibrary_INCLUDED
|
#ifndef Foundation_ClassLibrary_INCLUDED
|
||||||
#define Foundation_ClassLibrary_INCLUDED
|
#define Foundation_ClassLibrary_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Manifest.h"
|
#include "Poco/Manifest.h"
|
||||||
#include <typeinfo>
|
#include <typeinfo>
|
||||||
|
|
||||||
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#define POCO_LIBRARY_API __declspec(dllexport)
|
#define POCO_LIBRARY_API __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define POCO_LIBRARY_API
|
#define POCO_LIBRARY_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// the entry points for every class library
|
// the entry points for every class library
|
||||||
//
|
//
|
||||||
extern "C"
|
extern "C"
|
||||||
{
|
{
|
||||||
bool POCO_LIBRARY_API pocoBuildManifest(Poco::ManifestBase* pManifest);
|
bool POCO_LIBRARY_API pocoBuildManifest(Poco::ManifestBase* pManifest);
|
||||||
void POCO_LIBRARY_API pocoInitializeLibrary();
|
void POCO_LIBRARY_API pocoInitializeLibrary();
|
||||||
void POCO_LIBRARY_API pocoUninitializeLibrary();
|
void POCO_LIBRARY_API pocoUninitializeLibrary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// additional support for named manifests
|
// additional support for named manifests
|
||||||
//
|
//
|
||||||
#define POCO_DECLARE_NAMED_MANIFEST(name) \
|
#define POCO_DECLARE_NAMED_MANIFEST(name) \
|
||||||
extern "C" \
|
extern "C" \
|
||||||
{ \
|
{ \
|
||||||
bool POCO_LIBRARY_API POCO_JOIN(pocoBuildManifest, name)(Poco::ManifestBase* pManifest); \
|
bool POCO_LIBRARY_API POCO_JOIN(pocoBuildManifest, name)(Poco::ManifestBase* pManifest); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Macros to automatically implement pocoBuildManifest
|
// Macros to automatically implement pocoBuildManifest
|
||||||
//
|
//
|
||||||
// usage:
|
// usage:
|
||||||
//
|
//
|
||||||
// POCO_BEGIN_MANIFEST(MyBaseClass)
|
// POCO_BEGIN_MANIFEST(MyBaseClass)
|
||||||
// POCO_EXPORT_CLASS(MyFirstClass)
|
// POCO_EXPORT_CLASS(MyFirstClass)
|
||||||
// POCO_EXPORT_CLASS(MySecondClass)
|
// POCO_EXPORT_CLASS(MySecondClass)
|
||||||
// ...
|
// ...
|
||||||
// POCO_END_MANIFEST
|
// POCO_END_MANIFEST
|
||||||
//
|
//
|
||||||
#define POCO_BEGIN_MANIFEST_IMPL(fnName, base) \
|
#define POCO_BEGIN_MANIFEST_IMPL(fnName, base) \
|
||||||
bool fnName(Poco::ManifestBase* pManifest_) \
|
bool fnName(Poco::ManifestBase* pManifest_) \
|
||||||
{ \
|
{ \
|
||||||
typedef base _Base; \
|
typedef base _Base; \
|
||||||
typedef Poco::Manifest<_Base> _Manifest; \
|
typedef Poco::Manifest<_Base> _Manifest; \
|
||||||
std::string requiredType(typeid(_Manifest).name()); \
|
std::string requiredType(typeid(_Manifest).name()); \
|
||||||
std::string actualType(pManifest_->className()); \
|
std::string actualType(pManifest_->className()); \
|
||||||
if (requiredType == actualType) \
|
if (requiredType == actualType) \
|
||||||
{ \
|
{ \
|
||||||
Poco::Manifest<_Base>* pManifest = static_cast<_Manifest*>(pManifest_);
|
Poco::Manifest<_Base>* pManifest = static_cast<_Manifest*>(pManifest_);
|
||||||
|
|
||||||
|
|
||||||
#define POCO_BEGIN_MANIFEST(base) \
|
#define POCO_BEGIN_MANIFEST(base) \
|
||||||
POCO_BEGIN_MANIFEST_IMPL(pocoBuildManifest, base)
|
POCO_BEGIN_MANIFEST_IMPL(pocoBuildManifest, base)
|
||||||
|
|
||||||
|
|
||||||
#define POCO_BEGIN_NAMED_MANIFEST(name, base) \
|
#define POCO_BEGIN_NAMED_MANIFEST(name, base) \
|
||||||
POCO_DECLARE_NAMED_MANIFEST(name) \
|
POCO_DECLARE_NAMED_MANIFEST(name) \
|
||||||
POCO_BEGIN_MANIFEST_IMPL(POCO_JOIN(pocoBuildManifest, name), base)
|
POCO_BEGIN_MANIFEST_IMPL(POCO_JOIN(pocoBuildManifest, name), base)
|
||||||
|
|
||||||
|
|
||||||
#define POCO_END_MANIFEST \
|
#define POCO_END_MANIFEST \
|
||||||
return true; \
|
return true; \
|
||||||
} \
|
} \
|
||||||
else return false; \
|
else return false; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define POCO_EXPORT_CLASS(cls) \
|
#define POCO_EXPORT_CLASS(cls) \
|
||||||
pManifest->insert(new Poco::MetaObject<cls, _Base>(#cls));
|
pManifest->insert(new Poco::MetaObject<cls, _Base>(#cls));
|
||||||
|
|
||||||
|
|
||||||
#define POCO_EXPORT_SINGLETON(cls) \
|
#define POCO_EXPORT_SINGLETON(cls) \
|
||||||
pManifest->insert(new Poco::MetaSingleton<cls, _Base>(#cls));
|
pManifest->insert(new Poco::MetaSingleton<cls, _Base>(#cls));
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_ClassLibrary_INCLUDED
|
#endif // Foundation_ClassLibrary_INCLUDED
|
||||||
|
|||||||
@@ -1,385 +1,385 @@
|
|||||||
//
|
//
|
||||||
// ClassLoader.h
|
// ClassLoader.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ClassLoader.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ClassLoader.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: SharedLibrary
|
// Package: SharedLibrary
|
||||||
// Module: ClassLoader
|
// Module: ClassLoader
|
||||||
//
|
//
|
||||||
// Definition of the ClassLoader class.
|
// Definition of the ClassLoader 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_ClassLoader_INCLUDED
|
#ifndef Foundation_ClassLoader_INCLUDED
|
||||||
#define Foundation_ClassLoader_INCLUDED
|
#define Foundation_ClassLoader_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/MetaObject.h"
|
#include "Poco/MetaObject.h"
|
||||||
#include "Poco/Manifest.h"
|
#include "Poco/Manifest.h"
|
||||||
#include "Poco/SharedLibrary.h"
|
#include "Poco/SharedLibrary.h"
|
||||||
#include "Poco/Mutex.h"
|
#include "Poco/Mutex.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class Base>
|
template <class Base>
|
||||||
class ClassLoader
|
class ClassLoader
|
||||||
/// The ClassLoader loads C++ classes from shared libraries
|
/// The ClassLoader loads C++ classes from shared libraries
|
||||||
/// at runtime. It must be instantiated with a root class
|
/// at runtime. It must be instantiated with a root class
|
||||||
/// of the loadable classes.
|
/// of the loadable classes.
|
||||||
/// For a class to be loadable from a library, the library
|
/// For a class to be loadable from a library, the library
|
||||||
/// must provide a Manifest of all the classes it contains.
|
/// must provide a Manifest of all the classes it contains.
|
||||||
/// The Manifest for a shared library can be easily built
|
/// The Manifest for a shared library can be easily built
|
||||||
/// with the help of the macros in the header file
|
/// with the help of the macros in the header file
|
||||||
/// "Foundation/ClassLibrary.h".
|
/// "Foundation/ClassLibrary.h".
|
||||||
///
|
///
|
||||||
/// Starting with POCO release 1.3, a class library can
|
/// Starting with POCO release 1.3, a class library can
|
||||||
/// export multiple manifests. In addition to the default
|
/// export multiple manifests. In addition to the default
|
||||||
/// (unnamed) manifest, multiple named manifests can
|
/// (unnamed) manifest, multiple named manifests can
|
||||||
/// be exported, each having a different base class.
|
/// be exported, each having a different base class.
|
||||||
///
|
///
|
||||||
/// There is one important restriction: one instance of
|
/// There is one important restriction: one instance of
|
||||||
/// ClassLoader can only load one manifest from a class
|
/// ClassLoader can only load one manifest from a class
|
||||||
/// library.
|
/// library.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef AbstractMetaObject<Base> Meta;
|
typedef AbstractMetaObject<Base> Meta;
|
||||||
typedef Manifest<Base> Manif;
|
typedef Manifest<Base> Manif;
|
||||||
typedef void (*InitializeLibraryFunc)();
|
typedef void (*InitializeLibraryFunc)();
|
||||||
typedef void (*UninitializeLibraryFunc)();
|
typedef void (*UninitializeLibraryFunc)();
|
||||||
typedef bool (*BuildManifestFunc)(ManifestBase*);
|
typedef bool (*BuildManifestFunc)(ManifestBase*);
|
||||||
|
|
||||||
struct LibraryInfo
|
struct LibraryInfo
|
||||||
{
|
{
|
||||||
SharedLibrary* pLibrary;
|
SharedLibrary* pLibrary;
|
||||||
const Manif* pManifest;
|
const Manif* pManifest;
|
||||||
int refCount;
|
int refCount;
|
||||||
};
|
};
|
||||||
typedef std::map<std::string, LibraryInfo> LibraryMap;
|
typedef std::map<std::string, LibraryInfo> LibraryMap;
|
||||||
|
|
||||||
class Iterator
|
class Iterator
|
||||||
/// The ClassLoader's very own iterator class.
|
/// The ClassLoader's very own iterator class.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::pair<std::string, const Manif*> Pair;
|
typedef std::pair<std::string, const Manif*> Pair;
|
||||||
|
|
||||||
Iterator(const typename LibraryMap::const_iterator& it)
|
Iterator(const typename LibraryMap::const_iterator& it)
|
||||||
{
|
{
|
||||||
_it = it;
|
_it = it;
|
||||||
}
|
}
|
||||||
Iterator(const Iterator& it)
|
Iterator(const Iterator& it)
|
||||||
{
|
{
|
||||||
_it = it._it;
|
_it = it._it;
|
||||||
}
|
}
|
||||||
~Iterator()
|
~Iterator()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
Iterator& operator = (const Iterator& it)
|
Iterator& operator = (const Iterator& it)
|
||||||
{
|
{
|
||||||
_it = it._it;
|
_it = it._it;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
inline bool operator == (const Iterator& it) const
|
inline bool operator == (const Iterator& it) const
|
||||||
{
|
{
|
||||||
return _it == it._it;
|
return _it == it._it;
|
||||||
}
|
}
|
||||||
inline bool operator != (const Iterator& it) const
|
inline bool operator != (const Iterator& it) const
|
||||||
{
|
{
|
||||||
return _it != it._it;
|
return _it != it._it;
|
||||||
}
|
}
|
||||||
Iterator& operator ++ () // prefix
|
Iterator& operator ++ () // prefix
|
||||||
{
|
{
|
||||||
++_it;
|
++_it;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
Iterator operator ++ (int) // postfix
|
Iterator operator ++ (int) // postfix
|
||||||
{
|
{
|
||||||
Iterator result(_it);
|
Iterator result(_it);
|
||||||
++_it;
|
++_it;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
inline const Pair* operator * () const
|
inline const Pair* operator * () const
|
||||||
{
|
{
|
||||||
_pair.first = _it->first;
|
_pair.first = _it->first;
|
||||||
_pair.second = _it->second.pManifest;
|
_pair.second = _it->second.pManifest;
|
||||||
return &_pair;
|
return &_pair;
|
||||||
}
|
}
|
||||||
inline const Pair* operator -> () const
|
inline const Pair* operator -> () const
|
||||||
{
|
{
|
||||||
_pair.first = _it->first;
|
_pair.first = _it->first;
|
||||||
_pair.second = _it->second.pManifest;
|
_pair.second = _it->second.pManifest;
|
||||||
return &_pair;
|
return &_pair;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typename LibraryMap::const_iterator _it;
|
typename LibraryMap::const_iterator _it;
|
||||||
mutable Pair _pair;
|
mutable Pair _pair;
|
||||||
};
|
};
|
||||||
|
|
||||||
ClassLoader()
|
ClassLoader()
|
||||||
/// Creates the ClassLoader.
|
/// Creates the ClassLoader.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~ClassLoader()
|
virtual ~ClassLoader()
|
||||||
/// Destroys the ClassLoader.
|
/// Destroys the ClassLoader.
|
||||||
{
|
{
|
||||||
for (typename LibraryMap::const_iterator it = _map.begin(); it != _map.end(); ++it)
|
for (typename LibraryMap::const_iterator it = _map.begin(); it != _map.end(); ++it)
|
||||||
{
|
{
|
||||||
delete it->second.pLibrary;
|
delete it->second.pLibrary;
|
||||||
delete it->second.pManifest;
|
delete it->second.pManifest;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadLibrary(const std::string& path, const std::string& manifest)
|
void loadLibrary(const std::string& path, const std::string& manifest)
|
||||||
/// Loads a library from the given path, using the given manifest.
|
/// Loads a library from the given path, using the given manifest.
|
||||||
/// Does nothing if the library is already loaded.
|
/// Does nothing if the library is already loaded.
|
||||||
/// Throws a LibraryLoadException if the library
|
/// Throws a LibraryLoadException if the library
|
||||||
/// cannot be loaded or does not have a Manifest.
|
/// cannot be loaded or does not have a Manifest.
|
||||||
/// If the library exports a function named "pocoInitializeLibrary",
|
/// If the library exports a function named "pocoInitializeLibrary",
|
||||||
/// this function is executed.
|
/// this function is executed.
|
||||||
/// If called multiple times for the same library,
|
/// If called multiple times for the same library,
|
||||||
/// the number of calls to unloadLibrary() must be the same
|
/// the number of calls to unloadLibrary() must be the same
|
||||||
/// for the library to become unloaded.
|
/// for the library to become unloaded.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
typename LibraryMap::iterator it = _map.find(path);
|
typename LibraryMap::iterator it = _map.find(path);
|
||||||
if (it == _map.end())
|
if (it == _map.end())
|
||||||
{
|
{
|
||||||
LibraryInfo li;
|
LibraryInfo li;
|
||||||
li.pLibrary = new SharedLibrary(path);
|
li.pLibrary = new SharedLibrary(path);
|
||||||
li.pManifest = new Manif();
|
li.pManifest = new Manif();
|
||||||
li.refCount = 1;
|
li.refCount = 1;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
std::string pocoBuildManifestSymbol("pocoBuildManifest");
|
std::string pocoBuildManifestSymbol("pocoBuildManifest");
|
||||||
pocoBuildManifestSymbol.append(manifest);
|
pocoBuildManifestSymbol.append(manifest);
|
||||||
if (li.pLibrary->hasSymbol("pocoInitializeLibrary"))
|
if (li.pLibrary->hasSymbol("pocoInitializeLibrary"))
|
||||||
{
|
{
|
||||||
InitializeLibraryFunc initializeLibrary = (InitializeLibraryFunc) li.pLibrary->getSymbol("pocoInitializeLibrary");
|
InitializeLibraryFunc initializeLibrary = (InitializeLibraryFunc) li.pLibrary->getSymbol("pocoInitializeLibrary");
|
||||||
initializeLibrary();
|
initializeLibrary();
|
||||||
}
|
}
|
||||||
if (li.pLibrary->hasSymbol(pocoBuildManifestSymbol))
|
if (li.pLibrary->hasSymbol(pocoBuildManifestSymbol))
|
||||||
{
|
{
|
||||||
BuildManifestFunc buildManifest = (BuildManifestFunc) li.pLibrary->getSymbol(pocoBuildManifestSymbol);
|
BuildManifestFunc buildManifest = (BuildManifestFunc) li.pLibrary->getSymbol(pocoBuildManifestSymbol);
|
||||||
if (buildManifest(const_cast<Manif*>(li.pManifest)))
|
if (buildManifest(const_cast<Manif*>(li.pManifest)))
|
||||||
_map[path] = li;
|
_map[path] = li;
|
||||||
else
|
else
|
||||||
throw LibraryLoadException(std::string("Manifest class mismatch in ") + path, manifest);
|
throw LibraryLoadException(std::string("Manifest class mismatch in ") + path, manifest);
|
||||||
}
|
}
|
||||||
else throw LibraryLoadException(std::string("No manifest in ") + path, manifest);
|
else throw LibraryLoadException(std::string("No manifest in ") + path, manifest);
|
||||||
}
|
}
|
||||||
catch (...)
|
catch (...)
|
||||||
{
|
{
|
||||||
delete li.pLibrary;
|
delete li.pLibrary;
|
||||||
delete li.pManifest;
|
delete li.pManifest;
|
||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
++it->second.refCount;
|
++it->second.refCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadLibrary(const std::string& path)
|
void loadLibrary(const std::string& path)
|
||||||
/// Loads a library from the given path. Does nothing
|
/// Loads a library from the given path. Does nothing
|
||||||
/// if the library is already loaded.
|
/// if the library is already loaded.
|
||||||
/// Throws a LibraryLoadException if the library
|
/// Throws a LibraryLoadException if the library
|
||||||
/// cannot be loaded or does not have a Manifest.
|
/// cannot be loaded or does not have a Manifest.
|
||||||
/// If the library exports a function named "pocoInitializeLibrary",
|
/// If the library exports a function named "pocoInitializeLibrary",
|
||||||
/// this function is executed.
|
/// this function is executed.
|
||||||
/// If called multiple times for the same library,
|
/// If called multiple times for the same library,
|
||||||
/// the number of calls to unloadLibrary() must be the same
|
/// the number of calls to unloadLibrary() must be the same
|
||||||
/// for the library to become unloaded.
|
/// for the library to become unloaded.
|
||||||
///
|
///
|
||||||
/// Equivalent to loadLibrary(path, "").
|
/// Equivalent to loadLibrary(path, "").
|
||||||
{
|
{
|
||||||
loadLibrary(path, "");
|
loadLibrary(path, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
void unloadLibrary(const std::string& path)
|
void unloadLibrary(const std::string& path)
|
||||||
/// Unloads the given library.
|
/// Unloads the given library.
|
||||||
/// Be extremely cautious when unloading shared libraries.
|
/// Be extremely cautious when unloading shared libraries.
|
||||||
/// If objects from the library are still referenced somewhere,
|
/// If objects from the library are still referenced somewhere,
|
||||||
/// a total crash is very likely.
|
/// a total crash is very likely.
|
||||||
/// If the library exports a function named "pocoUninitializeLibrary",
|
/// If the library exports a function named "pocoUninitializeLibrary",
|
||||||
/// this function is executed before it is unloaded.
|
/// this function is executed before it is unloaded.
|
||||||
/// If loadLibrary() has been called multiple times for the same
|
/// If loadLibrary() has been called multiple times for the same
|
||||||
/// library, the number of calls to unloadLibrary() must be the same
|
/// library, the number of calls to unloadLibrary() must be the same
|
||||||
/// for the library to become unloaded.
|
/// for the library to become unloaded.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
typename LibraryMap::iterator it = _map.find(path);
|
typename LibraryMap::iterator it = _map.find(path);
|
||||||
if (it != _map.end())
|
if (it != _map.end())
|
||||||
{
|
{
|
||||||
if (--it->second.refCount == 0)
|
if (--it->second.refCount == 0)
|
||||||
{
|
{
|
||||||
if (it->second.pLibrary->hasSymbol("pocoUninitializeLibrary"))
|
if (it->second.pLibrary->hasSymbol("pocoUninitializeLibrary"))
|
||||||
{
|
{
|
||||||
UninitializeLibraryFunc uninitializeLibrary = (UninitializeLibraryFunc) it->second.pLibrary->getSymbol("pocoUninitializeLibrary");
|
UninitializeLibraryFunc uninitializeLibrary = (UninitializeLibraryFunc) it->second.pLibrary->getSymbol("pocoUninitializeLibrary");
|
||||||
uninitializeLibrary();
|
uninitializeLibrary();
|
||||||
}
|
}
|
||||||
delete it->second.pManifest;
|
delete it->second.pManifest;
|
||||||
it->second.pLibrary->unload();
|
it->second.pLibrary->unload();
|
||||||
delete it->second.pLibrary;
|
delete it->second.pLibrary;
|
||||||
_map.erase(it);
|
_map.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else throw NotFoundException(path);
|
else throw NotFoundException(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Meta* findClass(const std::string& className) const
|
const Meta* findClass(const std::string& className) const
|
||||||
/// Returns a pointer to the MetaObject for the given
|
/// Returns a pointer to the MetaObject for the given
|
||||||
/// class, or a null pointer if the class is not known.
|
/// class, or a null pointer if the class is not known.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
for (typename LibraryMap::const_iterator it = _map.begin(); it != _map.end(); ++it)
|
for (typename LibraryMap::const_iterator it = _map.begin(); it != _map.end(); ++it)
|
||||||
{
|
{
|
||||||
const Manif* pManif = it->second.pManifest;
|
const Manif* pManif = it->second.pManifest;
|
||||||
typename Manif::Iterator itm = pManif->find(className);
|
typename Manif::Iterator itm = pManif->find(className);
|
||||||
if (itm != pManif->end())
|
if (itm != pManif->end())
|
||||||
return *itm;
|
return *itm;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Meta& classFor(const std::string& className) const
|
const Meta& classFor(const std::string& className) const
|
||||||
/// Returns a reference to the MetaObject for the given
|
/// Returns a reference to the MetaObject for the given
|
||||||
/// class. Throws a NotFoundException if the class
|
/// class. Throws a NotFoundException if the class
|
||||||
/// is not known.
|
/// is not known.
|
||||||
{
|
{
|
||||||
const Meta* pMeta = findClass(className);
|
const Meta* pMeta = findClass(className);
|
||||||
if (pMeta)
|
if (pMeta)
|
||||||
return *pMeta;
|
return *pMeta;
|
||||||
else
|
else
|
||||||
throw NotFoundException(className);
|
throw NotFoundException(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
Base* create(const std::string& className) const
|
Base* create(const std::string& className) const
|
||||||
/// Creates an instance of the given class.
|
/// Creates an instance of the given class.
|
||||||
/// Throws a NotFoundException if the class
|
/// Throws a NotFoundException if the class
|
||||||
/// is not known.
|
/// is not known.
|
||||||
{
|
{
|
||||||
return classFor(className).create();
|
return classFor(className).create();
|
||||||
}
|
}
|
||||||
|
|
||||||
Base& instance(const std::string& className) const
|
Base& instance(const std::string& className) const
|
||||||
/// Returns a reference to the sole instance of
|
/// Returns a reference to the sole instance of
|
||||||
/// the given class. The class must be a singleton,
|
/// the given class. The class must be a singleton,
|
||||||
/// otherwise an InvalidAccessException will be thrown.
|
/// otherwise an InvalidAccessException will be thrown.
|
||||||
/// Throws a NotFoundException if the class
|
/// Throws a NotFoundException if the class
|
||||||
/// is not known.
|
/// is not known.
|
||||||
{
|
{
|
||||||
return classFor(className).instance();
|
return classFor(className).instance();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canCreate(const std::string& className) const
|
bool canCreate(const std::string& className) const
|
||||||
/// Returns true if create() can create new instances
|
/// Returns true if create() can create new instances
|
||||||
/// of the class.
|
/// of the class.
|
||||||
{
|
{
|
||||||
return classFor(className).canCreate();
|
return classFor(className).canCreate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy(const std::string& className, Base* pObject) const
|
void destroy(const std::string& className, Base* pObject) const
|
||||||
/// Destroys the object pObject points to.
|
/// Destroys the object pObject points to.
|
||||||
/// Does nothing if object is not found.
|
/// Does nothing if object is not found.
|
||||||
{
|
{
|
||||||
classFor(className).destroy(pObject);
|
classFor(className).destroy(pObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAutoDelete(const std::string& className, Base* pObject) const
|
bool isAutoDelete(const std::string& className, Base* pObject) const
|
||||||
/// Returns true if the object is automatically
|
/// Returns true if the object is automatically
|
||||||
/// deleted by its meta object.
|
/// deleted by its meta object.
|
||||||
{
|
{
|
||||||
return classFor(className).isAutoDelete(pObject);
|
return classFor(className).isAutoDelete(pObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
const Manif* findManifest(const std::string& path) const
|
const Manif* findManifest(const std::string& path) const
|
||||||
/// Returns a pointer to the Manifest for the given
|
/// Returns a pointer to the Manifest for the given
|
||||||
/// library, or a null pointer if the library has not been loaded.
|
/// library, or a null pointer if the library has not been loaded.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
typename LibraryMap::const_iterator it = _map.find(path);
|
typename LibraryMap::const_iterator it = _map.find(path);
|
||||||
if (it != _map.end())
|
if (it != _map.end())
|
||||||
return it->second.pManifest;
|
return it->second.pManifest;
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Manif& manifestFor(const std::string& path) const
|
const Manif& manifestFor(const std::string& path) const
|
||||||
/// Returns a reference to the Manifest for the given library
|
/// Returns a reference to the Manifest for the given library
|
||||||
/// Throws a NotFoundException if the library has not been loaded.
|
/// Throws a NotFoundException if the library has not been loaded.
|
||||||
{
|
{
|
||||||
const Manif* pManif = findManifest(path);
|
const Manif* pManif = findManifest(path);
|
||||||
if (pManif)
|
if (pManif)
|
||||||
return *pManif;
|
return *pManif;
|
||||||
else
|
else
|
||||||
throw NotFoundException(path);
|
throw NotFoundException(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isLibraryLoaded(const std::string& path) const
|
bool isLibraryLoaded(const std::string& path) const
|
||||||
/// Returns true if the library with the given name
|
/// Returns true if the library with the given name
|
||||||
/// has already been loaded.
|
/// has already been loaded.
|
||||||
{
|
{
|
||||||
return findManifest(path) != 0;
|
return findManifest(path) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator begin() const
|
Iterator begin() const
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
return Iterator(_map.begin());
|
return Iterator(_map.begin());
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator end() const
|
Iterator end() const
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
return Iterator(_map.end());
|
return Iterator(_map.end());
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LibraryMap _map;
|
LibraryMap _map;
|
||||||
mutable FastMutex _mutex;
|
mutable FastMutex _mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_ClassLoader_INCLUDED
|
#endif // Foundation_ClassLoader_INCLUDED
|
||||||
|
|||||||
@@ -1,63 +1,63 @@
|
|||||||
//
|
//
|
||||||
// CompareFunctions.h
|
// CompareFunctions.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/CompareFunctions.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/CompareFunctions.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
// Module: CompareFunctions
|
// Module: CompareFunctions
|
||||||
//
|
//
|
||||||
// Compare operators for the NotificationStrategies.
|
// Compare operators for the NotificationStrategies.
|
||||||
//
|
//
|
||||||
// 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 Foundation_CompareFunctions_INCLUDED
|
#ifndef Foundation_CompareFunctions_INCLUDED
|
||||||
#define Foundation_CompareFunctions_INCLUDED
|
#define Foundation_CompareFunctions_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct p_less: std::binary_function<T, T, bool>
|
struct p_less: std::binary_function<T, T, bool>
|
||||||
{
|
{
|
||||||
bool operator () (const T* const & x, const T* const & y) const
|
bool operator () (const T* const & x, const T* const & y) const
|
||||||
{
|
{
|
||||||
return *x < *y;
|
return *x < *y;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,159 +1,159 @@
|
|||||||
//
|
//
|
||||||
// Condition.h
|
// Condition.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Condition.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Condition.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
// Module: Condition
|
// Module: Condition
|
||||||
//
|
//
|
||||||
// Definition of the Condition class template.
|
// Definition of the Condition class template.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2007, 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_Condition_INCLUDED
|
#ifndef Foundation_Condition_INCLUDED
|
||||||
#define Foundation_Condition_INCLUDED
|
#define Foundation_Condition_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Mutex.h"
|
#include "Poco/Mutex.h"
|
||||||
#include "Poco/ScopedUnlock.h"
|
#include "Poco/ScopedUnlock.h"
|
||||||
#include "Poco/Event.h"
|
#include "Poco/Event.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Condition
|
class Foundation_API Condition
|
||||||
/// A Condition is a synchronization object used to block a thread
|
/// A Condition is a synchronization object used to block a thread
|
||||||
/// until a particular condition is met.
|
/// until a particular condition is met.
|
||||||
/// A Condition object is always used in conjunction with
|
/// A Condition object is always used in conjunction with
|
||||||
/// a Mutex (or FastMutex) object.
|
/// a Mutex (or FastMutex) object.
|
||||||
///
|
///
|
||||||
/// Condition objects are similar to POSIX condition variables, which the
|
/// Condition objects are similar to POSIX condition variables, which the
|
||||||
/// difference that Condition is not subject to spurious wakeups.
|
/// difference that Condition is not subject to spurious wakeups.
|
||||||
///
|
///
|
||||||
/// Threads waiting on a Condition are resumed in FIFO order.
|
/// Threads waiting on a Condition are resumed in FIFO order.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Condition();
|
Condition();
|
||||||
/// Creates the Condition.
|
/// Creates the Condition.
|
||||||
|
|
||||||
~Condition();
|
~Condition();
|
||||||
/// Destroys the Condition.
|
/// Destroys the Condition.
|
||||||
|
|
||||||
template <class Mtx>
|
template <class Mtx>
|
||||||
void wait(Mtx& mutex)
|
void wait(Mtx& mutex)
|
||||||
/// Unlocks the mutex (which must be locked upon calling
|
/// Unlocks the mutex (which must be locked upon calling
|
||||||
/// wait()) and waits until the Condition is signalled.
|
/// wait()) and waits until the Condition is signalled.
|
||||||
///
|
///
|
||||||
/// The given mutex will be locked again upon
|
/// The given mutex will be locked again upon
|
||||||
/// leaving the function, even in case of an exception.
|
/// leaving the function, even in case of an exception.
|
||||||
{
|
{
|
||||||
ScopedUnlock<Mtx> unlock(mutex, false);
|
ScopedUnlock<Mtx> unlock(mutex, false);
|
||||||
Event event;
|
Event event;
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
enqueue(event);
|
enqueue(event);
|
||||||
}
|
}
|
||||||
event.wait();
|
event.wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Mtx>
|
template <class Mtx>
|
||||||
void wait(Mtx& mutex, long milliseconds)
|
void wait(Mtx& mutex, long milliseconds)
|
||||||
/// Unlocks the mutex (which must be locked upon calling
|
/// Unlocks the mutex (which must be locked upon calling
|
||||||
/// wait()) and waits for the given time until the Condition is signalled.
|
/// wait()) and waits for the given time until the Condition is signalled.
|
||||||
///
|
///
|
||||||
/// The given mutex will be locked again upon successfully leaving the
|
/// The given mutex will be locked again upon successfully leaving the
|
||||||
/// function, even in case of an exception.
|
/// function, even in case of an exception.
|
||||||
///
|
///
|
||||||
/// Throws a TimeoutException if the Condition is not signalled
|
/// Throws a TimeoutException if the Condition is not signalled
|
||||||
/// within the given time interval.
|
/// within the given time interval.
|
||||||
{
|
{
|
||||||
if (!tryWait(mutex, milliseconds))
|
if (!tryWait(mutex, milliseconds))
|
||||||
throw TimeoutException();
|
throw TimeoutException();
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Mtx>
|
template <class Mtx>
|
||||||
bool tryWait(Mtx& mutex, long milliseconds)
|
bool tryWait(Mtx& mutex, long milliseconds)
|
||||||
/// Unlocks the mutex (which must be locked upon calling
|
/// Unlocks the mutex (which must be locked upon calling
|
||||||
/// tryWait()) and waits for the given time until the Condition is signalled.
|
/// tryWait()) and waits for the given time until the Condition is signalled.
|
||||||
///
|
///
|
||||||
/// The given mutex will be locked again upon leaving the
|
/// The given mutex will be locked again upon leaving the
|
||||||
/// function, even in case of an exception.
|
/// function, even in case of an exception.
|
||||||
///
|
///
|
||||||
/// Returns true if the Condition has been signalled
|
/// Returns true if the Condition has been signalled
|
||||||
/// within the given time interval, otherwise false.
|
/// within the given time interval, otherwise false.
|
||||||
{
|
{
|
||||||
ScopedUnlock<Mtx> unlock(mutex, false);
|
ScopedUnlock<Mtx> unlock(mutex, false);
|
||||||
Event event;
|
Event event;
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
mutex.unlock();
|
mutex.unlock();
|
||||||
enqueue(event);
|
enqueue(event);
|
||||||
}
|
}
|
||||||
if (!event.tryWait(milliseconds))
|
if (!event.tryWait(milliseconds))
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
dequeue(event);
|
dequeue(event);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void signal();
|
void signal();
|
||||||
/// Signals the Condition and allows one waiting thread
|
/// Signals the Condition and allows one waiting thread
|
||||||
/// to continue execution.
|
/// to continue execution.
|
||||||
|
|
||||||
void broadcast();
|
void broadcast();
|
||||||
/// Signals the Condition and allows all waiting
|
/// Signals the Condition and allows all waiting
|
||||||
/// threads to continue their execution.
|
/// threads to continue their execution.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void enqueue(Event& event);
|
void enqueue(Event& event);
|
||||||
void dequeue();
|
void dequeue();
|
||||||
void dequeue(Event& event);
|
void dequeue(Event& event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Condition(const Condition&);
|
Condition(const Condition&);
|
||||||
Condition& operator = (const Condition&);
|
Condition& operator = (const Condition&);
|
||||||
|
|
||||||
typedef std::deque<Event*> WaitQueue;
|
typedef std::deque<Event*> WaitQueue;
|
||||||
|
|
||||||
FastMutex _mutex;
|
FastMutex _mutex;
|
||||||
WaitQueue _waitQueue;
|
WaitQueue _waitQueue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Condition_INCLUDED
|
#endif // Foundation_Condition_INCLUDED
|
||||||
|
|||||||
@@ -1,92 +1,92 @@
|
|||||||
//
|
//
|
||||||
// Configurable.h
|
// Configurable.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Configurable.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Configurable.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Logging
|
// Package: Logging
|
||||||
// Module: Configurable
|
// Module: Configurable
|
||||||
//
|
//
|
||||||
// Definition of the Configurable class.
|
// Definition of the Configurable 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_Configurable_INCLUDED
|
#ifndef Foundation_Configurable_INCLUDED
|
||||||
#define Foundation_Configurable_INCLUDED
|
#define Foundation_Configurable_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Configurable
|
class Foundation_API Configurable
|
||||||
/// A simple interface that defines
|
/// A simple interface that defines
|
||||||
/// getProperty() and setProperty() methods.
|
/// getProperty() and setProperty() methods.
|
||||||
///
|
///
|
||||||
/// This interface is implemented by Formatter and
|
/// This interface is implemented by Formatter and
|
||||||
/// Channel and is used to configure arbitrary
|
/// Channel and is used to configure arbitrary
|
||||||
/// channels and formatters.
|
/// channels and formatters.
|
||||||
///
|
///
|
||||||
/// A property is basically a name-value pair. For
|
/// A property is basically a name-value pair. For
|
||||||
/// simplicity, both names and values are strings.
|
/// simplicity, both names and values are strings.
|
||||||
/// Every property controls a certain aspect of a
|
/// Every property controls a certain aspect of a
|
||||||
/// Formatter or Channel. For example, the PatternFormatter's
|
/// Formatter or Channel. For example, the PatternFormatter's
|
||||||
/// formatting pattern is set via a property.
|
/// formatting pattern is set via a property.
|
||||||
///
|
///
|
||||||
/// NOTE: The following property names are use internally
|
/// NOTE: The following property names are use internally
|
||||||
/// by the logging framework and must not be used by
|
/// by the logging framework and must not be used by
|
||||||
/// channels or formatters:
|
/// channels or formatters:
|
||||||
/// - class
|
/// - class
|
||||||
/// - pattern (Channel)
|
/// - pattern (Channel)
|
||||||
/// - formatter (Channel)
|
/// - formatter (Channel)
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Configurable();
|
Configurable();
|
||||||
/// Creates the Configurable.
|
/// Creates the Configurable.
|
||||||
|
|
||||||
virtual ~Configurable();
|
virtual ~Configurable();
|
||||||
/// Destroys the Configurable.
|
/// Destroys the Configurable.
|
||||||
|
|
||||||
virtual void setProperty(const std::string& name, const std::string& value) = 0;
|
virtual void setProperty(const std::string& name, const std::string& value) = 0;
|
||||||
/// Sets the property with the given name to the given value.
|
/// Sets the property with the given name to the given value.
|
||||||
/// If a property with the given name is not supported, a
|
/// If a property with the given name is not supported, a
|
||||||
/// PropertyNotSupportedException is thrown.
|
/// PropertyNotSupportedException is thrown.
|
||||||
|
|
||||||
virtual std::string getProperty(const std::string& name) const = 0;
|
virtual std::string getProperty(const std::string& name) const = 0;
|
||||||
/// Returns the value of the property with the given name.
|
/// Returns the value of the property with the given name.
|
||||||
/// If a property with the given name is not supported, a
|
/// If a property with the given name is not supported, a
|
||||||
/// PropertyNotSupportedException is thrown.
|
/// PropertyNotSupportedException is thrown.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Configurable_INCLUDED
|
#endif // Foundation_Configurable_INCLUDED
|
||||||
|
|||||||
@@ -1,89 +1,89 @@
|
|||||||
//
|
//
|
||||||
// ConsoleChannel.h
|
// ConsoleChannel.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ConsoleChannel.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ConsoleChannel.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Logging
|
// Package: Logging
|
||||||
// Module: ConsoleChannel
|
// Module: ConsoleChannel
|
||||||
//
|
//
|
||||||
// Definition of the ConsoleChannel class.
|
// Definition of the ConsoleChannel 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_ConsoleChannel_INCLUDED
|
#ifndef Foundation_ConsoleChannel_INCLUDED
|
||||||
#define Foundation_ConsoleChannel_INCLUDED
|
#define Foundation_ConsoleChannel_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Channel.h"
|
#include "Poco/Channel.h"
|
||||||
#include "Poco/Mutex.h"
|
#include "Poco/Mutex.h"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API ConsoleChannel: public Channel
|
class Foundation_API ConsoleChannel: public Channel
|
||||||
/// A channel that writes to an ostream.
|
/// A channel that writes to an ostream.
|
||||||
///
|
///
|
||||||
/// Only the message's text is written, followed
|
/// Only the message's text is written, followed
|
||||||
/// by a newline.
|
/// by a newline.
|
||||||
///
|
///
|
||||||
/// Chain this channel to a FormattingChannel with an
|
/// Chain this channel to a FormattingChannel with an
|
||||||
/// appropriate Formatter to control what is contained
|
/// appropriate Formatter to control what is contained
|
||||||
/// in the text.
|
/// in the text.
|
||||||
///
|
///
|
||||||
/// Similar to StreamChannel, except that a static
|
/// Similar to StreamChannel, except that a static
|
||||||
/// mutex is used to protect against multiple
|
/// mutex is used to protect against multiple
|
||||||
/// console channels concurrently writing to the
|
/// console channels concurrently writing to the
|
||||||
/// same stream.
|
/// same stream.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ConsoleChannel();
|
ConsoleChannel();
|
||||||
/// Creates the channel and attached std::clog.
|
/// Creates the channel and attached std::clog.
|
||||||
|
|
||||||
ConsoleChannel(std::ostream& str);
|
ConsoleChannel(std::ostream& str);
|
||||||
/// Creates the channel.
|
/// Creates the channel.
|
||||||
|
|
||||||
void log(const Message& msg);
|
void log(const Message& msg);
|
||||||
/// Logs the given message to the channel's stream.
|
/// Logs the given message to the channel's stream.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~ConsoleChannel();
|
~ConsoleChannel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::ostream& _str;
|
std::ostream& _str;
|
||||||
static FastMutex _mutex;
|
static FastMutex _mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_ConsoleChannel_INCLUDED
|
#endif // Foundation_ConsoleChannel_INCLUDED
|
||||||
|
|||||||
@@ -1,241 +1,241 @@
|
|||||||
//
|
//
|
||||||
// CountingStream.h
|
// CountingStream.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/CountingStream.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/CountingStream.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: CountingStream
|
// Module: CountingStream
|
||||||
//
|
//
|
||||||
// Definition of the CountingStreamBuf, CountingInputStream and CountingOutputStream classes.
|
// Definition of the CountingStreamBuf, CountingInputStream and CountingOutputStream classes.
|
||||||
//
|
//
|
||||||
// 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_CountingStream_INCLUDED
|
#ifndef Foundation_CountingStream_INCLUDED
|
||||||
#define Foundation_CountingStream_INCLUDED
|
#define Foundation_CountingStream_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/UnbufferedStreamBuf.h"
|
#include "Poco/UnbufferedStreamBuf.h"
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API CountingStreamBuf: public UnbufferedStreamBuf
|
class Foundation_API CountingStreamBuf: public UnbufferedStreamBuf
|
||||||
/// This stream buffer counts all characters and lines
|
/// This stream buffer counts all characters and lines
|
||||||
/// going through it.
|
/// going through it.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CountingStreamBuf();
|
CountingStreamBuf();
|
||||||
/// Creates an unconnected CountingStreamBuf.
|
/// Creates an unconnected CountingStreamBuf.
|
||||||
|
|
||||||
CountingStreamBuf(std::istream& istr);
|
CountingStreamBuf(std::istream& istr);
|
||||||
/// Creates the CountingStreamBuf and connects it
|
/// Creates the CountingStreamBuf and connects it
|
||||||
/// to the given input stream.
|
/// to the given input stream.
|
||||||
|
|
||||||
CountingStreamBuf(std::ostream& ostr);
|
CountingStreamBuf(std::ostream& ostr);
|
||||||
/// Creates the CountingStreamBuf and connects it
|
/// Creates the CountingStreamBuf and connects it
|
||||||
/// to the given output stream.
|
/// to the given output stream.
|
||||||
|
|
||||||
~CountingStreamBuf();
|
~CountingStreamBuf();
|
||||||
/// Destroys the CountingStream.
|
/// Destroys the CountingStream.
|
||||||
|
|
||||||
int chars() const;
|
int chars() const;
|
||||||
/// Returns the total number of characters.
|
/// Returns the total number of characters.
|
||||||
|
|
||||||
int lines() const;
|
int lines() const;
|
||||||
/// Returns the total number of lines.
|
/// Returns the total number of lines.
|
||||||
|
|
||||||
int pos() const;
|
int pos() const;
|
||||||
/// Returns the number of characters on the current line.
|
/// Returns the number of characters on the current line.
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
/// Resets all counters.
|
/// Resets all counters.
|
||||||
|
|
||||||
void setCurrentLineNumber(int line);
|
void setCurrentLineNumber(int line);
|
||||||
/// Sets the current line number.
|
/// Sets the current line number.
|
||||||
///
|
///
|
||||||
/// This is mainly useful when parsing C/C++
|
/// This is mainly useful when parsing C/C++
|
||||||
/// preprocessed source code containing #line directives.
|
/// preprocessed source code containing #line directives.
|
||||||
|
|
||||||
int getCurrentLineNumber() const;
|
int getCurrentLineNumber() const;
|
||||||
/// Returns the current line number (same as lines()).
|
/// Returns the current line number (same as lines()).
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int readFromDevice();
|
int readFromDevice();
|
||||||
int writeToDevice(char c);
|
int writeToDevice(char c);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::istream* _pIstr;
|
std::istream* _pIstr;
|
||||||
std::ostream* _pOstr;
|
std::ostream* _pOstr;
|
||||||
int _chars;
|
int _chars;
|
||||||
int _lines;
|
int _lines;
|
||||||
int _pos;
|
int _pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API CountingIOS: public virtual std::ios
|
class Foundation_API CountingIOS: public virtual std::ios
|
||||||
/// The base class for CountingInputStream and CountingOutputStream.
|
/// The base class for CountingInputStream and CountingOutputStream.
|
||||||
///
|
///
|
||||||
/// This class is needed to ensure the correct initialization
|
/// This class is needed to ensure the correct initialization
|
||||||
/// order of the stream buffer and base classes.
|
/// order of the stream buffer and base classes.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CountingIOS();
|
CountingIOS();
|
||||||
/// Creates the basic stream and leaves it unconnected.
|
/// Creates the basic stream and leaves it unconnected.
|
||||||
|
|
||||||
CountingIOS(std::istream& istr);
|
CountingIOS(std::istream& istr);
|
||||||
/// Creates the basic stream and connects it
|
/// Creates the basic stream and connects it
|
||||||
/// to the given input stream.
|
/// to the given input stream.
|
||||||
|
|
||||||
CountingIOS(std::ostream& ostr);
|
CountingIOS(std::ostream& ostr);
|
||||||
/// Creates the basic stream and connects it
|
/// Creates the basic stream and connects it
|
||||||
/// to the given output stream.
|
/// to the given output stream.
|
||||||
|
|
||||||
~CountingIOS();
|
~CountingIOS();
|
||||||
/// Destroys the stream.
|
/// Destroys the stream.
|
||||||
|
|
||||||
int chars() const;
|
int chars() const;
|
||||||
/// Returns the total number of characters.
|
/// Returns the total number of characters.
|
||||||
|
|
||||||
int lines() const;
|
int lines() const;
|
||||||
/// Returns the total number of lines.
|
/// Returns the total number of lines.
|
||||||
|
|
||||||
int pos() const;
|
int pos() const;
|
||||||
/// Returns the number of characters on the current line.
|
/// Returns the number of characters on the current line.
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
/// Resets all counters.
|
/// Resets all counters.
|
||||||
|
|
||||||
void setCurrentLineNumber(int line);
|
void setCurrentLineNumber(int line);
|
||||||
/// Sets the current line number.
|
/// Sets the current line number.
|
||||||
///
|
///
|
||||||
/// This is mainly useful when parsing C/C++
|
/// This is mainly useful when parsing C/C++
|
||||||
/// preprocessed source code containing #line directives.
|
/// preprocessed source code containing #line directives.
|
||||||
|
|
||||||
int getCurrentLineNumber() const;
|
int getCurrentLineNumber() const;
|
||||||
/// Returns the current line number (same as lines()).
|
/// Returns the current line number (same as lines()).
|
||||||
|
|
||||||
CountingStreamBuf* rdbuf();
|
CountingStreamBuf* rdbuf();
|
||||||
/// Returns a pointer to the underlying streambuf.
|
/// Returns a pointer to the underlying streambuf.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CountingStreamBuf _buf;
|
CountingStreamBuf _buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API CountingInputStream: public CountingIOS, public std::istream
|
class Foundation_API CountingInputStream: public CountingIOS, public std::istream
|
||||||
/// This stream counts all characters and lines
|
/// This stream counts all characters and lines
|
||||||
/// going through it. This is useful for lexers and parsers
|
/// going through it. This is useful for lexers and parsers
|
||||||
/// that need to determine the current position in the stream.
|
/// that need to determine the current position in the stream.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CountingInputStream(std::istream& istr);
|
CountingInputStream(std::istream& istr);
|
||||||
/// Creates the CountingInputStream and connects it
|
/// Creates the CountingInputStream and connects it
|
||||||
/// to the given input stream.
|
/// to the given input stream.
|
||||||
|
|
||||||
~CountingInputStream();
|
~CountingInputStream();
|
||||||
/// Destroys the stream.
|
/// Destroys the stream.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API CountingOutputStream: public CountingIOS, public std::ostream
|
class Foundation_API CountingOutputStream: public CountingIOS, public std::ostream
|
||||||
/// This stream counts all characters and lines
|
/// This stream counts all characters and lines
|
||||||
/// going through it.
|
/// going through it.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CountingOutputStream();
|
CountingOutputStream();
|
||||||
/// Creates an unconnected CountingOutputStream.
|
/// Creates an unconnected CountingOutputStream.
|
||||||
|
|
||||||
CountingOutputStream(std::ostream& ostr);
|
CountingOutputStream(std::ostream& ostr);
|
||||||
/// Creates the CountingOutputStream and connects it
|
/// Creates the CountingOutputStream and connects it
|
||||||
/// to the given input stream.
|
/// to the given input stream.
|
||||||
|
|
||||||
~CountingOutputStream();
|
~CountingOutputStream();
|
||||||
/// Destroys the CountingOutputStream.
|
/// Destroys the CountingOutputStream.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline int CountingStreamBuf::chars() const
|
inline int CountingStreamBuf::chars() const
|
||||||
{
|
{
|
||||||
return _chars;
|
return _chars;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int CountingStreamBuf::lines() const
|
inline int CountingStreamBuf::lines() const
|
||||||
{
|
{
|
||||||
return _lines;
|
return _lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int CountingStreamBuf::pos() const
|
inline int CountingStreamBuf::pos() const
|
||||||
{
|
{
|
||||||
return _pos;
|
return _pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int CountingStreamBuf::getCurrentLineNumber() const
|
inline int CountingStreamBuf::getCurrentLineNumber() const
|
||||||
{
|
{
|
||||||
return _lines;
|
return _lines;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int CountingIOS::chars() const
|
inline int CountingIOS::chars() const
|
||||||
{
|
{
|
||||||
return _buf.chars();
|
return _buf.chars();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int CountingIOS::lines() const
|
inline int CountingIOS::lines() const
|
||||||
{
|
{
|
||||||
return _buf.lines();
|
return _buf.lines();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int CountingIOS::pos() const
|
inline int CountingIOS::pos() const
|
||||||
{
|
{
|
||||||
return _buf.pos();
|
return _buf.pos();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int CountingIOS::getCurrentLineNumber() const
|
inline int CountingIOS::getCurrentLineNumber() const
|
||||||
{
|
{
|
||||||
return _buf.getCurrentLineNumber();
|
return _buf.getCurrentLineNumber();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_CountingStream_INCLUDED
|
#endif // Foundation_CountingStream_INCLUDED
|
||||||
|
|||||||
@@ -1,433 +1,433 @@
|
|||||||
//
|
//
|
||||||
// DateTime.h
|
// DateTime.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DateTime.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DateTime.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: DateTime
|
// Package: DateTime
|
||||||
// Module: DateTime
|
// Module: DateTime
|
||||||
//
|
//
|
||||||
// Definition of the DateTime class.
|
// Definition of the DateTime 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_DateTime_INCLUDED
|
#ifndef Foundation_DateTime_INCLUDED
|
||||||
#define Foundation_DateTime_INCLUDED
|
#define Foundation_DateTime_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
#include "Poco/Timespan.h"
|
#include "Poco/Timespan.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DateTime
|
class Foundation_API DateTime
|
||||||
/// This class represents an instant in time, expressed
|
/// This class represents an instant in time, expressed
|
||||||
/// in years, months, days, hours, minutes, seconds
|
/// in years, months, days, hours, minutes, seconds
|
||||||
/// and milliseconds based on the Gregorian calendar.
|
/// and milliseconds based on the Gregorian calendar.
|
||||||
/// The class is mainly useful for conversions between
|
/// The class is mainly useful for conversions between
|
||||||
/// UTC, Julian day and Gregorian calendar dates.
|
/// UTC, Julian day and Gregorian calendar dates.
|
||||||
///
|
///
|
||||||
/// Conversion calculations are based on algorithms
|
/// Conversion calculations are based on algorithms
|
||||||
/// collected and described by Peter Baum at
|
/// collected and described by Peter Baum at
|
||||||
/// http://vsg.cape.com/~pbaum/date/date0.htm
|
/// http://vsg.cape.com/~pbaum/date/date0.htm
|
||||||
///
|
///
|
||||||
/// Internally, this class stores a date/time in two
|
/// Internally, this class stores a date/time in two
|
||||||
/// forms (UTC and broken down) for performance reasons. Only use
|
/// forms (UTC and broken down) for performance reasons. Only use
|
||||||
/// this class for conversions between date/time representations.
|
/// this class for conversions between date/time representations.
|
||||||
/// Use the Timestamp class for everything else.
|
/// Use the Timestamp class for everything else.
|
||||||
///
|
///
|
||||||
/// Notes:
|
/// Notes:
|
||||||
/// * Zero is a valid year (in accordance with ISO 8601 and astronomical year numbering)
|
/// * Zero is a valid year (in accordance with ISO 8601 and astronomical year numbering)
|
||||||
/// * Year zero (0) is a leap year
|
/// * Year zero (0) is a leap year
|
||||||
/// * Negative years (years preceding 1 BC) are not supported
|
/// * Negative years (years preceding 1 BC) are not supported
|
||||||
///
|
///
|
||||||
/// For more information, please see:
|
/// For more information, please see:
|
||||||
/// * http://en.wikipedia.org/wiki/Gregorian_Calendar
|
/// * http://en.wikipedia.org/wiki/Gregorian_Calendar
|
||||||
/// * http://en.wikipedia.org/wiki/Julian_day
|
/// * http://en.wikipedia.org/wiki/Julian_day
|
||||||
/// * http://en.wikipedia.org/wiki/UTC
|
/// * http://en.wikipedia.org/wiki/UTC
|
||||||
/// * http://en.wikipedia.org/wiki/ISO_8601
|
/// * http://en.wikipedia.org/wiki/ISO_8601
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Months
|
enum Months
|
||||||
/// Symbolic names for month numbers (1 to 12).
|
/// Symbolic names for month numbers (1 to 12).
|
||||||
{
|
{
|
||||||
JANUARY = 1,
|
JANUARY = 1,
|
||||||
FEBRUARY,
|
FEBRUARY,
|
||||||
MARCH,
|
MARCH,
|
||||||
APRIL,
|
APRIL,
|
||||||
MAY,
|
MAY,
|
||||||
JUNE,
|
JUNE,
|
||||||
JULY,
|
JULY,
|
||||||
AUGUST,
|
AUGUST,
|
||||||
SEPTEMBER,
|
SEPTEMBER,
|
||||||
OCTOBER,
|
OCTOBER,
|
||||||
NOVEMBER,
|
NOVEMBER,
|
||||||
DECEMBER
|
DECEMBER
|
||||||
};
|
};
|
||||||
|
|
||||||
enum DaysOfWeek
|
enum DaysOfWeek
|
||||||
/// Symbolic names for week day numbers (0 to 6).
|
/// Symbolic names for week day numbers (0 to 6).
|
||||||
{
|
{
|
||||||
SUNDAY = 0,
|
SUNDAY = 0,
|
||||||
MONDAY,
|
MONDAY,
|
||||||
TUESDAY,
|
TUESDAY,
|
||||||
WEDNESDAY,
|
WEDNESDAY,
|
||||||
THURSDAY,
|
THURSDAY,
|
||||||
FRIDAY,
|
FRIDAY,
|
||||||
SATURDAY
|
SATURDAY
|
||||||
};
|
};
|
||||||
|
|
||||||
DateTime();
|
DateTime();
|
||||||
/// Creates a DateTime for the current date and time.
|
/// Creates a DateTime for the current date and time.
|
||||||
|
|
||||||
DateTime(const Timestamp& timestamp);
|
DateTime(const Timestamp& timestamp);
|
||||||
/// Creates a DateTime for the date and time given in
|
/// Creates a DateTime for the date and time given in
|
||||||
/// a Timestamp.
|
/// a Timestamp.
|
||||||
|
|
||||||
DateTime(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0);
|
DateTime(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0);
|
||||||
/// Creates a DateTime for the given Gregorian date and time.
|
/// Creates a DateTime for the given Gregorian date and time.
|
||||||
/// * year is from 0 to 9999.
|
/// * year is from 0 to 9999.
|
||||||
/// * month is from 1 to 12.
|
/// * month is from 1 to 12.
|
||||||
/// * day is from 1 to 31.
|
/// * day is from 1 to 31.
|
||||||
/// * hour is from 0 to 23.
|
/// * hour is from 0 to 23.
|
||||||
/// * minute is from 0 to 59.
|
/// * minute is from 0 to 59.
|
||||||
/// * second is from 0 to 59.
|
/// * second is from 0 to 59.
|
||||||
/// * millisecond is from 0 to 999.
|
/// * millisecond is from 0 to 999.
|
||||||
/// * microsecond is from 0 to 999.
|
/// * microsecond is from 0 to 999.
|
||||||
|
|
||||||
DateTime(double julianDay);
|
DateTime(double julianDay);
|
||||||
/// Creates a DateTime for the given Julian day.
|
/// Creates a DateTime for the given Julian day.
|
||||||
|
|
||||||
DateTime(Timestamp::UtcTimeVal utcTime, Timestamp::TimeDiff diff);
|
DateTime(Timestamp::UtcTimeVal utcTime, Timestamp::TimeDiff diff);
|
||||||
/// Creates a DateTime from an UtcTimeVal and a TimeDiff.
|
/// Creates a DateTime from an UtcTimeVal and a TimeDiff.
|
||||||
///
|
///
|
||||||
/// Mainly used internally by DateTime and friends.
|
/// Mainly used internally by DateTime and friends.
|
||||||
|
|
||||||
DateTime(const DateTime& dateTime);
|
DateTime(const DateTime& dateTime);
|
||||||
/// Copy constructor. Creates the DateTime from another one.
|
/// Copy constructor. Creates the DateTime from another one.
|
||||||
|
|
||||||
~DateTime();
|
~DateTime();
|
||||||
/// Destroys the DateTime.
|
/// Destroys the DateTime.
|
||||||
|
|
||||||
DateTime& operator = (const DateTime& dateTime);
|
DateTime& operator = (const DateTime& dateTime);
|
||||||
/// Assigns another DateTime.
|
/// Assigns another DateTime.
|
||||||
|
|
||||||
DateTime& operator = (const Timestamp& timestamp);
|
DateTime& operator = (const Timestamp& timestamp);
|
||||||
/// Assigns a Timestamp.
|
/// Assigns a Timestamp.
|
||||||
|
|
||||||
DateTime& operator = (double julianDay);
|
DateTime& operator = (double julianDay);
|
||||||
/// Assigns a Julian day.
|
/// Assigns a Julian day.
|
||||||
|
|
||||||
DateTime& assign(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microseconds = 0);
|
DateTime& assign(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microseconds = 0);
|
||||||
/// Assigns a Gregorian date and time.
|
/// Assigns a Gregorian date and time.
|
||||||
/// * year is from 0 to 9999.
|
/// * year is from 0 to 9999.
|
||||||
/// * month is from 1 to 12.
|
/// * month is from 1 to 12.
|
||||||
/// * day is from 1 to 31.
|
/// * day is from 1 to 31.
|
||||||
/// * hour is from 0 to 23.
|
/// * hour is from 0 to 23.
|
||||||
/// * minute is from 0 to 59.
|
/// * minute is from 0 to 59.
|
||||||
/// * second is from 0 to 59.
|
/// * second is from 0 to 59.
|
||||||
/// * millisecond is from 0 to 999.
|
/// * millisecond is from 0 to 999.
|
||||||
/// * microsecond is from 0 to 999.
|
/// * microsecond is from 0 to 999.
|
||||||
|
|
||||||
void swap(DateTime& dateTime);
|
void swap(DateTime& dateTime);
|
||||||
/// Swaps the DateTime with another one.
|
/// Swaps the DateTime with another one.
|
||||||
|
|
||||||
int year() const;
|
int year() const;
|
||||||
/// Returns the year.
|
/// Returns the year.
|
||||||
|
|
||||||
int month() const;
|
int month() const;
|
||||||
/// Returns the month (1 to 12).
|
/// Returns the month (1 to 12).
|
||||||
|
|
||||||
int week(int firstDayOfWeek = MONDAY) const;
|
int week(int firstDayOfWeek = MONDAY) const;
|
||||||
/// Returns the week number within the year.
|
/// Returns the week number within the year.
|
||||||
/// FirstDayOfWeek should be either SUNDAY (0) or MONDAY (1).
|
/// FirstDayOfWeek should be either SUNDAY (0) or MONDAY (1).
|
||||||
/// The returned week number will be from 0 to 53. Week number 1 is the week
|
/// The returned week number will be from 0 to 53. Week number 1 is the week
|
||||||
/// containing January 4. This is in accordance to ISO 8601.
|
/// containing January 4. This is in accordance to ISO 8601.
|
||||||
///
|
///
|
||||||
/// The following example assumes that firstDayOfWeek is MONDAY. For 2005, which started
|
/// The following example assumes that firstDayOfWeek is MONDAY. For 2005, which started
|
||||||
/// on a Saturday, week 1 will be the week starting on Monday, January 3.
|
/// on a Saturday, week 1 will be the week starting on Monday, January 3.
|
||||||
/// January 1 and 2 will fall within week 0 (or the last week of the previous year).
|
/// January 1 and 2 will fall within week 0 (or the last week of the previous year).
|
||||||
///
|
///
|
||||||
/// For 2007, which starts on a Monday, week 1 will be the week startung on Monday, January 1.
|
/// For 2007, which starts on a Monday, week 1 will be the week startung on Monday, January 1.
|
||||||
/// There will be no week 0 in 2007.
|
/// There will be no week 0 in 2007.
|
||||||
|
|
||||||
int day() const;
|
int day() const;
|
||||||
/// Returns the day witin the month (1 to 31).
|
/// Returns the day witin the month (1 to 31).
|
||||||
|
|
||||||
int dayOfWeek() const;
|
int dayOfWeek() const;
|
||||||
/// Returns the weekday (0 to 6, where
|
/// Returns the weekday (0 to 6, where
|
||||||
/// 0 = Sunday, 1 = Monday, ..., 6 = Saturday).
|
/// 0 = Sunday, 1 = Monday, ..., 6 = Saturday).
|
||||||
|
|
||||||
int dayOfYear() const;
|
int dayOfYear() const;
|
||||||
/// Returns the number of the day in the year.
|
/// Returns the number of the day in the year.
|
||||||
/// January 1 is 1, February 1 is 32, etc.
|
/// January 1 is 1, February 1 is 32, etc.
|
||||||
|
|
||||||
int hour() const;
|
int hour() const;
|
||||||
/// Returns the hour (0 to 23).
|
/// Returns the hour (0 to 23).
|
||||||
|
|
||||||
int hourAMPM() const;
|
int hourAMPM() const;
|
||||||
/// Returns the hour (0 to 12).
|
/// Returns the hour (0 to 12).
|
||||||
|
|
||||||
bool isAM() const;
|
bool isAM() const;
|
||||||
/// Returns true if hour < 12;
|
/// Returns true if hour < 12;
|
||||||
|
|
||||||
bool isPM() const;
|
bool isPM() const;
|
||||||
/// Returns true if hour >= 12.
|
/// Returns true if hour >= 12.
|
||||||
|
|
||||||
int minute() const;
|
int minute() const;
|
||||||
/// Returns the minute (0 to 59).
|
/// Returns the minute (0 to 59).
|
||||||
|
|
||||||
int second() const;
|
int second() const;
|
||||||
/// Returns the second (0 to 59).
|
/// Returns the second (0 to 59).
|
||||||
|
|
||||||
int millisecond() const;
|
int millisecond() const;
|
||||||
/// Returns the millisecond (0 to 999)
|
/// Returns the millisecond (0 to 999)
|
||||||
|
|
||||||
int microsecond() const;
|
int microsecond() const;
|
||||||
/// Returns the microsecond (0 to 999)
|
/// Returns the microsecond (0 to 999)
|
||||||
|
|
||||||
double julianDay() const;
|
double julianDay() const;
|
||||||
/// Returns the julian day for the date and time.
|
/// Returns the julian day for the date and time.
|
||||||
|
|
||||||
Timestamp timestamp() const;
|
Timestamp timestamp() const;
|
||||||
/// Returns the date and time expressed as a Timestamp.
|
/// Returns the date and time expressed as a Timestamp.
|
||||||
|
|
||||||
Timestamp::UtcTimeVal utcTime() const;
|
Timestamp::UtcTimeVal utcTime() const;
|
||||||
/// Returns the date and time expressed in UTC-based
|
/// Returns the date and time expressed in UTC-based
|
||||||
/// time. UTC base time is midnight, October 15, 1582.
|
/// time. UTC base time is midnight, October 15, 1582.
|
||||||
/// Resolution is 100 nanoseconds.
|
/// Resolution is 100 nanoseconds.
|
||||||
|
|
||||||
bool operator == (const DateTime& dateTime) const;
|
bool operator == (const DateTime& dateTime) const;
|
||||||
bool operator != (const DateTime& dateTime) const;
|
bool operator != (const DateTime& dateTime) const;
|
||||||
bool operator < (const DateTime& dateTime) const;
|
bool operator < (const DateTime& dateTime) const;
|
||||||
bool operator <= (const DateTime& dateTime) const;
|
bool operator <= (const DateTime& dateTime) const;
|
||||||
bool operator > (const DateTime& dateTime) const;
|
bool operator > (const DateTime& dateTime) const;
|
||||||
bool operator >= (const DateTime& dateTime) const;
|
bool operator >= (const DateTime& dateTime) const;
|
||||||
|
|
||||||
DateTime operator + (const Timespan& span) const;
|
DateTime operator + (const Timespan& span) const;
|
||||||
DateTime operator - (const Timespan& span) const;
|
DateTime operator - (const Timespan& span) const;
|
||||||
Timespan operator - (const DateTime& dateTime) const;
|
Timespan operator - (const DateTime& dateTime) const;
|
||||||
DateTime& operator += (const Timespan& span);
|
DateTime& operator += (const Timespan& span);
|
||||||
DateTime& operator -= (const Timespan& span);
|
DateTime& operator -= (const Timespan& span);
|
||||||
|
|
||||||
void makeUTC(int tzd);
|
void makeUTC(int tzd);
|
||||||
/// Converts a local time into UTC, by applying the given time zone differential.
|
/// Converts a local time into UTC, by applying the given time zone differential.
|
||||||
|
|
||||||
void makeLocal(int tzd);
|
void makeLocal(int tzd);
|
||||||
/// Converts a UTC time into a local time, by applying the given time zone differential.
|
/// Converts a UTC time into a local time, by applying the given time zone differential.
|
||||||
|
|
||||||
static bool isLeapYear(int year);
|
static bool isLeapYear(int year);
|
||||||
/// Returns true if the given year is a leap year;
|
/// Returns true if the given year is a leap year;
|
||||||
/// false otherwise.
|
/// false otherwise.
|
||||||
|
|
||||||
static int daysOfMonth(int year, int month);
|
static int daysOfMonth(int year, int month);
|
||||||
/// Returns the number of days in the given month
|
/// Returns the number of days in the given month
|
||||||
/// and year. Month is from 1 to 12.
|
/// and year. Month is from 1 to 12.
|
||||||
|
|
||||||
static bool isValid(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0);
|
static bool isValid(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0);
|
||||||
/// Checks if the given date and time is valid
|
/// Checks if the given date and time is valid
|
||||||
/// (all arguments are within a proper range).
|
/// (all arguments are within a proper range).
|
||||||
///
|
///
|
||||||
/// Returns true if all arguments are valid, false otherwise.
|
/// Returns true if all arguments are valid, false otherwise.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static double toJulianDay(Timestamp::UtcTimeVal utcTime);
|
static double toJulianDay(Timestamp::UtcTimeVal utcTime);
|
||||||
/// Computes the Julian day for an UTC time.
|
/// Computes the Julian day for an UTC time.
|
||||||
|
|
||||||
static double toJulianDay(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0);
|
static double toJulianDay(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0);
|
||||||
/// Computes the Julian day for a gregorian calendar date and time.
|
/// Computes the Julian day for a gregorian calendar date and time.
|
||||||
/// See <http://vsg.cape.com/~pbaum/date/jdimp.htm>, section 2.3.1 for the algorithm.
|
/// See <http://vsg.cape.com/~pbaum/date/jdimp.htm>, section 2.3.1 for the algorithm.
|
||||||
|
|
||||||
static Timestamp::UtcTimeVal toUtcTime(double julianDay);
|
static Timestamp::UtcTimeVal toUtcTime(double julianDay);
|
||||||
/// Computes the UTC time for a Julian day.
|
/// Computes the UTC time for a Julian day.
|
||||||
|
|
||||||
void computeGregorian(double julianDay);
|
void computeGregorian(double julianDay);
|
||||||
/// Computes the Gregorian date for the given Julian day.
|
/// Computes the Gregorian date for the given Julian day.
|
||||||
/// See <http://vsg.cape.com/~pbaum/date/injdimp.htm>, section 3.3.1 for the algorithm.
|
/// See <http://vsg.cape.com/~pbaum/date/injdimp.htm>, section 3.3.1 for the algorithm.
|
||||||
|
|
||||||
void computeDaytime();
|
void computeDaytime();
|
||||||
/// Extracts the daytime (hours, minutes, seconds, etc.) from the stored utcTime.
|
/// Extracts the daytime (hours, minutes, seconds, etc.) from the stored utcTime.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void checkLimit(short& lower, short& higher, short limit);
|
void checkLimit(short& lower, short& higher, short limit);
|
||||||
void normalize();
|
void normalize();
|
||||||
///utility functions used to correct the overflow in computeGregorian
|
///utility functions used to correct the overflow in computeGregorian
|
||||||
|
|
||||||
Timestamp::UtcTimeVal _utcTime;
|
Timestamp::UtcTimeVal _utcTime;
|
||||||
short _year;
|
short _year;
|
||||||
short _month;
|
short _month;
|
||||||
short _day;
|
short _day;
|
||||||
short _hour;
|
short _hour;
|
||||||
short _minute;
|
short _minute;
|
||||||
short _second;
|
short _second;
|
||||||
short _millisecond;
|
short _millisecond;
|
||||||
short _microsecond;
|
short _microsecond;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline Timestamp DateTime::timestamp() const
|
inline Timestamp DateTime::timestamp() const
|
||||||
{
|
{
|
||||||
return Timestamp::fromUtcTime(_utcTime);
|
return Timestamp::fromUtcTime(_utcTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline Timestamp::UtcTimeVal DateTime::utcTime() const
|
inline Timestamp::UtcTimeVal DateTime::utcTime() const
|
||||||
{
|
{
|
||||||
return _utcTime;
|
return _utcTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int DateTime::year() const
|
inline int DateTime::year() const
|
||||||
{
|
{
|
||||||
return _year;
|
return _year;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int DateTime::month() const
|
inline int DateTime::month() const
|
||||||
{
|
{
|
||||||
return _month;
|
return _month;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int DateTime::day() const
|
inline int DateTime::day() const
|
||||||
{
|
{
|
||||||
return _day;
|
return _day;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int DateTime::hour() const
|
inline int DateTime::hour() const
|
||||||
{
|
{
|
||||||
return _hour;
|
return _hour;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int DateTime::hourAMPM() const
|
inline int DateTime::hourAMPM() const
|
||||||
{
|
{
|
||||||
if (_hour < 1)
|
if (_hour < 1)
|
||||||
return 12;
|
return 12;
|
||||||
else if (_hour > 12)
|
else if (_hour > 12)
|
||||||
return _hour - 12;
|
return _hour - 12;
|
||||||
else
|
else
|
||||||
return _hour;
|
return _hour;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool DateTime::isAM() const
|
inline bool DateTime::isAM() const
|
||||||
{
|
{
|
||||||
return _hour < 12;
|
return _hour < 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool DateTime::isPM() const
|
inline bool DateTime::isPM() const
|
||||||
{
|
{
|
||||||
return _hour >= 12;
|
return _hour >= 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int DateTime::minute() const
|
inline int DateTime::minute() const
|
||||||
{
|
{
|
||||||
return _minute;
|
return _minute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int DateTime::second() const
|
inline int DateTime::second() const
|
||||||
{
|
{
|
||||||
return _second;
|
return _second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int DateTime::millisecond() const
|
inline int DateTime::millisecond() const
|
||||||
{
|
{
|
||||||
return _millisecond;
|
return _millisecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int DateTime::microsecond() const
|
inline int DateTime::microsecond() const
|
||||||
{
|
{
|
||||||
return _microsecond;
|
return _microsecond;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool DateTime::operator == (const DateTime& dateTime) const
|
inline bool DateTime::operator == (const DateTime& dateTime) const
|
||||||
{
|
{
|
||||||
return _utcTime == dateTime._utcTime;
|
return _utcTime == dateTime._utcTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool DateTime::operator != (const DateTime& dateTime) const
|
inline bool DateTime::operator != (const DateTime& dateTime) const
|
||||||
{
|
{
|
||||||
return _utcTime != dateTime._utcTime;
|
return _utcTime != dateTime._utcTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool DateTime::operator < (const DateTime& dateTime) const
|
inline bool DateTime::operator < (const DateTime& dateTime) const
|
||||||
{
|
{
|
||||||
return _utcTime < dateTime._utcTime;
|
return _utcTime < dateTime._utcTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool DateTime::operator <= (const DateTime& dateTime) const
|
inline bool DateTime::operator <= (const DateTime& dateTime) const
|
||||||
{
|
{
|
||||||
return _utcTime <= dateTime._utcTime;
|
return _utcTime <= dateTime._utcTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool DateTime::operator > (const DateTime& dateTime) const
|
inline bool DateTime::operator > (const DateTime& dateTime) const
|
||||||
{
|
{
|
||||||
return _utcTime > dateTime._utcTime;
|
return _utcTime > dateTime._utcTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool DateTime::operator >= (const DateTime& dateTime) const
|
inline bool DateTime::operator >= (const DateTime& dateTime) const
|
||||||
{
|
{
|
||||||
return _utcTime >= dateTime._utcTime;
|
return _utcTime >= dateTime._utcTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool DateTime::isLeapYear(int year)
|
inline bool DateTime::isLeapYear(int year)
|
||||||
{
|
{
|
||||||
return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0);
|
return (year % 4) == 0 && ((year % 100) != 0 || (year % 400) == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void swap(DateTime& d1, DateTime& d2)
|
inline void swap(DateTime& d1, DateTime& d2)
|
||||||
{
|
{
|
||||||
d1.swap(d2);
|
d1.swap(d2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DateTime_INCLUDED
|
#endif // Foundation_DateTime_INCLUDED
|
||||||
|
|||||||
@@ -1,123 +1,123 @@
|
|||||||
//
|
//
|
||||||
// DateTimeFormat.h
|
// DateTimeFormat.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DateTimeFormat.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DateTimeFormat.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: DateTime
|
// Package: DateTime
|
||||||
// Module: DateTimeFormat
|
// Module: DateTimeFormat
|
||||||
//
|
//
|
||||||
// Definition of the DateTimeFormat class.
|
// Definition of the DateTimeFormat 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_DateTimeFormat_INCLUDED
|
#ifndef Foundation_DateTimeFormat_INCLUDED
|
||||||
#define Foundation_DateTimeFormat_INCLUDED
|
#define Foundation_DateTimeFormat_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DateTimeFormat
|
class Foundation_API DateTimeFormat
|
||||||
/// Definition of date/time formats and various
|
/// Definition of date/time formats and various
|
||||||
/// constants used by DateTimeFormatter and DateTimeParser.
|
/// constants used by DateTimeFormatter and DateTimeParser.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// predefined date formats
|
// predefined date formats
|
||||||
static const std::string ISO8601_FORMAT;
|
static const std::string ISO8601_FORMAT;
|
||||||
/// The date/time format defined in the ISO 8601 standard.
|
/// The date/time format defined in the ISO 8601 standard.
|
||||||
///
|
///
|
||||||
/// Examples:
|
/// Examples:
|
||||||
/// 2005-01-01T12:00:00+01:00
|
/// 2005-01-01T12:00:00+01:00
|
||||||
/// 2005-01-01T11:00:00Z
|
/// 2005-01-01T11:00:00Z
|
||||||
|
|
||||||
static const std::string RFC822_FORMAT;
|
static const std::string RFC822_FORMAT;
|
||||||
/// The date/time format defined in RFC 822 (obsoleted by RFC 1123).
|
/// The date/time format defined in RFC 822 (obsoleted by RFC 1123).
|
||||||
///
|
///
|
||||||
/// Examples:
|
/// Examples:
|
||||||
/// Sat, 1 Jan 05 12:00:00 +0100
|
/// Sat, 1 Jan 05 12:00:00 +0100
|
||||||
/// Sat, 1 Jan 05 11:00:00 GMT
|
/// Sat, 1 Jan 05 11:00:00 GMT
|
||||||
|
|
||||||
static const std::string RFC1123_FORMAT;
|
static const std::string RFC1123_FORMAT;
|
||||||
/// The date/time format defined in RFC 1123 (obsoletes RFC 822).
|
/// The date/time format defined in RFC 1123 (obsoletes RFC 822).
|
||||||
///
|
///
|
||||||
/// Examples:
|
/// Examples:
|
||||||
/// Sat, 1 Jan 2005 12:00:00 +0100
|
/// Sat, 1 Jan 2005 12:00:00 +0100
|
||||||
/// Sat, 1 Jan 2005 11:00:00 GMT
|
/// Sat, 1 Jan 2005 11:00:00 GMT
|
||||||
|
|
||||||
static const std::string HTTP_FORMAT;
|
static const std::string HTTP_FORMAT;
|
||||||
/// The date/time format defined in the HTTP specification (RFC 2616),
|
/// The date/time format defined in the HTTP specification (RFC 2616),
|
||||||
/// which is basically a variant of RFC 1036 with a zero-padded day field.
|
/// which is basically a variant of RFC 1036 with a zero-padded day field.
|
||||||
///
|
///
|
||||||
/// Examples:
|
/// Examples:
|
||||||
/// Sat, 01 Jan 2005 12:00:00 +0100
|
/// Sat, 01 Jan 2005 12:00:00 +0100
|
||||||
/// Sat, 01 Jan 2005 11:00:00 GMT
|
/// Sat, 01 Jan 2005 11:00:00 GMT
|
||||||
|
|
||||||
static const std::string RFC850_FORMAT;
|
static const std::string RFC850_FORMAT;
|
||||||
/// The date/time format defined in RFC 850 (obsoleted by RFC 1036).
|
/// The date/time format defined in RFC 850 (obsoleted by RFC 1036).
|
||||||
///
|
///
|
||||||
/// Examples:
|
/// Examples:
|
||||||
/// Saturday, 1-Jan-05 12:00:00 +0100
|
/// Saturday, 1-Jan-05 12:00:00 +0100
|
||||||
/// Saturday, 1-Jan-05 11:00:00 GMT
|
/// Saturday, 1-Jan-05 11:00:00 GMT
|
||||||
|
|
||||||
static const std::string RFC1036_FORMAT;
|
static const std::string RFC1036_FORMAT;
|
||||||
/// The date/time format defined in RFC 1036 (obsoletes RFC 850).
|
/// The date/time format defined in RFC 1036 (obsoletes RFC 850).
|
||||||
///
|
///
|
||||||
/// Examples:
|
/// Examples:
|
||||||
/// Saturday, 1 Jan 05 12:00:00 +0100
|
/// Saturday, 1 Jan 05 12:00:00 +0100
|
||||||
/// Saturday, 1 Jan 05 11:00:00 GMT
|
/// Saturday, 1 Jan 05 11:00:00 GMT
|
||||||
|
|
||||||
static const std::string ASCTIME_FORMAT;
|
static const std::string ASCTIME_FORMAT;
|
||||||
/// The date/time format produced by the ANSI C asctime() function.
|
/// The date/time format produced by the ANSI C asctime() function.
|
||||||
///
|
///
|
||||||
/// Example:
|
/// Example:
|
||||||
/// Sat Jan 1 12:00:00 2005
|
/// Sat Jan 1 12:00:00 2005
|
||||||
|
|
||||||
static const std::string SORTABLE_FORMAT;
|
static const std::string SORTABLE_FORMAT;
|
||||||
/// A simple, sortable date/time format.
|
/// A simple, sortable date/time format.
|
||||||
///
|
///
|
||||||
/// Example:
|
/// Example:
|
||||||
/// 2005-01-01 12:00:00
|
/// 2005-01-01 12:00:00
|
||||||
|
|
||||||
|
|
||||||
// names used by formatter and parser
|
// names used by formatter and parser
|
||||||
static const std::string WEEKDAY_NAMES[7];
|
static const std::string WEEKDAY_NAMES[7];
|
||||||
/// English names of week days (Sunday, Monday, Tuesday, ...).
|
/// English names of week days (Sunday, Monday, Tuesday, ...).
|
||||||
|
|
||||||
static const std::string MONTH_NAMES[12];
|
static const std::string MONTH_NAMES[12];
|
||||||
/// English names of months (January, February, ...).
|
/// English names of months (January, February, ...).
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DateTimeFormat_INCLUDED
|
#endif // Foundation_DateTimeFormat_INCLUDED
|
||||||
|
|||||||
@@ -1,137 +1,137 @@
|
|||||||
//
|
//
|
||||||
// DateTimeFormatter.h
|
// DateTimeFormatter.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DateTimeFormatter.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DateTimeFormatter.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: DateTime
|
// Package: DateTime
|
||||||
// Module: DateTimeFormatter
|
// Module: DateTimeFormatter
|
||||||
//
|
//
|
||||||
// Definition of the DateTimeFormatter class.
|
// Definition of the DateTimeFormatter 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_DateTimeFormatter_INCLUDED
|
#ifndef Foundation_DateTimeFormatter_INCLUDED
|
||||||
#define Foundation_DateTimeFormatter_INCLUDED
|
#define Foundation_DateTimeFormatter_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class DateTime;
|
class DateTime;
|
||||||
class LocalDateTime;
|
class LocalDateTime;
|
||||||
class Timestamp;
|
class Timestamp;
|
||||||
class Timespan;
|
class Timespan;
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DateTimeFormatter
|
class Foundation_API DateTimeFormatter
|
||||||
/// This class converts dates and times into strings, supporting a
|
/// This class converts dates and times into strings, supporting a
|
||||||
/// variety of standard and custom formats.
|
/// variety of standard and custom formats.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
UTC = 0xFFFF /// Special value for timeZoneDifferential denoting UTC.
|
UTC = 0xFFFF /// Special value for timeZoneDifferential denoting UTC.
|
||||||
};
|
};
|
||||||
|
|
||||||
static std::string format(const Timestamp& timestamp, const std::string& fmt, int timeZoneDifferential = UTC);
|
static std::string format(const Timestamp& timestamp, const std::string& fmt, int timeZoneDifferential = UTC);
|
||||||
/// Formats the given timestamp according to the given format.
|
/// Formats the given timestamp according to the given format.
|
||||||
/// The format string is used as a template to format the date and
|
/// The format string is used as a template to format the date and
|
||||||
/// is copied character by character except for the following special characters,
|
/// is copied character by character except for the following special characters,
|
||||||
/// which are replaced by the corresponding value.
|
/// which are replaced by the corresponding value.
|
||||||
///
|
///
|
||||||
/// * %w - abbreviated weekday (Mon, Tue, ...)
|
/// * %w - abbreviated weekday (Mon, Tue, ...)
|
||||||
/// * %W - full weekday (Monday, Tuesday, ...)
|
/// * %W - full weekday (Monday, Tuesday, ...)
|
||||||
/// * %b - abbreviated month (Jan, Feb, ...)
|
/// * %b - abbreviated month (Jan, Feb, ...)
|
||||||
/// * %B - full month (January, February, ...)
|
/// * %B - full month (January, February, ...)
|
||||||
/// * %d - zero-padded day of month (01 .. 31)
|
/// * %d - zero-padded day of month (01 .. 31)
|
||||||
/// * %e - day of month (1 .. 31)
|
/// * %e - day of month (1 .. 31)
|
||||||
/// * %f - space-padded day of month ( 1 .. 31)
|
/// * %f - space-padded day of month ( 1 .. 31)
|
||||||
/// * %m - zero-padded month (01 .. 12)
|
/// * %m - zero-padded month (01 .. 12)
|
||||||
/// * %n - month (1 .. 12)
|
/// * %n - month (1 .. 12)
|
||||||
/// * %o - space-padded month ( 1 .. 12)
|
/// * %o - space-padded month ( 1 .. 12)
|
||||||
/// * %y - year without century (70)
|
/// * %y - year without century (70)
|
||||||
/// * %Y - year with century (1970)
|
/// * %Y - year with century (1970)
|
||||||
/// * %H - hour (00 .. 23)
|
/// * %H - hour (00 .. 23)
|
||||||
/// * %h - hour (00 .. 12)
|
/// * %h - hour (00 .. 12)
|
||||||
/// * %a - am/pm
|
/// * %a - am/pm
|
||||||
/// * %A - AM/PM
|
/// * %A - AM/PM
|
||||||
/// * %M - minute (00 .. 59)
|
/// * %M - minute (00 .. 59)
|
||||||
/// * %S - second (00 .. 59)
|
/// * %S - second (00 .. 59)
|
||||||
/// * %i - millisecond (000 .. 999)
|
/// * %i - millisecond (000 .. 999)
|
||||||
/// * %c - centisecond (0 .. 9)
|
/// * %c - centisecond (0 .. 9)
|
||||||
/// * %z - time zone differential in ISO 8601 format (Z or +NN.NN).
|
/// * %z - time zone differential in ISO 8601 format (Z or +NN.NN).
|
||||||
/// * %Z - time zone differential in RFC format (GMT or +NNNN)
|
/// * %Z - time zone differential in RFC format (GMT or +NNNN)
|
||||||
/// * %% - percent sign
|
/// * %% - percent sign
|
||||||
///
|
///
|
||||||
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
||||||
|
|
||||||
static std::string format(const DateTime& dateTime, const std::string& fmt, int timeZoneDifferential = UTC);
|
static std::string format(const DateTime& dateTime, const std::string& fmt, int timeZoneDifferential = UTC);
|
||||||
/// Formats the given date and time according to the given format.
|
/// Formats the given date and time according to the given format.
|
||||||
/// See format(const Timestamp&, const std::string&, int) for more information.
|
/// See format(const Timestamp&, const std::string&, int) for more information.
|
||||||
|
|
||||||
static std::string format(const LocalDateTime& dateTime, const std::string& fmt);
|
static std::string format(const LocalDateTime& dateTime, const std::string& fmt);
|
||||||
/// Formats the given local date and time according to the given format.
|
/// Formats the given local date and time according to the given format.
|
||||||
/// See format(const Timestamp&, const std::string&, int) for more information.
|
/// See format(const Timestamp&, const std::string&, int) for more information.
|
||||||
|
|
||||||
static std::string format(const Timespan& timespan, const std::string& fmt = "%dd %H:%M:%S.%i");
|
static std::string format(const Timespan& timespan, const std::string& fmt = "%dd %H:%M:%S.%i");
|
||||||
/// Formats the given timespan according to the given format.
|
/// Formats the given timespan according to the given format.
|
||||||
/// The format string is used as a template to format the date and
|
/// The format string is used as a template to format the date and
|
||||||
/// is copied character by character except for the following special characters,
|
/// is copied character by character except for the following special characters,
|
||||||
/// which are replaced by the corresponding value.
|
/// which are replaced by the corresponding value.
|
||||||
///
|
///
|
||||||
/// * %d - days
|
/// * %d - days
|
||||||
/// * %H - hours (00 .. 23)
|
/// * %H - hours (00 .. 23)
|
||||||
/// * %h - total hours (0 .. n)
|
/// * %h - total hours (0 .. n)
|
||||||
/// * %M - minutes (00 .. 59)
|
/// * %M - minutes (00 .. 59)
|
||||||
/// * %m - total minutes (0 .. n)
|
/// * %m - total minutes (0 .. n)
|
||||||
/// * %S - seconds (00 .. 59)
|
/// * %S - seconds (00 .. 59)
|
||||||
/// * %s - total seconds (0 .. n)
|
/// * %s - total seconds (0 .. n)
|
||||||
/// * %i - milliseconds (000 .. 999)
|
/// * %i - milliseconds (000 .. 999)
|
||||||
/// * %c - centisecond (0 .. 9)
|
/// * %c - centisecond (0 .. 9)
|
||||||
/// * %% - percent sign
|
/// * %% - percent sign
|
||||||
|
|
||||||
static std::string tzdISO(int timeZoneDifferential);
|
static std::string tzdISO(int timeZoneDifferential);
|
||||||
/// Formats the given timezone differential in ISO format.
|
/// Formats the given timezone differential in ISO format.
|
||||||
/// If timeZoneDifferential is UTC, "Z" is returned,
|
/// If timeZoneDifferential is UTC, "Z" is returned,
|
||||||
/// otherwise, +HH.MM (or -HH.MM) is returned.
|
/// otherwise, +HH.MM (or -HH.MM) is returned.
|
||||||
|
|
||||||
static std::string tzdRFC(int timeZoneDifferential);
|
static std::string tzdRFC(int timeZoneDifferential);
|
||||||
/// Formats the given timezone differential in RFC format.
|
/// Formats the given timezone differential in RFC format.
|
||||||
/// If timeZoneDifferential is UTC, "GMT" is returned,
|
/// If timeZoneDifferential is UTC, "GMT" is returned,
|
||||||
/// otherwise ++HHMM (or -HHMM) is returned.
|
/// otherwise ++HHMM (or -HHMM) is returned.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DateTimeFormatter_INCLUDED
|
#endif // Foundation_DateTimeFormatter_INCLUDED
|
||||||
|
|||||||
@@ -1,124 +1,124 @@
|
|||||||
//
|
//
|
||||||
// DateTimeParser.h
|
// DateTimeParser.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DateTimeParser.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DateTimeParser.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: DateTime
|
// Package: DateTime
|
||||||
// Module: DateTimeParser
|
// Module: DateTimeParser
|
||||||
//
|
//
|
||||||
// Definition of the DateTimeParser class.
|
// Definition of the DateTimeParser 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_DateTimeParser_INCLUDED
|
#ifndef Foundation_DateTimeParser_INCLUDED
|
||||||
#define Foundation_DateTimeParser_INCLUDED
|
#define Foundation_DateTimeParser_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/DateTime.h"
|
#include "Poco/DateTime.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DateTimeParser
|
class Foundation_API DateTimeParser
|
||||||
/// This class provides a method for parsing dates and times
|
/// This class provides a method for parsing dates and times
|
||||||
/// from strings. All parsing methods do their best to
|
/// from strings. All parsing methods do their best to
|
||||||
/// parse a meaningful result, even from malformed input
|
/// parse a meaningful result, even from malformed input
|
||||||
/// strings.
|
/// strings.
|
||||||
///
|
///
|
||||||
/// The returned DateTime will always contain a time in the same
|
/// The returned DateTime will always contain a time in the same
|
||||||
/// timezone as the time in the string. Call DateTime::makeUTC()
|
/// timezone as the time in the string. Call DateTime::makeUTC()
|
||||||
/// with the timeZoneDifferential returned by parse() to convert
|
/// with the timeZoneDifferential returned by parse() to convert
|
||||||
/// the DateTime to UTC.
|
/// the DateTime to UTC.
|
||||||
///
|
///
|
||||||
/// Note: When parsing a time in 12-hour (AM/PM) format, the hour
|
/// Note: When parsing a time in 12-hour (AM/PM) format, the hour
|
||||||
/// (%h) must be parsed before the AM/PM designator (%a, %A),
|
/// (%h) must be parsed before the AM/PM designator (%a, %A),
|
||||||
/// otherwise the AM/PM designator will be ignored.
|
/// otherwise the AM/PM designator will be ignored.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static void parse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
|
static void parse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
|
||||||
/// Parses a date and time in the given format from the given string.
|
/// Parses a date and time in the given format from the given string.
|
||||||
/// Throws a SyntaxException if the string cannot be successfully parsed.
|
/// Throws a SyntaxException if the string cannot be successfully parsed.
|
||||||
/// Please see DateTimeFormatter::format() for a description of the format string.
|
/// Please see DateTimeFormatter::format() for a description of the format string.
|
||||||
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
||||||
|
|
||||||
static DateTime parse(const std::string& fmt, const std::string& str, int& timeZoneDifferential);
|
static DateTime parse(const std::string& fmt, const std::string& str, int& timeZoneDifferential);
|
||||||
/// Parses a date and time in the given format from the given string.
|
/// Parses a date and time in the given format from the given string.
|
||||||
/// Throws a SyntaxException if the string cannot be successfully parsed.
|
/// Throws a SyntaxException if the string cannot be successfully parsed.
|
||||||
/// Please see DateTimeFormatter::format() for a description of the format string.
|
/// Please see DateTimeFormatter::format() for a description of the format string.
|
||||||
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
||||||
|
|
||||||
static bool tryParse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
|
static bool tryParse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
|
||||||
/// Parses a date and time in the given format from the given string.
|
/// Parses a date and time in the given format from the given string.
|
||||||
/// Returns true if the string has been successfully parsed, false otherwise.
|
/// Returns true if the string has been successfully parsed, false otherwise.
|
||||||
/// Please see DateTimeFormatter::format() for a description of the format string.
|
/// Please see DateTimeFormatter::format() for a description of the format string.
|
||||||
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
||||||
|
|
||||||
static void parse(const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
|
static void parse(const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
|
||||||
/// Parses a date and time from the given dateTime string. Before parsing, the method
|
/// Parses a date and time from the given dateTime string. Before parsing, the method
|
||||||
/// examines the dateTime string for a known date/time format.
|
/// examines the dateTime string for a known date/time format.
|
||||||
/// Throws a SyntaxException if the string cannot be successfully parsed.
|
/// Throws a SyntaxException if the string cannot be successfully parsed.
|
||||||
/// Please see DateTimeFormatter::format() for a description of the format string.
|
/// Please see DateTimeFormatter::format() for a description of the format string.
|
||||||
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
||||||
|
|
||||||
static DateTime parse(const std::string& str, int& timeZoneDifferential);
|
static DateTime parse(const std::string& str, int& timeZoneDifferential);
|
||||||
/// Parses a date and time from the given dateTime string. Before parsing, the method
|
/// Parses a date and time from the given dateTime string. Before parsing, the method
|
||||||
/// examines the dateTime string for a known date/time format.
|
/// examines the dateTime string for a known date/time format.
|
||||||
/// Please see DateTimeFormatter::format() for a description of the format string.
|
/// Please see DateTimeFormatter::format() for a description of the format string.
|
||||||
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
||||||
|
|
||||||
static bool tryParse(const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
|
static bool tryParse(const std::string& str, DateTime& dateTime, int& timeZoneDifferential);
|
||||||
/// Parses a date and time from the given dateTime string. Before parsing, the method
|
/// Parses a date and time from the given dateTime string. Before parsing, the method
|
||||||
/// examines the dateTime string for a known date/time format.
|
/// examines the dateTime string for a known date/time format.
|
||||||
/// Please see DateTimeFormatter::format() for a description of the format string.
|
/// Please see DateTimeFormatter::format() for a description of the format string.
|
||||||
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
/// Class DateTimeFormat defines format strings for various standard date/time formats.
|
||||||
|
|
||||||
static int parseMonth(std::string::const_iterator& it, const std::string::const_iterator& end);
|
static int parseMonth(std::string::const_iterator& it, const std::string::const_iterator& end);
|
||||||
/// Tries to interpret the given range as a month name. The range must be at least
|
/// Tries to interpret the given range as a month name. The range must be at least
|
||||||
/// three characters long.
|
/// three characters long.
|
||||||
/// Returns the month number (1 .. 12) if the month name is valid. Otherwise throws
|
/// Returns the month number (1 .. 12) if the month name is valid. Otherwise throws
|
||||||
/// a SyntaxException.
|
/// a SyntaxException.
|
||||||
|
|
||||||
static int parseDayOfWeek(std::string::const_iterator& it, const std::string::const_iterator& end);
|
static int parseDayOfWeek(std::string::const_iterator& it, const std::string::const_iterator& end);
|
||||||
/// Tries to interpret the given range as a weekday name. The range must be at least
|
/// Tries to interpret the given range as a weekday name. The range must be at least
|
||||||
/// three characters long.
|
/// three characters long.
|
||||||
/// Returns the weekday number (0 .. 6, where 0 = Synday, 1 = Monday, etc.) if the
|
/// Returns the weekday number (0 .. 6, where 0 = Synday, 1 = Monday, etc.) if the
|
||||||
/// weekday name is valid. Otherwise throws a SyntaxException.
|
/// weekday name is valid. Otherwise throws a SyntaxException.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static int parseTZD(std::string::const_iterator& it, const std::string::const_iterator& end);
|
static int parseTZD(std::string::const_iterator& it, const std::string::const_iterator& end);
|
||||||
static int parseAMPM(std::string::const_iterator& it, const std::string::const_iterator& end, int hour);
|
static int parseAMPM(std::string::const_iterator& it, const std::string::const_iterator& end, int hour);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DateTimeParser_INCLUDED
|
#endif // Foundation_DateTimeParser_INCLUDED
|
||||||
|
|||||||
@@ -1,95 +1,95 @@
|
|||||||
//
|
//
|
||||||
// Debugger.h
|
// Debugger.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Debugger.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Debugger.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: Debugger
|
// Module: Debugger
|
||||||
//
|
//
|
||||||
// Definition of the Debugger class.
|
// Definition of the Debugger 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_Debugger_INCLUDED
|
#ifndef Foundation_Debugger_INCLUDED
|
||||||
#define Foundation_Debugger_INCLUDED
|
#define Foundation_Debugger_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Debugger
|
class Foundation_API Debugger
|
||||||
/// The Debugger class provides an interface to the debugger.
|
/// The Debugger class provides an interface to the debugger.
|
||||||
/// The presence of a debugger can be checked for,
|
/// The presence of a debugger can be checked for,
|
||||||
/// messages can be written to the debugger's log window
|
/// messages can be written to the debugger's log window
|
||||||
/// and a break into the debugger can be enforced.
|
/// and a break into the debugger can be enforced.
|
||||||
/// The methods only work if the program is compiled
|
/// The methods only work if the program is compiled
|
||||||
/// in debug mode (the macro _DEBUG is defined).
|
/// in debug mode (the macro _DEBUG is defined).
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static bool isAvailable();
|
static bool isAvailable();
|
||||||
/// Returns true if a debugger is available, false otherwise.
|
/// Returns true if a debugger is available, false otherwise.
|
||||||
/// On Windows, this function uses the IsDebuggerPresent()
|
/// On Windows, this function uses the IsDebuggerPresent()
|
||||||
/// function.
|
/// function.
|
||||||
/// On Unix, this function returns true if the environment
|
/// On Unix, this function returns true if the environment
|
||||||
/// variable POCO_ENABLE_DEBUGGER is set.
|
/// variable POCO_ENABLE_DEBUGGER is set.
|
||||||
/// On OpenVMS, this function always returns true in debug,
|
/// On OpenVMS, this function always returns true in debug,
|
||||||
/// mode, false otherwise.
|
/// mode, false otherwise.
|
||||||
|
|
||||||
static void message(const std::string& msg);
|
static void message(const std::string& msg);
|
||||||
/// Writes a message to the debugger log, if available, otherwise to
|
/// Writes a message to the debugger log, if available, otherwise to
|
||||||
/// standard error output.
|
/// standard error output.
|
||||||
|
|
||||||
static void message(const std::string& msg, const char* file, int line);
|
static void message(const std::string& msg, const char* file, int line);
|
||||||
/// Writes a message to the debugger log, if available, otherwise to
|
/// Writes a message to the debugger log, if available, otherwise to
|
||||||
/// standard error output.
|
/// standard error output.
|
||||||
|
|
||||||
static void enter();
|
static void enter();
|
||||||
/// Breaks into the debugger, if it is available.
|
/// Breaks into the debugger, if it is available.
|
||||||
/// On Windows, this is done using the DebugBreak() function.
|
/// On Windows, this is done using the DebugBreak() function.
|
||||||
/// On Unix, the SIGINT signal is raised.
|
/// On Unix, the SIGINT signal is raised.
|
||||||
/// On OpenVMS, the SS$_DEBUG signal is raised.
|
/// On OpenVMS, the SS$_DEBUG signal is raised.
|
||||||
|
|
||||||
static void enter(const std::string& msg);
|
static void enter(const std::string& msg);
|
||||||
/// Writes a debug message to the debugger log and breaks into it.
|
/// Writes a debug message to the debugger log and breaks into it.
|
||||||
|
|
||||||
static void enter(const std::string& msg, const char* file, int line);
|
static void enter(const std::string& msg, const char* file, int line);
|
||||||
/// Writes a debug message to the debugger log and breaks into it.
|
/// Writes a debug message to the debugger log and breaks into it.
|
||||||
|
|
||||||
static void enter(const char* file, int line);
|
static void enter(const char* file, int line);
|
||||||
/// Writes a debug message to the debugger log and breaks into it.
|
/// Writes a debug message to the debugger log and breaks into it.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Debugger_INCLUDED
|
#endif // Foundation_Debugger_INCLUDED
|
||||||
|
|||||||
@@ -1,154 +1,154 @@
|
|||||||
//
|
//
|
||||||
// DefaultStrategy.h
|
// DefaultStrategy.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DefaultStrategy.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DefaultStrategy.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
// Module: DefaultStrategy
|
// Module: DefaultStrategy
|
||||||
//
|
//
|
||||||
// Implementation of the DefaultStrategy template.
|
// Implementation of the DefaultStrategy template.
|
||||||
//
|
//
|
||||||
// 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 Foundation_DefaultStrategy_INCLUDED
|
#ifndef Foundation_DefaultStrategy_INCLUDED
|
||||||
#define Foundation_DefaultStrategy_INCLUDED
|
#define Foundation_DefaultStrategy_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/NotificationStrategy.h"
|
#include "Poco/NotificationStrategy.h"
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TArgs, class TDelegate, class TCompare>
|
template <class TArgs, class TDelegate, class TCompare>
|
||||||
class DefaultStrategy: public NotificationStrategy<TArgs, TDelegate>
|
class DefaultStrategy: public NotificationStrategy<TArgs, TDelegate>
|
||||||
/// Default notification strategy. Allows one observer
|
/// Default notification strategy. Allows one observer
|
||||||
/// to register exactly once. The observer must provide an
|
/// to register exactly once. The observer must provide an
|
||||||
/// < (less-than) operator.
|
/// < (less-than) operator.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::set<TDelegate*, TCompare> Delegates;
|
typedef std::set<TDelegate*, TCompare> Delegates;
|
||||||
typedef typename Delegates::iterator Iterator;
|
typedef typename Delegates::iterator Iterator;
|
||||||
typedef typename Delegates::const_iterator ConstIterator;
|
typedef typename Delegates::const_iterator ConstIterator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
DefaultStrategy()
|
DefaultStrategy()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultStrategy(const DefaultStrategy& s)
|
DefaultStrategy(const DefaultStrategy& s)
|
||||||
{
|
{
|
||||||
operator = (s);
|
operator = (s);
|
||||||
}
|
}
|
||||||
|
|
||||||
~DefaultStrategy()
|
~DefaultStrategy()
|
||||||
{
|
{
|
||||||
clear();
|
clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void notify(const void* sender, TArgs& arguments)
|
void notify(const void* sender, TArgs& arguments)
|
||||||
{
|
{
|
||||||
std::vector<Iterator> delMe;
|
std::vector<Iterator> delMe;
|
||||||
|
|
||||||
for (Iterator it = _observers.begin(); it != _observers.end(); it++)
|
for (Iterator it = _observers.begin(); it != _observers.end(); it++)
|
||||||
{
|
{
|
||||||
if (!(*it)->notify(sender, arguments))
|
if (!(*it)->notify(sender, arguments))
|
||||||
{
|
{
|
||||||
// schedule for deletion
|
// schedule for deletion
|
||||||
delMe.push_back(it);
|
delMe.push_back(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
while (!delMe.empty())
|
while (!delMe.empty())
|
||||||
{
|
{
|
||||||
typename std::vector<Iterator>::iterator vit = delMe.end();
|
typename std::vector<Iterator>::iterator vit = delMe.end();
|
||||||
--vit;
|
--vit;
|
||||||
delete **vit;
|
delete **vit;
|
||||||
_observers.erase(*vit);
|
_observers.erase(*vit);
|
||||||
delMe.pop_back();
|
delMe.pop_back();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void add(const TDelegate& delegate)
|
void add(const TDelegate& delegate)
|
||||||
{
|
{
|
||||||
Iterator it = _observers.find(const_cast<TDelegate*>(&delegate));
|
Iterator it = _observers.find(const_cast<TDelegate*>(&delegate));
|
||||||
if (it != _observers.end())
|
if (it != _observers.end())
|
||||||
{
|
{
|
||||||
delete *it;
|
delete *it;
|
||||||
_observers.erase(it);
|
_observers.erase(it);
|
||||||
}
|
}
|
||||||
std::auto_ptr<TDelegate> pDelegate(delegate.clone());
|
std::auto_ptr<TDelegate> pDelegate(delegate.clone());
|
||||||
bool tmp = _observers.insert(pDelegate.get()).second;
|
bool tmp = _observers.insert(pDelegate.get()).second;
|
||||||
poco_assert (tmp);
|
poco_assert (tmp);
|
||||||
pDelegate.release();
|
pDelegate.release();
|
||||||
}
|
}
|
||||||
|
|
||||||
void remove(const TDelegate& delegate)
|
void remove(const TDelegate& delegate)
|
||||||
{
|
{
|
||||||
Iterator it = _observers.find(const_cast<TDelegate*>(&delegate));
|
Iterator it = _observers.find(const_cast<TDelegate*>(&delegate));
|
||||||
if (it != _observers.end())
|
if (it != _observers.end())
|
||||||
{
|
{
|
||||||
delete *it;
|
delete *it;
|
||||||
_observers.erase(it);
|
_observers.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultStrategy& operator = (const DefaultStrategy& s)
|
DefaultStrategy& operator = (const DefaultStrategy& s)
|
||||||
{
|
{
|
||||||
if (this != &s)
|
if (this != &s)
|
||||||
{
|
{
|
||||||
for (ConstIterator it = s._observers.begin(); it != s._observers.end(); ++it)
|
for (ConstIterator it = s._observers.begin(); it != s._observers.end(); ++it)
|
||||||
{
|
{
|
||||||
add(**it);
|
add(**it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
for (Iterator it = _observers.begin(); it != _observers.end(); ++it)
|
for (Iterator it = _observers.begin(); it != _observers.end(); ++it)
|
||||||
{
|
{
|
||||||
delete *it;
|
delete *it;
|
||||||
}
|
}
|
||||||
_observers.clear();
|
_observers.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Delegates _observers;
|
Delegates _observers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,141 +1,141 @@
|
|||||||
//
|
//
|
||||||
// DeflatingStream.h
|
// DeflatingStream.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DeflatingStream.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DeflatingStream.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: ZLibStream
|
// Module: ZLibStream
|
||||||
//
|
//
|
||||||
// Definition of the DeflatingStream class.
|
// Definition of the DeflatingStream 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_DeflatingStream_INCLUDED
|
#ifndef Foundation_DeflatingStream_INCLUDED
|
||||||
#define Foundation_DeflatingStream_INCLUDED
|
#define Foundation_DeflatingStream_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/BufferedStreamBuf.h"
|
#include "Poco/BufferedStreamBuf.h"
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include "Poco/zlib.h"
|
#include "Poco/zlib.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DeflatingStreamBuf: public BufferedStreamBuf
|
class Foundation_API DeflatingStreamBuf: public BufferedStreamBuf
|
||||||
/// This is the streambuf class used by DeflatingInputStream and DeflatingOutputStream.
|
/// This is the streambuf class used by DeflatingInputStream and DeflatingOutputStream.
|
||||||
/// The actual work is delegated to zlib 1.2.1 (see http://www.gzip.org).
|
/// The actual work is delegated to zlib 1.2.1 (see http://www.gzip.org).
|
||||||
/// Both zlib (deflate) streams and gzip streams are supported.
|
/// Both zlib (deflate) streams and gzip streams are supported.
|
||||||
/// Output streams should always call close() to ensure
|
/// Output streams should always call close() to ensure
|
||||||
/// proper completion of compression.
|
/// proper completion of compression.
|
||||||
/// A compression level (0 to 9) can be specified in the constructor.
|
/// A compression level (0 to 9) can be specified in the constructor.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum StreamType
|
enum StreamType
|
||||||
{
|
{
|
||||||
STREAM_ZLIB,
|
STREAM_ZLIB,
|
||||||
STREAM_GZIP
|
STREAM_GZIP
|
||||||
};
|
};
|
||||||
|
|
||||||
DeflatingStreamBuf(std::istream& istr, StreamType type, int level);
|
DeflatingStreamBuf(std::istream& istr, StreamType type, int level);
|
||||||
DeflatingStreamBuf(std::ostream& ostr, StreamType type, int level);
|
DeflatingStreamBuf(std::ostream& ostr, StreamType type, int level);
|
||||||
~DeflatingStreamBuf();
|
~DeflatingStreamBuf();
|
||||||
int close();
|
int close();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int readFromDevice(char* buffer, std::streamsize length);
|
int readFromDevice(char* buffer, std::streamsize length);
|
||||||
int writeToDevice(const char* buffer, std::streamsize length);
|
int writeToDevice(const char* buffer, std::streamsize length);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
STREAM_BUFFER_SIZE = 1024,
|
STREAM_BUFFER_SIZE = 1024,
|
||||||
DEFLATE_BUFFER_SIZE = 32768
|
DEFLATE_BUFFER_SIZE = 32768
|
||||||
};
|
};
|
||||||
|
|
||||||
std::istream* _pIstr;
|
std::istream* _pIstr;
|
||||||
std::ostream* _pOstr;
|
std::ostream* _pOstr;
|
||||||
char* _buffer;
|
char* _buffer;
|
||||||
z_stream _zstr;
|
z_stream _zstr;
|
||||||
bool _eof;
|
bool _eof;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DeflatingIOS: public virtual std::ios
|
class Foundation_API DeflatingIOS: public virtual std::ios
|
||||||
/// The base class for DeflatingOutputStream and DeflatingInputStream.
|
/// The base class for DeflatingOutputStream and DeflatingInputStream.
|
||||||
///
|
///
|
||||||
/// This class is needed to ensure the correct initialization
|
/// This class is needed to ensure the correct initialization
|
||||||
/// order of the stream buffer and base classes.
|
/// order of the stream buffer and base classes.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DeflatingIOS(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
|
DeflatingIOS(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
|
||||||
DeflatingIOS(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
|
DeflatingIOS(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
|
||||||
~DeflatingIOS();
|
~DeflatingIOS();
|
||||||
DeflatingStreamBuf* rdbuf();
|
DeflatingStreamBuf* rdbuf();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DeflatingStreamBuf _buf;
|
DeflatingStreamBuf _buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DeflatingOutputStream: public DeflatingIOS, public std::ostream
|
class Foundation_API DeflatingOutputStream: public DeflatingIOS, public std::ostream
|
||||||
/// This stream compresses all data passing through it
|
/// This stream compresses all data passing through it
|
||||||
/// using zlib's deflate algorithm.
|
/// using zlib's deflate algorithm.
|
||||||
/// After all data has been written to the stream, close()
|
/// After all data has been written to the stream, close()
|
||||||
/// must be called to ensure completion of compression.
|
/// must be called to ensure completion of compression.
|
||||||
/// Example:
|
/// Example:
|
||||||
/// std::ofstream ostr("data.gz", std::ios::binary);
|
/// std::ofstream ostr("data.gz", std::ios::binary);
|
||||||
/// DeflatingOutputStream deflater(ostr, DeflatingStreamBuf::STREAM_GZIP);
|
/// DeflatingOutputStream deflater(ostr, DeflatingStreamBuf::STREAM_GZIP);
|
||||||
/// deflater << "Hello, world!" << std::endl;
|
/// deflater << "Hello, world!" << std::endl;
|
||||||
/// deflater.close();
|
/// deflater.close();
|
||||||
/// ostr.close();
|
/// ostr.close();
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DeflatingOutputStream(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
|
DeflatingOutputStream(std::ostream& ostr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
|
||||||
~DeflatingOutputStream();
|
~DeflatingOutputStream();
|
||||||
int close();
|
int close();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DeflatingInputStream: public DeflatingIOS, public std::istream
|
class Foundation_API DeflatingInputStream: public DeflatingIOS, public std::istream
|
||||||
/// This stream compresses all data passing through it
|
/// This stream compresses all data passing through it
|
||||||
/// using zlib's deflate algorithm.
|
/// using zlib's deflate algorithm.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DeflatingInputStream(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
|
DeflatingInputStream(std::istream& istr, DeflatingStreamBuf::StreamType type = DeflatingStreamBuf::STREAM_ZLIB, int level = Z_DEFAULT_COMPRESSION);
|
||||||
~DeflatingInputStream();
|
~DeflatingInputStream();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DeflatingStream_INCLUDED
|
#endif // Foundation_DeflatingStream_INCLUDED
|
||||||
|
|||||||
@@ -1,109 +1,109 @@
|
|||||||
//
|
//
|
||||||
// Delegate.h
|
// Delegate.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Delegate.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Delegate.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
// Module: Delegate
|
// Module: Delegate
|
||||||
//
|
//
|
||||||
// Implementation of the Delegate template.
|
// Implementation of the Delegate template.
|
||||||
//
|
//
|
||||||
// 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 Foundation_Delegate_INCLUDED
|
#ifndef Foundation_Delegate_INCLUDED
|
||||||
#define Foundation_Delegate_INCLUDED
|
#define Foundation_Delegate_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/AbstractDelegate.h"
|
#include "Poco/AbstractDelegate.h"
|
||||||
#include "Poco/Expire.h"
|
#include "Poco/Expire.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TObj, class TArgs>
|
template <class TObj, class TArgs>
|
||||||
class Delegate: public AbstractDelegate<TArgs>
|
class Delegate: public AbstractDelegate<TArgs>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef void (TObj::*NotifyMethod)(const void*, TArgs&);
|
typedef void (TObj::*NotifyMethod)(const void*, TArgs&);
|
||||||
|
|
||||||
Delegate(TObj* obj, NotifyMethod method):
|
Delegate(TObj* obj, NotifyMethod method):
|
||||||
AbstractDelegate<TArgs>(obj),
|
AbstractDelegate<TArgs>(obj),
|
||||||
_receiverObject(obj),
|
_receiverObject(obj),
|
||||||
_receiverMethod(method)
|
_receiverMethod(method)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Delegate(const Delegate& delegate):
|
Delegate(const Delegate& delegate):
|
||||||
AbstractDelegate<TArgs>(delegate),
|
AbstractDelegate<TArgs>(delegate),
|
||||||
_receiverObject(delegate._receiverObject),
|
_receiverObject(delegate._receiverObject),
|
||||||
_receiverMethod(delegate._receiverMethod)
|
_receiverMethod(delegate._receiverMethod)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~Delegate()
|
~Delegate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Delegate& operator = (const Delegate& delegate)
|
Delegate& operator = (const Delegate& delegate)
|
||||||
{
|
{
|
||||||
if (&delegate != this)
|
if (&delegate != this)
|
||||||
{
|
{
|
||||||
this->_pTarget = delegate._pTarget;
|
this->_pTarget = delegate._pTarget;
|
||||||
this->_receiverObject = delegate._receiverObject;
|
this->_receiverObject = delegate._receiverObject;
|
||||||
this->_receiverMethod = delegate._receiverMethod;
|
this->_receiverMethod = delegate._receiverMethod;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool notify(const void* sender, TArgs& arguments)
|
bool notify(const void* sender, TArgs& arguments)
|
||||||
{
|
{
|
||||||
(_receiverObject->*_receiverMethod)(sender, arguments);
|
(_receiverObject->*_receiverMethod)(sender, arguments);
|
||||||
return true; // a "standard" delegate never expires
|
return true; // a "standard" delegate never expires
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractDelegate<TArgs>* clone() const
|
AbstractDelegate<TArgs>* clone() const
|
||||||
{
|
{
|
||||||
return new Delegate(*this);
|
return new Delegate(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
TObj* _receiverObject;
|
TObj* _receiverObject;
|
||||||
NotifyMethod _receiverMethod;
|
NotifyMethod _receiverMethod;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Delegate();
|
Delegate();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,125 +1,125 @@
|
|||||||
//
|
//
|
||||||
// DigestEngine.h
|
// DigestEngine.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DigestEngine.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DigestEngine.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Crypt
|
// Package: Crypt
|
||||||
// Module: DigestEngine
|
// Module: DigestEngine
|
||||||
//
|
//
|
||||||
// Definition of class DigestEngine.
|
// Definition of class DigestEngine.
|
||||||
//
|
//
|
||||||
// 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_DigestEngine_INCLUDED
|
#ifndef Foundation_DigestEngine_INCLUDED
|
||||||
#define Foundation_DigestEngine_INCLUDED
|
#define Foundation_DigestEngine_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DigestEngine
|
class Foundation_API DigestEngine
|
||||||
/// This class is an abstract base class
|
/// This class is an abstract base class
|
||||||
/// for all classes implementing a message
|
/// for all classes implementing a message
|
||||||
/// digest algorithm, like MD5Engine
|
/// digest algorithm, like MD5Engine
|
||||||
/// and SHA1Engine.
|
/// and SHA1Engine.
|
||||||
/// Call update() repeatedly with data to
|
/// Call update() repeatedly with data to
|
||||||
/// compute the digest from. When done,
|
/// compute the digest from. When done,
|
||||||
/// call digest() to obtain the message
|
/// call digest() to obtain the message
|
||||||
/// digest.
|
/// digest.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::vector<unsigned char> Digest;
|
typedef std::vector<unsigned char> Digest;
|
||||||
|
|
||||||
DigestEngine();
|
DigestEngine();
|
||||||
virtual ~DigestEngine();
|
virtual ~DigestEngine();
|
||||||
|
|
||||||
void update(const void* data, unsigned length);
|
void update(const void* data, unsigned length);
|
||||||
void update(char data);
|
void update(char data);
|
||||||
void update(const std::string& data);
|
void update(const std::string& data);
|
||||||
/// Updates the digest with the given data.
|
/// Updates the digest with the given data.
|
||||||
|
|
||||||
virtual unsigned digestLength() const = 0;
|
virtual unsigned digestLength() const = 0;
|
||||||
/// Returns the length of the digest in bytes.
|
/// Returns the length of the digest in bytes.
|
||||||
|
|
||||||
virtual void reset() = 0;
|
virtual void reset() = 0;
|
||||||
/// Resets the engine so that a new
|
/// Resets the engine so that a new
|
||||||
/// digest can be computed.
|
/// digest can be computed.
|
||||||
|
|
||||||
virtual const Digest& digest() = 0;
|
virtual const Digest& digest() = 0;
|
||||||
/// Finishes the computation of the digest and
|
/// Finishes the computation of the digest and
|
||||||
/// returns the message digest. Resets the engine
|
/// returns the message digest. Resets the engine
|
||||||
/// and can thus only be called once for every digest.
|
/// and can thus only be called once for every digest.
|
||||||
/// The returned reference is valid until the next
|
/// The returned reference is valid until the next
|
||||||
/// time digest() is called, or the engine object is destroyed.
|
/// time digest() is called, or the engine object is destroyed.
|
||||||
|
|
||||||
static std::string digestToHex(const Digest& bytes);
|
static std::string digestToHex(const Digest& bytes);
|
||||||
/// Converts a message digest into a string of hexadecimal numbers.
|
/// Converts a message digest into a string of hexadecimal numbers.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void updateImpl(const void* data, unsigned length) = 0;
|
virtual void updateImpl(const void* data, unsigned length) = 0;
|
||||||
/// Updates the digest with the given data. Must be implemented
|
/// Updates the digest with the given data. Must be implemented
|
||||||
/// by subclasses.
|
/// by subclasses.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DigestEngine(const DigestEngine&);
|
DigestEngine(const DigestEngine&);
|
||||||
DigestEngine& operator = (const DigestEngine&);
|
DigestEngine& operator = (const DigestEngine&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
inline void DigestEngine::update(const void* data, unsigned length)
|
inline void DigestEngine::update(const void* data, unsigned length)
|
||||||
{
|
{
|
||||||
updateImpl(data, length);
|
updateImpl(data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void DigestEngine::update(char data)
|
inline void DigestEngine::update(char data)
|
||||||
{
|
{
|
||||||
updateImpl(&data, 1);
|
updateImpl(&data, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void DigestEngine::update(const std::string& data)
|
inline void DigestEngine::update(const std::string& data)
|
||||||
{
|
{
|
||||||
updateImpl(data.data(), (unsigned) data.size());
|
updateImpl(data.data(), (unsigned) data.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DigestEngine_INCLUDED
|
#endif // Foundation_DigestEngine_INCLUDED
|
||||||
|
|||||||
@@ -1,122 +1,122 @@
|
|||||||
//
|
//
|
||||||
// DigestStream.h
|
// DigestStream.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DigestStream.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DigestStream.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Crypt
|
// Package: Crypt
|
||||||
// Module: DigestStream
|
// Module: DigestStream
|
||||||
//
|
//
|
||||||
// Definition of classes DigestInputStream and DigestOutputStream.
|
// Definition of classes DigestInputStream and DigestOutputStream.
|
||||||
//
|
//
|
||||||
// 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_DigestStream_INCLUDED
|
#ifndef Foundation_DigestStream_INCLUDED
|
||||||
#define Foundation_DigestStream_INCLUDED
|
#define Foundation_DigestStream_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/BufferedStreamBuf.h"
|
#include "Poco/BufferedStreamBuf.h"
|
||||||
#include "Poco/DigestEngine.h"
|
#include "Poco/DigestEngine.h"
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DigestBuf: public BufferedStreamBuf
|
class Foundation_API DigestBuf: public BufferedStreamBuf
|
||||||
/// This streambuf computes a digest of all data going
|
/// This streambuf computes a digest of all data going
|
||||||
/// through it.
|
/// through it.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DigestBuf(DigestEngine& eng);
|
DigestBuf(DigestEngine& eng);
|
||||||
DigestBuf(DigestEngine& eng, std::istream& istr);
|
DigestBuf(DigestEngine& eng, std::istream& istr);
|
||||||
DigestBuf(DigestEngine& eng, std::ostream& ostr);
|
DigestBuf(DigestEngine& eng, std::ostream& ostr);
|
||||||
~DigestBuf();
|
~DigestBuf();
|
||||||
int readFromDevice(char* buffer, std::streamsize length);
|
int readFromDevice(char* buffer, std::streamsize length);
|
||||||
int writeToDevice(const char* buffer, std::streamsize length);
|
int writeToDevice(const char* buffer, std::streamsize length);
|
||||||
void close();
|
void close();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DigestEngine& _eng;
|
DigestEngine& _eng;
|
||||||
std::istream* _pIstr;
|
std::istream* _pIstr;
|
||||||
std::ostream* _pOstr;
|
std::ostream* _pOstr;
|
||||||
static const int BUFFER_SIZE;
|
static const int BUFFER_SIZE;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DigestIOS: public virtual std::ios
|
class Foundation_API DigestIOS: public virtual std::ios
|
||||||
/// The base class for DigestInputStream and DigestOutputStream.
|
/// The base class for DigestInputStream and DigestOutputStream.
|
||||||
///
|
///
|
||||||
/// This class is needed to ensure the correct initialization
|
/// This class is needed to ensure the correct initialization
|
||||||
/// order of the stream buffer and base classes.
|
/// order of the stream buffer and base classes.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DigestIOS(DigestEngine& eng);
|
DigestIOS(DigestEngine& eng);
|
||||||
DigestIOS(DigestEngine& eng, std::istream& istr);
|
DigestIOS(DigestEngine& eng, std::istream& istr);
|
||||||
DigestIOS(DigestEngine& eng, std::ostream& ostr);
|
DigestIOS(DigestEngine& eng, std::ostream& ostr);
|
||||||
~DigestIOS();
|
~DigestIOS();
|
||||||
DigestBuf* rdbuf();
|
DigestBuf* rdbuf();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
DigestBuf _buf;
|
DigestBuf _buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DigestInputStream: public DigestIOS, public std::istream
|
class Foundation_API DigestInputStream: public DigestIOS, public std::istream
|
||||||
/// This istream computes a digest of
|
/// This istream computes a digest of
|
||||||
/// all the data passing through it,
|
/// all the data passing through it,
|
||||||
/// using a DigestEngine.
|
/// using a DigestEngine.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DigestInputStream(DigestEngine& eng, std::istream& istr);
|
DigestInputStream(DigestEngine& eng, std::istream& istr);
|
||||||
~DigestInputStream();
|
~DigestInputStream();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DigestOutputStream: public DigestIOS, public std::ostream
|
class Foundation_API DigestOutputStream: public DigestIOS, public std::ostream
|
||||||
/// This ostream computes a digest of
|
/// This ostream computes a digest of
|
||||||
/// all the data passing through it,
|
/// all the data passing through it,
|
||||||
/// using a DigestEngine.
|
/// using a DigestEngine.
|
||||||
/// To ensure that all data has been incorporated
|
/// To ensure that all data has been incorporated
|
||||||
/// into the digest, call close() or flush() before
|
/// into the digest, call close() or flush() before
|
||||||
/// you obtain the digest from the digest engine.
|
/// you obtain the digest from the digest engine.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DigestOutputStream(DigestEngine& eng);
|
DigestOutputStream(DigestEngine& eng);
|
||||||
DigestOutputStream(DigestEngine& eng, std::ostream& ostr);
|
DigestOutputStream(DigestEngine& eng, std::ostream& ostr);
|
||||||
~DigestOutputStream();
|
~DigestOutputStream();
|
||||||
void close();
|
void close();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DigestStream_INCLUDED
|
#endif // Foundation_DigestStream_INCLUDED
|
||||||
|
|||||||
@@ -1,173 +1,173 @@
|
|||||||
//
|
//
|
||||||
// DirectoryIterator.h
|
// DirectoryIterator.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Filesystem
|
// Package: Filesystem
|
||||||
// Module: DirectoryIterator
|
// Module: DirectoryIterator
|
||||||
//
|
//
|
||||||
// Definition of the DirectoryIterator class.
|
// Definition of the DirectoryIterator 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_DirectoryIterator_INCLUDED
|
#ifndef Foundation_DirectoryIterator_INCLUDED
|
||||||
#define Foundation_DirectoryIterator_INCLUDED
|
#define Foundation_DirectoryIterator_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/File.h"
|
#include "Poco/File.h"
|
||||||
#include "Poco/Path.h"
|
#include "Poco/Path.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class DirectoryIteratorImpl;
|
class DirectoryIteratorImpl;
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DirectoryIterator
|
class Foundation_API DirectoryIterator
|
||||||
/// The DirectoryIterator class is used to enumerate
|
/// The DirectoryIterator class is used to enumerate
|
||||||
/// all files in a directory.
|
/// all files in a directory.
|
||||||
///
|
///
|
||||||
/// DirectoryIterator has some limitations:
|
/// DirectoryIterator has some limitations:
|
||||||
/// * only forward iteration (++) is supported
|
/// * only forward iteration (++) is supported
|
||||||
/// * an iterator copied from another one will always
|
/// * an iterator copied from another one will always
|
||||||
/// point to the same file as the original iterator,
|
/// point to the same file as the original iterator,
|
||||||
/// even is the original iterator has been advanced
|
/// even is the original iterator has been advanced
|
||||||
/// (all copies of an iterator share their state with
|
/// (all copies of an iterator share their state with
|
||||||
/// the original iterator)
|
/// the original iterator)
|
||||||
/// * because of this you should only use the prefix
|
/// * because of this you should only use the prefix
|
||||||
/// increment operator
|
/// increment operator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DirectoryIterator();
|
DirectoryIterator();
|
||||||
/// Creates the end iterator.
|
/// Creates the end iterator.
|
||||||
|
|
||||||
DirectoryIterator(const std::string& path);
|
DirectoryIterator(const std::string& path);
|
||||||
/// Creates a directory iterator for the given path.
|
/// Creates a directory iterator for the given path.
|
||||||
|
|
||||||
DirectoryIterator(const DirectoryIterator& iterator);
|
DirectoryIterator(const DirectoryIterator& iterator);
|
||||||
/// Creates a directory iterator for the given path.
|
/// Creates a directory iterator for the given path.
|
||||||
|
|
||||||
DirectoryIterator(const File& file);
|
DirectoryIterator(const File& file);
|
||||||
/// Creates a directory iterator for the given file.
|
/// Creates a directory iterator for the given file.
|
||||||
|
|
||||||
DirectoryIterator(const Path& path);
|
DirectoryIterator(const Path& path);
|
||||||
/// Creates a directory iterator for the given path.
|
/// Creates a directory iterator for the given path.
|
||||||
|
|
||||||
~DirectoryIterator();
|
~DirectoryIterator();
|
||||||
/// Destroys the DirectoryIterator.
|
/// Destroys the DirectoryIterator.
|
||||||
|
|
||||||
const std::string& name() const;
|
const std::string& name() const;
|
||||||
/// Returns the current filename.
|
/// Returns the current filename.
|
||||||
|
|
||||||
const Path& path() const;
|
const Path& path() const;
|
||||||
/// Returns the current path.
|
/// Returns the current path.
|
||||||
|
|
||||||
DirectoryIterator& operator = (const DirectoryIterator& it);
|
DirectoryIterator& operator = (const DirectoryIterator& it);
|
||||||
DirectoryIterator& operator = (const File& file);
|
DirectoryIterator& operator = (const File& file);
|
||||||
DirectoryIterator& operator = (const Path& path);
|
DirectoryIterator& operator = (const Path& path);
|
||||||
DirectoryIterator& operator = (const std::string& path);
|
DirectoryIterator& operator = (const std::string& path);
|
||||||
|
|
||||||
DirectoryIterator& operator ++ (); // prefix
|
DirectoryIterator& operator ++ (); // prefix
|
||||||
|
|
||||||
//@ deprecated
|
//@ deprecated
|
||||||
DirectoryIterator operator ++ (int); // postfix
|
DirectoryIterator operator ++ (int); // postfix
|
||||||
/// Please use the prefix increment operator instead.
|
/// Please use the prefix increment operator instead.
|
||||||
|
|
||||||
const File& operator * () const;
|
const File& operator * () const;
|
||||||
File& operator * ();
|
File& operator * ();
|
||||||
const File* operator -> () const;
|
const File* operator -> () const;
|
||||||
File* operator -> ();
|
File* operator -> ();
|
||||||
|
|
||||||
bool operator == (const DirectoryIterator& iterator) const;
|
bool operator == (const DirectoryIterator& iterator) const;
|
||||||
bool operator != (const DirectoryIterator& iterator) const;
|
bool operator != (const DirectoryIterator& iterator) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Path _path;
|
Path _path;
|
||||||
File _file;
|
File _file;
|
||||||
DirectoryIteratorImpl* _pImpl;
|
DirectoryIteratorImpl* _pImpl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline const std::string& DirectoryIterator::name() const
|
inline const std::string& DirectoryIterator::name() const
|
||||||
{
|
{
|
||||||
return _path.getFileName();
|
return _path.getFileName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const Path& DirectoryIterator::path() const
|
inline const Path& DirectoryIterator::path() const
|
||||||
{
|
{
|
||||||
return _path;
|
return _path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const File& DirectoryIterator::operator * () const
|
inline const File& DirectoryIterator::operator * () const
|
||||||
{
|
{
|
||||||
return _file;
|
return _file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline File& DirectoryIterator::operator * ()
|
inline File& DirectoryIterator::operator * ()
|
||||||
{
|
{
|
||||||
return _file;
|
return _file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const File* DirectoryIterator::operator -> () const
|
inline const File* DirectoryIterator::operator -> () const
|
||||||
{
|
{
|
||||||
return &_file;
|
return &_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline File* DirectoryIterator::operator -> ()
|
inline File* DirectoryIterator::operator -> ()
|
||||||
{
|
{
|
||||||
return &_file;
|
return &_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool DirectoryIterator::operator == (const DirectoryIterator& iterator) const
|
inline bool DirectoryIterator::operator == (const DirectoryIterator& iterator) const
|
||||||
{
|
{
|
||||||
return name() == iterator.name();
|
return name() == iterator.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool DirectoryIterator::operator != (const DirectoryIterator& iterator) const
|
inline bool DirectoryIterator::operator != (const DirectoryIterator& iterator) const
|
||||||
{
|
{
|
||||||
return name() != iterator.name();
|
return name() != iterator.name();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DirectoryIterator_INCLUDED
|
#endif // Foundation_DirectoryIterator_INCLUDED
|
||||||
|
|||||||
@@ -1,94 +1,94 @@
|
|||||||
//
|
//
|
||||||
// DirectoryIterator_UNIX.h
|
// DirectoryIterator_UNIX.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator_UNIX.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator_UNIX.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Filesystem
|
// Package: Filesystem
|
||||||
// Module: DirectoryIterator
|
// Module: DirectoryIterator
|
||||||
//
|
//
|
||||||
// Definition of the DirectoryIteratorImpl class for UNIX.
|
// Definition of the DirectoryIteratorImpl class for UNIX.
|
||||||
//
|
//
|
||||||
// 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_DirectoryIterator_UNIX_INCLUDED
|
#ifndef Foundation_DirectoryIterator_UNIX_INCLUDED
|
||||||
#define Foundation_DirectoryIterator_UNIX_INCLUDED
|
#define Foundation_DirectoryIterator_UNIX_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DirectoryIteratorImpl
|
class Foundation_API DirectoryIteratorImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DirectoryIteratorImpl(const std::string& path);
|
DirectoryIteratorImpl(const std::string& path);
|
||||||
~DirectoryIteratorImpl();
|
~DirectoryIteratorImpl();
|
||||||
|
|
||||||
void duplicate();
|
void duplicate();
|
||||||
void release();
|
void release();
|
||||||
|
|
||||||
const std::string& get() const;
|
const std::string& get() const;
|
||||||
const std::string& next();
|
const std::string& next();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DIR* _pDir;
|
DIR* _pDir;
|
||||||
std::string _current;
|
std::string _current;
|
||||||
int _rc;
|
int _rc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
const std::string& DirectoryIteratorImpl::get() const
|
const std::string& DirectoryIteratorImpl::get() const
|
||||||
{
|
{
|
||||||
return _current;
|
return _current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void DirectoryIteratorImpl::duplicate()
|
inline void DirectoryIteratorImpl::duplicate()
|
||||||
{
|
{
|
||||||
++_rc;
|
++_rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void DirectoryIteratorImpl::release()
|
inline void DirectoryIteratorImpl::release()
|
||||||
{
|
{
|
||||||
if (--_rc == 0)
|
if (--_rc == 0)
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DirectoryIterator_UNIX_INCLUDED
|
#endif // Foundation_DirectoryIterator_UNIX_INCLUDED
|
||||||
|
|||||||
@@ -1,97 +1,97 @@
|
|||||||
//
|
//
|
||||||
// DirectoryIterator_VMS.h
|
// DirectoryIterator_VMS.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator_VMS.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator_VMS.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Filesystem
|
// Package: Filesystem
|
||||||
// Module: DirectoryIterator
|
// Module: DirectoryIterator
|
||||||
//
|
//
|
||||||
// Definition of the DirectoryIteratorImpl class for OpenVMS.
|
// Definition of the DirectoryIteratorImpl class for OpenVMS.
|
||||||
//
|
//
|
||||||
// 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_DirectoryIterator_VMS_INCLUDED
|
#ifndef Foundation_DirectoryIterator_VMS_INCLUDED
|
||||||
#define Foundation_DirectoryIterator_VMS_INCLUDED
|
#define Foundation_DirectoryIterator_VMS_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <rms.h>
|
#include <rms.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DirectoryIteratorImpl
|
class Foundation_API DirectoryIteratorImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DirectoryIteratorImpl(const std::string& path);
|
DirectoryIteratorImpl(const std::string& path);
|
||||||
~DirectoryIteratorImpl();
|
~DirectoryIteratorImpl();
|
||||||
|
|
||||||
void duplicate();
|
void duplicate();
|
||||||
void release();
|
void release();
|
||||||
|
|
||||||
const std::string& get() const;
|
const std::string& get() const;
|
||||||
const std::string& next();
|
const std::string& next();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct FAB _fab;
|
struct FAB _fab;
|
||||||
struct NAM _nam;
|
struct NAM _nam;
|
||||||
std::string _search;
|
std::string _search;
|
||||||
char _spec[255];
|
char _spec[255];
|
||||||
std::string _current;
|
std::string _current;
|
||||||
int _rc;
|
int _rc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
const std::string& DirectoryIteratorImpl::get() const
|
const std::string& DirectoryIteratorImpl::get() const
|
||||||
{
|
{
|
||||||
return _current;
|
return _current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void DirectoryIteratorImpl::duplicate()
|
inline void DirectoryIteratorImpl::duplicate()
|
||||||
{
|
{
|
||||||
++_rc;
|
++_rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void DirectoryIteratorImpl::release()
|
inline void DirectoryIteratorImpl::release()
|
||||||
{
|
{
|
||||||
if (--_rc == 0)
|
if (--_rc == 0)
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DirectoryIterator_VMS_INCLUDED
|
#endif // Foundation_DirectoryIterator_VMS_INCLUDED
|
||||||
|
|||||||
@@ -1,95 +1,95 @@
|
|||||||
//
|
//
|
||||||
// DirectoryIterator_WIN32.h
|
// DirectoryIterator_WIN32.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator_WIN32.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator_WIN32.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Filesystem
|
// Package: Filesystem
|
||||||
// Module: DirectoryIterator
|
// Module: DirectoryIterator
|
||||||
//
|
//
|
||||||
// Definition of the DirectoryIteratorImpl class for WIN32.
|
// Definition of the DirectoryIteratorImpl class for WIN32.
|
||||||
//
|
//
|
||||||
// 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_DirectoryIterator_WIN32_INCLUDED
|
#ifndef Foundation_DirectoryIterator_WIN32_INCLUDED
|
||||||
#define Foundation_DirectoryIterator_WIN32_INCLUDED
|
#define Foundation_DirectoryIterator_WIN32_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/UnWindows.h"
|
#include "Poco/UnWindows.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DirectoryIteratorImpl
|
class Foundation_API DirectoryIteratorImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DirectoryIteratorImpl(const std::string& path);
|
DirectoryIteratorImpl(const std::string& path);
|
||||||
~DirectoryIteratorImpl();
|
~DirectoryIteratorImpl();
|
||||||
|
|
||||||
void duplicate();
|
void duplicate();
|
||||||
void release();
|
void release();
|
||||||
|
|
||||||
const std::string& get() const;
|
const std::string& get() const;
|
||||||
const std::string& next();
|
const std::string& next();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HANDLE _fh;
|
HANDLE _fh;
|
||||||
WIN32_FIND_DATA _fd;
|
WIN32_FIND_DATA _fd;
|
||||||
std::string _current;
|
std::string _current;
|
||||||
int _rc;
|
int _rc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
const std::string& DirectoryIteratorImpl::get() const
|
const std::string& DirectoryIteratorImpl::get() const
|
||||||
{
|
{
|
||||||
return _current;
|
return _current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void DirectoryIteratorImpl::duplicate()
|
inline void DirectoryIteratorImpl::duplicate()
|
||||||
{
|
{
|
||||||
++_rc;
|
++_rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void DirectoryIteratorImpl::release()
|
inline void DirectoryIteratorImpl::release()
|
||||||
{
|
{
|
||||||
if (--_rc == 0)
|
if (--_rc == 0)
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DirectoryIterator_WIN32_INCLUDED
|
#endif // Foundation_DirectoryIterator_WIN32_INCLUDED
|
||||||
|
|||||||
@@ -1,95 +1,95 @@
|
|||||||
//
|
//
|
||||||
// DirectoryIterator_WIN32U.h
|
// DirectoryIterator_WIN32U.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator_WIN32U.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator_WIN32U.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Filesystem
|
// Package: Filesystem
|
||||||
// Module: DirectoryIterator
|
// Module: DirectoryIterator
|
||||||
//
|
//
|
||||||
// Definition of the DirectoryIteratorImpl class for WIN32.
|
// Definition of the DirectoryIteratorImpl class for WIN32.
|
||||||
//
|
//
|
||||||
// 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 Foundation_DirectoryIterator_WIN32U_INCLUDED
|
#ifndef Foundation_DirectoryIterator_WIN32U_INCLUDED
|
||||||
#define Foundation_DirectoryIterator_WIN32U_INCLUDED
|
#define Foundation_DirectoryIterator_WIN32U_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/UnWindows.h"
|
#include "Poco/UnWindows.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API DirectoryIteratorImpl
|
class Foundation_API DirectoryIteratorImpl
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
DirectoryIteratorImpl(const std::string& path);
|
DirectoryIteratorImpl(const std::string& path);
|
||||||
~DirectoryIteratorImpl();
|
~DirectoryIteratorImpl();
|
||||||
|
|
||||||
void duplicate();
|
void duplicate();
|
||||||
void release();
|
void release();
|
||||||
|
|
||||||
const std::string& get() const;
|
const std::string& get() const;
|
||||||
const std::string& next();
|
const std::string& next();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HANDLE _fh;
|
HANDLE _fh;
|
||||||
WIN32_FIND_DATAW _fd;
|
WIN32_FIND_DATAW _fd;
|
||||||
std::string _current;
|
std::string _current;
|
||||||
int _rc;
|
int _rc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
const std::string& DirectoryIteratorImpl::get() const
|
const std::string& DirectoryIteratorImpl::get() const
|
||||||
{
|
{
|
||||||
return _current;
|
return _current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void DirectoryIteratorImpl::duplicate()
|
inline void DirectoryIteratorImpl::duplicate()
|
||||||
{
|
{
|
||||||
++_rc;
|
++_rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void DirectoryIteratorImpl::release()
|
inline void DirectoryIteratorImpl::release()
|
||||||
{
|
{
|
||||||
if (--_rc == 0)
|
if (--_rc == 0)
|
||||||
delete this;
|
delete this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DirectoryIterator_WIN32U_INCLUDED
|
#endif // Foundation_DirectoryIterator_WIN32U_INCLUDED
|
||||||
|
|||||||
@@ -1,158 +1,158 @@
|
|||||||
//
|
//
|
||||||
// DynamicFactory.h
|
// DynamicFactory.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/DynamicFactory.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/DynamicFactory.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: DynamicFactory
|
// Module: DynamicFactory
|
||||||
//
|
//
|
||||||
// Definition of the DynamicFactory class.
|
// Definition of the DynamicFactory 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_DynamicFactory_INCLUDED
|
#ifndef Foundation_DynamicFactory_INCLUDED
|
||||||
#define Foundation_DynamicFactory_INCLUDED
|
#define Foundation_DynamicFactory_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Instantiator.h"
|
#include "Poco/Instantiator.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include "Poco/Mutex.h"
|
#include "Poco/Mutex.h"
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class Base>
|
template <class Base>
|
||||||
class DynamicFactory
|
class DynamicFactory
|
||||||
/// A factory that creates objects by class name.
|
/// A factory that creates objects by class name.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef AbstractInstantiator<Base> AbstractFactory;
|
typedef AbstractInstantiator<Base> AbstractFactory;
|
||||||
|
|
||||||
DynamicFactory()
|
DynamicFactory()
|
||||||
/// Creates the DynamicFactory.
|
/// Creates the DynamicFactory.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~DynamicFactory()
|
~DynamicFactory()
|
||||||
/// Destroys the DynamicFactory and deletes the instantiators for
|
/// Destroys the DynamicFactory and deletes the instantiators for
|
||||||
/// all registered classes.
|
/// all registered classes.
|
||||||
{
|
{
|
||||||
for (typename FactoryMap::iterator it = _map.begin(); it != _map.end(); ++it)
|
for (typename FactoryMap::iterator it = _map.begin(); it != _map.end(); ++it)
|
||||||
{
|
{
|
||||||
delete it->second;
|
delete it->second;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Base* createInstance(const std::string& className) const
|
Base* createInstance(const std::string& className) const
|
||||||
/// Creates a new instance of the class with the given name.
|
/// Creates a new instance of the class with the given name.
|
||||||
/// The class must have been registered with registerClass.
|
/// The class must have been registered with registerClass.
|
||||||
/// If the class name is unknown, a NotFoundException is thrown.
|
/// If the class name is unknown, a NotFoundException is thrown.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
typename FactoryMap::const_iterator it = _map.find(className);
|
typename FactoryMap::const_iterator it = _map.find(className);
|
||||||
if (it != _map.end())
|
if (it != _map.end())
|
||||||
return it->second->createInstance();
|
return it->second->createInstance();
|
||||||
else
|
else
|
||||||
throw NotFoundException(className);
|
throw NotFoundException(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class C>
|
template <class C>
|
||||||
void registerClass(const std::string& className)
|
void registerClass(const std::string& className)
|
||||||
/// Registers the instantiator for the given class with the DynamicFactory.
|
/// Registers the instantiator for the given class with the DynamicFactory.
|
||||||
/// The DynamicFactory takes ownership of the instantiator and deletes
|
/// The DynamicFactory takes ownership of the instantiator and deletes
|
||||||
/// it when it's no longer used.
|
/// it when it's no longer used.
|
||||||
/// If the class has already been registered, an ExistsException is thrown
|
/// If the class has already been registered, an ExistsException is thrown
|
||||||
/// and the instantiator is deleted.
|
/// and the instantiator is deleted.
|
||||||
{
|
{
|
||||||
registerClass(className, new Instantiator<C, Base>);
|
registerClass(className, new Instantiator<C, Base>);
|
||||||
}
|
}
|
||||||
|
|
||||||
void registerClass(const std::string& className, AbstractFactory* pAbstractFactory)
|
void registerClass(const std::string& className, AbstractFactory* pAbstractFactory)
|
||||||
/// Registers the instantiator for the given class with the DynamicFactory.
|
/// Registers the instantiator for the given class with the DynamicFactory.
|
||||||
/// The DynamicFactory takes ownership of the instantiator and deletes
|
/// The DynamicFactory takes ownership of the instantiator and deletes
|
||||||
/// it when it's no longer used.
|
/// it when it's no longer used.
|
||||||
/// If the class has already been registered, an ExistsException is thrown
|
/// If the class has already been registered, an ExistsException is thrown
|
||||||
/// and the instantiator is deleted.
|
/// and the instantiator is deleted.
|
||||||
{
|
{
|
||||||
poco_check_ptr (pAbstractFactory);
|
poco_check_ptr (pAbstractFactory);
|
||||||
|
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
std::auto_ptr<AbstractFactory> ptr(pAbstractFactory);
|
std::auto_ptr<AbstractFactory> ptr(pAbstractFactory);
|
||||||
typename FactoryMap::iterator it = _map.find(className);
|
typename FactoryMap::iterator it = _map.find(className);
|
||||||
if (it == _map.end())
|
if (it == _map.end())
|
||||||
_map[className] = ptr.release();
|
_map[className] = ptr.release();
|
||||||
else
|
else
|
||||||
throw ExistsException(className);
|
throw ExistsException(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
void unregisterClass(const std::string& className)
|
void unregisterClass(const std::string& className)
|
||||||
/// Unregisters the given class and deletes the instantiator
|
/// Unregisters the given class and deletes the instantiator
|
||||||
/// for the class.
|
/// for the class.
|
||||||
/// Throws a NotFoundException if the class has not been registered.
|
/// Throws a NotFoundException if the class has not been registered.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
typename FactoryMap::iterator it = _map.find(className);
|
typename FactoryMap::iterator it = _map.find(className);
|
||||||
if (it != _map.end())
|
if (it != _map.end())
|
||||||
{
|
{
|
||||||
delete it->second;
|
delete it->second;
|
||||||
_map.erase(it);
|
_map.erase(it);
|
||||||
}
|
}
|
||||||
else throw NotFoundException(className);
|
else throw NotFoundException(className);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isClass(const std::string& className) const
|
bool isClass(const std::string& className) const
|
||||||
/// Returns true iff the given class has been registered.
|
/// Returns true iff the given class has been registered.
|
||||||
{
|
{
|
||||||
FastMutex::ScopedLock lock(_mutex);
|
FastMutex::ScopedLock lock(_mutex);
|
||||||
|
|
||||||
return _map.find(className) != _map.end();
|
return _map.find(className) != _map.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DynamicFactory(const DynamicFactory&);
|
DynamicFactory(const DynamicFactory&);
|
||||||
DynamicFactory& operator = (const DynamicFactory&);
|
DynamicFactory& operator = (const DynamicFactory&);
|
||||||
|
|
||||||
typedef std::map<std::string, AbstractFactory*> FactoryMap;
|
typedef std::map<std::string, AbstractFactory*> FactoryMap;
|
||||||
|
|
||||||
FactoryMap _map;
|
FactoryMap _map;
|
||||||
mutable FastMutex _mutex;
|
mutable FastMutex _mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_DynamicFactory_INCLUDED
|
#endif // Foundation_DynamicFactory_INCLUDED
|
||||||
|
|||||||
@@ -1,142 +1,142 @@
|
|||||||
//
|
//
|
||||||
// ErrorHandler.h
|
// ErrorHandler.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ErrorHandler.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ErrorHandler.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
// Module: ErrorHandler
|
// Module: ErrorHandler
|
||||||
//
|
//
|
||||||
// Definition of the ErrorHandler class.
|
// Definition of the ErrorHandler 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 Foundation_ErrorHandler_INCLUDED
|
#ifndef Foundation_ErrorHandler_INCLUDED
|
||||||
#define Foundation_ErrorHandler_INCLUDED
|
#define Foundation_ErrorHandler_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include "Poco/Mutex.h"
|
#include "Poco/Mutex.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API ErrorHandler
|
class Foundation_API ErrorHandler
|
||||||
/// This is the base class for thread error handlers.
|
/// This is the base class for thread error handlers.
|
||||||
///
|
///
|
||||||
/// An unhandled exception that causes a thread to terminate is usually
|
/// An unhandled exception that causes a thread to terminate is usually
|
||||||
/// silently ignored, since the class library cannot do anything meaningful
|
/// silently ignored, since the class library cannot do anything meaningful
|
||||||
/// about it.
|
/// about it.
|
||||||
///
|
///
|
||||||
/// The Thread class provides the possibility to register a
|
/// The Thread class provides the possibility to register a
|
||||||
/// global ErrorHandler that is invoked whenever a thread has
|
/// global ErrorHandler that is invoked whenever a thread has
|
||||||
/// been terminated by an unhandled exception.
|
/// been terminated by an unhandled exception.
|
||||||
/// The ErrorHandler must be derived from this class and can
|
/// The ErrorHandler must be derived from this class and can
|
||||||
/// provide implementations of all three handleException() overloads.
|
/// provide implementations of all three handleException() overloads.
|
||||||
///
|
///
|
||||||
/// The ErrorHandler is always invoked within the context of
|
/// The ErrorHandler is always invoked within the context of
|
||||||
/// the offending thread.
|
/// the offending thread.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ErrorHandler();
|
ErrorHandler();
|
||||||
/// Creates the ErrorHandler.
|
/// Creates the ErrorHandler.
|
||||||
|
|
||||||
virtual ~ErrorHandler();
|
virtual ~ErrorHandler();
|
||||||
/// Destroys the ErrorHandler.
|
/// Destroys the ErrorHandler.
|
||||||
|
|
||||||
virtual void exception(const Exception& exc);
|
virtual void exception(const Exception& exc);
|
||||||
/// Called when a Poco::Exception (or a subclass)
|
/// Called when a Poco::Exception (or a subclass)
|
||||||
/// caused the thread to terminate.
|
/// caused the thread to terminate.
|
||||||
///
|
///
|
||||||
/// This method should not throw any exception - it would
|
/// This method should not throw any exception - it would
|
||||||
/// be silently ignored.
|
/// be silently ignored.
|
||||||
///
|
///
|
||||||
/// The default implementation just breaks into the debugger.
|
/// The default implementation just breaks into the debugger.
|
||||||
|
|
||||||
virtual void exception(const std::exception& exc);
|
virtual void exception(const std::exception& exc);
|
||||||
/// Called when a std::exception (or a subclass)
|
/// Called when a std::exception (or a subclass)
|
||||||
/// caused the thread to terminate.
|
/// caused the thread to terminate.
|
||||||
///
|
///
|
||||||
/// This method should not throw any exception - it would
|
/// This method should not throw any exception - it would
|
||||||
/// be silently ignored.
|
/// be silently ignored.
|
||||||
///
|
///
|
||||||
/// The default implementation just breaks into the debugger.
|
/// The default implementation just breaks into the debugger.
|
||||||
|
|
||||||
virtual void exception();
|
virtual void exception();
|
||||||
/// Called when an exception that is neither a
|
/// Called when an exception that is neither a
|
||||||
/// Poco::Exception nor a std::exception caused
|
/// Poco::Exception nor a std::exception caused
|
||||||
/// the thread to terminate.
|
/// the thread to terminate.
|
||||||
///
|
///
|
||||||
/// This method should not throw any exception - it would
|
/// This method should not throw any exception - it would
|
||||||
/// be silently ignored.
|
/// be silently ignored.
|
||||||
///
|
///
|
||||||
/// The default implementation just breaks into the debugger.
|
/// The default implementation just breaks into the debugger.
|
||||||
|
|
||||||
static void handle(const Exception& exc);
|
static void handle(const Exception& exc);
|
||||||
/// Invokes the currently registered ErrorHandler.
|
/// Invokes the currently registered ErrorHandler.
|
||||||
|
|
||||||
static void handle(const std::exception& exc);
|
static void handle(const std::exception& exc);
|
||||||
/// Invokes the currently registered ErrorHandler.
|
/// Invokes the currently registered ErrorHandler.
|
||||||
|
|
||||||
static void handle();
|
static void handle();
|
||||||
/// Invokes the currently registered ErrorHandler.
|
/// Invokes the currently registered ErrorHandler.
|
||||||
|
|
||||||
static ErrorHandler* set(ErrorHandler* pHandler);
|
static ErrorHandler* set(ErrorHandler* pHandler);
|
||||||
/// Registers the given handler as the current error handler.
|
/// Registers the given handler as the current error handler.
|
||||||
///
|
///
|
||||||
/// Returns the previously registered handler.
|
/// Returns the previously registered handler.
|
||||||
|
|
||||||
static ErrorHandler* get();
|
static ErrorHandler* get();
|
||||||
/// Returns a pointer to the currently registered
|
/// Returns a pointer to the currently registered
|
||||||
/// ErrorHandler.
|
/// ErrorHandler.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static ErrorHandler* defaultHandler();
|
static ErrorHandler* defaultHandler();
|
||||||
/// Returns the default ErrorHandler.
|
/// Returns the default ErrorHandler.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static ErrorHandler* _pHandler;
|
static ErrorHandler* _pHandler;
|
||||||
static FastMutex _mutex;
|
static FastMutex _mutex;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline ErrorHandler* ErrorHandler::get()
|
inline ErrorHandler* ErrorHandler::get()
|
||||||
{
|
{
|
||||||
return _pHandler;
|
return _pHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_ErrorHandler_INCLUDED
|
#endif // Foundation_ErrorHandler_INCLUDED
|
||||||
|
|||||||
@@ -1,143 +1,143 @@
|
|||||||
//
|
//
|
||||||
// Event.h
|
// Event.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Event.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Event.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
// Module: Event
|
// Module: Event
|
||||||
//
|
//
|
||||||
// Definition of the Event class.
|
// Definition of the Event 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_Event_INCLUDED
|
#ifndef Foundation_Event_INCLUDED
|
||||||
#define Foundation_Event_INCLUDED
|
#define Foundation_Event_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||||
#include "Poco/Event_WIN32.h"
|
#include "Poco/Event_WIN32.h"
|
||||||
#else
|
#else
|
||||||
#include "Poco/Event_POSIX.h"
|
#include "Poco/Event_POSIX.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Event: private EventImpl
|
class Foundation_API Event: private EventImpl
|
||||||
/// An Event is a synchronization object that
|
/// An Event is a synchronization object that
|
||||||
/// allows one thread to signal one or more
|
/// allows one thread to signal one or more
|
||||||
/// other threads that a certain event
|
/// other threads that a certain event
|
||||||
/// has happened.
|
/// has happened.
|
||||||
/// Usually, one thread signals an event,
|
/// Usually, one thread signals an event,
|
||||||
/// while one or more other threads wait
|
/// while one or more other threads wait
|
||||||
/// for an event to become signalled.
|
/// for an event to become signalled.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Event(bool autoReset = true);
|
Event(bool autoReset = true);
|
||||||
/// Creates the event. If autoReset is true,
|
/// Creates the event. If autoReset is true,
|
||||||
/// the event is automatically reset after
|
/// the event is automatically reset after
|
||||||
/// a wait() successfully returns.
|
/// a wait() successfully returns.
|
||||||
|
|
||||||
~Event();
|
~Event();
|
||||||
/// Destroys the event.
|
/// Destroys the event.
|
||||||
|
|
||||||
void set();
|
void set();
|
||||||
/// Signals the event. If autoReset is true,
|
/// Signals the event. If autoReset is true,
|
||||||
/// only one thread waiting for the event
|
/// only one thread waiting for the event
|
||||||
/// can resume execution.
|
/// can resume execution.
|
||||||
/// If autoReset is false, all waiting threads
|
/// If autoReset is false, all waiting threads
|
||||||
/// can resume execution.
|
/// can resume execution.
|
||||||
|
|
||||||
void wait();
|
void wait();
|
||||||
/// Waits for the event to become signalled.
|
/// Waits for the event to become signalled.
|
||||||
|
|
||||||
void wait(long milliseconds);
|
void wait(long milliseconds);
|
||||||
/// Waits for the event to become signalled.
|
/// Waits for the event to become signalled.
|
||||||
/// Throws a TimeoutException if the event
|
/// Throws a TimeoutException if the event
|
||||||
/// does not become signalled within the specified
|
/// does not become signalled within the specified
|
||||||
/// time interval.
|
/// time interval.
|
||||||
|
|
||||||
bool tryWait(long milliseconds);
|
bool tryWait(long milliseconds);
|
||||||
/// Waits for the event to become signalled.
|
/// Waits for the event to become signalled.
|
||||||
/// Returns true if the event
|
/// Returns true if the event
|
||||||
/// became signalled within the specified
|
/// became signalled within the specified
|
||||||
/// time interval, false otherwise.
|
/// time interval, false otherwise.
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
/// Resets the event to unsignalled state.
|
/// Resets the event to unsignalled state.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Event(const Event&);
|
Event(const Event&);
|
||||||
Event& operator = (const Event&);
|
Event& operator = (const Event&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline void Event::set()
|
inline void Event::set()
|
||||||
{
|
{
|
||||||
setImpl();
|
setImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Event::wait()
|
inline void Event::wait()
|
||||||
{
|
{
|
||||||
waitImpl();
|
waitImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Event::wait(long milliseconds)
|
inline void Event::wait(long milliseconds)
|
||||||
{
|
{
|
||||||
if (!waitImpl(milliseconds))
|
if (!waitImpl(milliseconds))
|
||||||
throw TimeoutException();
|
throw TimeoutException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool Event::tryWait(long milliseconds)
|
inline bool Event::tryWait(long milliseconds)
|
||||||
{
|
{
|
||||||
return waitImpl(milliseconds);
|
return waitImpl(milliseconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void Event::reset()
|
inline void Event::reset()
|
||||||
{
|
{
|
||||||
resetImpl();
|
resetImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Event_INCLUDED
|
#endif // Foundation_Event_INCLUDED
|
||||||
|
|||||||
@@ -1,66 +1,66 @@
|
|||||||
//
|
//
|
||||||
// EventArgs.h
|
// EventArgs.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/EventArgs.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/EventArgs.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
// Module: EventArgs
|
// Module: EventArgs
|
||||||
//
|
//
|
||||||
// Definition of EventArgs.
|
// Definition of EventArgs.
|
||||||
//
|
//
|
||||||
// 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 Foundation_EventArgs_INCLUDED
|
#ifndef Foundation_EventArgs_INCLUDED
|
||||||
#define Foundation_EventArgs_INCLUDED
|
#define Foundation_EventArgs_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API EventArgs
|
class Foundation_API EventArgs
|
||||||
/// The purpose of the EventArgs class is to be used as parameter
|
/// The purpose of the EventArgs class is to be used as parameter
|
||||||
/// when one doesn't want to send any data.
|
/// when one doesn't want to send any data.
|
||||||
/// One can use EventArgs as a super-class for one's own event arguments
|
/// One can use EventArgs as a super-class for one's own event arguments
|
||||||
/// but with the arguments being a template parameter this is not
|
/// but with the arguments being a template parameter this is not
|
||||||
/// necessary.
|
/// necessary.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EventArgs();
|
EventArgs();
|
||||||
|
|
||||||
virtual ~EventArgs();
|
virtual ~EventArgs();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,127 +1,127 @@
|
|||||||
//
|
//
|
||||||
// EventLogChannel.h
|
// EventLogChannel.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/EventLogChannel.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/EventLogChannel.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Logging
|
// Package: Logging
|
||||||
// Module: EventLogChannel
|
// Module: EventLogChannel
|
||||||
//
|
//
|
||||||
// Definition of the EventLogChannel class specific to WIN32.
|
// Definition of the EventLogChannel class specific to WIN32.
|
||||||
//
|
//
|
||||||
// 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_EventLogChannel_INCLUDED
|
#ifndef Foundation_EventLogChannel_INCLUDED
|
||||||
#define Foundation_EventLogChannel_INCLUDED
|
#define Foundation_EventLogChannel_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Channel.h"
|
#include "Poco/Channel.h"
|
||||||
#include "Poco/UnWindows.h"
|
#include "Poco/UnWindows.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API EventLogChannel: public Channel
|
class Foundation_API EventLogChannel: public Channel
|
||||||
/// This Windows-only channel works with the Windows NT Event Log
|
/// This Windows-only channel works with the Windows NT Event Log
|
||||||
/// service.
|
/// service.
|
||||||
///
|
///
|
||||||
/// To work properly, the EventLogChannel class requires that either
|
/// To work properly, the EventLogChannel class requires that either
|
||||||
/// the PocoFoundation.dll or the PocoMsg.dll Dynamic Link Library
|
/// the PocoFoundation.dll or the PocoMsg.dll Dynamic Link Library
|
||||||
/// containing the message definition resources can be found in $PATH.
|
/// containing the message definition resources can be found in $PATH.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
EventLogChannel();
|
EventLogChannel();
|
||||||
/// Creates the EventLogChannel.
|
/// Creates the EventLogChannel.
|
||||||
/// The name of the current application (or more correctly,
|
/// The name of the current application (or more correctly,
|
||||||
/// the name of its executable) is taken as event source name.
|
/// the name of its executable) is taken as event source name.
|
||||||
|
|
||||||
EventLogChannel(const std::string& name);
|
EventLogChannel(const std::string& name);
|
||||||
/// Creates the EventLogChannel with the given event source name.
|
/// Creates the EventLogChannel with the given event source name.
|
||||||
|
|
||||||
EventLogChannel(const std::string& name, const std::string& host);
|
EventLogChannel(const std::string& name, const std::string& host);
|
||||||
/// Creates an EventLogChannel with the given event source
|
/// Creates an EventLogChannel with the given event source
|
||||||
/// name that routes messages to the given host.
|
/// name that routes messages to the given host.
|
||||||
|
|
||||||
void open();
|
void open();
|
||||||
/// Opens the EventLogChannel. If necessary, the
|
/// Opens the EventLogChannel. If necessary, the
|
||||||
/// required registry entries to register a
|
/// required registry entries to register a
|
||||||
/// message resource DLL are made.
|
/// message resource DLL are made.
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
/// Closes the EventLogChannel.
|
/// Closes the EventLogChannel.
|
||||||
|
|
||||||
void log(const Message& msg);
|
void log(const Message& msg);
|
||||||
/// Logs the given message to the Windows Event Log.
|
/// Logs the given message to the Windows Event Log.
|
||||||
///
|
///
|
||||||
/// The message type and priority are mapped to
|
/// The message type and priority are mapped to
|
||||||
/// appropriate values for Event Log type and category.
|
/// appropriate values for Event Log type and category.
|
||||||
|
|
||||||
void setProperty(const std::string& name, const std::string& value);
|
void setProperty(const std::string& name, const std::string& value);
|
||||||
/// Sets or changes a configuration property.
|
/// Sets or changes a configuration property.
|
||||||
///
|
///
|
||||||
/// The following properties are supported:
|
/// The following properties are supported:
|
||||||
///
|
///
|
||||||
/// * name: The name of the event source.
|
/// * name: The name of the event source.
|
||||||
/// * loghost: The name of the host where the Event Log service is running.
|
/// * loghost: The name of the host where the Event Log service is running.
|
||||||
/// The default is "localhost".
|
/// The default is "localhost".
|
||||||
/// * host: same as host.
|
/// * host: same as host.
|
||||||
/// * logfile: The name of the log file. The default is "Application".
|
/// * logfile: The name of the log file. The default is "Application".
|
||||||
|
|
||||||
std::string getProperty(const std::string& name) const;
|
std::string getProperty(const std::string& name) const;
|
||||||
/// Returns the value of the given property.
|
/// Returns the value of the given property.
|
||||||
|
|
||||||
static const std::string PROP_NAME;
|
static const std::string PROP_NAME;
|
||||||
static const std::string PROP_HOST;
|
static const std::string PROP_HOST;
|
||||||
static const std::string PROP_LOGHOST;
|
static const std::string PROP_LOGHOST;
|
||||||
static const std::string PROP_LOGFILE;
|
static const std::string PROP_LOGFILE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~EventLogChannel();
|
~EventLogChannel();
|
||||||
static int getType(const Message& msg);
|
static int getType(const Message& msg);
|
||||||
static int getCategory(const Message& msg);
|
static int getCategory(const Message& msg);
|
||||||
void setUpRegistry() const;
|
void setUpRegistry() const;
|
||||||
#if defined(POCO_WIN32_UTF8)
|
#if defined(POCO_WIN32_UTF8)
|
||||||
static std::wstring findLibrary(const wchar_t* name);
|
static std::wstring findLibrary(const wchar_t* name);
|
||||||
#else
|
#else
|
||||||
static std::string findLibrary(const char* name);
|
static std::string findLibrary(const char* name);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _name;
|
std::string _name;
|
||||||
std::string _host;
|
std::string _host;
|
||||||
std::string _logFile;
|
std::string _logFile;
|
||||||
HANDLE _h;
|
HANDLE _h;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_EventLogChannel_INCLUDED
|
#endif // Foundation_EventLogChannel_INCLUDED
|
||||||
|
|||||||
@@ -1,99 +1,99 @@
|
|||||||
//
|
//
|
||||||
// Event_POSIX.h
|
// Event_POSIX.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Event_POSIX.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Event_POSIX.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
// Module: Event
|
// Module: Event
|
||||||
//
|
//
|
||||||
// Definition of the EventImpl class for POSIX Threads.
|
// Definition of the EventImpl class for POSIX Threads.
|
||||||
//
|
//
|
||||||
// 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_Event_POSIX_INCLUDED
|
#ifndef Foundation_Event_POSIX_INCLUDED
|
||||||
#define Foundation_Event_POSIX_INCLUDED
|
#define Foundation_Event_POSIX_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API EventImpl
|
class Foundation_API EventImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
EventImpl(bool autoReset);
|
EventImpl(bool autoReset);
|
||||||
~EventImpl();
|
~EventImpl();
|
||||||
void setImpl();
|
void setImpl();
|
||||||
void waitImpl();
|
void waitImpl();
|
||||||
bool waitImpl(long milliseconds);
|
bool waitImpl(long milliseconds);
|
||||||
void resetImpl();
|
void resetImpl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _auto;
|
bool _auto;
|
||||||
volatile bool _state;
|
volatile bool _state;
|
||||||
pthread_mutex_t _mutex;
|
pthread_mutex_t _mutex;
|
||||||
pthread_cond_t _cond;
|
pthread_cond_t _cond;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline void EventImpl::setImpl()
|
inline void EventImpl::setImpl()
|
||||||
{
|
{
|
||||||
if (pthread_mutex_lock(&_mutex))
|
if (pthread_mutex_lock(&_mutex))
|
||||||
throw SystemException("cannot signal event (lock)");
|
throw SystemException("cannot signal event (lock)");
|
||||||
_state = true;
|
_state = true;
|
||||||
if (pthread_cond_broadcast(&_cond))
|
if (pthread_cond_broadcast(&_cond))
|
||||||
{
|
{
|
||||||
pthread_mutex_unlock(&_mutex);
|
pthread_mutex_unlock(&_mutex);
|
||||||
throw SystemException("cannot signal event");
|
throw SystemException("cannot signal event");
|
||||||
}
|
}
|
||||||
pthread_mutex_unlock(&_mutex);
|
pthread_mutex_unlock(&_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void EventImpl::resetImpl()
|
inline void EventImpl::resetImpl()
|
||||||
{
|
{
|
||||||
if (pthread_mutex_lock(&_mutex))
|
if (pthread_mutex_lock(&_mutex))
|
||||||
throw SystemException("cannot reset event");
|
throw SystemException("cannot reset event");
|
||||||
_state = false;
|
_state = false;
|
||||||
pthread_mutex_unlock(&_mutex);
|
pthread_mutex_unlock(&_mutex);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Event_POSIX_INCLUDED
|
#endif // Foundation_Event_POSIX_INCLUDED
|
||||||
|
|||||||
@@ -1,90 +1,90 @@
|
|||||||
//
|
//
|
||||||
// Event_WIN32.h
|
// Event_WIN32.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Event_WIN32.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Event_WIN32.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Threading
|
// Package: Threading
|
||||||
// Module: Event
|
// Module: Event
|
||||||
//
|
//
|
||||||
// Definition of the EventImpl class for WIN32.
|
// Definition of the EventImpl class for WIN32.
|
||||||
//
|
//
|
||||||
// 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_Event_WIN32_INCLUDED
|
#ifndef Foundation_Event_WIN32_INCLUDED
|
||||||
#define Foundation_Event_WIN32_INCLUDED
|
#define Foundation_Event_WIN32_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include "Poco/UnWindows.h"
|
#include "Poco/UnWindows.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API EventImpl
|
class Foundation_API EventImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
EventImpl(bool autoReset = false);
|
EventImpl(bool autoReset = false);
|
||||||
~EventImpl();
|
~EventImpl();
|
||||||
void setImpl();
|
void setImpl();
|
||||||
void waitImpl();
|
void waitImpl();
|
||||||
bool waitImpl(long milliseconds);
|
bool waitImpl(long milliseconds);
|
||||||
void resetImpl();
|
void resetImpl();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HANDLE _event;
|
HANDLE _event;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline void EventImpl::setImpl()
|
inline void EventImpl::setImpl()
|
||||||
{
|
{
|
||||||
if (!SetEvent(_event))
|
if (!SetEvent(_event))
|
||||||
{
|
{
|
||||||
throw SystemException("cannot signal event");
|
throw SystemException("cannot signal event");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void EventImpl::resetImpl()
|
inline void EventImpl::resetImpl()
|
||||||
{
|
{
|
||||||
if (!ResetEvent(_event))
|
if (!ResetEvent(_event))
|
||||||
{
|
{
|
||||||
throw SystemException("cannot reset event");
|
throw SystemException("cannot reset event");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Event_WIN32_INCLUDED
|
#endif // Foundation_Event_WIN32_INCLUDED
|
||||||
|
|||||||
@@ -1,264 +1,264 @@
|
|||||||
//
|
//
|
||||||
// Exception.h
|
// Exception.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Exception.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Exception.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: Exception
|
// Module: Exception
|
||||||
//
|
//
|
||||||
// Definition of various Poco exception classes.
|
// Definition of various Poco exception classes.
|
||||||
//
|
//
|
||||||
// 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_Exception_INCLUDED
|
#ifndef Foundation_Exception_INCLUDED
|
||||||
#define Foundation_Exception_INCLUDED
|
#define Foundation_Exception_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Exception: public std::exception
|
class Foundation_API Exception: public std::exception
|
||||||
/// This is the base class for all exceptions defined
|
/// This is the base class for all exceptions defined
|
||||||
/// in the Poco class library.
|
/// in the Poco class library.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Exception(const std::string& msg, int code = 0);
|
Exception(const std::string& msg, int code = 0);
|
||||||
/// Creates an exception.
|
/// Creates an exception.
|
||||||
|
|
||||||
Exception(const std::string& msg, const std::string& arg, int code = 0);
|
Exception(const std::string& msg, const std::string& arg, int code = 0);
|
||||||
/// Creates an exception.
|
/// Creates an exception.
|
||||||
|
|
||||||
Exception(const std::string& msg, const Exception& nested, int code = 0);
|
Exception(const std::string& msg, const Exception& nested, int code = 0);
|
||||||
/// Creates an exception and stores a clone
|
/// Creates an exception and stores a clone
|
||||||
/// of the nested exception.
|
/// of the nested exception.
|
||||||
|
|
||||||
Exception(const Exception& exc);
|
Exception(const Exception& exc);
|
||||||
/// Copy constructor.
|
/// Copy constructor.
|
||||||
|
|
||||||
~Exception() throw();
|
~Exception() throw();
|
||||||
/// Destroys the exception and deletes the nested exception.
|
/// Destroys the exception and deletes the nested exception.
|
||||||
|
|
||||||
Exception& operator = (const Exception& exc);
|
Exception& operator = (const Exception& exc);
|
||||||
/// Assignment operator.
|
/// Assignment operator.
|
||||||
|
|
||||||
virtual const char* name() const throw();
|
virtual const char* name() const throw();
|
||||||
/// Returns a static string describing the exception.
|
/// Returns a static string describing the exception.
|
||||||
|
|
||||||
virtual const char* className() const throw();
|
virtual const char* className() const throw();
|
||||||
/// Returns the name of the exception class.
|
/// Returns the name of the exception class.
|
||||||
|
|
||||||
virtual const char* what() const throw();
|
virtual const char* what() const throw();
|
||||||
/// Returns a static string describing the exception.
|
/// Returns a static string describing the exception.
|
||||||
///
|
///
|
||||||
/// Same as name(), but for compatibility with std::exception.
|
/// Same as name(), but for compatibility with std::exception.
|
||||||
|
|
||||||
const Exception* nested() const;
|
const Exception* nested() const;
|
||||||
/// Returns a pointer to the nested exception, or
|
/// Returns a pointer to the nested exception, or
|
||||||
/// null if no nested exception exists.
|
/// null if no nested exception exists.
|
||||||
|
|
||||||
const std::string& message() const;
|
const std::string& message() const;
|
||||||
/// Returns the message text.
|
/// Returns the message text.
|
||||||
|
|
||||||
int code() const;
|
int code() const;
|
||||||
/// Returns the exception code if defined.
|
/// Returns the exception code if defined.
|
||||||
|
|
||||||
std::string displayText() const;
|
std::string displayText() const;
|
||||||
/// Returns a string consisting of the
|
/// Returns a string consisting of the
|
||||||
/// message name and the message text.
|
/// message name and the message text.
|
||||||
|
|
||||||
virtual Exception* clone() const;
|
virtual 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.
|
||||||
|
|
||||||
virtual void rethrow() const;
|
virtual 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.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Exception(int code = 0);
|
Exception(int code = 0);
|
||||||
/// Standard constructor.
|
/// Standard constructor.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _msg;
|
std::string _msg;
|
||||||
Exception* _pNested;
|
Exception* _pNested;
|
||||||
int _code;
|
int _code;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline const Exception* Exception::nested() const
|
inline const Exception* Exception::nested() const
|
||||||
{
|
{
|
||||||
return _pNested;
|
return _pNested;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const std::string& Exception::message() const
|
inline const std::string& Exception::message() const
|
||||||
{
|
{
|
||||||
return _msg;
|
return _msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline int Exception::code() const
|
inline int Exception::code() const
|
||||||
{
|
{
|
||||||
return _code;
|
return _code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Macros for quickly declaring and implementing exception classes.
|
// Macros for quickly declaring and implementing exception classes.
|
||||||
// Unfortunately, we cannot use a template here because character
|
// Unfortunately, we cannot use a template here because character
|
||||||
// pointers (which we need for specifying the exception name)
|
// pointers (which we need for specifying the exception name)
|
||||||
// are not allowed as template arguments.
|
// are not allowed as template arguments.
|
||||||
//
|
//
|
||||||
#define POCO_DECLARE_EXCEPTION(API, CLS, BASE) \
|
#define POCO_DECLARE_EXCEPTION(API, CLS, BASE) \
|
||||||
class API CLS: public BASE \
|
class API CLS: public BASE \
|
||||||
{ \
|
{ \
|
||||||
public: \
|
public: \
|
||||||
CLS(int code = 0); \
|
CLS(int code = 0); \
|
||||||
CLS(const std::string& msg, int code = 0); \
|
CLS(const std::string& msg, int code = 0); \
|
||||||
CLS(const std::string& msg, const std::string& arg, int code = 0); \
|
CLS(const std::string& msg, const std::string& arg, int code = 0); \
|
||||||
CLS(const std::string& msg, const Poco::Exception& exc, int code = 0); \
|
CLS(const std::string& msg, const Poco::Exception& exc, int code = 0); \
|
||||||
CLS(const CLS& exc); \
|
CLS(const CLS& exc); \
|
||||||
~CLS() throw(); \
|
~CLS() throw(); \
|
||||||
CLS& operator = (const CLS& exc); \
|
CLS& operator = (const CLS& exc); \
|
||||||
const char* name() const throw(); \
|
const char* name() const throw(); \
|
||||||
const char* className() const throw(); \
|
const char* className() const throw(); \
|
||||||
Poco::Exception* clone() const; \
|
Poco::Exception* clone() const; \
|
||||||
void rethrow() const; \
|
void rethrow() const; \
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#define POCO_IMPLEMENT_EXCEPTION(CLS, BASE, NAME) \
|
#define POCO_IMPLEMENT_EXCEPTION(CLS, BASE, NAME) \
|
||||||
CLS::CLS(int code): BASE(code) \
|
CLS::CLS(int code): BASE(code) \
|
||||||
{ \
|
{ \
|
||||||
} \
|
} \
|
||||||
CLS::CLS(const std::string& msg, int code): BASE(msg, code) \
|
CLS::CLS(const std::string& msg, int code): BASE(msg, code) \
|
||||||
{ \
|
{ \
|
||||||
} \
|
} \
|
||||||
CLS::CLS(const std::string& msg, const std::string& arg, int code): BASE(msg, arg, code) \
|
CLS::CLS(const std::string& msg, const std::string& arg, int code): BASE(msg, arg, code) \
|
||||||
{ \
|
{ \
|
||||||
} \
|
} \
|
||||||
CLS::CLS(const std::string& msg, const Poco::Exception& exc, int code): BASE(msg, exc, code) \
|
CLS::CLS(const std::string& msg, const Poco::Exception& exc, int code): BASE(msg, exc, code) \
|
||||||
{ \
|
{ \
|
||||||
} \
|
} \
|
||||||
CLS::CLS(const CLS& exc): BASE(exc) \
|
CLS::CLS(const CLS& exc): BASE(exc) \
|
||||||
{ \
|
{ \
|
||||||
} \
|
} \
|
||||||
CLS::~CLS() throw() \
|
CLS::~CLS() throw() \
|
||||||
{ \
|
{ \
|
||||||
} \
|
} \
|
||||||
CLS& CLS::operator = (const CLS& exc) \
|
CLS& CLS::operator = (const CLS& exc) \
|
||||||
{ \
|
{ \
|
||||||
BASE::operator = (exc); \
|
BASE::operator = (exc); \
|
||||||
return *this; \
|
return *this; \
|
||||||
} \
|
} \
|
||||||
const char* CLS::name() const throw() \
|
const char* CLS::name() const throw() \
|
||||||
{ \
|
{ \
|
||||||
return NAME; \
|
return NAME; \
|
||||||
} \
|
} \
|
||||||
const char* CLS::className() const throw() \
|
const char* CLS::className() const throw() \
|
||||||
{ \
|
{ \
|
||||||
return typeid(*this).name(); \
|
return typeid(*this).name(); \
|
||||||
} \
|
} \
|
||||||
Poco::Exception* CLS::clone() const \
|
Poco::Exception* CLS::clone() const \
|
||||||
{ \
|
{ \
|
||||||
return new CLS(*this); \
|
return new CLS(*this); \
|
||||||
} \
|
} \
|
||||||
void CLS::rethrow() const \
|
void CLS::rethrow() const \
|
||||||
{ \
|
{ \
|
||||||
throw *this; \
|
throw *this; \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Standard exception classes
|
// Standard exception classes
|
||||||
//
|
//
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, LogicException, Exception)
|
POCO_DECLARE_EXCEPTION(Foundation_API, LogicException, Exception)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, AssertionViolationException, LogicException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, AssertionViolationException, LogicException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, NullPointerException, LogicException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, NullPointerException, LogicException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, BugcheckException, LogicException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, BugcheckException, LogicException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, InvalidArgumentException, LogicException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, InvalidArgumentException, LogicException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, NotImplementedException, LogicException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, NotImplementedException, LogicException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, RangeException, LogicException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, RangeException, LogicException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, IllegalStateException, LogicException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, IllegalStateException, LogicException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, InvalidAccessException, LogicException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, InvalidAccessException, LogicException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, SignalException, LogicException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, SignalException, LogicException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, UnhandledException, LogicException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, UnhandledException, LogicException)
|
||||||
|
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, RuntimeException, Exception)
|
POCO_DECLARE_EXCEPTION(Foundation_API, RuntimeException, Exception)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, NotFoundException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, NotFoundException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, ExistsException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, ExistsException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, TimeoutException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, TimeoutException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, SystemException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, SystemException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, RegularExpressionException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, RegularExpressionException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, LibraryLoadException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, LibraryLoadException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, LibraryAlreadyLoadedException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, LibraryAlreadyLoadedException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, NoThreadAvailableException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, NoThreadAvailableException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, PropertyNotSupportedException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, PropertyNotSupportedException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, PoolOverflowException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, PoolOverflowException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, NoPermissionException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, NoPermissionException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, OutOfMemoryException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, OutOfMemoryException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, DataException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, DataException, RuntimeException)
|
||||||
|
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, DataFormatException, DataException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, DataFormatException, DataException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, SyntaxException, DataException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, SyntaxException, DataException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, CircularReferenceException, DataException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, CircularReferenceException, DataException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, PathSyntaxException, SyntaxException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, PathSyntaxException, SyntaxException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, IOException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, IOException, RuntimeException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, FileException, IOException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, FileException, IOException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, FileExistsException, FileException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, FileExistsException, FileException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, FileNotFoundException, FileException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, FileNotFoundException, FileException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, PathNotFoundException, FileException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, PathNotFoundException, FileException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, FileReadOnlyException, FileException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, FileReadOnlyException, FileException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, FileAccessDeniedException, FileException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, FileAccessDeniedException, FileException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, CreateFileException, FileException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, CreateFileException, FileException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, OpenFileException, FileException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, OpenFileException, FileException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, WriteFileException, FileException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, WriteFileException, FileException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, ReadFileException, FileException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, ReadFileException, FileException)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, UnknownURISchemeException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, UnknownURISchemeException, RuntimeException)
|
||||||
|
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, ApplicationException, Exception)
|
POCO_DECLARE_EXCEPTION(Foundation_API, ApplicationException, Exception)
|
||||||
POCO_DECLARE_EXCEPTION(Foundation_API, BadCastException, RuntimeException)
|
POCO_DECLARE_EXCEPTION(Foundation_API, BadCastException, RuntimeException)
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Exception_INCLUDED
|
#endif // Foundation_Exception_INCLUDED
|
||||||
|
|||||||
@@ -1,113 +1,113 @@
|
|||||||
//
|
//
|
||||||
// ExpirationDecorator.h
|
// ExpirationDecorator.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ExpirationDecorator.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ExpirationDecorator.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
// Module: ExpirationDecorator
|
// Module: ExpirationDecorator
|
||||||
//
|
//
|
||||||
// Implementation of the ExpirationDecorator template.
|
// Implementation of the ExpirationDecorator template.
|
||||||
//
|
//
|
||||||
// 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 Foundation_ExpirationDecorator_INCLUDED
|
#ifndef Foundation_ExpirationDecorator_INCLUDED
|
||||||
#define Foundation_ExpirationDecorator_INCLUDED
|
#define Foundation_ExpirationDecorator_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
#include "Poco/Timespan.h"
|
#include "Poco/Timespan.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <typename TArgs>
|
template <typename TArgs>
|
||||||
class ExpirationDecorator
|
class ExpirationDecorator
|
||||||
/// ExpirationDecorator adds an expiration method to values so that they can be used
|
/// ExpirationDecorator adds an expiration method to values so that they can be used
|
||||||
/// with the UniqueExpireCache
|
/// with the UniqueExpireCache
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExpirationDecorator():
|
ExpirationDecorator():
|
||||||
_value(),
|
_value(),
|
||||||
_expiresAt()
|
_expiresAt()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpirationDecorator(const TArgs& p, const Poco::Timespan::TimeDiff& diffInMs):
|
ExpirationDecorator(const TArgs& p, const Poco::Timespan::TimeDiff& diffInMs):
|
||||||
/// Creates an element that will expire in diff milliseconds
|
/// Creates an element that will expire in diff milliseconds
|
||||||
_value(p),
|
_value(p),
|
||||||
_expiresAt()
|
_expiresAt()
|
||||||
{
|
{
|
||||||
_expiresAt += (diffInMs*1000);
|
_expiresAt += (diffInMs*1000);
|
||||||
}
|
}
|
||||||
ExpirationDecorator(const TArgs& p, const Poco::Timespan& timeSpan):
|
ExpirationDecorator(const TArgs& p, const Poco::Timespan& timeSpan):
|
||||||
/// Creates an element that will expire after the given timeSpan
|
/// Creates an element that will expire after the given timeSpan
|
||||||
_value(p),
|
_value(p),
|
||||||
_expiresAt()
|
_expiresAt()
|
||||||
{
|
{
|
||||||
_expiresAt += timeSpan.totalMicroseconds();
|
_expiresAt += timeSpan.totalMicroseconds();
|
||||||
}
|
}
|
||||||
|
|
||||||
ExpirationDecorator(const TArgs& p, const Poco::Timestamp& timeStamp):
|
ExpirationDecorator(const TArgs& p, const Poco::Timestamp& timeStamp):
|
||||||
/// Creates an element that will expire at the given time point
|
/// Creates an element that will expire at the given time point
|
||||||
_value(p),
|
_value(p),
|
||||||
_expiresAt(timeStamp)
|
_expiresAt(timeStamp)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
~ExpirationDecorator()
|
~ExpirationDecorator()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const Poco::Timestamp& getExpiration() const
|
const Poco::Timestamp& getExpiration() const
|
||||||
{
|
{
|
||||||
return _expiresAt;
|
return _expiresAt;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TArgs& value() const
|
const TArgs& value() const
|
||||||
{
|
{
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
TArgs& value()
|
TArgs& value()
|
||||||
{
|
{
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TArgs _value;
|
TArgs _value;
|
||||||
Timestamp _expiresAt;
|
Timestamp _expiresAt;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,132 +1,132 @@
|
|||||||
//
|
//
|
||||||
// Expire.h
|
// Expire.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Expire.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Expire.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
// Module: Expire
|
// Module: Expire
|
||||||
//
|
//
|
||||||
// Implementation of the Expire template.
|
// Implementation of the Expire template.
|
||||||
//
|
//
|
||||||
// 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 Foundation_Expire_INCLUDED
|
#ifndef Foundation_Expire_INCLUDED
|
||||||
#define Foundation_Expire_INCLUDED
|
#define Foundation_Expire_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/AbstractDelegate.h"
|
#include "Poco/AbstractDelegate.h"
|
||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TArgs>
|
template <class TArgs>
|
||||||
class Expire: public AbstractDelegate<TArgs>
|
class Expire: public AbstractDelegate<TArgs>
|
||||||
/// Decorator for AbstractDelegate adding automatic
|
/// Decorator for AbstractDelegate adding automatic
|
||||||
/// expiring of registrations to AbstractDelegates.
|
/// expiring of registrations to AbstractDelegates.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Expire(const AbstractDelegate<TArgs>& p, Timestamp::TimeDiff expireMillisecs):
|
Expire(const AbstractDelegate<TArgs>& p, Timestamp::TimeDiff expireMillisecs):
|
||||||
AbstractDelegate<TArgs>(p),
|
AbstractDelegate<TArgs>(p),
|
||||||
_pDelegate(p.clone()),
|
_pDelegate(p.clone()),
|
||||||
_expire(expireMillisecs*1000)
|
_expire(expireMillisecs*1000)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Expire(const Expire& expire):
|
Expire(const Expire& expire):
|
||||||
AbstractDelegate<TArgs>(expire),
|
AbstractDelegate<TArgs>(expire),
|
||||||
_pDelegate(expire._pDelegate->clone()),
|
_pDelegate(expire._pDelegate->clone()),
|
||||||
_expire(expire._expire),
|
_expire(expire._expire),
|
||||||
_creationTime(expire._creationTime)
|
_creationTime(expire._creationTime)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~Expire()
|
~Expire()
|
||||||
{
|
{
|
||||||
destroy();
|
destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
Expire& operator = (const Expire& expire)
|
Expire& operator = (const Expire& expire)
|
||||||
{
|
{
|
||||||
if (&expire != this)
|
if (&expire != this)
|
||||||
{
|
{
|
||||||
delete this->_pDelegate;
|
delete this->_pDelegate;
|
||||||
this->_pDelegate = expire._pDelegate->clone();
|
this->_pDelegate = expire._pDelegate->clone();
|
||||||
this->_expire = expire._expire;
|
this->_expire = expire._expire;
|
||||||
this->_creationTime = expire._creationTime;
|
this->_creationTime = expire._creationTime;
|
||||||
this->_pTarget = expire._pTarget;
|
this->_pTarget = expire._pTarget;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool notify(const void* sender, TArgs& arguments)
|
bool notify(const void* sender, TArgs& arguments)
|
||||||
{
|
{
|
||||||
if (!expired())
|
if (!expired())
|
||||||
return this->_pDelegate->notify(sender, arguments);
|
return this->_pDelegate->notify(sender, arguments);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractDelegate<TArgs>* clone() const
|
AbstractDelegate<TArgs>* clone() const
|
||||||
{
|
{
|
||||||
return new Expire(*this);
|
return new Expire(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void destroy()
|
void destroy()
|
||||||
{
|
{
|
||||||
delete this->_pDelegate;
|
delete this->_pDelegate;
|
||||||
this->_pDelegate = 0;
|
this->_pDelegate = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
const AbstractDelegate<TArgs>& getDelegate() const
|
const AbstractDelegate<TArgs>& getDelegate() const
|
||||||
{
|
{
|
||||||
return *this->_pDelegate;
|
return *this->_pDelegate;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool expired() const
|
bool expired() const
|
||||||
{
|
{
|
||||||
return _creationTime.isElapsed(_expire);
|
return _creationTime.isElapsed(_expire);
|
||||||
}
|
}
|
||||||
|
|
||||||
AbstractDelegate<TArgs>* _pDelegate;
|
AbstractDelegate<TArgs>* _pDelegate;
|
||||||
Timestamp::TimeDiff _expire;
|
Timestamp::TimeDiff _expire;
|
||||||
Timestamp _creationTime;
|
Timestamp _creationTime;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Expire();
|
Expire();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,78 +1,78 @@
|
|||||||
//
|
//
|
||||||
// ExpireCache.h
|
// ExpireCache.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ExpireCache.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ExpireCache.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
// Module: ExpireCache
|
// Module: ExpireCache
|
||||||
//
|
//
|
||||||
// Definition of the ExpireCache class.
|
// Definition of the ExpireCache 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 Foundation_ExpireCache_INCLUDED
|
#ifndef Foundation_ExpireCache_INCLUDED
|
||||||
#define Foundation_ExpireCache_INCLUDED
|
#define Foundation_ExpireCache_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/AbstractCache.h"
|
#include "Poco/AbstractCache.h"
|
||||||
#include "Poco/ExpireStrategy.h"
|
#include "Poco/ExpireStrategy.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TKey, class TValue>
|
template <class TKey, class TValue>
|
||||||
class ExpireCache: public AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue> >
|
class ExpireCache: public AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue> >
|
||||||
/// An ExpireCache caches entries for a fixed time period (per default 10 minutes)
|
/// An ExpireCache caches entries for a fixed time period (per default 10 minutes)
|
||||||
/// Be careful when using an ExpireCache. A cache is often used
|
/// Be careful when using an ExpireCache. A cache is often used
|
||||||
/// like cache.has(x) followed by cache.get x). Note that it could happen
|
/// like cache.has(x) followed by cache.get x). Note that it could happen
|
||||||
/// that the "has" call works, then the current execution thread gets descheduled, time passes,
|
/// that the "has" call works, then the current execution thread gets descheduled, time passes,
|
||||||
/// the entry gets invalid, thus leading to an empty SharedPtr being returned
|
/// the entry gets invalid, thus leading to an empty SharedPtr being returned
|
||||||
/// when "get" is invoked.
|
/// when "get" is invoked.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExpireCache(Timestamp::TimeDiff expire = 600000):
|
ExpireCache(Timestamp::TimeDiff expire = 600000):
|
||||||
AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue> >(ExpireStrategy<TKey, TValue>(expire))
|
AbstractCache<TKey, TValue, ExpireStrategy<TKey, TValue> >(ExpireStrategy<TKey, TValue>(expire))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~ExpireCache()
|
~ExpireCache()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExpireCache(const ExpireCache& aCache);
|
ExpireCache(const ExpireCache& aCache);
|
||||||
ExpireCache& operator = (const ExpireCache& aCache);
|
ExpireCache& operator = (const ExpireCache& aCache);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,82 +1,82 @@
|
|||||||
//
|
//
|
||||||
// ExpireLRUCache.h
|
// ExpireLRUCache.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ExpireLRUCache.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ExpireLRUCache.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
// Module: ExpireLRUCache
|
// Module: ExpireLRUCache
|
||||||
//
|
//
|
||||||
// Definition of the ExpireLRUCache class.
|
// Definition of the ExpireLRUCache 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 Foundation_ExpireLRUCache_INCLUDED
|
#ifndef Foundation_ExpireLRUCache_INCLUDED
|
||||||
#define Foundation_ExpireLRUCache_INCLUDED
|
#define Foundation_ExpireLRUCache_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/AbstractCache.h"
|
#include "Poco/AbstractCache.h"
|
||||||
#include "Poco/StrategyCollection.h"
|
#include "Poco/StrategyCollection.h"
|
||||||
#include "Poco/ExpireStrategy.h"
|
#include "Poco/ExpireStrategy.h"
|
||||||
#include "Poco/LRUStrategy.h"
|
#include "Poco/LRUStrategy.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <
|
template <
|
||||||
class TKey,
|
class TKey,
|
||||||
class TValue
|
class TValue
|
||||||
>
|
>
|
||||||
class ExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue> >
|
class ExpireLRUCache: public AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue> >
|
||||||
/// An ExpireLRUCache combines LRU caching and time based expire caching.
|
/// An ExpireLRUCache combines LRU caching and time based expire caching.
|
||||||
/// It cache entries for a fixed time period (per default 10 minutes)
|
/// It cache entries for a fixed time period (per default 10 minutes)
|
||||||
/// but also limits the size of the cache (per default: 1024).
|
/// but also limits the size of the cache (per default: 1024).
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ExpireLRUCache(long cacheSize = 1024, Timestamp::TimeDiff expire = 600000):
|
ExpireLRUCache(long cacheSize = 1024, Timestamp::TimeDiff expire = 600000):
|
||||||
AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue> >(StrategyCollection<TKey, TValue>())
|
AbstractCache<TKey, TValue, StrategyCollection<TKey, TValue> >(StrategyCollection<TKey, TValue>())
|
||||||
{
|
{
|
||||||
this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize));
|
this->_strategy.pushBack(new LRUStrategy<TKey, TValue>(cacheSize));
|
||||||
this->_strategy.pushBack(new ExpireStrategy<TKey, TValue>(expire));
|
this->_strategy.pushBack(new ExpireStrategy<TKey, TValue>(expire));
|
||||||
}
|
}
|
||||||
|
|
||||||
~ExpireLRUCache()
|
~ExpireLRUCache()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ExpireLRUCache(const ExpireLRUCache& aCache);
|
ExpireLRUCache(const ExpireLRUCache& aCache);
|
||||||
ExpireLRUCache& operator = (const ExpireLRUCache& aCache);
|
ExpireLRUCache& operator = (const ExpireLRUCache& aCache);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,150 +1,150 @@
|
|||||||
//
|
//
|
||||||
// ExpireStrategy.h
|
// ExpireStrategy.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/ExpireStrategy.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/ExpireStrategy.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
// Module: ExpireStrategy
|
// Module: ExpireStrategy
|
||||||
//
|
//
|
||||||
// Definition of the ExpireStrategy class.
|
// Definition of the ExpireStrategy 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 Foundation_ExpireStrategy_INCLUDED
|
#ifndef Foundation_ExpireStrategy_INCLUDED
|
||||||
#define Foundation_ExpireStrategy_INCLUDED
|
#define Foundation_ExpireStrategy_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/KeyValueArgs.h"
|
#include "Poco/KeyValueArgs.h"
|
||||||
#include "Poco/ValidArgs.h"
|
#include "Poco/ValidArgs.h"
|
||||||
#include "Poco/AbstractStrategy.h"
|
#include "Poco/AbstractStrategy.h"
|
||||||
#include "Poco/Bugcheck.h"
|
#include "Poco/Bugcheck.h"
|
||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
#include "Poco/EventArgs.h"
|
#include "Poco/EventArgs.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <
|
template <
|
||||||
class TKey,
|
class TKey,
|
||||||
class TValue
|
class TValue
|
||||||
>
|
>
|
||||||
class ExpireStrategy: public AbstractStrategy<TKey, TValue>
|
class ExpireStrategy: public AbstractStrategy<TKey, TValue>
|
||||||
/// An ExpireStrategy implements time based expiration of cache entries
|
/// An ExpireStrategy implements time based expiration of cache entries
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef std::multimap<Timestamp, TKey> TimeIndex;
|
typedef std::multimap<Timestamp, TKey> TimeIndex;
|
||||||
typedef typename TimeIndex::iterator IndexIterator;
|
typedef typename TimeIndex::iterator IndexIterator;
|
||||||
typedef typename TimeIndex::const_iterator ConstIndexIterator;
|
typedef typename TimeIndex::const_iterator ConstIndexIterator;
|
||||||
typedef std::map<TKey, IndexIterator> Keys;
|
typedef std::map<TKey, IndexIterator> Keys;
|
||||||
typedef typename Keys::iterator Iterator;
|
typedef typename Keys::iterator Iterator;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ExpireStrategy(Timestamp::TimeDiff expireTimeInMilliSec): _expireTime(expireTimeInMilliSec * 1000)
|
ExpireStrategy(Timestamp::TimeDiff expireTimeInMilliSec): _expireTime(expireTimeInMilliSec * 1000)
|
||||||
/// Create an expire strategy. Note that the smallest allowed caching time is 25ms.
|
/// Create an expire strategy. Note that the smallest allowed caching time is 25ms.
|
||||||
/// Anything lower than that is not useful with current operating systems.
|
/// Anything lower than that is not useful with current operating systems.
|
||||||
{
|
{
|
||||||
if (_expireTime < 25000) throw InvalidArgumentException("expireTime must be at least 25 ms");
|
if (_expireTime < 25000) throw InvalidArgumentException("expireTime must be at least 25 ms");
|
||||||
}
|
}
|
||||||
|
|
||||||
~ExpireStrategy()
|
~ExpireStrategy()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void onAdd(const void*, const KeyValueArgs <TKey, TValue>& args)
|
void onAdd(const void*, const KeyValueArgs <TKey, TValue>& args)
|
||||||
{
|
{
|
||||||
Timestamp now;
|
Timestamp now;
|
||||||
IndexIterator it = _keyIndex.insert(typename TimeIndex::value_type(now, args.key()));
|
IndexIterator it = _keyIndex.insert(typename TimeIndex::value_type(now, args.key()));
|
||||||
std::pair<Iterator, bool> stat = _keys.insert(typename Keys::value_type(args.key(), it));
|
std::pair<Iterator, bool> stat = _keys.insert(typename Keys::value_type(args.key(), it));
|
||||||
if (!stat.second)
|
if (!stat.second)
|
||||||
{
|
{
|
||||||
_keyIndex.erase(stat.first->second);
|
_keyIndex.erase(stat.first->second);
|
||||||
stat.first->second = it;
|
stat.first->second = it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onRemove(const void*, const TKey& key)
|
void onRemove(const void*, const TKey& key)
|
||||||
{
|
{
|
||||||
Iterator it = _keys.find(key);
|
Iterator it = _keys.find(key);
|
||||||
if (it != _keys.end())
|
if (it != _keys.end())
|
||||||
{
|
{
|
||||||
_keyIndex.erase(it->second);
|
_keyIndex.erase(it->second);
|
||||||
_keys.erase(it);
|
_keys.erase(it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onGet(const void*, const TKey& key)
|
void onGet(const void*, const TKey& key)
|
||||||
{
|
{
|
||||||
// get triggers no changes in an expire
|
// get triggers no changes in an expire
|
||||||
}
|
}
|
||||||
|
|
||||||
void onClear(const void*, const EventArgs& args)
|
void onClear(const void*, const EventArgs& args)
|
||||||
{
|
{
|
||||||
_keys.clear();
|
_keys.clear();
|
||||||
_keyIndex.clear();
|
_keyIndex.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void onIsValid(const void*, ValidArgs<TKey>& args)
|
void onIsValid(const void*, ValidArgs<TKey>& args)
|
||||||
{
|
{
|
||||||
Iterator it = _keys.find(args.key());
|
Iterator it = _keys.find(args.key());
|
||||||
if (it != _keys.end())
|
if (it != _keys.end())
|
||||||
{
|
{
|
||||||
if (it->second->first.isElapsed(_expireTime))
|
if (it->second->first.isElapsed(_expireTime))
|
||||||
{
|
{
|
||||||
args.invalidate();
|
args.invalidate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void onReplace(const void*, std::set<TKey>& elemsToRemove)
|
void onReplace(const void*, std::set<TKey>& elemsToRemove)
|
||||||
{
|
{
|
||||||
// Note: replace only informs the cache which elements
|
// Note: replace only informs the cache which elements
|
||||||
// it would like to remove!
|
// it would like to remove!
|
||||||
// it does not remove them on its own!
|
// it does not remove them on its own!
|
||||||
IndexIterator it = _keyIndex.begin();
|
IndexIterator it = _keyIndex.begin();
|
||||||
while (it != _keyIndex.end() && it->first.isElapsed(_expireTime))
|
while (it != _keyIndex.end() && it->first.isElapsed(_expireTime))
|
||||||
{
|
{
|
||||||
elemsToRemove.insert(it->second);
|
elemsToRemove.insert(it->second);
|
||||||
++it;
|
++it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Timestamp::TimeDiff _expireTime;
|
Timestamp::TimeDiff _expireTime;
|
||||||
Keys _keys; /// For faster replacement of keys, the iterator points to the _keyIndex map
|
Keys _keys; /// For faster replacement of keys, the iterator points to the _keyIndex map
|
||||||
TimeIndex _keyIndex; /// Maps time to key value
|
TimeIndex _keyIndex; /// Maps time to key value
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,90 +1,90 @@
|
|||||||
//
|
//
|
||||||
// FIFOEvent.h
|
// FIFOEvent.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/FIFOEvent.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/FIFOEvent.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Events
|
// Package: Events
|
||||||
// Module: FIFOEvent
|
// Module: FIFOEvent
|
||||||
//
|
//
|
||||||
// Implementation of the FIFOEvent template.
|
// Implementation of the FIFOEvent template.
|
||||||
//
|
//
|
||||||
// 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 Foundation_FIFOEvent_INCLUDED
|
#ifndef Foundation_FIFOEvent_INCLUDED
|
||||||
#define Foundation_FIFOEvent_INCLUDED
|
#define Foundation_FIFOEvent_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/AbstractEvent.h"
|
#include "Poco/AbstractEvent.h"
|
||||||
#include "Poco/FIFOStrategy.h"
|
#include "Poco/FIFOStrategy.h"
|
||||||
#include "Poco/AbstractDelegate.h"
|
#include "Poco/AbstractDelegate.h"
|
||||||
#include "Poco/CompareFunctions.h"
|
#include "Poco/CompareFunctions.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TArgs>
|
template <class TArgs>
|
||||||
class FIFOEvent: public AbstractEvent <
|
class FIFOEvent: public AbstractEvent <
|
||||||
TArgs,
|
TArgs,
|
||||||
FIFOStrategy<TArgs, AbstractDelegate<TArgs>, p_less<AbstractDelegate< TArgs> > >,
|
FIFOStrategy<TArgs, AbstractDelegate<TArgs>, p_less<AbstractDelegate< TArgs> > >,
|
||||||
AbstractDelegate<TArgs>
|
AbstractDelegate<TArgs>
|
||||||
>
|
>
|
||||||
/// A FIFOEvent uses internally a FIFOStrategy which guarantees
|
/// A FIFOEvent uses internally a FIFOStrategy which guarantees
|
||||||
/// that delegates are invoked in the order they were added to
|
/// that delegates are invoked in the order they were added to
|
||||||
/// the event.
|
/// the event.
|
||||||
///
|
///
|
||||||
/// Note that one object can only register one method to a FIFOEvent.
|
/// Note that one object can only register one method to a FIFOEvent.
|
||||||
/// Subsequent registrations will overwrite the existing delegate.
|
/// Subsequent registrations will overwrite the existing delegate.
|
||||||
/// For example:
|
/// For example:
|
||||||
/// FIFOEvent<int> tmp;
|
/// FIFOEvent<int> tmp;
|
||||||
/// MyClass myObject;
|
/// MyClass myObject;
|
||||||
/// tmp += Delegate<MyClass, int>(&myObject, &MyClass::myMethod1);
|
/// tmp += Delegate<MyClass, int>(&myObject, &MyClass::myMethod1);
|
||||||
/// tmp += Delegate<MyClass, int>(&myObject, &MyClass::myMethod2);
|
/// tmp += Delegate<MyClass, int>(&myObject, &MyClass::myMethod2);
|
||||||
///
|
///
|
||||||
/// The second registration will overwrite the first one.
|
/// The second registration will overwrite the first one.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FIFOEvent()
|
FIFOEvent()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~FIFOEvent()
|
~FIFOEvent()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FIFOEvent(const FIFOEvent& e);
|
FIFOEvent(const FIFOEvent& e);
|
||||||
FIFOEvent& operator = (const FIFOEvent& e);
|
FIFOEvent& operator = (const FIFOEvent& e);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,227 +1,227 @@
|
|||||||
//
|
//
|
||||||
// FPEnvironment.h
|
// FPEnvironment.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: FPEnvironment
|
// Module: FPEnvironment
|
||||||
//
|
//
|
||||||
// Definitions of class FPEnvironment.
|
// Definitions of class FPEnvironment.
|
||||||
//
|
//
|
||||||
// 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_FPEnvironment_INCLUDED
|
#ifndef Foundation_FPEnvironment_INCLUDED
|
||||||
#define Foundation_FPEnvironment_INCLUDED
|
#define Foundation_FPEnvironment_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
#if defined(POCO_NO_FPENVIRONMENT)
|
#if defined(POCO_NO_FPENVIRONMENT)
|
||||||
#include "Poco/FPEnvironment_DUMMY.h"
|
#include "Poco/FPEnvironment_DUMMY.h"
|
||||||
#elif defined(__osf__) || defined(__VMS)
|
#elif defined(__osf__) || defined(__VMS)
|
||||||
#include "Poco/FPEnvironment_DEC.h"
|
#include "Poco/FPEnvironment_DEC.h"
|
||||||
#elif defined(sun) || defined(__sun)
|
#elif defined(sun) || defined(__sun)
|
||||||
#include "Poco/FPEnvironment_SUN.h"
|
#include "Poco/FPEnvironment_SUN.h"
|
||||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||||
#include "Poco/FPEnvironment_C99.h"
|
#include "Poco/FPEnvironment_C99.h"
|
||||||
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
#elif defined(POCO_OS_FAMILY_WINDOWS)
|
||||||
#include "Poco/FPEnvironment_WIN32.h"
|
#include "Poco/FPEnvironment_WIN32.h"
|
||||||
#else
|
#else
|
||||||
#include "Poco/FPEnvironment_DUMMY.h"
|
#include "Poco/FPEnvironment_DUMMY.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FPEnvironment: private FPEnvironmentImpl
|
class Foundation_API FPEnvironment: private FPEnvironmentImpl
|
||||||
/// Instances of this class can be used to save
|
/// Instances of this class can be used to save
|
||||||
/// and later restore the current floating
|
/// and later restore the current floating
|
||||||
/// point environment (consisting of rounding
|
/// point environment (consisting of rounding
|
||||||
/// mode and floating-point flags).
|
/// mode and floating-point flags).
|
||||||
/// The class also provides various static
|
/// The class also provides various static
|
||||||
/// methods to query certain properties
|
/// methods to query certain properties
|
||||||
/// of a floating-point number.
|
/// of a floating-point number.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum RoundingMode
|
enum RoundingMode
|
||||||
{
|
{
|
||||||
FP_ROUND_DOWNWARD = FP_ROUND_DOWNWARD_IMPL,
|
FP_ROUND_DOWNWARD = FP_ROUND_DOWNWARD_IMPL,
|
||||||
FP_ROUND_UPWARD = FP_ROUND_UPWARD_IMPL,
|
FP_ROUND_UPWARD = FP_ROUND_UPWARD_IMPL,
|
||||||
FP_ROUND_TONEAREST = FP_ROUND_TONEAREST_IMPL,
|
FP_ROUND_TONEAREST = FP_ROUND_TONEAREST_IMPL,
|
||||||
FP_ROUND_TOWARDZERO = FP_ROUND_TOWARDZERO_IMPL
|
FP_ROUND_TOWARDZERO = FP_ROUND_TOWARDZERO_IMPL
|
||||||
};
|
};
|
||||||
|
|
||||||
enum Flag
|
enum Flag
|
||||||
{
|
{
|
||||||
FP_DIVIDE_BY_ZERO = FP_DIVIDE_BY_ZERO_IMPL,
|
FP_DIVIDE_BY_ZERO = FP_DIVIDE_BY_ZERO_IMPL,
|
||||||
FP_INEXACT = FP_INEXACT_IMPL,
|
FP_INEXACT = FP_INEXACT_IMPL,
|
||||||
FP_OVERFLOW = FP_OVERFLOW_IMPL,
|
FP_OVERFLOW = FP_OVERFLOW_IMPL,
|
||||||
FP_UNDERFLOW = FP_UNDERFLOW_IMPL,
|
FP_UNDERFLOW = FP_UNDERFLOW_IMPL,
|
||||||
FP_INVALID = FP_INVALID_IMPL
|
FP_INVALID = FP_INVALID_IMPL
|
||||||
};
|
};
|
||||||
|
|
||||||
FPEnvironment();
|
FPEnvironment();
|
||||||
/// Standard constructor.
|
/// Standard constructor.
|
||||||
/// Remembers the current environment.
|
/// Remembers the current environment.
|
||||||
|
|
||||||
FPEnvironment(RoundingMode mode);
|
FPEnvironment(RoundingMode mode);
|
||||||
/// Remembers the current environment and
|
/// Remembers the current environment and
|
||||||
/// sets the given rounding mode.
|
/// sets the given rounding mode.
|
||||||
|
|
||||||
FPEnvironment(const FPEnvironment& env);
|
FPEnvironment(const FPEnvironment& env);
|
||||||
/// Copy constructor.
|
/// Copy constructor.
|
||||||
|
|
||||||
~FPEnvironment();
|
~FPEnvironment();
|
||||||
/// Restores the previous environment (unless
|
/// Restores the previous environment (unless
|
||||||
/// keepCurrent() has been called previously)
|
/// keepCurrent() has been called previously)
|
||||||
|
|
||||||
FPEnvironment& operator = (const FPEnvironment& env);
|
FPEnvironment& operator = (const FPEnvironment& env);
|
||||||
/// Assignment operator
|
/// Assignment operator
|
||||||
|
|
||||||
void keepCurrent();
|
void keepCurrent();
|
||||||
/// Keep the current environment even after
|
/// Keep the current environment even after
|
||||||
/// destroying the FPEnvironment object.
|
/// destroying the FPEnvironment object.
|
||||||
|
|
||||||
static void clearFlags();
|
static void clearFlags();
|
||||||
/// Resets all flags.
|
/// Resets all flags.
|
||||||
|
|
||||||
static bool isFlag(Flag flag);
|
static bool isFlag(Flag flag);
|
||||||
/// Returns true iff the given flag is set.
|
/// Returns true iff the given flag is set.
|
||||||
|
|
||||||
static void setRoundingMode(RoundingMode mode);
|
static void setRoundingMode(RoundingMode mode);
|
||||||
/// Sets the rounding mode.
|
/// Sets the rounding mode.
|
||||||
|
|
||||||
static RoundingMode getRoundingMode();
|
static RoundingMode getRoundingMode();
|
||||||
/// Returns the current rounding mode.
|
/// Returns the current rounding mode.
|
||||||
|
|
||||||
static bool isInfinite(float value);
|
static bool isInfinite(float value);
|
||||||
static bool isInfinite(double value);
|
static bool isInfinite(double value);
|
||||||
static bool isInfinite(long double value);
|
static bool isInfinite(long double value);
|
||||||
/// Returns true iff the given number is infinite.
|
/// Returns true iff the given number is infinite.
|
||||||
|
|
||||||
static bool isNaN(float value);
|
static bool isNaN(float value);
|
||||||
static bool isNaN(double value);
|
static bool isNaN(double value);
|
||||||
static bool isNaN(long double value);
|
static bool isNaN(long double value);
|
||||||
/// Returns true iff the given number is NaN.
|
/// Returns true iff the given number is NaN.
|
||||||
|
|
||||||
static float copySign(float target, float source);
|
static float copySign(float target, float source);
|
||||||
static double copySign(double target, double source);
|
static double copySign(double target, double source);
|
||||||
static long double copySign(long double target, long double source);
|
static long double copySign(long double target, long double source);
|
||||||
/// Copies the sign from source to target.
|
/// Copies the sign from source to target.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// For convenience, we provide a shorter name for
|
// For convenience, we provide a shorter name for
|
||||||
// the FPEnvironment class.
|
// the FPEnvironment class.
|
||||||
//
|
//
|
||||||
typedef FPEnvironment FPE;
|
typedef FPEnvironment FPE;
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inline's
|
// inline's
|
||||||
//
|
//
|
||||||
inline bool FPEnvironment::isFlag(Flag flag)
|
inline bool FPEnvironment::isFlag(Flag flag)
|
||||||
{
|
{
|
||||||
return isFlagImpl(FlagImpl(flag));
|
return isFlagImpl(FlagImpl(flag));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline void FPEnvironment::setRoundingMode(RoundingMode mode)
|
inline void FPEnvironment::setRoundingMode(RoundingMode mode)
|
||||||
{
|
{
|
||||||
setRoundingModeImpl(RoundingModeImpl(mode));
|
setRoundingModeImpl(RoundingModeImpl(mode));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline FPEnvironment::RoundingMode FPEnvironment::getRoundingMode()
|
inline FPEnvironment::RoundingMode FPEnvironment::getRoundingMode()
|
||||||
{
|
{
|
||||||
return RoundingMode(getRoundingModeImpl());
|
return RoundingMode(getRoundingModeImpl());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironment::isInfinite(float value)
|
inline bool FPEnvironment::isInfinite(float value)
|
||||||
{
|
{
|
||||||
return isInfiniteImpl(value);
|
return isInfiniteImpl(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironment::isInfinite(double value)
|
inline bool FPEnvironment::isInfinite(double value)
|
||||||
{
|
{
|
||||||
return isInfiniteImpl(value);
|
return isInfiniteImpl(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironment::isInfinite(long double value)
|
inline bool FPEnvironment::isInfinite(long double value)
|
||||||
{
|
{
|
||||||
return isInfiniteImpl(value);
|
return isInfiniteImpl(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironment::isNaN(float value)
|
inline bool FPEnvironment::isNaN(float value)
|
||||||
{
|
{
|
||||||
return isNaNImpl(value);
|
return isNaNImpl(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironment::isNaN(double value)
|
inline bool FPEnvironment::isNaN(double value)
|
||||||
{
|
{
|
||||||
return isNaNImpl(value);
|
return isNaNImpl(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironment::isNaN(long double value)
|
inline bool FPEnvironment::isNaN(long double value)
|
||||||
{
|
{
|
||||||
return isNaNImpl(value);
|
return isNaNImpl(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float FPEnvironment::copySign(float target, float source)
|
inline float FPEnvironment::copySign(float target, float source)
|
||||||
{
|
{
|
||||||
return copySignImpl(target, source);
|
return copySignImpl(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double FPEnvironment::copySign(double target, double source)
|
inline double FPEnvironment::copySign(double target, double source)
|
||||||
{
|
{
|
||||||
return copySignImpl(target, source);
|
return copySignImpl(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline long double FPEnvironment::copySign(long double target, long double source)
|
inline long double FPEnvironment::copySign(long double target, long double source)
|
||||||
{
|
{
|
||||||
return copySignImpl(target, source);
|
return copySignImpl(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_FPEnvironment_INCLUDED
|
#endif // Foundation_FPEnvironment_INCLUDED
|
||||||
|
|||||||
@@ -1,147 +1,147 @@
|
|||||||
//
|
//
|
||||||
// FPEnvironment_C99.h
|
// FPEnvironment_C99.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_C99.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_C99.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: FPEnvironment
|
// Module: FPEnvironment
|
||||||
//
|
//
|
||||||
// Definitions of class FPEnvironmentImpl for C99.
|
// Definitions of class FPEnvironmentImpl for C99.
|
||||||
//
|
//
|
||||||
// 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_FPEnvironment_C99_INCLUDED
|
#ifndef Foundation_FPEnvironment_C99_INCLUDED
|
||||||
#define Foundation_FPEnvironment_C99_INCLUDED
|
#define Foundation_FPEnvironment_C99_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <fenv.h>
|
#include <fenv.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class FPEnvironmentImpl
|
class FPEnvironmentImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
enum RoundingModeImpl
|
enum RoundingModeImpl
|
||||||
{
|
{
|
||||||
FP_ROUND_DOWNWARD_IMPL = FE_DOWNWARD,
|
FP_ROUND_DOWNWARD_IMPL = FE_DOWNWARD,
|
||||||
FP_ROUND_UPWARD_IMPL = FE_UPWARD,
|
FP_ROUND_UPWARD_IMPL = FE_UPWARD,
|
||||||
FP_ROUND_TONEAREST_IMPL = FE_TONEAREST,
|
FP_ROUND_TONEAREST_IMPL = FE_TONEAREST,
|
||||||
FP_ROUND_TOWARDZERO_IMPL = FE_TOWARDZERO
|
FP_ROUND_TOWARDZERO_IMPL = FE_TOWARDZERO
|
||||||
};
|
};
|
||||||
enum FlagImpl
|
enum FlagImpl
|
||||||
{
|
{
|
||||||
FP_DIVIDE_BY_ZERO_IMPL = FE_DIVBYZERO,
|
FP_DIVIDE_BY_ZERO_IMPL = FE_DIVBYZERO,
|
||||||
FP_INEXACT_IMPL = FE_INEXACT,
|
FP_INEXACT_IMPL = FE_INEXACT,
|
||||||
FP_OVERFLOW_IMPL = FE_OVERFLOW,
|
FP_OVERFLOW_IMPL = FE_OVERFLOW,
|
||||||
FP_UNDERFLOW_IMPL = FE_UNDERFLOW,
|
FP_UNDERFLOW_IMPL = FE_UNDERFLOW,
|
||||||
FP_INVALID_IMPL = FE_INVALID
|
FP_INVALID_IMPL = FE_INVALID
|
||||||
};
|
};
|
||||||
FPEnvironmentImpl();
|
FPEnvironmentImpl();
|
||||||
FPEnvironmentImpl(const FPEnvironmentImpl& env);
|
FPEnvironmentImpl(const FPEnvironmentImpl& env);
|
||||||
~FPEnvironmentImpl();
|
~FPEnvironmentImpl();
|
||||||
FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
|
FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
|
||||||
void keepCurrentImpl();
|
void keepCurrentImpl();
|
||||||
static void clearFlagsImpl();
|
static void clearFlagsImpl();
|
||||||
static bool isFlagImpl(FlagImpl flag);
|
static bool isFlagImpl(FlagImpl flag);
|
||||||
static void setRoundingModeImpl(RoundingModeImpl mode);
|
static void setRoundingModeImpl(RoundingModeImpl mode);
|
||||||
static RoundingModeImpl getRoundingModeImpl();
|
static RoundingModeImpl getRoundingModeImpl();
|
||||||
static bool isInfiniteImpl(float value);
|
static bool isInfiniteImpl(float value);
|
||||||
static bool isInfiniteImpl(double value);
|
static bool isInfiniteImpl(double value);
|
||||||
static bool isInfiniteImpl(long double value);
|
static bool isInfiniteImpl(long double value);
|
||||||
static bool isNaNImpl(float value);
|
static bool isNaNImpl(float value);
|
||||||
static bool isNaNImpl(double value);
|
static bool isNaNImpl(double value);
|
||||||
static bool isNaNImpl(long double value);
|
static bool isNaNImpl(long double value);
|
||||||
static float copySignImpl(float target, float source);
|
static float copySignImpl(float target, float source);
|
||||||
static double copySignImpl(double target, double source);
|
static double copySignImpl(double target, double source);
|
||||||
static long double copySignImpl(long double target, long double source);
|
static long double copySignImpl(long double target, long double source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
fenv_t _env;
|
fenv_t _env;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline bool FPEnvironmentImpl::isInfiniteImpl(float value)
|
inline bool FPEnvironmentImpl::isInfiniteImpl(float value)
|
||||||
{
|
{
|
||||||
return isinf(value) != 0;
|
return isinf(value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isInfiniteImpl(double value)
|
inline bool FPEnvironmentImpl::isInfiniteImpl(double value)
|
||||||
{
|
{
|
||||||
return isinf(value) != 0;
|
return isinf(value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isInfiniteImpl(long double value)
|
inline bool FPEnvironmentImpl::isInfiniteImpl(long double value)
|
||||||
{
|
{
|
||||||
return isinf((double) value) != 0;
|
return isinf((double) value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isNaNImpl(float value)
|
inline bool FPEnvironmentImpl::isNaNImpl(float value)
|
||||||
{
|
{
|
||||||
return isnan(value) != 0;
|
return isnan(value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isNaNImpl(double value)
|
inline bool FPEnvironmentImpl::isNaNImpl(double value)
|
||||||
{
|
{
|
||||||
return isnan(value) != 0;
|
return isnan(value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isNaNImpl(long double value)
|
inline bool FPEnvironmentImpl::isNaNImpl(long double value)
|
||||||
{
|
{
|
||||||
return isnan((double) value) != 0;
|
return isnan((double) value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float FPEnvironmentImpl::copySignImpl(float target, float source)
|
inline float FPEnvironmentImpl::copySignImpl(float target, float source)
|
||||||
{
|
{
|
||||||
return copysignf(target, source);
|
return copysignf(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double FPEnvironmentImpl::copySignImpl(double target, double source)
|
inline double FPEnvironmentImpl::copySignImpl(double target, double source)
|
||||||
{
|
{
|
||||||
return copysign(target, source);
|
return copysign(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_FPEnvironment_C99_INCLUDED
|
#endif // Foundation_FPEnvironment_C99_INCLUDED
|
||||||
|
|||||||
@@ -1,111 +1,111 @@
|
|||||||
//
|
//
|
||||||
// FPEnvironment_DEC.h
|
// FPEnvironment_DEC.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_DEC.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_DEC.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: FPEnvironment
|
// Module: FPEnvironment
|
||||||
//
|
//
|
||||||
// Definitions of class FPEnvironmentImpl for Tru64 and OpenVMS Alpha.
|
// Definitions of class FPEnvironmentImpl for Tru64 and OpenVMS Alpha.
|
||||||
//
|
//
|
||||||
// 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_FPEnvironment_DEC_INCLUDED
|
#ifndef Foundation_FPEnvironment_DEC_INCLUDED
|
||||||
#define Foundation_FPEnvironment_DEC_INCLUDED
|
#define Foundation_FPEnvironment_DEC_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#if defined(__VMS)
|
#if defined(__VMS)
|
||||||
#include <ieeedef.h>
|
#include <ieeedef.h>
|
||||||
#else
|
#else
|
||||||
#include <machine/fpu.h>
|
#include <machine/fpu.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class FPEnvironmentImpl
|
class FPEnvironmentImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
enum RoundingModeImpl
|
enum RoundingModeImpl
|
||||||
{
|
{
|
||||||
FP_ROUND_DOWNWARD_IMPL = 0,
|
FP_ROUND_DOWNWARD_IMPL = 0,
|
||||||
FP_ROUND_UPWARD_IMPL = 0,
|
FP_ROUND_UPWARD_IMPL = 0,
|
||||||
FP_ROUND_TONEAREST_IMPL = 0,
|
FP_ROUND_TONEAREST_IMPL = 0,
|
||||||
FP_ROUND_TOWARDZERO_IMPL = 0
|
FP_ROUND_TOWARDZERO_IMPL = 0
|
||||||
};
|
};
|
||||||
enum FlagImpl
|
enum FlagImpl
|
||||||
{
|
{
|
||||||
#if defined(__VMS)
|
#if defined(__VMS)
|
||||||
FP_DIVIDE_BY_ZERO_IMPL = IEEE$M_STATUS_DZE,
|
FP_DIVIDE_BY_ZERO_IMPL = IEEE$M_STATUS_DZE,
|
||||||
FP_INEXACT_IMPL = IEEE$M_STATUS_INE,
|
FP_INEXACT_IMPL = IEEE$M_STATUS_INE,
|
||||||
FP_OVERFLOW_IMPL = IEEE$M_STATUS_OVF,
|
FP_OVERFLOW_IMPL = IEEE$M_STATUS_OVF,
|
||||||
FP_UNDERFLOW_IMPL = IEEE$M_STATUS_UNF,
|
FP_UNDERFLOW_IMPL = IEEE$M_STATUS_UNF,
|
||||||
FP_INVALID_IMPL = IEEE$M_STATUS_INV
|
FP_INVALID_IMPL = IEEE$M_STATUS_INV
|
||||||
#else
|
#else
|
||||||
FP_DIVIDE_BY_ZERO_IMPL = IEEE_STATUS_DZE,
|
FP_DIVIDE_BY_ZERO_IMPL = IEEE_STATUS_DZE,
|
||||||
FP_INEXACT_IMPL = IEEE_STATUS_INE,
|
FP_INEXACT_IMPL = IEEE_STATUS_INE,
|
||||||
FP_OVERFLOW_IMPL = IEEE_STATUS_OVF,
|
FP_OVERFLOW_IMPL = IEEE_STATUS_OVF,
|
||||||
FP_UNDERFLOW_IMPL = IEEE_STATUS_UNF,
|
FP_UNDERFLOW_IMPL = IEEE_STATUS_UNF,
|
||||||
FP_INVALID_IMPL = IEEE_STATUS_INV
|
FP_INVALID_IMPL = IEEE_STATUS_INV
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
FPEnvironmentImpl();
|
FPEnvironmentImpl();
|
||||||
FPEnvironmentImpl(const FPEnvironmentImpl& env);
|
FPEnvironmentImpl(const FPEnvironmentImpl& env);
|
||||||
~FPEnvironmentImpl();
|
~FPEnvironmentImpl();
|
||||||
FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
|
FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
|
||||||
void keepCurrentImpl();
|
void keepCurrentImpl();
|
||||||
static void clearFlagsImpl();
|
static void clearFlagsImpl();
|
||||||
static bool isFlagImpl(FlagImpl flag);
|
static bool isFlagImpl(FlagImpl flag);
|
||||||
static void setRoundingModeImpl(RoundingModeImpl mode);
|
static void setRoundingModeImpl(RoundingModeImpl mode);
|
||||||
static RoundingModeImpl getRoundingModeImpl();
|
static RoundingModeImpl getRoundingModeImpl();
|
||||||
static bool isInfiniteImpl(float value);
|
static bool isInfiniteImpl(float value);
|
||||||
static bool isInfiniteImpl(double value);
|
static bool isInfiniteImpl(double value);
|
||||||
static bool isInfiniteImpl(long double value);
|
static bool isInfiniteImpl(long double value);
|
||||||
static bool isNaNImpl(float value);
|
static bool isNaNImpl(float value);
|
||||||
static bool isNaNImpl(double value);
|
static bool isNaNImpl(double value);
|
||||||
static bool isNaNImpl(long double value);
|
static bool isNaNImpl(long double value);
|
||||||
static float copySignImpl(float target, float source);
|
static float copySignImpl(float target, float source);
|
||||||
static double copySignImpl(double target, double source);
|
static double copySignImpl(double target, double source);
|
||||||
static long double copySignImpl(long double target, long double source);
|
static long double copySignImpl(long double target, long double source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
#if defined(__VMS)
|
#if defined(__VMS)
|
||||||
struct _ieee _env;
|
struct _ieee _env;
|
||||||
#else
|
#else
|
||||||
unsigned long _env;
|
unsigned long _env;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_FPEnvironment_DEC_INCLUDED
|
#endif // Foundation_FPEnvironment_DEC_INCLUDED
|
||||||
|
|||||||
@@ -1,147 +1,147 @@
|
|||||||
//
|
//
|
||||||
// FPEnvironment_DUMMY.h
|
// FPEnvironment_DUMMY.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_DUMMY.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_DUMMY.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: FPEnvironment
|
// Module: FPEnvironment
|
||||||
//
|
//
|
||||||
// Definition of class FPEnvironmentImpl for platforms that do not
|
// Definition of class FPEnvironmentImpl for platforms that do not
|
||||||
// support IEEE 754 extensions.
|
// support IEEE 754 extensions.
|
||||||
//
|
//
|
||||||
// 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_FPEnvironment_DUMMY_INCLUDED
|
#ifndef Foundation_FPEnvironment_DUMMY_INCLUDED
|
||||||
#define Foundation_FPEnvironment_DUMMY_INCLUDED
|
#define Foundation_FPEnvironment_DUMMY_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FPEnvironmentImpl
|
class Foundation_API FPEnvironmentImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
enum RoundingModeImpl
|
enum RoundingModeImpl
|
||||||
{
|
{
|
||||||
FP_ROUND_DOWNWARD_IMPL,
|
FP_ROUND_DOWNWARD_IMPL,
|
||||||
FP_ROUND_UPWARD_IMPL,
|
FP_ROUND_UPWARD_IMPL,
|
||||||
FP_ROUND_TONEAREST_IMPL,
|
FP_ROUND_TONEAREST_IMPL,
|
||||||
FP_ROUND_TOWARDZERO_IMPL
|
FP_ROUND_TOWARDZERO_IMPL
|
||||||
};
|
};
|
||||||
enum FlagImpl
|
enum FlagImpl
|
||||||
{
|
{
|
||||||
FP_DIVIDE_BY_ZERO_IMPL,
|
FP_DIVIDE_BY_ZERO_IMPL,
|
||||||
FP_INEXACT_IMPL,
|
FP_INEXACT_IMPL,
|
||||||
FP_OVERFLOW_IMPL,
|
FP_OVERFLOW_IMPL,
|
||||||
FP_UNDERFLOW_IMPL,
|
FP_UNDERFLOW_IMPL,
|
||||||
FP_INVALID_IMPL
|
FP_INVALID_IMPL
|
||||||
};
|
};
|
||||||
FPEnvironmentImpl();
|
FPEnvironmentImpl();
|
||||||
FPEnvironmentImpl(const FPEnvironmentImpl& env);
|
FPEnvironmentImpl(const FPEnvironmentImpl& env);
|
||||||
~FPEnvironmentImpl();
|
~FPEnvironmentImpl();
|
||||||
FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
|
FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
|
||||||
void keepCurrentImpl();
|
void keepCurrentImpl();
|
||||||
static void clearFlagsImpl();
|
static void clearFlagsImpl();
|
||||||
static bool isFlagImpl(FlagImpl flag);
|
static bool isFlagImpl(FlagImpl flag);
|
||||||
static void setRoundingModeImpl(RoundingModeImpl mode);
|
static void setRoundingModeImpl(RoundingModeImpl mode);
|
||||||
static RoundingModeImpl getRoundingModeImpl();
|
static RoundingModeImpl getRoundingModeImpl();
|
||||||
static bool isInfiniteImpl(float value);
|
static bool isInfiniteImpl(float value);
|
||||||
static bool isInfiniteImpl(double value);
|
static bool isInfiniteImpl(double value);
|
||||||
static bool isInfiniteImpl(long double value);
|
static bool isInfiniteImpl(long double value);
|
||||||
static bool isNaNImpl(float value);
|
static bool isNaNImpl(float value);
|
||||||
static bool isNaNImpl(double value);
|
static bool isNaNImpl(double value);
|
||||||
static bool isNaNImpl(long double value);
|
static bool isNaNImpl(long double value);
|
||||||
static float copySignImpl(float target, float source);
|
static float copySignImpl(float target, float source);
|
||||||
static double copySignImpl(double target, double source);
|
static double copySignImpl(double target, double source);
|
||||||
static long double copySignImpl(long double target, long double source);
|
static long double copySignImpl(long double target, long double source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static RoundingModeImpl _roundingMode;
|
static RoundingModeImpl _roundingMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline bool FPEnvironmentImpl::isInfiniteImpl(float value)
|
inline bool FPEnvironmentImpl::isInfiniteImpl(float value)
|
||||||
{
|
{
|
||||||
return isinf(value) != 0;
|
return isinf(value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isInfiniteImpl(double value)
|
inline bool FPEnvironmentImpl::isInfiniteImpl(double value)
|
||||||
{
|
{
|
||||||
return isinf(value) != 0;
|
return isinf(value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isInfiniteImpl(long double value)
|
inline bool FPEnvironmentImpl::isInfiniteImpl(long double value)
|
||||||
{
|
{
|
||||||
return isinf((double) value) != 0;
|
return isinf((double) value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isNaNImpl(float value)
|
inline bool FPEnvironmentImpl::isNaNImpl(float value)
|
||||||
{
|
{
|
||||||
return isnan(value) != 0;
|
return isnan(value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isNaNImpl(double value)
|
inline bool FPEnvironmentImpl::isNaNImpl(double value)
|
||||||
{
|
{
|
||||||
return isnan(value) != 0;
|
return isnan(value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isNaNImpl(long double value)
|
inline bool FPEnvironmentImpl::isNaNImpl(long double value)
|
||||||
{
|
{
|
||||||
return isnan((double) value) != 0;
|
return isnan((double) value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float FPEnvironmentImpl::copySignImpl(float target, float source)
|
inline float FPEnvironmentImpl::copySignImpl(float target, float source)
|
||||||
{
|
{
|
||||||
return copysignf(target, source);
|
return copysignf(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double FPEnvironmentImpl::copySignImpl(double target, double source)
|
inline double FPEnvironmentImpl::copySignImpl(double target, double source)
|
||||||
{
|
{
|
||||||
return copysign(target, source);
|
return copysign(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_FPEnvironment_DUMMY_INCLUDED
|
#endif // Foundation_FPEnvironment_DUMMY_INCLUDED
|
||||||
|
|||||||
@@ -1,96 +1,96 @@
|
|||||||
//
|
//
|
||||||
// FPEnvironment_SUN.h
|
// FPEnvironment_SUN.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_SUN.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_SUN.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: FPEnvironment
|
// Module: FPEnvironment
|
||||||
//
|
//
|
||||||
// Definitions of class FPEnvironmentImpl for Solaris.
|
// Definitions of class FPEnvironmentImpl for Solaris.
|
||||||
//
|
//
|
||||||
// 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 Foundation_FPEnvironment_SUN_INCLUDED
|
#ifndef Foundation_FPEnvironment_SUN_INCLUDED
|
||||||
#define Foundation_FPEnvironment_SUN_INCLUDED
|
#define Foundation_FPEnvironment_SUN_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <ieeefp.h>
|
#include <ieeefp.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class FPEnvironmentImpl
|
class FPEnvironmentImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
enum RoundingModeImpl
|
enum RoundingModeImpl
|
||||||
{
|
{
|
||||||
FP_ROUND_DOWNWARD_IMPL = FP_RM,
|
FP_ROUND_DOWNWARD_IMPL = FP_RM,
|
||||||
FP_ROUND_UPWARD_IMPL = FP_RP,
|
FP_ROUND_UPWARD_IMPL = FP_RP,
|
||||||
FP_ROUND_TONEAREST_IMPL = FP_RN,
|
FP_ROUND_TONEAREST_IMPL = FP_RN,
|
||||||
FP_ROUND_TOWARDZERO_IMPL = FP_RZ
|
FP_ROUND_TOWARDZERO_IMPL = FP_RZ
|
||||||
};
|
};
|
||||||
enum FlagImpl
|
enum FlagImpl
|
||||||
{
|
{
|
||||||
FP_DIVIDE_BY_ZERO_IMPL = FP_X_DZ,
|
FP_DIVIDE_BY_ZERO_IMPL = FP_X_DZ,
|
||||||
FP_INEXACT_IMPL = FP_X_IMP,
|
FP_INEXACT_IMPL = FP_X_IMP,
|
||||||
FP_OVERFLOW_IMPL = FP_X_OFL,
|
FP_OVERFLOW_IMPL = FP_X_OFL,
|
||||||
FP_UNDERFLOW_IMPL = FP_X_UFL,
|
FP_UNDERFLOW_IMPL = FP_X_UFL,
|
||||||
FP_INVALID_IMPL = FP_X_INV
|
FP_INVALID_IMPL = FP_X_INV
|
||||||
};
|
};
|
||||||
FPEnvironmentImpl();
|
FPEnvironmentImpl();
|
||||||
FPEnvironmentImpl(const FPEnvironmentImpl& env);
|
FPEnvironmentImpl(const FPEnvironmentImpl& env);
|
||||||
~FPEnvironmentImpl();
|
~FPEnvironmentImpl();
|
||||||
FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
|
FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
|
||||||
void keepCurrentImpl();
|
void keepCurrentImpl();
|
||||||
static void clearFlagsImpl();
|
static void clearFlagsImpl();
|
||||||
static bool isFlagImpl(FlagImpl flag);
|
static bool isFlagImpl(FlagImpl flag);
|
||||||
static void setRoundingModeImpl(RoundingModeImpl mode);
|
static void setRoundingModeImpl(RoundingModeImpl mode);
|
||||||
static RoundingModeImpl getRoundingModeImpl();
|
static RoundingModeImpl getRoundingModeImpl();
|
||||||
static bool isInfiniteImpl(float value);
|
static bool isInfiniteImpl(float value);
|
||||||
static bool isInfiniteImpl(double value);
|
static bool isInfiniteImpl(double value);
|
||||||
static bool isInfiniteImpl(long double value);
|
static bool isInfiniteImpl(long double value);
|
||||||
static bool isNaNImpl(float value);
|
static bool isNaNImpl(float value);
|
||||||
static bool isNaNImpl(double value);
|
static bool isNaNImpl(double value);
|
||||||
static bool isNaNImpl(long double value);
|
static bool isNaNImpl(long double value);
|
||||||
static float copySignImpl(float target, float source);
|
static float copySignImpl(float target, float source);
|
||||||
static double copySignImpl(double target, double source);
|
static double copySignImpl(double target, double source);
|
||||||
static long double copySignImpl(long double target, long double source);
|
static long double copySignImpl(long double target, long double source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
fp_rnd _rnd;
|
fp_rnd _rnd;
|
||||||
fp_except _exc;
|
fp_except _exc;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_FPEnvironment_SUN_INCLUDED
|
#endif // Foundation_FPEnvironment_SUN_INCLUDED
|
||||||
|
|||||||
@@ -1,153 +1,153 @@
|
|||||||
//
|
//
|
||||||
// FPEnvironment_WIN32.h
|
// FPEnvironment_WIN32.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_WIN32.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_WIN32.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: FPEnvironment
|
// Module: FPEnvironment
|
||||||
//
|
//
|
||||||
// Definitions of class FPEnvironmentImpl for WIN32.
|
// Definitions of class FPEnvironmentImpl for WIN32.
|
||||||
//
|
//
|
||||||
// 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_FPEnvironment_WIN32_INCLUDED
|
#ifndef Foundation_FPEnvironment_WIN32_INCLUDED
|
||||||
#define Foundation_FPEnvironment_WIN32_INCLUDED
|
#define Foundation_FPEnvironment_WIN32_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <float.h>
|
#include <float.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FPEnvironmentImpl
|
class Foundation_API FPEnvironmentImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
enum RoundingModeImpl
|
enum RoundingModeImpl
|
||||||
{
|
{
|
||||||
FP_ROUND_DOWNWARD_IMPL = RC_DOWN,
|
FP_ROUND_DOWNWARD_IMPL = RC_DOWN,
|
||||||
FP_ROUND_UPWARD_IMPL = RC_UP,
|
FP_ROUND_UPWARD_IMPL = RC_UP,
|
||||||
FP_ROUND_TONEAREST_IMPL = RC_NEAR,
|
FP_ROUND_TONEAREST_IMPL = RC_NEAR,
|
||||||
FP_ROUND_TOWARDZERO_IMPL = RC_CHOP
|
FP_ROUND_TOWARDZERO_IMPL = RC_CHOP
|
||||||
};
|
};
|
||||||
enum FlagImpl
|
enum FlagImpl
|
||||||
{
|
{
|
||||||
FP_DIVIDE_BY_ZERO_IMPL = SW_ZERODIVIDE,
|
FP_DIVIDE_BY_ZERO_IMPL = SW_ZERODIVIDE,
|
||||||
FP_INEXACT_IMPL = SW_INEXACT,
|
FP_INEXACT_IMPL = SW_INEXACT,
|
||||||
FP_OVERFLOW_IMPL = SW_OVERFLOW,
|
FP_OVERFLOW_IMPL = SW_OVERFLOW,
|
||||||
FP_UNDERFLOW_IMPL = SW_UNDERFLOW,
|
FP_UNDERFLOW_IMPL = SW_UNDERFLOW,
|
||||||
FP_INVALID_IMPL = SW_INVALID
|
FP_INVALID_IMPL = SW_INVALID
|
||||||
};
|
};
|
||||||
FPEnvironmentImpl();
|
FPEnvironmentImpl();
|
||||||
FPEnvironmentImpl(const FPEnvironmentImpl& env);
|
FPEnvironmentImpl(const FPEnvironmentImpl& env);
|
||||||
~FPEnvironmentImpl();
|
~FPEnvironmentImpl();
|
||||||
FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
|
FPEnvironmentImpl& operator = (const FPEnvironmentImpl& env);
|
||||||
void keepCurrentImpl();
|
void keepCurrentImpl();
|
||||||
static void clearFlagsImpl();
|
static void clearFlagsImpl();
|
||||||
static bool isFlagImpl(FlagImpl flag);
|
static bool isFlagImpl(FlagImpl flag);
|
||||||
static void setRoundingModeImpl(RoundingModeImpl mode);
|
static void setRoundingModeImpl(RoundingModeImpl mode);
|
||||||
static RoundingModeImpl getRoundingModeImpl();
|
static RoundingModeImpl getRoundingModeImpl();
|
||||||
static bool isInfiniteImpl(float value);
|
static bool isInfiniteImpl(float value);
|
||||||
static bool isInfiniteImpl(double value);
|
static bool isInfiniteImpl(double value);
|
||||||
static bool isInfiniteImpl(long double value);
|
static bool isInfiniteImpl(long double value);
|
||||||
static bool isNaNImpl(float value);
|
static bool isNaNImpl(float value);
|
||||||
static bool isNaNImpl(double value);
|
static bool isNaNImpl(double value);
|
||||||
static bool isNaNImpl(long double value);
|
static bool isNaNImpl(long double value);
|
||||||
static float copySignImpl(float target, float source);
|
static float copySignImpl(float target, float source);
|
||||||
static double copySignImpl(double target, double source);
|
static double copySignImpl(double target, double source);
|
||||||
static long double copySignImpl(long double target, long double source);
|
static long double copySignImpl(long double target, long double source);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned _env;
|
unsigned _env;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline bool FPEnvironmentImpl::isInfiniteImpl(float value)
|
inline bool FPEnvironmentImpl::isInfiniteImpl(float value)
|
||||||
{
|
{
|
||||||
return _finite(value) == 0;
|
return _finite(value) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isInfiniteImpl(double value)
|
inline bool FPEnvironmentImpl::isInfiniteImpl(double value)
|
||||||
{
|
{
|
||||||
return _finite(value) == 0;
|
return _finite(value) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isInfiniteImpl(long double value)
|
inline bool FPEnvironmentImpl::isInfiniteImpl(long double value)
|
||||||
{
|
{
|
||||||
return _finite(value) == 0;
|
return _finite(value) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isNaNImpl(float value)
|
inline bool FPEnvironmentImpl::isNaNImpl(float value)
|
||||||
{
|
{
|
||||||
return _isnan(value) != 0;
|
return _isnan(value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isNaNImpl(double value)
|
inline bool FPEnvironmentImpl::isNaNImpl(double value)
|
||||||
{
|
{
|
||||||
return _isnan(value) != 0;
|
return _isnan(value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline bool FPEnvironmentImpl::isNaNImpl(long double value)
|
inline bool FPEnvironmentImpl::isNaNImpl(long double value)
|
||||||
{
|
{
|
||||||
return _isnan(value) != 0;
|
return _isnan(value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline float FPEnvironmentImpl::copySignImpl(float target, float source)
|
inline float FPEnvironmentImpl::copySignImpl(float target, float source)
|
||||||
{
|
{
|
||||||
return float(_copysign(target, source));
|
return float(_copysign(target, source));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double FPEnvironmentImpl::copySignImpl(double target, double source)
|
inline double FPEnvironmentImpl::copySignImpl(double target, double source)
|
||||||
{
|
{
|
||||||
return _copysign(target, source);
|
return _copysign(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
|
inline long double FPEnvironmentImpl::copySignImpl(long double target, long double source)
|
||||||
{
|
{
|
||||||
return (source > 0 && target > 0) || (source < 0 && target < 0) ? target : -target;
|
return (source > 0 && target > 0) || (source < 0 && target < 0) ? target : -target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_FPEnvironment_WIN32_INCLUDED
|
#endif // Foundation_FPEnvironment_WIN32_INCLUDED
|
||||||
|
|||||||
@@ -1,194 +1,194 @@
|
|||||||
//
|
//
|
||||||
// FileStream.h
|
// FileStream.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/FileStream.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/FileStream.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: FileStream
|
// Module: FileStream
|
||||||
//
|
//
|
||||||
// Definition of the FileStreamBuf, FileInputStream and FileOutputStream classes.
|
// Definition of the FileStreamBuf, FileInputStream and FileOutputStream classes.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2007, 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_FileStream_INCLUDED
|
#ifndef Foundation_FileStream_INCLUDED
|
||||||
#define Foundation_FileStream_INCLUDED
|
#define Foundation_FileStream_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#if defined(POCO_OS_FAMILY_WINDOWS)
|
#if defined(POCO_OS_FAMILY_WINDOWS)
|
||||||
#include "FileStream_WIN32.h"
|
#include "FileStream_WIN32.h"
|
||||||
#else
|
#else
|
||||||
#include "FileStream_POSIX.h"
|
#include "FileStream_POSIX.h"
|
||||||
#endif
|
#endif
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FileIOS: public virtual std::ios
|
class Foundation_API FileIOS: public virtual std::ios
|
||||||
/// The base class for FileInputStream and FileOutputStream.
|
/// The base class for FileInputStream and FileOutputStream.
|
||||||
///
|
///
|
||||||
/// This class is needed to ensure the correct initialization
|
/// This class is needed to ensure the correct initialization
|
||||||
/// order of the stream buffer and base classes.
|
/// order of the stream buffer and base classes.
|
||||||
///
|
///
|
||||||
/// Files are always opened in binary mode, a text mode
|
/// Files are always opened in binary mode, a text mode
|
||||||
/// with CR-LF translation is not supported. Thus, the
|
/// with CR-LF translation is not supported. Thus, the
|
||||||
/// file is always opened as if the std::ios::binary flag
|
/// file is always opened as if the std::ios::binary flag
|
||||||
/// was specified.
|
/// was specified.
|
||||||
/// Use an InputLineEndingConverter or OutputLineEndingConverter
|
/// Use an InputLineEndingConverter or OutputLineEndingConverter
|
||||||
/// if you require CR-LF translation.
|
/// if you require CR-LF translation.
|
||||||
///
|
///
|
||||||
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd,
|
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd,
|
||||||
/// UTF-8 encoded Unicode paths are correctly handled.
|
/// UTF-8 encoded Unicode paths are correctly handled.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileIOS(std::ios::openmode defaultMode);
|
FileIOS(std::ios::openmode defaultMode);
|
||||||
/// Creates the basic stream.
|
/// Creates the basic stream.
|
||||||
|
|
||||||
~FileIOS();
|
~FileIOS();
|
||||||
/// Destroys the stream.
|
/// Destroys the stream.
|
||||||
|
|
||||||
void open(const std::string& path, std::ios::openmode mode);
|
void open(const std::string& path, std::ios::openmode mode);
|
||||||
/// Opens the file specified by path, using the given mode.
|
/// Opens the file specified by path, using the given mode.
|
||||||
///
|
///
|
||||||
/// Throws a FileException (or a similar exception) if the file
|
/// Throws a FileException (or a similar exception) if the file
|
||||||
/// does not exist or is not accessible for other reasons and
|
/// does not exist or is not accessible for other reasons and
|
||||||
/// a new file cannot be created.
|
/// a new file cannot be created.
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
/// Closes the file stream.
|
/// Closes the file stream.
|
||||||
|
|
||||||
FileStreamBuf* rdbuf();
|
FileStreamBuf* rdbuf();
|
||||||
/// Returns a pointer to the underlying streambuf.
|
/// Returns a pointer to the underlying streambuf.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
FileStreamBuf _buf;
|
FileStreamBuf _buf;
|
||||||
std::ios::openmode _defaultMode;
|
std::ios::openmode _defaultMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FileInputStream: public FileIOS, public std::istream
|
class Foundation_API FileInputStream: public FileIOS, public std::istream
|
||||||
/// An input stream for reading from a file.
|
/// An input stream for reading from a file.
|
||||||
///
|
///
|
||||||
/// Files are always opened in binary mode, a text mode
|
/// Files are always opened in binary mode, a text mode
|
||||||
/// with CR-LF translation is not supported. Thus, the
|
/// with CR-LF translation is not supported. Thus, the
|
||||||
/// file is always opened as if the std::ios::binary flag
|
/// file is always opened as if the std::ios::binary flag
|
||||||
/// was specified.
|
/// was specified.
|
||||||
/// Use an InputLineEndingConverter if you require CR-LF translation.
|
/// Use an InputLineEndingConverter if you require CR-LF translation.
|
||||||
///
|
///
|
||||||
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd,
|
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd,
|
||||||
/// UTF-8 encoded Unicode paths are correctly handled.
|
/// UTF-8 encoded Unicode paths are correctly handled.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileInputStream();
|
FileInputStream();
|
||||||
/// Creates an unopened FileInputStream.
|
/// Creates an unopened FileInputStream.
|
||||||
|
|
||||||
FileInputStream(const std::string& path, std::ios::openmode mode = std::ios::in);
|
FileInputStream(const std::string& path, std::ios::openmode mode = std::ios::in);
|
||||||
/// Creates the FileInputStream for the file given by path, using
|
/// Creates the FileInputStream for the file given by path, using
|
||||||
/// the given mode.
|
/// the given mode.
|
||||||
///
|
///
|
||||||
/// The std::ios::in flag is always set, regardless of the actual
|
/// The std::ios::in flag is always set, regardless of the actual
|
||||||
/// value specified for mode.
|
/// value specified for mode.
|
||||||
///
|
///
|
||||||
/// Throws a FileNotFoundException (or a similar exception) if the file
|
/// Throws a FileNotFoundException (or a similar exception) if the file
|
||||||
/// does not exist or is not accessible for other reasons.
|
/// does not exist or is not accessible for other reasons.
|
||||||
|
|
||||||
~FileInputStream();
|
~FileInputStream();
|
||||||
/// Destroys the stream.
|
/// Destroys the stream.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FileOutputStream: public FileIOS, public std::ostream
|
class Foundation_API FileOutputStream: public FileIOS, public std::ostream
|
||||||
/// An output stream for writing to a file.
|
/// An output stream for writing to a file.
|
||||||
///
|
///
|
||||||
/// Files are always opened in binary mode, a text mode
|
/// Files are always opened in binary mode, a text mode
|
||||||
/// with CR-LF translation is not supported. Thus, the
|
/// with CR-LF translation is not supported. Thus, the
|
||||||
/// file is always opened as if the std::ios::binary flag
|
/// file is always opened as if the std::ios::binary flag
|
||||||
/// was specified.
|
/// was specified.
|
||||||
/// Use an OutputLineEndingConverter if you require CR-LF translation.
|
/// Use an OutputLineEndingConverter if you require CR-LF translation.
|
||||||
///
|
///
|
||||||
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd,
|
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd,
|
||||||
/// UTF-8 encoded Unicode paths are correctly handled.
|
/// UTF-8 encoded Unicode paths are correctly handled.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileOutputStream();
|
FileOutputStream();
|
||||||
/// Creats an unopened FileOutputStream.
|
/// Creats an unopened FileOutputStream.
|
||||||
|
|
||||||
FileOutputStream(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::trunc);
|
FileOutputStream(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::trunc);
|
||||||
/// Creates the FileOutputStream for the file given by path, using
|
/// Creates the FileOutputStream for the file given by path, using
|
||||||
/// the given mode.
|
/// the given mode.
|
||||||
///
|
///
|
||||||
/// The std::ios::out is always set, regardless of the actual
|
/// The std::ios::out is always set, regardless of the actual
|
||||||
/// value specified for mode.
|
/// value specified for mode.
|
||||||
///
|
///
|
||||||
/// Throws a FileException (or a similar exception) if the file
|
/// Throws a FileException (or a similar exception) if the file
|
||||||
/// does not exist or is not accessible for other reasons and
|
/// does not exist or is not accessible for other reasons and
|
||||||
/// a new file cannot be created.
|
/// a new file cannot be created.
|
||||||
|
|
||||||
~FileOutputStream();
|
~FileOutputStream();
|
||||||
/// Destroys the FileOutputStream.
|
/// Destroys the FileOutputStream.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FileStream: public FileIOS, public std::iostream
|
class Foundation_API FileStream: public FileIOS, public std::iostream
|
||||||
/// A stream for reading from and writing to a file.
|
/// A stream for reading from and writing to a file.
|
||||||
///
|
///
|
||||||
/// Files are always opened in binary mode, a text mode
|
/// Files are always opened in binary mode, a text mode
|
||||||
/// with CR-LF translation is not supported. Thus, the
|
/// with CR-LF translation is not supported. Thus, the
|
||||||
/// file is always opened as if the std::ios::binary flag
|
/// file is always opened as if the std::ios::binary flag
|
||||||
/// was specified.
|
/// was specified.
|
||||||
/// Use an InputLineEndingConverter or OutputLineEndingConverter
|
/// Use an InputLineEndingConverter or OutputLineEndingConverter
|
||||||
/// if you require CR-LF translation.
|
/// if you require CR-LF translation.
|
||||||
///
|
///
|
||||||
/// A seek (seekg() or seekp()) operation will always set the
|
/// A seek (seekg() or seekp()) operation will always set the
|
||||||
/// read position and the write position simultaneously to the
|
/// read position and the write position simultaneously to the
|
||||||
/// same value.
|
/// same value.
|
||||||
///
|
///
|
||||||
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd,
|
/// On Windows platforms, if POCO_WIN32_UTF8 is #define'd,
|
||||||
/// UTF-8 encoded Unicode paths are correctly handled.
|
/// UTF-8 encoded Unicode paths are correctly handled.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileStream();
|
FileStream();
|
||||||
/// Creats an unopened FileStream.
|
/// Creats an unopened FileStream.
|
||||||
|
|
||||||
FileStream(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::in);
|
FileStream(const std::string& path, std::ios::openmode mode = std::ios::out | std::ios::in);
|
||||||
/// Creates the FileStream for the file given by path, using
|
/// Creates the FileStream for the file given by path, using
|
||||||
/// the given mode.
|
/// the given mode.
|
||||||
|
|
||||||
~FileStream();
|
~FileStream();
|
||||||
/// Destroys the FileOutputStream.
|
/// Destroys the FileOutputStream.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_FileStream_INCLUDED
|
#endif // Foundation_FileStream_INCLUDED
|
||||||
|
|||||||
@@ -1,83 +1,83 @@
|
|||||||
//
|
//
|
||||||
// FileStreamFactory.h
|
// FileStreamFactory.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/FileStreamFactory.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/FileStreamFactory.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: URI
|
// Package: URI
|
||||||
// Module: FileStreamFactory
|
// Module: FileStreamFactory
|
||||||
//
|
//
|
||||||
// Definition of the FileStreamFactory class.
|
// Definition of the FileStreamFactory 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_FileStreamFactory_INCLUDED
|
#ifndef Foundation_FileStreamFactory_INCLUDED
|
||||||
#define Foundation_FileStreamFactory_INCLUDED
|
#define Foundation_FileStreamFactory_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/URIStreamFactory.h"
|
#include "Poco/URIStreamFactory.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Path;
|
class Path;
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FileStreamFactory: public URIStreamFactory
|
class Foundation_API FileStreamFactory: public URIStreamFactory
|
||||||
/// An implementation of the URIStreamFactory interface
|
/// An implementation of the URIStreamFactory interface
|
||||||
/// that handles file URIs.
|
/// that handles file URIs.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileStreamFactory();
|
FileStreamFactory();
|
||||||
/// Creates the FileStreamFactory.
|
/// Creates the FileStreamFactory.
|
||||||
|
|
||||||
~FileStreamFactory();
|
~FileStreamFactory();
|
||||||
/// Destroys the FileStreamFactory.
|
/// Destroys the FileStreamFactory.
|
||||||
|
|
||||||
std::istream* open(const URI& uri);
|
std::istream* open(const URI& uri);
|
||||||
/// Creates and opens a file stream in binary mode for the given URI.
|
/// Creates and opens a file stream in binary mode for the given URI.
|
||||||
/// The URI must be either a file URI or a relative URI reference
|
/// The URI must be either a file URI or a relative URI reference
|
||||||
/// containing a path to a local file.
|
/// containing a path to a local file.
|
||||||
///
|
///
|
||||||
/// Throws an FileNotFound exception if the file cannot
|
/// Throws an FileNotFound exception if the file cannot
|
||||||
/// be opened.
|
/// be opened.
|
||||||
|
|
||||||
std::istream* open(const Path& path);
|
std::istream* open(const Path& path);
|
||||||
/// Creates and opens a file stream in binary mode for the given path.
|
/// Creates and opens a file stream in binary mode for the given path.
|
||||||
///
|
///
|
||||||
/// Throws an FileNotFound exception if the file cannot
|
/// Throws an FileNotFound exception if the file cannot
|
||||||
/// be opened.
|
/// be opened.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_FileStreamFactory_INCLUDED
|
#endif // Foundation_FileStreamFactory_INCLUDED
|
||||||
|
|||||||
@@ -1,93 +1,93 @@
|
|||||||
//
|
//
|
||||||
// FileStream_POSIX.h
|
// FileStream_POSIX.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/FileStream_POSIX.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/FileStream_POSIX.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: FileStream
|
// Module: FileStream
|
||||||
//
|
//
|
||||||
// Definition of the FileStreamBuf, FileInputStream and FileOutputStream classes.
|
// Definition of the FileStreamBuf, FileInputStream and FileOutputStream classes.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2007, 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_FileStream_POSIX_INCLUDED
|
#ifndef Foundation_FileStream_POSIX_INCLUDED
|
||||||
#define Foundation_FileStream_POSIX_INCLUDED
|
#define Foundation_FileStream_POSIX_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/BufferedBidirectionalStreamBuf.h"
|
#include "Poco/BufferedBidirectionalStreamBuf.h"
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FileStreamBuf: public BufferedBidirectionalStreamBuf
|
class Foundation_API FileStreamBuf: public BufferedBidirectionalStreamBuf
|
||||||
/// This stream buffer handles Fileio
|
/// This stream buffer handles Fileio
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileStreamBuf();
|
FileStreamBuf();
|
||||||
/// Creates a FileStreamBuf.
|
/// Creates a FileStreamBuf.
|
||||||
|
|
||||||
~FileStreamBuf();
|
~FileStreamBuf();
|
||||||
/// Destroys the FileStream.
|
/// Destroys the FileStream.
|
||||||
|
|
||||||
void open(const std::string& path, std::ios::openmode mode);
|
void open(const std::string& path, std::ios::openmode mode);
|
||||||
/// Opens the given file in the given mode.
|
/// Opens the given file in the given mode.
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
/// Closes the File stream buffer.
|
/// Closes the File stream buffer.
|
||||||
|
|
||||||
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out);
|
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||||
/// Change position by offset, according to way and mode.
|
/// Change position by offset, according to way and mode.
|
||||||
|
|
||||||
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out);
|
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||||
/// Change to specified position, according to mode.
|
/// Change to specified position, according to mode.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
BUFFER_SIZE = 4096
|
BUFFER_SIZE = 4096
|
||||||
};
|
};
|
||||||
|
|
||||||
int readFromDevice(char* buffer, std::streamsize length);
|
int readFromDevice(char* buffer, std::streamsize length);
|
||||||
int writeToDevice(const char* buffer, std::streamsize length);
|
int writeToDevice(const char* buffer, std::streamsize length);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _path;
|
std::string _path;
|
||||||
int _fd;
|
int _fd;
|
||||||
std::streamoff _pos;
|
std::streamoff _pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_FileStream_WIN32_INCLUDED
|
#endif // Foundation_FileStream_WIN32_INCLUDED
|
||||||
|
|||||||
@@ -1,92 +1,92 @@
|
|||||||
//
|
//
|
||||||
// FileStream_WIN32.h
|
// FileStream_WIN32.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/FileStream_WIN32.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/FileStream_WIN32.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: FileStream
|
// Module: FileStream
|
||||||
//
|
//
|
||||||
// Definition of the FileStreamBuf, FileInputStream and FileOutputStream classes.
|
// Definition of the FileStreamBuf, FileInputStream and FileOutputStream classes.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2007, 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_FileStream_WIN32_INCLUDED
|
#ifndef Foundation_FileStream_WIN32_INCLUDED
|
||||||
#define Foundation_FileStream_WIN32_INCLUDED
|
#define Foundation_FileStream_WIN32_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/BufferedBidirectionalStreamBuf.h"
|
#include "Poco/BufferedBidirectionalStreamBuf.h"
|
||||||
#include "Poco/UnWindows.h"
|
#include "Poco/UnWindows.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FileStreamBuf: public BufferedBidirectionalStreamBuf
|
class Foundation_API FileStreamBuf: public BufferedBidirectionalStreamBuf
|
||||||
/// This stream buffer handles Fileio
|
/// This stream buffer handles Fileio
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileStreamBuf();
|
FileStreamBuf();
|
||||||
/// Creates a FileStreamBuf.
|
/// Creates a FileStreamBuf.
|
||||||
|
|
||||||
~FileStreamBuf();
|
~FileStreamBuf();
|
||||||
/// Destroys the FileStream.
|
/// Destroys the FileStream.
|
||||||
|
|
||||||
void open(const std::string& path, std::ios::openmode mode);
|
void open(const std::string& path, std::ios::openmode mode);
|
||||||
/// Opens the given file in the given mode.
|
/// Opens the given file in the given mode.
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
/// Closes the File stream buffer
|
/// Closes the File stream buffer
|
||||||
|
|
||||||
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out);
|
std::streampos seekoff(std::streamoff off, std::ios::seekdir dir, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||||
/// change position by offset, according to way and mode
|
/// change position by offset, according to way and mode
|
||||||
|
|
||||||
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out);
|
std::streampos seekpos(std::streampos pos, std::ios::openmode mode = std::ios::in | std::ios::out);
|
||||||
/// change to specified position, according to mode
|
/// change to specified position, according to mode
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
BUFFER_SIZE = 4096
|
BUFFER_SIZE = 4096
|
||||||
};
|
};
|
||||||
|
|
||||||
int readFromDevice(char* buffer, std::streamsize length);
|
int readFromDevice(char* buffer, std::streamsize length);
|
||||||
int writeToDevice(const char* buffer, std::streamsize length);
|
int writeToDevice(const char* buffer, std::streamsize length);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _path;
|
std::string _path;
|
||||||
HANDLE _handle;
|
HANDLE _handle;
|
||||||
UInt64 _pos;
|
UInt64 _pos;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_FileStream_WIN32_INCLUDED
|
#endif // Foundation_FileStream_WIN32_INCLUDED
|
||||||
|
|||||||
@@ -1,101 +1,101 @@
|
|||||||
//
|
//
|
||||||
// File_UNIX.h
|
// File_UNIX.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/File_UNIX.h#3 $
|
// $Id: //poco/1.3/Foundation/include/Poco/File_UNIX.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Filesystem
|
// Package: Filesystem
|
||||||
// Module: File
|
// Module: File
|
||||||
//
|
//
|
||||||
// Definition of the FileImpl class for Unix.
|
// Definition of the FileImpl class for Unix.
|
||||||
//
|
//
|
||||||
// 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_File_UNIX_INCLUDED
|
#ifndef Foundation_File_UNIX_INCLUDED
|
||||||
#define Foundation_File_UNIX_INCLUDED
|
#define Foundation_File_UNIX_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class FileImpl
|
class FileImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef UInt64 FileSizeImpl;
|
typedef UInt64 FileSizeImpl;
|
||||||
|
|
||||||
FileImpl();
|
FileImpl();
|
||||||
FileImpl(const std::string& path);
|
FileImpl(const std::string& path);
|
||||||
virtual ~FileImpl();
|
virtual ~FileImpl();
|
||||||
void swapImpl(FileImpl& file);
|
void swapImpl(FileImpl& file);
|
||||||
void setPathImpl(const std::string& path);
|
void setPathImpl(const std::string& path);
|
||||||
const std::string& getPathImpl() const;
|
const std::string& getPathImpl() const;
|
||||||
bool existsImpl() const;
|
bool existsImpl() const;
|
||||||
bool canReadImpl() const;
|
bool canReadImpl() const;
|
||||||
bool canWriteImpl() const;
|
bool canWriteImpl() const;
|
||||||
bool canExecuteImpl() const;
|
bool canExecuteImpl() const;
|
||||||
bool isFileImpl() const;
|
bool isFileImpl() const;
|
||||||
bool isDirectoryImpl() const;
|
bool isDirectoryImpl() const;
|
||||||
bool isLinkImpl() const;
|
bool isLinkImpl() const;
|
||||||
bool isHiddenImpl() const;
|
bool isHiddenImpl() const;
|
||||||
Timestamp createdImpl() const;
|
Timestamp createdImpl() const;
|
||||||
Timestamp getLastModifiedImpl() const;
|
Timestamp getLastModifiedImpl() const;
|
||||||
void setLastModifiedImpl(const Timestamp& ts);
|
void setLastModifiedImpl(const Timestamp& ts);
|
||||||
FileSizeImpl getSizeImpl() const;
|
FileSizeImpl getSizeImpl() const;
|
||||||
void setSizeImpl(FileSizeImpl size);
|
void setSizeImpl(FileSizeImpl size);
|
||||||
void setWriteableImpl(bool flag = true);
|
void setWriteableImpl(bool flag = true);
|
||||||
void setExecutableImpl(bool flag = true);
|
void setExecutableImpl(bool flag = true);
|
||||||
void copyToImpl(const std::string& path) const;
|
void copyToImpl(const std::string& path) const;
|
||||||
void renameToImpl(const std::string& path);
|
void renameToImpl(const std::string& path);
|
||||||
void removeImpl();
|
void removeImpl();
|
||||||
bool createFileImpl();
|
bool createFileImpl();
|
||||||
bool createDirectoryImpl();
|
bool createDirectoryImpl();
|
||||||
static void handleLastErrorImpl(const std::string& path);
|
static void handleLastErrorImpl(const std::string& path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _path;
|
std::string _path;
|
||||||
|
|
||||||
friend class DirectoryIteratorImpl;
|
friend class DirectoryIteratorImpl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline const std::string& FileImpl::getPathImpl() const
|
inline const std::string& FileImpl::getPathImpl() const
|
||||||
{
|
{
|
||||||
return _path;
|
return _path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_File_UNIX_INCLUDED
|
#endif // Foundation_File_UNIX_INCLUDED
|
||||||
|
|||||||
@@ -1,100 +1,100 @@
|
|||||||
//
|
//
|
||||||
// File_VMS.h
|
// File_VMS.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/File_VMS.h#3 $
|
// $Id: //poco/1.3/Foundation/include/Poco/File_VMS.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Filesystem
|
// Package: Filesystem
|
||||||
// Module: File
|
// Module: File
|
||||||
//
|
//
|
||||||
// Definition of the FileImpl class for OpenVMS.
|
// Definition of the FileImpl class for OpenVMS.
|
||||||
//
|
//
|
||||||
// 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_File_VMS_INCLUDED
|
#ifndef Foundation_File_VMS_INCLUDED
|
||||||
#define Foundation_File_VMS_INCLUDED
|
#define Foundation_File_VMS_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class FileImpl
|
class FileImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef UInt64 FileSizeImpl;
|
typedef UInt64 FileSizeImpl;
|
||||||
|
|
||||||
FileImpl();
|
FileImpl();
|
||||||
FileImpl(const std::string& path);
|
FileImpl(const std::string& path);
|
||||||
virtual ~FileImpl();
|
virtual ~FileImpl();
|
||||||
void setPath(const std::string& path);
|
void setPath(const std::string& path);
|
||||||
void swapImpl(FileImpl& file);
|
void swapImpl(FileImpl& file);
|
||||||
void setPathImpl(const std::string& path);
|
void setPathImpl(const std::string& path);
|
||||||
const std::string& getPathImpl() const;
|
const std::string& getPathImpl() const;
|
||||||
bool existsImpl() const;
|
bool existsImpl() const;
|
||||||
bool canReadImpl() const;
|
bool canReadImpl() const;
|
||||||
bool canWriteImpl() const;
|
bool canWriteImpl() const;
|
||||||
bool canExecuteImpl() const;
|
bool canExecuteImpl() const;
|
||||||
bool isFileImpl() const;
|
bool isFileImpl() const;
|
||||||
bool isDirectoryImpl() const;
|
bool isDirectoryImpl() const;
|
||||||
bool isLinkImpl() const;
|
bool isLinkImpl() const;
|
||||||
bool isHiddenImpl() const;
|
bool isHiddenImpl() const;
|
||||||
Timestamp createdImpl() const;
|
Timestamp createdImpl() const;
|
||||||
Timestamp getLastModifiedImpl() const;
|
Timestamp getLastModifiedImpl() const;
|
||||||
void setLastModifiedImpl(const Timestamp& ts);
|
void setLastModifiedImpl(const Timestamp& ts);
|
||||||
FileSizeImpl getSizeImpl() const;
|
FileSizeImpl getSizeImpl() const;
|
||||||
void setSizeImpl(FileSizeImpl size);
|
void setSizeImpl(FileSizeImpl size);
|
||||||
void setWriteableImpl(bool flag = true);
|
void setWriteableImpl(bool flag = true);
|
||||||
void setExecutableImpl(bool flag = true);
|
void setExecutableImpl(bool flag = true);
|
||||||
void copyToImpl(const std::string& path) const;
|
void copyToImpl(const std::string& path) const;
|
||||||
void renameToImpl(const std::string& path);
|
void renameToImpl(const std::string& path);
|
||||||
void removeImpl();
|
void removeImpl();
|
||||||
bool createFileImpl();
|
bool createFileImpl();
|
||||||
bool createDirectoryImpl();
|
bool createDirectoryImpl();
|
||||||
static void handleLastError(const std::string& path);
|
static void handleLastError(const std::string& path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _path;
|
std::string _path;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline const std::string& FileImpl::getPathImpl() const
|
inline const std::string& FileImpl::getPathImpl() const
|
||||||
{
|
{
|
||||||
return _path;
|
return _path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_File_VMS_INCLUDED
|
#endif // Foundation_File_VMS_INCLUDED
|
||||||
|
|||||||
@@ -1,103 +1,103 @@
|
|||||||
//
|
//
|
||||||
// File_WIN32.h
|
// File_WIN32.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/File_WIN32.h#3 $
|
// $Id: //poco/1.3/Foundation/include/Poco/File_WIN32.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Filesystem
|
// Package: Filesystem
|
||||||
// Module: File
|
// Module: File
|
||||||
//
|
//
|
||||||
// Definition of the FileImpl class for WIN32.
|
// Definition of the FileImpl class for WIN32.
|
||||||
//
|
//
|
||||||
// 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_File_WIN32_INCLUDED
|
#ifndef Foundation_File_WIN32_INCLUDED
|
||||||
#define Foundation_File_WIN32_INCLUDED
|
#define Foundation_File_WIN32_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FileImpl
|
class Foundation_API FileImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef UInt64 FileSizeImpl;
|
typedef UInt64 FileSizeImpl;
|
||||||
|
|
||||||
FileImpl();
|
FileImpl();
|
||||||
FileImpl(const std::string& path);
|
FileImpl(const std::string& path);
|
||||||
virtual ~FileImpl();
|
virtual ~FileImpl();
|
||||||
void swapImpl(FileImpl& file);
|
void swapImpl(FileImpl& file);
|
||||||
void setPathImpl(const std::string& path);
|
void setPathImpl(const std::string& path);
|
||||||
const std::string& getPathImpl() const;
|
const std::string& getPathImpl() const;
|
||||||
bool existsImpl() const;
|
bool existsImpl() const;
|
||||||
bool canReadImpl() const;
|
bool canReadImpl() const;
|
||||||
bool canWriteImpl() const;
|
bool canWriteImpl() const;
|
||||||
bool canExecuteImpl() const;
|
bool canExecuteImpl() const;
|
||||||
bool isFileImpl() const;
|
bool isFileImpl() const;
|
||||||
bool isDirectoryImpl() const;
|
bool isDirectoryImpl() const;
|
||||||
bool isLinkImpl() const;
|
bool isLinkImpl() const;
|
||||||
bool isHiddenImpl() const;
|
bool isHiddenImpl() const;
|
||||||
Timestamp createdImpl() const;
|
Timestamp createdImpl() const;
|
||||||
Timestamp getLastModifiedImpl() const;
|
Timestamp getLastModifiedImpl() const;
|
||||||
void setLastModifiedImpl(const Timestamp& ts);
|
void setLastModifiedImpl(const Timestamp& ts);
|
||||||
FileSizeImpl getSizeImpl() const;
|
FileSizeImpl getSizeImpl() const;
|
||||||
void setSizeImpl(FileSizeImpl size);
|
void setSizeImpl(FileSizeImpl size);
|
||||||
void setWriteableImpl(bool flag = true);
|
void setWriteableImpl(bool flag = true);
|
||||||
void setExecutableImpl(bool flag = true);
|
void setExecutableImpl(bool flag = true);
|
||||||
void copyToImpl(const std::string& path) const;
|
void copyToImpl(const std::string& path) const;
|
||||||
void renameToImpl(const std::string& path);
|
void renameToImpl(const std::string& path);
|
||||||
void removeImpl();
|
void removeImpl();
|
||||||
bool createFileImpl();
|
bool createFileImpl();
|
||||||
bool createDirectoryImpl();
|
bool createDirectoryImpl();
|
||||||
static void handleLastErrorImpl(const std::string& path);
|
static void handleLastErrorImpl(const std::string& path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _path;
|
std::string _path;
|
||||||
|
|
||||||
friend class FileHandle;
|
friend class FileHandle;
|
||||||
friend class DirectoryIteratorImpl;
|
friend class DirectoryIteratorImpl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline const std::string& FileImpl::getPathImpl() const
|
inline const std::string& FileImpl::getPathImpl() const
|
||||||
{
|
{
|
||||||
return _path;
|
return _path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_File_WIN32_INCLUDED
|
#endif // Foundation_File_WIN32_INCLUDED
|
||||||
|
|||||||
@@ -1,104 +1,104 @@
|
|||||||
//
|
//
|
||||||
// File_WIN32U.h
|
// File_WIN32U.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/File_WIN32U.h#3 $
|
// $Id: //poco/1.3/Foundation/include/Poco/File_WIN32U.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Filesystem
|
// Package: Filesystem
|
||||||
// Module: File
|
// Module: File
|
||||||
//
|
//
|
||||||
// Definition of the Unicode FileImpl class for WIN32.
|
// Definition of the Unicode FileImpl class for WIN32.
|
||||||
//
|
//
|
||||||
// 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 Foundation_File_WIN32U_INCLUDED
|
#ifndef Foundation_File_WIN32U_INCLUDED
|
||||||
#define Foundation_File_WIN32U_INCLUDED
|
#define Foundation_File_WIN32U_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Timestamp.h"
|
#include "Poco/Timestamp.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FileImpl
|
class Foundation_API FileImpl
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
typedef UInt64 FileSizeImpl;
|
typedef UInt64 FileSizeImpl;
|
||||||
|
|
||||||
FileImpl();
|
FileImpl();
|
||||||
FileImpl(const std::string& path);
|
FileImpl(const std::string& path);
|
||||||
virtual ~FileImpl();
|
virtual ~FileImpl();
|
||||||
void swapImpl(FileImpl& file);
|
void swapImpl(FileImpl& file);
|
||||||
void setPathImpl(const std::string& path);
|
void setPathImpl(const std::string& path);
|
||||||
const std::string& getPathImpl() const;
|
const std::string& getPathImpl() const;
|
||||||
bool existsImpl() const;
|
bool existsImpl() const;
|
||||||
bool canReadImpl() const;
|
bool canReadImpl() const;
|
||||||
bool canWriteImpl() const;
|
bool canWriteImpl() const;
|
||||||
bool canExecuteImpl() const;
|
bool canExecuteImpl() const;
|
||||||
bool isFileImpl() const;
|
bool isFileImpl() const;
|
||||||
bool isDirectoryImpl() const;
|
bool isDirectoryImpl() const;
|
||||||
bool isLinkImpl() const;
|
bool isLinkImpl() const;
|
||||||
bool isHiddenImpl() const;
|
bool isHiddenImpl() const;
|
||||||
Timestamp createdImpl() const;
|
Timestamp createdImpl() const;
|
||||||
Timestamp getLastModifiedImpl() const;
|
Timestamp getLastModifiedImpl() const;
|
||||||
void setLastModifiedImpl(const Timestamp& ts);
|
void setLastModifiedImpl(const Timestamp& ts);
|
||||||
FileSizeImpl getSizeImpl() const;
|
FileSizeImpl getSizeImpl() const;
|
||||||
void setSizeImpl(FileSizeImpl size);
|
void setSizeImpl(FileSizeImpl size);
|
||||||
void setWriteableImpl(bool flag = true);
|
void setWriteableImpl(bool flag = true);
|
||||||
void setExecutableImpl(bool flag = true);
|
void setExecutableImpl(bool flag = true);
|
||||||
void copyToImpl(const std::string& path) const;
|
void copyToImpl(const std::string& path) const;
|
||||||
void renameToImpl(const std::string& path);
|
void renameToImpl(const std::string& path);
|
||||||
void removeImpl();
|
void removeImpl();
|
||||||
bool createFileImpl();
|
bool createFileImpl();
|
||||||
bool createDirectoryImpl();
|
bool createDirectoryImpl();
|
||||||
static void handleLastErrorImpl(const std::string& path);
|
static void handleLastErrorImpl(const std::string& path);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _path;
|
std::string _path;
|
||||||
std::wstring _upath;
|
std::wstring _upath;
|
||||||
|
|
||||||
friend class FileHandle;
|
friend class FileHandle;
|
||||||
friend class DirectoryIteratorImpl;
|
friend class DirectoryIteratorImpl;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline const std::string& FileImpl::getPathImpl() const
|
inline const std::string& FileImpl::getPathImpl() const
|
||||||
{
|
{
|
||||||
return _path;
|
return _path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_File_WIN32U_INCLUDED
|
#endif // Foundation_File_WIN32U_INCLUDED
|
||||||
|
|||||||
@@ -1,157 +1,157 @@
|
|||||||
//
|
//
|
||||||
// Format.h
|
// Format.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Format.h#5 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Format.h#5 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: Format
|
// Module: Format
|
||||||
//
|
//
|
||||||
// Definition of the format freestanding function.
|
// Definition of the format freestanding function.
|
||||||
//
|
//
|
||||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||||
// All rights reserved.
|
// All rights reserved.
|
||||||
//
|
//
|
||||||
// Redistribution and use in source and binary forms, with or without
|
// Redistribution and use in source and binary forms, with or without
|
||||||
// modification, are permitted provided that the following conditions
|
// modification, are permitted provided that the following conditions
|
||||||
// are met:
|
// are met:
|
||||||
//
|
//
|
||||||
// 1. Redistributions of source code must retain the above copyright
|
// 1. Redistributions of source code must retain the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer.
|
// notice, this list of conditions and the following disclaimer.
|
||||||
//
|
//
|
||||||
// 2. Redistributions in binary form must reproduce the above copyright
|
// 2. Redistributions in binary form must reproduce the above copyright
|
||||||
// notice, this list of conditions and the following disclaimer in the
|
// notice, this list of conditions and the following disclaimer in the
|
||||||
// documentation and/or other materials provided with the distribution.
|
// documentation and/or other materials provided with the distribution.
|
||||||
//
|
//
|
||||||
// 3. Redistributions in any form must be accompanied by information on
|
// 3. Redistributions in any form must be accompanied by information on
|
||||||
// how to obtain complete source code for this software and any
|
// how to obtain complete source code for this software and any
|
||||||
// accompanying software that uses this software. The source code
|
// accompanying software that uses this software. The source code
|
||||||
// must either be included in the distribution or be available for no
|
// must either be included in the distribution or be available for no
|
||||||
// more than the cost of distribution plus a nominal fee, and must be
|
// more than the cost of distribution plus a nominal fee, and must be
|
||||||
// freely redistributable under reasonable conditions. For an
|
// freely redistributable under reasonable conditions. For an
|
||||||
// executable file, complete source code means the source code for all
|
// executable file, complete source code means the source code for all
|
||||||
// modules it contains. It does not include source code for modules or
|
// modules it contains. It does not include source code for modules or
|
||||||
// files that typically accompany the major components of the operating
|
// files that typically accompany the major components of the operating
|
||||||
// system on which the executable file runs.
|
// system on which the executable file runs.
|
||||||
//
|
//
|
||||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
// FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
// COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
// INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
// BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
// LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
// ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
// POSSIBILITY OF SUCH DAMAGE.
|
// POSSIBILITY OF SUCH DAMAGE.
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#ifndef Foundation_Format_INCLUDED
|
#ifndef Foundation_Format_INCLUDED
|
||||||
#define Foundation_Format_INCLUDED
|
#define Foundation_Format_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Any.h"
|
#include "Poco/Any.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
std::string Foundation_API format(const std::string& fmt, const Any& value);
|
std::string Foundation_API format(const std::string& fmt, const Any& value);
|
||||||
/// This function implements sprintf-style formatting in a typesafe way.
|
/// This function implements sprintf-style formatting in a typesafe way.
|
||||||
/// Various variants of the function are available, supporting a
|
/// Various variants of the function are available, supporting a
|
||||||
/// different number of arguments (up to six).
|
/// different number of arguments (up to six).
|
||||||
///
|
///
|
||||||
/// The formatting is controlled by the format string in fmt.
|
/// The formatting is controlled by the format string in fmt.
|
||||||
/// Format strings are quite similar to those of the std::printf() function, but
|
/// Format strings are quite similar to those of the std::printf() function, but
|
||||||
/// there are some minor differences.
|
/// there are some minor differences.
|
||||||
///
|
///
|
||||||
/// The format string can consist of any sequence of characters; certain
|
/// The format string can consist of any sequence of characters; certain
|
||||||
/// characters have a special meaning. Characters without a special meaning
|
/// characters have a special meaning. Characters without a special meaning
|
||||||
/// are copied verbatim to the result. A percent sign (%) marks the beginning
|
/// are copied verbatim to the result. A percent sign (%) marks the beginning
|
||||||
/// of a format specification. Format specifications have the following syntax:
|
/// of a format specification. Format specifications have the following syntax:
|
||||||
///
|
///
|
||||||
/// %[<flags>][<width>][.<precision>][<modifier>]<type>
|
/// %[<flags>][<width>][.<precision>][<modifier>]<type>
|
||||||
///
|
///
|
||||||
/// Flags, width, precision and prefix are optional. The only required part of
|
/// Flags, width, precision and prefix are optional. The only required part of
|
||||||
/// the format specification, apart from the percent sign, is the type.
|
/// the format specification, apart from the percent sign, is the type.
|
||||||
///
|
///
|
||||||
/// Following are valid type specifications and their meaning:
|
/// Following are valid type specifications and their meaning:
|
||||||
///
|
///
|
||||||
/// * b boolean (true = 1, false = 0)
|
/// * b boolean (true = 1, false = 0)
|
||||||
/// * c character
|
/// * c character
|
||||||
/// * d signed decimal integer
|
/// * d signed decimal integer
|
||||||
/// * i signed decimal integer
|
/// * i signed decimal integer
|
||||||
/// * o unsigned octal integer
|
/// * o unsigned octal integer
|
||||||
/// * u unsigned decimal integer
|
/// * u unsigned decimal integer
|
||||||
/// * x unsigned hexadecimal integer (lower case)
|
/// * x unsigned hexadecimal integer (lower case)
|
||||||
/// * X unsigned hexadecimal integer (upper case)
|
/// * X unsigned hexadecimal integer (upper case)
|
||||||
/// * e signed floating-point value in the form [-]d.dddde[<sign>]dd[d]
|
/// * e signed floating-point value in the form [-]d.dddde[<sign>]dd[d]
|
||||||
/// * E signed floating-point value in the form [-]d.ddddE[<sign>]dd[d]
|
/// * E signed floating-point value in the form [-]d.ddddE[<sign>]dd[d]
|
||||||
/// * f signed floating-point value in the form [-]dddd.dddd
|
/// * f signed floating-point value in the form [-]dddd.dddd
|
||||||
/// * s std::string
|
/// * s std::string
|
||||||
/// * z std::size_t
|
/// * z std::size_t
|
||||||
///
|
///
|
||||||
/// The following flags are supported:
|
/// The following flags are supported:
|
||||||
///
|
///
|
||||||
/// * - left align the result within the given field width
|
/// * - left align the result within the given field width
|
||||||
/// * + prefix the output value with a sign (+ or <20>) if the output value is of a signed type
|
/// * + prefix the output value with a sign (+ or <20>) if the output value is of a signed type
|
||||||
/// * 0 if width is prefixed with 0, zeros are added until the minimum width is reached
|
/// * 0 if width is prefixed with 0, zeros are added until the minimum width is reached
|
||||||
/// * # For o, x, X, the # flag prefixes any nonzero output value with 0, 0x, or 0X, respectively;
|
/// * # For o, x, X, the # flag prefixes any nonzero output value with 0, 0x, or 0X, respectively;
|
||||||
/// for e, E, f, the # flag forces the output value to contain a decimal point in all cases.
|
/// for e, E, f, the # flag forces the output value to contain a decimal point in all cases.
|
||||||
///
|
///
|
||||||
/// The following modifiers are supported:
|
/// The following modifiers are supported:
|
||||||
///
|
///
|
||||||
/// * (none) argument is char (c), int (d, i), unsigned (o, u, x, X) double (e, E, f, g, G) or string (s)
|
/// * (none) argument is char (c), int (d, i), unsigned (o, u, x, X) double (e, E, f, g, G) or string (s)
|
||||||
/// * l argument is long (d, i), unsigned long (o, u, x, X) or long double (e, E, f, g, G)
|
/// * l argument is long (d, i), unsigned long (o, u, x, X) or long double (e, E, f, g, G)
|
||||||
/// * L argument is long long (d, i), unsigned long long (o, u, x, X)
|
/// * L argument is long long (d, i), unsigned long long (o, u, x, X)
|
||||||
/// * h argument is short (d, i), unsigned short (o, u, x, X) or float (e, E, f, g, G)
|
/// * h argument is short (d, i), unsigned short (o, u, x, X) or float (e, E, f, g, G)
|
||||||
/// * ? argument is any signed or unsigned int, short, long, or 64-bit integer (d, i, o, x, X)
|
/// * ? argument is any signed or unsigned int, short, long, or 64-bit integer (d, i, o, x, X)
|
||||||
///
|
///
|
||||||
/// The width argument is a nonnegative decimal integer controlling the minimum number of characters printed.
|
/// The width argument is a nonnegative decimal integer controlling the minimum number of characters printed.
|
||||||
/// If the number of characters in the output value is less than the specified width, blanks or
|
/// If the number of characters in the output value is less than the specified width, blanks or
|
||||||
/// leading zeros are added, according to the specified flags (-, +, 0).
|
/// leading zeros are added, according to the specified flags (-, +, 0).
|
||||||
///
|
///
|
||||||
/// Precision is a nonnegative decimal integer, preceded by a period (.), which specifies the number of characters
|
/// Precision is a nonnegative decimal integer, preceded by a period (.), which specifies the number of characters
|
||||||
/// to be printed, the number of decimal places, or the number of significant digits.
|
/// to be printed, the number of decimal places, or the number of significant digits.
|
||||||
///
|
///
|
||||||
/// Throws a BadCastException if an argument does not correspond to the type of its format specification.
|
/// Throws a BadCastException if an argument does not correspond to the type of its format specification.
|
||||||
///
|
///
|
||||||
/// If there are more format specifiers than values, the format specifiers without a corresponding value
|
/// If there are more format specifiers than values, the format specifiers without a corresponding value
|
||||||
/// are copied verbatim to output.
|
/// are copied verbatim to output.
|
||||||
///
|
///
|
||||||
/// If there are more values than format specifiers, the superfluous values are ignored.
|
/// If there are more values than format specifiers, the superfluous values are ignored.
|
||||||
///
|
///
|
||||||
/// Usage Example:
|
/// Usage Example:
|
||||||
/// std::string s = format("The answer to life, the universe, and everything is %d", 42);
|
/// std::string s = format("The answer to life, the universe, and everything is %d", 42);
|
||||||
|
|
||||||
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2);
|
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2);
|
||||||
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3);
|
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3);
|
||||||
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
||||||
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
||||||
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
||||||
|
|
||||||
|
|
||||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value);
|
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value);
|
||||||
/// Appends the formatted string to result.
|
/// Appends the formatted string to result.
|
||||||
|
|
||||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2);
|
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2);
|
||||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3);
|
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3);
|
||||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4);
|
||||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5);
|
||||||
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6);
|
||||||
|
|
||||||
|
|
||||||
void Foundation_API format(std::string& result, const std::string& fmt, const std::vector<Any>& values);
|
void Foundation_API format(std::string& result, const std::string& fmt, const std::vector<Any>& values);
|
||||||
/// Supports a variable number of arguments and is used by
|
/// Supports a variable number of arguments and is used by
|
||||||
/// all other variants of format().
|
/// all other variants of format().
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Format_INCLUDED
|
#endif // Foundation_Format_INCLUDED
|
||||||
|
|||||||
@@ -1,96 +1,96 @@
|
|||||||
//
|
//
|
||||||
// Formatter.h
|
// Formatter.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Formatter.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Formatter.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Logging
|
// Package: Logging
|
||||||
// Module: Formatter
|
// Module: Formatter
|
||||||
//
|
//
|
||||||
// Definition of the Formatter class.
|
// Definition of the Formatter 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_Formatter_INCLUDED
|
#ifndef Foundation_Formatter_INCLUDED
|
||||||
#define Foundation_Formatter_INCLUDED
|
#define Foundation_Formatter_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Configurable.h"
|
#include "Poco/Configurable.h"
|
||||||
#include "Poco/RefCountedObject.h"
|
#include "Poco/RefCountedObject.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Message;
|
class Message;
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Formatter: public Configurable, public RefCountedObject
|
class Foundation_API Formatter: public Configurable, public RefCountedObject
|
||||||
/// The base class for all Formatter classes.
|
/// The base class for all Formatter classes.
|
||||||
///
|
///
|
||||||
/// A formatter basically takes a Message object
|
/// A formatter basically takes a Message object
|
||||||
/// and formats it into a string. How the formatting
|
/// and formats it into a string. How the formatting
|
||||||
/// is exactly done is up to the implementation of
|
/// is exactly done is up to the implementation of
|
||||||
/// Formatter. For example, a very simple implementation
|
/// Formatter. For example, a very simple implementation
|
||||||
/// might simply take the message's Text (see Message::getText()).
|
/// might simply take the message's Text (see Message::getText()).
|
||||||
/// A useful implementation should at least take the Message's
|
/// A useful implementation should at least take the Message's
|
||||||
/// Time, Priority and Text fields and put them into a string.
|
/// Time, Priority and Text fields and put them into a string.
|
||||||
///
|
///
|
||||||
/// The Formatter class supports the Configurable
|
/// The Formatter class supports the Configurable
|
||||||
/// interface, so the behaviour of certain formatters
|
/// interface, so the behaviour of certain formatters
|
||||||
/// is configurable.
|
/// is configurable.
|
||||||
///
|
///
|
||||||
/// Trivial implementations of of getProperty() and
|
/// Trivial implementations of of getProperty() and
|
||||||
/// setProperty() are provided.
|
/// setProperty() are provided.
|
||||||
///
|
///
|
||||||
/// Subclasses must at least provide a format() method.
|
/// Subclasses must at least provide a format() method.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Formatter();
|
Formatter();
|
||||||
/// Creates the formatter.
|
/// Creates the formatter.
|
||||||
|
|
||||||
virtual ~Formatter();
|
virtual ~Formatter();
|
||||||
/// Destroys the formatter.
|
/// Destroys the formatter.
|
||||||
|
|
||||||
virtual void format(const Message& msg, std::string& text) = 0;
|
virtual void format(const Message& msg, std::string& text) = 0;
|
||||||
/// Formats the message and places the result in text.
|
/// Formats the message and places the result in text.
|
||||||
/// Subclasses must override this method.
|
/// Subclasses must override this method.
|
||||||
|
|
||||||
void setProperty(const std::string& name, const std::string& value);
|
void setProperty(const std::string& name, const std::string& value);
|
||||||
/// Throws a PropertyNotSupportedException.
|
/// Throws a PropertyNotSupportedException.
|
||||||
|
|
||||||
std::string getProperty(const std::string& name) const;
|
std::string getProperty(const std::string& name) const;
|
||||||
/// Throws a PropertyNotSupportedException.
|
/// Throws a PropertyNotSupportedException.
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Formatter_INCLUDED
|
#endif // Foundation_Formatter_INCLUDED
|
||||||
|
|||||||
@@ -1,118 +1,118 @@
|
|||||||
//
|
//
|
||||||
// FormattingChannel.h
|
// FormattingChannel.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/FormattingChannel.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/FormattingChannel.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Logging
|
// Package: Logging
|
||||||
// Module: Formatter
|
// Module: Formatter
|
||||||
//
|
//
|
||||||
// Definition of the FormattingChannel class.
|
// Definition of the FormattingChannel 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_FormattingChannel_INCLUDED
|
#ifndef Foundation_FormattingChannel_INCLUDED
|
||||||
#define Foundation_FormattingChannel_INCLUDED
|
#define Foundation_FormattingChannel_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Channel.h"
|
#include "Poco/Channel.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Formatter;
|
class Formatter;
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API FormattingChannel: public Channel
|
class Foundation_API FormattingChannel: public Channel
|
||||||
/// The FormattingChannel is a filter channel that routes
|
/// The FormattingChannel is a filter channel that routes
|
||||||
/// a Message through a Formatter before passing it on
|
/// a Message through a Formatter before passing it on
|
||||||
/// to the destination channel.
|
/// to the destination channel.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FormattingChannel();
|
FormattingChannel();
|
||||||
/// Creates a FormattingChannel.
|
/// Creates a FormattingChannel.
|
||||||
|
|
||||||
FormattingChannel(Formatter* pFormatter);
|
FormattingChannel(Formatter* pFormatter);
|
||||||
/// Creates a FormattingChannel and attaches a Formatter.
|
/// Creates a FormattingChannel and attaches a Formatter.
|
||||||
|
|
||||||
FormattingChannel(Formatter* pFormatter, Channel* pChannel);
|
FormattingChannel(Formatter* pFormatter, Channel* pChannel);
|
||||||
/// Creates a FormattingChannel and attaches a Formatter
|
/// Creates a FormattingChannel and attaches a Formatter
|
||||||
/// and a Channel.
|
/// and a Channel.
|
||||||
|
|
||||||
void setFormatter(Formatter* pFormatter);
|
void setFormatter(Formatter* pFormatter);
|
||||||
/// Sets the Formatter used to format the messages
|
/// Sets the Formatter used to format the messages
|
||||||
/// before they are passed on. If null, the message
|
/// before they are passed on. If null, the message
|
||||||
/// is passed on unmodified.
|
/// is passed on unmodified.
|
||||||
|
|
||||||
Formatter* getFormatter() const;
|
Formatter* getFormatter() const;
|
||||||
/// Returns the Formatter used to format messages,
|
/// Returns the Formatter used to format messages,
|
||||||
/// which may be null.
|
/// which may be null.
|
||||||
|
|
||||||
void setChannel(Channel* pChannel);
|
void setChannel(Channel* pChannel);
|
||||||
/// Sets the destination channel to which the formatted
|
/// Sets the destination channel to which the formatted
|
||||||
/// messages are passed on.
|
/// messages are passed on.
|
||||||
|
|
||||||
Channel* getChannel() const;
|
Channel* getChannel() const;
|
||||||
/// Returns the channel to which the formatted
|
/// Returns the channel to which the formatted
|
||||||
/// messages are passed on.
|
/// messages are passed on.
|
||||||
|
|
||||||
void log(const Message& msg);
|
void log(const Message& msg);
|
||||||
/// Formats the given Message using the Formatter and
|
/// Formats the given Message using the Formatter and
|
||||||
/// passes the formatted message on to the destination
|
/// passes the formatted message on to the destination
|
||||||
/// Channel.
|
/// Channel.
|
||||||
|
|
||||||
void setProperty(const std::string& name, const std::string& value);
|
void setProperty(const std::string& name, const std::string& value);
|
||||||
/// Sets or changes a configuration property.
|
/// Sets or changes a configuration property.
|
||||||
///
|
///
|
||||||
/// Only the "channel" and "formatter" properties are supported, which allow
|
/// Only the "channel" and "formatter" properties are supported, which allow
|
||||||
/// setting the target channel and formatter, respectively, via the LoggingRegistry.
|
/// setting the target channel and formatter, respectively, via the LoggingRegistry.
|
||||||
/// The "channel" and "formatter" properties are set-only.
|
/// The "channel" and "formatter" properties are set-only.
|
||||||
///
|
///
|
||||||
/// Unsupported properties are passed to the attached Channel.
|
/// Unsupported properties are passed to the attached Channel.
|
||||||
|
|
||||||
void open();
|
void open();
|
||||||
/// Opens the attached channel.
|
/// Opens the attached channel.
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
/// Closes the attached channel.
|
/// Closes the attached channel.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~FormattingChannel();
|
~FormattingChannel();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Formatter* _pFormatter;
|
Formatter* _pFormatter;
|
||||||
Channel* _pChannel;
|
Channel* _pChannel;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_FormattingChannel_INCLUDED
|
#endif // Foundation_FormattingChannel_INCLUDED
|
||||||
|
|||||||
@@ -1,140 +1,140 @@
|
|||||||
//
|
//
|
||||||
// Foundation.h
|
// Foundation.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Foundation.h#3 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Foundation.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: Foundation
|
// Module: Foundation
|
||||||
//
|
//
|
||||||
// Basic definitions for the POCO Foundation library.
|
// Basic definitions for the POCO Foundation library.
|
||||||
// This file must be the first file included by every other Foundation
|
// This file must be the first file included by every other Foundation
|
||||||
// header file.
|
// header file.
|
||||||
//
|
//
|
||||||
// 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_Foundation_INCLUDED
|
#ifndef Foundation_Foundation_INCLUDED
|
||||||
#define Foundation_Foundation_INCLUDED
|
#define Foundation_Foundation_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Include library configuration
|
// Include library configuration
|
||||||
//
|
//
|
||||||
#include "Poco/Config.h"
|
#include "Poco/Config.h"
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Ensure that POCO_DLL is default unless POCO_STATIC is defined
|
// Ensure that POCO_DLL is default unless POCO_STATIC is defined
|
||||||
//
|
//
|
||||||
#if defined(_WIN32) && defined(_DLL)
|
#if defined(_WIN32) && defined(_DLL)
|
||||||
#if !defined(POCO_DLL) && !defined(POCO_STATIC)
|
#if !defined(POCO_DLL) && !defined(POCO_STATIC)
|
||||||
#define POCO_DLL
|
#define POCO_DLL
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// 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 Foundation_EXPORTS
|
// from a DLL simpler. All files within this DLL are compiled with the Foundation_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
|
||||||
// Foundation_API functions as being imported from a DLL, wheras this DLL sees symbols
|
// Foundation_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(Foundation_EXPORTS)
|
#if defined(Foundation_EXPORTS)
|
||||||
#define Foundation_API __declspec(dllexport)
|
#define Foundation_API __declspec(dllexport)
|
||||||
#else
|
#else
|
||||||
#define Foundation_API __declspec(dllimport)
|
#define Foundation_API __declspec(dllimport)
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if !defined(Foundation_API)
|
#if !defined(Foundation_API)
|
||||||
#define Foundation_API
|
#define Foundation_API
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Automatically link Foundation library.
|
// Automatically link Foundation library.
|
||||||
//
|
//
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(Foundation_EXPORTS)
|
#if !defined(POCO_NO_AUTOMATIC_LIBS) && !defined(Foundation_EXPORTS)
|
||||||
#if defined(POCO_DLL)
|
#if defined(POCO_DLL)
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
#pragma comment(lib, "PocoFoundationd.lib")
|
#pragma comment(lib, "PocoFoundationd.lib")
|
||||||
#else
|
#else
|
||||||
#pragma comment(lib, "PocoFoundation.lib")
|
#pragma comment(lib, "PocoFoundation.lib")
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
#if defined(_DEBUG)
|
#if defined(_DEBUG)
|
||||||
#pragma comment(lib, "PocoFoundationmtd.lib")
|
#pragma comment(lib, "PocoFoundationmtd.lib")
|
||||||
#else
|
#else
|
||||||
#pragma comment(lib, "PocoFoundationmt.lib")
|
#pragma comment(lib, "PocoFoundationmt.lib")
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Include platform-specific definitions
|
// Include platform-specific definitions
|
||||||
//
|
//
|
||||||
#include "Poco/Platform.h"
|
#include "Poco/Platform.h"
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include "Poco/Platform_WIN32.h"
|
#include "Poco/Platform_WIN32.h"
|
||||||
#elif defined(__VMS)
|
#elif defined(__VMS)
|
||||||
#include "Poco/Platform_VMS.h"
|
#include "Poco/Platform_VMS.h"
|
||||||
#elif defined(POCO_OS_FAMILY_UNIX)
|
#elif defined(POCO_OS_FAMILY_UNIX)
|
||||||
#include "Poco/Platform_POSIX.h"
|
#include "Poco/Platform_POSIX.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// POCO_JOIN
|
// POCO_JOIN
|
||||||
//
|
//
|
||||||
// The following piece of macro magic joins the two
|
// The following piece of macro magic joins the two
|
||||||
// arguments together, even when one of the arguments is
|
// arguments together, even when one of the arguments is
|
||||||
// itself a macro (see 16.3.1 in C++ standard). The key
|
// itself a macro (see 16.3.1 in C++ standard). The key
|
||||||
// is that macro expansion of macro arguments does not
|
// is that macro expansion of macro arguments does not
|
||||||
// occur in POCO_DO_JOIN2 but does in POCO_DO_JOIN.
|
// occur in POCO_DO_JOIN2 but does in POCO_DO_JOIN.
|
||||||
//
|
//
|
||||||
#define POCO_JOIN(X, Y) POCO_DO_JOIN(X, Y)
|
#define POCO_JOIN(X, Y) POCO_DO_JOIN(X, Y)
|
||||||
#define POCO_DO_JOIN(X, Y) POCO_DO_JOIN2(X, Y)
|
#define POCO_DO_JOIN(X, Y) POCO_DO_JOIN2(X, Y)
|
||||||
#define POCO_DO_JOIN2(X, Y) X##Y
|
#define POCO_DO_JOIN2(X, Y) X##Y
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Pull in basic definitions
|
// Pull in basic definitions
|
||||||
//
|
//
|
||||||
#include "Poco/Bugcheck.h"
|
#include "Poco/Bugcheck.h"
|
||||||
#include "Poco/Types.h"
|
#include "Poco/Types.h"
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Foundation_INCLUDED
|
#endif // Foundation_Foundation_INCLUDED
|
||||||
|
|||||||
@@ -1,160 +1,160 @@
|
|||||||
//
|
//
|
||||||
// Glob.h
|
// Glob.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Glob.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Glob.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Filesystem
|
// Package: Filesystem
|
||||||
// Module: Glob
|
// Module: Glob
|
||||||
//
|
//
|
||||||
// Definition of the Glob class.
|
// Definition of the Glob 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_Glob_INCLUDED
|
#ifndef Foundation_Glob_INCLUDED
|
||||||
#define Foundation_Glob_INCLUDED
|
#define Foundation_Glob_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Path;
|
class Path;
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API Glob
|
class Foundation_API Glob
|
||||||
/// This class implements glob-style pattern matching
|
/// This class implements glob-style pattern matching
|
||||||
/// as known from Unix shells.
|
/// as known from Unix shells.
|
||||||
///
|
///
|
||||||
/// In the pattern string, '*' matches any sequence of characters,
|
/// In the pattern string, '*' matches any sequence of characters,
|
||||||
/// '?' matches any single character, [SET] matches any single character
|
/// '?' matches any single character, [SET] matches any single character
|
||||||
/// in the specified set, [!SET] matches any character not in the
|
/// in the specified set, [!SET] matches any character not in the
|
||||||
/// specified set.
|
/// specified set.
|
||||||
///
|
///
|
||||||
/// A set is composed of characters or ranges; a range looks like
|
/// A set is composed of characters or ranges; a range looks like
|
||||||
/// character hyphen character (as in 0-9 or A-Z).
|
/// character hyphen character (as in 0-9 or A-Z).
|
||||||
/// [0-9a-zA-Z_] is the set of characters allowed in C identifiers.
|
/// [0-9a-zA-Z_] is the set of characters allowed in C identifiers.
|
||||||
/// Any other character in the pattern must be matched exactly.
|
/// Any other character in the pattern must be matched exactly.
|
||||||
///
|
///
|
||||||
/// To suppress the special syntactic significance of any of '[]*?!-\',
|
/// To suppress the special syntactic significance of any of '[]*?!-\',
|
||||||
/// and match the character exactly, precede it with a backslash.
|
/// and match the character exactly, precede it with a backslash.
|
||||||
///
|
///
|
||||||
/// UTF-8 encoded strings are not supported.
|
/// UTF-8 encoded strings are not supported.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum Options
|
enum Options
|
||||||
/// Flags that modify the matching behavior.
|
/// Flags that modify the matching behavior.
|
||||||
{
|
{
|
||||||
GLOB_DEFAULT = 0x00, /// default behavior
|
GLOB_DEFAULT = 0x00, /// default behavior
|
||||||
GLOB_DOT_SPECIAL = 0x01, /// '*' and '?' do not match '.' at beginning of subject
|
GLOB_DOT_SPECIAL = 0x01, /// '*' and '?' do not match '.' at beginning of subject
|
||||||
GLOB_FOLLOW_SYMLINKS = 0x02, /// follow symbolic links
|
GLOB_FOLLOW_SYMLINKS = 0x02, /// follow symbolic links
|
||||||
GLOB_DIRS_ONLY = 0x80 /// only glob for directories (for internal use only)
|
GLOB_DIRS_ONLY = 0x80 /// only glob for directories (for internal use only)
|
||||||
};
|
};
|
||||||
|
|
||||||
Glob(const std::string& pattern, int options = 0);
|
Glob(const std::string& pattern, int options = 0);
|
||||||
/// Creates the Glob, using the given pattern. The pattern
|
/// Creates the Glob, using the given pattern. The pattern
|
||||||
/// must not be an empty string.
|
/// must not be an empty string.
|
||||||
///
|
///
|
||||||
/// If the GLOB_DOT_SPECIAL option is specified, '*' and '?' do
|
/// If the GLOB_DOT_SPECIAL option is specified, '*' and '?' do
|
||||||
/// not match '.' at the beginning of a matched subject. This is useful for
|
/// not match '.' at the beginning of a matched subject. This is useful for
|
||||||
/// making dot-files invisible in good old Unix-style.
|
/// making dot-files invisible in good old Unix-style.
|
||||||
|
|
||||||
~Glob();
|
~Glob();
|
||||||
/// Destroys the Glob.
|
/// Destroys the Glob.
|
||||||
|
|
||||||
bool match(const std::string& subject);
|
bool match(const std::string& subject);
|
||||||
/// Matches the given subject against the glob pattern.
|
/// Matches the given subject against the glob pattern.
|
||||||
/// Returns true if the subject matches the pattern, false
|
/// Returns true if the subject matches the pattern, false
|
||||||
/// otherwise.
|
/// otherwise.
|
||||||
|
|
||||||
static void glob(const std::string& pathPattern, std::set<std::string>& files, int options = 0);
|
static void glob(const std::string& pathPattern, std::set<std::string>& files, int options = 0);
|
||||||
/// Creates a set of files that match the given pathPattern.
|
/// Creates a set of files that match the given pathPattern.
|
||||||
///
|
///
|
||||||
/// The path may be give in either Unix, Windows or VMS syntax and
|
/// The path may be give in either Unix, Windows or VMS syntax and
|
||||||
/// is automatically expanded by calling Path::expand().
|
/// is automatically expanded by calling Path::expand().
|
||||||
///
|
///
|
||||||
/// The pattern may contain wildcard expressions even in intermediate
|
/// The pattern may contain wildcard expressions even in intermediate
|
||||||
/// directory names (e.g. /usr/include/*/*.h).
|
/// directory names (e.g. /usr/include/*/*.h).
|
||||||
///
|
///
|
||||||
/// Note that, for obvious reasons, escaping characters in a pattern
|
/// Note that, for obvious reasons, escaping characters in a pattern
|
||||||
/// with a backslash does not work in Windows-style paths.
|
/// with a backslash does not work in Windows-style paths.
|
||||||
///
|
///
|
||||||
/// Directories that for whatever reason cannot be traversed are
|
/// Directories that for whatever reason cannot be traversed are
|
||||||
/// ignored.
|
/// ignored.
|
||||||
|
|
||||||
static void glob(const char* pathPattern, std::set<std::string>& files, int options = 0);
|
static void glob(const char* pathPattern, std::set<std::string>& files, int options = 0);
|
||||||
/// Creates a set of files that match the given pathPattern.
|
/// Creates a set of files that match the given pathPattern.
|
||||||
///
|
///
|
||||||
/// The path may be give in either Unix, Windows or VMS syntax and
|
/// The path may be give in either Unix, Windows or VMS syntax and
|
||||||
/// is automatically expanded by calling Path::expand().
|
/// is automatically expanded by calling Path::expand().
|
||||||
///
|
///
|
||||||
/// The pattern may contain wildcard expressions even in intermediate
|
/// The pattern may contain wildcard expressions even in intermediate
|
||||||
/// directory names (e.g. /usr/include/*/*.h).
|
/// directory names (e.g. /usr/include/*/*.h).
|
||||||
///
|
///
|
||||||
/// Note that, for obvious reasons, escaping characters in a pattern
|
/// Note that, for obvious reasons, escaping characters in a pattern
|
||||||
/// with a backslash does not work in Windows-style paths.
|
/// with a backslash does not work in Windows-style paths.
|
||||||
///
|
///
|
||||||
/// Directories that for whatever reason cannot be traversed are
|
/// Directories that for whatever reason cannot be traversed are
|
||||||
/// ignored.
|
/// ignored.
|
||||||
|
|
||||||
static void glob(const Path& pathPattern, std::set<std::string>& files, int options = 0);
|
static void glob(const Path& pathPattern, std::set<std::string>& files, int options = 0);
|
||||||
/// Creates a set of files that match the given pathPattern.
|
/// Creates a set of files that match the given pathPattern.
|
||||||
///
|
///
|
||||||
/// The pattern may contain wildcard expressions even in intermediate
|
/// The pattern may contain wildcard expressions even in intermediate
|
||||||
/// directory names (e.g. /usr/include/*/*.h).
|
/// directory names (e.g. /usr/include/*/*.h).
|
||||||
///
|
///
|
||||||
/// Note that, for obvious reasons, escaping characters in a pattern
|
/// Note that, for obvious reasons, escaping characters in a pattern
|
||||||
/// with a backslash does not work in Windows-style paths.
|
/// with a backslash does not work in Windows-style paths.
|
||||||
///
|
///
|
||||||
/// Directories that for whatever reason cannot be traversed are
|
/// Directories that for whatever reason cannot be traversed are
|
||||||
/// ignored.
|
/// ignored.
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool match(std::string::const_iterator& itp, const std::string::const_iterator& endp, std::string::const_iterator& its, const std::string::const_iterator& ends);
|
bool match(std::string::const_iterator& itp, const std::string::const_iterator& endp, std::string::const_iterator& its, const std::string::const_iterator& ends);
|
||||||
bool matchAfterAsterisk(std::string::const_iterator itp, const std::string::const_iterator& endp, std::string::const_iterator its, const std::string::const_iterator& ends);
|
bool matchAfterAsterisk(std::string::const_iterator itp, const std::string::const_iterator& endp, std::string::const_iterator its, const std::string::const_iterator& ends);
|
||||||
bool matchSet(std::string::const_iterator& itp, const std::string::const_iterator& endp, char c);
|
bool matchSet(std::string::const_iterator& itp, const std::string::const_iterator& endp, char c);
|
||||||
static void collect(const Path& pathPattern, const Path& base, const Path& current, const std::string& pattern, std::set<std::string>& files, int options);
|
static void collect(const Path& pathPattern, const Path& base, const Path& current, const std::string& pattern, std::set<std::string>& files, int options);
|
||||||
static bool isDirectory(const Path& path, bool followSymlink);
|
static bool isDirectory(const Path& path, bool followSymlink);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string _pattern;
|
std::string _pattern;
|
||||||
int _options;
|
int _options;
|
||||||
|
|
||||||
Glob();
|
Glob();
|
||||||
Glob(const Glob&);
|
Glob(const Glob&);
|
||||||
Glob& operator = (const Glob&);
|
Glob& operator = (const Glob&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Glob_INCLUDED
|
#endif // Foundation_Glob_INCLUDED
|
||||||
|
|||||||
@@ -1,168 +1,168 @@
|
|||||||
//
|
//
|
||||||
// HMACEngine.h
|
// HMACEngine.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/HMACEngine.h#3 $
|
// $Id: //poco/1.3/Foundation/include/Poco/HMACEngine.h#3 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Crypt
|
// Package: Crypt
|
||||||
// Module: HMACEngine
|
// Module: HMACEngine
|
||||||
//
|
//
|
||||||
// Definition of the HMACEngine class.
|
// Definition of the HMACEngine 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_HMACEngine_INCLUDED
|
#ifndef Foundation_HMACEngine_INCLUDED
|
||||||
#define Foundation_HMACEngine_INCLUDED
|
#define Foundation_HMACEngine_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/DigestEngine.h"
|
#include "Poco/DigestEngine.h"
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class Engine>
|
template <class Engine>
|
||||||
class HMACEngine: public DigestEngine
|
class HMACEngine: public DigestEngine
|
||||||
/// This class implementes the HMAC message
|
/// This class implementes the HMAC message
|
||||||
/// authentication code algorithm, as specified
|
/// authentication code algorithm, as specified
|
||||||
/// in RFC 2104. The underlying DigestEngine
|
/// in RFC 2104. The underlying DigestEngine
|
||||||
/// (MD5Engine, SHA1Engine, etc.) must be given as
|
/// (MD5Engine, SHA1Engine, etc.) must be given as
|
||||||
/// template argument.
|
/// template argument.
|
||||||
/// Since the HMACEngine is a DigestEngine, it can
|
/// Since the HMACEngine is a DigestEngine, it can
|
||||||
/// be used with the DigestStream class to create
|
/// be used with the DigestStream class to create
|
||||||
/// a HMAC for a stream.
|
/// a HMAC for a stream.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
BLOCK_SIZE = Engine::BLOCK_SIZE,
|
BLOCK_SIZE = Engine::BLOCK_SIZE,
|
||||||
DIGEST_SIZE = Engine::DIGEST_SIZE
|
DIGEST_SIZE = Engine::DIGEST_SIZE
|
||||||
};
|
};
|
||||||
|
|
||||||
HMACEngine(const std::string& passphrase)
|
HMACEngine(const std::string& passphrase)
|
||||||
{
|
{
|
||||||
init(passphrase.data(), (unsigned) passphrase.length());
|
init(passphrase.data(), (unsigned) passphrase.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
HMACEngine(const char* passphrase, unsigned length)
|
HMACEngine(const char* passphrase, unsigned length)
|
||||||
{
|
{
|
||||||
poco_check_ptr (passphrase);
|
poco_check_ptr (passphrase);
|
||||||
|
|
||||||
init(passphrase, length);
|
init(passphrase, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
~HMACEngine()
|
~HMACEngine()
|
||||||
{
|
{
|
||||||
std::memset(_ipad, 0, BLOCK_SIZE);
|
std::memset(_ipad, 0, BLOCK_SIZE);
|
||||||
std::memset(_opad, 0, BLOCK_SIZE);
|
std::memset(_opad, 0, BLOCK_SIZE);
|
||||||
delete [] _ipad;
|
delete [] _ipad;
|
||||||
delete [] _opad;
|
delete [] _opad;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned digestLength() const
|
unsigned digestLength() const
|
||||||
{
|
{
|
||||||
return DIGEST_SIZE;
|
return DIGEST_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset()
|
void reset()
|
||||||
{
|
{
|
||||||
_engine.reset();
|
_engine.reset();
|
||||||
_engine.update(_ipad, BLOCK_SIZE);
|
_engine.update(_ipad, BLOCK_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
const DigestEngine::Digest& digest()
|
const DigestEngine::Digest& digest()
|
||||||
{
|
{
|
||||||
const DigestEngine::Digest& d = _engine.digest();
|
const DigestEngine::Digest& d = _engine.digest();
|
||||||
char db[DIGEST_SIZE];
|
char db[DIGEST_SIZE];
|
||||||
char* pdb = db;
|
char* pdb = db;
|
||||||
for (DigestEngine::Digest::const_iterator it = d.begin(); it != d.end(); ++it)
|
for (DigestEngine::Digest::const_iterator it = d.begin(); it != d.end(); ++it)
|
||||||
*pdb++ = *it;
|
*pdb++ = *it;
|
||||||
_engine.reset();
|
_engine.reset();
|
||||||
_engine.update(_opad, BLOCK_SIZE);
|
_engine.update(_opad, BLOCK_SIZE);
|
||||||
_engine.update(db, DIGEST_SIZE);
|
_engine.update(db, DIGEST_SIZE);
|
||||||
const DigestEngine::Digest& result = _engine.digest();
|
const DigestEngine::Digest& result = _engine.digest();
|
||||||
reset();
|
reset();
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void init(const char* passphrase, unsigned length)
|
void init(const char* passphrase, unsigned length)
|
||||||
{
|
{
|
||||||
_ipad = new char[BLOCK_SIZE];
|
_ipad = new char[BLOCK_SIZE];
|
||||||
_opad = new char[BLOCK_SIZE];
|
_opad = new char[BLOCK_SIZE];
|
||||||
std::memset(_ipad, 0, BLOCK_SIZE);
|
std::memset(_ipad, 0, BLOCK_SIZE);
|
||||||
std::memset(_opad, 0, BLOCK_SIZE);
|
std::memset(_opad, 0, BLOCK_SIZE);
|
||||||
if (length > BLOCK_SIZE)
|
if (length > BLOCK_SIZE)
|
||||||
{
|
{
|
||||||
_engine.reset();
|
_engine.reset();
|
||||||
_engine.update(passphrase, length);
|
_engine.update(passphrase, length);
|
||||||
const DigestEngine::Digest& d = _engine.digest();
|
const DigestEngine::Digest& d = _engine.digest();
|
||||||
char* ipad = _ipad;
|
char* ipad = _ipad;
|
||||||
char* opad = _opad;
|
char* opad = _opad;
|
||||||
int n = BLOCK_SIZE;
|
int n = BLOCK_SIZE;
|
||||||
for (DigestEngine::Digest::const_iterator it = d.begin(); it != d.end() && n-- > 0; ++it)
|
for (DigestEngine::Digest::const_iterator it = d.begin(); it != d.end() && n-- > 0; ++it)
|
||||||
{
|
{
|
||||||
*ipad++ = *it;
|
*ipad++ = *it;
|
||||||
*opad++ = *it;
|
*opad++ = *it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
std::memcpy(_ipad, passphrase, length);
|
std::memcpy(_ipad, passphrase, length);
|
||||||
std::memcpy(_opad, passphrase, length);
|
std::memcpy(_opad, passphrase, length);
|
||||||
}
|
}
|
||||||
for (int i = 0; i < BLOCK_SIZE; ++i)
|
for (int i = 0; i < BLOCK_SIZE; ++i)
|
||||||
{
|
{
|
||||||
_ipad[i] ^= 0x36;
|
_ipad[i] ^= 0x36;
|
||||||
_opad[i] ^= 0x5c;
|
_opad[i] ^= 0x5c;
|
||||||
}
|
}
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateImpl(const void* data, unsigned length)
|
void updateImpl(const void* data, unsigned length)
|
||||||
{
|
{
|
||||||
_engine.update(data, length);
|
_engine.update(data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HMACEngine();
|
HMACEngine();
|
||||||
HMACEngine(const HMACEngine&);
|
HMACEngine(const HMACEngine&);
|
||||||
HMACEngine& operator = (const HMACEngine&);
|
HMACEngine& operator = (const HMACEngine&);
|
||||||
|
|
||||||
Engine _engine;
|
Engine _engine;
|
||||||
char* _ipad;
|
char* _ipad;
|
||||||
char* _opad;
|
char* _opad;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_HMACEngine_INCLUDED
|
#endif // Foundation_HMACEngine_INCLUDED
|
||||||
|
|||||||
@@ -1,127 +1,127 @@
|
|||||||
//
|
//
|
||||||
// Hash.h
|
// Hash.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Hash.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Hash.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Hashing
|
// Package: Hashing
|
||||||
// Module: Hash
|
// Module: Hash
|
||||||
//
|
//
|
||||||
// Definition of the Hash class.
|
// Definition of the Hash 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 Foundation_Hash_INCLUDED
|
#ifndef Foundation_Hash_INCLUDED
|
||||||
#define Foundation_Hash_INCLUDED
|
#define Foundation_Hash_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
struct Hash
|
struct Hash
|
||||||
/// A generic hash function.
|
/// A generic hash function.
|
||||||
{
|
{
|
||||||
std::size_t operator () (T value) const
|
std::size_t operator () (T value) const
|
||||||
/// Returns the hash for the given value.
|
/// Returns the hash for the given value.
|
||||||
{
|
{
|
||||||
return hash(value);
|
return hash(value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
std::size_t Foundation_API hash(Int8 n);
|
std::size_t Foundation_API hash(Int8 n);
|
||||||
std::size_t Foundation_API hash(UInt8 n);
|
std::size_t Foundation_API hash(UInt8 n);
|
||||||
std::size_t Foundation_API hash(Int16 n);
|
std::size_t Foundation_API hash(Int16 n);
|
||||||
std::size_t Foundation_API hash(UInt16 n);
|
std::size_t Foundation_API hash(UInt16 n);
|
||||||
std::size_t Foundation_API hash(Int32 n);
|
std::size_t Foundation_API hash(Int32 n);
|
||||||
std::size_t Foundation_API hash(UInt32 n);
|
std::size_t Foundation_API hash(UInt32 n);
|
||||||
std::size_t Foundation_API hash(Int64 n);
|
std::size_t Foundation_API hash(Int64 n);
|
||||||
std::size_t Foundation_API hash(UInt64 n);
|
std::size_t Foundation_API hash(UInt64 n);
|
||||||
std::size_t Foundation_API hash(const std::string& str);
|
std::size_t Foundation_API hash(const std::string& str);
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// inlines
|
// inlines
|
||||||
//
|
//
|
||||||
inline std::size_t hash(Int8 n)
|
inline std::size_t hash(Int8 n)
|
||||||
{
|
{
|
||||||
return static_cast<std::size_t>(n)*2654435761U;
|
return static_cast<std::size_t>(n)*2654435761U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::size_t hash(UInt8 n)
|
inline std::size_t hash(UInt8 n)
|
||||||
{
|
{
|
||||||
return static_cast<std::size_t>(n)*2654435761U;
|
return static_cast<std::size_t>(n)*2654435761U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::size_t hash(Int16 n)
|
inline std::size_t hash(Int16 n)
|
||||||
{
|
{
|
||||||
return static_cast<std::size_t>(n)*2654435761U;
|
return static_cast<std::size_t>(n)*2654435761U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::size_t hash(UInt16 n)
|
inline std::size_t hash(UInt16 n)
|
||||||
{
|
{
|
||||||
return static_cast<std::size_t>(n)*2654435761U;
|
return static_cast<std::size_t>(n)*2654435761U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::size_t hash(Int32 n)
|
inline std::size_t hash(Int32 n)
|
||||||
{
|
{
|
||||||
return static_cast<std::size_t>(n)*2654435761U;
|
return static_cast<std::size_t>(n)*2654435761U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::size_t hash(UInt32 n)
|
inline std::size_t hash(UInt32 n)
|
||||||
{
|
{
|
||||||
return static_cast<std::size_t>(n)*2654435761U;
|
return static_cast<std::size_t>(n)*2654435761U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::size_t hash(Int64 n)
|
inline std::size_t hash(Int64 n)
|
||||||
{
|
{
|
||||||
return static_cast<std::size_t>(n)*2654435761U;
|
return static_cast<std::size_t>(n)*2654435761U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline std::size_t hash(UInt64 n)
|
inline std::size_t hash(UInt64 n)
|
||||||
{
|
{
|
||||||
return static_cast<std::size_t>(n)*2654435761U;
|
return static_cast<std::size_t>(n)*2654435761U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Hash_INCLUDED
|
#endif // Foundation_Hash_INCLUDED
|
||||||
|
|||||||
@@ -1,79 +1,79 @@
|
|||||||
//
|
//
|
||||||
// HashFunction.h
|
// HashFunction.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/HashFunction.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/HashFunction.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Hashing
|
// Package: Hashing
|
||||||
// Module: HashFunction
|
// Module: HashFunction
|
||||||
//
|
//
|
||||||
// Definition of the HashFunction class.
|
// Definition of the HashFunction 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 Foundation_HashFunction_INCLUDED
|
#ifndef Foundation_HashFunction_INCLUDED
|
||||||
#define Foundation_HashFunction_INCLUDED
|
#define Foundation_HashFunction_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/Hash.h"
|
#include "Poco/Hash.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
//@ deprecated
|
//@ deprecated
|
||||||
template <class T>
|
template <class T>
|
||||||
struct HashFunction
|
struct HashFunction
|
||||||
/// A generic hash function.
|
/// A generic hash function.
|
||||||
{
|
{
|
||||||
UInt32 operator () (T key, UInt32 maxValue) const
|
UInt32 operator () (T key, UInt32 maxValue) const
|
||||||
/// Returns the hash value for the given key.
|
/// Returns the hash value for the given key.
|
||||||
{
|
{
|
||||||
return ((UInt32) hash(key)) % maxValue;
|
return ((UInt32) hash(key)) % maxValue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
//@ deprecated
|
//@ deprecated
|
||||||
template <>
|
template <>
|
||||||
struct HashFunction<std::string>
|
struct HashFunction<std::string>
|
||||||
/// A generic hash function.
|
/// A generic hash function.
|
||||||
{
|
{
|
||||||
UInt32 operator () (const std::string& key, UInt32 maxValue) const
|
UInt32 operator () (const std::string& key, UInt32 maxValue) const
|
||||||
/// Returns the hash value for the given key.
|
/// Returns the hash value for the given key.
|
||||||
{
|
{
|
||||||
return ((UInt32) hash(key)) % maxValue;
|
return ((UInt32) hash(key)) % maxValue;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_HashFunctions_INCLUDED
|
#endif // Foundation_HashFunctions_INCLUDED
|
||||||
|
|||||||
@@ -1,244 +1,244 @@
|
|||||||
//
|
//
|
||||||
// HashMap.h
|
// HashMap.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/HashMap.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/HashMap.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Hashing
|
// Package: Hashing
|
||||||
// Module: HashMap
|
// Module: HashMap
|
||||||
//
|
//
|
||||||
// Definition of the HashMap class.
|
// Definition of the HashMap 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 Foundation_HashMap_INCLUDED
|
#ifndef Foundation_HashMap_INCLUDED
|
||||||
#define Foundation_HashMap_INCLUDED
|
#define Foundation_HashMap_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/LinearHashTable.h"
|
#include "Poco/LinearHashTable.h"
|
||||||
#include "Poco/Exception.h"
|
#include "Poco/Exception.h"
|
||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class Key, class Value>
|
template <class Key, class Value>
|
||||||
struct HashMapEntry
|
struct HashMapEntry
|
||||||
/// This class template is used internally by HashMap.
|
/// This class template is used internally by HashMap.
|
||||||
{
|
{
|
||||||
Key first;
|
Key first;
|
||||||
Value second;
|
Value second;
|
||||||
|
|
||||||
HashMapEntry():
|
HashMapEntry():
|
||||||
first(),
|
first(),
|
||||||
second()
|
second()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMapEntry(const Key& key):
|
HashMapEntry(const Key& key):
|
||||||
first(key),
|
first(key),
|
||||||
second()
|
second()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMapEntry(const Key& key, const Value& value):
|
HashMapEntry(const Key& key, const Value& value):
|
||||||
first(key),
|
first(key),
|
||||||
second(value)
|
second(value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator == (const HashMapEntry& entry) const
|
bool operator == (const HashMapEntry& entry) const
|
||||||
{
|
{
|
||||||
return first == entry.first;
|
return first == entry.first;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator != (const HashMapEntry& entry) const
|
bool operator != (const HashMapEntry& entry) const
|
||||||
{
|
{
|
||||||
return first != entry.first;
|
return first != entry.first;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class HME, class KeyHashFunc>
|
template <class HME, class KeyHashFunc>
|
||||||
struct HashMapEntryHash
|
struct HashMapEntryHash
|
||||||
/// This class template is used internally by HashMap.
|
/// This class template is used internally by HashMap.
|
||||||
{
|
{
|
||||||
std::size_t operator () (const HME& entry) const
|
std::size_t operator () (const HME& entry) const
|
||||||
{
|
{
|
||||||
return _func(entry.first);
|
return _func(entry.first);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KeyHashFunc _func;
|
KeyHashFunc _func;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class Key, class Mapped, class HashFunc = Hash<Key> >
|
template <class Key, class Mapped, class HashFunc = Hash<Key> >
|
||||||
class HashMap
|
class HashMap
|
||||||
/// This class implements a map using a LinearHashTable.
|
/// This class implements a map using a LinearHashTable.
|
||||||
///
|
///
|
||||||
/// A HashMap can be used just like a std::map.
|
/// A HashMap can be used just like a std::map.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Key KeyType;
|
typedef Key KeyType;
|
||||||
typedef Mapped MappedType;
|
typedef Mapped MappedType;
|
||||||
typedef Mapped& Reference;
|
typedef Mapped& Reference;
|
||||||
typedef const Mapped& ConstReference;
|
typedef const Mapped& ConstReference;
|
||||||
typedef Mapped* Pointer;
|
typedef Mapped* Pointer;
|
||||||
typedef const Mapped* ConstPointer;
|
typedef const Mapped* ConstPointer;
|
||||||
|
|
||||||
typedef HashMapEntry<Key, Mapped> ValueType;
|
typedef HashMapEntry<Key, Mapped> ValueType;
|
||||||
typedef std::pair<KeyType, MappedType> PairType;
|
typedef std::pair<KeyType, MappedType> PairType;
|
||||||
|
|
||||||
typedef HashMapEntryHash<ValueType, HashFunc> HashType;
|
typedef HashMapEntryHash<ValueType, HashFunc> HashType;
|
||||||
typedef LinearHashTable<ValueType, HashType> HashTable;
|
typedef LinearHashTable<ValueType, HashType> HashTable;
|
||||||
|
|
||||||
typedef typename HashTable::Iterator Iterator;
|
typedef typename HashTable::Iterator Iterator;
|
||||||
typedef typename HashTable::ConstIterator ConstIterator;
|
typedef typename HashTable::ConstIterator ConstIterator;
|
||||||
|
|
||||||
HashMap()
|
HashMap()
|
||||||
/// Creates an empty HashMap.
|
/// Creates an empty HashMap.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap(std::size_t initialReserve):
|
HashMap(std::size_t initialReserve):
|
||||||
_table(initialReserve)
|
_table(initialReserve)
|
||||||
/// Creates the HashMap with room for initialReserve entries.
|
/// Creates the HashMap with room for initialReserve entries.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap& operator = (const HashMap& map)
|
HashMap& operator = (const HashMap& map)
|
||||||
/// Assigns another HashMap.
|
/// Assigns another HashMap.
|
||||||
{
|
{
|
||||||
HashMap tmp(map);
|
HashMap tmp(map);
|
||||||
swap(tmp);
|
swap(tmp);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(HashMap& map)
|
void swap(HashMap& map)
|
||||||
/// Swaps the HashMap with another one.
|
/// Swaps the HashMap with another one.
|
||||||
{
|
{
|
||||||
_table.swap(map._table);
|
_table.swap(map._table);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstIterator begin() const
|
ConstIterator begin() const
|
||||||
{
|
{
|
||||||
return _table.begin();
|
return _table.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstIterator end() const
|
ConstIterator end() const
|
||||||
{
|
{
|
||||||
return _table.end();
|
return _table.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator begin()
|
Iterator begin()
|
||||||
{
|
{
|
||||||
return _table.begin();
|
return _table.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator end()
|
Iterator end()
|
||||||
{
|
{
|
||||||
return _table.end();
|
return _table.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstIterator find(const KeyType& key) const
|
ConstIterator find(const KeyType& key) const
|
||||||
{
|
{
|
||||||
ValueType value(key);
|
ValueType value(key);
|
||||||
return _table.find(value);
|
return _table.find(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator find(const KeyType& key)
|
Iterator find(const KeyType& key)
|
||||||
{
|
{
|
||||||
ValueType value(key);
|
ValueType value(key);
|
||||||
return _table.find(value);
|
return _table.find(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<Iterator, bool> insert(const PairType& pair)
|
std::pair<Iterator, bool> insert(const PairType& pair)
|
||||||
{
|
{
|
||||||
ValueType value(pair.first, pair.second);
|
ValueType value(pair.first, pair.second);
|
||||||
return _table.insert(value);
|
return _table.insert(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<Iterator, bool> insert(const ValueType& value)
|
std::pair<Iterator, bool> insert(const ValueType& value)
|
||||||
{
|
{
|
||||||
return _table.insert(value);
|
return _table.insert(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void erase(Iterator it)
|
void erase(Iterator it)
|
||||||
{
|
{
|
||||||
_table.erase(it);
|
_table.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
void erase(const KeyType& key)
|
void erase(const KeyType& key)
|
||||||
{
|
{
|
||||||
Iterator it = find(key);
|
Iterator it = find(key);
|
||||||
_table.erase(it);
|
_table.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
{
|
{
|
||||||
_table.clear();
|
_table.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t size() const
|
std::size_t size() const
|
||||||
{
|
{
|
||||||
return _table.size();
|
return _table.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty() const
|
bool empty() const
|
||||||
{
|
{
|
||||||
return _table.empty();
|
return _table.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstReference operator [] (const KeyType& key) const
|
ConstReference operator [] (const KeyType& key) const
|
||||||
{
|
{
|
||||||
ConstIterator it = _table.find(key);
|
ConstIterator it = _table.find(key);
|
||||||
if (it != _table.end())
|
if (it != _table.end())
|
||||||
return it->second;
|
return it->second;
|
||||||
else
|
else
|
||||||
throw NotFoundException();
|
throw NotFoundException();
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference operator [] (const KeyType& key)
|
Reference operator [] (const KeyType& key)
|
||||||
{
|
{
|
||||||
ValueType value(key);
|
ValueType value(key);
|
||||||
std::pair<Iterator, bool> res = _table.insert(value);
|
std::pair<Iterator, bool> res = _table.insert(value);
|
||||||
return res.first->second;
|
return res.first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HashTable _table;
|
HashTable _table;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_HashMap_INCLUDED
|
#endif // Foundation_HashMap_INCLUDED
|
||||||
|
|||||||
@@ -1,199 +1,199 @@
|
|||||||
//
|
//
|
||||||
// HashSet.h
|
// HashSet.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/HashSet.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/HashSet.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Hashing
|
// Package: Hashing
|
||||||
// Module: HashSet
|
// Module: HashSet
|
||||||
//
|
//
|
||||||
// Definition of the HashSet class.
|
// Definition of the HashSet 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 Foundation_HashSet_INCLUDED
|
#ifndef Foundation_HashSet_INCLUDED
|
||||||
#define Foundation_HashSet_INCLUDED
|
#define Foundation_HashSet_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/LinearHashTable.h"
|
#include "Poco/LinearHashTable.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class Value, class HashFunc = Hash<Value> >
|
template <class Value, class HashFunc = Hash<Value> >
|
||||||
class HashSet
|
class HashSet
|
||||||
/// This class implements a set using a LinearHashTable.
|
/// This class implements a set using a LinearHashTable.
|
||||||
///
|
///
|
||||||
/// A HashSet can be used just like a std::set.
|
/// A HashSet can be used just like a std::set.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef Value ValueType;
|
typedef Value ValueType;
|
||||||
typedef Value& Reference;
|
typedef Value& Reference;
|
||||||
typedef const Value& ConstReference;
|
typedef const Value& ConstReference;
|
||||||
typedef Value* Pointer;
|
typedef Value* Pointer;
|
||||||
typedef const Value* ConstPointer;
|
typedef const Value* ConstPointer;
|
||||||
typedef HashFunc Hash;
|
typedef HashFunc Hash;
|
||||||
|
|
||||||
typedef LinearHashTable<ValueType, Hash> HashTable;
|
typedef LinearHashTable<ValueType, Hash> HashTable;
|
||||||
|
|
||||||
typedef typename HashTable::Iterator Iterator;
|
typedef typename HashTable::Iterator Iterator;
|
||||||
typedef typename HashTable::ConstIterator ConstIterator;
|
typedef typename HashTable::ConstIterator ConstIterator;
|
||||||
|
|
||||||
HashSet()
|
HashSet()
|
||||||
/// Creates an empty HashSet.
|
/// Creates an empty HashSet.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HashSet(std::size_t initialReserve):
|
HashSet(std::size_t initialReserve):
|
||||||
_table(initialReserve)
|
_table(initialReserve)
|
||||||
/// Creates the HashSet, using the given initialReserve.
|
/// Creates the HashSet, using the given initialReserve.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HashSet(const HashSet& set):
|
HashSet(const HashSet& set):
|
||||||
_table(set._table)
|
_table(set._table)
|
||||||
/// Creates the HashSet by copying another one.
|
/// Creates the HashSet by copying another one.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~HashSet()
|
~HashSet()
|
||||||
/// Destroys the HashSet.
|
/// Destroys the HashSet.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
HashSet& operator = (const HashSet& table)
|
HashSet& operator = (const HashSet& table)
|
||||||
/// Assigns another HashSet.
|
/// Assigns another HashSet.
|
||||||
{
|
{
|
||||||
HashSet tmp(table);
|
HashSet tmp(table);
|
||||||
swap(tmp);
|
swap(tmp);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
void swap(HashSet& set)
|
void swap(HashSet& set)
|
||||||
/// Swaps the HashSet with another one.
|
/// Swaps the HashSet with another one.
|
||||||
{
|
{
|
||||||
_table.swap(set._table);
|
_table.swap(set._table);
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstIterator begin() const
|
ConstIterator begin() const
|
||||||
/// Returns an iterator pointing to the first entry, if one exists.
|
/// Returns an iterator pointing to the first entry, if one exists.
|
||||||
{
|
{
|
||||||
return _table.begin();
|
return _table.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstIterator end() const
|
ConstIterator end() const
|
||||||
/// Returns an iterator pointing to the end of the table.
|
/// Returns an iterator pointing to the end of the table.
|
||||||
{
|
{
|
||||||
return _table.end();
|
return _table.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator begin()
|
Iterator begin()
|
||||||
/// Returns an iterator pointing to the first entry, if one exists.
|
/// Returns an iterator pointing to the first entry, if one exists.
|
||||||
{
|
{
|
||||||
return _table.begin();
|
return _table.begin();
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator end()
|
Iterator end()
|
||||||
/// Returns an iterator pointing to the end of the table.
|
/// Returns an iterator pointing to the end of the table.
|
||||||
{
|
{
|
||||||
return _table.end();
|
return _table.end();
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstIterator find(const ValueType& value) const
|
ConstIterator find(const ValueType& value) const
|
||||||
/// Finds an entry in the table.
|
/// Finds an entry in the table.
|
||||||
{
|
{
|
||||||
return _table.find(value);
|
return _table.find(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
Iterator find(const ValueType& value)
|
Iterator find(const ValueType& value)
|
||||||
/// Finds an entry in the table.
|
/// Finds an entry in the table.
|
||||||
{
|
{
|
||||||
return _table.find(value);
|
return _table.find(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t count(const ValueType& value) const
|
std::size_t count(const ValueType& value) const
|
||||||
/// Returns the number of elements with the given
|
/// Returns the number of elements with the given
|
||||||
/// value, with is either 1 or 0.
|
/// value, with is either 1 or 0.
|
||||||
{
|
{
|
||||||
return _table.count(value);
|
return _table.count(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::pair<Iterator, bool> insert(const ValueType& value)
|
std::pair<Iterator, bool> insert(const ValueType& value)
|
||||||
/// Inserts an element into the set.
|
/// Inserts an element into the set.
|
||||||
///
|
///
|
||||||
/// If the element already exists in the set,
|
/// If the element already exists in the set,
|
||||||
/// a pair(iterator, false) with iterator pointing to the
|
/// a pair(iterator, false) with iterator pointing to the
|
||||||
/// existing element is returned.
|
/// existing element is returned.
|
||||||
/// Otherwise, the element is inserted an a
|
/// Otherwise, the element is inserted an a
|
||||||
/// pair(iterator, true) with iterator
|
/// pair(iterator, true) with iterator
|
||||||
/// pointing to the new element is returned.
|
/// pointing to the new element is returned.
|
||||||
{
|
{
|
||||||
return _table.insert(value);
|
return _table.insert(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void erase(Iterator it)
|
void erase(Iterator it)
|
||||||
/// Erases the element pointed to by it.
|
/// Erases the element pointed to by it.
|
||||||
{
|
{
|
||||||
_table.erase(it);
|
_table.erase(it);
|
||||||
}
|
}
|
||||||
|
|
||||||
void erase(const ValueType& value)
|
void erase(const ValueType& value)
|
||||||
/// Erases the element with the given value, if it exists.
|
/// Erases the element with the given value, if it exists.
|
||||||
{
|
{
|
||||||
_table.erase(value);
|
_table.erase(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear()
|
void clear()
|
||||||
/// Erases all elements.
|
/// Erases all elements.
|
||||||
{
|
{
|
||||||
_table.clear();
|
_table.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
std::size_t size() const
|
std::size_t size() const
|
||||||
/// Returns the number of elements in the table.
|
/// Returns the number of elements in the table.
|
||||||
{
|
{
|
||||||
return _table.size();
|
return _table.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty() const
|
bool empty() const
|
||||||
/// Returns true iff the table is empty.
|
/// Returns true iff the table is empty.
|
||||||
{
|
{
|
||||||
return _table.empty();
|
return _table.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HashTable _table;
|
HashTable _table;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_HashSet_INCLUDED
|
#endif // Foundation_HashSet_INCLUDED
|
||||||
|
|||||||
@@ -1,148 +1,148 @@
|
|||||||
//
|
//
|
||||||
// HashStatistic.h
|
// HashStatistic.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/HashStatistic.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/HashStatistic.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Hashing
|
// Package: Hashing
|
||||||
// Module: HashStatistic
|
// Module: HashStatistic
|
||||||
//
|
//
|
||||||
// Definition of the HashStatistic class.
|
// Definition of the HashStatistic 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 Foundation_HashStatistic_INCLUDED
|
#ifndef Foundation_HashStatistic_INCLUDED
|
||||||
#define Foundation_HashStatistic_INCLUDED
|
#define Foundation_HashStatistic_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
//@ deprecated
|
//@ deprecated
|
||||||
class Foundation_API HashStatistic
|
class Foundation_API HashStatistic
|
||||||
/// HashStatistic class bundles statistical information on the current state of a HashTable
|
/// HashStatistic class bundles statistical information on the current state of a HashTable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HashStatistic(
|
HashStatistic(
|
||||||
UInt32 tableSize,
|
UInt32 tableSize,
|
||||||
UInt32 numEntries,
|
UInt32 numEntries,
|
||||||
UInt32 numZeroEntries,
|
UInt32 numZeroEntries,
|
||||||
UInt32 maxEntry,
|
UInt32 maxEntry,
|
||||||
std::vector<UInt32> details = std::vector<UInt32>());
|
std::vector<UInt32> details = std::vector<UInt32>());
|
||||||
/// Creates the HashStatistic.
|
/// Creates the HashStatistic.
|
||||||
|
|
||||||
virtual ~HashStatistic();
|
virtual ~HashStatistic();
|
||||||
/// Destroys the HashStatistic.
|
/// Destroys the HashStatistic.
|
||||||
|
|
||||||
UInt32 maxPositionsOfTable() const;
|
UInt32 maxPositionsOfTable() const;
|
||||||
/// Returns the maximum number of different hash values possible for the table
|
/// Returns the maximum number of different hash values possible for the table
|
||||||
|
|
||||||
UInt32 numberOfEntries() const;
|
UInt32 numberOfEntries() const;
|
||||||
/// Returns the total number of entries currently stored in the HashTable
|
/// Returns the total number of entries currently stored in the HashTable
|
||||||
|
|
||||||
UInt32 numberOfZeroPositions() const;
|
UInt32 numberOfZeroPositions() const;
|
||||||
/// Returns the number of hash positions that contain no entry.
|
/// Returns the number of hash positions that contain no entry.
|
||||||
|
|
||||||
double avgEntriesPerHash() const;
|
double avgEntriesPerHash() const;
|
||||||
/// Returns the average number of entries per position in the Hashtable, the higher this value the less efficient
|
/// Returns the average number of entries per position in the Hashtable, the higher this value the less efficient
|
||||||
/// performs hashing. If a large value is returned and getNumberOfZeroPositions also returns a large value, this
|
/// performs hashing. If a large value is returned and getNumberOfZeroPositions also returns a large value, this
|
||||||
/// indicates an inefficient hashing function. If the number of zero entries is low, resizing the HashTable, should
|
/// indicates an inefficient hashing function. If the number of zero entries is low, resizing the HashTable, should
|
||||||
/// be enough to improve performance
|
/// be enough to improve performance
|
||||||
|
|
||||||
double avgEntriesPerHashExclZeroEntries() const;
|
double avgEntriesPerHashExclZeroEntries() const;
|
||||||
/// Same as getAvgEntriesPerHash but hash values that contain no entry are ignored,
|
/// Same as getAvgEntriesPerHash but hash values that contain no entry are ignored,
|
||||||
/// getAvgEntriesPerHashExclZeroEntries >= getAvgEntriesPerHash will always be true.
|
/// getAvgEntriesPerHashExclZeroEntries >= getAvgEntriesPerHash will always be true.
|
||||||
|
|
||||||
UInt32 maxEntriesPerHash() const;
|
UInt32 maxEntriesPerHash() const;
|
||||||
/// Returns the maximum number of entries per hash value found in the current table.
|
/// Returns the maximum number of entries per hash value found in the current table.
|
||||||
|
|
||||||
const std::vector<UInt32> detailedEntriesPerHash() const;
|
const std::vector<UInt32> detailedEntriesPerHash() const;
|
||||||
/// Will either be an empty vector or will contain for each possible hash value, the number of entries currently stored
|
/// Will either be an empty vector or will contain for each possible hash value, the number of entries currently stored
|
||||||
|
|
||||||
std::string toString() const;
|
std::string toString() const;
|
||||||
/// Converts the whole data structure into a string.
|
/// Converts the whole data structure into a string.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
UInt32 _sizeOfTable;
|
UInt32 _sizeOfTable;
|
||||||
UInt32 _numberOfEntries;
|
UInt32 _numberOfEntries;
|
||||||
UInt32 _numZeroEntries;
|
UInt32 _numZeroEntries;
|
||||||
UInt32 _maxEntriesPerHash;
|
UInt32 _maxEntriesPerHash;
|
||||||
std::vector<UInt32> _detailedEntriesPerHash;
|
std::vector<UInt32> _detailedEntriesPerHash;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
inline UInt32 HashStatistic::maxPositionsOfTable() const
|
inline UInt32 HashStatistic::maxPositionsOfTable() const
|
||||||
{
|
{
|
||||||
return _sizeOfTable;
|
return _sizeOfTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline UInt32 HashStatistic::numberOfEntries() const
|
inline UInt32 HashStatistic::numberOfEntries() const
|
||||||
{
|
{
|
||||||
return _numberOfEntries;
|
return _numberOfEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline UInt32 HashStatistic::numberOfZeroPositions() const
|
inline UInt32 HashStatistic::numberOfZeroPositions() const
|
||||||
{
|
{
|
||||||
return _numZeroEntries;
|
return _numZeroEntries;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double HashStatistic::avgEntriesPerHash() const
|
inline double HashStatistic::avgEntriesPerHash() const
|
||||||
{
|
{
|
||||||
return ((double) numberOfEntries()) / maxPositionsOfTable();
|
return ((double) numberOfEntries()) / maxPositionsOfTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline double HashStatistic::avgEntriesPerHashExclZeroEntries() const
|
inline double HashStatistic::avgEntriesPerHashExclZeroEntries() const
|
||||||
{
|
{
|
||||||
return ((double) numberOfEntries()) / (maxPositionsOfTable() - numberOfZeroPositions());
|
return ((double) numberOfEntries()) / (maxPositionsOfTable() - numberOfZeroPositions());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline UInt32 HashStatistic::maxEntriesPerHash() const
|
inline UInt32 HashStatistic::maxEntriesPerHash() const
|
||||||
{
|
{
|
||||||
return _maxEntriesPerHash;
|
return _maxEntriesPerHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
inline const std::vector<UInt32> HashStatistic::detailedEntriesPerHash() const
|
inline const std::vector<UInt32> HashStatistic::detailedEntriesPerHash() const
|
||||||
{
|
{
|
||||||
return _detailedEntriesPerHash;
|
return _detailedEntriesPerHash;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_HashStatistic_INCLUDED
|
#endif // Foundation_HashStatistic_INCLUDED
|
||||||
|
|||||||
@@ -1,104 +1,104 @@
|
|||||||
//
|
//
|
||||||
// HexBinaryDecoder.h
|
// HexBinaryDecoder.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/HexBinaryDecoder.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/HexBinaryDecoder.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: HexBinary
|
// Module: HexBinary
|
||||||
//
|
//
|
||||||
// Definition of the HexBinaryDecoder class.
|
// Definition of the HexBinaryDecoder 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_HexBinaryDecoder_INCLUDED
|
#ifndef Foundation_HexBinaryDecoder_INCLUDED
|
||||||
#define Foundation_HexBinaryDecoder_INCLUDED
|
#define Foundation_HexBinaryDecoder_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/UnbufferedStreamBuf.h"
|
#include "Poco/UnbufferedStreamBuf.h"
|
||||||
#include <istream>
|
#include <istream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API HexBinaryDecoderBuf: public UnbufferedStreamBuf
|
class Foundation_API HexBinaryDecoderBuf: public UnbufferedStreamBuf
|
||||||
/// This streambuf decodes all hexBinary-encoded data read
|
/// This streambuf decodes all hexBinary-encoded data read
|
||||||
/// from the istream connected to it.
|
/// from the istream connected to it.
|
||||||
/// In hexBinary encoding, each binary octet is encoded as a character tuple,
|
/// In hexBinary encoding, each binary octet is encoded as a character tuple,
|
||||||
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
||||||
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
||||||
/// section 3.2.15.
|
/// section 3.2.15.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HexBinaryDecoderBuf(std::istream& istr);
|
HexBinaryDecoderBuf(std::istream& istr);
|
||||||
~HexBinaryDecoderBuf();
|
~HexBinaryDecoderBuf();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int readFromDevice();
|
int readFromDevice();
|
||||||
int readOne();
|
int readOne();
|
||||||
|
|
||||||
std::istream& _istr;
|
std::istream& _istr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API HexBinaryDecoderIOS: public virtual std::ios
|
class Foundation_API HexBinaryDecoderIOS: public virtual std::ios
|
||||||
/// The base class for HexBinaryDecoder.
|
/// The base class for HexBinaryDecoder.
|
||||||
///
|
///
|
||||||
/// This class is needed to ensure the correct initialization
|
/// This class is needed to ensure the correct initialization
|
||||||
/// order of the stream buffer and base classes.
|
/// order of the stream buffer and base classes.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HexBinaryDecoderIOS(std::istream& istr);
|
HexBinaryDecoderIOS(std::istream& istr);
|
||||||
~HexBinaryDecoderIOS();
|
~HexBinaryDecoderIOS();
|
||||||
HexBinaryDecoderBuf* rdbuf();
|
HexBinaryDecoderBuf* rdbuf();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HexBinaryDecoderBuf _buf;
|
HexBinaryDecoderBuf _buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API HexBinaryDecoder: public HexBinaryDecoderIOS, public std::istream
|
class Foundation_API HexBinaryDecoder: public HexBinaryDecoderIOS, public std::istream
|
||||||
/// This istream decodes all hexBinary-encoded data read
|
/// This istream decodes all hexBinary-encoded data read
|
||||||
/// from the istream connected to it.
|
/// from the istream connected to it.
|
||||||
/// In hexBinary encoding, each binary octet is encoded as a character tuple,
|
/// In hexBinary encoding, each binary octet is encoded as a character tuple,
|
||||||
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
||||||
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
||||||
/// section 3.2.15.
|
/// section 3.2.15.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HexBinaryDecoder(std::istream& istr);
|
HexBinaryDecoder(std::istream& istr);
|
||||||
~HexBinaryDecoder();
|
~HexBinaryDecoder();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_HexBinaryDecoder_INCLUDED
|
#endif // Foundation_HexBinaryDecoder_INCLUDED
|
||||||
|
|||||||
@@ -1,129 +1,129 @@
|
|||||||
//
|
//
|
||||||
// HexBinaryEncoder.h
|
// HexBinaryEncoder.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/HexBinaryEncoder.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/HexBinaryEncoder.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: HexBinary
|
// Module: HexBinary
|
||||||
//
|
//
|
||||||
// Definition of the HexBinaryEncoder class.
|
// Definition of the HexBinaryEncoder 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_HexBinaryEncoder_INCLUDED
|
#ifndef Foundation_HexBinaryEncoder_INCLUDED
|
||||||
#define Foundation_HexBinaryEncoder_INCLUDED
|
#define Foundation_HexBinaryEncoder_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/UnbufferedStreamBuf.h"
|
#include "Poco/UnbufferedStreamBuf.h"
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API HexBinaryEncoderBuf: public UnbufferedStreamBuf
|
class Foundation_API HexBinaryEncoderBuf: public UnbufferedStreamBuf
|
||||||
/// This streambuf encodes all data written
|
/// This streambuf encodes all data written
|
||||||
/// to it in hexBinary encoding and forwards it to a connected
|
/// to it in hexBinary encoding and forwards it to a connected
|
||||||
/// ostream.
|
/// ostream.
|
||||||
/// In hexBinary encoding, each binary octet is encoded as a character tuple,
|
/// In hexBinary encoding, each binary octet is encoded as a character tuple,
|
||||||
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
||||||
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
||||||
/// section 3.2.15.
|
/// section 3.2.15.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HexBinaryEncoderBuf(std::ostream& ostr);
|
HexBinaryEncoderBuf(std::ostream& ostr);
|
||||||
~HexBinaryEncoderBuf();
|
~HexBinaryEncoderBuf();
|
||||||
|
|
||||||
int close();
|
int close();
|
||||||
/// Closes the stream buffer.
|
/// Closes the stream buffer.
|
||||||
|
|
||||||
void setLineLength(int lineLength);
|
void setLineLength(int lineLength);
|
||||||
/// Specify the line length.
|
/// Specify the line length.
|
||||||
///
|
///
|
||||||
/// After the given number of characters have been written,
|
/// After the given number of characters have been written,
|
||||||
/// a newline character will be written.
|
/// a newline character will be written.
|
||||||
///
|
///
|
||||||
/// Specify 0 for an unlimited line length.
|
/// Specify 0 for an unlimited line length.
|
||||||
|
|
||||||
int getLineLength() const;
|
int getLineLength() const;
|
||||||
/// Returns the currently set line length.
|
/// Returns the currently set line length.
|
||||||
|
|
||||||
void setUppercase(bool flag = true);
|
void setUppercase(bool flag = true);
|
||||||
/// Specify whether hex digits a-f are written in upper or lower case.
|
/// Specify whether hex digits a-f are written in upper or lower case.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int writeToDevice(char c);
|
int writeToDevice(char c);
|
||||||
|
|
||||||
int _pos;
|
int _pos;
|
||||||
int _lineLength;
|
int _lineLength;
|
||||||
int _uppercase;
|
int _uppercase;
|
||||||
std::ostream& _ostr;
|
std::ostream& _ostr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API HexBinaryEncoderIOS: public virtual std::ios
|
class Foundation_API HexBinaryEncoderIOS: public virtual std::ios
|
||||||
/// The base class for HexBinaryEncoder.
|
/// The base class for HexBinaryEncoder.
|
||||||
///
|
///
|
||||||
/// This class is needed to ensure the correct initialization
|
/// This class is needed to ensure the correct initialization
|
||||||
/// order of the stream buffer and base classes.
|
/// order of the stream buffer and base classes.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HexBinaryEncoderIOS(std::ostream& ostr);
|
HexBinaryEncoderIOS(std::ostream& ostr);
|
||||||
~HexBinaryEncoderIOS();
|
~HexBinaryEncoderIOS();
|
||||||
int close();
|
int close();
|
||||||
HexBinaryEncoderBuf* rdbuf();
|
HexBinaryEncoderBuf* rdbuf();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
HexBinaryEncoderBuf _buf;
|
HexBinaryEncoderBuf _buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API HexBinaryEncoder: public HexBinaryEncoderIOS, public std::ostream
|
class Foundation_API HexBinaryEncoder: public HexBinaryEncoderIOS, public std::ostream
|
||||||
/// This ostream encodes all data
|
/// This ostream encodes all data
|
||||||
/// written to it in BinHex encoding and forwards it to
|
/// written to it in BinHex encoding and forwards it to
|
||||||
/// a connected ostream.
|
/// a connected ostream.
|
||||||
/// Always call close() when done
|
/// Always call close() when done
|
||||||
/// writing data, to ensure proper
|
/// writing data, to ensure proper
|
||||||
/// completion of the encoding operation.
|
/// completion of the encoding operation.
|
||||||
/// In hexBinary encoding, each binary octet is encoded as a character tuple,
|
/// In hexBinary encoding, each binary octet is encoded as a character tuple,
|
||||||
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
/// consisting of two hexadecimal digits ([0-9a-fA-F]) representing the octet code.
|
||||||
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
/// See also: XML Schema Part 2: Datatypes (http://www.w3.org/TR/xmlschema-2/),
|
||||||
/// section 3.2.15.
|
/// section 3.2.15.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
HexBinaryEncoder(std::ostream& ostr);
|
HexBinaryEncoder(std::ostream& ostr);
|
||||||
~HexBinaryEncoder();
|
~HexBinaryEncoder();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_HexBinaryEncoder_INCLUDED
|
#endif // Foundation_HexBinaryEncoder_INCLUDED
|
||||||
|
|||||||
@@ -1,141 +1,141 @@
|
|||||||
//
|
//
|
||||||
// InflatingStream.h
|
// InflatingStream.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/InflatingStream.h#2 $
|
// $Id: //poco/1.3/Foundation/include/Poco/InflatingStream.h#2 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Streams
|
// Package: Streams
|
||||||
// Module: ZLibStream
|
// Module: ZLibStream
|
||||||
//
|
//
|
||||||
// Definition of the InflatingInputStream and InflatingOutputStream classes.
|
// Definition of the InflatingInputStream and InflatingOutputStream classes.
|
||||||
//
|
//
|
||||||
// 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_InflatingStream_INCLUDED
|
#ifndef Foundation_InflatingStream_INCLUDED
|
||||||
#define Foundation_InflatingStream_INCLUDED
|
#define Foundation_InflatingStream_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
#include "Poco/BufferedStreamBuf.h"
|
#include "Poco/BufferedStreamBuf.h"
|
||||||
#include <istream>
|
#include <istream>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
#include "Poco/zlib.h"
|
#include "Poco/zlib.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API InflatingStreamBuf: public BufferedStreamBuf
|
class Foundation_API InflatingStreamBuf: public BufferedStreamBuf
|
||||||
/// This is the streambuf class used by InflatingInputStream and InflatingOutputStream.
|
/// This is the streambuf class used by InflatingInputStream and InflatingOutputStream.
|
||||||
/// The actual work is delegated to zlib 1.2.1 (see http://www.gzip.org).
|
/// The actual work is delegated to zlib 1.2.1 (see http://www.gzip.org).
|
||||||
/// Both zlib (deflate) streams and gzip streams are supported.
|
/// Both zlib (deflate) streams and gzip streams are supported.
|
||||||
/// Output streams should always call close() to ensure
|
/// Output streams should always call close() to ensure
|
||||||
/// proper completion of decompression.
|
/// proper completion of decompression.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
enum StreamType
|
enum StreamType
|
||||||
{
|
{
|
||||||
STREAM_ZLIB,
|
STREAM_ZLIB,
|
||||||
STREAM_GZIP,
|
STREAM_GZIP,
|
||||||
STREAM_ZIP // ZIP is handled as STREAM_ZLIB, except that we do not check the ADLER32 value (must be checked by an outside class!)
|
STREAM_ZIP // ZIP is handled as STREAM_ZLIB, except that we do not check the ADLER32 value (must be checked by an outside class!)
|
||||||
};
|
};
|
||||||
|
|
||||||
InflatingStreamBuf(std::istream& istr, StreamType type);
|
InflatingStreamBuf(std::istream& istr, StreamType type);
|
||||||
InflatingStreamBuf(std::ostream& ostr, StreamType type);
|
InflatingStreamBuf(std::ostream& ostr, StreamType type);
|
||||||
~InflatingStreamBuf();
|
~InflatingStreamBuf();
|
||||||
int close();
|
int close();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
int readFromDevice(char* buffer, std::streamsize length);
|
int readFromDevice(char* buffer, std::streamsize length);
|
||||||
int writeToDevice(const char* buffer, std::streamsize length);
|
int writeToDevice(const char* buffer, std::streamsize length);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
STREAM_BUFFER_SIZE = 1024,
|
STREAM_BUFFER_SIZE = 1024,
|
||||||
INFLATE_BUFFER_SIZE = 32768
|
INFLATE_BUFFER_SIZE = 32768
|
||||||
};
|
};
|
||||||
|
|
||||||
std::istream* _pIstr;
|
std::istream* _pIstr;
|
||||||
std::ostream* _pOstr;
|
std::ostream* _pOstr;
|
||||||
char* _buffer;
|
char* _buffer;
|
||||||
z_stream _zstr;
|
z_stream _zstr;
|
||||||
bool _eof;
|
bool _eof;
|
||||||
bool _check;
|
bool _check;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API InflatingIOS: public virtual std::ios
|
class Foundation_API InflatingIOS: public virtual std::ios
|
||||||
/// The base class for InflatingOutputStream and InflatingInputStream.
|
/// The base class for InflatingOutputStream and InflatingInputStream.
|
||||||
///
|
///
|
||||||
/// This class is needed to ensure the correct initialization
|
/// This class is needed to ensure the correct initialization
|
||||||
/// order of the stream buffer and base classes.
|
/// order of the stream buffer and base classes.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InflatingIOS(std::ostream& ostr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB);
|
InflatingIOS(std::ostream& ostr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB);
|
||||||
InflatingIOS(std::istream& istr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB);
|
InflatingIOS(std::istream& istr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB);
|
||||||
~InflatingIOS();
|
~InflatingIOS();
|
||||||
InflatingStreamBuf* rdbuf();
|
InflatingStreamBuf* rdbuf();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
InflatingStreamBuf _buf;
|
InflatingStreamBuf _buf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API InflatingOutputStream: public InflatingIOS, public std::ostream
|
class Foundation_API InflatingOutputStream: public InflatingIOS, public std::ostream
|
||||||
/// This stream decompresses all data passing through it
|
/// This stream decompresses all data passing through it
|
||||||
/// using zlib's inflate algorithm.
|
/// using zlib's inflate algorithm.
|
||||||
/// After all data has been written to the stream, close()
|
/// After all data has been written to the stream, close()
|
||||||
/// must be called to ensure completion of decompression.
|
/// must be called to ensure completion of decompression.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InflatingOutputStream(std::ostream& ostr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB);
|
InflatingOutputStream(std::ostream& ostr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB);
|
||||||
~InflatingOutputStream();
|
~InflatingOutputStream();
|
||||||
int close();
|
int close();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
class Foundation_API InflatingInputStream: public InflatingIOS, public std::istream
|
class Foundation_API InflatingInputStream: public InflatingIOS, public std::istream
|
||||||
/// This stream decompresses all data passing through it
|
/// This stream decompresses all data passing through it
|
||||||
/// using zlib's inflate algorithm.
|
/// using zlib's inflate algorithm.
|
||||||
/// Example:
|
/// Example:
|
||||||
/// std::ifstream istr("data.gz", std::ios::binary);
|
/// std::ifstream istr("data.gz", std::ios::binary);
|
||||||
/// InflatingInputStream inflater(istr, InflatingStreamBuf::STREAM_GZIP);
|
/// InflatingInputStream inflater(istr, InflatingStreamBuf::STREAM_GZIP);
|
||||||
/// std::string data;
|
/// std::string data;
|
||||||
/// istr >> data;
|
/// istr >> data;
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
InflatingInputStream(std::istream& istr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB);
|
InflatingInputStream(std::istream& istr, InflatingStreamBuf::StreamType type = InflatingStreamBuf::STREAM_ZLIB);
|
||||||
~InflatingInputStream();
|
~InflatingInputStream();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_InflatingStream_INCLUDED
|
#endif // Foundation_InflatingStream_INCLUDED
|
||||||
|
|||||||
@@ -1,104 +1,104 @@
|
|||||||
//
|
//
|
||||||
// Instantiator.h
|
// Instantiator.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/Instantiator.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/Instantiator.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Core
|
// Package: Core
|
||||||
// Module: Instantiator
|
// Module: Instantiator
|
||||||
//
|
//
|
||||||
// Definition of the Instantiator class.
|
// Definition of the Instantiator 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_Instantiator_INCLUDED
|
#ifndef Foundation_Instantiator_INCLUDED
|
||||||
#define Foundation_Instantiator_INCLUDED
|
#define Foundation_Instantiator_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class Base>
|
template <class Base>
|
||||||
class AbstractInstantiator
|
class AbstractInstantiator
|
||||||
/// The common base class for all Instantiator instantiations.
|
/// The common base class for all Instantiator instantiations.
|
||||||
/// Used by DynamicFactory.
|
/// Used by DynamicFactory.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AbstractInstantiator()
|
AbstractInstantiator()
|
||||||
/// Creates the AbstractInstantiator.
|
/// Creates the AbstractInstantiator.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~AbstractInstantiator()
|
virtual ~AbstractInstantiator()
|
||||||
/// Destroys the AbstractInstantiator.
|
/// Destroys the AbstractInstantiator.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual Base* createInstance() const = 0;
|
virtual Base* createInstance() const = 0;
|
||||||
/// Creates an instance of a concrete subclass of Base.
|
/// Creates an instance of a concrete subclass of Base.
|
||||||
|
|
||||||
private:
|
private:
|
||||||
AbstractInstantiator(const AbstractInstantiator&);
|
AbstractInstantiator(const AbstractInstantiator&);
|
||||||
AbstractInstantiator& operator = (const AbstractInstantiator&);
|
AbstractInstantiator& operator = (const AbstractInstantiator&);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
template <class C, class Base>
|
template <class C, class Base>
|
||||||
class Instantiator: public AbstractInstantiator<Base>
|
class Instantiator: public AbstractInstantiator<Base>
|
||||||
/// A template class for the easy instantiation of
|
/// A template class for the easy instantiation of
|
||||||
/// instantiators.
|
/// instantiators.
|
||||||
///
|
///
|
||||||
/// For the Instantiator to work, the class of which
|
/// For the Instantiator to work, the class of which
|
||||||
/// instances are to be instantiated must have a no-argument
|
/// instances are to be instantiated must have a no-argument
|
||||||
/// constructor.
|
/// constructor.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Instantiator()
|
Instantiator()
|
||||||
/// Creates the Instantiator.
|
/// Creates the Instantiator.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual ~Instantiator()
|
virtual ~Instantiator()
|
||||||
/// Destroys the Instantiator.
|
/// Destroys the Instantiator.
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
Base* createInstance() const
|
Base* createInstance() const
|
||||||
{
|
{
|
||||||
return new C;
|
return new C;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif // Foundation_Instantiator_INCLUDED
|
#endif // Foundation_Instantiator_INCLUDED
|
||||||
|
|||||||
@@ -1,95 +1,95 @@
|
|||||||
//
|
//
|
||||||
// KeyValueArgs.h
|
// KeyValueArgs.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/KeyValueArgs.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/KeyValueArgs.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
// Module: KeyValueArgs
|
// Module: KeyValueArgs
|
||||||
//
|
//
|
||||||
// Definition of the KeyValueArgs class.
|
// Definition of the KeyValueArgs 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 Foundation_KeyValueArgs_INCLUDED
|
#ifndef Foundation_KeyValueArgs_INCLUDED
|
||||||
#define Foundation_KeyValueArgs_INCLUDED
|
#define Foundation_KeyValueArgs_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/Foundation.h"
|
#include "Poco/Foundation.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TKey, class TValue>
|
template <class TKey, class TValue>
|
||||||
class KeyValueArgs
|
class KeyValueArgs
|
||||||
/// Simply event arguments class to transfer a key and a value via an event call.
|
/// Simply event arguments class to transfer a key and a value via an event call.
|
||||||
/// Note that key and value are *NOT* copied, only references to them are stored.
|
/// Note that key and value are *NOT* copied, only references to them are stored.
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
KeyValueArgs(const TKey& aKey, const TValue& aVal):
|
KeyValueArgs(const TKey& aKey, const TValue& aVal):
|
||||||
_key(aKey),
|
_key(aKey),
|
||||||
_value(aVal)
|
_value(aVal)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
KeyValueArgs(const KeyValueArgs& args):
|
KeyValueArgs(const KeyValueArgs& args):
|
||||||
_key(args._key),
|
_key(args._key),
|
||||||
_value(args._value)
|
_value(args._value)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~KeyValueArgs()
|
~KeyValueArgs()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
const TKey& key() const
|
const TKey& key() const
|
||||||
/// Returns a reference to the key,
|
/// Returns a reference to the key,
|
||||||
{
|
{
|
||||||
return _key;
|
return _key;
|
||||||
}
|
}
|
||||||
|
|
||||||
const TValue& value() const
|
const TValue& value() const
|
||||||
/// Returns a Reference to the value.
|
/// Returns a Reference to the value.
|
||||||
{
|
{
|
||||||
return _value;
|
return _value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
const TKey& _key;
|
const TKey& _key;
|
||||||
const TValue& _value;
|
const TValue& _value;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
KeyValueArgs& operator = (const KeyValueArgs& args);
|
KeyValueArgs& operator = (const KeyValueArgs& args);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -1,73 +1,73 @@
|
|||||||
//
|
//
|
||||||
// LRUCache.h
|
// LRUCache.h
|
||||||
//
|
//
|
||||||
// $Id: //poco/1.3/Foundation/include/Poco/LRUCache.h#1 $
|
// $Id: //poco/1.3/Foundation/include/Poco/LRUCache.h#1 $
|
||||||
//
|
//
|
||||||
// Library: Foundation
|
// Library: Foundation
|
||||||
// Package: Cache
|
// Package: Cache
|
||||||
// Module: LRUCache
|
// Module: LRUCache
|
||||||
//
|
//
|
||||||
// Definition of the LRUCache class.
|
// Definition of the LRUCache 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 Foundation_LRUCache_INCLUDED
|
#ifndef Foundation_LRUCache_INCLUDED
|
||||||
#define Foundation_LRUCache_INCLUDED
|
#define Foundation_LRUCache_INCLUDED
|
||||||
|
|
||||||
|
|
||||||
#include "Poco/AbstractCache.h"
|
#include "Poco/AbstractCache.h"
|
||||||
#include "Poco/LRUStrategy.h"
|
#include "Poco/LRUStrategy.h"
|
||||||
|
|
||||||
|
|
||||||
namespace Poco {
|
namespace Poco {
|
||||||
|
|
||||||
|
|
||||||
template <class TKey, class TValue>
|
template <class TKey, class TValue>
|
||||||
class LRUCache: public AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >
|
class LRUCache: public AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >
|
||||||
/// An LRUCache implements Least Recently Used caching. The default size for a cache is 1024 entries
|
/// An LRUCache implements Least Recently Used caching. The default size for a cache is 1024 entries
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
LRUCache(long size = 1024):
|
LRUCache(long size = 1024):
|
||||||
AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >(LRUStrategy<TKey, TValue>(size))
|
AbstractCache<TKey, TValue, LRUStrategy<TKey, TValue> >(LRUStrategy<TKey, TValue>(size))
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~LRUCache()
|
~LRUCache()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LRUCache(const LRUCache& aCache);
|
LRUCache(const LRUCache& aCache);
|
||||||
LRUCache& operator = (const LRUCache& aCache);
|
LRUCache& operator = (const LRUCache& aCache);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
} // namespace Poco
|
} // namespace Poco
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user