set eol-style to native

This commit is contained in:
Guenter Obiltschnig
2006-10-23 16:21:00 +00:00
parent 201a0be588
commit 1ecd4a8a9e
126 changed files with 17218 additions and 17218 deletions

View File

@@ -1,23 +1,23 @@
# #
# Makefile # Makefile
# #
# $Id: //poco/1.2/Util/Makefile#1 $ # $Id: //poco/1.2/Util/Makefile#1 $
# #
# Makefile for Poco Util # Makefile for Poco Util
# #
include $(POCO_BASE)/build/rules/global include $(POCO_BASE)/build/rules/global
objects = AbstractConfiguration Application ConfigurationMapper \ objects = AbstractConfiguration Application ConfigurationMapper \
ConfigurationView HelpFormatter IniFileConfiguration LayeredConfiguration \ ConfigurationView HelpFormatter IniFileConfiguration LayeredConfiguration \
LoggingConfigurator LoggingSubsystem MapConfiguration \ LoggingConfigurator LoggingSubsystem MapConfiguration \
Option OptionException OptionProcessor OptionSet \ Option OptionException OptionProcessor OptionSet \
PropertyFileConfiguration Subsystem SystemConfiguration \ PropertyFileConfiguration Subsystem SystemConfiguration \
XMLConfiguration FilesystemConfiguration ServerApplication \ XMLConfiguration FilesystemConfiguration ServerApplication \
Validator IntValidator RegExpValidator OptionCallback Validator IntValidator RegExpValidator OptionCallback
target = PocoUtil target = PocoUtil
target_version = $(LIBVERSION) target_version = $(LIBVERSION)
target_libs = PocoFoundation PocoXML target_libs = PocoFoundation PocoXML
include $(POCO_BASE)/build/rules/lib include $(POCO_BASE)/build/rules/lib

View File

@@ -1,26 +1,26 @@
# #
# Util.vmsbuild # Util.vmsbuild
# #
# $Id: //poco/1.2/Util/Util.vmsbuild#1 $ # $Id: //poco/1.2/Util/Util.vmsbuild#1 $
# #
LIB=PocoUtil LIB=PocoUtil
AbstractConfiguration AbstractConfiguration
Application Application
ConfigurationMapper ConfigurationMapper
ConfigurationView ConfigurationView
HelpFormatter HelpFormatter
IniFileConfiguration IniFileConfiguration
LayeredConfiguration LayeredConfiguration
LoggingConfigurator LoggingConfigurator
LoggingSubsystem LoggingSubsystem
MapConfiguration MapConfiguration
Option Option
OptionException OptionException
OptionProcessor OptionProcessor
OptionSet OptionSet
PropertyFileConfiguration PropertyFileConfiguration
Subsystem Subsystem
SystemConfiguration SystemConfiguration
XMLConfiguration XMLConfiguration
FilesystemConfiguration FilesystemConfiguration
ServerApplication ServerApplication

View File

@@ -1,30 +1,30 @@
Microsoft Visual Studio Solution File, Format Version 8.00 Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Util", "Util_vs71.vcproj", "{6FF56CDB-787A-4714-A28C-919003F9FA6C}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Util", "Util_vs71.vcproj", "{6FF56CDB-787A-4714-A28C-919003F9FA6C}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs71.vcproj", "{E40E738C-447B-40F4-A878-EBA9A2459270}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs71.vcproj", "{E40E738C-447B-40F4-A878-EBA9A2459270}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{6FF56CDB-787A-4714-A28C-919003F9FA6C} = {6FF56CDB-787A-4714-A28C-919003F9FA6C} {6FF56CDB-787A-4714-A28C-919003F9FA6C} = {6FF56CDB-787A-4714-A28C-919003F9FA6C}
EndProjectSection EndProjectSection
EndProject EndProject
Global Global
GlobalSection(SolutionConfiguration) = preSolution GlobalSection(SolutionConfiguration) = preSolution
debug_shared = debug_shared debug_shared = debug_shared
release_shared = release_shared release_shared = release_shared
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution GlobalSection(ProjectConfiguration) = postSolution
{6FF56CDB-787A-4714-A28C-919003F9FA6C}.debug_shared.ActiveCfg = debug_shared|Win32 {6FF56CDB-787A-4714-A28C-919003F9FA6C}.debug_shared.ActiveCfg = debug_shared|Win32
{6FF56CDB-787A-4714-A28C-919003F9FA6C}.debug_shared.Build.0 = debug_shared|Win32 {6FF56CDB-787A-4714-A28C-919003F9FA6C}.debug_shared.Build.0 = debug_shared|Win32
{6FF56CDB-787A-4714-A28C-919003F9FA6C}.release_shared.ActiveCfg = release_shared|Win32 {6FF56CDB-787A-4714-A28C-919003F9FA6C}.release_shared.ActiveCfg = release_shared|Win32
{6FF56CDB-787A-4714-A28C-919003F9FA6C}.release_shared.Build.0 = release_shared|Win32 {6FF56CDB-787A-4714-A28C-919003F9FA6C}.release_shared.Build.0 = release_shared|Win32
{E40E738C-447B-40F4-A878-EBA9A2459270}.debug_shared.ActiveCfg = debug_shared|Win32 {E40E738C-447B-40F4-A878-EBA9A2459270}.debug_shared.ActiveCfg = debug_shared|Win32
{E40E738C-447B-40F4-A878-EBA9A2459270}.debug_shared.Build.0 = debug_shared|Win32 {E40E738C-447B-40F4-A878-EBA9A2459270}.debug_shared.Build.0 = debug_shared|Win32
{E40E738C-447B-40F4-A878-EBA9A2459270}.release_shared.ActiveCfg = release_shared|Win32 {E40E738C-447B-40F4-A878-EBA9A2459270}.release_shared.ActiveCfg = release_shared|Win32
{E40E738C-447B-40F4-A878-EBA9A2459270}.release_shared.Build.0 = release_shared|Win32 {E40E738C-447B-40F4-A878-EBA9A2459270}.release_shared.Build.0 = release_shared|Win32
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@@ -1,373 +1,373 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="7.10" Version="7.10"
Name="Util" Name="Util"
ProjectGUID="{6ff56cdb-787a-4714-a28c-919003f9fa6c}" ProjectGUID="{6ff56cdb-787a-4714-a28c-919003f9fa6c}"
RootNamespace="Util" RootNamespace="Util"
Keyword="Win32Proj"> Keyword="Win32Proj">
<Platforms> <Platforms>
<Platform <Platform
Name="Win32"/> Name="Win32"/>
</Platforms> </Platforms>
<Configurations> <Configurations>
<Configuration <Configuration
Name="debug_shared|Win32" Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared" OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared" IntermediateDirectory="obj\debug_shared"
ConfigurationType="2" ConfigurationType="2"
CharacterSet="2"> CharacterSet="2">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories=".\include;..\Foundation\include;..\XML\include" AdditionalIncludeDirectories=".\include;..\Foundation\include;..\XML\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;Util_EXPORTS" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;Util_EXPORTS"
StringPooling="TRUE" StringPooling="TRUE"
MinimalRebuild="TRUE" MinimalRebuild="TRUE"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
BufferSecurityCheck="TRUE" BufferSecurityCheck="TRUE"
TreatWChar_tAsBuiltInType="TRUE" TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE" ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE" RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4" DebugInformationFormat="4"
CompileAs="0"/> CompileAs="0"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib" AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib"
OutputFile="..\bin\PocoUtild.dll" OutputFile="..\bin\PocoUtild.dll"
LinkIncremental="2" LinkIncremental="2"
SuppressStartupBanner="TRUE" SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\lib" AdditionalLibraryDirectories="..\lib"
GenerateDebugInformation="TRUE" GenerateDebugInformation="TRUE"
ProgramDatabaseFile="..\bin\PocoUtild.pdb" ProgramDatabaseFile="..\bin\PocoUtild.pdb"
SubSystem="1" SubSystem="1"
OptimizeForWindows98="1" OptimizeForWindows98="1"
ImportLibrary="..\lib\PocoUtild.lib" ImportLibrary="..\lib\PocoUtild.lib"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
Name="VCPostBuildEventTool"/> Name="VCPostBuildEventTool"/>
<Tool <Tool
Name="VCPreBuildEventTool"/> Name="VCPreBuildEventTool"/>
<Tool <Tool
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool"/> Name="VCResourceCompilerTool"/>
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool"/> Name="VCWebServiceProxyGeneratorTool"/>
<Tool <Tool
Name="VCXMLDataGeneratorTool"/> Name="VCXMLDataGeneratorTool"/>
<Tool <Tool
Name="VCWebDeploymentTool"/> Name="VCWebDeploymentTool"/>
<Tool <Tool
Name="VCManagedWrapperGeneratorTool"/> Name="VCManagedWrapperGeneratorTool"/>
<Tool <Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration> </Configuration>
<Configuration <Configuration
Name="release_shared|Win32" Name="release_shared|Win32"
OutputDirectory="obj\release_shared" OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared" IntermediateDirectory="obj\release_shared"
ConfigurationType="2" ConfigurationType="2"
CharacterSet="2"> CharacterSet="2">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="4" Optimization="4"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
EnableIntrinsicFunctions="TRUE" EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="TRUE" OmitFramePointers="TRUE"
OptimizeForProcessor="3" OptimizeForProcessor="3"
AdditionalIncludeDirectories=".\include;..\Foundation\include;..\XML\include" AdditionalIncludeDirectories=".\include;..\Foundation\include;..\XML\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;Util_EXPORTS" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;Util_EXPORTS"
GeneratePreprocessedFile="0" GeneratePreprocessedFile="0"
KeepComments="FALSE" KeepComments="FALSE"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="2" RuntimeLibrary="2"
BufferSecurityCheck="FALSE" BufferSecurityCheck="FALSE"
TreatWChar_tAsBuiltInType="TRUE" TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE" ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE" RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="0" DebugInformationFormat="0"
CompileAs="0"/> CompileAs="0"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib" AdditionalDependencies="PocoFoundation.lib PocoXML.lib"
OutputFile="..\bin\PocoUtil.dll" OutputFile="..\bin\PocoUtil.dll"
LinkIncremental="1" LinkIncremental="1"
SuppressStartupBanner="TRUE" SuppressStartupBanner="TRUE"
AdditionalLibraryDirectories="..\lib" AdditionalLibraryDirectories="..\lib"
GenerateDebugInformation="FALSE" GenerateDebugInformation="FALSE"
ProgramDatabaseFile="" ProgramDatabaseFile=""
SubSystem="1" SubSystem="1"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
OptimizeForWindows98="1" OptimizeForWindows98="1"
ImportLibrary="..\lib\PocoUtil.lib" ImportLibrary="..\lib\PocoUtil.lib"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
Name="VCPostBuildEventTool"/> Name="VCPostBuildEventTool"/>
<Tool <Tool
Name="VCPreBuildEventTool"/> Name="VCPreBuildEventTool"/>
<Tool <Tool
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool"/> Name="VCResourceCompilerTool"/>
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool"/> Name="VCWebServiceProxyGeneratorTool"/>
<Tool <Tool
Name="VCXMLDataGeneratorTool"/> Name="VCXMLDataGeneratorTool"/>
<Tool <Tool
Name="VCWebDeploymentTool"/> Name="VCWebDeploymentTool"/>
<Tool <Tool
Name="VCManagedWrapperGeneratorTool"/> Name="VCManagedWrapperGeneratorTool"/>
<Tool <Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration> </Configuration>
</Configurations> </Configurations>
<References> <References>
</References> </References>
<Files> <Files>
<Filter <Filter
Name="Application" Name="Application"
Filter=""> Filter="">
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter=""> Filter="">
<File <File
RelativePath=".\include\Poco\Util\Application.h"> RelativePath=".\include\Poco\Util\Application.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\LoggingSubsystem.h"> RelativePath=".\include\Poco\Util\LoggingSubsystem.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\ServerApplication.h"> RelativePath=".\include\Poco\Util\ServerApplication.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\Subsystem.h"> RelativePath=".\include\Poco\Util\Subsystem.h">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\Application.cpp"> RelativePath=".\src\Application.cpp">
</File> </File>
<File <File
RelativePath=".\src\LoggingSubsystem.cpp"> RelativePath=".\src\LoggingSubsystem.cpp">
</File> </File>
<File <File
RelativePath=".\src\ServerApplication.cpp"> RelativePath=".\src\ServerApplication.cpp">
</File> </File>
<File <File
RelativePath=".\src\Subsystem.cpp"> RelativePath=".\src\Subsystem.cpp">
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Configuration" Name="Configuration"
Filter=""> Filter="">
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter=""> Filter="">
<File <File
RelativePath=".\include\Poco\Util\AbstractConfiguration.h"> RelativePath=".\include\Poco\Util\AbstractConfiguration.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\ConfigurationMapper.h"> RelativePath=".\include\Poco\Util\ConfigurationMapper.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\ConfigurationView.h"> RelativePath=".\include\Poco\Util\ConfigurationView.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\FilesystemConfiguration.h"> RelativePath=".\include\Poco\Util\FilesystemConfiguration.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\IniFileConfiguration.h"> RelativePath=".\include\Poco\Util\IniFileConfiguration.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\LayeredConfiguration.h"> RelativePath=".\include\Poco\Util\LayeredConfiguration.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\LoggingConfigurator.h"> RelativePath=".\include\Poco\Util\LoggingConfigurator.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\MapConfiguration.h"> RelativePath=".\include\Poco\Util\MapConfiguration.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\PropertyFileConfiguration.h"> RelativePath=".\include\Poco\Util\PropertyFileConfiguration.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\SystemConfiguration.h"> RelativePath=".\include\Poco\Util\SystemConfiguration.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\XMLConfiguration.h"> RelativePath=".\include\Poco\Util\XMLConfiguration.h">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\AbstractConfiguration.cpp"> RelativePath=".\src\AbstractConfiguration.cpp">
</File> </File>
<File <File
RelativePath=".\src\ConfigurationMapper.cpp"> RelativePath=".\src\ConfigurationMapper.cpp">
</File> </File>
<File <File
RelativePath=".\src\ConfigurationView.cpp"> RelativePath=".\src\ConfigurationView.cpp">
</File> </File>
<File <File
RelativePath=".\src\FilesystemConfiguration.cpp"> RelativePath=".\src\FilesystemConfiguration.cpp">
</File> </File>
<File <File
RelativePath=".\src\IniFileConfiguration.cpp"> RelativePath=".\src\IniFileConfiguration.cpp">
</File> </File>
<File <File
RelativePath=".\src\LayeredConfiguration.cpp"> RelativePath=".\src\LayeredConfiguration.cpp">
</File> </File>
<File <File
RelativePath=".\src\LoggingConfigurator.cpp"> RelativePath=".\src\LoggingConfigurator.cpp">
</File> </File>
<File <File
RelativePath=".\src\MapConfiguration.cpp"> RelativePath=".\src\MapConfiguration.cpp">
</File> </File>
<File <File
RelativePath=".\src\PropertyFileConfiguration.cpp"> RelativePath=".\src\PropertyFileConfiguration.cpp">
</File> </File>
<File <File
RelativePath=".\src\SystemConfiguration.cpp"> RelativePath=".\src\SystemConfiguration.cpp">
</File> </File>
<File <File
RelativePath=".\src\XMLConfiguration.cpp"> RelativePath=".\src\XMLConfiguration.cpp">
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Options" Name="Options"
Filter=""> Filter="">
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter=""> Filter="">
<File <File
RelativePath=".\include\Poco\Util\HelpFormatter.h"> RelativePath=".\include\Poco\Util\HelpFormatter.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\IntValidator.h"> RelativePath=".\include\Poco\Util\IntValidator.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\Option.h"> RelativePath=".\include\Poco\Util\Option.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\OptionCallback.h"> RelativePath=".\include\Poco\Util\OptionCallback.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\OptionException.h"> RelativePath=".\include\Poco\Util\OptionException.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\OptionProcessor.h"> RelativePath=".\include\Poco\Util\OptionProcessor.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\OptionSet.h"> RelativePath=".\include\Poco\Util\OptionSet.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\RegExpValidator.h"> RelativePath=".\include\Poco\Util\RegExpValidator.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\Validator.h"> RelativePath=".\include\Poco\Util\Validator.h">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\HelpFormatter.cpp"> RelativePath=".\src\HelpFormatter.cpp">
</File> </File>
<File <File
RelativePath=".\src\IntValidator.cpp"> RelativePath=".\src\IntValidator.cpp">
</File> </File>
<File <File
RelativePath=".\src\Option.cpp"> RelativePath=".\src\Option.cpp">
</File> </File>
<File <File
RelativePath=".\src\OptionCallback.cpp"> RelativePath=".\src\OptionCallback.cpp">
</File> </File>
<File <File
RelativePath=".\src\OptionException.cpp"> RelativePath=".\src\OptionException.cpp">
</File> </File>
<File <File
RelativePath=".\src\OptionProcessor.cpp"> RelativePath=".\src\OptionProcessor.cpp">
</File> </File>
<File <File
RelativePath=".\src\OptionSet.cpp"> RelativePath=".\src\OptionSet.cpp">
</File> </File>
<File <File
RelativePath=".\src\RegExpValidator.cpp"> RelativePath=".\src\RegExpValidator.cpp">
</File> </File>
<File <File
RelativePath=".\src\Validator.cpp"> RelativePath=".\src\Validator.cpp">
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Windows" Name="Windows"
Filter=""> Filter="">
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter=""> Filter="">
<File <File
RelativePath=".\include\Poco\Util\WinRegistryConfiguration.h"> RelativePath=".\include\Poco\Util\WinRegistryConfiguration.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\WinRegistryKey.h"> RelativePath=".\include\Poco\Util\WinRegistryKey.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\WinService.h"> RelativePath=".\include\Poco\Util\WinService.h">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\WinRegistryConfiguration.cpp"> RelativePath=".\src\WinRegistryConfiguration.cpp">
</File> </File>
<File <File
RelativePath=".\src\WinRegistryKey.cpp"> RelativePath=".\src\WinRegistryKey.cpp">
</File> </File>
<File <File
RelativePath=".\src\WinService.cpp"> RelativePath=".\src\WinService.cpp">
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Util" Name="Util"
Filter=""> Filter="">
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter=""> Filter="">
<File <File
RelativePath=".\include\Poco\Util\Util.h"> RelativePath=".\include\Poco\Util\Util.h">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
</Filter> </Filter>
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
</VisualStudioProject> </VisualStudioProject>

View File

@@ -1,28 +1,28 @@
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}") = "Util", "Util_vs80.vcproj", "{6FF56CDB-787A-4714-A28C-919003F9FA6C}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Util", "Util_vs80.vcproj", "{6FF56CDB-787A-4714-A28C-919003F9FA6C}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs80.vcproj", "{E40E738C-447B-40F4-A878-EBA9A2459270}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TestSuite", "testsuite\TestSuite_vs80.vcproj", "{E40E738C-447B-40F4-A878-EBA9A2459270}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
{6FF56CDB-787A-4714-A28C-919003F9FA6C} = {6FF56CDB-787A-4714-A28C-919003F9FA6C} {6FF56CDB-787A-4714-A28C-919003F9FA6C} = {6FF56CDB-787A-4714-A28C-919003F9FA6C}
EndProjectSection EndProjectSection
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
debug_shared|Win32 = debug_shared|Win32 debug_shared|Win32 = debug_shared|Win32
release_shared|Win32 = release_shared|Win32 release_shared|Win32 = release_shared|Win32
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6FF56CDB-787A-4714-A28C-919003F9FA6C}.debug_shared|Win32.ActiveCfg = debug_shared|Win32 {6FF56CDB-787A-4714-A28C-919003F9FA6C}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{6FF56CDB-787A-4714-A28C-919003F9FA6C}.debug_shared|Win32.Build.0 = debug_shared|Win32 {6FF56CDB-787A-4714-A28C-919003F9FA6C}.debug_shared|Win32.Build.0 = debug_shared|Win32
{6FF56CDB-787A-4714-A28C-919003F9FA6C}.release_shared|Win32.ActiveCfg = release_shared|Win32 {6FF56CDB-787A-4714-A28C-919003F9FA6C}.release_shared|Win32.ActiveCfg = release_shared|Win32
{6FF56CDB-787A-4714-A28C-919003F9FA6C}.release_shared|Win32.Build.0 = release_shared|Win32 {6FF56CDB-787A-4714-A28C-919003F9FA6C}.release_shared|Win32.Build.0 = release_shared|Win32
{E40E738C-447B-40F4-A878-EBA9A2459270}.debug_shared|Win32.ActiveCfg = debug_shared|Win32 {E40E738C-447B-40F4-A878-EBA9A2459270}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{E40E738C-447B-40F4-A878-EBA9A2459270}.debug_shared|Win32.Build.0 = debug_shared|Win32 {E40E738C-447B-40F4-A878-EBA9A2459270}.debug_shared|Win32.Build.0 = debug_shared|Win32
{E40E738C-447B-40F4-A878-EBA9A2459270}.release_shared|Win32.ActiveCfg = release_shared|Win32 {E40E738C-447B-40F4-A878-EBA9A2459270}.release_shared|Win32.ActiveCfg = release_shared|Win32
{E40E738C-447B-40F4-A878-EBA9A2459270}.release_shared|Win32.Build.0 = release_shared|Win32 {E40E738C-447B-40F4-A878-EBA9A2459270}.release_shared|Win32.Build.0 = release_shared|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@@ -1,491 +1,491 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8.00" Version="8.00"
Name="Util" Name="Util"
ProjectGUID="{6FF56CDB-787A-4714-A28C-919003F9FA6C}" ProjectGUID="{6FF56CDB-787A-4714-A28C-919003F9FA6C}"
RootNamespace="Util" RootNamespace="Util"
Keyword="Win32Proj" Keyword="Win32Proj"
> >
<Platforms> <Platforms>
<Platform <Platform
Name="Win32" Name="Win32"
/> />
</Platforms> </Platforms>
<ToolFiles> <ToolFiles>
</ToolFiles> </ToolFiles>
<Configurations> <Configurations>
<Configuration <Configuration
Name="debug_shared|Win32" Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared" OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared" IntermediateDirectory="obj\debug_shared"
ConfigurationType="2" ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2" CharacterSet="2"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
/> />
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
/> />
<Tool <Tool
Name="VCXMLDataGeneratorTool" Name="VCXMLDataGeneratorTool"
/> />
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool" Name="VCWebServiceProxyGeneratorTool"
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
/> />
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories=".\include;..\Foundation\include;..\XML\include" AdditionalIncludeDirectories=".\include;..\Foundation\include;..\XML\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;Util_EXPORTS" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;POCO_DLL;Util_EXPORTS"
StringPooling="true" StringPooling="true"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
BufferSecurityCheck="true" BufferSecurityCheck="true"
TreatWChar_tAsBuiltInType="true" TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true" ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true" RuntimeTypeInfo="true"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="true" Detect64BitPortabilityProblems="true"
DebugInformationFormat="4" DebugInformationFormat="4"
CompileAs="0" CompileAs="0"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
/> />
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib" AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib"
OutputFile="..\bin\PocoUtild.dll" OutputFile="..\bin\PocoUtild.dll"
LinkIncremental="2" LinkIncremental="2"
SuppressStartupBanner="true" SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\lib" AdditionalLibraryDirectories="..\lib"
GenerateDebugInformation="true" GenerateDebugInformation="true"
ProgramDatabaseFile="..\bin\PocoUtild.pdb" ProgramDatabaseFile="..\bin\PocoUtild.pdb"
SubSystem="1" SubSystem="1"
OptimizeForWindows98="1" OptimizeForWindows98="1"
ImportLibrary="..\lib\PocoUtild.lib" ImportLibrary="..\lib\PocoUtild.lib"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
/> />
<Tool <Tool
Name="VCManifestTool" Name="VCManifestTool"
/> />
<Tool <Tool
Name="VCXDCMakeTool" Name="VCXDCMakeTool"
/> />
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
/> />
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
/> />
<Tool <Tool
Name="VCWebDeploymentTool" Name="VCWebDeploymentTool"
/> />
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
<Configuration <Configuration
Name="release_shared|Win32" Name="release_shared|Win32"
OutputDirectory="obj\release_shared" OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared" IntermediateDirectory="obj\release_shared"
ConfigurationType="2" ConfigurationType="2"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
CharacterSet="2" CharacterSet="2"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
/> />
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
/> />
<Tool <Tool
Name="VCXMLDataGeneratorTool" Name="VCXMLDataGeneratorTool"
/> />
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool" Name="VCWebServiceProxyGeneratorTool"
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
/> />
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="4" Optimization="4"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true" EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="true" OmitFramePointers="true"
AdditionalIncludeDirectories=".\include;..\Foundation\include;..\XML\include" AdditionalIncludeDirectories=".\include;..\Foundation\include;..\XML\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;Util_EXPORTS" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;POCO_DLL;Util_EXPORTS"
GeneratePreprocessedFile="0" GeneratePreprocessedFile="0"
KeepComments="false" KeepComments="false"
StringPooling="true" StringPooling="true"
RuntimeLibrary="2" RuntimeLibrary="2"
BufferSecurityCheck="false" BufferSecurityCheck="false"
TreatWChar_tAsBuiltInType="true" TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true" ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true" RuntimeTypeInfo="true"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="true" Detect64BitPortabilityProblems="true"
DebugInformationFormat="0" DebugInformationFormat="0"
CompileAs="0" CompileAs="0"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
/> />
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib" AdditionalDependencies="PocoFoundation.lib PocoXML.lib"
OutputFile="..\bin\PocoUtil.dll" OutputFile="..\bin\PocoUtil.dll"
LinkIncremental="1" LinkIncremental="1"
SuppressStartupBanner="true" SuppressStartupBanner="true"
AdditionalLibraryDirectories="..\lib" AdditionalLibraryDirectories="..\lib"
GenerateDebugInformation="false" GenerateDebugInformation="false"
ProgramDatabaseFile="" ProgramDatabaseFile=""
SubSystem="1" SubSystem="1"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
OptimizeForWindows98="1" OptimizeForWindows98="1"
ImportLibrary="..\lib\PocoUtil.lib" ImportLibrary="..\lib\PocoUtil.lib"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
/> />
<Tool <Tool
Name="VCManifestTool" Name="VCManifestTool"
/> />
<Tool <Tool
Name="VCXDCMakeTool" Name="VCXDCMakeTool"
/> />
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
/> />
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
/> />
<Tool <Tool
Name="VCWebDeploymentTool" Name="VCWebDeploymentTool"
/> />
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
</Configurations> </Configurations>
<References> <References>
</References> </References>
<Files> <Files>
<Filter <Filter
Name="Application" Name="Application"
> >
<Filter <Filter
Name="Header Files" Name="Header Files"
> >
<File <File
RelativePath=".\include\Poco\Util\Application.h" RelativePath=".\include\Poco\Util\Application.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\LoggingSubsystem.h" RelativePath=".\include\Poco\Util\LoggingSubsystem.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\ServerApplication.h" RelativePath=".\include\Poco\Util\ServerApplication.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\Subsystem.h" RelativePath=".\include\Poco\Util\Subsystem.h"
> >
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
<File <File
RelativePath=".\src\Application.cpp" RelativePath=".\src\Application.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\LoggingSubsystem.cpp" RelativePath=".\src\LoggingSubsystem.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\ServerApplication.cpp" RelativePath=".\src\ServerApplication.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\Subsystem.cpp" RelativePath=".\src\Subsystem.cpp"
> >
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Configuration" Name="Configuration"
> >
<Filter <Filter
Name="Header Files" Name="Header Files"
> >
<File <File
RelativePath=".\include\Poco\Util\AbstractConfiguration.h" RelativePath=".\include\Poco\Util\AbstractConfiguration.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\ConfigurationMapper.h" RelativePath=".\include\Poco\Util\ConfigurationMapper.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\ConfigurationView.h" RelativePath=".\include\Poco\Util\ConfigurationView.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\FilesystemConfiguration.h" RelativePath=".\include\Poco\Util\FilesystemConfiguration.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\IniFileConfiguration.h" RelativePath=".\include\Poco\Util\IniFileConfiguration.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\LayeredConfiguration.h" RelativePath=".\include\Poco\Util\LayeredConfiguration.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\LoggingConfigurator.h" RelativePath=".\include\Poco\Util\LoggingConfigurator.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\MapConfiguration.h" RelativePath=".\include\Poco\Util\MapConfiguration.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\PropertyFileConfiguration.h" RelativePath=".\include\Poco\Util\PropertyFileConfiguration.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\SystemConfiguration.h" RelativePath=".\include\Poco\Util\SystemConfiguration.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\XMLConfiguration.h" RelativePath=".\include\Poco\Util\XMLConfiguration.h"
> >
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
<File <File
RelativePath=".\src\AbstractConfiguration.cpp" RelativePath=".\src\AbstractConfiguration.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\ConfigurationMapper.cpp" RelativePath=".\src\ConfigurationMapper.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\ConfigurationView.cpp" RelativePath=".\src\ConfigurationView.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\FilesystemConfiguration.cpp" RelativePath=".\src\FilesystemConfiguration.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\IniFileConfiguration.cpp" RelativePath=".\src\IniFileConfiguration.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\LayeredConfiguration.cpp" RelativePath=".\src\LayeredConfiguration.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\LoggingConfigurator.cpp" RelativePath=".\src\LoggingConfigurator.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\MapConfiguration.cpp" RelativePath=".\src\MapConfiguration.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\PropertyFileConfiguration.cpp" RelativePath=".\src\PropertyFileConfiguration.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\SystemConfiguration.cpp" RelativePath=".\src\SystemConfiguration.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\XMLConfiguration.cpp" RelativePath=".\src\XMLConfiguration.cpp"
> >
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Options" Name="Options"
> >
<Filter <Filter
Name="Header Files" Name="Header Files"
> >
<File <File
RelativePath=".\include\Poco\Util\HelpFormatter.h" RelativePath=".\include\Poco\Util\HelpFormatter.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\IntValidator.h" RelativePath=".\include\Poco\Util\IntValidator.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\Option.h" RelativePath=".\include\Poco\Util\Option.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\OptionCallback.h" RelativePath=".\include\Poco\Util\OptionCallback.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\OptionException.h" RelativePath=".\include\Poco\Util\OptionException.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\OptionProcessor.h" RelativePath=".\include\Poco\Util\OptionProcessor.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\OptionSet.h" RelativePath=".\include\Poco\Util\OptionSet.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\RegExpValidator.h" RelativePath=".\include\Poco\Util\RegExpValidator.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\Validator.h" RelativePath=".\include\Poco\Util\Validator.h"
> >
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
<File <File
RelativePath=".\src\HelpFormatter.cpp" RelativePath=".\src\HelpFormatter.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\IntValidator.cpp" RelativePath=".\src\IntValidator.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\Option.cpp" RelativePath=".\src\Option.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\OptionCallback.cpp" RelativePath=".\src\OptionCallback.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\OptionException.cpp" RelativePath=".\src\OptionException.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\OptionProcessor.cpp" RelativePath=".\src\OptionProcessor.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\OptionSet.cpp" RelativePath=".\src\OptionSet.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\RegExpValidator.cpp" RelativePath=".\src\RegExpValidator.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\Validator.cpp" RelativePath=".\src\Validator.cpp"
> >
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Windows" Name="Windows"
> >
<Filter <Filter
Name="Header Files" Name="Header Files"
> >
<File <File
RelativePath=".\include\Poco\Util\WinRegistryConfiguration.h" RelativePath=".\include\Poco\Util\WinRegistryConfiguration.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\WinRegistryKey.h" RelativePath=".\include\Poco\Util\WinRegistryKey.h"
> >
</File> </File>
<File <File
RelativePath=".\include\Poco\Util\WinService.h" RelativePath=".\include\Poco\Util\WinService.h"
> >
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
<File <File
RelativePath=".\src\WinRegistryConfiguration.cpp" RelativePath=".\src\WinRegistryConfiguration.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\WinRegistryKey.cpp" RelativePath=".\src\WinRegistryKey.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\WinService.cpp" RelativePath=".\src\WinService.cpp"
> >
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Util" Name="Util"
> >
<Filter <Filter
Name="Header Files" Name="Header Files"
> >
<File <File
RelativePath=".\include\Poco\Util\Util.h" RelativePath=".\include\Poco\Util\Util.h"
> >
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
</Filter> </Filter>
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
</VisualStudioProject> </VisualStudioProject>

View File

@@ -1,235 +1,235 @@
// //
// AbstractConfiguration.h // AbstractConfiguration.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/AbstractConfiguration.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/AbstractConfiguration.h#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: AbstractConfiguration // Module: AbstractConfiguration
// //
// Definition of the AbstractConfiguration class. // Definition of the AbstractConfiguration 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 Util_AbstractConfiguration_INCLUDED #ifndef Util_AbstractConfiguration_INCLUDED
#define Util_AbstractConfiguration_INCLUDED #define Util_AbstractConfiguration_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Mutex.h" #include "Poco/Mutex.h"
#include "Poco/RefCountedObject.h" #include "Poco/RefCountedObject.h"
#include <vector> #include <vector>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API AbstractConfiguration: public Poco::RefCountedObject class Util_API AbstractConfiguration: public Poco::RefCountedObject
/// AbstractConfiguration is an abstract base class for different /// AbstractConfiguration is an abstract base class for different
/// kinds of configuration data, such as INI files, property files, /// kinds of configuration data, such as INI files, property files,
/// XML configuration files or the Windows Registry. /// XML configuration files or the Windows Registry.
/// ///
/// Configuration property keys have a hierarchical format, consisting /// Configuration property keys have a hierarchical format, consisting
/// of names separated by periods. The exact interpretation of key names /// of names separated by periods. The exact interpretation of key names
/// is up to the actual subclass implementation of AbstractConfiguration. /// is up to the actual subclass implementation of AbstractConfiguration.
/// Keys are case sensitive. /// Keys are case sensitive.
/// ///
/// All public methods are synchronized, so the class is safe for multithreaded use. /// All public methods are synchronized, so the class is safe for multithreaded use.
/// AbstractConfiguration implements reference counting based garbage collection. /// AbstractConfiguration implements reference counting based garbage collection.
/// ///
/// Subclasses must override the getRaw(), setRaw() and enumerate() methods. /// Subclasses must override the getRaw(), setRaw() and enumerate() methods.
{ {
public: public:
typedef std::vector<std::string> Keys; typedef std::vector<std::string> Keys;
AbstractConfiguration(); AbstractConfiguration();
/// Creates the AbstractConfiguration. /// Creates the AbstractConfiguration.
bool hasProperty(const std::string& key) const; bool hasProperty(const std::string& key) const;
/// Returns true iff the property with the given key exists. /// Returns true iff the property with the given key exists.
bool hasOption(const std::string& key) const; bool hasOption(const std::string& key) const;
/// Returns true iff the property with the given key exists. /// Returns true iff the property with the given key exists.
/// Same as hasProperty(). /// Same as hasProperty().
std::string getString(const std::string& key) const; std::string getString(const std::string& key) const;
/// Returns the string value of the property with the given name. /// Returns the string value of the property with the given name.
/// Throws a NotFoundException if the key does not exist. /// Throws a NotFoundException if the key does not exist.
/// If the value contains references to other properties (${<property>}), these /// If the value contains references to other properties (${<property>}), these
/// are expanded. /// are expanded.
std::string getString(const std::string& key, const std::string& defaultValue) const; std::string getString(const std::string& key, const std::string& defaultValue) const;
/// If a property with the given key exists, returns the property's string value, /// If a property with the given key exists, returns the property's string value,
/// otherwise returns the given default value. /// otherwise returns the given default value.
/// If the value contains references to other properties (${<property>}), these /// If the value contains references to other properties (${<property>}), these
/// are expanded. /// are expanded.
std::string getRawString(const std::string& key) const; std::string getRawString(const std::string& key) const;
/// Returns the raw string value of the property with the given name. /// Returns the raw string value of the property with the given name.
/// Throws a NotFoundException if the key does not exist. /// Throws a NotFoundException if the key does not exist.
/// References to other properties are not expanded. /// References to other properties are not expanded.
std::string getRawString(const std::string& key, const std::string& defaultValue) const; std::string getRawString(const std::string& key, const std::string& defaultValue) const;
/// If a property with the given key exists, returns the property's raw string value, /// If a property with the given key exists, returns the property's raw string value,
/// otherwise returns the given default value. /// otherwise returns the given default value.
/// References to other properties are not expanded. /// References to other properties are not expanded.
int getInt(const std::string& key) const; int getInt(const std::string& key) const;
/// Returns the int value of the property with the given name. /// Returns the int value of the property with the given name.
/// Throws a NotFoundException if the key does not exist. /// Throws a NotFoundException if the key does not exist.
/// Throws a SyntaxException if the property can not be converted /// Throws a SyntaxException if the property can not be converted
/// to an int. /// to an int.
/// Numbers starting with 0x are treated as hexadecimal. /// Numbers starting with 0x are treated as hexadecimal.
/// If the value contains references to other properties (${<property>}), these /// If the value contains references to other properties (${<property>}), these
/// are expanded. /// are expanded.
int getInt(const std::string& key, int defaultValue) const; int getInt(const std::string& key, int defaultValue) const;
/// If a property with the given key exists, returns the property's int value, /// If a property with the given key exists, returns the property's int value,
/// otherwise returns the given default value. /// otherwise returns the given default value.
/// Throws a SyntaxException if the property can not be converted /// Throws a SyntaxException if the property can not be converted
/// to an int. /// to an int.
/// Numbers starting with 0x are treated as hexadecimal. /// Numbers starting with 0x are treated as hexadecimal.
/// If the value contains references to other properties (${<property>}), these /// If the value contains references to other properties (${<property>}), these
/// are expanded. /// are expanded.
double getDouble(const std::string& key) const; double getDouble(const std::string& key) const;
/// Returns the double value of the property with the given name. /// Returns the double value of the property with the given name.
/// Throws a NotFoundException if the key does not exist. /// Throws a NotFoundException if the key does not exist.
/// Throws a SyntaxException if the property can not be converted /// Throws a SyntaxException if the property can not be converted
/// to a double. /// to a double.
/// If the value contains references to other properties (${<property>}), these /// If the value contains references to other properties (${<property>}), these
/// are expanded. /// are expanded.
double getDouble(const std::string& key, double defaultValue) const; double getDouble(const std::string& key, double defaultValue) const;
/// If a property with the given key exists, returns the property's double value, /// If a property with the given key exists, returns the property's double value,
/// otherwise returns the given default value. /// otherwise returns the given default value.
/// Throws a SyntaxException if the property can not be converted /// Throws a SyntaxException if the property can not be converted
/// to an double. /// to an double.
/// If the value contains references to other properties (${<property>}), these /// If the value contains references to other properties (${<property>}), these
/// are expanded. /// are expanded.
bool getBool(const std::string& key) const; bool getBool(const std::string& key) const;
/// Returns the double value of the property with the given name. /// Returns the double value of the property with the given name.
/// Throws a NotFoundException if the key does not exist. /// Throws a NotFoundException if the key does not exist.
/// Throws a SyntaxException if the property can not be converted /// Throws a SyntaxException if the property can not be converted
/// to a double. /// to a double.
/// If the value contains references to other properties (${<property>}), these /// If the value contains references to other properties (${<property>}), these
/// are expanded. /// are expanded.
bool getBool(const std::string& key, bool defaultValue) const; bool getBool(const std::string& key, bool defaultValue) const;
/// If a property with the given key exists, returns the property's bool value, /// If a property with the given key exists, returns the property's bool value,
/// otherwise returns the given default value. /// otherwise returns the given default value.
/// Throws a SyntaxException if the property can not be converted /// Throws a SyntaxException if the property can not be converted
/// to a boolean. /// to a boolean.
/// The following string values can be converted into a boolean: /// The following string values can be converted into a boolean:
/// - numerical values: non zero becomes true, zero becomes false /// - numerical values: non zero becomes true, zero becomes false
/// - strings: true, yes, on become true, false, no, off become false /// - strings: true, yes, on become true, false, no, off become false
/// Case does not matter. /// Case does not matter.
/// If the value contains references to other properties (${<property>}), these /// If the value contains references to other properties (${<property>}), these
/// are expanded. /// are expanded.
void setString(const std::string& key, const std::string& value); void setString(const std::string& key, const std::string& value);
/// Sets the property with the given key to the given value. /// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten. /// An already existing value for the key is overwritten.
void setInt(const std::string& key, int value); void setInt(const std::string& key, int value);
/// Sets the property with the given key to the given value. /// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten. /// An already existing value for the key is overwritten.
void setDouble(const std::string& key, double value); void setDouble(const std::string& key, double value);
/// Sets the property with the given key to the given value. /// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten. /// An already existing value for the key is overwritten.
void setBool(const std::string& key, bool value); void setBool(const std::string& key, bool value);
/// Sets the property with the given key to the given value. /// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten. /// An already existing value for the key is overwritten.
void keys(Keys& range) const; void keys(Keys& range) const;
/// Returns in range the names of all keys at root level. /// Returns in range the names of all keys at root level.
void keys(const std::string& key, Keys& range) const; void keys(const std::string& key, Keys& range) const;
/// Returns in range the names of all subkeys under the given key. /// Returns in range the names of all subkeys under the given key.
/// If an empty key is passed, all root level keys are returned. /// If an empty key is passed, all root level keys are returned.
const AbstractConfiguration* createView(const std::string& prefix) const; const AbstractConfiguration* createView(const std::string& prefix) const;
/// Creates a non-mutable view (see ConfigurationView) into the configuration. /// Creates a non-mutable view (see ConfigurationView) into the configuration.
AbstractConfiguration* createView(const std::string& prefix); AbstractConfiguration* createView(const std::string& prefix);
/// Creates a view (see ConfigurationView) into the configuration. /// Creates a view (see ConfigurationView) into the configuration.
std::string expand(const std::string& value) const; std::string expand(const std::string& value) const;
/// Replaces all occurences of ${<property>} in value with the /// Replaces all occurences of ${<property>} in value with the
/// value of the <property>. If <property> does not exist, /// value of the <property>. If <property> does not exist,
/// nothing is changed. /// nothing is changed.
/// ///
/// If a circular property reference is detected, a /// If a circular property reference is detected, a
/// CircularReferenceException will be thrown. /// CircularReferenceException will be thrown.
protected: protected:
virtual bool getRaw(const std::string& key, std::string& value) const = 0; virtual bool getRaw(const std::string& key, std::string& value) const = 0;
/// If the property with the given key exists, stores the property's value /// If the property with the given key exists, stores the property's value
/// in value and returns true. Otherwise, returns false. /// in value and returns true. Otherwise, returns false.
/// ///
/// Must be overridden by subclasses. /// Must be overridden by subclasses.
virtual void setRaw(const std::string& key, const std::string& value) = 0; virtual void setRaw(const std::string& key, const std::string& value) = 0;
/// Sets the property with the given key to the given value. /// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten. /// An already existing value for the key is overwritten.
/// ///
/// Must be overridden by subclasses. /// Must be overridden by subclasses.
virtual void enumerate(const std::string& key, Keys& range) const = 0; virtual void enumerate(const std::string& key, Keys& range) const = 0;
/// Returns in range the names of all subkeys under the given key. /// Returns in range the names of all subkeys under the given key.
/// If an empty key is passed, all root level keys are returned. /// If an empty key is passed, all root level keys are returned.
static int parseInt(const std::string& value); static int parseInt(const std::string& value);
static bool parseBool(const std::string& value); static bool parseBool(const std::string& value);
virtual ~AbstractConfiguration(); virtual ~AbstractConfiguration();
private: private:
std::string internalExpand(const std::string& value) const; std::string internalExpand(const std::string& value) const;
std::string uncheckedExpand(const std::string& value) const; std::string uncheckedExpand(const std::string& value) const;
AbstractConfiguration(const AbstractConfiguration&); AbstractConfiguration(const AbstractConfiguration&);
AbstractConfiguration& operator = (const AbstractConfiguration&); AbstractConfiguration& operator = (const AbstractConfiguration&);
mutable int _depth; mutable int _depth;
mutable Poco::FastMutex _mutex; mutable Poco::FastMutex _mutex;
friend class LayeredConfiguration; friend class LayeredConfiguration;
friend class ConfigurationView; friend class ConfigurationView;
friend class ConfigurationMapper; friend class ConfigurationMapper;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_AbstractConfiguration_INCLUDED #endif // Util_AbstractConfiguration_INCLUDED

View File

@@ -1,452 +1,452 @@
// //
// Application.h // Application.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/Application.h#2 $ // $Id: //poco/1.2/Util/include/Poco/Util/Application.h#2 $
// //
// Library: Util // Library: Util
// Package: Application // Package: Application
// Module: Application // Module: Application
// //
// Definition of the Application class. // Definition of the Application 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 Util_Application_INCLUDED #ifndef Util_Application_INCLUDED
#define Util_Application_INCLUDED #define Util_Application_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/Subsystem.h" #include "Poco/Util/Subsystem.h"
#include "Poco/Util/LayeredConfiguration.h" #include "Poco/Util/LayeredConfiguration.h"
#include "Poco/Util/OptionSet.h" #include "Poco/Util/OptionSet.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include "Poco/Logger.h" #include "Poco/Logger.h"
#include "Poco/Path.h" #include "Poco/Path.h"
#include "Poco/Timestamp.h" #include "Poco/Timestamp.h"
#include "Poco/Timespan.h" #include "Poco/Timespan.h"
#include <vector> #include <vector>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class OptionSet; class OptionSet;
class Util_API Application: public Subsystem class Util_API Application: public Subsystem
/// The Application class implements the main subsystem /// The Application class implements the main subsystem
/// in a process. The application class is responsible for /// in a process. The application class is responsible for
/// initializing all its subsystems. /// initializing all its subsystems.
/// ///
/// Subclasses can and should override the following virtual methods: /// Subclasses can and should override the following virtual methods:
/// - initialize() (the one-argument, protected variant) /// - initialize() (the one-argument, protected variant)
/// - uninitialize() /// - uninitialize()
/// - reinitialize() /// - reinitialize()
/// - defineOptions() /// - defineOptions()
/// - handleOption() /// - handleOption()
/// - main() /// - main()
/// ///
/// The application's main logic should be implemented in /// The application's main logic should be implemented in
/// the main() method. /// the main() method.
/// ///
/// There may be at most one instance of the Application class /// There may be at most one instance of the Application class
/// in a process. /// in a process.
/// ///
/// The Application class sets a few default properties in /// The Application class sets a few default properties in
/// its configuration (available via the config() method). /// its configuration (available via the config() method).
/// These are: /// These are:
/// - application.path: the absolute path to application executable /// - application.path: the absolute path to application executable
/// - application.name: the file name of the application executable /// - application.name: the file name of the application executable
/// - application.baseName: the file name (excluding extension) of the application executable /// - application.baseName: the file name (excluding extension) of the application executable
/// - application.dir: the path to the directory where the application executable resides /// - application.dir: the path to the directory where the application executable resides
/// - application.configDir: the path to the directory where the last configuration file loaded with loadConfiguration() was found. /// - application.configDir: the path to the directory where the last configuration file loaded with loadConfiguration() was found.
/// If loadConfiguration() has never been called, application.configDir will be equal to application.dir. /// If loadConfiguration() has never been called, application.configDir will be equal to application.dir.
/// ///
/// The POCO_APP_MAIN macro can be used to implement main(argc, argv). /// The POCO_APP_MAIN macro can be used to implement main(argc, argv).
/// If POCO has been built with POCO_WIN32_UTF8, POCO_APP_MAIN supports /// If POCO has been built with POCO_WIN32_UTF8, POCO_APP_MAIN supports
/// Unicode command line arguments. /// Unicode command line arguments.
{ {
public: public:
enum ExitCode enum ExitCode
/// Commonly used exit status codes. /// Commonly used exit status codes.
/// Based on the definitions in the 4.3BSD <sysexits.h> header file. /// Based on the definitions in the 4.3BSD <sysexits.h> header file.
{ {
EXIT_OK = 0, /// successful termination EXIT_OK = 0, /// successful termination
EXIT_USAGE = 64, /// command line usage error EXIT_USAGE = 64, /// command line usage error
EXIT_DATAERR = 65, /// data format error EXIT_DATAERR = 65, /// data format error
EXIT_NOINPUT = 66, /// cannot open input EXIT_NOINPUT = 66, /// cannot open input
EXIT_NOUSER = 67, /// addressee unknown EXIT_NOUSER = 67, /// addressee unknown
EXIT_NOHOST = 68, /// host name unknown EXIT_NOHOST = 68, /// host name unknown
EXIT_UNAVAILABLE = 69, /// service unavailable EXIT_UNAVAILABLE = 69, /// service unavailable
EXIT_SOFTWARE = 70, /// internal software error EXIT_SOFTWARE = 70, /// internal software error
EXIT_OSERR = 71, /// system error (e.g., can't fork) EXIT_OSERR = 71, /// system error (e.g., can't fork)
EXIT_OSFILE = 72, /// critical OS file missing EXIT_OSFILE = 72, /// critical OS file missing
EXIT_CANTCREAT = 73, /// can't create (user) output file EXIT_CANTCREAT = 73, /// can't create (user) output file
EXIT_IOERR = 74, /// input/output error EXIT_IOERR = 74, /// input/output error
EXIT_TEMPFAIL = 75, /// temp failure; user is invited to retry EXIT_TEMPFAIL = 75, /// temp failure; user is invited to retry
EXIT_PROTOCOL = 76, /// remote error in protocol EXIT_PROTOCOL = 76, /// remote error in protocol
EXIT_NOPERM = 77, /// permission denied EXIT_NOPERM = 77, /// permission denied
EXIT_CONFIG = 78 /// configuration error EXIT_CONFIG = 78 /// configuration error
}; };
Application(); Application();
/// Creates the Application. /// Creates the Application.
Application(int argc, char* argv[]); Application(int argc, char* argv[]);
/// Creates the Application and calls init(argc, argv). /// Creates the Application and calls init(argc, argv).
void addSubsystem(Subsystem* pSubsystem); void addSubsystem(Subsystem* pSubsystem);
/// Adds a new subsystem to the application. The /// Adds a new subsystem to the application. The
/// application immediately takes ownership of it, so that a /// application immediately takes ownership of it, so that a
/// call in the form /// call in the form
/// Application::instance().addSubsystem(new MySubsystem); /// Application::instance().addSubsystem(new MySubsystem);
/// is okay. /// is okay.
void init(int argc, char* argv[]); void init(int argc, char* argv[]);
/// Initializes the application and all registered subsystems, /// Initializes the application and all registered subsystems,
/// using the given command line arguments. /// using the given command line arguments.
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
void init(int argc, wchar_t* argv[]); void init(int argc, wchar_t* argv[]);
/// Initializes the application and all registered subsystems, /// Initializes the application and all registered subsystems,
/// using the given command line arguments. /// using the given command line arguments.
/// ///
/// This Windows-specific version of init is used for passing /// This Windows-specific version of init is used for passing
/// Unicode command line arguments from wmain(). /// Unicode command line arguments from wmain().
#endif #endif
void init(const std::vector<std::string>& args); void init(const std::vector<std::string>& args);
/// Initializes the application and all registered subsystems, /// Initializes the application and all registered subsystems,
/// using the given command line arguments. /// using the given command line arguments.
bool initialized() const; bool initialized() const;
/// Returns true iff the application is in initialized state /// Returns true iff the application is in initialized state
/// (that means, has been initialized but not yet uninitialized). /// (that means, has been initialized but not yet uninitialized).
void setUnixOptions(bool flag); void setUnixOptions(bool flag);
/// Specify whether command line option handling is Unix-style /// Specify whether command line option handling is Unix-style
/// (flag == true; default) or Windows/OpenVMS-style (flag == false). /// (flag == true; default) or Windows/OpenVMS-style (flag == false).
int loadConfiguration(); int loadConfiguration();
/// Loads configuration information from a default location. /// Loads configuration information from a default location.
/// ///
/// The configuration file(s) must be located in the same directory /// The configuration file(s) must be located in the same directory
/// as the executable or a parent directory of it, and must have the /// as the executable or a parent directory of it, and must have the
/// same base name as the executable, with one of the following extensions: /// same base name as the executable, with one of the following extensions:
/// .properties, .ini or .xml. /// .properties, .ini or .xml.
/// ///
/// The .properties file, if it exists, is loaded first, followed /// The .properties file, if it exists, is loaded first, followed
/// by the .ini file and the .xml file. /// by the .ini file and the .xml file.
/// ///
/// If the application is built in debug mode (the _DEBUG preprocessor /// If the application is built in debug mode (the _DEBUG preprocessor
/// macro is defined) and the base name of the appication executable /// macro is defined) and the base name of the appication executable
/// ends with a 'd', a config file without the 'd' ending its base name is /// ends with a 'd', a config file without the 'd' ending its base name is
/// also found. /// also found.
/// ///
/// Example: Given the application "SampleAppd.exe", built in debug mode. /// Example: Given the application "SampleAppd.exe", built in debug mode.
/// Then loadConfiguration() will automatically find a configuration file /// Then loadConfiguration() will automatically find a configuration file
/// named "SampleApp.properties" if it exists and if "SampleAppd.properties" /// named "SampleApp.properties" if it exists and if "SampleAppd.properties"
/// cannot be found. /// cannot be found.
/// ///
/// Returns the number of configuration files loaded, which may be zero. /// Returns the number of configuration files loaded, which may be zero.
/// ///
/// This method must not be called before initialize(argc, argv) /// This method must not be called before initialize(argc, argv)
/// has been called. /// has been called.
void loadConfiguration(const std::string& path); void loadConfiguration(const std::string& path);
/// Loads configuration information from the file specified by /// Loads configuration information from the file specified by
/// the given path. The file type is determined by the file /// the given path. The file type is determined by the file
/// extension. The following extensions are supported: /// extension. The following extensions are supported:
/// - .properties - properties file (PropertyFileConfiguration) /// - .properties - properties file (PropertyFileConfiguration)
/// - .ini - initialization file (IniFileConfiguration) /// - .ini - initialization file (IniFileConfiguration)
/// - .xml - XML file (XMLConfiguration) /// - .xml - XML file (XMLConfiguration)
/// ///
/// Extensions are not case sensitive. /// Extensions are not case sensitive.
template <class C> C& getSubsystem() const; template <class C> C& getSubsystem() const;
/// Returns a reference to the subsystem of the class /// Returns a reference to the subsystem of the class
/// given as template argument. /// given as template argument.
/// ///
/// Throws a NotFoundException if such a subsystem has /// Throws a NotFoundException if such a subsystem has
/// not been registered. /// not been registered.
virtual int run(); virtual int run();
/// Runs the application by performing additional initializations /// Runs the application by performing additional initializations
/// and calling the main() method. /// and calling the main() method.
std::string commandName() const; std::string commandName() const;
/// Returns the command name used to invoke the application. /// Returns the command name used to invoke the application.
LayeredConfiguration& config() const; LayeredConfiguration& config() const;
/// Returns the application's configuration. /// Returns the application's configuration.
Poco::Logger& logger() const; Poco::Logger& logger() const;
/// Returns the application's logger. /// Returns the application's logger.
/// ///
/// Before the logging subsystem has been initialized, the /// Before the logging subsystem has been initialized, the
/// application's logger is "ApplicationStartup", which is /// application's logger is "ApplicationStartup", which is
/// connected to a ConsoleChannel. /// connected to a ConsoleChannel.
/// ///
/// After the logging subsystem has been initialized, which /// After the logging subsystem has been initialized, which
/// usually happens as the first action in Application::initialize(), /// usually happens as the first action in Application::initialize(),
/// the application's logger is the one specified by the /// the application's logger is the one specified by the
/// "application.logger" configuration property. If that property /// "application.logger" configuration property. If that property
/// is not specified, the logger is "Application". /// is not specified, the logger is "Application".
const OptionSet& options() const; const OptionSet& options() const;
/// Returns the application's option set. /// Returns the application's option set.
static Application& instance(); static Application& instance();
/// Returns a reference to the Application singleton. /// Returns a reference to the Application singleton.
/// ///
/// Throws a NullPointerException if no Application instance exists. /// Throws a NullPointerException if no Application instance exists.
const Poco::Timestamp& startTime() const; const Poco::Timestamp& startTime() const;
/// Returns the application start time (UTC). /// Returns the application start time (UTC).
Poco::Timespan uptime() const; Poco::Timespan uptime() const;
/// Returns the application uptime. /// Returns the application uptime.
void stopOptionsProcessing(); void stopOptionsProcessing();
/// If called from an option callback, stops all further /// If called from an option callback, stops all further
/// options processing. /// options processing.
/// ///
/// If called, the following options on the command line /// If called, the following options on the command line
/// will not be processed, and required options will not /// will not be processed, and required options will not
/// be checked. /// be checked.
/// ///
/// This is useful, for example, if an option for displaying /// This is useful, for example, if an option for displaying
/// help information has been encountered and no other things /// help information has been encountered and no other things
/// besides displaying help shall be done. /// besides displaying help shall be done.
const char* name() const; const char* name() const;
protected: protected:
void initialize(Application& self); void initialize(Application& self);
/// Initializes the application and all registered subsystems. /// Initializes the application and all registered subsystems.
/// Subsystems are always initialized in the exact same order /// Subsystems are always initialized in the exact same order
/// in which they have been registered. /// in which they have been registered.
/// ///
/// Overriding implementations must call the base class implementation. /// Overriding implementations must call the base class implementation.
void uninitialize(); void uninitialize();
/// Uninitializes the application and all registered subsystems. /// Uninitializes the application and all registered subsystems.
/// Subsystems are always uninitialized in reverse order in which /// Subsystems are always uninitialized in reverse order in which
/// they have been initialized. /// they have been initialized.
/// ///
/// Overriding implementations must call the base class implementation. /// Overriding implementations must call the base class implementation.
void reinitialize(Application& self); void reinitialize(Application& self);
/// Re-nitializes the application and all registered subsystems. /// Re-nitializes the application and all registered subsystems.
/// Subsystems are always reinitialized in the exact same order /// Subsystems are always reinitialized in the exact same order
/// in which they have been registered. /// in which they have been registered.
/// ///
/// Overriding implementations must call the base class implementation. /// Overriding implementations must call the base class implementation.
virtual void defineOptions(OptionSet& options); virtual void defineOptions(OptionSet& options);
/// Called before command line processing begins. /// Called before command line processing begins.
/// If a subclass wants to support command line arguments, /// If a subclass wants to support command line arguments,
/// it must override this method. /// it must override this method.
/// The default implementation does not define any options. /// The default implementation does not define any options.
/// ///
/// Overriding implementations should call the base class implementation. /// Overriding implementations should call the base class implementation.
virtual void handleOption(const std::string& name, const std::string& value); virtual void handleOption(const std::string& name, const std::string& value);
/// Called when the option with the given name is encountered /// Called when the option with the given name is encountered
/// during command line arguments processing. /// during command line arguments processing.
/// ///
/// The default implementation does option validation, bindings /// The default implementation does option validation, bindings
/// and callback handling. /// and callback handling.
/// ///
/// Overriding implementations must call the base class implementation. /// Overriding implementations must call the base class implementation.
void setLogger(Poco::Logger& logger); void setLogger(Poco::Logger& logger);
/// Sets the logger used by the application. /// Sets the logger used by the application.
virtual int main(const std::vector<std::string>& args); virtual int main(const std::vector<std::string>& args);
/// The application's main logic. /// The application's main logic.
/// ///
/// Unprocessed command line arguments are passed in args. /// Unprocessed command line arguments are passed in args.
/// Note that all original command line arguments are available /// Note that all original command line arguments are available
/// via the properties application.argc and application.argv[<n>]. /// via the properties application.argc and application.argv[<n>].
/// ///
/// Returns an exit code which should be one of the values /// Returns an exit code which should be one of the values
/// from the ExitCode enumeration. /// from the ExitCode enumeration.
bool findFile(Poco::Path& path) const; bool findFile(Poco::Path& path) const;
/// Searches for the file in path in the application directory. /// Searches for the file in path in the application directory.
/// ///
/// If path is absolute, the method immediately returns true and /// If path is absolute, the method immediately returns true and
/// leaves path unchanged. /// leaves path unchanged.
/// ///
/// If path is relative, searches for the file in the application /// If path is relative, searches for the file in the application
/// directory and in all subsequent parent directories. /// directory and in all subsequent parent directories.
/// Returns true and stores the absolute path to the file in /// Returns true and stores the absolute path to the file in
/// path if the file could be found. Returns false and leaves path /// path if the file could be found. Returns false and leaves path
/// unchanged otherwise. /// unchanged otherwise.
void init(); void init();
/// Common initialization code. /// Common initialization code.
~Application(); ~Application();
/// Destroys the Application and deletes all registered subsystems. /// Destroys the Application and deletes all registered subsystems.
private: private:
void setup(); void setup();
void setArgs(int argc, char* argv[]); void setArgs(int argc, char* argv[]);
void setArgs(const std::vector<std::string>& args); void setArgs(const std::vector<std::string>& args);
void getApplicationPath(Poco::Path& path) const; void getApplicationPath(Poco::Path& path) const;
void processOptions(); void processOptions();
bool findAppConfigFile(const std::string& appName, const std::string& extension, Poco::Path& path) const; bool findAppConfigFile(const std::string& appName, const std::string& extension, Poco::Path& path) const;
typedef Poco::AutoPtr<Subsystem> SubsystemPtr; typedef Poco::AutoPtr<Subsystem> SubsystemPtr;
typedef std::vector<SubsystemPtr> SubsystemVec; typedef std::vector<SubsystemPtr> SubsystemVec;
typedef Poco::AutoPtr<LayeredConfiguration> ConfigPtr; typedef Poco::AutoPtr<LayeredConfiguration> ConfigPtr;
typedef std::vector<std::string> ArgVec; typedef std::vector<std::string> ArgVec;
ConfigPtr _pConfig; ConfigPtr _pConfig;
SubsystemVec _subsystems; SubsystemVec _subsystems;
bool _initialized; bool _initialized;
std::string _command; std::string _command;
ArgVec _args; ArgVec _args;
OptionSet _options; OptionSet _options;
bool _unixOptions; bool _unixOptions;
Poco::Logger* _pLogger; Poco::Logger* _pLogger;
Poco::Timestamp _startTime; Poco::Timestamp _startTime;
bool _stopOptionsProcessing; bool _stopOptionsProcessing;
static Application* _pInstance; static Application* _pInstance;
friend class LoggingSubsystem; friend class LoggingSubsystem;
}; };
// //
// inlines // inlines
// //
template <class C> C& Application::getSubsystem() const template <class C> C& Application::getSubsystem() const
{ {
for (SubsystemVec::const_iterator it = _subsystems.begin(); it != _subsystems.end(); ++it) for (SubsystemVec::const_iterator it = _subsystems.begin(); it != _subsystems.end(); ++it)
{ {
if (dynamic_cast<C*>(*it)) if (dynamic_cast<C*>(*it))
return **it; return **it;
} }
throw Poco::NotFoundException("The subsystem has not been registered"); throw Poco::NotFoundException("The subsystem has not been registered");
} }
inline bool Application::initialized() const inline bool Application::initialized() const
{ {
return _initialized; return _initialized;
} }
inline LayeredConfiguration& Application::config() const inline LayeredConfiguration& Application::config() const
{ {
return *const_cast<LayeredConfiguration*>(_pConfig.get()); return *const_cast<LayeredConfiguration*>(_pConfig.get());
} }
inline Poco::Logger& Application::logger() const inline Poco::Logger& Application::logger() const
{ {
poco_check_ptr (_pLogger); poco_check_ptr (_pLogger);
return *_pLogger; return *_pLogger;
} }
inline const OptionSet& Application::options() const inline const OptionSet& Application::options() const
{ {
return _options; return _options;
} }
inline Application& Application::instance() inline Application& Application::instance()
{ {
poco_check_ptr (_pInstance); poco_check_ptr (_pInstance);
return *_pInstance; return *_pInstance;
} }
inline const Poco::Timestamp& Application::startTime() const inline const Poco::Timestamp& Application::startTime() const
{ {
return _startTime; return _startTime;
} }
inline Poco::Timespan Application::uptime() const inline Poco::Timespan Application::uptime() const
{ {
Poco::Timestamp now; Poco::Timestamp now;
Poco::Timespan uptime = now - _startTime; Poco::Timespan uptime = now - _startTime;
return uptime; return uptime;
} }
} } // namespace Poco::Util } } // namespace Poco::Util
// //
// Macro to implement main() // Macro to implement main()
// //
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
#define POCO_APP_MAIN(App) \ #define POCO_APP_MAIN(App) \
int wmain(int argc, wchar_t** argv) \ int wmain(int argc, wchar_t** argv) \
{ \ { \
AutoPtr<App> pApp = new App; \ AutoPtr<App> pApp = new App; \
try \ try \
{ \ { \
pApp->init(argc, argv); \ pApp->init(argc, argv); \
} \ } \
catch (Poco::Exception& exc) \ catch (Poco::Exception& exc) \
{ \ { \
pApp->logger().log(exc); \ pApp->logger().log(exc); \
return Application::EXIT_CONFIG;\ return Application::EXIT_CONFIG;\
} \ } \
return pApp->run(); \ return pApp->run(); \
} }
#else #else
#define POCO_APP_MAIN(App) \ #define POCO_APP_MAIN(App) \
int main(int argc, char** argv) \ int main(int argc, char** argv) \
{ \ { \
AutoPtr<App> pApp = new App; \ AutoPtr<App> pApp = new App; \
try \ try \
{ \ { \
pApp->init(argc, argv); \ pApp->init(argc, argv); \
} \ } \
catch (Poco::Exception& exc) \ catch (Poco::Exception& exc) \
{ \ { \
pApp->logger().log(exc); \ pApp->logger().log(exc); \
return Application::EXIT_CONFIG;\ return Application::EXIT_CONFIG;\
} \ } \
return pApp->run(); \ return pApp->run(); \
} }
#endif #endif
#endif // Util_Application_INCLUDED #endif // Util_Application_INCLUDED

View File

@@ -1,115 +1,115 @@
// //
// ConfigurationMapper.h // ConfigurationMapper.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/ConfigurationMapper.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/ConfigurationMapper.h#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: ConfigurationMapper // Module: ConfigurationMapper
// //
// Definition of the ConfigurationMapper class. // Definition of the ConfigurationMapper 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 Util_ConfigurationMapper_INCLUDED #ifndef Util_ConfigurationMapper_INCLUDED
#define Util_ConfigurationMapper_INCLUDED #define Util_ConfigurationMapper_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API ConfigurationMapper: public AbstractConfiguration class Util_API ConfigurationMapper: public AbstractConfiguration
/// This configuration maps a property hierarchy into another /// This configuration maps a property hierarchy into another
/// hierarchy. /// hierarchy.
/// ///
/// For example, given a configuration with the following properties: /// For example, given a configuration with the following properties:
/// config.value1 /// config.value1
/// config.value2 /// config.value2
/// config.sub.value1 /// config.sub.value1
/// config.sub.value2 /// config.sub.value2
/// and a ConfigurationView with fromPrefix == "config" and toPrefix == "root.conf", then /// and a ConfigurationView with fromPrefix == "config" and toPrefix == "root.conf", then
/// the above properties will be available via the mapper as /// the above properties will be available via the mapper as
/// root.conf.value1 /// root.conf.value1
/// root.conf.value2 /// root.conf.value2
/// root.conf.sub.value1 /// root.conf.sub.value1
/// root.conf.sub.value2 /// root.conf.sub.value2
/// ///
/// FromPrefix can be empty, in which case, and given toPrefix == "root", /// FromPrefix can be empty, in which case, and given toPrefix == "root",
/// the properties will be available as /// the properties will be available as
/// root.config.value1 /// root.config.value1
/// root.config.value2 /// root.config.value2
/// root.config.sub.value1 /// root.config.sub.value1
/// root.config.sub.value2 /// root.config.sub.value2
/// ///
/// This is equivalent to the functionality of the ConfigurationView class. /// This is equivalent to the functionality of the ConfigurationView class.
/// ///
/// Similarly, toPrefix can also be empty. Given fromPrefix == "config" and /// Similarly, toPrefix can also be empty. Given fromPrefix == "config" and
/// toPrefix == "", the properties will be available as /// toPrefix == "", the properties will be available as
/// value1 /// value1
/// value2 /// value2
/// sub.value1 /// sub.value1
/// sub.value2 /// sub.value2
/// ///
/// If both fromPrefix and toPrefix are empty, no mapping is performed. /// If both fromPrefix and toPrefix are empty, no mapping is performed.
/// ///
/// A ConfigurationMapper is most useful in combination with a /// A ConfigurationMapper is most useful in combination with a
/// LayeredConfiguration. /// LayeredConfiguration.
{ {
public: public:
ConfigurationMapper(const std::string& fromPrefix, const std::string& toPrefix, AbstractConfiguration* pConfig); ConfigurationMapper(const std::string& fromPrefix, const std::string& toPrefix, AbstractConfiguration* pConfig);
/// Creates the ConfigurationMapper. The ConfigurationMapper does not take /// Creates the ConfigurationMapper. The ConfigurationMapper does not take
/// ownership of the passed configuration. /// ownership of the passed configuration.
protected: protected:
bool getRaw(const std::string& key, std::string& value) const; bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value); void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const; void enumerate(const std::string& key, Keys& range) const;
std::string translateKey(const std::string& key) const; std::string translateKey(const std::string& key) const;
~ConfigurationMapper(); ~ConfigurationMapper();
private: private:
ConfigurationMapper(const ConfigurationMapper&); ConfigurationMapper(const ConfigurationMapper&);
ConfigurationMapper& operator = (const ConfigurationMapper&); ConfigurationMapper& operator = (const ConfigurationMapper&);
std::string _fromPrefix; std::string _fromPrefix;
std::string _toPrefix; std::string _toPrefix;
AbstractConfiguration* _pConfig; AbstractConfiguration* _pConfig;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_ConfigurationMapper_INCLUDED #endif // Util_ConfigurationMapper_INCLUDED

View File

@@ -1,103 +1,103 @@
// //
// ConfigurationView.h // ConfigurationView.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/ConfigurationView.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/ConfigurationView.h#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: ConfigurationView // Module: ConfigurationView
// //
// Definition of the ConfigurationView class. // Definition of the ConfigurationView 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 Util_ConfigurationView_INCLUDED #ifndef Util_ConfigurationView_INCLUDED
#define Util_ConfigurationView_INCLUDED #define Util_ConfigurationView_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API ConfigurationView: public AbstractConfiguration class Util_API ConfigurationView: public AbstractConfiguration
/// This configuration implements a "view" into a sub-hierarchy /// This configuration implements a "view" into a sub-hierarchy
/// of another configuration. /// of another configuration.
/// ///
/// For example, given a configuration with the following properties: /// For example, given a configuration with the following properties:
/// config.value1 /// config.value1
/// config.value2 /// config.value2
/// config.sub.value1 /// config.sub.value1
/// config.sub.value2 /// config.sub.value2
/// and a ConfigurationView with the prefix "config", then /// and a ConfigurationView with the prefix "config", then
/// the above properties will be available via the view as /// the above properties will be available via the view as
/// value1 /// value1
/// value2 /// value2
/// sub.value1 /// sub.value1
/// sub.value2 /// sub.value2
/// ///
/// A ConfigurationView is most useful in combination with a /// A ConfigurationView is most useful in combination with a
/// LayeredConfiguration. /// LayeredConfiguration.
/// ///
/// If a property is not found in the view, it is searched in /// If a property is not found in the view, it is searched in
/// the original configuration. Given the above example configuration, /// the original configuration. Given the above example configuration,
/// the property named "config.value1" will still be found in the view. /// the property named "config.value1" will still be found in the view.
/// ///
/// The main reason for this is that placeholder expansion (${property}) /// The main reason for this is that placeholder expansion (${property})
/// still works as expected given a ConfigurationView. /// still works as expected given a ConfigurationView.
{ {
public: public:
ConfigurationView(const std::string& prefix, AbstractConfiguration* pConfig); ConfigurationView(const std::string& prefix, AbstractConfiguration* pConfig);
/// Creates the ConfigurationView. The ConfigurationView does not take /// Creates the ConfigurationView. The ConfigurationView does not take
/// ownership of the passed configuration. /// ownership of the passed configuration.
protected: protected:
bool getRaw(const std::string& key, std::string& value) const; bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value); void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const; void enumerate(const std::string& key, Keys& range) const;
std::string translateKey(const std::string& key) const; std::string translateKey(const std::string& key) const;
~ConfigurationView(); ~ConfigurationView();
private: private:
ConfigurationView(const ConfigurationView&); ConfigurationView(const ConfigurationView&);
ConfigurationView& operator = (const ConfigurationView&); ConfigurationView& operator = (const ConfigurationView&);
std::string _prefix; std::string _prefix;
AbstractConfiguration* _pConfig; AbstractConfiguration* _pConfig;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_ConfigurationView_INCLUDED #endif // Util_ConfigurationView_INCLUDED

View File

@@ -1,114 +1,114 @@
// //
// FilesystemConfiguration.h // FilesystemConfiguration.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/FilesystemConfiguration.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/FilesystemConfiguration.h#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: FilesystemConfiguration // Module: FilesystemConfiguration
// //
// Definition of the FilesystemConfiguration class. // Definition of the FilesystemConfiguration 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 Util_FilesystemConfiguration_INCLUDED #ifndef Util_FilesystemConfiguration_INCLUDED
#define Util_FilesystemConfiguration_INCLUDED #define Util_FilesystemConfiguration_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
#include "Poco/Path.h" #include "Poco/Path.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API FilesystemConfiguration: public AbstractConfiguration class Util_API FilesystemConfiguration: public AbstractConfiguration
/// An implementation of AbstractConfiguration that stores configuration data /// An implementation of AbstractConfiguration that stores configuration data
/// in a directory hierarchy in the filesystem. /// in a directory hierarchy in the filesystem.
/// ///
/// Every period-separated part of a property name is represented /// Every period-separated part of a property name is represented
/// as a directory in the filesystem, relative to the base directory. /// as a directory in the filesystem, relative to the base directory.
/// Values are stored in files named "data". /// Values are stored in files named "data".
/// ///
/// All changes to properties are immediately persisted in the filesystem. /// All changes to properties are immediately persisted in the filesystem.
/// ///
/// For example, a configuration consisting of the properties /// For example, a configuration consisting of the properties
/// ///
/// logging.loggers.root.channel.class = ConsoleChannel /// logging.loggers.root.channel.class = ConsoleChannel
/// logging.loggers.app.name = Application /// logging.loggers.app.name = Application
/// logging.loggers.app.channel = c1 /// logging.loggers.app.channel = c1
/// logging.formatters.f1.class = PatternFormatter /// logging.formatters.f1.class = PatternFormatter
/// logging.formatters.f1.pattern = [%p] %t /// logging.formatters.f1.pattern = [%p] %t
/// ///
/// is stored in the filesystem as follows: /// is stored in the filesystem as follows:
/// ///
/// logging/ /// logging/
/// loggers/ /// loggers/
/// root/ /// root/
/// channel/ /// channel/
/// class/ /// class/
/// data ("ConsoleChannel") /// data ("ConsoleChannel")
/// app/ /// app/
/// name/ /// name/
/// data ("Application") /// data ("Application")
/// channel/ /// channel/
/// data ("c1") /// data ("c1")
/// formatters/ /// formatters/
/// f1/ /// f1/
/// class/ /// class/
/// data ("PatternFormatter") /// data ("PatternFormatter")
/// pattern/ /// pattern/
/// data ("[%p] %t") /// data ("[%p] %t")
{ {
public: public:
FilesystemConfiguration(const std::string& path); FilesystemConfiguration(const std::string& path);
/// Creates a FilesystemConfiguration using the given path. /// Creates a FilesystemConfiguration using the given path.
/// All directories are created as necessary. /// All directories are created as necessary.
void clear(); void clear();
/// Clears the configuration by erasing the configuration /// Clears the configuration by erasing the configuration
/// directory and all its subdirectories and files. /// directory and all its subdirectories and files.
protected: protected:
bool getRaw(const std::string& key, std::string& value) const; bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value); void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const; void enumerate(const std::string& key, Keys& range) const;
Poco::Path keyToPath(const std::string& key) const; Poco::Path keyToPath(const std::string& key) const;
~FilesystemConfiguration(); ~FilesystemConfiguration();
private: private:
Poco::Path _path; Poco::Path _path;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_FilesystemConfiguration_INCLUDED #endif // Util_FilesystemConfiguration_INCLUDED

View File

@@ -1,221 +1,221 @@
// //
// HelpFormatter.h // HelpFormatter.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/HelpFormatter.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/HelpFormatter.h#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: HelpFormatter // Module: HelpFormatter
// //
// Definition of the HelpFormatter class. // Definition of the HelpFormatter 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 Util_HelpFormatter_INCLUDED #ifndef Util_HelpFormatter_INCLUDED
#define Util_HelpFormatter_INCLUDED #define Util_HelpFormatter_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include <ostream> #include <ostream>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class OptionSet; class OptionSet;
class Option; class Option;
class Util_API HelpFormatter class Util_API HelpFormatter
/// This class formats a help message from an OptionSet. /// This class formats a help message from an OptionSet.
{ {
public: public:
HelpFormatter(const OptionSet& options); HelpFormatter(const OptionSet& options);
/// Creates the HelpFormatter, using the given /// Creates the HelpFormatter, using the given
/// options. /// options.
/// ///
/// The HelpFormatter just stores a reference /// The HelpFormatter just stores a reference
/// to the given OptionSet, so the OptionSet must not /// to the given OptionSet, so the OptionSet must not
/// be destroyed during the lifetime of the HelpFormatter. /// be destroyed during the lifetime of the HelpFormatter.
~HelpFormatter(); ~HelpFormatter();
/// Destroys the HelpFormatter. /// Destroys the HelpFormatter.
void setCommand(const std::string& command); void setCommand(const std::string& command);
/// Sets the command name. /// Sets the command name.
const std::string& getCommand() const; const std::string& getCommand() const;
/// Returns the command name. /// Returns the command name.
void setUsage(const std::string& usage); void setUsage(const std::string& usage);
/// Sets the usage string. /// Sets the usage string.
const std::string& getUsage() const; const std::string& getUsage() const;
/// Returns the usage string. /// Returns the usage string.
void setHeader(const std::string& header); void setHeader(const std::string& header);
/// Sets the header string. /// Sets the header string.
const std::string& getHeader() const; const std::string& getHeader() const;
/// Returns the header string. /// Returns the header string.
void setFooter(const std::string& footer); void setFooter(const std::string& footer);
/// Sets the footer string. /// Sets the footer string.
const std::string& getFooter() const; const std::string& getFooter() const;
/// Returns the footer string. /// Returns the footer string.
void format(std::ostream& ostr) const; void format(std::ostream& ostr) const;
/// Writes the formatted help text to the given stream. /// Writes the formatted help text to the given stream.
void setWidth(int width); void setWidth(int width);
/// Sets the line width for the formatted help text. /// Sets the line width for the formatted help text.
int getWidth() const; int getWidth() const;
/// Returns the line width for the formatted help text. /// Returns the line width for the formatted help text.
/// ///
/// The default width is 72. /// The default width is 72.
void setIndent(int indent); void setIndent(int indent);
/// Sets the indentation for description continuation lines. /// Sets the indentation for description continuation lines.
int getIndent() const; int getIndent() const;
/// Returns the indentation for description continuation lines. /// Returns the indentation for description continuation lines.
void setAutoIndent(); void setAutoIndent();
/// Sets the indentation for description continuation lines so that /// Sets the indentation for description continuation lines so that
/// the description text is left-aligned. /// the description text is left-aligned.
void setUnixStyle(bool flag); void setUnixStyle(bool flag);
/// Enables Unix-style options. Both short and long option names /// Enables Unix-style options. Both short and long option names
/// are printed if Unix-style is set. Otherwise, only long option /// are printed if Unix-style is set. Otherwise, only long option
/// names are printed. /// names are printed.
bool isUnixStyle() const; bool isUnixStyle() const;
/// Returns if Unix-style options are set. /// Returns if Unix-style options are set.
std::string shortPrefix() const; std::string shortPrefix() const;
/// Returns the platform-specific prefix for short options. /// Returns the platform-specific prefix for short options.
/// "-" on Unix, "/" on Windows and OpenVMS. /// "-" on Unix, "/" on Windows and OpenVMS.
std::string longPrefix() const; std::string longPrefix() const;
/// Returns the platform-specific prefix for long options. /// Returns the platform-specific prefix for long options.
/// "--" on Unix, "/" on Windows and OpenVMS. /// "--" on Unix, "/" on Windows and OpenVMS.
protected: protected:
int calcIndent() const; int calcIndent() const;
/// Calculates the indentation for the option descriptions /// Calculates the indentation for the option descriptions
/// from the given options. /// from the given options.
void formatOptions(std::ostream& ostr) const; void formatOptions(std::ostream& ostr) const;
/// Formats all options. /// Formats all options.
void formatOption(std::ostream& ostr, const Option& option, int width) const; void formatOption(std::ostream& ostr, const Option& option, int width) const;
/// Formats an option, using the platform-specific /// Formats an option, using the platform-specific
/// prefixes. /// prefixes.
void formatText(std::ostream& ostr, const std::string& text, int indent) const; void formatText(std::ostream& ostr, const std::string& text, int indent) const;
/// Formats the given text. /// Formats the given text.
void formatText(std::ostream& ostr, const std::string& text, int indent, int firstIndent) const; void formatText(std::ostream& ostr, const std::string& text, int indent, int firstIndent) const;
/// Formats the given text. /// Formats the given text.
void formatWord(std::ostream& ostr, int& pos, const std::string& word, int indent) const; void formatWord(std::ostream& ostr, int& pos, const std::string& word, int indent) const;
/// Formats the given word. /// Formats the given word.
void clearWord(std::ostream& ostr, int& pos, std::string& word, int indent) const; void clearWord(std::ostream& ostr, int& pos, std::string& word, int indent) const;
/// Formats and then clears the given word. /// Formats and then clears the given word.
private: private:
HelpFormatter(const HelpFormatter&); HelpFormatter(const HelpFormatter&);
HelpFormatter& operator = (const HelpFormatter&); HelpFormatter& operator = (const HelpFormatter&);
const OptionSet& _options; const OptionSet& _options;
int _width; int _width;
int _indent; int _indent;
std::string _command; std::string _command;
std::string _usage; std::string _usage;
std::string _header; std::string _header;
std::string _footer; std::string _footer;
bool _unixStyle; bool _unixStyle;
static const int TAB_WIDTH; static const int TAB_WIDTH;
static const int LINE_WIDTH; static const int LINE_WIDTH;
}; };
// //
// inlines // inlines
// //
inline int HelpFormatter::getWidth() const inline int HelpFormatter::getWidth() const
{ {
return _width; return _width;
} }
inline int HelpFormatter::getIndent() const inline int HelpFormatter::getIndent() const
{ {
return _indent; return _indent;
} }
inline const std::string& HelpFormatter::getCommand() const inline const std::string& HelpFormatter::getCommand() const
{ {
return _command; return _command;
} }
inline const std::string& HelpFormatter::getUsage() const inline const std::string& HelpFormatter::getUsage() const
{ {
return _usage; return _usage;
} }
inline const std::string& HelpFormatter::getHeader() const inline const std::string& HelpFormatter::getHeader() const
{ {
return _header; return _header;
} }
inline const std::string& HelpFormatter::getFooter() const inline const std::string& HelpFormatter::getFooter() const
{ {
return _footer; return _footer;
} }
inline bool HelpFormatter::isUnixStyle() const inline bool HelpFormatter::isUnixStyle() const
{ {
return _unixStyle; return _unixStyle;
} }
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_HelpFormatter_INCLUDED #endif // Util_HelpFormatter_INCLUDED

View File

@@ -1,115 +1,115 @@
// //
// IniFileConfiguration.h // IniFileConfiguration.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/IniFileConfiguration.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/IniFileConfiguration.h#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: IniFileConfiguration // Module: IniFileConfiguration
// //
// Definition of the IniFileConfiguration class. // Definition of the IniFileConfiguration 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 Util_IniFileConfiguration_INCLUDED #ifndef Util_IniFileConfiguration_INCLUDED
#define Util_IniFileConfiguration_INCLUDED #define Util_IniFileConfiguration_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
#include <map> #include <map>
#include <istream> #include <istream>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API IniFileConfiguration: public AbstractConfiguration class Util_API IniFileConfiguration: public AbstractConfiguration
/// This implementation of a Configuration reads properties /// This implementation of a Configuration reads properties
/// from a legacy Windows initialization (.ini) file. /// from a legacy Windows initialization (.ini) file.
/// ///
/// The file syntax is implemented as follows. /// The file syntax is implemented as follows.
/// - a line starting with a semicolon is treated as a comment and ignored /// - a line starting with a semicolon is treated as a comment and ignored
/// - a line starting with a square bracket denotes a section key [<key>] /// - a line starting with a square bracket denotes a section key [<key>]
/// - every other line denotes a property assignment in the form /// - every other line denotes a property assignment in the form
/// <value key> = <value> /// <value key> = <value>
/// ///
/// The name of a property is composed of the section key and the value key, /// The name of a property is composed of the section key and the value key,
/// separated by a period (<section key>.<value key>). /// separated by a period (<section key>.<value key>).
/// ///
/// Property names are not case sensitive. Leading and trailing whitespace is /// Property names are not case sensitive. Leading and trailing whitespace is
/// removed from both keys and values. /// removed from both keys and values.
/// ///
/// Setting properties is not supported. An attempt to set a property results /// Setting properties is not supported. An attempt to set a property results
/// in a NotImplementedException being thrown. /// in a NotImplementedException being thrown.
{ {
public: public:
IniFileConfiguration(); IniFileConfiguration();
/// Creates an empty IniFileConfiguration. /// Creates an empty IniFileConfiguration.
IniFileConfiguration(std::istream& istr); IniFileConfiguration(std::istream& istr);
/// Creates an IniFileConfiguration and loads the configuration data /// Creates an IniFileConfiguration and loads the configuration data
/// from the given stream, which must be in initialization file format. /// from the given stream, which must be in initialization file format.
IniFileConfiguration(const std::string& path); IniFileConfiguration(const std::string& path);
/// Creates an IniFileConfiguration and loads the configuration data /// Creates an IniFileConfiguration and loads the configuration data
/// from the given file, which must be in initialization file format. /// from the given file, which must be in initialization file format.
void load(std::istream& istr); void load(std::istream& istr);
/// Loads the configuration data from the given stream, which /// Loads the configuration data from the given stream, which
/// must be in initialization file format. /// must be in initialization file format.
void load(const std::string& path); void load(const std::string& path);
/// Loads the configuration data from the given file, which /// Loads the configuration data from the given file, which
/// must be in initialization file format. /// must be in initialization file format.
protected: protected:
bool getRaw(const std::string& key, std::string& value) const; bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value); void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const; void enumerate(const std::string& key, Keys& range) const;
~IniFileConfiguration(); ~IniFileConfiguration();
private: private:
void parseLine(std::istream& istr); void parseLine(std::istream& istr);
struct ICompare struct ICompare
{ {
bool operator () (const std::string& s1, const std::string& s2) const; bool operator () (const std::string& s1, const std::string& s2) const;
}; };
typedef std::map<std::string, std::string, ICompare> IStringMap; typedef std::map<std::string, std::string, ICompare> IStringMap;
IStringMap _map; IStringMap _map;
std::string _sectionKey; std::string _sectionKey;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_IniFileConfiguration_INCLUDED #endif // Util_IniFileConfiguration_INCLUDED

View File

@@ -1,78 +1,78 @@
// //
// IntValidator.h // IntValidator.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/IntValidator.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/IntValidator.h#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: IntValidator // Module: IntValidator
// //
// Definition of the IntValidator class. // Definition of the IntValidator 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 Util_IntValidator_INCLUDED #ifndef Util_IntValidator_INCLUDED
#define Util_IntValidator_INCLUDED #define Util_IntValidator_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/Validator.h" #include "Poco/Util/Validator.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API IntValidator: public Validator class Util_API IntValidator: public Validator
/// The IntValidator tests whether the option argument, /// The IntValidator tests whether the option argument,
/// which must be an integer, lies within a given range. /// which must be an integer, lies within a given range.
{ {
public: public:
IntValidator(int min, int max); IntValidator(int min, int max);
/// Creates the IntValidator. /// Creates the IntValidator.
~IntValidator(); ~IntValidator();
/// Destroys the IntValidator. /// Destroys the IntValidator.
void validate(const Option& option, const std::string& value); void validate(const Option& option, const std::string& value);
/// Validates the value for the given option by /// Validates the value for the given option by
/// testing whether it's an integer that lies within /// testing whether it's an integer that lies within
/// a given range. /// a given range.
private: private:
IntValidator(); IntValidator();
int _min; int _min;
int _max; int _max;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_IntValidator_INCLUDED #endif // Util_IntValidator_INCLUDED

View File

@@ -1,110 +1,110 @@
// //
// LayeredConfiguration.h // LayeredConfiguration.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/LayeredConfiguration.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/LayeredConfiguration.h#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: LayeredConfiguration // Module: LayeredConfiguration
// //
// Definition of the LayeredConfiguration class. // Definition of the LayeredConfiguration 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 Util_LayeredConfiguration_INCLUDED #ifndef Util_LayeredConfiguration_INCLUDED
#define Util_LayeredConfiguration_INCLUDED #define Util_LayeredConfiguration_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include <vector> #include <vector>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API LayeredConfiguration: public AbstractConfiguration class Util_API LayeredConfiguration: public AbstractConfiguration
/// A LayeredConfiguration consists of a number of AbstractConfigurations. /// A LayeredConfiguration consists of a number of AbstractConfigurations.
/// ///
/// When reading a configuration property in a LayeredConfiguration, /// When reading a configuration property in a LayeredConfiguration,
/// all added configurations are searched, from the first added to the last added. /// all added configurations are searched, from the first added to the last added.
/// ///
/// When setting a property, the property is always written to the last configuration /// When setting a property, the property is always written to the last configuration
/// added. If no configurations have been added to the LayeredConfiguration, and an /// added. If no configurations have been added to the LayeredConfiguration, and an
/// attempt is made to set a property, a RuntimeException is thrown. /// attempt is made to set a property, a RuntimeException is thrown.
{ {
public: public:
LayeredConfiguration(); LayeredConfiguration();
/// Creates the LayeredConfiguration. /// Creates the LayeredConfiguration.
void add(AbstractConfiguration* pConfig); void add(AbstractConfiguration* pConfig);
/// Adds a configuration to the back of the LayeredConfiguration. /// Adds a configuration to the back of the LayeredConfiguration.
/// The LayeredConfiguration does not take ownership of the given /// The LayeredConfiguration does not take ownership of the given
/// configuration. In other words, the configuration's reference /// configuration. In other words, the configuration's reference
/// count is incremented. /// count is incremented.
void add(AbstractConfiguration* pConfig, bool shared); void add(AbstractConfiguration* pConfig, bool shared);
/// Adds a configuration to the back of the LayeredConfiguration. /// Adds a configuration to the back of the LayeredConfiguration.
/// If shared is false, the LayeredConfiguration takes ownership /// If shared is false, the LayeredConfiguration takes ownership
/// of the given configuration (and the configuration's reference /// of the given configuration (and the configuration's reference
/// count remains unchanged). /// count remains unchanged).
void addFront(AbstractConfiguration* pConfig); void addFront(AbstractConfiguration* pConfig);
/// Adds a configuration to the front of the LayeredConfiguration. /// Adds a configuration to the front of the LayeredConfiguration.
/// The LayeredConfiguration does not take ownership of the given /// The LayeredConfiguration does not take ownership of the given
/// configuration. In other words, the configuration's reference /// configuration. In other words, the configuration's reference
/// count is incremented. /// count is incremented.
void addFront(AbstractConfiguration* pConfig, bool shared); void addFront(AbstractConfiguration* pConfig, bool shared);
/// Adds a configuration to the front of the LayeredConfiguration. /// Adds a configuration to the front of the LayeredConfiguration.
/// If shared is true, the LayeredConfiguration takes ownership /// If shared is true, the LayeredConfiguration takes ownership
/// of the given configuration. /// of the given configuration.
protected: protected:
bool getRaw(const std::string& key, std::string& value) const; bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value); void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const; void enumerate(const std::string& key, Keys& range) const;
~LayeredConfiguration(); ~LayeredConfiguration();
private: private:
LayeredConfiguration(const LayeredConfiguration&); LayeredConfiguration(const LayeredConfiguration&);
LayeredConfiguration& operator = (const LayeredConfiguration&); LayeredConfiguration& operator = (const LayeredConfiguration&);
typedef Poco::AutoPtr<AbstractConfiguration> ConfigPtr; typedef Poco::AutoPtr<AbstractConfiguration> ConfigPtr;
typedef std::vector<ConfigPtr> ConfigVec; typedef std::vector<ConfigPtr> ConfigVec;
ConfigVec _configs; ConfigVec _configs;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_LayeredConfiguration_INCLUDED #endif // Util_LayeredConfiguration_INCLUDED

View File

@@ -1,161 +1,161 @@
// //
// LoggingConfigurator.h // LoggingConfigurator.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/LoggingConfigurator.h#2 $ // $Id: //poco/1.2/Util/include/Poco/Util/LoggingConfigurator.h#2 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: LoggingConfigurator // Module: LoggingConfigurator
// //
// Definition of the LoggingConfigurator class. // Definition of the LoggingConfigurator 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 Util_LoggingConfigurator_INCLUDED #ifndef Util_LoggingConfigurator_INCLUDED
#define Util_LoggingConfigurator_INCLUDED #define Util_LoggingConfigurator_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Formatter.h" #include "Poco/Formatter.h"
#include "Poco/Channel.h" #include "Poco/Channel.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class AbstractConfiguration; class AbstractConfiguration;
class Util_API LoggingConfigurator class Util_API LoggingConfigurator
/// This utility class uses a configuration object to configure the /// This utility class uses a configuration object to configure the
/// logging subsystem of an application. /// logging subsystem of an application.
/// ///
/// The LoggingConfigurator sets up and connects formatters, channels /// The LoggingConfigurator sets up and connects formatters, channels
/// and loggers. To accomplish its work, the LoggingConfigurator relies on the /// and loggers. To accomplish its work, the LoggingConfigurator relies on the
/// functionality provided by the LoggingFactory und LoggingRegistry classes. /// functionality provided by the LoggingFactory und LoggingRegistry classes.
/// ///
/// The LoggingConfigurator expects all configuration data to be under a root /// The LoggingConfigurator expects all configuration data to be under a root
/// property named "logging". /// property named "logging".
/// ///
/// Configuring Formatters /// Configuring Formatters
/// ///
/// A formatter is configured using the "logging.formatters" property. Every /// A formatter is configured using the "logging.formatters" property. Every
/// formatter has an internal name, which is only used for referring to it /// formatter has an internal name, which is only used for referring to it
/// during configuration time. This name becomes part of the property name. /// during configuration time. This name becomes part of the property name.
/// Every formatter has a mandatory "class" property, which specifies the actual /// Every formatter has a mandatory "class" property, which specifies the actual
/// class implementing the formatter. Any other properties are passed on to /// class implementing the formatter. Any other properties are passed on to
/// the formatter by calling its setProperty() method. /// the formatter by calling its setProperty() method.
/// ///
/// A typical formatter definition looks as follows: /// A typical formatter definition looks as follows:
/// logging.formatters.f1.class = PatternFormatter /// logging.formatters.f1.class = PatternFormatter
/// logging.formatters.f1.pattern = %s: [%p] %t /// logging.formatters.f1.pattern = %s: [%p] %t
/// logging.formatters.f1.times = UTC /// logging.formatters.f1.times = UTC
/// ///
/// Configuring Channels /// Configuring Channels
/// ///
/// A channel is configured using the "logging.channels" property. Like with /// A channel is configured using the "logging.channels" property. Like with
/// Formatters, every channel has an internal name, which is used during /// Formatters, every channel has an internal name, which is used during
/// configuration only. The name becomes part of the property name. /// configuration only. The name becomes part of the property name.
/// Every channel has a mandatory "class" property, which specifies the actual /// Every channel has a mandatory "class" property, which specifies the actual
/// class implementing the channel. Any other properties are passed on to /// class implementing the channel. Any other properties are passed on to
/// the formatter by calling its setProperty() method. /// the formatter by calling its setProperty() method.
/// ///
/// For convenience, the "formatter" property of a channel is treated /// For convenience, the "formatter" property of a channel is treated
/// specifically. The "formatter" property can either be used to refer to /// specifically. The "formatter" property can either be used to refer to
/// an already defined formatter, or it can be used to specify an "inline" /// an already defined formatter, or it can be used to specify an "inline"
/// formatter definition. In either case, when a "formatter" property is /// formatter definition. In either case, when a "formatter" property is
/// present, the channel is automatically "wrapped" in a FormattingChannel /// present, the channel is automatically "wrapped" in a FormattingChannel
/// object. /// object.
/// ///
/// Similarly, a channel supports also a "pattern" property, which results /// Similarly, a channel supports also a "pattern" property, which results
/// in the automatic instantiation of a FormattingChannel object with a /// in the automatic instantiation of a FormattingChannel object with a
/// connected PatternFormatter. /// connected PatternFormatter.
/// ///
/// Examples: /// Examples:
/// logging.channels.c1.class = ConsoleChannel /// logging.channels.c1.class = ConsoleChannel
/// logging.channels.c1.formatter = f1 /// logging.channels.c1.formatter = f1
/// logging.channels.c2.class = FileChannel /// logging.channels.c2.class = FileChannel
/// logging.channels.c2.path = ${system.tempDir}/sample.log /// logging.channels.c2.path = ${system.tempDir}/sample.log
/// logging.channels.c2.formatter.class = PatternFormatter /// logging.channels.c2.formatter.class = PatternFormatter
/// logging.channels.c2.formatter.pattern = %s: [%p] %t /// logging.channels.c2.formatter.pattern = %s: [%p] %t
/// logging.channels.c3.class = ConsoleChannel /// logging.channels.c3.class = ConsoleChannel
/// logging.channels.c3.pattern = %s: [%p] %t /// logging.channels.c3.pattern = %s: [%p] %t
/// ///
/// Configuring Loggers /// Configuring Loggers
/// ///
/// A logger is configured using the "logging.loggers" property. Like with /// A logger is configured using the "logging.loggers" property. Like with
/// channels and formatters, every logger has an internal name, which, however, /// channels and formatters, every logger has an internal name, which, however,
/// is only used to ensure the uniqueness of the property names. Note that this /// is only used to ensure the uniqueness of the property names. Note that this
/// name is different from the logger's full name, which is used to access /// name is different from the logger's full name, which is used to access
/// the logger at runtime. /// the logger at runtime.
/// Every logger except the root logger has a mandatory "name" property which /// Every logger except the root logger has a mandatory "name" property which
/// is used to specify the logger's full name. /// is used to specify the logger's full name.
/// Furthermore, a "channel" property is supported, which can either refer /// Furthermore, a "channel" property is supported, which can either refer
/// to a named channel, or which can contain an inline channel definition. /// to a named channel, or which can contain an inline channel definition.
/// ///
/// Examples: /// Examples:
/// logging.loggers.root.channel = c1 /// logging.loggers.root.channel = c1
/// logging.loggers.root.level = warning /// logging.loggers.root.level = warning
/// logging.loggers.l1.name = logger1 /// logging.loggers.l1.name = logger1
/// logging.loggers.l1.channel.class = ConsoleChannel /// logging.loggers.l1.channel.class = ConsoleChannel
/// logging.loggers.l1.channel.pattern = %s: [%p] %t /// logging.loggers.l1.channel.pattern = %s: [%p] %t
/// logging.loggers.l1.level = information /// logging.loggers.l1.level = information
{ {
public: public:
LoggingConfigurator(); LoggingConfigurator();
/// Creates the LoggingConfigurator. /// Creates the LoggingConfigurator.
~LoggingConfigurator(); ~LoggingConfigurator();
/// Destroys the LoggingConfigurator. /// Destroys the LoggingConfigurator.
void configure(AbstractConfiguration* pConfig); void configure(AbstractConfiguration* pConfig);
/// Configures the logging subsystem based on /// Configures the logging subsystem based on
/// the given configuration. /// the given configuration.
/// ///
/// A ConfigurationView can be used to pass only /// A ConfigurationView can be used to pass only
/// a part of a larger configuration. /// a part of a larger configuration.
private: private:
void configureFormatters(AbstractConfiguration* pConfig); void configureFormatters(AbstractConfiguration* pConfig);
void configureChannels(AbstractConfiguration* pConfig); void configureChannels(AbstractConfiguration* pConfig);
void configureLoggers(AbstractConfiguration* pConfig); void configureLoggers(AbstractConfiguration* pConfig);
Poco::Formatter* createFormatter(AbstractConfiguration* pConfig); Poco::Formatter* createFormatter(AbstractConfiguration* pConfig);
Poco::Channel* createChannel(AbstractConfiguration* pConfig); Poco::Channel* createChannel(AbstractConfiguration* pConfig);
void configureChannel(Channel* pChannel, AbstractConfiguration* pConfig); void configureChannel(Channel* pChannel, AbstractConfiguration* pConfig);
void configureLogger(AbstractConfiguration* pConfig); void configureLogger(AbstractConfiguration* pConfig);
LoggingConfigurator(const LoggingConfigurator&); LoggingConfigurator(const LoggingConfigurator&);
LoggingConfigurator& operator = (const LoggingConfigurator&); LoggingConfigurator& operator = (const LoggingConfigurator&);
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_LoggingConfigurator_INCLUDED #endif // Util_LoggingConfigurator_INCLUDED

View File

@@ -1,74 +1,74 @@
// //
// LoggingSubsystem.h // LoggingSubsystem.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/LoggingSubsystem.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/LoggingSubsystem.h#1 $
// //
// Library: Util // Library: Util
// Package: Application // Package: Application
// Module: LoggingSubsystem // Module: LoggingSubsystem
// //
// Definition of the LoggingSubsystem class. // Definition of the LoggingSubsystem 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 Util_LoggingSubsystem_INCLUDED #ifndef Util_LoggingSubsystem_INCLUDED
#define Util_LoggingSubsystem_INCLUDED #define Util_LoggingSubsystem_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/Subsystem.h" #include "Poco/Util/Subsystem.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API LoggingSubsystem: public Subsystem class Util_API LoggingSubsystem: public Subsystem
/// The LoggingSubsystem class initializes the logging /// The LoggingSubsystem class initializes the logging
/// framework using the LoggingConfigurator. /// framework using the LoggingConfigurator.
/// ///
/// It also sets the Application's logger to /// It also sets the Application's logger to
/// the logger specified by the "application.logger" /// the logger specified by the "application.logger"
/// property, or to "Application" if the property /// property, or to "Application" if the property
/// is not specified. /// is not specified.
{ {
public: public:
LoggingSubsystem(); LoggingSubsystem();
const char* name() const; const char* name() const;
protected: protected:
void initialize(Application& self); void initialize(Application& self);
void uninitialize(); void uninitialize();
~LoggingSubsystem(); ~LoggingSubsystem();
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_LoggingSubsystem_INCLUDED #endif // Util_LoggingSubsystem_INCLUDED

View File

@@ -1,82 +1,82 @@
// //
// MapConfiguration.h // MapConfiguration.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/MapConfiguration.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/MapConfiguration.h#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: MapConfiguration // Module: MapConfiguration
// //
// Definition of the MapConfiguration class. // Definition of the MapConfiguration 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 Util_MapConfiguration_INCLUDED #ifndef Util_MapConfiguration_INCLUDED
#define Util_MapConfiguration_INCLUDED #define Util_MapConfiguration_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
#include <map> #include <map>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API MapConfiguration: public AbstractConfiguration class Util_API MapConfiguration: public AbstractConfiguration
/// An implementation of AbstractConfiguration that stores configuration data in a map. /// An implementation of AbstractConfiguration that stores configuration data in a map.
{ {
public: public:
MapConfiguration(); MapConfiguration();
/// Creates an empty MapConfiguration. /// Creates an empty MapConfiguration.
void clear(); void clear();
/// Clears the configuration. /// Clears the configuration.
protected: protected:
typedef std::map<std::string, std::string> StringMap; typedef std::map<std::string, std::string> StringMap;
typedef StringMap::const_iterator iterator; typedef StringMap::const_iterator iterator;
bool getRaw(const std::string& key, std::string& value) const; bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value); void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const; void enumerate(const std::string& key, Keys& range) const;
~MapConfiguration(); ~MapConfiguration();
iterator begin() const; iterator begin() const;
iterator end() const; iterator end() const;
private: private:
StringMap _map; StringMap _map;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_MapConfiguration_INCLUDED #endif // Util_MapConfiguration_INCLUDED

View File

@@ -1,337 +1,337 @@
// //
// Option.h // Option.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/Option.h#2 $ // $Id: //poco/1.2/Util/include/Poco/Util/Option.h#2 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: Option // Module: Option
// //
// Definition of the Option class. // Definition of the Option 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 Util_Option_INCLUDED #ifndef Util_Option_INCLUDED
#define Util_Option_INCLUDED #define Util_Option_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/OptionCallback.h" #include "Poco/Util/OptionCallback.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Application; class Application;
class Validator; class Validator;
class Util_API Option class Util_API Option
/// This class represents and stores the properties /// This class represents and stores the properties
/// of a command line option. /// of a command line option.
/// ///
/// An option has a full name, an optional short name, /// An option has a full name, an optional short name,
/// a description (used for printing a usage statement), /// a description (used for printing a usage statement),
/// and an optional argument name. /// and an optional argument name.
/// An option can be optional or required. /// An option can be optional or required.
/// An option can be repeatable, which means that it can /// An option can be repeatable, which means that it can
/// be given more than once on the command line. /// be given more than once on the command line.
/// ///
/// An option can be part of an option group. At most one /// An option can be part of an option group. At most one
/// option of each group may be specified on the command /// option of each group may be specified on the command
/// line. /// line.
/// ///
/// An option can be bound to a configuration property. /// An option can be bound to a configuration property.
/// In this case, a configuration property will automatically /// In this case, a configuration property will automatically
/// receive the option's argument value. /// receive the option's argument value.
/// ///
/// A callback method can be specified for options. This method /// A callback method can be specified for options. This method
/// is called whenever an option is specified on the command line. /// is called whenever an option is specified on the command line.
/// ///
/// Option argument values can be automatically validated using a /// Option argument values can be automatically validated using a
/// Validator. /// Validator.
/// ///
/// Option instances are value objects. /// Option instances are value objects.
/// ///
/// Typcally, after construction, an Option object is immediately /// Typcally, after construction, an Option object is immediately
/// passed to an Options object. /// passed to an Options object.
/// ///
/// An Option object can be created by chaining the constructor /// An Option object can be created by chaining the constructor
/// with any of the setter methods, as in the following example: /// with any of the setter methods, as in the following example:
/// ///
/// Option versionOpt("include", "I", "specify an include directory") /// Option versionOpt("include", "I", "specify an include directory")
/// .required(false) /// .required(false)
/// .repeatable(true) /// .repeatable(true)
/// .argument("directory"); /// .argument("directory");
{ {
public: public:
Option(); Option();
/// Creates an empty Option. /// Creates an empty Option.
Option(const Option& option); Option(const Option& option);
/// Creates an option from another one. /// Creates an option from another one.
Option(const std::string& fullName, const std::string& shortName); Option(const std::string& fullName, const std::string& shortName);
/// Creates an option with the given properties. /// Creates an option with the given properties.
Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required = false); Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required = false);
/// Creates an option with the given properties. /// Creates an option with the given properties.
Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required, const std::string& argName, bool argOptional = false); Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required, const std::string& argName, bool argOptional = false);
/// Creates an option with the given properties. /// Creates an option with the given properties.
~Option(); ~Option();
/// Destroys the Option. /// Destroys the Option.
Option& operator = (const Option& option); Option& operator = (const Option& option);
/// Assignment operator. /// Assignment operator.
void swap(Option& option); void swap(Option& option);
/// Swaps the option with another one. /// Swaps the option with another one.
Option& shortName(const std::string& name); Option& shortName(const std::string& name);
/// Sets the short name of the option. /// Sets the short name of the option.
Option& fullName(const std::string& name); Option& fullName(const std::string& name);
/// Sets the full name of the option. /// Sets the full name of the option.
Option& description(const std::string& text); Option& description(const std::string& text);
/// Sets the description of the option. /// Sets the description of the option.
Option& required(bool flag); Option& required(bool flag);
/// Sets whether the option is required (flag == true) /// Sets whether the option is required (flag == true)
/// or optional (flag == false). /// or optional (flag == false).
Option& repeatable(bool flag); Option& repeatable(bool flag);
/// Sets whether the option can be specified more than once /// Sets whether the option can be specified more than once
/// (flag == true) or at most once (flag == false). /// (flag == true) or at most once (flag == false).
Option& argument(const std::string& name, bool required = true); Option& argument(const std::string& name, bool required = true);
/// Specifies that the option takes an (optional or required) /// Specifies that the option takes an (optional or required)
/// argument. /// argument.
Option& noArgument(); Option& noArgument();
/// Specifies that the option does not take an argument (default). /// Specifies that the option does not take an argument (default).
Option& group(const std::string& group); Option& group(const std::string& group);
/// Specifies the option group the option is part of. /// Specifies the option group the option is part of.
Option& binding(const std::string& propertyName); Option& binding(const std::string& propertyName);
/// Binds the option to the configuration property with the given name. /// Binds the option to the configuration property with the given name.
/// ///
/// The configuration will automatically receive the option's argument. /// The configuration will automatically receive the option's argument.
Option& callback(const AbstractOptionCallback& cb); Option& callback(const AbstractOptionCallback& cb);
/// Binds the option to the given method. /// Binds the option to the given method.
/// ///
/// The callback method will be called when the option /// The callback method will be called when the option
/// has been specified on the command line. /// has been specified on the command line.
/// ///
/// Usage: /// Usage:
/// callback(OptionCallback<MyApplication>(this, &MyApplication::myCallback)); /// callback(OptionCallback<MyApplication>(this, &MyApplication::myCallback));
Option& validator(Validator* pValidator); Option& validator(Validator* pValidator);
/// Sets the validator for the given option. /// Sets the validator for the given option.
/// ///
/// The Option takes ownership of the Validator and /// The Option takes ownership of the Validator and
/// deletes it when it's no longer needed. /// deletes it when it's no longer needed.
const std::string& shortName() const; const std::string& shortName() const;
/// Returns the short name of the option. /// Returns the short name of the option.
const std::string& fullName() const; const std::string& fullName() const;
/// Returns the full name of the option. /// Returns the full name of the option.
const std::string& description() const; const std::string& description() const;
/// Returns the description of the option. /// Returns the description of the option.
bool required() const; bool required() const;
/// Returns true if the option is required, false if not. /// Returns true if the option is required, false if not.
bool repeatable() const; bool repeatable() const;
/// Returns true if the option can be specified more than /// Returns true if the option can be specified more than
/// once, or false if at most once. /// once, or false if at most once.
bool takesArgument() const; bool takesArgument() const;
/// Returns true if the options takes an (optional) argument. /// Returns true if the options takes an (optional) argument.
bool argumentRequired() const; bool argumentRequired() const;
/// Returns true if the argument is required. /// Returns true if the argument is required.
const std::string& argumentName() const; const std::string& argumentName() const;
/// Returns the argument name, if specified. /// Returns the argument name, if specified.
const std::string& group() const; const std::string& group() const;
/// Returns the option group the option is part of, /// Returns the option group the option is part of,
/// or an empty string, if the option is not part of /// or an empty string, if the option is not part of
/// a group. /// a group.
const std::string& binding() const; const std::string& binding() const;
/// Returns the property name the option is bound to, /// Returns the property name the option is bound to,
/// or an empty string in case it is not bound. /// or an empty string in case it is not bound.
AbstractOptionCallback* callback() const; AbstractOptionCallback* callback() const;
/// Returns a pointer to the callback method for the option, /// Returns a pointer to the callback method for the option,
/// or NULL if no callback has been specified. /// or NULL if no callback has been specified.
Validator* validator() const; Validator* validator() const;
/// Returns the option's Validator, if one has been specified, /// Returns the option's Validator, if one has been specified,
/// or NULL otherwise. /// or NULL otherwise.
bool matchesShort(const std::string& option) const; bool matchesShort(const std::string& option) const;
/// Returns true if the given option string matches the /// Returns true if the given option string matches the
/// short name. /// short name.
/// ///
/// The first characters of the option string must match /// The first characters of the option string must match
/// the short name of the option (case sensitive), /// the short name of the option (case sensitive),
/// or the option string must partially match the full /// or the option string must partially match the full
/// name (case insensitive). /// name (case insensitive).
bool matchesFull(const std::string& option) const; bool matchesFull(const std::string& option) const;
/// Returns true if the given option string matches the /// Returns true if the given option string matches the
/// full name. /// full name.
/// ///
/// The option string must match the full /// The option string must match the full
/// name (case insensitive). /// name (case insensitive).
bool matchesPartial(const std::string& option) const; bool matchesPartial(const std::string& option) const;
/// Returns true if the given option string partially matches the /// Returns true if the given option string partially matches the
/// full name. /// full name.
/// ///
/// The option string must partially match the full /// The option string must partially match the full
/// name (case insensitive). /// name (case insensitive).
void process(const std::string& option, std::string& arg) const; void process(const std::string& option, std::string& arg) const;
/// Verifies that the given option string matches the /// Verifies that the given option string matches the
/// requirements of the option, and extracts the option argument, /// requirements of the option, and extracts the option argument,
/// if present. /// if present.
/// ///
/// If the option string is okay and carries an argument, /// If the option string is okay and carries an argument,
/// the argument is returned in arg. /// the argument is returned in arg.
/// ///
/// Throws a MissingArgumentException if a required argument /// Throws a MissingArgumentException if a required argument
/// is missing. Throws an UnexpectedArgumentException if an /// is missing. Throws an UnexpectedArgumentException if an
/// argument has been found, but none is expected. /// argument has been found, but none is expected.
private: private:
std::string _shortName; std::string _shortName;
std::string _fullName; std::string _fullName;
std::string _description; std::string _description;
bool _required; bool _required;
bool _repeatable; bool _repeatable;
std::string _argName; std::string _argName;
bool _argRequired; bool _argRequired;
std::string _group; std::string _group;
std::string _binding; std::string _binding;
Validator* _pValidator; Validator* _pValidator;
AbstractOptionCallback* _pCallback; AbstractOptionCallback* _pCallback;
}; };
// //
// inlines // inlines
// //
inline const std::string& Option::shortName() const inline const std::string& Option::shortName() const
{ {
return _shortName; return _shortName;
} }
inline const std::string& Option::fullName() const inline const std::string& Option::fullName() const
{ {
return _fullName; return _fullName;
} }
inline const std::string& Option::description() const inline const std::string& Option::description() const
{ {
return _description; return _description;
} }
inline bool Option::required() const inline bool Option::required() const
{ {
return _required; return _required;
} }
inline bool Option::repeatable() const inline bool Option::repeatable() const
{ {
return _repeatable; return _repeatable;
} }
inline bool Option::takesArgument() const inline bool Option::takesArgument() const
{ {
return !_argName.empty(); return !_argName.empty();
} }
inline bool Option::argumentRequired() const inline bool Option::argumentRequired() const
{ {
return _argRequired; return _argRequired;
} }
inline const std::string& Option::argumentName() const inline const std::string& Option::argumentName() const
{ {
return _argName; return _argName;
} }
inline const std::string& Option::group() const inline const std::string& Option::group() const
{ {
return _group; return _group;
} }
inline const std::string& Option::binding() const inline const std::string& Option::binding() const
{ {
return _binding; return _binding;
} }
inline AbstractOptionCallback* Option::callback() const inline AbstractOptionCallback* Option::callback() const
{ {
return _pCallback; return _pCallback;
} }
inline Validator* Option::validator() const inline Validator* Option::validator() const
{ {
return _pValidator; return _pValidator;
} }
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_Option_INCLUDED #endif // Util_Option_INCLUDED

View File

@@ -1,131 +1,131 @@
// //
// OptionCallback.h // OptionCallback.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/OptionCallback.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/OptionCallback.h#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: OptionCallback // Module: OptionCallback
// //
// Definition of the OptionCallback class. // Definition of the OptionCallback 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 Util_OptionCallback_INCLUDED #ifndef Util_OptionCallback_INCLUDED
#define Util_OptionCallback_INCLUDED #define Util_OptionCallback_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API AbstractOptionCallback class Util_API AbstractOptionCallback
/// Base class for OptionCallback. /// Base class for OptionCallback.
{ {
public: public:
virtual void invoke(const std::string& name, const std::string& value) const = 0; virtual void invoke(const std::string& name, const std::string& value) const = 0;
/// Invokes the callback member function. /// Invokes the callback member function.
virtual AbstractOptionCallback* clone() const = 0; virtual AbstractOptionCallback* clone() const = 0;
/// Creates and returns a copy of the object. /// Creates and returns a copy of the object.
virtual ~AbstractOptionCallback(); virtual ~AbstractOptionCallback();
/// Destroys the AbstractOptionCallback. /// Destroys the AbstractOptionCallback.
protected: protected:
AbstractOptionCallback(); AbstractOptionCallback();
AbstractOptionCallback(const AbstractOptionCallback&); AbstractOptionCallback(const AbstractOptionCallback&);
}; };
template <class C> template <class C>
class OptionCallback: public AbstractOptionCallback class OptionCallback: public AbstractOptionCallback
/// This class is used as an argument to Option::callback(). /// This class is used as an argument to Option::callback().
/// ///
/// It stores a pointer to an object and a pointer to a member /// It stores a pointer to an object and a pointer to a member
/// function of the object's class. /// function of the object's class.
{ {
public: public:
typedef void (C::*Callback)(const std::string& name, const std::string& value); typedef void (C::*Callback)(const std::string& name, const std::string& value);
OptionCallback(C* pObject, Callback method): OptionCallback(C* pObject, Callback method):
_pObject(pObject), _pObject(pObject),
_method(method) _method(method)
/// Creates the OptionCallback for the given object and member function. /// Creates the OptionCallback for the given object and member function.
{ {
poco_check_ptr (pObject); poco_check_ptr (pObject);
} }
OptionCallback(const OptionCallback& cb): OptionCallback(const OptionCallback& cb):
AbstractOptionCallback(cb), AbstractOptionCallback(cb),
_pObject(cb._pObject), _pObject(cb._pObject),
_method(cb._method) _method(cb._method)
/// Creates an OptionCallback from another one. /// Creates an OptionCallback from another one.
{ {
} }
~OptionCallback() ~OptionCallback()
/// Destroys the OptionCallback. /// Destroys the OptionCallback.
{ {
} }
OptionCallback& operator = (const OptionCallback& cb) OptionCallback& operator = (const OptionCallback& cb)
{ {
if (&cb != this) if (&cb != this)
{ {
this->_pObject = cb._pObject; this->_pObject = cb._pObject;
this->_method = cb._method; this->_method = cb._method;
} }
return *this; return *this;
} }
void invoke(const std::string& name, const std::string& value) const void invoke(const std::string& name, const std::string& value) const
{ {
(_pObject->*_method)(name, value); (_pObject->*_method)(name, value);
} }
AbstractOptionCallback* clone() const AbstractOptionCallback* clone() const
{ {
return new OptionCallback(_pObject, _method); return new OptionCallback(_pObject, _method);
} }
private: private:
OptionCallback(); OptionCallback();
C* _pObject; C* _pObject;
Callback _method; Callback _method;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_OptionCallback_INCLUDED #endif // Util_OptionCallback_INCLUDED

View File

@@ -1,66 +1,66 @@
// //
// OptionException.h // OptionException.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/OptionException.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/OptionException.h#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: OptionException // Module: OptionException
// //
// Definition of the OptionException class. // Definition of the OptionException 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 Util_OptionException_INCLUDED #ifndef Util_OptionException_INCLUDED
#define Util_OptionException_INCLUDED #define Util_OptionException_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
POCO_DECLARE_EXCEPTION(Util_API, OptionException, Poco::DataException) POCO_DECLARE_EXCEPTION(Util_API, OptionException, Poco::DataException)
POCO_DECLARE_EXCEPTION(Util_API, UnknownOptionException, OptionException) POCO_DECLARE_EXCEPTION(Util_API, UnknownOptionException, OptionException)
POCO_DECLARE_EXCEPTION(Util_API, AmbiguousOptionException, OptionException) POCO_DECLARE_EXCEPTION(Util_API, AmbiguousOptionException, OptionException)
POCO_DECLARE_EXCEPTION(Util_API, MissingOptionException, OptionException) POCO_DECLARE_EXCEPTION(Util_API, MissingOptionException, OptionException)
POCO_DECLARE_EXCEPTION(Util_API, MissingArgumentException, OptionException) POCO_DECLARE_EXCEPTION(Util_API, MissingArgumentException, OptionException)
POCO_DECLARE_EXCEPTION(Util_API, InvalidArgumentException, OptionException) POCO_DECLARE_EXCEPTION(Util_API, InvalidArgumentException, OptionException)
POCO_DECLARE_EXCEPTION(Util_API, UnexpectedArgumentException, OptionException) POCO_DECLARE_EXCEPTION(Util_API, UnexpectedArgumentException, OptionException)
POCO_DECLARE_EXCEPTION(Util_API, IncompatibleOptionsException, OptionException) POCO_DECLARE_EXCEPTION(Util_API, IncompatibleOptionsException, OptionException)
POCO_DECLARE_EXCEPTION(Util_API, DuplicateOptionException, OptionException) POCO_DECLARE_EXCEPTION(Util_API, DuplicateOptionException, OptionException)
POCO_DECLARE_EXCEPTION(Util_API, EmptyOptionException, OptionException) POCO_DECLARE_EXCEPTION(Util_API, EmptyOptionException, OptionException)
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_OptionException_INCLUDED #endif // Util_OptionException_INCLUDED

View File

@@ -1,148 +1,148 @@
// //
// OptionProcessor.h // OptionProcessor.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/OptionProcessor.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/OptionProcessor.h#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: OptionProcessor // Module: OptionProcessor
// //
// Definition of the OptionProcessor class. // Definition of the OptionProcessor 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 Util_OptionProcessor_INCLUDED #ifndef Util_OptionProcessor_INCLUDED
#define Util_OptionProcessor_INCLUDED #define Util_OptionProcessor_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include <set> #include <set>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class OptionSet; class OptionSet;
class Util_API OptionProcessor class Util_API OptionProcessor
/// An OptionProcessor is used to process the command line /// An OptionProcessor is used to process the command line
/// arguments of an application. /// arguments of an application.
/// ///
/// The process() method takes an argument from the command line. /// The process() method takes an argument from the command line.
/// If that argument starts with an option prefix, the argument /// If that argument starts with an option prefix, the argument
/// is further processed. Otherwise, the argument is ignored and /// is further processed. Otherwise, the argument is ignored and
/// false is ignored. The argument must match one of the options /// false is ignored. The argument must match one of the options
/// given in the OptionSet that is passed to the OptionProcessor /// given in the OptionSet that is passed to the OptionProcessor
/// with the constructor. If an option is part of a group, at most /// with the constructor. If an option is part of a group, at most
/// one option of the group can be passed to the OptionProcessor. /// one option of the group can be passed to the OptionProcessor.
/// Otherwise an IncompatibleOptionsException is thrown. /// Otherwise an IncompatibleOptionsException is thrown.
/// If the same option is given multiple times, but the option /// If the same option is given multiple times, but the option
/// is not repeatable, a DuplicateOptionException is thrown. /// is not repeatable, a DuplicateOptionException is thrown.
/// If the option is not recognized, a UnexpectedArgumentException /// If the option is not recognized, a UnexpectedArgumentException
/// is thrown. /// is thrown.
/// If the option requires an argument, but none is given, an /// If the option requires an argument, but none is given, an
/// MissingArgumentException is thrown. /// MissingArgumentException is thrown.
/// If no argument is expected, but one is present, a /// If no argument is expected, but one is present, a
/// UnexpectedArgumentException is thrown. /// UnexpectedArgumentException is thrown.
/// If a partial option name is ambiguous, an AmbiguousOptionException /// If a partial option name is ambiguous, an AmbiguousOptionException
/// is thrown. /// is thrown.
/// ///
/// The OptionProcessor supports two modes: Unix mode and default mode. /// The OptionProcessor supports two modes: Unix mode and default mode.
/// In Unix mode, the option prefix is a dash '-'. A dash must be followed /// In Unix mode, the option prefix is a dash '-'. A dash must be followed
/// by a short option name, or another dash, followed by a (partial) /// by a short option name, or another dash, followed by a (partial)
/// long option name. /// long option name.
/// In default mode, the option prefix is a slash '/', followed by /// In default mode, the option prefix is a slash '/', followed by
/// a (partial) long option name. /// a (partial) long option name.
/// If the special option '--' is encountered in Unix mode, all following /// If the special option '--' is encountered in Unix mode, all following
/// options are ignored. /// options are ignored.
{ {
public: public:
OptionProcessor(const OptionSet& options); OptionProcessor(const OptionSet& options);
/// Creates the OptionProcessor, using the given OptionSet. /// Creates the OptionProcessor, using the given OptionSet.
~OptionProcessor(); ~OptionProcessor();
/// Destroys the OptionProcessor. /// Destroys the OptionProcessor.
void setUnixStyle(bool flag); void setUnixStyle(bool flag);
/// Enables (flag == true) or disables (flag == false) Unix-style /// Enables (flag == true) or disables (flag == false) Unix-style
/// option processing. /// option processing.
/// ///
/// If Unix-style processing is enabled, options are expected to /// If Unix-style processing is enabled, options are expected to
/// begin with a single or a double dash ('-' or '--', respectively). /// begin with a single or a double dash ('-' or '--', respectively).
/// A single dash must be followed by a short option name. A double /// A single dash must be followed by a short option name. A double
/// dash must be followed by a (partial) full option name. /// dash must be followed by a (partial) full option name.
/// ///
/// If Unix-style processing is disabled, options are expected to /// If Unix-style processing is disabled, options are expected to
/// begin with a slash ('/'), followed by a (partial) full option name. /// begin with a slash ('/'), followed by a (partial) full option name.
bool isUnixStyle() const; bool isUnixStyle() const;
/// Returns true iff Unix-style option processing is enabled. /// Returns true iff Unix-style option processing is enabled.
bool process(const std::string& argument, std::string& optionName, std::string& optionArg); bool process(const std::string& argument, std::string& optionName, std::string& optionArg);
/// Examines and processes the given command line argument. /// Examines and processes the given command line argument.
/// ///
/// If the argument begins with an option prefix, the option is processed /// If the argument begins with an option prefix, the option is processed
/// and true is returned. The full option name is stored in optionName and the /// and true is returned. The full option name is stored in optionName and the
/// option argument, if present, is stored in optionArg. /// option argument, if present, is stored in optionArg.
/// ///
/// If the option does not begin with an option prefix, false is returned. /// If the option does not begin with an option prefix, false is returned.
void checkRequired() const; void checkRequired() const;
/// Checks if all required options have been processed. /// Checks if all required options have been processed.
/// ///
/// Does nothing if all required options have been processed. /// Does nothing if all required options have been processed.
/// Throws a MissingOptionException otherwise. /// Throws a MissingOptionException otherwise.
private: private:
bool processUnix(const std::string& argument, std::string& optionName, std::string& optionArg); bool processUnix(const std::string& argument, std::string& optionName, std::string& optionArg);
bool processDefault(const std::string& argument, std::string& optionName, std::string& optionArg); bool processDefault(const std::string& argument, std::string& optionName, std::string& optionArg);
bool processCommon(const std::string& option, bool isShort, std::string& optionName, std::string& optionArg); bool processCommon(const std::string& option, bool isShort, std::string& optionName, std::string& optionArg);
const OptionSet& _options; const OptionSet& _options;
bool _unixStyle; bool _unixStyle;
bool _ignore; bool _ignore;
std::set<std::string> _groups; std::set<std::string> _groups;
std::set<std::string> _specifiedOptions; std::set<std::string> _specifiedOptions;
}; };
// //
// inlines // inlines
// //
inline bool OptionProcessor::isUnixStyle() const inline bool OptionProcessor::isUnixStyle() const
{ {
return _unixStyle; return _unixStyle;
} }
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_OptionProcessor_INCLUDED #endif // Util_OptionProcessor_INCLUDED

View File

@@ -1,110 +1,110 @@
// //
// OptionSet.h // OptionSet.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/OptionSet.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/OptionSet.h#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: OptionSet // Module: OptionSet
// //
// Definition of the OptionSet class. // Definition of the OptionSet 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 Util_OptionSet_INCLUDED #ifndef Util_OptionSet_INCLUDED
#define Util_OptionSet_INCLUDED #define Util_OptionSet_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/Option.h" #include "Poco/Util/Option.h"
#include <vector> #include <vector>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API OptionSet class Util_API OptionSet
/// A collection of Option objects. /// A collection of Option objects.
{ {
public: public:
typedef std::vector<Option> OptionVec; typedef std::vector<Option> OptionVec;
typedef OptionVec::const_iterator Iterator; typedef OptionVec::const_iterator Iterator;
OptionSet(); OptionSet();
/// Creates the OptionSet. /// Creates the OptionSet.
OptionSet(const OptionSet& options); OptionSet(const OptionSet& options);
/// Creates an option set from another one. /// Creates an option set from another one.
~OptionSet(); ~OptionSet();
/// Destroys the OptionSet. /// Destroys the OptionSet.
OptionSet& operator = (const OptionSet& options); OptionSet& operator = (const OptionSet& options);
/// Assignment operator. /// Assignment operator.
void addOption(const Option& option); void addOption(const Option& option);
/// Adds an option to the collection. /// Adds an option to the collection.
bool hasOption(const std::string& name, bool matchShort = false) const; bool hasOption(const std::string& name, bool matchShort = false) const;
/// Returns a true iff an option with the given name exists. /// Returns a true iff an option with the given name exists.
/// ///
/// The given name can either be a fully specified short name, /// The given name can either be a fully specified short name,
/// or a partially specified full name. If a partial name /// or a partially specified full name. If a partial name
/// matches more than one full name, false is returned. /// matches more than one full name, false is returned.
/// The name must either match the short or full name of an /// The name must either match the short or full name of an
/// option. Comparison case sensitive for the short name and /// option. Comparison case sensitive for the short name and
/// not case sensitive for the full name. /// not case sensitive for the full name.
const Option& getOption(const std::string& name, bool matchShort = false) const; const Option& getOption(const std::string& name, bool matchShort = false) const;
/// Returns a reference to the option with the given name. /// Returns a reference to the option with the given name.
/// ///
/// The given name can either be a fully specified short name, /// The given name can either be a fully specified short name,
/// or a partially specified full name. /// or a partially specified full name.
/// The name must either match the short or full name of an /// The name must either match the short or full name of an
/// option. Comparison case sensitive for the short name and /// option. Comparison case sensitive for the short name and
/// not case sensitive for the full name. /// not case sensitive for the full name.
/// Throws a NotFoundException if no matching option has been found. /// Throws a NotFoundException if no matching option has been found.
/// Throws an UnknownOptionException if a partial full name matches /// Throws an UnknownOptionException if a partial full name matches
/// more than one option. /// more than one option.
Iterator begin() const; Iterator begin() const;
/// Supports iterating over all options. /// Supports iterating over all options.
Iterator end() const; Iterator end() const;
/// Supports iterating over all options. /// Supports iterating over all options.
private: private:
OptionVec _options; OptionVec _options;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_OptionSet_INCLUDED #endif // Util_OptionSet_INCLUDED

View File

@@ -1,121 +1,121 @@
// //
// PropertyFileConfiguration.h // PropertyFileConfiguration.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/PropertyFileConfiguration.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/PropertyFileConfiguration.h#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: PropertyFileConfiguration // Module: PropertyFileConfiguration
// //
// Definition of the PropertyFileConfiguration class. // Definition of the PropertyFileConfiguration 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 Util_PropertyFileConfiguration_INCLUDED #ifndef Util_PropertyFileConfiguration_INCLUDED
#define Util_PropertyFileConfiguration_INCLUDED #define Util_PropertyFileConfiguration_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/MapConfiguration.h" #include "Poco/Util/MapConfiguration.h"
#include <istream> #include <istream>
#include <ostream> #include <ostream>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API PropertyFileConfiguration: public MapConfiguration class Util_API PropertyFileConfiguration: public MapConfiguration
/// This implementation of a Configuration reads properties /// This implementation of a Configuration reads properties
/// from a Java-style properties file. /// from a Java-style properties file.
/// ///
/// The file syntax is implemented as follows. /// The file syntax is implemented as follows.
/// - a line starting with a hash '#' or exclamation mark '!' is treated as a comment and ignored /// - a line starting with a hash '#' or exclamation mark '!' is treated as a comment and ignored
/// - every other line denotes a property assignment in the form /// - every other line denotes a property assignment in the form
/// <key> = <value> or /// <key> = <value> or
/// <key> : <value> /// <key> : <value>
/// ///
/// Keys and values may contain special characters represented by the following escape sequences: /// Keys and values may contain special characters represented by the following escape sequences:
/// - \t: tab (0x09) /// - \t: tab (0x09)
/// - \n: line feed (0x0a) /// - \n: line feed (0x0a)
/// - \r: carriage return (0x0d) /// - \r: carriage return (0x0d)
/// - \f: form feed (0x0c) /// - \f: form feed (0x0c)
/// ///
/// For every other sequence that starts with a backslash, the backslash is removed. /// For every other sequence that starts with a backslash, the backslash is removed.
/// Therefore, the sequence \a would just yield an 'a'. /// Therefore, the sequence \a would just yield an 'a'.
/// ///
/// A value can spread across multiple lines if the last character in a line (the character /// A value can spread across multiple lines if the last character in a line (the character
/// immediately before the carriage return or line feed character) is a single backslash. /// immediately before the carriage return or line feed character) is a single backslash.
/// ///
/// Property names are case sensitive. Leading and trailing whitespace is /// Property names are case sensitive. Leading and trailing whitespace is
/// removed from both keys and values. A property name can neither contain /// removed from both keys and values. A property name can neither contain
/// a colon ':' nor an equal sign '=' character. /// a colon ':' nor an equal sign '=' character.
{ {
public: public:
PropertyFileConfiguration(); PropertyFileConfiguration();
/// Creates an empty PropertyFileConfiguration. /// Creates an empty PropertyFileConfiguration.
PropertyFileConfiguration(std::istream& istr); PropertyFileConfiguration(std::istream& istr);
/// Creates an PropertyFileConfiguration and loads the configuration data /// Creates an PropertyFileConfiguration and loads the configuration data
/// from the given stream, which must be in properties file format. /// from the given stream, which must be in properties file format.
PropertyFileConfiguration(const std::string& path); PropertyFileConfiguration(const std::string& path);
/// Creates an PropertyFileConfiguration and loads the configuration data /// Creates an PropertyFileConfiguration and loads the configuration data
/// from the given file, which must be in properties file format. /// from the given file, which must be in properties file format.
void load(std::istream& istr); void load(std::istream& istr);
/// Loads the configuration data from the given stream, which /// Loads the configuration data from the given stream, which
/// must be in properties file format. /// must be in properties file format.
void load(const std::string& path); void load(const std::string& path);
/// Loads the configuration data from the given file, which /// Loads the configuration data from the given file, which
/// must be in properties file format. /// must be in properties file format.
void save(std::ostream& ostr) const; void save(std::ostream& ostr) const;
/// Writes the configuration data to the given stream. /// Writes the configuration data to the given stream.
/// ///
/// The data is written as a sequence of statements in the form /// The data is written as a sequence of statements in the form
/// <key>: <value> /// <key>: <value>
/// separated by a newline character. /// separated by a newline character.
void save(const std::string& path) const; void save(const std::string& path) const;
/// Writes the configuration data to the given file. /// Writes the configuration data to the given file.
protected: protected:
~PropertyFileConfiguration(); ~PropertyFileConfiguration();
private: private:
void parseLine(std::istream& istr); void parseLine(std::istream& istr);
static int readChar(std::istream& istr); static int readChar(std::istream& istr);
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_PropertyFileConfiguration_INCLUDED #endif // Util_PropertyFileConfiguration_INCLUDED

View File

@@ -1,76 +1,76 @@
// //
// RegExpValidator.h // RegExpValidator.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/RegExpValidator.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/RegExpValidator.h#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: RegExpValidator // Module: RegExpValidator
// //
// Definition of the RegExpValidator class. // Definition of the RegExpValidator 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 Util_RegExpValidator_INCLUDED #ifndef Util_RegExpValidator_INCLUDED
#define Util_RegExpValidator_INCLUDED #define Util_RegExpValidator_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/Validator.h" #include "Poco/Util/Validator.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API RegExpValidator: public Validator class Util_API RegExpValidator: public Validator
/// This validator matches the option value against /// This validator matches the option value against
/// a regular expression. /// a regular expression.
{ {
public: public:
RegExpValidator(const std::string& regexp); RegExpValidator(const std::string& regexp);
/// Creates the RegExpValidator, using the given regular expression. /// Creates the RegExpValidator, using the given regular expression.
~RegExpValidator(); ~RegExpValidator();
/// Destroys the RegExpValidator. /// Destroys the RegExpValidator.
void validate(const Option& option, const std::string& value); void validate(const Option& option, const std::string& value);
/// Validates the value for the given option by /// Validates the value for the given option by
/// matching it with the regular expression. /// matching it with the regular expression.
private: private:
RegExpValidator(); RegExpValidator();
std::string _regexp; std::string _regexp;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_RegExpValidator_INCLUDED #endif // Util_RegExpValidator_INCLUDED

View File

@@ -1,214 +1,214 @@
// //
// ServerApplication.h // ServerApplication.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/ServerApplication.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/ServerApplication.h#1 $
// //
// Library: Util // Library: Util
// Package: Application // Package: Application
// Module: ServerApplication // Module: ServerApplication
// //
// Definition of the ServerApplication class. // Definition of the ServerApplication 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 Util_ServerApplication_INCLUDED #ifndef Util_ServerApplication_INCLUDED
#define Util_ServerApplication_INCLUDED #define Util_ServerApplication_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/Application.h" #include "Poco/Util/Application.h"
#include "Poco/Event.h" #include "Poco/Event.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API ServerApplication: public Application class Util_API ServerApplication: public Application
/// A subclass of the Application class that is used /// A subclass of the Application class that is used
/// for implementing server applications. /// for implementing server applications.
/// ///
/// A ServerApplication allows for the application /// A ServerApplication allows for the application
/// to run as a Windows service or as a Unix daemon /// to run as a Windows service or as a Unix daemon
/// without the need to add extra code. /// without the need to add extra code.
/// ///
/// For a ServerApplication to work both from the command line /// For a ServerApplication to work both from the command line
/// and as a daemon or service, a few rules must be met: /// and as a daemon or service, a few rules must be met:
/// - Subsystems must be registered in the constructor. /// - Subsystems must be registered in the constructor.
/// - All non-trivial initializations must be made in the /// - All non-trivial initializations must be made in the
/// initialize() method. /// initialize() method.
/// - At the end of the main() method, waitForTerminationRequest() /// - At the end of the main() method, waitForTerminationRequest()
/// should be called. /// should be called.
/// - The main(argc, argv) function must look as follows: /// - The main(argc, argv) function must look as follows:
/// ///
/// int main(int argc, char** argv) /// int main(int argc, char** argv)
/// { /// {
/// MyServerApplication app; /// MyServerApplication app;
/// return app.run(argc, argv); /// return app.run(argc, argv);
/// } /// }
/// ///
/// The POCO_SERVER_MAIN macro can be used to implement main(argc, argv). /// The POCO_SERVER_MAIN macro can be used to implement main(argc, argv).
/// If POCO has been built with POCO_WIN32_UTF8, POCO_SERVER_MAIN supports /// If POCO has been built with POCO_WIN32_UTF8, POCO_SERVER_MAIN supports
/// Unicode command line arguments. /// Unicode command line arguments.
/// ///
/// On Windows platforms, an application built on top of the /// On Windows platforms, an application built on top of the
/// ServerApplication class can be run both from the command line /// ServerApplication class can be run both from the command line
/// or as a service. /// or as a service.
/// ///
/// To run an application as a Windows service, it must be registered /// To run an application as a Windows service, it must be registered
/// with the Windows Service Control Manager (SCM). To do this, the application /// with the Windows Service Control Manager (SCM). To do this, the application
/// can be started from the command line, with the /registerService option /// can be started from the command line, with the /registerService option
/// specified. This causes the application to register itself with the /// specified. This causes the application to register itself with the
/// SCM, and then exit. Similarly, an application registered as a service can /// SCM, and then exit. Similarly, an application registered as a service can
/// be unregistered, by specifying the /unregisterService option. /// be unregistered, by specifying the /unregisterService option.
/// The file name of the application executable (excluding the .exe suffix) /// The file name of the application executable (excluding the .exe suffix)
/// is used as the service name. Additionally, a more user-friendly name can be /// is used as the service name. Additionally, a more user-friendly name can be
/// specified, using the /displayName option (e.g., /displayName="Demo Service"). /// specified, using the /displayName option (e.g., /displayName="Demo Service").
/// ///
/// An application can determine whether it is running as a service by checking /// An application can determine whether it is running as a service by checking
/// for the "application.runAsService" configuration property. /// for the "application.runAsService" configuration property.
/// ///
/// if (config().getBool("application.runAsService", false)) /// if (config().getBool("application.runAsService", false))
/// { /// {
/// // do service specific things /// // do service specific things
/// } /// }
/// ///
/// Note that the working directory for an application running as a service /// Note that the working directory for an application running as a service
/// is the Windows system directory (e.g., C:\Windows\system32). Take this /// is the Windows system directory (e.g., C:\Windows\system32). Take this
/// into account when working with relative filesystem paths. /// into account when working with relative filesystem paths.
/// ///
/// An application registered as a Windows service can be started /// An application registered as a Windows service can be started
/// with the NET START <name> command and stopped with the NET STOP <name> /// with the NET START <name> command and stopped with the NET STOP <name>
/// command. Alternatively, the Services MMC applet can be used. /// command. Alternatively, the Services MMC applet can be used.
/// ///
/// On Unix platforms, an application built on top of the ServerApplication /// On Unix platforms, an application built on top of the ServerApplication
/// class can be optionally run as a daemon. A daemon, when launched, immediately /// class can be optionally run as a daemon. A daemon, when launched, immediately
/// forks off a background process that does the actual work. After launching /// forks off a background process that does the actual work. After launching
/// the background process, the foreground process exits. /// the background process, the foreground process exits.
/// ///
/// After the initialization is complete, but before entering the main() method, /// After the initialization is complete, but before entering the main() method,
/// the current working directory for the daemon process is changed to the root /// the current working directory for the daemon process is changed to the root
/// directory ("/"), as it is common practice for daemon processes. Therefore, be /// directory ("/"), as it is common practice for daemon processes. Therefore, be
/// careful when working with files, as relative paths may not point to where /// careful when working with files, as relative paths may not point to where
/// you expect them point to. /// you expect them point to.
/// ///
/// An application can determine whether it is running as a daemon by checking /// An application can determine whether it is running as a daemon by checking
/// for the "application.runAsDaemon" configuration property. /// for the "application.runAsDaemon" configuration property.
/// ///
/// if (config().getBool("application.runAsDaemon", false)) /// if (config().getBool("application.runAsDaemon", false))
/// { /// {
/// // do daemon specific things /// // do daemon specific things
/// } /// }
{ {
public: public:
ServerApplication(); ServerApplication();
/// Creates the ServerApplication. /// Creates the ServerApplication.
~ServerApplication(); ~ServerApplication();
/// Destroys the ServerApplication. /// Destroys the ServerApplication.
bool isInteractive() const; bool isInteractive() const;
/// Returns true if the application runs from the command line. /// Returns true if the application runs from the command line.
/// Returns false if the application runs as a Unix daemon /// Returns false if the application runs as a Unix daemon
/// or Windows service. /// or Windows service.
int run(int argc, char** argv); int run(int argc, char** argv);
/// Runs the application by performing additional initializations /// Runs the application by performing additional initializations
/// and calling the main() method. /// and calling the main() method.
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
int run(int argc, wchar_t** argv); int run(int argc, wchar_t** argv);
/// Runs the application by performing additional initializations /// Runs the application by performing additional initializations
/// and calling the main() method. /// and calling the main() method.
/// ///
/// This Windows-specific version of init is used for passing /// This Windows-specific version of init is used for passing
/// Unicode command line arguments from wmain(). /// Unicode command line arguments from wmain().
#endif #endif
protected: protected:
int run(); int run();
void waitForTerminationRequest(); void waitForTerminationRequest();
void defineOptions(OptionSet& options); void defineOptions(OptionSet& options);
void handleOption(const std::string& name, const std::string& value); void handleOption(const std::string& name, const std::string& value);
static void terminate(); static void terminate();
private: private:
#if defined(POCO_OS_FAMILY_UNIX) #if defined(POCO_OS_FAMILY_UNIX)
bool isDaemon(int argc, char** argv); bool isDaemon(int argc, char** argv);
void beDaemon(); void beDaemon();
#elif defined(POCO_OS_FAMILY_WINDOWS) #elif defined(POCO_OS_FAMILY_WINDOWS)
enum Action enum Action
{ {
SRV_RUN, SRV_RUN,
SRV_REGISTER, SRV_REGISTER,
SRV_UNREGISTER SRV_UNREGISTER
}; };
static BOOL __stdcall ConsoleCtrlHandler(DWORD ctrlType); static BOOL __stdcall ConsoleCtrlHandler(DWORD ctrlType);
static void __stdcall ServiceControlHandler(DWORD control); static void __stdcall ServiceControlHandler(DWORD control);
static void __stdcall ServiceMain(DWORD argc, LPTSTR* argv); static void __stdcall ServiceMain(DWORD argc, LPTSTR* argv);
bool hasConsole(); bool hasConsole();
bool isService(); bool isService();
void beService(); void beService();
void registerService(); void registerService();
void unregisterService(); void unregisterService();
Action _action; Action _action;
std::string _displayName; std::string _displayName;
static Poco::Event _terminated; static Poco::Event _terminated;
static SERVICE_STATUS _serviceStatus; static SERVICE_STATUS _serviceStatus;
static SERVICE_STATUS_HANDLE _serviceStatusHandle; static SERVICE_STATUS_HANDLE _serviceStatusHandle;
#endif #endif
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
// //
// Macro to implement main() // Macro to implement main()
// //
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
#define POCO_SERVER_MAIN(App) \ #define POCO_SERVER_MAIN(App) \
int wmain(int argc, wchar_t** argv) \ int wmain(int argc, wchar_t** argv) \
{ \ { \
App app; \ App app; \
return app.run(argc, argv); \ return app.run(argc, argv); \
} }
#else #else
#define POCO_SERVER_MAIN(App) \ #define POCO_SERVER_MAIN(App) \
int main(int argc, char** argv) \ int main(int argc, char** argv) \
{ \ { \
App app; \ App app; \
return app.run(argc, argv); \ return app.run(argc, argv); \
} }
#endif #endif
#endif // Util_ServerApplication_INCLUDED #endif // Util_ServerApplication_INCLUDED

View File

@@ -1,105 +1,105 @@
// //
// Subsystem.h // Subsystem.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/Subsystem.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/Subsystem.h#1 $
// //
// Library: Util // Library: Util
// Package: Application // Package: Application
// Module: Subsystem // Module: Subsystem
// //
// Definition of the Subsystem class. // Definition of the Subsystem 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 Util_Subsystem_INCLUDED #ifndef Util_Subsystem_INCLUDED
#define Util_Subsystem_INCLUDED #define Util_Subsystem_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/RefCountedObject.h" #include "Poco/RefCountedObject.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Application; class Application;
class Util_API Subsystem: public Poco::RefCountedObject class Util_API Subsystem: public Poco::RefCountedObject
/// Subsystems extend an application in a modular way. /// Subsystems extend an application in a modular way.
/// ///
/// The Subsystem class provides a common interface /// The Subsystem class provides a common interface
/// for subsystems so that subsystems can be automatically /// for subsystems so that subsystems can be automatically
/// initialized at startup and uninitialized at shutdown. /// initialized at startup and uninitialized at shutdown.
/// ///
/// Subsystems should also support dynamic reconfiguration, /// Subsystems should also support dynamic reconfiguration,
/// so that they can be reconfigured anytime during the /// so that they can be reconfigured anytime during the
/// life of a running application. /// life of a running application.
/// ///
/// The degree to which dynamic reconfiguration is supported /// The degree to which dynamic reconfiguration is supported
/// is up to the actual subsystem implementation. It can /// is up to the actual subsystem implementation. It can
/// range from ignoring the reconfiguration request (not /// range from ignoring the reconfiguration request (not
/// recommended), to changing certain settings that affect /// recommended), to changing certain settings that affect
/// the performance, to a complete reinitialization. /// the performance, to a complete reinitialization.
{ {
public: public:
Subsystem(); Subsystem();
/// Creates the Subsystem. /// Creates the Subsystem.
protected: protected:
virtual const char* name() const = 0; virtual const char* name() const = 0;
/// Returns the name of the subsystem. /// Returns the name of the subsystem.
/// Must be implemented by subclasses. /// Must be implemented by subclasses.
virtual void initialize(Application& app) = 0; virtual void initialize(Application& app) = 0;
/// Initializes the subsystem. /// Initializes the subsystem.
virtual void uninitialize() = 0; virtual void uninitialize() = 0;
/// Uninitializes the subsystem. /// Uninitializes the subsystem.
virtual void reinitialize(Application& app); virtual void reinitialize(Application& app);
/// Re-initializes the subsystem. /// Re-initializes the subsystem.
/// ///
/// The default implementation just calls /// The default implementation just calls
/// uninitialize() followed by initialize(). /// uninitialize() followed by initialize().
/// Actual implementations might want to use a /// Actual implementations might want to use a
/// less radical and possibly more performant /// less radical and possibly more performant
/// approach. /// approach.
virtual ~Subsystem(); virtual ~Subsystem();
/// Destroys the Subsystem. /// Destroys the Subsystem.
friend class Application; friend class Application;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_Subsystem_INCLUDED #endif // Util_Subsystem_INCLUDED

View File

@@ -1,98 +1,98 @@
// //
// SystemConfiguration.h // SystemConfiguration.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/SystemConfiguration.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/SystemConfiguration.h#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: SystemConfiguration // Module: SystemConfiguration
// //
// Definition of the SystemConfiguration class. // Definition of the SystemConfiguration 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 Util_SystemConfiguration_INCLUDED #ifndef Util_SystemConfiguration_INCLUDED
#define Util_SystemConfiguration_INCLUDED #define Util_SystemConfiguration_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API SystemConfiguration: public AbstractConfiguration class Util_API SystemConfiguration: public AbstractConfiguration
/// This class implements a Configuration interface to /// This class implements a Configuration interface to
/// various system properties and environment variables. /// various system properties and environment variables.
/// ///
/// The following properties are supported: /// The following properties are supported:
/// - system.osName: the operating system name /// - system.osName: the operating system name
/// - system.osVersion: the operating system version /// - system.osVersion: the operating system version
/// - system.osArchitecture: the operating system architecture /// - system.osArchitecture: the operating system architecture
/// - system.nodeName: the node (or host) name /// - system.nodeName: the node (or host) name
/// - system.currentDir: the current working directory /// - system.currentDir: the current working directory
/// - system.homeDir: the user's home directory /// - system.homeDir: the user's home directory
/// - system.tempDir: the system's temporary directory /// - system.tempDir: the system's temporary directory
/// - system.env.<NAME>: the environment variable with the given <NAME>. /// - system.env.<NAME>: the environment variable with the given <NAME>.
/// ///
/// An attempt to set a system variable will result in an /// An attempt to set a system variable will result in an
/// InvalidAccessException being thrown. /// InvalidAccessException being thrown.
/// ///
/// Enumerating environment variables is not supported. /// Enumerating environment variables is not supported.
/// An attemp to call keys("system.env") will return an empty range. /// An attemp to call keys("system.env") will return an empty range.
{ {
public: public:
SystemConfiguration(); SystemConfiguration();
/// Creates the SystemConfiguration. /// Creates the SystemConfiguration.
protected: protected:
bool getRaw(const std::string& key, std::string& value) const; bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value); void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const; void enumerate(const std::string& key, Keys& range) const;
~SystemConfiguration(); ~SystemConfiguration();
private: private:
static bool getEnv(const std::string& name, std::string& value); static bool getEnv(const std::string& name, std::string& value);
static const std::string OSNAME; static const std::string OSNAME;
static const std::string OSVERSION; static const std::string OSVERSION;
static const std::string OSARCHITECTURE; static const std::string OSARCHITECTURE;
static const std::string NODENAME; static const std::string NODENAME;
static const std::string CURRENTDIR; static const std::string CURRENTDIR;
static const std::string HOMEDIR; static const std::string HOMEDIR;
static const std::string TEMPDIR; static const std::string TEMPDIR;
static const std::string ENV; static const std::string ENV;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_SystemConfiguration_INCLUDED #endif // Util_SystemConfiguration_INCLUDED

View File

@@ -1,70 +1,70 @@
// //
// Util.h // Util.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/Util.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/Util.h#1 $
// //
// Library: Util // Library: Util
// Package: Util // Package: Util
// Module: Util // Module: Util
// //
// Basic definitions for the Poco Util library. // Basic definitions for the Poco Util library.
// This file must be the first file included by every other Util // This file must be the first file included by every other Util
// 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 Util_Util_INCLUDED #ifndef Util_Util_INCLUDED
#define Util_Util_INCLUDED #define Util_Util_INCLUDED
#include "Poco/Foundation.h" #include "Poco/Foundation.h"
// //
// The following block is the standard way of creating macros which make exporting // The following block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the Util_EXPORTS // from a DLL simpler. All files within this DLL are compiled with the Util_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
// Util_API functions as being imported from a DLL, wheras this DLL sees symbols // Util_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(Util_EXPORTS) #if defined(Util_EXPORTS)
#define Util_API __declspec(dllexport) #define Util_API __declspec(dllexport)
#else #else
#define Util_API __declspec(dllimport) #define Util_API __declspec(dllimport)
#endif #endif
#endif #endif
#if !defined(Util_API) #if !defined(Util_API)
#define Util_API #define Util_API
#endif #endif
#endif // Util_Util_INCLUDED #endif // Util_Util_INCLUDED

View File

@@ -1,79 +1,79 @@
// //
// Validator.h // Validator.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/Validator.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/Validator.h#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: Validator // Module: Validator
// //
// Definition of the Validator class. // Definition of the Validator 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 Util_Validator_INCLUDED #ifndef Util_Validator_INCLUDED
#define Util_Validator_INCLUDED #define Util_Validator_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/RefCountedObject.h" #include "Poco/RefCountedObject.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Option; class Option;
class Util_API Validator: public Poco::RefCountedObject class Util_API Validator: public Poco::RefCountedObject
/// Validator specifies the interface for option validators. /// Validator specifies the interface for option validators.
/// ///
/// Option validators provide a simple way for the automatic /// Option validators provide a simple way for the automatic
/// validation of command line argument values. /// validation of command line argument values.
{ {
public: public:
virtual void validate(const Option& option, const std::string& value) = 0; virtual void validate(const Option& option, const std::string& value) = 0;
/// Validates the value for the given option. /// Validates the value for the given option.
/// Does nothing if the value is valid. /// Does nothing if the value is valid.
/// ///
/// Throws an InvalidOptionException otherwise. /// Throws an InvalidOptionException otherwise.
protected: protected:
Validator(); Validator();
/// Creates the Validator. /// Creates the Validator.
virtual ~Validator(); virtual ~Validator();
/// Destroys the Validator. /// Destroys the Validator.
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_Validator_INCLUDED #endif // Util_Validator_INCLUDED

View File

@@ -1,97 +1,97 @@
// //
// WinRegistryConfiguration.h // WinRegistryConfiguration.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/WinRegistryConfiguration.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/WinRegistryConfiguration.h#1 $
// //
// Library: Util // Library: Util
// Package: Windows // Package: Windows
// Module: WinRegistryConfiguration // Module: WinRegistryConfiguration
// //
// Definition of the WinRegistryConfiguration class. // Definition of the WinRegistryConfiguration 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 Util_WinRegistryConfiguration_INCLUDED #ifndef Util_WinRegistryConfiguration_INCLUDED
#define Util_WinRegistryConfiguration_INCLUDED #define Util_WinRegistryConfiguration_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
#include "Poco/String.h" #include "Poco/String.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API WinRegistryConfiguration: public AbstractConfiguration class Util_API WinRegistryConfiguration: public AbstractConfiguration
/// An implementation of AbstractConfiguration that stores configuration data /// An implementation of AbstractConfiguration that stores configuration data
/// in the Windows registry. /// in the Windows registry.
{ {
public: public:
WinRegistryConfiguration(const std::string& rootPath); WinRegistryConfiguration(const std::string& rootPath);
/// Creates the WinRegistryConfiguration. /// Creates the WinRegistryConfiguration.
/// The rootPath must start with one of the root key names /// The rootPath must start with one of the root key names
/// like HKEY_CLASSES_ROOT, e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services. /// like HKEY_CLASSES_ROOT, e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.
/// All further keys are relativ to the root path and can be /// All further keys are relativ to the root path and can be
/// dot seperated, e.g. the path MyService.ServiceName will be converted to /// dot seperated, e.g. the path MyService.ServiceName will be converted to
/// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\ServiceName. /// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\ServiceName.
bool getRaw(const std::string& key, std::string& value) const; bool getRaw(const std::string& key, std::string& value) const;
/// If the property with the given key exists, stores the property's value /// If the property with the given key exists, stores the property's value
/// in value and returns true. Otherwise, returns false. /// in value and returns true. Otherwise, returns false.
/// ///
/// Must be overridden by subclasses. /// Must be overridden by subclasses.
void setRaw(const std::string& key, const std::string& value); void setRaw(const std::string& key, const std::string& value);
/// Sets the property with the given key to the given value. /// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten. /// An already existing value for the key is overwritten.
/// ///
/// Must be overridden by subclasses. /// Must be overridden by subclasses.
void enumerate(const std::string& key, Keys& range) const; void enumerate(const std::string& key, Keys& range) const;
/// Returns in range the names of all subkeys under the given key. /// Returns in range the names of all subkeys under the given key.
/// If an empty key is passed, all root level keys are returned. /// If an empty key is passed, all root level keys are returned.
protected: protected:
~WinRegistryConfiguration(); ~WinRegistryConfiguration();
/// Destroys the WinRegistryConfiguration. /// Destroys the WinRegistryConfiguration.
std::string ConvertToRegFormat(const std::string& key, std::string& keyName) const; std::string ConvertToRegFormat(const std::string& key, std::string& keyName) const;
/// takes a key in the format of A.B.C and converts it to /// takes a key in the format of A.B.C and converts it to
/// registry format A\B\C, the last entry is the keyName, the rest is returned as path /// registry format A\B\C, the last entry is the keyName, the rest is returned as path
private: private:
std::string _rootPath; std::string _rootPath;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_WinRegistryConfiguration_INCLUDED #endif // Util_WinRegistryConfiguration_INCLUDED

View File

@@ -1,159 +1,159 @@
// //
// WinRegistryKey.h // WinRegistryKey.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/WinRegistryKey.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/WinRegistryKey.h#1 $
// //
// Library: Util // Library: Util
// Package: Windows // Package: Windows
// Module: WinRegistryKey // Module: WinRegistryKey
// //
// Definition of the WinRegistryKey class. // Definition of the WinRegistryKey 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 Util_WinRegistryKey_INCLUDED #ifndef Util_WinRegistryKey_INCLUDED
#define Util_WinRegistryKey_INCLUDED #define Util_WinRegistryKey_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include <windows.h> #include <windows.h>
#include <vector> #include <vector>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API WinRegistryKey class Util_API WinRegistryKey
/// This class implements a convenient interface to the /// This class implements a convenient interface to the
/// Windows Registry. /// Windows Registry.
/// ///
/// This class is only available on Windows platforms. /// This class is only available on Windows platforms.
{ {
public: public:
typedef std::vector<std::string> Keys; typedef std::vector<std::string> Keys;
typedef std::vector<std::string> Values; typedef std::vector<std::string> Values;
enum Type enum Type
{ {
REGT_NONE = 0, REGT_NONE = 0,
REGT_STRING = 1, REGT_STRING = 1,
REGT_STRING_EXPAND = 2, REGT_STRING_EXPAND = 2,
REGT_DWORD = 4 REGT_DWORD = 4
}; };
WinRegistryKey(const std::string& key); WinRegistryKey(const std::string& key);
/// Creates the WinRegistryKey. /// Creates the WinRegistryKey.
/// ///
/// The key must start with one of the root key names /// The key must start with one of the root key names
/// like HKEY_CLASSES_ROOT, e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services. /// like HKEY_CLASSES_ROOT, e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.
WinRegistryKey(HKEY hRootKey, const std::string& subKey); WinRegistryKey(HKEY hRootKey, const std::string& subKey);
/// Creates the WinRegistryKey. /// Creates the WinRegistryKey.
~WinRegistryKey(); ~WinRegistryKey();
/// Destroys the WinRegistryKey. /// Destroys the WinRegistryKey.
void setString(const std::string& name, const std::string& value); void setString(const std::string& name, const std::string& value);
/// Sets the string value (REG_SZ) with the given name. /// Sets the string value (REG_SZ) with the given name.
/// An empty name denotes the default value. /// An empty name denotes the default value.
std::string getString(const std::string& name); std::string getString(const std::string& name);
/// Returns the string value (REG_SZ) with the given name. /// Returns the string value (REG_SZ) with the given name.
/// An empty name denotes the default value. /// An empty name denotes the default value.
/// ///
/// Throws a NotFoundException if the value does not exist. /// Throws a NotFoundException if the value does not exist.
void setStringExpand(const std::string& name, const std::string& value); void setStringExpand(const std::string& name, const std::string& value);
/// Sets the expandable string value (REG_EXPAND_SZ) with the given name. /// Sets the expandable string value (REG_EXPAND_SZ) with the given name.
/// An empty name denotes the default value. /// An empty name denotes the default value.
std::string getStringExpand(const std::string& name); std::string getStringExpand(const std::string& name);
/// Returns the string value (REG_EXPAND_SZ) with the given name. /// Returns the string value (REG_EXPAND_SZ) with the given name.
/// An empty name denotes the default value. /// An empty name denotes the default value.
/// All references to environment variables (%VAR%) in the string /// All references to environment variables (%VAR%) in the string
/// are expanded. /// are expanded.
/// ///
/// Throws a NotFoundException if the value does not exist. /// Throws a NotFoundException if the value does not exist.
void setInt(const std::string& name, int value); void setInt(const std::string& name, int value);
/// Sets the numeric (REG_DWORD) value with the given name. /// Sets the numeric (REG_DWORD) value with the given name.
/// An empty name denotes the default value. /// An empty name denotes the default value.
int getInt(const std::string& name); int getInt(const std::string& name);
/// Returns the numeric value (REG_DWORD) with the given name. /// Returns the numeric value (REG_DWORD) with the given name.
/// An empty name denotes the default value. /// An empty name denotes the default value.
/// ///
/// Throws a NotFoundException if the value does not exist. /// Throws a NotFoundException if the value does not exist.
void deleteValue(const std::string& name); void deleteValue(const std::string& name);
/// Deletes the value with the given name. /// Deletes the value with the given name.
/// ///
/// Throws a NotFoundException if the value does not exist. /// Throws a NotFoundException if the value does not exist.
void deleteKey(); void deleteKey();
/// Deletes the key. The key must not have subkeys. /// Deletes the key. The key must not have subkeys.
bool exists(); bool exists();
/// Returns true iff the key exists. /// Returns true iff the key exists.
Type type(const std::string& name); Type type(const std::string& name);
/// Returns the type of the key value. /// Returns the type of the key value.
bool exists(const std::string& name); bool exists(const std::string& name);
/// Returns true iff the given value exists under that key. /// Returns true iff the given value exists under that key.
void subKeys(Keys& keys); void subKeys(Keys& keys);
/// Appends all subKey names to keys. /// Appends all subKey names to keys.
void values(Values& vals); void values(Values& vals);
/// Appends all value names to vals; /// Appends all value names to vals;
protected: protected:
void open(); void open();
void close(); void close();
std::string key() const; std::string key() const;
std::string key(const std::string& valueName) const; std::string key(const std::string& valueName) const;
void handleSetError(const std::string& name); void handleSetError(const std::string& name);
static HKEY handleFor(const std::string& rootKey); static HKEY handleFor(const std::string& rootKey);
private: private:
WinRegistryKey(); WinRegistryKey();
WinRegistryKey(const WinRegistryKey&); WinRegistryKey(const WinRegistryKey&);
WinRegistryKey& operator = (const WinRegistryKey&); WinRegistryKey& operator = (const WinRegistryKey&);
HKEY _hRootKey; HKEY _hRootKey;
std::string _subKey; std::string _subKey;
HKEY _hKey; HKEY _hKey;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_WinRegistryKey_INCLUDED #endif // Util_WinRegistryKey_INCLUDED

View File

@@ -1,146 +1,146 @@
// //
// WinService.h // WinService.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/WinService.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/WinService.h#1 $
// //
// Library: Util // Library: Util
// Package: Windows // Package: Windows
// Module: WinService // Module: WinService
// //
// Definition of the WinService class. // Definition of the WinService 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 Util_WinService_INCLUDED #ifndef Util_WinService_INCLUDED
#define Util_WinService_INCLUDED #define Util_WinService_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include <windows.h> #include <windows.h>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API WinService class Util_API WinService
/// This class provides an object-oriented interface to /// This class provides an object-oriented interface to
/// the Windows Service Control Manager for registering, /// the Windows Service Control Manager for registering,
/// unregistering, configuring, starting and stopping /// unregistering, configuring, starting and stopping
/// services. /// services.
/// ///
/// This class is only available on Windows platforms. /// This class is only available on Windows platforms.
{ {
public: public:
enum Startup enum Startup
{ {
SVC_AUTO_START, SVC_AUTO_START,
SVC_MANUAL_START, SVC_MANUAL_START,
SVC_DISABLED SVC_DISABLED
}; };
WinService(const std::string& name); WinService(const std::string& name);
/// Creates the WinService, using the given service name. /// Creates the WinService, using the given service name.
~WinService(); ~WinService();
/// Destroys the WinService. /// Destroys the WinService.
const std::string& name() const; const std::string& name() const;
/// Returns the service name. /// Returns the service name.
std::string displayName() const; std::string displayName() const;
/// Returns the service's display name. /// Returns the service's display name.
std::string path() const; std::string path() const;
/// Returns the path to the service executable. /// Returns the path to the service executable.
/// ///
/// Throws a NotFoundException if the service has not been registered. /// Throws a NotFoundException if the service has not been registered.
void registerService(const std::string& path, const std::string& displayName); void registerService(const std::string& path, const std::string& displayName);
/// Creates a Windows service with the executable specified by path /// Creates a Windows service with the executable specified by path
/// and the given displayName. /// and the given displayName.
/// ///
/// Throws a ExistsException if the service has already been registered. /// Throws a ExistsException if the service has already been registered.
void registerService(const std::string& path); void registerService(const std::string& path);
/// Creates a Windows service with the executable specified by path /// Creates a Windows service with the executable specified by path
/// and the given displayName. The service name is used as display name. /// and the given displayName. The service name is used as display name.
/// ///
/// Throws a ExistsException if the service has already been registered. /// Throws a ExistsException if the service has already been registered.
void unregisterService(); void unregisterService();
/// Deletes the Windows service. /// Deletes the Windows service.
/// ///
/// Throws a NotFoundException if the service has not been registered. /// Throws a NotFoundException if the service has not been registered.
bool isRegistered() const; bool isRegistered() const;
/// Returns true if the service has been registered with the Service Control Manager. /// Returns true if the service has been registered with the Service Control Manager.
bool isRunning() const; bool isRunning() const;
/// Returns true if the service is currently running. /// Returns true if the service is currently running.
void start(); void start();
/// Starts the service. /// Starts the service.
/// Does nothing if the service is already running. /// Does nothing if the service is already running.
/// ///
/// Throws a NotFoundException if the service has not been registered. /// Throws a NotFoundException if the service has not been registered.
void stop(); void stop();
/// Stops the service. /// Stops the service.
/// Does nothing if the service is not running. /// Does nothing if the service is not running.
/// ///
/// Throws a NotFoundException if the service has not been registered. /// Throws a NotFoundException if the service has not been registered.
void setStartup(Startup startup); void setStartup(Startup startup);
/// Sets the startup mode for the service. /// Sets the startup mode for the service.
Startup getStartup() const; Startup getStartup() const;
/// Returns the startup mode for the service. /// Returns the startup mode for the service.
static const int STARTUP_TIMEOUT; static const int STARTUP_TIMEOUT;
private: private:
void open() const; void open() const;
bool tryOpen() const; bool tryOpen() const;
void close() const; void close() const;
LPQUERY_SERVICE_CONFIG config() const; LPQUERY_SERVICE_CONFIG config() const;
WinService(); WinService();
WinService(const WinService&); WinService(const WinService&);
WinService& operator = (const WinService&); WinService& operator = (const WinService&);
std::string _name; std::string _name;
SC_HANDLE _scmHandle; SC_HANDLE _scmHandle;
mutable SC_HANDLE _svcHandle; mutable SC_HANDLE _svcHandle;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_WinService_INCLUDED #endif // Util_WinService_INCLUDED

View File

@@ -1,156 +1,156 @@
// //
// XMLConfiguration.h // XMLConfiguration.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/XMLConfiguration.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/XMLConfiguration.h#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: XMLConfiguration // Module: XMLConfiguration
// //
// Definition of the XMLConfiguration class. // Definition of the XMLConfiguration 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 Util_XMLConfiguration_INCLUDED #ifndef Util_XMLConfiguration_INCLUDED
#define Util_XMLConfiguration_INCLUDED #define Util_XMLConfiguration_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "Poco/Util/MapConfiguration.h" #include "Poco/Util/MapConfiguration.h"
#include "Poco/DOM/Document.h" #include "Poco/DOM/Document.h"
#include "Poco/DOM/AutoPtr.h" #include "Poco/DOM/AutoPtr.h"
#include "Poco/SAX/InputSource.h" #include "Poco/SAX/InputSource.h"
#include <istream> #include <istream>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
class Util_API XMLConfiguration: public AbstractConfiguration class Util_API XMLConfiguration: public AbstractConfiguration
/// This configuration class extracts configuration properties /// This configuration class extracts configuration properties
/// from an XML document. An XPath-like syntax for property /// from an XML document. An XPath-like syntax for property
/// names is supported to allow full access to the XML document. /// names is supported to allow full access to the XML document.
/// XML namespaces are not supported. The name of the root element /// XML namespaces are not supported. The name of the root element
/// of an XML document is not significant. Periods in tag names /// of an XML document is not significant. Periods in tag names
/// are not supported. /// are not supported.
/// ///
/// Given the following XML document as an example: /// Given the following XML document as an example:
/// ///
/// <config> /// <config>
/// <prop1>value1</prop1> /// <prop1>value1</prop1>
/// <prop2>value2</prop2> /// <prop2>value2</prop2>
/// <prop3> /// <prop3>
/// <prop4 attr="value3"/> /// <prop4 attr="value3"/>
/// <prop4 attr="value4"/> /// <prop4 attr="value4"/>
/// </prop3> /// </prop3>
/// <prop5>value5</prop5> /// <prop5>value5</prop5>
/// <prop5>value6</prop5> /// <prop5>value6</prop5>
/// </config> /// </config>
/// ///
/// The following property names would be valid and would /// The following property names would be valid and would
/// yield the shown values: /// yield the shown values:
/// ///
/// prop1 -> value1 /// prop1 -> value1
/// prop2 -> value2 /// prop2 -> value2
/// prop3.prop4 -> (empty string) /// prop3.prop4 -> (empty string)
/// prop3.prop4[@attr] -> value3 /// prop3.prop4[@attr] -> value3
/// prop3.prop4[1][@attr] -> value4 /// prop3.prop4[1][@attr] -> value4
/// prop5[0] -> value5 /// prop5[0] -> value5
/// prop5[1] -> value6 /// prop5[1] -> value6
/// ///
/// Enumerating attributes is not supported. /// Enumerating attributes is not supported.
/// Calling keys("prop3.prop4") will return an empty range. /// Calling keys("prop3.prop4") will return an empty range.
/// ///
/// Setting properties is not supported. An attempt to set a property results /// Setting properties is not supported. An attempt to set a property results
/// in a NotImplementedException being thrown. /// in a NotImplementedException being thrown.
{ {
public: public:
XMLConfiguration(); XMLConfiguration();
/// Creates an empty XMLConfiguration. /// Creates an empty XMLConfiguration.
XMLConfiguration(Poco::XML::InputSource* pInputSource); XMLConfiguration(Poco::XML::InputSource* pInputSource);
/// Creates an XMLConfiguration and loads the XML document from /// Creates an XMLConfiguration and loads the XML document from
/// the given InputSource. /// the given InputSource.
XMLConfiguration(std::istream& istr); XMLConfiguration(std::istream& istr);
/// Creates an XMLConfiguration and loads the XML document from /// Creates an XMLConfiguration and loads the XML document from
/// the given stream. /// the given stream.
XMLConfiguration(const std::string& path); XMLConfiguration(const std::string& path);
/// Creates an XMLConfiguration and loads the XML document from /// Creates an XMLConfiguration and loads the XML document from
/// the given path. /// the given path.
XMLConfiguration(const Poco::XML::Document* pDocument); XMLConfiguration(const Poco::XML::Document* pDocument);
/// Creates the XMLConfiguration using the given XML document. /// Creates the XMLConfiguration using the given XML document.
XMLConfiguration(const Poco::XML::Node* pNode); XMLConfiguration(const Poco::XML::Node* pNode);
/// Creates the XMLConfiguration using the given XML node. /// Creates the XMLConfiguration using the given XML node.
void load(Poco::XML::InputSource* pInputSource); void load(Poco::XML::InputSource* pInputSource);
/// Loads the XML document containing the configuration data /// Loads the XML document containing the configuration data
/// from the given InputSource. /// from the given InputSource.
void load(std::istream& istr); void load(std::istream& istr);
/// Loads the XML document containing the configuration data /// Loads the XML document containing the configuration data
/// from the given stream. /// from the given stream.
void load(const std::string& path); void load(const std::string& path);
/// Loads the XML document containing the configuration data /// Loads the XML document containing the configuration data
/// from the given file. /// from the given file.
void load(const Poco::XML::Document* pDocument); void load(const Poco::XML::Document* pDocument);
/// Loads the XML document containing the configuration data /// Loads the XML document containing the configuration data
/// from the given XML document. /// from the given XML document.
void load(const Poco::XML::Node* pNode); void load(const Poco::XML::Node* pNode);
/// Loads the XML document containing the configuration data /// Loads the XML document containing the configuration data
/// from the given XML node. /// from the given XML node.
protected: protected:
bool getRaw(const std::string& key, std::string& value) const; bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value); void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const; void enumerate(const std::string& key, Keys& range) const;
~XMLConfiguration(); ~XMLConfiguration();
private: private:
const Poco::XML::Node* findNode(const std::string& key) const; const Poco::XML::Node* findNode(const std::string& key) const;
static const Poco::XML::Node* findNode(std::string::const_iterator& it, const std::string::const_iterator& end, const Poco::XML::Node* pNode); static const Poco::XML::Node* findNode(std::string::const_iterator& it, const std::string::const_iterator& end, const Poco::XML::Node* pNode);
static const Poco::XML::Node* findElement(const std::string& name, const Poco::XML::Node* pNode); static const Poco::XML::Node* findElement(const std::string& name, const Poco::XML::Node* pNode);
static const Poco::XML::Node* findElement(int index, const Poco::XML::Node* pNode); static const Poco::XML::Node* findElement(int index, const Poco::XML::Node* pNode);
static const Poco::XML::Node* findAttribute(const std::string& name, const Poco::XML::Node* pNode); static const Poco::XML::Node* findAttribute(const std::string& name, const Poco::XML::Node* pNode);
Poco::XML::AutoPtr<Poco::XML::Node> _pRoot; Poco::XML::AutoPtr<Poco::XML::Node> _pRoot;
Poco::XML::AutoPtr<Poco::XML::Document> _pDocument; Poco::XML::AutoPtr<Poco::XML::Document> _pDocument;
}; };
} } // namespace Poco::Util } } // namespace Poco::Util
#endif // Util_XMLConfiguration_INCLUDED #endif // Util_XMLConfiguration_INCLUDED

View File

@@ -1,13 +1,13 @@
# #
# Makefile # Makefile
# #
# $Id: //poco/1.2/Util/samples/Makefile#1 $ # $Id: //poco/1.2/Util/samples/Makefile#1 $
# #
# Makefile for Poco Util Samples # Makefile for Poco Util Samples
# #
.PHONY: projects .PHONY: projects
clean all: projects clean all: projects
projects: projects:
$(MAKE) -C SampleApp $(MAKECMDGOALS) $(MAKE) -C SampleApp $(MAKECMDGOALS)
$(MAKE) -C SampleServer $(MAKECMDGOALS) $(MAKE) -C SampleServer $(MAKECMDGOALS)

View File

@@ -1,17 +1,17 @@
# #
# Makefile # Makefile
# #
# $Id: //poco/1.2/Util/samples/SampleApp/Makefile#1 $ # $Id: //poco/1.2/Util/samples/SampleApp/Makefile#1 $
# #
# Makefile for Poco SampleApp # Makefile for Poco SampleApp
# #
include $(POCO_BASE)/build/rules/global include $(POCO_BASE)/build/rules/global
objects = SampleApp objects = SampleApp
target = SampleApp target = SampleApp
target_version = 1 target_version = 1
target_libs = PocoUtil PocoXML PocoFoundation target_libs = PocoUtil PocoXML PocoFoundation
include $(POCO_BASE)/build/rules/exec include $(POCO_BASE)/build/rules/exec

View File

@@ -1,8 +1,8 @@
# This is a sample configuration file. # This is a sample configuration file.
logging.loggers.root.channel.class = ConsoleChannel logging.loggers.root.channel.class = ConsoleChannel
logging.loggers.app.name = Application logging.loggers.app.name = Application
logging.loggers.app.channel = c1 logging.loggers.app.channel = c1
logging.formatters.f1.class = PatternFormatter logging.formatters.f1.class = PatternFormatter
logging.formatters.f1.pattern = [%p] %t logging.formatters.f1.pattern = [%p] %t
logging.channels.c1.class = ConsoleChannel logging.channels.c1.class = ConsoleChannel
logging.channels.c1.formatter = f1 logging.channels.c1.formatter = f1

View File

@@ -1,7 +1,7 @@
# #
# sample.vmsbuild # sample.vmsbuild
# #
# $Id: //poco/1.2/Util/samples/SampleApp/SampleApp.vmsbuild#1 $ # $Id: //poco/1.2/Util/samples/SampleApp/SampleApp.vmsbuild#1 $
# #
EXE=SampleApp EXE=SampleApp
SampleApp SampleApp

View File

@@ -1,152 +1,152 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="7.10" Version="7.10"
Name="SampleApp" Name="SampleApp"
ProjectGUID="{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}" ProjectGUID="{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}"
Keyword="Win32Proj"> Keyword="Win32Proj">
<Platforms> <Platforms>
<Platform <Platform
Name="Win32"/> Name="Win32"/>
</Platforms> </Platforms>
<Configurations> <Configurations>
<Configuration <Configuration
Name="debug_shared|Win32" Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared" OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared" IntermediateDirectory="obj\debug_shared"
ConfigurationType="1" ConfigurationType="1"
UseOfMFC="2" UseOfMFC="2"
CharacterSet="2"> CharacterSet="2">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include" AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="TRUE" MinimalRebuild="TRUE"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
BufferSecurityCheck="TRUE" BufferSecurityCheck="TRUE"
TreatWChar_tAsBuiltInType="TRUE" TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE" ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE" RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/> DebugInformationFormat="4"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoUtild.lib" AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoUtild.lib"
OutputFile="bin/SampleAppd.exe" OutputFile="bin/SampleAppd.exe"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib" AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="TRUE" GenerateDebugInformation="TRUE"
ProgramDatabaseFile="bin/SampleAppd.pdb" ProgramDatabaseFile="bin/SampleAppd.pdb"
SubSystem="1" SubSystem="1"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
Name="VCPostBuildEventTool"/> Name="VCPostBuildEventTool"/>
<Tool <Tool
Name="VCPreBuildEventTool"/> Name="VCPreBuildEventTool"/>
<Tool <Tool
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool"/> Name="VCResourceCompilerTool"/>
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool"/> Name="VCWebServiceProxyGeneratorTool"/>
<Tool <Tool
Name="VCXMLDataGeneratorTool"/> Name="VCXMLDataGeneratorTool"/>
<Tool <Tool
Name="VCWebDeploymentTool"/> Name="VCWebDeploymentTool"/>
<Tool <Tool
Name="VCManagedWrapperGeneratorTool"/> Name="VCManagedWrapperGeneratorTool"/>
<Tool <Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration> </Configuration>
<Configuration <Configuration
Name="release_shared|Win32" Name="release_shared|Win32"
OutputDirectory="obj\release_shared" OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared" IntermediateDirectory="obj\release_shared"
ConfigurationType="1" ConfigurationType="1"
UseOfMFC="2" UseOfMFC="2"
CharacterSet="2"> CharacterSet="2">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="4" Optimization="4"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
EnableIntrinsicFunctions="TRUE" EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="TRUE" OmitFramePointers="TRUE"
OptimizeForWindowsApplication="TRUE" OptimizeForWindowsApplication="TRUE"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include" AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="2" RuntimeLibrary="2"
BufferSecurityCheck="FALSE" BufferSecurityCheck="FALSE"
TreatWChar_tAsBuiltInType="TRUE" TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE" ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE" RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/> DebugInformationFormat="3"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoUtil.lib" AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoUtil.lib"
OutputFile="bin/SampleApp.exe" OutputFile="bin/SampleApp.exe"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\lib" AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="FALSE" GenerateDebugInformation="FALSE"
ProgramDatabaseFile="" ProgramDatabaseFile=""
SubSystem="1" SubSystem="1"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
Name="VCPostBuildEventTool"/> Name="VCPostBuildEventTool"/>
<Tool <Tool
Name="VCPreBuildEventTool"/> Name="VCPreBuildEventTool"/>
<Tool <Tool
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool"/> Name="VCResourceCompilerTool"/>
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool"/> Name="VCWebServiceProxyGeneratorTool"/>
<Tool <Tool
Name="VCXMLDataGeneratorTool"/> Name="VCXMLDataGeneratorTool"/>
<Tool <Tool
Name="VCWebDeploymentTool"/> Name="VCWebDeploymentTool"/>
<Tool <Tool
Name="VCManagedWrapperGeneratorTool"/> Name="VCManagedWrapperGeneratorTool"/>
<Tool <Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration> </Configuration>
</Configurations> </Configurations>
<References> <References>
</References> </References>
<Files> <Files>
<Filter <Filter
Name="Configuration Files" Name="Configuration Files"
Filter=""> Filter="">
<File <File
RelativePath=".\SampleApp.properties"> RelativePath=".\SampleApp.properties">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\SampleApp.cpp"> RelativePath=".\src\SampleApp.cpp">
</File> </File>
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
</VisualStudioProject> </VisualStudioProject>

View File

@@ -1,217 +1,217 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8.00" Version="8.00"
Name="SampleApp" Name="SampleApp"
ProjectGUID="{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}" ProjectGUID="{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}"
Keyword="Win32Proj" Keyword="Win32Proj"
> >
<Platforms> <Platforms>
<Platform <Platform
Name="Win32" Name="Win32"
/> />
</Platforms> </Platforms>
<ToolFiles> <ToolFiles>
</ToolFiles> </ToolFiles>
<Configurations> <Configurations>
<Configuration <Configuration
Name="debug_shared|Win32" Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared" OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared" IntermediateDirectory="obj\debug_shared"
ConfigurationType="1" ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="2" UseOfMFC="2"
CharacterSet="2" CharacterSet="2"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
/> />
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
/> />
<Tool <Tool
Name="VCXMLDataGeneratorTool" Name="VCXMLDataGeneratorTool"
/> />
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool" Name="VCWebServiceProxyGeneratorTool"
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
/> />
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include" AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
BufferSecurityCheck="true" BufferSecurityCheck="true"
TreatWChar_tAsBuiltInType="true" TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true" ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true" RuntimeTypeInfo="true"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="true" Detect64BitPortabilityProblems="true"
DebugInformationFormat="4" DebugInformationFormat="4"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
/> />
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoUtild.lib" AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoUtild.lib"
OutputFile="bin/SampleAppd.exe" OutputFile="bin/SampleAppd.exe"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib" AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="true" GenerateDebugInformation="true"
ProgramDatabaseFile="bin/SampleAppd.pdb" ProgramDatabaseFile="bin/SampleAppd.pdb"
SubSystem="1" SubSystem="1"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
/> />
<Tool <Tool
Name="VCManifestTool" Name="VCManifestTool"
/> />
<Tool <Tool
Name="VCXDCMakeTool" Name="VCXDCMakeTool"
/> />
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
/> />
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
/> />
<Tool <Tool
Name="VCWebDeploymentTool" Name="VCWebDeploymentTool"
/> />
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
<Configuration <Configuration
Name="release_shared|Win32" Name="release_shared|Win32"
OutputDirectory="obj\release_shared" OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared" IntermediateDirectory="obj\release_shared"
ConfigurationType="1" ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="2" UseOfMFC="2"
CharacterSet="2" CharacterSet="2"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
/> />
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
/> />
<Tool <Tool
Name="VCXMLDataGeneratorTool" Name="VCXMLDataGeneratorTool"
/> />
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool" Name="VCWebServiceProxyGeneratorTool"
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
/> />
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="4" Optimization="4"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true" EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="true" OmitFramePointers="true"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include" AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="true" StringPooling="true"
RuntimeLibrary="2" RuntimeLibrary="2"
BufferSecurityCheck="false" BufferSecurityCheck="false"
TreatWChar_tAsBuiltInType="true" TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true" ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true" RuntimeTypeInfo="true"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="true" Detect64BitPortabilityProblems="true"
DebugInformationFormat="3" DebugInformationFormat="3"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
/> />
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoUtil.lib" AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoUtil.lib"
OutputFile="bin/SampleApp.exe" OutputFile="bin/SampleApp.exe"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\lib" AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="false" GenerateDebugInformation="false"
ProgramDatabaseFile="" ProgramDatabaseFile=""
SubSystem="1" SubSystem="1"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
/> />
<Tool <Tool
Name="VCManifestTool" Name="VCManifestTool"
/> />
<Tool <Tool
Name="VCXDCMakeTool" Name="VCXDCMakeTool"
/> />
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
/> />
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
/> />
<Tool <Tool
Name="VCWebDeploymentTool" Name="VCWebDeploymentTool"
/> />
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
</Configurations> </Configurations>
<References> <References>
</References> </References>
<Files> <Files>
<Filter <Filter
Name="Configuration Files" Name="Configuration Files"
> >
<File <File
RelativePath=".\SampleApp.properties" RelativePath=".\SampleApp.properties"
> >
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
<File <File
RelativePath=".\src\SampleApp.cpp" RelativePath=".\src\SampleApp.cpp"
> >
</File> </File>
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
</VisualStudioProject> </VisualStudioProject>

View File

@@ -1,204 +1,204 @@
// //
// SampleApp.cpp // SampleApp.cpp
// //
// $Id: //poco/1.2/Util/samples/SampleApp/src/SampleApp.cpp#1 $ // $Id: //poco/1.2/Util/samples/SampleApp/src/SampleApp.cpp#1 $
// //
// This sample demonstrates the Application class. // This sample demonstrates the Application 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.
// //
#include "Poco/Util/Application.h" #include "Poco/Util/Application.h"
#include "Poco/Util/Option.h" #include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h" #include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h" #include "Poco/Util/HelpFormatter.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include <iostream> #include <iostream>
using Poco::Util::Application; using Poco::Util::Application;
using Poco::Util::Option; using Poco::Util::Option;
using Poco::Util::OptionSet; using Poco::Util::OptionSet;
using Poco::Util::HelpFormatter; using Poco::Util::HelpFormatter;
using Poco::Util::AbstractConfiguration; using Poco::Util::AbstractConfiguration;
using Poco::Util::OptionCallback; using Poco::Util::OptionCallback;
using Poco::AutoPtr; using Poco::AutoPtr;
class SampleApp: public Application class SampleApp: public Application
/// This sample demonstrates some of the features of the Util::Application class, /// This sample demonstrates some of the features of the Util::Application class,
/// such as configuration file handling and command line arguments processing. /// such as configuration file handling and command line arguments processing.
/// ///
/// Try SampleApp --help (on Unix platforms) or SampleApp /help (elsewhere) for /// Try SampleApp --help (on Unix platforms) or SampleApp /help (elsewhere) for
/// more information. /// more information.
{ {
public: public:
SampleApp(): _helpRequested(false) SampleApp(): _helpRequested(false)
{ {
} }
protected: protected:
void initialize(Application& self) void initialize(Application& self)
{ {
loadConfiguration(); // load default configuration files, if present loadConfiguration(); // load default configuration files, if present
Application::initialize(self); Application::initialize(self);
// add your own initialization code here // add your own initialization code here
} }
void uninitialize() void uninitialize()
{ {
// add your own uninitialization code here // add your own uninitialization code here
Application::uninitialize(); Application::uninitialize();
} }
void reinitialize(Application& self) void reinitialize(Application& self)
{ {
Application::reinitialize(self); Application::reinitialize(self);
// add your own reinitialization code here // add your own reinitialization code here
} }
void defineOptions(OptionSet& options) void defineOptions(OptionSet& options)
{ {
Application::defineOptions(options); Application::defineOptions(options);
options.addOption( options.addOption(
Option("help", "h", "display help information on command line arguments") Option("help", "h", "display help information on command line arguments")
.required(false) .required(false)
.repeatable(false) .repeatable(false)
.callback(OptionCallback<SampleApp>(this, &SampleApp::handleHelp))); .callback(OptionCallback<SampleApp>(this, &SampleApp::handleHelp)));
options.addOption( options.addOption(
Option("define", "D", "define a configuration property") Option("define", "D", "define a configuration property")
.required(false) .required(false)
.repeatable(true) .repeatable(true)
.argument("name=value") .argument("name=value")
.callback(OptionCallback<SampleApp>(this, &SampleApp::handleDefine))); .callback(OptionCallback<SampleApp>(this, &SampleApp::handleDefine)));
options.addOption( options.addOption(
Option("config-file", "f", "load configuration data from a file") Option("config-file", "f", "load configuration data from a file")
.required(false) .required(false)
.repeatable(true) .repeatable(true)
.argument("file") .argument("file")
.callback(OptionCallback<SampleApp>(this, &SampleApp::handleConfig))); .callback(OptionCallback<SampleApp>(this, &SampleApp::handleConfig)));
options.addOption( options.addOption(
Option("bind", "b", "bind option value to test.property") Option("bind", "b", "bind option value to test.property")
.required(false) .required(false)
.repeatable(false) .repeatable(false)
.argument("value") .argument("value")
.binding("test.property")); .binding("test.property"));
} }
void handleHelp(const std::string& name, const std::string& value) void handleHelp(const std::string& name, const std::string& value)
{ {
_helpRequested = true; _helpRequested = true;
displayHelp(); displayHelp();
stopOptionsProcessing(); stopOptionsProcessing();
} }
void handleDefine(const std::string& name, const std::string& value) void handleDefine(const std::string& name, const std::string& value)
{ {
defineProperty(value); defineProperty(value);
} }
void handleConfig(const std::string& name, const std::string& value) void handleConfig(const std::string& name, const std::string& value)
{ {
loadConfiguration(value); loadConfiguration(value);
} }
void displayHelp() void displayHelp()
{ {
HelpFormatter helpFormatter(options()); HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName()); helpFormatter.setCommand(commandName());
helpFormatter.setUsage("OPTIONS"); helpFormatter.setUsage("OPTIONS");
helpFormatter.setHeader("A sample application that demonstrates some of the features of the Poco::Util::Application class."); helpFormatter.setHeader("A sample application that demonstrates some of the features of the Poco::Util::Application class.");
helpFormatter.format(std::cout); helpFormatter.format(std::cout);
} }
void defineProperty(const std::string& def) void defineProperty(const std::string& def)
{ {
std::string name; std::string name;
std::string value; std::string value;
std::string::size_type pos = def.find('='); std::string::size_type pos = def.find('=');
if (pos != std::string::npos) if (pos != std::string::npos)
{ {
name.assign(def, 0, pos); name.assign(def, 0, pos);
value.assign(def, pos + 1, def.length() - pos); value.assign(def, pos + 1, def.length() - pos);
} }
else name = def; else name = def;
config().setString(name, value); config().setString(name, value);
} }
int main(const std::vector<std::string>& args) int main(const std::vector<std::string>& args)
{ {
if (!_helpRequested) if (!_helpRequested)
{ {
logger().information("Arguments to main():"); logger().information("Arguments to main():");
for (std::vector<std::string>::const_iterator it = args.begin(); it != args.end(); ++it) for (std::vector<std::string>::const_iterator it = args.begin(); it != args.end(); ++it)
{ {
logger().information(*it); logger().information(*it);
} }
logger().information("Application properties:"); logger().information("Application properties:");
printProperties(""); printProperties("");
} }
return Application::EXIT_OK; return Application::EXIT_OK;
} }
void printProperties(const std::string& base) void printProperties(const std::string& base)
{ {
AbstractConfiguration::Keys keys; AbstractConfiguration::Keys keys;
config().keys(base, keys); config().keys(base, keys);
if (keys.empty()) if (keys.empty())
{ {
if (config().hasProperty(base)) if (config().hasProperty(base))
{ {
std::string msg; std::string msg;
msg.append(base); msg.append(base);
msg.append(" = "); msg.append(" = ");
msg.append(config().getString(base)); msg.append(config().getString(base));
logger().information(msg); logger().information(msg);
} }
} }
else else
{ {
for (AbstractConfiguration::Keys::const_iterator it = keys.begin(); it != keys.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = keys.begin(); it != keys.end(); ++it)
{ {
std::string fullKey = base; std::string fullKey = base;
if (!fullKey.empty()) fullKey += '.'; if (!fullKey.empty()) fullKey += '.';
fullKey.append(*it); fullKey.append(*it);
printProperties(fullKey); printProperties(fullKey);
} }
} }
} }
private: private:
bool _helpRequested; bool _helpRequested;
}; };
POCO_APP_MAIN(SampleApp) POCO_APP_MAIN(SampleApp)

View File

@@ -1,17 +1,17 @@
# #
# Makefile # Makefile
# #
# $Id: //poco/1.2/Util/samples/SampleServer/Makefile#1 $ # $Id: //poco/1.2/Util/samples/SampleServer/Makefile#1 $
# #
# Makefile for Poco SampleServer # Makefile for Poco SampleServer
# #
include $(POCO_BASE)/build/rules/global include $(POCO_BASE)/build/rules/global
objects = SampleServer objects = SampleServer
target = SampleServer target = SampleServer
target_version = 1 target_version = 1
target_libs = PocoUtil PocoXML PocoFoundation target_libs = PocoUtil PocoXML PocoFoundation
include $(POCO_BASE)/build/rules/exec include $(POCO_BASE)/build/rules/exec

View File

@@ -1,5 +1,5 @@
# This is a sample configuration file. # This is a sample configuration file.
logging.loggers.root.channel = c1 logging.loggers.root.channel = c1
logging.channels.c1.class = FileChannel logging.channels.c1.class = FileChannel
logging.channels.c1.path = ${application.dir}SampleServer.log logging.channels.c1.path = ${application.dir}SampleServer.log
logging.channels.c1.pattern = %s: [%p] %t logging.channels.c1.pattern = %s: [%p] %t

View File

@@ -1,8 +1,8 @@
# #
# sample.vmsbuild # sample.vmsbuild
# #
# $Id: //poco/1.2/Util/samples/SampleServer/SampleServer.vmsbuild#1 $ # $Id: //poco/1.2/Util/samples/SampleServer/SampleServer.vmsbuild#1 $
# #
EXE=SampleServer EXE=SampleServer
SampleServer SampleServer
<SourceFilesHere> <SourceFilesHere>

View File

@@ -1,149 +1,149 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="7.10" Version="7.10"
Name="SampleServer" Name="SampleServer"
ProjectGUID="{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}" ProjectGUID="{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}"
Keyword="Win32Proj"> Keyword="Win32Proj">
<Platforms> <Platforms>
<Platform <Platform
Name="Win32"/> Name="Win32"/>
</Platforms> </Platforms>
<Configurations> <Configurations>
<Configuration <Configuration
Name="debug_shared|Win32" Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared" OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared" IntermediateDirectory="obj\debug_shared"
ConfigurationType="1" ConfigurationType="1"
UseOfMFC="2" UseOfMFC="2"
CharacterSet="2"> CharacterSet="2">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include" AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="TRUE" MinimalRebuild="TRUE"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
BufferSecurityCheck="TRUE" BufferSecurityCheck="TRUE"
TreatWChar_tAsBuiltInType="TRUE" TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE" ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE" RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/> DebugInformationFormat="4"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoUtild.lib" AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoUtild.lib"
OutputFile="bin/SampleServerd.exe" OutputFile="bin/SampleServerd.exe"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib" AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="TRUE" GenerateDebugInformation="TRUE"
ProgramDatabaseFile="bin/SampleServerd.pdb" ProgramDatabaseFile="bin/SampleServerd.pdb"
SubSystem="1" SubSystem="1"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
Name="VCPostBuildEventTool"/> Name="VCPostBuildEventTool"/>
<Tool <Tool
Name="VCPreBuildEventTool"/> Name="VCPreBuildEventTool"/>
<Tool <Tool
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool"/> Name="VCResourceCompilerTool"/>
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool"/> Name="VCWebServiceProxyGeneratorTool"/>
<Tool <Tool
Name="VCXMLDataGeneratorTool"/> Name="VCXMLDataGeneratorTool"/>
<Tool <Tool
Name="VCWebDeploymentTool"/> Name="VCWebDeploymentTool"/>
<Tool <Tool
Name="VCManagedWrapperGeneratorTool"/> Name="VCManagedWrapperGeneratorTool"/>
<Tool <Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration> </Configuration>
<Configuration <Configuration
Name="release_shared|Win32" Name="release_shared|Win32"
OutputDirectory="obj\release_shared" OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared" IntermediateDirectory="obj\release_shared"
ConfigurationType="1" ConfigurationType="1"
UseOfMFC="2" UseOfMFC="2"
CharacterSet="2"> CharacterSet="2">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="4" Optimization="4"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
EnableIntrinsicFunctions="TRUE" EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="TRUE" OmitFramePointers="TRUE"
OptimizeForWindowsApplication="TRUE" OptimizeForWindowsApplication="TRUE"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include" AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="2" RuntimeLibrary="2"
BufferSecurityCheck="FALSE" BufferSecurityCheck="FALSE"
TreatWChar_tAsBuiltInType="TRUE" TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE" ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE" RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/> DebugInformationFormat="3"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoUtil.lib" AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoUtil.lib"
OutputFile="bin/SampleServer.exe" OutputFile="bin/SampleServer.exe"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\lib" AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="FALSE" GenerateDebugInformation="FALSE"
ProgramDatabaseFile="" ProgramDatabaseFile=""
SubSystem="1" SubSystem="1"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
Name="VCPostBuildEventTool"/> Name="VCPostBuildEventTool"/>
<Tool <Tool
Name="VCPreBuildEventTool"/> Name="VCPreBuildEventTool"/>
<Tool <Tool
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool"/> Name="VCResourceCompilerTool"/>
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool"/> Name="VCWebServiceProxyGeneratorTool"/>
<Tool <Tool
Name="VCXMLDataGeneratorTool"/> Name="VCXMLDataGeneratorTool"/>
<Tool <Tool
Name="VCWebDeploymentTool"/> Name="VCWebDeploymentTool"/>
<Tool <Tool
Name="VCManagedWrapperGeneratorTool"/> Name="VCManagedWrapperGeneratorTool"/>
<Tool <Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration> </Configuration>
</Configurations> </Configurations>
<References> <References>
</References> </References>
<Files> <Files>
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter=""> Filter="">
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\SampleServer.cpp"> RelativePath=".\src\SampleServer.cpp">
</File> </File>
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
</VisualStudioProject> </VisualStudioProject>

View File

@@ -1,213 +1,213 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8.00" Version="8.00"
Name="SampleServer" Name="SampleServer"
ProjectGUID="{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}" ProjectGUID="{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}"
Keyword="Win32Proj" Keyword="Win32Proj"
> >
<Platforms> <Platforms>
<Platform <Platform
Name="Win32" Name="Win32"
/> />
</Platforms> </Platforms>
<ToolFiles> <ToolFiles>
</ToolFiles> </ToolFiles>
<Configurations> <Configurations>
<Configuration <Configuration
Name="debug_shared|Win32" Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared" OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared" IntermediateDirectory="obj\debug_shared"
ConfigurationType="1" ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="2" UseOfMFC="2"
CharacterSet="2" CharacterSet="2"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
/> />
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
/> />
<Tool <Tool
Name="VCXMLDataGeneratorTool" Name="VCXMLDataGeneratorTool"
/> />
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool" Name="VCWebServiceProxyGeneratorTool"
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
/> />
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include" AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
BufferSecurityCheck="true" BufferSecurityCheck="true"
TreatWChar_tAsBuiltInType="true" TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true" ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true" RuntimeTypeInfo="true"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="true" Detect64BitPortabilityProblems="true"
DebugInformationFormat="4" DebugInformationFormat="4"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
/> />
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoUtild.lib" AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib PocoUtild.lib"
OutputFile="bin/SampleServerd.exe" OutputFile="bin/SampleServerd.exe"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="..\..\..\lib" AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="true" GenerateDebugInformation="true"
ProgramDatabaseFile="bin/SampleServerd.pdb" ProgramDatabaseFile="bin/SampleServerd.pdb"
SubSystem="1" SubSystem="1"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
/> />
<Tool <Tool
Name="VCManifestTool" Name="VCManifestTool"
/> />
<Tool <Tool
Name="VCXDCMakeTool" Name="VCXDCMakeTool"
/> />
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
/> />
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
/> />
<Tool <Tool
Name="VCWebDeploymentTool" Name="VCWebDeploymentTool"
/> />
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
<Configuration <Configuration
Name="release_shared|Win32" Name="release_shared|Win32"
OutputDirectory="obj\release_shared" OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared" IntermediateDirectory="obj\release_shared"
ConfigurationType="1" ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="2" UseOfMFC="2"
CharacterSet="2" CharacterSet="2"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
/> />
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
/> />
<Tool <Tool
Name="VCXMLDataGeneratorTool" Name="VCXMLDataGeneratorTool"
/> />
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool" Name="VCWebServiceProxyGeneratorTool"
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
/> />
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="4" Optimization="4"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true" EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="true" OmitFramePointers="true"
AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include" AdditionalIncludeDirectories=".\include;..\..\..\Foundation\include;..\..\..\XML\include;..\..\..\Util\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="true" StringPooling="true"
RuntimeLibrary="2" RuntimeLibrary="2"
BufferSecurityCheck="false" BufferSecurityCheck="false"
TreatWChar_tAsBuiltInType="true" TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true" ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true" RuntimeTypeInfo="true"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="true" Detect64BitPortabilityProblems="true"
DebugInformationFormat="3" DebugInformationFormat="3"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
/> />
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoUtil.lib" AdditionalDependencies="PocoFoundation.lib PocoXML.lib PocoUtil.lib"
OutputFile="bin/SampleServer.exe" OutputFile="bin/SampleServer.exe"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="..\..\..\lib" AdditionalLibraryDirectories="..\..\..\lib"
GenerateDebugInformation="false" GenerateDebugInformation="false"
ProgramDatabaseFile="" ProgramDatabaseFile=""
SubSystem="1" SubSystem="1"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
/> />
<Tool <Tool
Name="VCManifestTool" Name="VCManifestTool"
/> />
<Tool <Tool
Name="VCXDCMakeTool" Name="VCXDCMakeTool"
/> />
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
/> />
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
/> />
<Tool <Tool
Name="VCWebDeploymentTool" Name="VCWebDeploymentTool"
/> />
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
</Configurations> </Configurations>
<References> <References>
</References> </References>
<Files> <Files>
<Filter <Filter
Name="Header Files" Name="Header Files"
> >
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
<File <File
RelativePath=".\src\SampleServer.cpp" RelativePath=".\src\SampleServer.cpp"
> >
</File> </File>
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
</VisualStudioProject> </VisualStudioProject>

View File

@@ -1,144 +1,144 @@
// //
// SampleServer.cpp // SampleServer.cpp
// //
// $Id: //poco/1.2/Util/samples/SampleServer/src/SampleServer.cpp#1 $ // $Id: //poco/1.2/Util/samples/SampleServer/src/SampleServer.cpp#1 $
// //
// This sample demonstrates the ServerApplication class. // This sample demonstrates the ServerApplication 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.
// //
#include "Poco/Util/ServerApplication.h" #include "Poco/Util/ServerApplication.h"
#include "Poco/Util/Option.h" #include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h" #include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h" #include "Poco/Util/HelpFormatter.h"
#include "Poco/Task.h" #include "Poco/Task.h"
#include "Poco/TaskManager.h" #include "Poco/TaskManager.h"
#include "Poco/DateTimeFormatter.h" #include "Poco/DateTimeFormatter.h"
#include <iostream> #include <iostream>
using Poco::Util::Application; using Poco::Util::Application;
using Poco::Util::ServerApplication; using Poco::Util::ServerApplication;
using Poco::Util::Option; using Poco::Util::Option;
using Poco::Util::OptionSet; using Poco::Util::OptionSet;
using Poco::Util::OptionCallback; using Poco::Util::OptionCallback;
using Poco::Util::HelpFormatter; using Poco::Util::HelpFormatter;
using Poco::Task; using Poco::Task;
using Poco::TaskManager; using Poco::TaskManager;
using Poco::DateTimeFormatter; using Poco::DateTimeFormatter;
class SampleTask: public Task class SampleTask: public Task
{ {
public: public:
SampleTask(): Task("SampleTask") SampleTask(): Task("SampleTask")
{ {
} }
void runTask() void runTask()
{ {
Application& app = Application::instance(); Application& app = Application::instance();
while (!sleep(5000)) while (!sleep(5000))
{ {
Application::instance().logger().information("busy doing nothing... " + DateTimeFormatter::format(app.uptime())); Application::instance().logger().information("busy doing nothing... " + DateTimeFormatter::format(app.uptime()));
} }
} }
}; };
class SampleServer: public ServerApplication class SampleServer: public ServerApplication
{ {
public: public:
SampleServer(): _helpRequested(false) SampleServer(): _helpRequested(false)
{ {
} }
~SampleServer() ~SampleServer()
{ {
} }
protected: protected:
void initialize(Application& self) void initialize(Application& self)
{ {
loadConfiguration(); // load default configuration files, if present loadConfiguration(); // load default configuration files, if present
ServerApplication::initialize(self); ServerApplication::initialize(self);
logger().information("starting up"); logger().information("starting up");
} }
void uninitialize() void uninitialize()
{ {
logger().information("shutting down"); logger().information("shutting down");
ServerApplication::uninitialize(); ServerApplication::uninitialize();
} }
void defineOptions(OptionSet& options) void defineOptions(OptionSet& options)
{ {
ServerApplication::defineOptions(options); ServerApplication::defineOptions(options);
options.addOption( options.addOption(
Option("help", "h", "display help information on command line arguments") Option("help", "h", "display help information on command line arguments")
.required(false) .required(false)
.repeatable(false) .repeatable(false)
.callback(OptionCallback<SampleServer>(this, &SampleServer::handleHelp))); .callback(OptionCallback<SampleServer>(this, &SampleServer::handleHelp)));
} }
void handleHelp(const std::string& name, const std::string& value) void handleHelp(const std::string& name, const std::string& value)
{ {
_helpRequested = true; _helpRequested = true;
displayHelp(); displayHelp();
stopOptionsProcessing(); stopOptionsProcessing();
} }
void displayHelp() void displayHelp()
{ {
HelpFormatter helpFormatter(options()); HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName()); helpFormatter.setCommand(commandName());
helpFormatter.setUsage("OPTIONS"); helpFormatter.setUsage("OPTIONS");
helpFormatter.setHeader("A sample server application that demonstrates some of the features of the Util::ServerApplication class."); helpFormatter.setHeader("A sample server application that demonstrates some of the features of the Util::ServerApplication class.");
helpFormatter.format(std::cout); helpFormatter.format(std::cout);
} }
int main(const std::vector<std::string>& args) int main(const std::vector<std::string>& args)
{ {
if (!_helpRequested) if (!_helpRequested)
{ {
TaskManager tm; TaskManager tm;
tm.start(new SampleTask); tm.start(new SampleTask);
waitForTerminationRequest(); waitForTerminationRequest();
tm.cancelAll(); tm.cancelAll();
tm.joinAll(); tm.joinAll();
} }
return Application::EXIT_OK; return Application::EXIT_OK;
} }
private: private:
bool _helpRequested; bool _helpRequested;
}; };
POCO_SERVER_MAIN(SampleServer) POCO_SERVER_MAIN(SampleServer)

View File

@@ -1,29 +1,29 @@
Microsoft Visual Studio Solution File, Format Version 8.00 Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleApp", "SampleApp\SampleApp_vs71.vcproj", "{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleApp", "SampleApp\SampleApp_vs71.vcproj", "{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}"
ProjectSection(ProjectDependencies) = postProject ProjectSection(ProjectDependencies) = postProject
EndProjectSection EndProjectSection
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleServer", "SampleServer\SampleServer_vs71.vcproj", "{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleServer", "SampleServer\SampleServer_vs71.vcproj", "{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}"
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
release_shared = release_shared release_shared = release_shared
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution GlobalSection(ProjectConfiguration) = postSolution
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.debug_shared.ActiveCfg = debug_shared|Win32 {73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.debug_shared.ActiveCfg = debug_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.debug_shared.Build.0 = debug_shared|Win32 {73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.debug_shared.Build.0 = debug_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.release_shared.ActiveCfg = release_shared|Win32 {73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.release_shared.ActiveCfg = release_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.release_shared.Build.0 = release_shared|Win32 {73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.release_shared.Build.0 = release_shared|Win32
{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.debug_shared.ActiveCfg = debug_shared|Win32 {0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.debug_shared.ActiveCfg = debug_shared|Win32
{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.debug_shared.Build.0 = debug_shared|Win32 {0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.debug_shared.Build.0 = debug_shared|Win32
{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.release_shared.ActiveCfg = release_shared|Win32 {0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.release_shared.ActiveCfg = release_shared|Win32
{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.release_shared.Build.0 = release_shared|Win32 {0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.release_shared.Build.0 = release_shared|Win32
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@@ -1,25 +1,25 @@
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}") = "SampleApp", "SampleApp\SampleApp_vs80.vcproj", "{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleApp", "SampleApp\SampleApp_vs80.vcproj", "{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}"
EndProject EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleServer", "SampleServer\SampleServer_vs80.vcproj", "{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}" Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleServer", "SampleServer\SampleServer_vs80.vcproj", "{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
debug_shared|Win32 = debug_shared|Win32 debug_shared|Win32 = debug_shared|Win32
release_shared|Win32 = release_shared|Win32 release_shared|Win32 = release_shared|Win32
EndGlobalSection EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution GlobalSection(ProjectConfigurationPlatforms) = postSolution
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.debug_shared|Win32.ActiveCfg = debug_shared|Win32 {73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.debug_shared|Win32.Build.0 = debug_shared|Win32 {73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.debug_shared|Win32.Build.0 = debug_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.release_shared|Win32.ActiveCfg = release_shared|Win32 {73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.release_shared|Win32.ActiveCfg = release_shared|Win32
{73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.release_shared|Win32.Build.0 = release_shared|Win32 {73408DCF-2E65-47AF-BF38-7466DAB8D5CB}.release_shared|Win32.Build.0 = release_shared|Win32
{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.debug_shared|Win32.ActiveCfg = debug_shared|Win32 {0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.debug_shared|Win32.ActiveCfg = debug_shared|Win32
{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.debug_shared|Win32.Build.0 = debug_shared|Win32 {0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.debug_shared|Win32.Build.0 = debug_shared|Win32
{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.release_shared|Win32.ActiveCfg = release_shared|Win32 {0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.release_shared|Win32.ActiveCfg = release_shared|Win32
{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.release_shared|Win32.Build.0 = release_shared|Win32 {0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}.release_shared|Win32.Build.0 = release_shared|Win32
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
EndGlobalSection EndGlobalSection
EndGlobal EndGlobal

View File

@@ -1,370 +1,370 @@
// //
// AbstractConfiguration.cpp // AbstractConfiguration.cpp
// //
// $Id: //poco/1.2/Util/src/AbstractConfiguration.cpp#1 $ // $Id: //poco/1.2/Util/src/AbstractConfiguration.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: AbstractConfiguration // Module: AbstractConfiguration
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
#include "Poco/Util/ConfigurationView.h" #include "Poco/Util/ConfigurationView.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/NumberParser.h" #include "Poco/NumberParser.h"
#include "Poco/NumberFormatter.h" #include "Poco/NumberFormatter.h"
#include "Poco/String.h" #include "Poco/String.h"
using Poco::FastMutex; using Poco::FastMutex;
using Poco::NotFoundException; using Poco::NotFoundException;
using Poco::SyntaxException; using Poco::SyntaxException;
using Poco::CircularReferenceException; using Poco::CircularReferenceException;
using Poco::NumberParser; using Poco::NumberParser;
using Poco::NumberFormatter; using Poco::NumberFormatter;
using Poco::icompare; using Poco::icompare;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
AbstractConfiguration::AbstractConfiguration(): _depth(0) AbstractConfiguration::AbstractConfiguration(): _depth(0)
{ {
} }
AbstractConfiguration::~AbstractConfiguration() AbstractConfiguration::~AbstractConfiguration()
{ {
} }
bool AbstractConfiguration::hasProperty(const std::string& key) const bool AbstractConfiguration::hasProperty(const std::string& key) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
std::string value; std::string value;
return getRaw(key, value); return getRaw(key, value);
} }
bool AbstractConfiguration::hasOption(const std::string& key) const bool AbstractConfiguration::hasOption(const std::string& key) const
{ {
return hasProperty(key); return hasProperty(key);
} }
std::string AbstractConfiguration::getString(const std::string& key) const std::string AbstractConfiguration::getString(const std::string& key) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
std::string value; std::string value;
if (getRaw(key, value)) if (getRaw(key, value))
return internalExpand(value); return internalExpand(value);
else else
throw NotFoundException(key); throw NotFoundException(key);
} }
std::string AbstractConfiguration::getString(const std::string& key, const std::string& defaultValue) const std::string AbstractConfiguration::getString(const std::string& key, const std::string& defaultValue) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
std::string value; std::string value;
if (getRaw(key, value)) if (getRaw(key, value))
return internalExpand(value); return internalExpand(value);
else else
return defaultValue; return defaultValue;
} }
std::string AbstractConfiguration::getRawString(const std::string& key) const std::string AbstractConfiguration::getRawString(const std::string& key) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
std::string value; std::string value;
if (getRaw(key, value)) if (getRaw(key, value))
return value; return value;
else else
throw NotFoundException(key); throw NotFoundException(key);
} }
std::string AbstractConfiguration::getRawString(const std::string& key, const std::string& defaultValue) const std::string AbstractConfiguration::getRawString(const std::string& key, const std::string& defaultValue) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
std::string value; std::string value;
if (getRaw(key, value)) if (getRaw(key, value))
return value; return value;
else else
return defaultValue; return defaultValue;
} }
int AbstractConfiguration::getInt(const std::string& key) const int AbstractConfiguration::getInt(const std::string& key) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
std::string value; std::string value;
if (getRaw(key, value)) if (getRaw(key, value))
return parseInt(internalExpand(value)); return parseInt(internalExpand(value));
else else
throw NotFoundException(key); throw NotFoundException(key);
} }
int AbstractConfiguration::getInt(const std::string& key, int defaultValue) const int AbstractConfiguration::getInt(const std::string& key, int defaultValue) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
std::string value; std::string value;
if (getRaw(key, value)) if (getRaw(key, value))
return parseInt(internalExpand(value)); return parseInt(internalExpand(value));
else else
return defaultValue; return defaultValue;
} }
double AbstractConfiguration::getDouble(const std::string& key) const double AbstractConfiguration::getDouble(const std::string& key) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
std::string value; std::string value;
if (getRaw(key, value)) if (getRaw(key, value))
return NumberParser::parseFloat(internalExpand(value)); return NumberParser::parseFloat(internalExpand(value));
else else
throw NotFoundException(key); throw NotFoundException(key);
} }
double AbstractConfiguration::getDouble(const std::string& key, double defaultValue) const double AbstractConfiguration::getDouble(const std::string& key, double defaultValue) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
std::string value; std::string value;
if (getRaw(key, value)) if (getRaw(key, value))
return NumberParser::parseFloat(internalExpand(value)); return NumberParser::parseFloat(internalExpand(value));
else else
return defaultValue; return defaultValue;
} }
bool AbstractConfiguration::getBool(const std::string& key) const bool AbstractConfiguration::getBool(const std::string& key) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
std::string value; std::string value;
if (getRaw(key, value)) if (getRaw(key, value))
return parseBool(internalExpand(value)); return parseBool(internalExpand(value));
else else
throw NotFoundException(key); throw NotFoundException(key);
} }
bool AbstractConfiguration::getBool(const std::string& key, bool defaultValue) const bool AbstractConfiguration::getBool(const std::string& key, bool defaultValue) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
std::string value; std::string value;
if (getRaw(key, value)) if (getRaw(key, value))
return parseBool(internalExpand(value)); return parseBool(internalExpand(value));
else else
return defaultValue; return defaultValue;
} }
void AbstractConfiguration::setString(const std::string& key, const std::string& value) void AbstractConfiguration::setString(const std::string& key, const std::string& value)
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
setRaw(key, value); setRaw(key, value);
} }
void AbstractConfiguration::setInt(const std::string& key, int value) void AbstractConfiguration::setInt(const std::string& key, int value)
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
setRaw(key, NumberFormatter::format(value)); setRaw(key, NumberFormatter::format(value));
} }
void AbstractConfiguration::setDouble(const std::string& key, double value) void AbstractConfiguration::setDouble(const std::string& key, double value)
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
setRaw(key, NumberFormatter::format(value)); setRaw(key, NumberFormatter::format(value));
} }
void AbstractConfiguration::setBool(const std::string& key, bool value) void AbstractConfiguration::setBool(const std::string& key, bool value)
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
setRaw(key, value ? "true" : "false"); setRaw(key, value ? "true" : "false");
} }
void AbstractConfiguration::keys(Keys& range) const void AbstractConfiguration::keys(Keys& range) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
std::string key; std::string key;
range.clear(); range.clear();
enumerate(key, range); enumerate(key, range);
} }
void AbstractConfiguration::keys(const std::string& key, Keys& range) const void AbstractConfiguration::keys(const std::string& key, Keys& range) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
range.clear(); range.clear();
enumerate(key, range); enumerate(key, range);
} }
const AbstractConfiguration* AbstractConfiguration::createView(const std::string& prefix) const const AbstractConfiguration* AbstractConfiguration::createView(const std::string& prefix) const
{ {
return new ConfigurationView(prefix, const_cast<AbstractConfiguration*>(this)); return new ConfigurationView(prefix, const_cast<AbstractConfiguration*>(this));
} }
AbstractConfiguration* AbstractConfiguration::createView(const std::string& prefix) AbstractConfiguration* AbstractConfiguration::createView(const std::string& prefix)
{ {
return new ConfigurationView(prefix, this); return new ConfigurationView(prefix, this);
} }
namespace namespace
{ {
class AutoCounter class AutoCounter
{ {
public: public:
AutoCounter(int& count): _count(count) AutoCounter(int& count): _count(count)
{ {
++_count; ++_count;
} }
~AutoCounter() ~AutoCounter()
{ {
--_count; --_count;
} }
private: private:
int& _count; int& _count;
}; };
} }
std::string AbstractConfiguration::expand(const std::string& value) const std::string AbstractConfiguration::expand(const std::string& value) const
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
return internalExpand(value); return internalExpand(value);
} }
std::string AbstractConfiguration::internalExpand(const std::string& value) const std::string AbstractConfiguration::internalExpand(const std::string& value) const
{ {
AutoCounter counter(_depth); AutoCounter counter(_depth);
if (_depth > 10) throw CircularReferenceException("Too many property references encountered"); if (_depth > 10) throw CircularReferenceException("Too many property references encountered");
return uncheckedExpand(value); return uncheckedExpand(value);
} }
std::string AbstractConfiguration::uncheckedExpand(const std::string& value) const std::string AbstractConfiguration::uncheckedExpand(const std::string& value) const
{ {
std::string result; std::string result;
std::string::const_iterator it = value.begin(); std::string::const_iterator it = value.begin();
std::string::const_iterator end = value.end(); std::string::const_iterator end = value.end();
while (it != end) while (it != end)
{ {
if (*it == '$') if (*it == '$')
{ {
++it; ++it;
if (it != end && *it == '{') if (it != end && *it == '{')
{ {
++it; ++it;
std::string prop; std::string prop;
while (it != end && *it != '}') prop += *it++; while (it != end && *it != '}') prop += *it++;
if (it != end) ++it; if (it != end) ++it;
std::string value; std::string value;
if (getRaw(prop, value)) if (getRaw(prop, value))
{ {
result.append(internalExpand(value)); result.append(internalExpand(value));
} }
else else
{ {
result.append("${"); result.append("${");
result.append(prop); result.append(prop);
result.append("}"); result.append("}");
} }
} }
else result += *it++; else result += *it++;
} }
else result += *it++; else result += *it++;
} }
return result; return result;
} }
int AbstractConfiguration::parseInt(const std::string& value) int AbstractConfiguration::parseInt(const std::string& value)
{ {
if (value.compare(0, 2, "0x") == 0) if (value.compare(0, 2, "0x") == 0)
return NumberParser::parseHex(value.substr(2)); return NumberParser::parseHex(value.substr(2));
else else
return NumberParser::parse(value); return NumberParser::parse(value);
} }
bool AbstractConfiguration::parseBool(const std::string& value) bool AbstractConfiguration::parseBool(const std::string& value)
{ {
int n; int n;
if (NumberParser::tryParse(value, n)) if (NumberParser::tryParse(value, n))
return n != 0; return n != 0;
else if (icompare(value, "true") == 0) else if (icompare(value, "true") == 0)
return true; return true;
else if (icompare(value, "yes") == 0) else if (icompare(value, "yes") == 0)
return true; return true;
else if (icompare(value, "on") == 0) else if (icompare(value, "on") == 0)
return true; return true;
else if (icompare(value, "false") == 0) else if (icompare(value, "false") == 0)
return false; return false;
else if (icompare(value, "no") == 0) else if (icompare(value, "no") == 0)
return false; return false;
else if (icompare(value, "off") == 0) else if (icompare(value, "off") == 0)
return false; return false;
else else
throw SyntaxException("Cannot convert to boolean", value); throw SyntaxException("Cannot convert to boolean", value);
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,498 +1,498 @@
// //
// Application.cpp // Application.cpp
// //
// $Id: //poco/1.2/Util/src/Application.cpp#1 $ // $Id: //poco/1.2/Util/src/Application.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Application // Package: Application
// Module: Application // Module: Application
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/Application.h" #include "Poco/Util/Application.h"
#include "Poco/Util/SystemConfiguration.h" #include "Poco/Util/SystemConfiguration.h"
#include "Poco/Util/MapConfiguration.h" #include "Poco/Util/MapConfiguration.h"
#include "Poco/Util/PropertyFileConfiguration.h" #include "Poco/Util/PropertyFileConfiguration.h"
#include "Poco/Util/IniFileConfiguration.h" #include "Poco/Util/IniFileConfiguration.h"
#include "Poco/Util/XMLConfiguration.h" #include "Poco/Util/XMLConfiguration.h"
#include "Poco/Util/LoggingSubsystem.h" #include "Poco/Util/LoggingSubsystem.h"
#include "Poco/Util/Option.h" #include "Poco/Util/Option.h"
#include "Poco/Util/OptionProcessor.h" #include "Poco/Util/OptionProcessor.h"
#include "Poco/Util/Validator.h" #include "Poco/Util/Validator.h"
#include "Poco/Environment.h" #include "Poco/Environment.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/NumberFormatter.h" #include "Poco/NumberFormatter.h"
#include "Poco/File.h" #include "Poco/File.h"
#include "Poco/Path.h" #include "Poco/Path.h"
#include "Poco/String.h" #include "Poco/String.h"
#include "Poco/ConsoleChannel.h" #include "Poco/ConsoleChannel.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#if defined(POCO_OS_FAMILY_WINDOWS) #if defined(POCO_OS_FAMILY_WINDOWS)
#include <windows.h> #include <windows.h>
#endif #endif
#if defined(POCO_OS_FAMILY_UNIX) #if defined(POCO_OS_FAMILY_UNIX)
#include "Poco/SignalHandler.h" #include "Poco/SignalHandler.h"
#endif #endif
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
#include "Poco/UnicodeConverter.h" #include "Poco/UnicodeConverter.h"
#endif #endif
using Poco::Logger; using Poco::Logger;
using Poco::Path; using Poco::Path;
using Poco::File; using Poco::File;
using Poco::Environment; using Poco::Environment;
using Poco::SystemException; using Poco::SystemException;
using Poco::ConsoleChannel; using Poco::ConsoleChannel;
using Poco::NumberFormatter; using Poco::NumberFormatter;
using Poco::AutoPtr; using Poco::AutoPtr;
using Poco::icompare; using Poco::icompare;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
Application* Application::_pInstance = 0; Application* Application::_pInstance = 0;
Application::Application(): Application::Application():
_pConfig(new LayeredConfiguration), _pConfig(new LayeredConfiguration),
_initialized(false), _initialized(false),
_unixOptions(true), _unixOptions(true),
_pLogger(&Logger::get("ApplicationStartup")), _pLogger(&Logger::get("ApplicationStartup")),
_stopOptionsProcessing(false) _stopOptionsProcessing(false)
{ {
setup(); setup();
} }
Application::Application(int argc, char* argv[]): Application::Application(int argc, char* argv[]):
_pConfig(new LayeredConfiguration), _pConfig(new LayeredConfiguration),
_initialized(false), _initialized(false),
_unixOptions(true), _unixOptions(true),
_pLogger(&Logger::get("ApplicationStartup")), _pLogger(&Logger::get("ApplicationStartup")),
_stopOptionsProcessing(false) _stopOptionsProcessing(false)
{ {
setup(); setup();
init(argc, argv); init(argc, argv);
} }
Application::~Application() Application::~Application()
{ {
try try
{ {
uninitialize(); uninitialize();
} }
catch (...) catch (...)
{ {
} }
_pInstance = 0; _pInstance = 0;
} }
void Application::setup() void Application::setup()
{ {
poco_assert (_pInstance == 0); poco_assert (_pInstance == 0);
_pConfig->add(new SystemConfiguration, false); _pConfig->add(new SystemConfiguration, false);
_pConfig->add(new MapConfiguration, false); _pConfig->add(new MapConfiguration, false);
addSubsystem(new LoggingSubsystem); addSubsystem(new LoggingSubsystem);
#if defined(POCO_OS_FAMILY_UNIX) #if defined(POCO_OS_FAMILY_UNIX)
#if !defined(_DEBUG) #if !defined(_DEBUG)
Poco::SignalHandler::install(); Poco::SignalHandler::install();
#endif #endif
#else #else
setUnixOptions(false); setUnixOptions(false);
#endif #endif
_pInstance = this; _pInstance = this;
AutoPtr<ConsoleChannel> pCC = new ConsoleChannel; AutoPtr<ConsoleChannel> pCC = new ConsoleChannel;
Logger::setChannel("", pCC); Logger::setChannel("", pCC);
} }
void Application::addSubsystem(Subsystem* pSubsystem) void Application::addSubsystem(Subsystem* pSubsystem)
{ {
poco_check_ptr (pSubsystem); poco_check_ptr (pSubsystem);
_subsystems.push_back(pSubsystem); _subsystems.push_back(pSubsystem);
} }
void Application::init(int argc, char* argv[]) void Application::init(int argc, char* argv[])
{ {
setArgs(argc, argv); setArgs(argc, argv);
init(); init();
} }
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
void Application::init(int argc, wchar_t* argv[]) void Application::init(int argc, wchar_t* argv[])
{ {
std::vector<std::string> args; std::vector<std::string> args;
for (int i = 0; i < argc; ++i) for (int i = 0; i < argc; ++i)
{ {
std::string arg; std::string arg;
Poco::UnicodeConverter::toUTF8(argv[i], arg); Poco::UnicodeConverter::toUTF8(argv[i], arg);
args.push_back(arg); args.push_back(arg);
} }
init(args); init(args);
} }
#endif #endif
void Application::init(const std::vector<std::string>& args) void Application::init(const std::vector<std::string>& args)
{ {
setArgs(args); setArgs(args);
init(); init();
} }
void Application::init() void Application::init()
{ {
Path appPath; Path appPath;
getApplicationPath(appPath); getApplicationPath(appPath);
_pConfig->setString("application.path", appPath.toString()); _pConfig->setString("application.path", appPath.toString());
_pConfig->setString("application.name", appPath.getFileName()); _pConfig->setString("application.name", appPath.getFileName());
_pConfig->setString("application.baseName", appPath.getBaseName()); _pConfig->setString("application.baseName", appPath.getBaseName());
_pConfig->setString("application.dir", appPath.parent().toString()); _pConfig->setString("application.dir", appPath.parent().toString());
_pConfig->setString("application.configDir", appPath.parent().toString()); _pConfig->setString("application.configDir", appPath.parent().toString());
processOptions(); processOptions();
initialize(*this); initialize(*this);
} }
const char* Application::name() const const char* Application::name() const
{ {
return "Application"; return "Application";
} }
void Application::initialize(Application& self) void Application::initialize(Application& self)
{ {
for (SubsystemVec::iterator it = _subsystems.begin(); it != _subsystems.end(); ++it) for (SubsystemVec::iterator it = _subsystems.begin(); it != _subsystems.end(); ++it)
{ {
_pLogger->debug(std::string("Initializing subsystem: ") + (*it)->name()); _pLogger->debug(std::string("Initializing subsystem: ") + (*it)->name());
(*it)->initialize(self); (*it)->initialize(self);
} }
_initialized = true; _initialized = true;
} }
void Application::uninitialize() void Application::uninitialize()
{ {
if (_initialized) if (_initialized)
{ {
for (SubsystemVec::reverse_iterator it = _subsystems.rbegin(); it != _subsystems.rend(); ++it) for (SubsystemVec::reverse_iterator it = _subsystems.rbegin(); it != _subsystems.rend(); ++it)
{ {
_pLogger->debug(std::string("Uninitializing subsystem: ") + (*it)->name()); _pLogger->debug(std::string("Uninitializing subsystem: ") + (*it)->name());
(*it)->uninitialize(); (*it)->uninitialize();
} }
_initialized = false; _initialized = false;
} }
} }
void Application::reinitialize(Application& self) void Application::reinitialize(Application& self)
{ {
for (SubsystemVec::iterator it = _subsystems.begin(); it != _subsystems.end(); ++it) for (SubsystemVec::iterator it = _subsystems.begin(); it != _subsystems.end(); ++it)
{ {
_pLogger->debug(std::string("Re-initializing subsystem: ") + (*it)->name()); _pLogger->debug(std::string("Re-initializing subsystem: ") + (*it)->name());
(*it)->reinitialize(self); (*it)->reinitialize(self);
} }
} }
void Application::setUnixOptions(bool flag) void Application::setUnixOptions(bool flag)
{ {
_unixOptions = flag; _unixOptions = flag;
} }
int Application::loadConfiguration() int Application::loadConfiguration()
{ {
int n = 0; int n = 0;
Path appPath; Path appPath;
getApplicationPath(appPath); getApplicationPath(appPath);
Path cfgPath; Path cfgPath;
if (findAppConfigFile(appPath.getBaseName(), "properties", cfgPath)) if (findAppConfigFile(appPath.getBaseName(), "properties", cfgPath))
{ {
_pConfig->addFront(new PropertyFileConfiguration(cfgPath.toString()), false); _pConfig->addFront(new PropertyFileConfiguration(cfgPath.toString()), false);
++n; ++n;
} }
if (findAppConfigFile(appPath.getBaseName(), "ini", cfgPath)) if (findAppConfigFile(appPath.getBaseName(), "ini", cfgPath))
{ {
_pConfig->addFront(new IniFileConfiguration(cfgPath.toString()), false); _pConfig->addFront(new IniFileConfiguration(cfgPath.toString()), false);
++n; ++n;
} }
if (findAppConfigFile(appPath.getBaseName(), "xml", cfgPath)) if (findAppConfigFile(appPath.getBaseName(), "xml", cfgPath))
{ {
_pConfig->addFront(new XMLConfiguration(cfgPath.toString()), false); _pConfig->addFront(new XMLConfiguration(cfgPath.toString()), false);
++n; ++n;
} }
if (n > 0) if (n > 0)
{ {
_pConfig->setString("application.configDir", cfgPath.parent().toString()); _pConfig->setString("application.configDir", cfgPath.parent().toString());
} }
return n; return n;
} }
void Application::loadConfiguration(const std::string& path) void Application::loadConfiguration(const std::string& path)
{ {
Path confPath(path); Path confPath(path);
std::string ext = confPath.getExtension(); std::string ext = confPath.getExtension();
if (icompare(ext, "properties") == 0) if (icompare(ext, "properties") == 0)
_pConfig->addFront(new PropertyFileConfiguration(confPath.toString()), false); _pConfig->addFront(new PropertyFileConfiguration(confPath.toString()), false);
else if (icompare(ext, "ini") == 0) else if (icompare(ext, "ini") == 0)
_pConfig->addFront(new IniFileConfiguration(confPath.toString()), false); _pConfig->addFront(new IniFileConfiguration(confPath.toString()), false);
else if (icompare(ext, "xml") == 0) else if (icompare(ext, "xml") == 0)
_pConfig->addFront(new XMLConfiguration(confPath.toString()), false); _pConfig->addFront(new XMLConfiguration(confPath.toString()), false);
else else
throw Poco::InvalidArgumentException("Unsupported configuration file type", ext); throw Poco::InvalidArgumentException("Unsupported configuration file type", ext);
} }
std::string Application::commandName() const std::string Application::commandName() const
{ {
return _pConfig->getString("application.baseName"); return _pConfig->getString("application.baseName");
} }
void Application::stopOptionsProcessing() void Application::stopOptionsProcessing()
{ {
_stopOptionsProcessing = true; _stopOptionsProcessing = true;
} }
int Application::run() int Application::run()
{ {
try try
{ {
return main(_args); return main(_args);
} }
catch (Poco::Exception& exc) catch (Poco::Exception& exc)
{ {
logger().log(exc); logger().log(exc);
} }
catch (std::exception& exc) catch (std::exception& exc)
{ {
logger().error(exc.what()); logger().error(exc.what());
} }
catch (...) catch (...)
{ {
logger().fatal("system exception"); logger().fatal("system exception");
} }
return EXIT_SOFTWARE; return EXIT_SOFTWARE;
} }
int Application::main(const std::vector<std::string>& args) int Application::main(const std::vector<std::string>& args)
{ {
return EXIT_OK; return EXIT_OK;
} }
void Application::setArgs(int argc, char* argv[]) void Application::setArgs(int argc, char* argv[])
{ {
_command = argv[0]; _command = argv[0];
_pConfig->setInt("application.argc", argc); _pConfig->setInt("application.argc", argc);
_args.reserve(argc); _args.reserve(argc);
std::string argvKey = "application.argv["; std::string argvKey = "application.argv[";
for (int i = 0; i < argc; ++i) for (int i = 0; i < argc; ++i)
{ {
std::string arg(argv[i]); std::string arg(argv[i]);
_pConfig->setString(argvKey + NumberFormatter::format(i) + "]", arg); _pConfig->setString(argvKey + NumberFormatter::format(i) + "]", arg);
_args.push_back(arg); _args.push_back(arg);
} }
} }
void Application::setArgs(const std::vector<std::string>& args) void Application::setArgs(const std::vector<std::string>& args)
{ {
poco_assert (!args.empty()); poco_assert (!args.empty());
_command = args[0]; _command = args[0];
_pConfig->setInt("application.argc", (int) args.size()); _pConfig->setInt("application.argc", (int) args.size());
_args = args; _args = args;
std::string argvKey = "application.argv["; std::string argvKey = "application.argv[";
for (int i = 0; i < args.size(); ++i) for (int i = 0; i < args.size(); ++i)
{ {
_pConfig->setString(argvKey + NumberFormatter::format(i) + "]", args[i]); _pConfig->setString(argvKey + NumberFormatter::format(i) + "]", args[i]);
} }
} }
void Application::processOptions() void Application::processOptions()
{ {
defineOptions(_options); defineOptions(_options);
OptionProcessor processor(_options); OptionProcessor processor(_options);
processor.setUnixStyle(_unixOptions); processor.setUnixStyle(_unixOptions);
_args.erase(_args.begin()); _args.erase(_args.begin());
ArgVec::iterator it = _args.begin(); ArgVec::iterator it = _args.begin();
while (it != _args.end() && !_stopOptionsProcessing) while (it != _args.end() && !_stopOptionsProcessing)
{ {
std::string name; std::string name;
std::string value; std::string value;
if (processor.process(*it, name, value)) if (processor.process(*it, name, value))
{ {
handleOption(name, value); handleOption(name, value);
it = _args.erase(it); it = _args.erase(it);
} }
else ++it; else ++it;
} }
if (!_stopOptionsProcessing) if (!_stopOptionsProcessing)
processor.checkRequired(); processor.checkRequired();
} }
void Application::getApplicationPath(Poco::Path& appPath) const void Application::getApplicationPath(Poco::Path& appPath) const
{ {
#if defined(POCO_OS_FAMILY_UNIX) #if defined(POCO_OS_FAMILY_UNIX)
if (_command.find('/') != std::string::npos) if (_command.find('/') != std::string::npos)
{ {
Path path(_command); Path path(_command);
if (path.isAbsolute()) if (path.isAbsolute())
{ {
appPath = path; appPath = path;
} }
else else
{ {
appPath = Path::current(); appPath = Path::current();
appPath.append(path); appPath.append(path);
} }
} }
else else
{ {
if (!Path::find(Environment::get("PATH"), _command, appPath)) if (!Path::find(Environment::get("PATH"), _command, appPath))
appPath = Path(Path::current(), _command); appPath = Path(Path::current(), _command);
} }
#elif defined(POCO_OS_FAMILY_WINDOWS) #elif defined(POCO_OS_FAMILY_WINDOWS)
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
wchar_t path[1024]; wchar_t path[1024];
int n = GetModuleFileNameW(0, path, sizeof(path)/sizeof(wchar_t)); int n = GetModuleFileNameW(0, path, sizeof(path)/sizeof(wchar_t));
if (n > 0) if (n > 0)
{ {
std::string p; std::string p;
Poco::UnicodeConverter::toUTF8(path, p); Poco::UnicodeConverter::toUTF8(path, p);
appPath = p; appPath = p;
} }
else throw SystemException("Cannot get application file name."); else throw SystemException("Cannot get application file name.");
#else #else
char path[1024]; char path[1024];
int n = GetModuleFileName(0, path, sizeof(path)); int n = GetModuleFileName(0, path, sizeof(path));
if (n > 0) if (n > 0)
appPath = path; appPath = path;
else else
throw SystemException("Cannot get application file name."); throw SystemException("Cannot get application file name.");
#endif #endif
#else #else
appPath = _command; appPath = _command;
#endif #endif
} }
bool Application::findFile(Poco::Path& path) const bool Application::findFile(Poco::Path& path) const
{ {
if (path.isAbsolute()) return true; if (path.isAbsolute()) return true;
Path appPath; Path appPath;
getApplicationPath(appPath); getApplicationPath(appPath);
Path base = appPath.parent(); Path base = appPath.parent();
while (base.depth() > 0) while (base.depth() > 0)
{ {
Path p(base, path); Path p(base, path);
File f(p); File f(p);
if (f.exists()) if (f.exists())
{ {
path = p; path = p;
return true; return true;
} }
base.popDirectory(); base.popDirectory();
} }
return false; return false;
} }
bool Application::findAppConfigFile(const std::string& appName, const std::string& extension, Path& path) const bool Application::findAppConfigFile(const std::string& appName, const std::string& extension, Path& path) const
{ {
poco_assert (!appName.empty()); poco_assert (!appName.empty());
Path p(appName); Path p(appName);
p.setExtension(extension); p.setExtension(extension);
bool found = findFile(p); bool found = findFile(p);
if (!found) if (!found)
{ {
#if defined(_DEBUG) #if defined(_DEBUG)
if (appName[appName.length() - 1] == 'd') if (appName[appName.length() - 1] == 'd')
{ {
p.setBaseName(appName.substr(0, appName.length() - 1)); p.setBaseName(appName.substr(0, appName.length() - 1));
found = findFile(p); found = findFile(p);
} }
#endif #endif
} }
if (found) if (found)
path = p; path = p;
return found; return found;
} }
void Application::defineOptions(OptionSet& options) void Application::defineOptions(OptionSet& options)
{ {
} }
void Application::handleOption(const std::string& name, const std::string& value) void Application::handleOption(const std::string& name, const std::string& value)
{ {
const Option& option = _options.getOption(name); const Option& option = _options.getOption(name);
if (option.validator()) if (option.validator())
{ {
option.validator()->validate(option, value); option.validator()->validate(option, value);
} }
if (!option.binding().empty()) if (!option.binding().empty())
{ {
config().setString(option.binding(), value); config().setString(option.binding(), value);
} }
if (option.callback()) if (option.callback())
{ {
option.callback()->invoke(name, value); option.callback()->invoke(name, value);
} }
} }
void Application::setLogger(Logger& logger) void Application::setLogger(Logger& logger)
{ {
_pLogger = &logger; _pLogger = &logger;
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,116 +1,116 @@
// //
// ConfigurationMapper.cpp // ConfigurationMapper.cpp
// //
// $Id: //poco/1.2/Util/src/ConfigurationMapper.cpp#1 $ // $Id: //poco/1.2/Util/src/ConfigurationMapper.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: ConfigurationMapper // Module: ConfigurationMapper
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/ConfigurationMapper.h" #include "Poco/Util/ConfigurationMapper.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
ConfigurationMapper::ConfigurationMapper(const std::string& fromPrefix, const std::string& toPrefix, AbstractConfiguration* pConfig): ConfigurationMapper::ConfigurationMapper(const std::string& fromPrefix, const std::string& toPrefix, AbstractConfiguration* pConfig):
_fromPrefix(fromPrefix), _fromPrefix(fromPrefix),
_toPrefix(toPrefix), _toPrefix(toPrefix),
_pConfig(pConfig) _pConfig(pConfig)
{ {
poco_check_ptr (pConfig); poco_check_ptr (pConfig);
if (!_fromPrefix.empty()) _fromPrefix += '.'; if (!_fromPrefix.empty()) _fromPrefix += '.';
if (!_toPrefix.empty()) _toPrefix += '.'; if (!_toPrefix.empty()) _toPrefix += '.';
_pConfig->duplicate(); _pConfig->duplicate();
} }
ConfigurationMapper::~ConfigurationMapper() ConfigurationMapper::~ConfigurationMapper()
{ {
_pConfig->release(); _pConfig->release();
} }
bool ConfigurationMapper::getRaw(const std::string& key, std::string& value) const bool ConfigurationMapper::getRaw(const std::string& key, std::string& value) const
{ {
std::string translatedKey = translateKey(key); std::string translatedKey = translateKey(key);
return _pConfig->getRaw(translatedKey, value); return _pConfig->getRaw(translatedKey, value);
} }
void ConfigurationMapper::setRaw(const std::string& key, const std::string& value) void ConfigurationMapper::setRaw(const std::string& key, const std::string& value)
{ {
std::string translatedKey = translateKey(key); std::string translatedKey = translateKey(key);
_pConfig->setRaw(translatedKey, value); _pConfig->setRaw(translatedKey, value);
} }
void ConfigurationMapper::enumerate(const std::string& key, Keys& range) const void ConfigurationMapper::enumerate(const std::string& key, Keys& range) const
{ {
std::string cKey(key); std::string cKey(key);
if (!cKey.empty()) cKey += '.'; if (!cKey.empty()) cKey += '.';
std::string::size_type keyLen = cKey.length(); std::string::size_type keyLen = cKey.length();
if (keyLen < _toPrefix.length()) if (keyLen < _toPrefix.length())
{ {
if (_toPrefix.compare(0, keyLen, cKey) == 0) if (_toPrefix.compare(0, keyLen, cKey) == 0)
{ {
std::string::size_type pos = _toPrefix.find_first_of('.', keyLen); std::string::size_type pos = _toPrefix.find_first_of('.', keyLen);
poco_assert_dbg(pos != std::string::npos); poco_assert_dbg(pos != std::string::npos);
range.push_back(_toPrefix.substr(keyLen, pos - keyLen)); range.push_back(_toPrefix.substr(keyLen, pos - keyLen));
} }
} }
else else
{ {
std::string translatedKey; std::string translatedKey;
if (cKey == _toPrefix) if (cKey == _toPrefix)
{ {
translatedKey = _fromPrefix; translatedKey = _fromPrefix;
if (!translatedKey.empty()) if (!translatedKey.empty())
translatedKey.resize(translatedKey.length() - 1); translatedKey.resize(translatedKey.length() - 1);
} }
else translatedKey = translateKey(key); else translatedKey = translateKey(key);
_pConfig->enumerate(translatedKey, range); _pConfig->enumerate(translatedKey, range);
} }
} }
std::string ConfigurationMapper::translateKey(const std::string& key) const std::string ConfigurationMapper::translateKey(const std::string& key) const
{ {
std::string result(key); std::string result(key);
if (result.compare(0, _toPrefix.size(), _toPrefix) == 0) if (result.compare(0, _toPrefix.size(), _toPrefix) == 0)
result.replace(0, _toPrefix.size(), _fromPrefix); result.replace(0, _toPrefix.size(), _fromPrefix);
return result; return result;
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,90 +1,90 @@
// //
// ConfigurationView.cpp // ConfigurationView.cpp
// //
// $Id: //poco/1.2/Util/src/ConfigurationView.cpp#1 $ // $Id: //poco/1.2/Util/src/ConfigurationView.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: ConfigurationView // Module: ConfigurationView
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/ConfigurationView.h" #include "Poco/Util/ConfigurationView.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
ConfigurationView::ConfigurationView(const std::string& prefix, AbstractConfiguration* pConfig): ConfigurationView::ConfigurationView(const std::string& prefix, AbstractConfiguration* pConfig):
_prefix(prefix), _prefix(prefix),
_pConfig(pConfig) _pConfig(pConfig)
{ {
poco_check_ptr (pConfig); poco_check_ptr (pConfig);
_pConfig->duplicate(); _pConfig->duplicate();
} }
ConfigurationView::~ConfigurationView() ConfigurationView::~ConfigurationView()
{ {
_pConfig->release(); _pConfig->release();
} }
bool ConfigurationView::getRaw(const std::string& key, std::string& value) const bool ConfigurationView::getRaw(const std::string& key, std::string& value) const
{ {
std::string translatedKey = translateKey(key); std::string translatedKey = translateKey(key);
return _pConfig->getRaw(translatedKey, value) || _pConfig->getRaw(key, value); return _pConfig->getRaw(translatedKey, value) || _pConfig->getRaw(key, value);
} }
void ConfigurationView::setRaw(const std::string& key, const std::string& value) void ConfigurationView::setRaw(const std::string& key, const std::string& value)
{ {
std::string translatedKey = translateKey(key); std::string translatedKey = translateKey(key);
_pConfig->setRaw(translatedKey, value); _pConfig->setRaw(translatedKey, value);
} }
void ConfigurationView::enumerate(const std::string& key, Keys& range) const void ConfigurationView::enumerate(const std::string& key, Keys& range) const
{ {
std::string translatedKey = translateKey(key); std::string translatedKey = translateKey(key);
_pConfig->enumerate(translatedKey, range); _pConfig->enumerate(translatedKey, range);
} }
std::string ConfigurationView::translateKey(const std::string& key) const std::string ConfigurationView::translateKey(const std::string& key) const
{ {
std::string result = _prefix; std::string result = _prefix;
if (!result.empty() && !key.empty()) result += '.'; if (!result.empty() && !key.empty()) result += '.';
result += key; result += key;
return result; return result;
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,132 +1,132 @@
// //
// FilesystemConfiguration.cpp // FilesystemConfiguration.cpp
// //
// $Id: //poco/1.2/Util/src/FilesystemConfiguration.cpp#1 $ // $Id: //poco/1.2/Util/src/FilesystemConfiguration.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: FilesystemConfiguration // Module: FilesystemConfiguration
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/FilesystemConfiguration.h" #include "Poco/Util/FilesystemConfiguration.h"
#include "Poco/File.h" #include "Poco/File.h"
#include "Poco/DirectoryIterator.h" #include "Poco/DirectoryIterator.h"
#include "Poco/StringTokenizer.h" #include "Poco/StringTokenizer.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <fstream> #include <fstream>
using Poco::Path; using Poco::Path;
using Poco::File; using Poco::File;
using Poco::DirectoryIterator; using Poco::DirectoryIterator;
using Poco::StringTokenizer; using Poco::StringTokenizer;
using Poco::NotFoundException; using Poco::NotFoundException;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
FilesystemConfiguration::FilesystemConfiguration(const std::string& path): FilesystemConfiguration::FilesystemConfiguration(const std::string& path):
_path(path) _path(path)
{ {
_path.makeDirectory(); _path.makeDirectory();
} }
FilesystemConfiguration::~FilesystemConfiguration() FilesystemConfiguration::~FilesystemConfiguration()
{ {
} }
void FilesystemConfiguration::clear() void FilesystemConfiguration::clear()
{ {
File regDir(_path); File regDir(_path);
regDir.remove(true); regDir.remove(true);
} }
bool FilesystemConfiguration::getRaw(const std::string& key, std::string& value) const bool FilesystemConfiguration::getRaw(const std::string& key, std::string& value) const
{ {
Path p(keyToPath(key)); Path p(keyToPath(key));
p.setFileName("data"); p.setFileName("data");
File f(p); File f(p);
if (f.exists()) if (f.exists())
{ {
value.reserve((std::string::size_type) f.getSize()); value.reserve((std::string::size_type) f.getSize());
std::ifstream istr(p.toString().c_str()); std::ifstream istr(p.toString().c_str());
int c = istr.get(); int c = istr.get();
while (c != std::char_traits<char>::eof()) while (c != std::char_traits<char>::eof())
{ {
value += (char) c; value += (char) c;
c = istr.get(); c = istr.get();
} }
return true; return true;
} }
else return false; else return false;
} }
void FilesystemConfiguration::setRaw(const std::string& key, const std::string& value) void FilesystemConfiguration::setRaw(const std::string& key, const std::string& value)
{ {
Path p(keyToPath(key)); Path p(keyToPath(key));
File dir(p); File dir(p);
dir.createDirectories(); dir.createDirectories();
p.setFileName("data"); p.setFileName("data");
std::ofstream ostr(p.toString().c_str()); std::ofstream ostr(p.toString().c_str());
ostr.write(value.data(), (std::streamsize) value.length()); ostr.write(value.data(), (std::streamsize) value.length());
} }
void FilesystemConfiguration::enumerate(const std::string& key, Keys& range) const void FilesystemConfiguration::enumerate(const std::string& key, Keys& range) const
{ {
DirectoryIterator it(keyToPath(key)); DirectoryIterator it(keyToPath(key));
DirectoryIterator end; DirectoryIterator end;
while (it != end) while (it != end)
{ {
if (it->isDirectory()) if (it->isDirectory())
range.push_back(it.name()); range.push_back(it.name());
++it; ++it;
} }
} }
Path FilesystemConfiguration::keyToPath(const std::string& key) const Path FilesystemConfiguration::keyToPath(const std::string& key) const
{ {
Path result(_path); Path result(_path);
StringTokenizer tokenizer(key, ".", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM); StringTokenizer tokenizer(key, ".", StringTokenizer::TOK_IGNORE_EMPTY | StringTokenizer::TOK_TRIM);
for (StringTokenizer::Iterator it = tokenizer.begin(); it != tokenizer.end(); ++it) for (StringTokenizer::Iterator it = tokenizer.begin(); it != tokenizer.end(); ++it)
{ {
result.pushDirectory(*it); result.pushDirectory(*it);
} }
return result; return result;
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,309 +1,309 @@
// //
// HelpFormatter.cpp // HelpFormatter.cpp
// //
// $Id: //poco/1.2/Util/src/HelpFormatter.cpp#1 $ // $Id: //poco/1.2/Util/src/HelpFormatter.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: HelpFormatter // Module: HelpFormatter
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/HelpFormatter.h" #include "Poco/Util/HelpFormatter.h"
#include "Poco/Util/OptionSet.h" #include "Poco/Util/OptionSet.h"
#include "Poco/Util/Option.h" #include "Poco/Util/Option.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
const int HelpFormatter::TAB_WIDTH = 4; const int HelpFormatter::TAB_WIDTH = 4;
const int HelpFormatter::LINE_WIDTH = 78; const int HelpFormatter::LINE_WIDTH = 78;
HelpFormatter::HelpFormatter(const OptionSet& options): HelpFormatter::HelpFormatter(const OptionSet& options):
_options(options), _options(options),
_width(LINE_WIDTH), _width(LINE_WIDTH),
_indent(calcIndent()), _indent(calcIndent()),
_unixStyle(true) _unixStyle(true)
{ {
#if !defined(POCO_OS_FAMILY_UNIX) #if !defined(POCO_OS_FAMILY_UNIX)
_unixStyle = false; _unixStyle = false;
#endif #endif
} }
HelpFormatter::~HelpFormatter() HelpFormatter::~HelpFormatter()
{ {
} }
void HelpFormatter::setCommand(const std::string& command) void HelpFormatter::setCommand(const std::string& command)
{ {
_command = command; _command = command;
} }
void HelpFormatter::setUsage(const std::string& usage) void HelpFormatter::setUsage(const std::string& usage)
{ {
_usage = usage; _usage = usage;
} }
void HelpFormatter::setHeader(const std::string& header) void HelpFormatter::setHeader(const std::string& header)
{ {
_header = header; _header = header;
} }
void HelpFormatter::setFooter(const std::string& footer) void HelpFormatter::setFooter(const std::string& footer)
{ {
_footer = footer; _footer = footer;
} }
void HelpFormatter::format(std::ostream& ostr) const void HelpFormatter::format(std::ostream& ostr) const
{ {
ostr << "usage: " << _command; ostr << "usage: " << _command;
if (!_usage.empty()) if (!_usage.empty())
{ {
ostr << ' '; ostr << ' ';
formatText(ostr, _usage, (int) _command.length() + 1); formatText(ostr, _usage, (int) _command.length() + 1);
} }
ostr << '\n'; ostr << '\n';
if (!_header.empty()) if (!_header.empty())
{ {
formatText(ostr, _header, 0); formatText(ostr, _header, 0);
ostr << "\n\n"; ostr << "\n\n";
} }
formatOptions(ostr); formatOptions(ostr);
if (!_footer.empty()) if (!_footer.empty())
{ {
ostr << '\n'; ostr << '\n';
formatText(ostr, _footer, 0); formatText(ostr, _footer, 0);
ostr << '\n'; ostr << '\n';
} }
} }
void HelpFormatter::setWidth(int width) void HelpFormatter::setWidth(int width)
{ {
poco_assert (width > 0); poco_assert (width > 0);
_width = width; _width = width;
} }
void HelpFormatter::setIndent(int indent) void HelpFormatter::setIndent(int indent)
{ {
poco_assert (indent >= 0 && indent < _width); poco_assert (indent >= 0 && indent < _width);
_indent = indent; _indent = indent;
} }
void HelpFormatter::setAutoIndent() void HelpFormatter::setAutoIndent()
{ {
_indent = calcIndent(); _indent = calcIndent();
} }
void HelpFormatter::setUnixStyle(bool flag) void HelpFormatter::setUnixStyle(bool flag)
{ {
_unixStyle = flag; _unixStyle = flag;
} }
int HelpFormatter::calcIndent() const int HelpFormatter::calcIndent() const
{ {
int indent = 0; int indent = 0;
for (OptionSet::Iterator it = _options.begin(); it != _options.end(); ++it) for (OptionSet::Iterator it = _options.begin(); it != _options.end(); ++it)
{ {
int shortLen = (int) it->shortName().length(); int shortLen = (int) it->shortName().length();
int fullLen = (int) it->fullName().length(); int fullLen = (int) it->fullName().length();
int n = 0; int n = 0;
if (_unixStyle && shortLen > 0) if (_unixStyle && shortLen > 0)
{ {
n += shortLen + (int) shortPrefix().length(); n += shortLen + (int) shortPrefix().length();
if (it->takesArgument()) if (it->takesArgument())
n += (int) it->argumentName().length() + (it->argumentRequired() ? 0 : 2); n += (int) it->argumentName().length() + (it->argumentRequired() ? 0 : 2);
if (fullLen > 0) n += 2; if (fullLen > 0) n += 2;
} }
if (fullLen > 0) if (fullLen > 0)
{ {
n += fullLen + (int) longPrefix().length(); n += fullLen + (int) longPrefix().length();
if (it->takesArgument()) if (it->takesArgument())
n += 1 + (int) it->argumentName().length() + (it->argumentRequired() ? 0 : 2); n += 1 + (int) it->argumentName().length() + (it->argumentRequired() ? 0 : 2);
} }
n += 2; n += 2;
if (n > indent) if (n > indent)
indent = n; indent = n;
} }
return indent; return indent;
} }
void HelpFormatter::formatOptions(std::ostream& ostr) const void HelpFormatter::formatOptions(std::ostream& ostr) const
{ {
int optWidth = calcIndent(); int optWidth = calcIndent();
for (OptionSet::Iterator it = _options.begin(); it != _options.end(); ++it) for (OptionSet::Iterator it = _options.begin(); it != _options.end(); ++it)
{ {
formatOption(ostr, *it, optWidth); formatOption(ostr, *it, optWidth);
formatText(ostr, it->description(), _indent, optWidth); formatText(ostr, it->description(), _indent, optWidth);
ostr << '\n'; ostr << '\n';
} }
} }
void HelpFormatter::formatOption(std::ostream& ostr, const Option& option, int width) const void HelpFormatter::formatOption(std::ostream& ostr, const Option& option, int width) const
{ {
int shortLen = (int) option.shortName().length(); int shortLen = (int) option.shortName().length();
int fullLen = (int) option.fullName().length(); int fullLen = (int) option.fullName().length();
int n = 0; int n = 0;
if (_unixStyle && shortLen > 0) if (_unixStyle && shortLen > 0)
{ {
ostr << shortPrefix() << option.shortName(); ostr << shortPrefix() << option.shortName();
n += (int) shortPrefix().length() + (int) option.shortName().length(); n += (int) shortPrefix().length() + (int) option.shortName().length();
if (option.takesArgument()) if (option.takesArgument())
{ {
if (!option.argumentRequired()) { ostr << '['; ++n; } if (!option.argumentRequired()) { ostr << '['; ++n; }
ostr << option.argumentName(); ostr << option.argumentName();
n += (int) option.argumentName().length(); n += (int) option.argumentName().length();
if (!option.argumentRequired()) { ostr << ']'; ++n; } if (!option.argumentRequired()) { ostr << ']'; ++n; }
} }
if (fullLen > 0) { ostr << ", "; n += 2; } if (fullLen > 0) { ostr << ", "; n += 2; }
} }
if (fullLen > 0) if (fullLen > 0)
{ {
ostr << longPrefix() << option.fullName(); ostr << longPrefix() << option.fullName();
n += (int) longPrefix().length() + (int) option.fullName().length(); n += (int) longPrefix().length() + (int) option.fullName().length();
if (option.takesArgument()) if (option.takesArgument())
{ {
if (!option.argumentRequired()) { ostr << '['; ++n; } if (!option.argumentRequired()) { ostr << '['; ++n; }
ostr << '='; ostr << '=';
++n; ++n;
ostr << option.argumentName(); ostr << option.argumentName();
n += (int) option.argumentName().length(); n += (int) option.argumentName().length();
if (!option.argumentRequired()) { ostr << ']'; ++n; } if (!option.argumentRequired()) { ostr << ']'; ++n; }
} }
} }
while (n < width) { ostr << ' '; ++n; } while (n < width) { ostr << ' '; ++n; }
} }
void HelpFormatter::formatText(std::ostream& ostr, const std::string& text, int indent) const void HelpFormatter::formatText(std::ostream& ostr, const std::string& text, int indent) const
{ {
formatText(ostr, text, indent, indent); formatText(ostr, text, indent, indent);
} }
void HelpFormatter::formatText(std::ostream& ostr, const std::string& text, int indent, int firstIndent) const void HelpFormatter::formatText(std::ostream& ostr, const std::string& text, int indent, int firstIndent) const
{ {
int pos = firstIndent; int pos = firstIndent;
int maxWordLen = _width - indent; int maxWordLen = _width - indent;
std::string word; std::string word;
for (std::string::const_iterator it = text.begin(); it != text.end(); ++it) for (std::string::const_iterator it = text.begin(); it != text.end(); ++it)
{ {
if (*it == '\n') if (*it == '\n')
{ {
clearWord(ostr, pos, word, indent); clearWord(ostr, pos, word, indent);
ostr << '\n'; ostr << '\n';
pos = 0; pos = 0;
while (pos < indent) { ostr << ' '; ++pos; } while (pos < indent) { ostr << ' '; ++pos; }
} }
else if (*it == '\t') else if (*it == '\t')
{ {
clearWord(ostr, pos, word, indent); clearWord(ostr, pos, word, indent);
if (pos < _width) ++pos; if (pos < _width) ++pos;
while (pos < _width && pos % TAB_WIDTH != 0) while (pos < _width && pos % TAB_WIDTH != 0)
{ {
ostr << ' '; ostr << ' ';
++pos; ++pos;
} }
} }
else if (*it == ' ') else if (*it == ' ')
{ {
clearWord(ostr, pos, word, indent); clearWord(ostr, pos, word, indent);
if (pos < _width) { ostr << ' '; ++pos; } if (pos < _width) { ostr << ' '; ++pos; }
} }
else else
{ {
if (word.length() == maxWordLen) if (word.length() == maxWordLen)
{ {
clearWord(ostr, pos, word, indent); clearWord(ostr, pos, word, indent);
} }
else word += *it; else word += *it;
} }
} }
clearWord(ostr, pos, word, indent); clearWord(ostr, pos, word, indent);
} }
void HelpFormatter::formatWord(std::ostream& ostr, int& pos, const std::string& word, int indent) const void HelpFormatter::formatWord(std::ostream& ostr, int& pos, const std::string& word, int indent) const
{ {
if (pos + word.length() > _width) if (pos + word.length() > _width)
{ {
ostr << '\n'; ostr << '\n';
pos = 0; pos = 0;
while (pos < indent) { ostr << ' '; ++pos; } while (pos < indent) { ostr << ' '; ++pos; }
} }
ostr << word; ostr << word;
pos += (int) word.length(); pos += (int) word.length();
} }
void HelpFormatter::clearWord(std::ostream& ostr, int& pos, std::string& word, int indent) const void HelpFormatter::clearWord(std::ostream& ostr, int& pos, std::string& word, int indent) const
{ {
formatWord(ostr, pos, word, indent); formatWord(ostr, pos, word, indent);
word.clear(); word.clear();
} }
std::string HelpFormatter::shortPrefix() const std::string HelpFormatter::shortPrefix() const
{ {
#if defined(POCO_OS_FAMILY_UNIX) #if defined(POCO_OS_FAMILY_UNIX)
return "-"; return "-";
#else #else
return _unixStyle ? "-" : "/"; return _unixStyle ? "-" : "/";
#endif #endif
} }
std::string HelpFormatter::longPrefix() const std::string HelpFormatter::longPrefix() const
{ {
#if defined(POCO_OS_FAMILY_UNIX) #if defined(POCO_OS_FAMILY_UNIX)
return "--"; return "--";
#else #else
return _unixStyle ? "--" : "/"; return _unixStyle ? "--" : "/";
#endif #endif
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,185 +1,185 @@
// //
// IniFileConfiguration.cpp // IniFileConfiguration.cpp
// //
// $Id: //poco/1.2/Util/src/IniFileConfiguration.cpp#1 $ // $Id: //poco/1.2/Util/src/IniFileConfiguration.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: IniFileConfiguration // Module: IniFileConfiguration
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/IniFileConfiguration.h" #include "Poco/Util/IniFileConfiguration.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/String.h" #include "Poco/String.h"
#include <fstream> #include <fstream>
#include <locale> #include <locale>
#include <set> #include <set>
using Poco::icompare; using Poco::icompare;
using Poco::trim; using Poco::trim;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
IniFileConfiguration::IniFileConfiguration() IniFileConfiguration::IniFileConfiguration()
{ {
} }
IniFileConfiguration::IniFileConfiguration(std::istream& istr) IniFileConfiguration::IniFileConfiguration(std::istream& istr)
{ {
load(istr); load(istr);
} }
IniFileConfiguration::IniFileConfiguration(const std::string& path) IniFileConfiguration::IniFileConfiguration(const std::string& path)
{ {
load(path); load(path);
} }
IniFileConfiguration::~IniFileConfiguration() IniFileConfiguration::~IniFileConfiguration()
{ {
} }
void IniFileConfiguration::load(std::istream& istr) void IniFileConfiguration::load(std::istream& istr)
{ {
_map.clear(); _map.clear();
_sectionKey.clear(); _sectionKey.clear();
while (!istr.eof()) while (!istr.eof())
{ {
parseLine(istr); parseLine(istr);
} }
} }
void IniFileConfiguration::load(const std::string& path) void IniFileConfiguration::load(const std::string& path)
{ {
std::ifstream istr(path.c_str()); std::ifstream istr(path.c_str());
if (istr.good()) if (istr.good())
load(istr); load(istr);
else else
throw Poco::OpenFileException(path); throw Poco::OpenFileException(path);
} }
bool IniFileConfiguration::getRaw(const std::string& key, std::string& value) const bool IniFileConfiguration::getRaw(const std::string& key, std::string& value) const
{ {
IStringMap::const_iterator it = _map.find(key); IStringMap::const_iterator it = _map.find(key);
if (it != _map.end()) if (it != _map.end())
{ {
value = it->second; value = it->second;
return true; return true;
} }
else return false; else return false;
} }
void IniFileConfiguration::setRaw(const std::string& key, const std::string& value) void IniFileConfiguration::setRaw(const std::string& key, const std::string& value)
{ {
throw Poco::NotImplementedException("Setting a property in an IniFileConfiguration"); throw Poco::NotImplementedException("Setting a property in an IniFileConfiguration");
} }
void IniFileConfiguration::enumerate(const std::string& key, Keys& range) const void IniFileConfiguration::enumerate(const std::string& key, Keys& range) const
{ {
std::set<std::string> keys; std::set<std::string> keys;
std::string prefix = key; std::string prefix = key;
if (!prefix.empty()) prefix += '.'; if (!prefix.empty()) prefix += '.';
std::string::size_type psize = prefix.size(); std::string::size_type psize = prefix.size();
for (IStringMap::const_iterator it = _map.begin(); it != _map.end(); ++it) for (IStringMap::const_iterator it = _map.begin(); it != _map.end(); ++it)
{ {
if (icompare(it->first, psize, prefix) == 0) if (icompare(it->first, psize, prefix) == 0)
{ {
std::string subKey; std::string subKey;
std::string::size_type end = it->first.find('.', psize); std::string::size_type end = it->first.find('.', psize);
if (end == std::string::npos) if (end == std::string::npos)
subKey = it->first.substr(psize); subKey = it->first.substr(psize);
else else
subKey = it->first.substr(psize, end - psize); subKey = it->first.substr(psize, end - psize);
if (keys.find(subKey) == keys.end()) if (keys.find(subKey) == keys.end())
{ {
range.push_back(subKey); range.push_back(subKey);
keys.insert(subKey); keys.insert(subKey);
} }
} }
} }
} }
bool IniFileConfiguration::ICompare::operator () (const std::string& s1, const std::string& s2) const bool IniFileConfiguration::ICompare::operator () (const std::string& s1, const std::string& s2) const
{ {
return icompare(s1, s2) < 0; return icompare(s1, s2) < 0;
} }
void IniFileConfiguration::parseLine(std::istream& istr) void IniFileConfiguration::parseLine(std::istream& istr)
{ {
static const int eof = std::char_traits<char>::eof(); static const int eof = std::char_traits<char>::eof();
std::locale loc; std::locale loc;
int c = istr.get(); int c = istr.get();
while (c != eof && isspace((char) c, loc)) c = istr.get(); while (c != eof && isspace((char) c, loc)) c = istr.get();
if (c != eof) if (c != eof)
{ {
if (c == ';') if (c == ';')
{ {
while (c != eof && c != '\n') c = istr.get(); while (c != eof && c != '\n') c = istr.get();
} }
else if (c == '[') else if (c == '[')
{ {
std::string key; std::string key;
c = istr.get(); c = istr.get();
while (c != eof && c != ']' && c != '\n') { key += (char) c; c = istr.get(); } while (c != eof && c != ']' && c != '\n') { key += (char) c; c = istr.get(); }
_sectionKey = trim(key); _sectionKey = trim(key);
} }
else else
{ {
std::string key; std::string key;
while (c != eof && c != '=' && c != '\n') { key += (char) c; c = istr.get(); } while (c != eof && c != '=' && c != '\n') { key += (char) c; c = istr.get(); }
std::string value; std::string value;
if (c == '=') if (c == '=')
{ {
c = istr.get(); c = istr.get();
while (c != eof && c != '\n') { value += (char) c; c = istr.get(); } while (c != eof && c != '\n') { value += (char) c; c = istr.get(); }
} }
std::string fullKey = _sectionKey; std::string fullKey = _sectionKey;
if (!fullKey.empty()) fullKey += '.'; if (!fullKey.empty()) fullKey += '.';
fullKey.append(trim(key)); fullKey.append(trim(key));
_map[fullKey] = trim(value); _map[fullKey] = trim(value);
} }
} }
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,76 +1,76 @@
// //
// IntValidator.cpp // IntValidator.cpp
// //
// $Id: //poco/1.2/Util/src/IntValidator.cpp#1 $ // $Id: //poco/1.2/Util/src/IntValidator.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: IntValidator // Module: IntValidator
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/IntValidator.h" #include "Poco/Util/IntValidator.h"
#include "Poco/Util/Option.h" #include "Poco/Util/Option.h"
#include "Poco/Util/OptionException.h" #include "Poco/Util/OptionException.h"
#include "Poco/NumberParser.h" #include "Poco/NumberParser.h"
#include "Poco/Format.h" #include "Poco/Format.h"
using Poco::NumberParser; using Poco::NumberParser;
using Poco::format; using Poco::format;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
IntValidator::IntValidator(int min, int max): IntValidator::IntValidator(int min, int max):
_min(min), _min(min),
_max(max) _max(max)
{ {
} }
IntValidator::~IntValidator() IntValidator::~IntValidator()
{ {
} }
void IntValidator::validate(const Option& option, const std::string& value) void IntValidator::validate(const Option& option, const std::string& value)
{ {
int n; int n;
if (NumberParser::tryParse(value, n)) if (NumberParser::tryParse(value, n))
{ {
if (n < _min || n > _max) if (n < _min || n > _max)
throw InvalidArgumentException(format("argument for %s must be in range %d to %d", option.fullName(), _min, _max)); throw InvalidArgumentException(format("argument for %s must be in range %d to %d", option.fullName(), _min, _max));
} }
else throw InvalidArgumentException(format("argument for %s must be an integer", option.fullName())); else throw InvalidArgumentException(format("argument for %s must be an integer", option.fullName()));
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,127 +1,127 @@
// //
// LayeredConfiguration.cpp // LayeredConfiguration.cpp
// //
// $Id: //poco/1.2/Util/src/LayeredConfiguration.cpp#1 $ // $Id: //poco/1.2/Util/src/LayeredConfiguration.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: LayeredConfiguration // Module: LayeredConfiguration
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/LayeredConfiguration.h" #include "Poco/Util/LayeredConfiguration.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <set> #include <set>
using Poco::AutoPtr; using Poco::AutoPtr;
using Poco::RuntimeException; using Poco::RuntimeException;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
LayeredConfiguration::LayeredConfiguration() LayeredConfiguration::LayeredConfiguration()
{ {
} }
LayeredConfiguration::~LayeredConfiguration() LayeredConfiguration::~LayeredConfiguration()
{ {
} }
void LayeredConfiguration::add(AbstractConfiguration* pConfig) void LayeredConfiguration::add(AbstractConfiguration* pConfig)
{ {
add(pConfig, true); add(pConfig, true);
} }
void LayeredConfiguration::add(AbstractConfiguration* pConfig, bool shared) void LayeredConfiguration::add(AbstractConfiguration* pConfig, bool shared)
{ {
poco_check_ptr (pConfig); poco_check_ptr (pConfig);
_configs.push_back(ConfigPtr(pConfig, shared)); _configs.push_back(ConfigPtr(pConfig, shared));
} }
void LayeredConfiguration::addFront(AbstractConfiguration* pConfig) void LayeredConfiguration::addFront(AbstractConfiguration* pConfig)
{ {
addFront(pConfig, true); addFront(pConfig, true);
} }
void LayeredConfiguration::addFront(AbstractConfiguration* pConfig, bool shared) void LayeredConfiguration::addFront(AbstractConfiguration* pConfig, bool shared)
{ {
poco_check_ptr (pConfig); poco_check_ptr (pConfig);
_configs.insert(_configs.begin(), ConfigPtr(pConfig, shared)); _configs.insert(_configs.begin(), ConfigPtr(pConfig, shared));
} }
bool LayeredConfiguration::getRaw(const std::string& key, std::string& value) const bool LayeredConfiguration::getRaw(const std::string& key, std::string& value) const
{ {
for (ConfigVec::const_iterator it = _configs.begin(); it != _configs.end(); ++it) for (ConfigVec::const_iterator it = _configs.begin(); it != _configs.end(); ++it)
{ {
if ((*it)->getRaw(key, value)) if ((*it)->getRaw(key, value))
return true; return true;
} }
return false; return false;
} }
void LayeredConfiguration::setRaw(const std::string& key, const std::string& value) void LayeredConfiguration::setRaw(const std::string& key, const std::string& value)
{ {
if (!_configs.empty()) if (!_configs.empty())
_configs.back()->setRaw(key, value); _configs.back()->setRaw(key, value);
else else
throw RuntimeException("No configuration object to store the property", key); throw RuntimeException("No configuration object to store the property", key);
} }
void LayeredConfiguration::enumerate(const std::string& key, Keys& range) const void LayeredConfiguration::enumerate(const std::string& key, Keys& range) const
{ {
std::set<std::string> keys; std::set<std::string> keys;
for (ConfigVec::const_iterator itc = _configs.begin(); itc != _configs.end(); ++itc) for (ConfigVec::const_iterator itc = _configs.begin(); itc != _configs.end(); ++itc)
{ {
Keys partRange; Keys partRange;
(*itc)->enumerate(key, partRange); (*itc)->enumerate(key, partRange);
for (Keys::const_iterator itr = partRange.begin(); itr != partRange.end(); ++itr) for (Keys::const_iterator itr = partRange.begin(); itr != partRange.end(); ++itr)
{ {
if (keys.find(*itr) == keys.end()) if (keys.find(*itr) == keys.end())
{ {
range.push_back(*itr); range.push_back(*itr);
keys.insert(*itr); keys.insert(*itr);
} }
} }
} }
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,225 +1,225 @@
// //
// LoggingConfigurator.cpp // LoggingConfigurator.cpp
// //
// $Id: //poco/1.2/Util/src/LoggingConfigurator.cpp#3 $ // $Id: //poco/1.2/Util/src/LoggingConfigurator.cpp#3 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: LoggingConfigurator // Module: LoggingConfigurator
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/LoggingConfigurator.h" #include "Poco/Util/LoggingConfigurator.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include "Poco/Channel.h" #include "Poco/Channel.h"
#include "Poco/FormattingChannel.h" #include "Poco/FormattingChannel.h"
#include "Poco/Formatter.h" #include "Poco/Formatter.h"
#include "Poco/PatternFormatter.h" #include "Poco/PatternFormatter.h"
#include "Poco/Logger.h" #include "Poco/Logger.h"
#include "Poco/LoggingRegistry.h" #include "Poco/LoggingRegistry.h"
#include "Poco/LoggingFactory.h" #include "Poco/LoggingFactory.h"
#include <map> #include <map>
using Poco::AutoPtr; using Poco::AutoPtr;
using Poco::Formatter; using Poco::Formatter;
using Poco::PatternFormatter; using Poco::PatternFormatter;
using Poco::Channel; using Poco::Channel;
using Poco::FormattingChannel; using Poco::FormattingChannel;
using Poco::Logger; using Poco::Logger;
using Poco::LoggingRegistry; using Poco::LoggingRegistry;
using Poco::LoggingFactory; using Poco::LoggingFactory;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
LoggingConfigurator::LoggingConfigurator() LoggingConfigurator::LoggingConfigurator()
{ {
} }
LoggingConfigurator::~LoggingConfigurator() LoggingConfigurator::~LoggingConfigurator()
{ {
} }
void LoggingConfigurator::configure(AbstractConfiguration* pConfig) void LoggingConfigurator::configure(AbstractConfiguration* pConfig)
{ {
poco_check_ptr (pConfig); poco_check_ptr (pConfig);
AutoPtr<AbstractConfiguration> pFormattersConfig(pConfig->createView("logging.formatters")); AutoPtr<AbstractConfiguration> pFormattersConfig(pConfig->createView("logging.formatters"));
configureFormatters(pFormattersConfig); configureFormatters(pFormattersConfig);
AutoPtr<AbstractConfiguration> pChannelsConfig(pConfig->createView("logging.channels")); AutoPtr<AbstractConfiguration> pChannelsConfig(pConfig->createView("logging.channels"));
configureChannels(pChannelsConfig); configureChannels(pChannelsConfig);
AutoPtr<AbstractConfiguration> pLoggersConfig(pConfig->createView("logging.loggers")); AutoPtr<AbstractConfiguration> pLoggersConfig(pConfig->createView("logging.loggers"));
configureLoggers(pLoggersConfig); configureLoggers(pLoggersConfig);
} }
void LoggingConfigurator::configureFormatters(AbstractConfiguration* pConfig) void LoggingConfigurator::configureFormatters(AbstractConfiguration* pConfig)
{ {
AbstractConfiguration::Keys formatters; AbstractConfiguration::Keys formatters;
pConfig->keys(formatters); pConfig->keys(formatters);
for (AbstractConfiguration::Keys::const_iterator it = formatters.begin(); it != formatters.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = formatters.begin(); it != formatters.end(); ++it)
{ {
AutoPtr<AbstractConfiguration> pFormatterConfig(pConfig->createView(*it)); AutoPtr<AbstractConfiguration> pFormatterConfig(pConfig->createView(*it));
AutoPtr<Formatter> pFormatter(createFormatter(pFormatterConfig)); AutoPtr<Formatter> pFormatter(createFormatter(pFormatterConfig));
LoggingRegistry::defaultRegistry().registerFormatter(*it, pFormatter); LoggingRegistry::defaultRegistry().registerFormatter(*it, pFormatter);
} }
} }
void LoggingConfigurator::configureChannels(AbstractConfiguration* pConfig) void LoggingConfigurator::configureChannels(AbstractConfiguration* pConfig)
{ {
AbstractConfiguration::Keys channels; AbstractConfiguration::Keys channels;
pConfig->keys(channels); pConfig->keys(channels);
for (AbstractConfiguration::Keys::const_iterator it = channels.begin(); it != channels.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = channels.begin(); it != channels.end(); ++it)
{ {
AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it)); AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it));
AutoPtr<Channel> pChannel = createChannel(pChannelConfig); AutoPtr<Channel> pChannel = createChannel(pChannelConfig);
LoggingRegistry::defaultRegistry().registerChannel(*it, pChannel); LoggingRegistry::defaultRegistry().registerChannel(*it, pChannel);
} }
for (AbstractConfiguration::Keys::const_iterator it = channels.begin(); it != channels.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = channels.begin(); it != channels.end(); ++it)
{ {
AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it)); AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it));
Channel* pChannel = LoggingRegistry::defaultRegistry().channelForName(*it); Channel* pChannel = LoggingRegistry::defaultRegistry().channelForName(*it);
configureChannel(pChannel, pChannelConfig); configureChannel(pChannel, pChannelConfig);
} }
} }
void LoggingConfigurator::configureLoggers(AbstractConfiguration* pConfig) void LoggingConfigurator::configureLoggers(AbstractConfiguration* pConfig)
{ {
typedef std::map<std::string, AutoPtr<AbstractConfiguration> > LoggerMap; typedef std::map<std::string, AutoPtr<AbstractConfiguration> > LoggerMap;
AbstractConfiguration::Keys loggers; AbstractConfiguration::Keys loggers;
pConfig->keys(loggers); pConfig->keys(loggers);
// use a map to sort loggers by their name, ensuring initialization in correct order (parents before children) // use a map to sort loggers by their name, ensuring initialization in correct order (parents before children)
LoggerMap loggerMap; LoggerMap loggerMap;
for (AbstractConfiguration::Keys::const_iterator it = loggers.begin(); it != loggers.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = loggers.begin(); it != loggers.end(); ++it)
{ {
AutoPtr<AbstractConfiguration> pLoggerConfig(pConfig->createView(*it)); AutoPtr<AbstractConfiguration> pLoggerConfig(pConfig->createView(*it));
loggerMap[pLoggerConfig->getString("name", "")] = pLoggerConfig; loggerMap[pLoggerConfig->getString("name", "")] = pLoggerConfig;
} }
for (LoggerMap::iterator it = loggerMap.begin(); it != loggerMap.end(); ++it) for (LoggerMap::iterator it = loggerMap.begin(); it != loggerMap.end(); ++it)
{ {
configureLogger(it->second); configureLogger(it->second);
} }
} }
Formatter* LoggingConfigurator::createFormatter(AbstractConfiguration* pConfig) Formatter* LoggingConfigurator::createFormatter(AbstractConfiguration* pConfig)
{ {
AutoPtr<Formatter> pFormatter(LoggingFactory::defaultFactory().createFormatter(pConfig->getString("class"))); AutoPtr<Formatter> pFormatter(LoggingFactory::defaultFactory().createFormatter(pConfig->getString("class")));
AbstractConfiguration::Keys props; AbstractConfiguration::Keys props;
pConfig->keys(props); pConfig->keys(props);
for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
{ {
if (*it != "class") if (*it != "class")
pFormatter->setProperty(*it, pConfig->getString(*it)); pFormatter->setProperty(*it, pConfig->getString(*it));
} }
return pFormatter.duplicate(); return pFormatter.duplicate();
} }
Channel* LoggingConfigurator::createChannel(AbstractConfiguration* pConfig) Channel* LoggingConfigurator::createChannel(AbstractConfiguration* pConfig)
{ {
AutoPtr<Channel> pChannel(LoggingFactory::defaultFactory().createChannel(pConfig->getString("class"))); AutoPtr<Channel> pChannel(LoggingFactory::defaultFactory().createChannel(pConfig->getString("class")));
AutoPtr<Channel> pWrapper(pChannel); AutoPtr<Channel> pWrapper(pChannel);
AbstractConfiguration::Keys props; AbstractConfiguration::Keys props;
pConfig->keys(props); pConfig->keys(props);
for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
{ {
if (*it == "pattern") if (*it == "pattern")
{ {
AutoPtr<Formatter> pPatternFormatter(new PatternFormatter(pConfig->getString(*it))); AutoPtr<Formatter> pPatternFormatter(new PatternFormatter(pConfig->getString(*it)));
pWrapper = new FormattingChannel(pPatternFormatter, pChannel); pWrapper = new FormattingChannel(pPatternFormatter, pChannel);
} }
else if (*it == "formatter") else if (*it == "formatter")
{ {
AutoPtr<FormattingChannel> pFormattingChannel(new FormattingChannel(0, pChannel)); AutoPtr<FormattingChannel> pFormattingChannel(new FormattingChannel(0, pChannel));
if (pConfig->hasProperty("formatter.class")) if (pConfig->hasProperty("formatter.class"))
{ {
AutoPtr<AbstractConfiguration> pFormatterConfig(pConfig->createView(*it)); AutoPtr<AbstractConfiguration> pFormatterConfig(pConfig->createView(*it));
AutoPtr<Formatter> pFormatter(createFormatter(pFormatterConfig)); AutoPtr<Formatter> pFormatter(createFormatter(pFormatterConfig));
pFormattingChannel->setFormatter(pFormatter); pFormattingChannel->setFormatter(pFormatter);
} }
else pFormattingChannel->setProperty(*it, pConfig->getString(*it)); else pFormattingChannel->setProperty(*it, pConfig->getString(*it));
#if defined(__GNUC__) && __GNUC__ < 3 #if defined(__GNUC__) && __GNUC__ < 3
pWrapper = pFormattingChannel.duplicate(); pWrapper = pFormattingChannel.duplicate();
#else #else
pWrapper = pFormattingChannel; pWrapper = pFormattingChannel;
#endif #endif
} }
} }
return pWrapper.duplicate(); return pWrapper.duplicate();
} }
void LoggingConfigurator::configureChannel(Channel* pChannel, AbstractConfiguration* pConfig) void LoggingConfigurator::configureChannel(Channel* pChannel, AbstractConfiguration* pConfig)
{ {
AbstractConfiguration::Keys props; AbstractConfiguration::Keys props;
pConfig->keys(props); pConfig->keys(props);
for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
{ {
if (*it != "pattern" && *it != "formatter" && *it != "class") if (*it != "pattern" && *it != "formatter" && *it != "class")
{ {
pChannel->setProperty(*it, pConfig->getString(*it)); pChannel->setProperty(*it, pConfig->getString(*it));
} }
} }
} }
void LoggingConfigurator::configureLogger(AbstractConfiguration* pConfig) void LoggingConfigurator::configureLogger(AbstractConfiguration* pConfig)
{ {
Logger& logger = Logger::get(pConfig->getString("name", "")); Logger& logger = Logger::get(pConfig->getString("name", ""));
AbstractConfiguration::Keys props; AbstractConfiguration::Keys props;
pConfig->keys(props); pConfig->keys(props);
for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
{ {
if (*it == "channel" && pConfig->hasProperty("channel.class")) if (*it == "channel" && pConfig->hasProperty("channel.class"))
{ {
AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it)); AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it));
AutoPtr<Channel> pChannel(createChannel(pChannelConfig)); AutoPtr<Channel> pChannel(createChannel(pChannelConfig));
configureChannel(pChannel, pChannelConfig); configureChannel(pChannel, pChannelConfig);
Logger::setChannel(logger.name(), pChannel); Logger::setChannel(logger.name(), pChannel);
} }
else if (*it != "name") else if (*it != "name")
{ {
Logger::setProperty(logger.name(), *it, pConfig->getString(*it)); Logger::setProperty(logger.name(), *it, pConfig->getString(*it));
} }
} }
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,80 +1,80 @@
// //
// LoggingSubsystem.cpp // LoggingSubsystem.cpp
// //
// $Id: //poco/1.2/Util/src/LoggingSubsystem.cpp#1 $ // $Id: //poco/1.2/Util/src/LoggingSubsystem.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Application // Package: Application
// Module: LoggingSubsystem // Module: LoggingSubsystem
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/LoggingSubsystem.h" #include "Poco/Util/LoggingSubsystem.h"
#include "Poco/Util/LoggingConfigurator.h" #include "Poco/Util/LoggingConfigurator.h"
#include "Poco/Util/Application.h" #include "Poco/Util/Application.h"
#include "Poco/Logger.h" #include "Poco/Logger.h"
using Poco::Logger; using Poco::Logger;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
LoggingSubsystem::LoggingSubsystem() LoggingSubsystem::LoggingSubsystem()
{ {
} }
LoggingSubsystem::~LoggingSubsystem() LoggingSubsystem::~LoggingSubsystem()
{ {
} }
const char* LoggingSubsystem::name() const const char* LoggingSubsystem::name() const
{ {
return "Logging Subsystem"; return "Logging Subsystem";
} }
void LoggingSubsystem::initialize(Application& app) void LoggingSubsystem::initialize(Application& app)
{ {
LoggingConfigurator configurator; LoggingConfigurator configurator;
configurator.configure(&app.config()); configurator.configure(&app.config());
std::string logger = app.config().getString("application.logger", "Application"); std::string logger = app.config().getString("application.logger", "Application");
app.setLogger(Logger::get(logger)); app.setLogger(Logger::get(logger));
} }
void LoggingSubsystem::uninitialize() void LoggingSubsystem::uninitialize()
{ {
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,117 +1,117 @@
// //
// MapConfiguration.cpp // MapConfiguration.cpp
// //
// $Id: //poco/1.2/Util/src/MapConfiguration.cpp#1 $ // $Id: //poco/1.2/Util/src/MapConfiguration.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: MapConfiguration // Module: MapConfiguration
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/MapConfiguration.h" #include "Poco/Util/MapConfiguration.h"
#include <set> #include <set>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
MapConfiguration::MapConfiguration() MapConfiguration::MapConfiguration()
{ {
} }
MapConfiguration::~MapConfiguration() MapConfiguration::~MapConfiguration()
{ {
} }
void MapConfiguration::clear() void MapConfiguration::clear()
{ {
_map.clear(); _map.clear();
} }
bool MapConfiguration::getRaw(const std::string& key, std::string& value) const bool MapConfiguration::getRaw(const std::string& key, std::string& value) const
{ {
StringMap::const_iterator it = _map.find(key); StringMap::const_iterator it = _map.find(key);
if (it != _map.end()) if (it != _map.end())
{ {
value = it->second; value = it->second;
return true; return true;
} }
else return false; else return false;
} }
void MapConfiguration::setRaw(const std::string& key, const std::string& value) void MapConfiguration::setRaw(const std::string& key, const std::string& value)
{ {
_map[key] = value; _map[key] = value;
} }
void MapConfiguration::enumerate(const std::string& key, Keys& range) const void MapConfiguration::enumerate(const std::string& key, Keys& range) const
{ {
std::set<std::string> keys; std::set<std::string> keys;
std::string prefix = key; std::string prefix = key;
if (!prefix.empty()) prefix += '.'; if (!prefix.empty()) prefix += '.';
std::string::size_type psize = prefix.size(); std::string::size_type psize = prefix.size();
for (StringMap::const_iterator it = _map.begin(); it != _map.end(); ++it) for (StringMap::const_iterator it = _map.begin(); it != _map.end(); ++it)
{ {
if (it->first.compare(0, psize, prefix) == 0) if (it->first.compare(0, psize, prefix) == 0)
{ {
std::string subKey; std::string subKey;
std::string::size_type end = it->first.find('.', psize); std::string::size_type end = it->first.find('.', psize);
if (end == std::string::npos) if (end == std::string::npos)
subKey = it->first.substr(psize); subKey = it->first.substr(psize);
else else
subKey = it->first.substr(psize, end - psize); subKey = it->first.substr(psize, end - psize);
if (keys.find(subKey) == keys.end()) if (keys.find(subKey) == keys.end())
{ {
range.push_back(subKey); range.push_back(subKey);
keys.insert(subKey); keys.insert(subKey);
} }
} }
} }
} }
MapConfiguration::iterator MapConfiguration::begin() const MapConfiguration::iterator MapConfiguration::begin() const
{ {
return _map.begin(); return _map.begin();
} }
MapConfiguration::iterator MapConfiguration::end() const MapConfiguration::iterator MapConfiguration::end() const
{ {
return _map.end(); return _map.end();
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,297 +1,297 @@
// //
// Option.cpp // Option.cpp
// //
// $Id: //poco/1.2/Util/src/Option.cpp#2 $ // $Id: //poco/1.2/Util/src/Option.cpp#2 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: Option // Module: Option
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/Option.h" #include "Poco/Util/Option.h"
#include "Poco/Util/OptionException.h" #include "Poco/Util/OptionException.h"
#include "Poco/Util/Validator.h" #include "Poco/Util/Validator.h"
#include "Poco/String.h" #include "Poco/String.h"
#include <algorithm> #include <algorithm>
using Poco::icompare; using Poco::icompare;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
Option::Option(): Option::Option():
_required(false), _required(false),
_repeatable(false), _repeatable(false),
_argRequired(false), _argRequired(false),
_pValidator(0), _pValidator(0),
_pCallback(0) _pCallback(0)
{ {
} }
Option::Option(const Option& option): Option::Option(const Option& option):
_shortName(option._shortName), _shortName(option._shortName),
_fullName(option._fullName), _fullName(option._fullName),
_description(option._description), _description(option._description),
_required(option._required), _required(option._required),
_repeatable(option._repeatable), _repeatable(option._repeatable),
_argName(option._argName), _argName(option._argName),
_argRequired(option._argRequired), _argRequired(option._argRequired),
_group(option._group), _group(option._group),
_binding(option._binding), _binding(option._binding),
_pValidator(option._pValidator), _pValidator(option._pValidator),
_pCallback(option._pCallback) _pCallback(option._pCallback)
{ {
if (_pValidator) _pValidator->duplicate(); if (_pValidator) _pValidator->duplicate();
if (_pCallback) _pCallback = _pCallback->clone(); if (_pCallback) _pCallback = _pCallback->clone();
} }
Option::Option(const std::string& fullName, const std::string& shortName): Option::Option(const std::string& fullName, const std::string& shortName):
_shortName(shortName), _shortName(shortName),
_fullName(fullName), _fullName(fullName),
_required(false), _required(false),
_repeatable(false), _repeatable(false),
_argRequired(false), _argRequired(false),
_pValidator(0), _pValidator(0),
_pCallback(0) _pCallback(0)
{ {
} }
Option::Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required): Option::Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required):
_shortName(shortName), _shortName(shortName),
_fullName(fullName), _fullName(fullName),
_description(description), _description(description),
_required(required), _required(required),
_repeatable(false), _repeatable(false),
_argRequired(false), _argRequired(false),
_pValidator(0), _pValidator(0),
_pCallback(0) _pCallback(0)
{ {
} }
Option::Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required, const std::string& argName, bool argOptional): Option::Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required, const std::string& argName, bool argOptional):
_shortName(shortName), _shortName(shortName),
_fullName(fullName), _fullName(fullName),
_description(description), _description(description),
_required(required), _required(required),
_repeatable(false), _repeatable(false),
_argName(argName), _argName(argName),
_argRequired(argOptional), _argRequired(argOptional),
_pValidator(0), _pValidator(0),
_pCallback(0) _pCallback(0)
{ {
} }
Option::~Option() Option::~Option()
{ {
if (_pValidator) _pValidator->release(); if (_pValidator) _pValidator->release();
delete _pCallback; delete _pCallback;
} }
Option& Option::operator = (const Option& option) Option& Option::operator = (const Option& option)
{ {
if (&option != this) if (&option != this)
{ {
Option tmp(option); Option tmp(option);
swap(tmp); swap(tmp);
} }
return *this; return *this;
} }
void Option::swap(Option& option) void Option::swap(Option& option)
{ {
std::swap(_shortName, option._shortName); std::swap(_shortName, option._shortName);
std::swap(_fullName, option._fullName); std::swap(_fullName, option._fullName);
std::swap(_description, option._description); std::swap(_description, option._description);
std::swap(_required, option._required); std::swap(_required, option._required);
std::swap(_repeatable, option._repeatable); std::swap(_repeatable, option._repeatable);
std::swap(_argName, option._argName); std::swap(_argName, option._argName);
std::swap(_argRequired, option._argRequired); std::swap(_argRequired, option._argRequired);
std::swap(_group, option._group); std::swap(_group, option._group);
std::swap(_binding, option._binding); std::swap(_binding, option._binding);
std::swap(_pValidator, option._pValidator); std::swap(_pValidator, option._pValidator);
std::swap(_pCallback, option._pCallback); std::swap(_pCallback, option._pCallback);
} }
Option& Option::shortName(const std::string& name) Option& Option::shortName(const std::string& name)
{ {
_shortName = name; _shortName = name;
return *this; return *this;
} }
Option& Option::fullName(const std::string& name) Option& Option::fullName(const std::string& name)
{ {
_fullName = name; _fullName = name;
return *this; return *this;
} }
Option& Option::description(const std::string& text) Option& Option::description(const std::string& text)
{ {
_description = text; _description = text;
return *this; return *this;
} }
Option& Option::required(bool flag) Option& Option::required(bool flag)
{ {
_required = flag; _required = flag;
return *this; return *this;
} }
Option& Option::repeatable(bool flag) Option& Option::repeatable(bool flag)
{ {
_repeatable = flag; _repeatable = flag;
return *this; return *this;
} }
Option& Option::argument(const std::string& name, bool required) Option& Option::argument(const std::string& name, bool required)
{ {
_argName = name; _argName = name;
_argRequired = required; _argRequired = required;
return *this; return *this;
} }
Option& Option::noArgument() Option& Option::noArgument()
{ {
_argName.clear(); _argName.clear();
_argRequired = false; _argRequired = false;
return *this; return *this;
} }
Option& Option::group(const std::string& group) Option& Option::group(const std::string& group)
{ {
_group = group; _group = group;
return *this; return *this;
} }
Option& Option::binding(const std::string& propertyName) Option& Option::binding(const std::string& propertyName)
{ {
_binding = propertyName; _binding = propertyName;
return *this; return *this;
} }
Option& Option::callback(const AbstractOptionCallback& cb) Option& Option::callback(const AbstractOptionCallback& cb)
{ {
_pCallback = cb.clone(); _pCallback = cb.clone();
return *this; return *this;
} }
Option& Option::validator(Validator* pValidator) Option& Option::validator(Validator* pValidator)
{ {
if (_pValidator) _pValidator->release(); if (_pValidator) _pValidator->release();
_pValidator = pValidator; _pValidator = pValidator;
if (_pValidator) _pValidator->duplicate(); if (_pValidator) _pValidator->duplicate();
return *this; return *this;
} }
bool Option::matchesShort(const std::string& option) const bool Option::matchesShort(const std::string& option) const
{ {
return option.length() > 0 return option.length() > 0
&& !_shortName.empty() && option.compare(0, _shortName.length(), _shortName) == 0; && !_shortName.empty() && option.compare(0, _shortName.length(), _shortName) == 0;
} }
bool Option::matchesFull(const std::string& option) const bool Option::matchesFull(const std::string& option) const
{ {
std::string::size_type pos = option.find_first_of(":="); std::string::size_type pos = option.find_first_of(":=");
std::string::size_type len = pos == std::string::npos ? option.length() : pos; std::string::size_type len = pos == std::string::npos ? option.length() : pos;
return len == _fullName.length() return len == _fullName.length()
&& icompare(option, 0, len, _fullName, 0, len) == 0; && icompare(option, 0, len, _fullName, 0, len) == 0;
} }
bool Option::matchesPartial(const std::string& option) const bool Option::matchesPartial(const std::string& option) const
{ {
std::string::size_type pos = option.find_first_of(":="); std::string::size_type pos = option.find_first_of(":=");
std::string::size_type len = pos == std::string::npos ? option.length() : pos; std::string::size_type len = pos == std::string::npos ? option.length() : pos;
return option.length() > 0 return option.length() > 0
&& icompare(option, 0, len, _fullName, 0, len) == 0; && icompare(option, 0, len, _fullName, 0, len) == 0;
} }
void Option::process(const std::string& option, std::string& arg) const void Option::process(const std::string& option, std::string& arg) const
{ {
std::string::size_type pos = option.find_first_of(":="); std::string::size_type pos = option.find_first_of(":=");
std::string::size_type len = pos == std::string::npos ? option.length() : pos; std::string::size_type len = pos == std::string::npos ? option.length() : pos;
if (icompare(option, 0, len, _fullName, 0, len) == 0) if (icompare(option, 0, len, _fullName, 0, len) == 0)
{ {
if (takesArgument()) if (takesArgument())
{ {
if (argumentRequired() && pos == std::string::npos) if (argumentRequired() && pos == std::string::npos)
throw MissingArgumentException(_fullName + " requires " + argumentName()); throw MissingArgumentException(_fullName + " requires " + argumentName());
if (pos != std::string::npos) if (pos != std::string::npos)
arg.assign(option, pos + 1, option.length() - pos - 1); arg.assign(option, pos + 1, option.length() - pos - 1);
else else
arg.clear(); arg.clear();
} }
else if (pos != std::string::npos) else if (pos != std::string::npos)
{ {
throw UnexpectedArgumentException(option); throw UnexpectedArgumentException(option);
} }
else arg.clear(); else arg.clear();
} }
else if (!_shortName.empty() && option.compare(0, _shortName.length(), _shortName) == 0) else if (!_shortName.empty() && option.compare(0, _shortName.length(), _shortName) == 0)
{ {
if (takesArgument()) if (takesArgument())
{ {
if (argumentRequired() && option.length() == _shortName.length()) if (argumentRequired() && option.length() == _shortName.length())
throw MissingArgumentException(_shortName + " requires " + argumentName()); throw MissingArgumentException(_shortName + " requires " + argumentName());
arg.assign(option, _shortName.length(), option.length() - _shortName.length()); arg.assign(option, _shortName.length(), option.length() - _shortName.length());
} }
else if (option.length() != _shortName.length()) else if (option.length() != _shortName.length())
{ {
throw UnexpectedArgumentException(option); throw UnexpectedArgumentException(option);
} }
else arg.clear(); else arg.clear();
} }
else throw UnknownOptionException(option); else throw UnknownOptionException(option);
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,59 +1,59 @@
// //
// OptionCallback.cpp // OptionCallback.cpp
// //
// $Id: //poco/1.2/Util/src/OptionCallback.cpp#1 $ // $Id: //poco/1.2/Util/src/OptionCallback.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: OptionCallback // Module: OptionCallback
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/OptionCallback.h" #include "Poco/Util/OptionCallback.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
AbstractOptionCallback::AbstractOptionCallback() AbstractOptionCallback::AbstractOptionCallback()
{ {
} }
AbstractOptionCallback::AbstractOptionCallback(const AbstractOptionCallback&) AbstractOptionCallback::AbstractOptionCallback(const AbstractOptionCallback&)
{ {
} }
AbstractOptionCallback::~AbstractOptionCallback() AbstractOptionCallback::~AbstractOptionCallback()
{ {
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,57 +1,57 @@
// //
// OptionException.cpp // OptionException.cpp
// //
// $Id: //poco/1.2/Util/src/OptionException.cpp#1 $ // $Id: //poco/1.2/Util/src/OptionException.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: OptionException // Module: OptionException
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/OptionException.h" #include "Poco/Util/OptionException.h"
#include <typeinfo> #include <typeinfo>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
POCO_IMPLEMENT_EXCEPTION(OptionException, Poco::DataException, "Option exception") POCO_IMPLEMENT_EXCEPTION(OptionException, Poco::DataException, "Option exception")
POCO_IMPLEMENT_EXCEPTION(UnknownOptionException, OptionException, "Unknown option specified") POCO_IMPLEMENT_EXCEPTION(UnknownOptionException, OptionException, "Unknown option specified")
POCO_IMPLEMENT_EXCEPTION(AmbiguousOptionException, OptionException, "Ambiguous option specified") POCO_IMPLEMENT_EXCEPTION(AmbiguousOptionException, OptionException, "Ambiguous option specified")
POCO_IMPLEMENT_EXCEPTION(MissingOptionException, OptionException, "Required option not specified") POCO_IMPLEMENT_EXCEPTION(MissingOptionException, OptionException, "Required option not specified")
POCO_IMPLEMENT_EXCEPTION(MissingArgumentException, OptionException, "Missing option argument") POCO_IMPLEMENT_EXCEPTION(MissingArgumentException, OptionException, "Missing option argument")
POCO_IMPLEMENT_EXCEPTION(InvalidArgumentException, OptionException, "Invalid option argument") POCO_IMPLEMENT_EXCEPTION(InvalidArgumentException, OptionException, "Invalid option argument")
POCO_IMPLEMENT_EXCEPTION(UnexpectedArgumentException, OptionException, "Unexpected option argument") POCO_IMPLEMENT_EXCEPTION(UnexpectedArgumentException, OptionException, "Unexpected option argument")
POCO_IMPLEMENT_EXCEPTION(IncompatibleOptionsException, OptionException, "Incompatible options") POCO_IMPLEMENT_EXCEPTION(IncompatibleOptionsException, OptionException, "Incompatible options")
POCO_IMPLEMENT_EXCEPTION(DuplicateOptionException, OptionException, "Option must not be given more than once") POCO_IMPLEMENT_EXCEPTION(DuplicateOptionException, OptionException, "Option must not be given more than once")
POCO_IMPLEMENT_EXCEPTION(EmptyOptionException, OptionException, "Empty option specified") POCO_IMPLEMENT_EXCEPTION(EmptyOptionException, OptionException, "Empty option specified")
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,155 +1,155 @@
// //
// OptionProcessor.cpp // OptionProcessor.cpp
// //
// $Id: //poco/1.2/Util/src/OptionProcessor.cpp#1 $ // $Id: //poco/1.2/Util/src/OptionProcessor.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: OptionProcessor // Module: OptionProcessor
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/OptionProcessor.h" #include "Poco/Util/OptionProcessor.h"
#include "Poco/Util/OptionSet.h" #include "Poco/Util/OptionSet.h"
#include "Poco/Util/Option.h" #include "Poco/Util/Option.h"
#include "Poco/Util/OptionException.h" #include "Poco/Util/OptionException.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
OptionProcessor::OptionProcessor(const OptionSet& options): OptionProcessor::OptionProcessor(const OptionSet& options):
_options(options), _options(options),
_unixStyle(true), _unixStyle(true),
_ignore(false) _ignore(false)
{ {
} }
OptionProcessor::~OptionProcessor() OptionProcessor::~OptionProcessor()
{ {
} }
void OptionProcessor::setUnixStyle(bool flag) void OptionProcessor::setUnixStyle(bool flag)
{ {
_unixStyle = flag; _unixStyle = flag;
} }
bool OptionProcessor::process(const std::string& argument, std::string& optionName, std::string& optionArg) bool OptionProcessor::process(const std::string& argument, std::string& optionName, std::string& optionArg)
{ {
if (!_ignore) if (!_ignore)
{ {
if (_unixStyle) if (_unixStyle)
return processUnix(argument, optionName, optionArg); return processUnix(argument, optionName, optionArg);
else else
return processDefault(argument, optionName, optionArg); return processDefault(argument, optionName, optionArg);
} }
return false; return false;
} }
void OptionProcessor::checkRequired() const void OptionProcessor::checkRequired() const
{ {
for (OptionSet::Iterator it = _options.begin(); it != _options.end(); ++it) for (OptionSet::Iterator it = _options.begin(); it != _options.end(); ++it)
{ {
if (it->required() && _specifiedOptions.find(it->fullName()) == _specifiedOptions.end()) if (it->required() && _specifiedOptions.find(it->fullName()) == _specifiedOptions.end())
throw MissingOptionException(it->fullName()); throw MissingOptionException(it->fullName());
} }
} }
bool OptionProcessor::processUnix(const std::string& argument, std::string& optionName, std::string& optionArg) bool OptionProcessor::processUnix(const std::string& argument, std::string& optionName, std::string& optionArg)
{ {
std::string::const_iterator it = argument.begin(); std::string::const_iterator it = argument.begin();
std::string::const_iterator end = argument.end(); std::string::const_iterator end = argument.end();
if (it != end) if (it != end)
{ {
if (*it == '-') if (*it == '-')
{ {
++it; ++it;
if (it != end) if (it != end)
{ {
if (*it == '-') if (*it == '-')
{ {
++it; ++it;
if (it == end) if (it == end)
{ {
_ignore = true; _ignore = true;
return true; return true;
} }
else return processCommon(std::string(it, end), false, optionName, optionArg); else return processCommon(std::string(it, end), false, optionName, optionArg);
} }
else return processCommon(std::string(it, end), true, optionName, optionArg); else return processCommon(std::string(it, end), true, optionName, optionArg);
} }
} }
} }
return false; return false;
} }
bool OptionProcessor::processDefault(const std::string& argument, std::string& optionName, std::string& optionArg) bool OptionProcessor::processDefault(const std::string& argument, std::string& optionName, std::string& optionArg)
{ {
std::string::const_iterator it = argument.begin(); std::string::const_iterator it = argument.begin();
std::string::const_iterator end = argument.end(); std::string::const_iterator end = argument.end();
if (it != end) if (it != end)
{ {
if (*it == '/') if (*it == '/')
{ {
++it; ++it;
return processCommon(std::string(it, end), false, optionName, optionArg); return processCommon(std::string(it, end), false, optionName, optionArg);
} }
} }
return false; return false;
} }
bool OptionProcessor::processCommon(const std::string& optionStr, bool isShort, std::string& optionName, std::string& optionArg) bool OptionProcessor::processCommon(const std::string& optionStr, bool isShort, std::string& optionName, std::string& optionArg)
{ {
if (optionStr.empty()) throw EmptyOptionException(); if (optionStr.empty()) throw EmptyOptionException();
const Option& option = _options.getOption(optionStr, isShort); const Option& option = _options.getOption(optionStr, isShort);
const std::string& group = option.group(); const std::string& group = option.group();
if (!group.empty()) if (!group.empty())
{ {
if (_groups.find(group) != _groups.end()) if (_groups.find(group) != _groups.end())
throw IncompatibleOptionsException(option.fullName()); throw IncompatibleOptionsException(option.fullName());
else else
_groups.insert(group); _groups.insert(group);
} }
if (_specifiedOptions.find(option.fullName()) != _specifiedOptions.end() && !option.repeatable()) if (_specifiedOptions.find(option.fullName()) != _specifiedOptions.end() && !option.repeatable())
throw DuplicateOptionException(option.fullName()); throw DuplicateOptionException(option.fullName());
_specifiedOptions.insert(option.fullName()); _specifiedOptions.insert(option.fullName());
option.process(optionStr, optionArg); option.process(optionStr, optionArg);
optionName = option.fullName(); optionName = option.fullName();
return true; return true;
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,144 +1,144 @@
// //
// OptionSet.cpp // OptionSet.cpp
// //
// $Id: //poco/1.2/Util/src/OptionSet.cpp#2 $ // $Id: //poco/1.2/Util/src/OptionSet.cpp#2 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: OptionSet // Module: OptionSet
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/OptionSet.h" #include "Poco/Util/OptionSet.h"
#include "Poco/Util/OptionException.h" #include "Poco/Util/OptionException.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
OptionSet::OptionSet() OptionSet::OptionSet()
{ {
} }
OptionSet::OptionSet(const OptionSet& options): OptionSet::OptionSet(const OptionSet& options):
_options(options._options) _options(options._options)
{ {
} }
OptionSet::~OptionSet() OptionSet::~OptionSet()
{ {
} }
OptionSet& OptionSet::operator = (const OptionSet& options) OptionSet& OptionSet::operator = (const OptionSet& options)
{ {
if (&options != this) if (&options != this)
_options = options._options; _options = options._options;
return *this; return *this;
} }
void OptionSet::addOption(const Option& option) void OptionSet::addOption(const Option& option)
{ {
poco_assert (!option.fullName().empty()); poco_assert (!option.fullName().empty());
OptionVec::const_iterator it = _options.begin(); OptionVec::const_iterator it = _options.begin();
OptionVec::const_iterator itEnd = _options.end(); OptionVec::const_iterator itEnd = _options.end();
for (; it != itEnd; ++it) for (; it != itEnd; ++it)
{ {
if (it->fullName() == option.fullName()) if (it->fullName() == option.fullName())
{ {
throw DuplicateOptionException(it->fullName()); throw DuplicateOptionException(it->fullName());
} }
} }
_options.push_back(option); _options.push_back(option);
} }
bool OptionSet::hasOption(const std::string& name, bool matchShort) const bool OptionSet::hasOption(const std::string& name, bool matchShort) const
{ {
bool found = false; bool found = false;
for (Iterator it = _options.begin(); it != _options.end(); ++it) for (Iterator it = _options.begin(); it != _options.end(); ++it)
{ {
if (matchShort && it->matchesShort(name) || !matchShort && it->matchesFull(name)) if (matchShort && it->matchesShort(name) || !matchShort && it->matchesFull(name))
{ {
if (!found) if (!found)
found = true; found = true;
else else
return false; return false;
} }
} }
return found; return found;
} }
const Option& OptionSet::getOption(const std::string& name, bool matchShort) const const Option& OptionSet::getOption(const std::string& name, bool matchShort) const
{ {
const Option* pOption = 0; const Option* pOption = 0;
for (Iterator it = _options.begin(); it != _options.end(); ++it) for (Iterator it = _options.begin(); it != _options.end(); ++it)
{ {
if (matchShort && it->matchesShort(name) || !matchShort && it->matchesPartial(name)) if (matchShort && it->matchesShort(name) || !matchShort && it->matchesPartial(name))
{ {
if (!pOption) if (!pOption)
{ {
pOption = &*it; pOption = &*it;
if (!matchShort && it->matchesFull(name)) if (!matchShort && it->matchesFull(name))
break; break;
} }
else if (!matchShort && it->matchesFull(name)) else if (!matchShort && it->matchesFull(name))
{ {
pOption = &*it; pOption = &*it;
break; break;
} }
else throw AmbiguousOptionException(name); else throw AmbiguousOptionException(name);
} }
} }
if (pOption) if (pOption)
return *pOption; return *pOption;
else else
throw UnknownOptionException(name); throw UnknownOptionException(name);
} }
OptionSet::Iterator OptionSet::begin() const OptionSet::Iterator OptionSet::begin() const
{ {
return _options.begin(); return _options.begin();
} }
OptionSet::Iterator OptionSet::end() const OptionSet::Iterator OptionSet::end() const
{ {
return _options.end(); return _options.end();
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,180 +1,180 @@
// //
// PropertyFileConfiguration.cpp // PropertyFileConfiguration.cpp
// //
// $Id: //poco/1.2/Util/src/PropertyFileConfiguration.cpp#1 $ // $Id: //poco/1.2/Util/src/PropertyFileConfiguration.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: PropertyFileConfiguration // Module: PropertyFileConfiguration
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/PropertyFileConfiguration.h" #include "Poco/Util/PropertyFileConfiguration.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/String.h" #include "Poco/String.h"
#include <fstream> #include <fstream>
#include <locale> #include <locale>
using Poco::trim; using Poco::trim;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
PropertyFileConfiguration::PropertyFileConfiguration() PropertyFileConfiguration::PropertyFileConfiguration()
{ {
} }
PropertyFileConfiguration::PropertyFileConfiguration(std::istream& istr) PropertyFileConfiguration::PropertyFileConfiguration(std::istream& istr)
{ {
load(istr); load(istr);
} }
PropertyFileConfiguration::PropertyFileConfiguration(const std::string& path) PropertyFileConfiguration::PropertyFileConfiguration(const std::string& path)
{ {
load(path); load(path);
} }
PropertyFileConfiguration::~PropertyFileConfiguration() PropertyFileConfiguration::~PropertyFileConfiguration()
{ {
} }
void PropertyFileConfiguration::load(std::istream& istr) void PropertyFileConfiguration::load(std::istream& istr)
{ {
clear(); clear();
while (!istr.eof()) while (!istr.eof())
{ {
parseLine(istr); parseLine(istr);
} }
} }
void PropertyFileConfiguration::load(const std::string& path) void PropertyFileConfiguration::load(const std::string& path)
{ {
std::ifstream istr(path.c_str()); std::ifstream istr(path.c_str());
if (istr.good()) if (istr.good())
load(istr); load(istr);
else else
throw Poco::OpenFileException(path); throw Poco::OpenFileException(path);
} }
void PropertyFileConfiguration::save(std::ostream& ostr) const void PropertyFileConfiguration::save(std::ostream& ostr) const
{ {
MapConfiguration::iterator it = begin(); MapConfiguration::iterator it = begin();
MapConfiguration::iterator ed = end(); MapConfiguration::iterator ed = end();
while (it != ed) while (it != ed)
{ {
ostr << it->first << ": " << it->second << "\n"; ostr << it->first << ": " << it->second << "\n";
++it; ++it;
} }
} }
void PropertyFileConfiguration::save(const std::string& path) const void PropertyFileConfiguration::save(const std::string& path) const
{ {
std::ofstream ostr(path.c_str()); std::ofstream ostr(path.c_str());
if (ostr.good()) if (ostr.good())
{ {
save(ostr); save(ostr);
ostr.flush(); ostr.flush();
if (!ostr.good()) throw Poco::WriteFileException(path); if (!ostr.good()) throw Poco::WriteFileException(path);
} }
else throw Poco::CreateFileException(path); else throw Poco::CreateFileException(path);
} }
void PropertyFileConfiguration::parseLine(std::istream& istr) void PropertyFileConfiguration::parseLine(std::istream& istr)
{ {
static const int eof = std::char_traits<char>::eof(); static const int eof = std::char_traits<char>::eof();
std::locale loc; std::locale loc;
int c = istr.get(); int c = istr.get();
while (c != eof && isspace((char) c, loc)) c = istr.get(); while (c != eof && isspace((char) c, loc)) c = istr.get();
if (c != eof) if (c != eof)
{ {
if (c == '#' || c == '!') if (c == '#' || c == '!')
{ {
while (c != eof && c != '\n' && c != '\r') c = istr.get(); while (c != eof && c != '\n' && c != '\r') c = istr.get();
} }
else else
{ {
std::string key; std::string key;
while (c != eof && c != '=' && c != ':' && c != '\r' && c != '\n') { key += (char) c; c = istr.get(); } while (c != eof && c != '=' && c != ':' && c != '\r' && c != '\n') { key += (char) c; c = istr.get(); }
std::string value; std::string value;
if (c == '=' || c == ':') if (c == '=' || c == ':')
{ {
c = readChar(istr); c = readChar(istr);
while (c != eof && c) { value += (char) c; c = readChar(istr); } while (c != eof && c) { value += (char) c; c = readChar(istr); }
} }
setRaw(trim(key), trim(value)); setRaw(trim(key), trim(value));
} }
} }
} }
int PropertyFileConfiguration::readChar(std::istream& istr) int PropertyFileConfiguration::readChar(std::istream& istr)
{ {
int c = istr.get(); int c = istr.get();
if (c == '\\') if (c == '\\')
{ {
c = istr.get(); c = istr.get();
switch (c) switch (c)
{ {
case 't': case 't':
return '\t'; return '\t';
case 'r': case 'r':
return '\r'; return '\r';
case 'n': case 'n':
return '\n'; return '\n';
case 'f': case 'f':
return '\f'; return '\f';
case '\r': case '\r':
if (istr.peek() == '\n') if (istr.peek() == '\n')
istr.get(); istr.get();
return ' '; return ' ';
case '\n': case '\n':
return ' '; return ' ';
default: default:
return c; return c;
} }
} }
else if (c == '\n' || c == '\r') else if (c == '\n' || c == '\r')
return 0; return 0;
else else
return c; return c;
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,69 +1,69 @@
// //
// RegExpValidator.cpp // RegExpValidator.cpp
// //
// $Id: //poco/1.2/Util/src/RegExpValidator.cpp#1 $ // $Id: //poco/1.2/Util/src/RegExpValidator.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: RegExpValidator // Module: RegExpValidator
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/RegExpValidator.h" #include "Poco/Util/RegExpValidator.h"
#include "Poco/Util/Option.h" #include "Poco/Util/Option.h"
#include "Poco/Util/OptionException.h" #include "Poco/Util/OptionException.h"
#include "Poco/RegularExpression.h" #include "Poco/RegularExpression.h"
#include "Poco/Format.h" #include "Poco/Format.h"
using Poco::format; using Poco::format;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
RegExpValidator::RegExpValidator(const std::string& regexp): RegExpValidator::RegExpValidator(const std::string& regexp):
_regexp(regexp) _regexp(regexp)
{ {
} }
RegExpValidator::~RegExpValidator() RegExpValidator::~RegExpValidator()
{ {
} }
void RegExpValidator::validate(const Option& option, const std::string& value) void RegExpValidator::validate(const Option& option, const std::string& value)
{ {
if (!RegularExpression::match(value, _regexp, RegularExpression::RE_ANCHORED | RegularExpression::RE_UTF8)) if (!RegularExpression::match(value, _regexp, RegularExpression::RE_ANCHORED | RegularExpression::RE_UTF8))
throw InvalidArgumentException(format("argument for %s does not match regular expression %s", option.fullName(), _regexp)); throw InvalidArgumentException(format("argument for %s does not match regular expression %s", option.fullName(), _regexp));
} }
} } // namespace Poco::Util } } // namespace Poco::Util

File diff suppressed because it is too large Load Diff

View File

@@ -1,61 +1,61 @@
// //
// Subsystem.cpp // Subsystem.cpp
// //
// $Id: //poco/1.2/Util/src/Subsystem.cpp#1 $ // $Id: //poco/1.2/Util/src/Subsystem.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Application // Package: Application
// Module: Subsystem // Module: Subsystem
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/Subsystem.h" #include "Poco/Util/Subsystem.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
Subsystem::Subsystem() Subsystem::Subsystem()
{ {
} }
Subsystem::~Subsystem() Subsystem::~Subsystem()
{ {
} }
void Subsystem::reinitialize(Application& app) void Subsystem::reinitialize(Application& app)
{ {
uninitialize(); uninitialize();
initialize(app); initialize(app);
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,132 +1,132 @@
// //
// SystemConfiguration.cpp // SystemConfiguration.cpp
// //
// $Id: //poco/1.2/Util/src/SystemConfiguration.cpp#1 $ // $Id: //poco/1.2/Util/src/SystemConfiguration.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: SystemConfiguration // Module: SystemConfiguration
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/SystemConfiguration.h" #include "Poco/Util/SystemConfiguration.h"
#include "Poco/Environment.h" #include "Poco/Environment.h"
#include "Poco/Path.h" #include "Poco/Path.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
using Poco::Environment; using Poco::Environment;
using Poco::Path; using Poco::Path;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
const std::string SystemConfiguration::OSNAME = "system.osName"; const std::string SystemConfiguration::OSNAME = "system.osName";
const std::string SystemConfiguration::OSVERSION = "system.osVersion"; const std::string SystemConfiguration::OSVERSION = "system.osVersion";
const std::string SystemConfiguration::OSARCHITECTURE = "system.osArchitecture"; const std::string SystemConfiguration::OSARCHITECTURE = "system.osArchitecture";
const std::string SystemConfiguration::NODENAME = "system.nodeName"; const std::string SystemConfiguration::NODENAME = "system.nodeName";
const std::string SystemConfiguration::CURRENTDIR = "system.currentDir"; const std::string SystemConfiguration::CURRENTDIR = "system.currentDir";
const std::string SystemConfiguration::HOMEDIR = "system.homeDir"; const std::string SystemConfiguration::HOMEDIR = "system.homeDir";
const std::string SystemConfiguration::TEMPDIR = "system.tempDir"; const std::string SystemConfiguration::TEMPDIR = "system.tempDir";
const std::string SystemConfiguration::ENV = "system.env."; const std::string SystemConfiguration::ENV = "system.env.";
SystemConfiguration::SystemConfiguration() SystemConfiguration::SystemConfiguration()
{ {
} }
SystemConfiguration::~SystemConfiguration() SystemConfiguration::~SystemConfiguration()
{ {
} }
bool SystemConfiguration::getRaw(const std::string& key, std::string& value) const bool SystemConfiguration::getRaw(const std::string& key, std::string& value) const
{ {
if (key == OSNAME) if (key == OSNAME)
value = Environment::osName(); value = Environment::osName();
else if (key == OSVERSION) else if (key == OSVERSION)
value = Environment::osVersion(); value = Environment::osVersion();
else if (key == OSARCHITECTURE) else if (key == OSARCHITECTURE)
value = Environment::osArchitecture(); value = Environment::osArchitecture();
else if (key == NODENAME) else if (key == NODENAME)
value = Environment::nodeName(); value = Environment::nodeName();
else if (key == CURRENTDIR) else if (key == CURRENTDIR)
value = Path::current(); value = Path::current();
else if (key == HOMEDIR) else if (key == HOMEDIR)
value = Path::home(); value = Path::home();
else if (key == TEMPDIR) else if (key == TEMPDIR)
value = Path::temp(); value = Path::temp();
else if (key.compare(0, ENV.size(), ENV) == 0) else if (key.compare(0, ENV.size(), ENV) == 0)
return getEnv(key.substr(ENV.size()), value); return getEnv(key.substr(ENV.size()), value);
else else
return false; return false;
return true; return true;
} }
void SystemConfiguration::setRaw(const std::string& key, const std::string& value) void SystemConfiguration::setRaw(const std::string& key, const std::string& value)
{ {
throw Poco::InvalidAccessException("Attempt to modify a system property", key); throw Poco::InvalidAccessException("Attempt to modify a system property", key);
} }
void SystemConfiguration::enumerate(const std::string& key, Keys& range) const void SystemConfiguration::enumerate(const std::string& key, Keys& range) const
{ {
if (key.empty()) if (key.empty())
{ {
range.push_back("system"); range.push_back("system");
} }
else if (key == "system") else if (key == "system")
{ {
range.push_back("osName"); range.push_back("osName");
range.push_back("osVersion"); range.push_back("osVersion");
range.push_back("osArchitecture"); range.push_back("osArchitecture");
range.push_back("nodeName"); range.push_back("nodeName");
range.push_back("currentDir"); range.push_back("currentDir");
range.push_back("homeDir"); range.push_back("homeDir");
range.push_back("tempDir"); range.push_back("tempDir");
range.push_back("env"); range.push_back("env");
} }
} }
bool SystemConfiguration::getEnv(const std::string& name, std::string& value) bool SystemConfiguration::getEnv(const std::string& name, std::string& value)
{ {
if (Environment::has(name)) if (Environment::has(name))
{ {
value = Environment::get(name); value = Environment::get(name);
return true; return true;
} }
return false; return false;
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,54 +1,54 @@
// //
// Validator.cpp // Validator.cpp
// //
// $Id: //poco/1.2/Util/src/Validator.cpp#1 $ // $Id: //poco/1.2/Util/src/Validator.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
// Module: Validator // Module: Validator
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/Validator.h" #include "Poco/Util/Validator.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
Validator::Validator() Validator::Validator()
{ {
} }
Validator::~Validator() Validator::~Validator()
{ {
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,134 +1,134 @@
// //
// WinRegistryConfiguration.cpp // WinRegistryConfiguration.cpp
// //
// $Id: //poco/1.2/Util/src/WinRegistryConfiguration.cpp#1 $ // $Id: //poco/1.2/Util/src/WinRegistryConfiguration.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Windows // Package: Windows
// Module: WinRegistryConfiguration // Module: WinRegistryConfiguration
// //
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/WinRegistryConfiguration.h" #include "Poco/Util/WinRegistryConfiguration.h"
#include "Poco/Util/WinRegistryKey.h" #include "Poco/Util/WinRegistryKey.h"
#include "Poco/NumberFormatter.h" #include "Poco/NumberFormatter.h"
#include "Poco/NumberParser.h" #include "Poco/NumberParser.h"
namespace Poco { namespace Poco {
namespace Util { namespace Util {
WinRegistryConfiguration::WinRegistryConfiguration(const std::string& rootPath): _rootPath(rootPath) WinRegistryConfiguration::WinRegistryConfiguration(const std::string& rootPath): _rootPath(rootPath)
{ {
// rootPath must end with backslash // rootPath must end with backslash
if (*(--_rootPath.end()) != '\\') if (*(--_rootPath.end()) != '\\')
_rootPath.append("\\"); _rootPath.append("\\");
} }
WinRegistryConfiguration::~WinRegistryConfiguration() WinRegistryConfiguration::~WinRegistryConfiguration()
{ {
} }
bool WinRegistryConfiguration::getRaw(const std::string& key, std::string& value) const bool WinRegistryConfiguration::getRaw(const std::string& key, std::string& value) const
{ {
std::string keyName; std::string keyName;
std::string fullPath = _rootPath + ConvertToRegFormat(key, keyName); std::string fullPath = _rootPath + ConvertToRegFormat(key, keyName);
WinRegistryKey aKey(fullPath); WinRegistryKey aKey(fullPath);
WinRegistryKey::Type type = aKey.type(keyName); WinRegistryKey::Type type = aKey.type(keyName);
bool ret = true; bool ret = true;
switch(type) switch(type)
{ {
case WinRegistryKey::REGT_STRING: case WinRegistryKey::REGT_STRING:
value = aKey.getString(keyName); value = aKey.getString(keyName);
break; break;
case WinRegistryKey::REGT_STRING_EXPAND: case WinRegistryKey::REGT_STRING_EXPAND:
value = aKey.getStringExpand(keyName); value = aKey.getStringExpand(keyName);
break; break;
case WinRegistryKey::REGT_DWORD: case WinRegistryKey::REGT_DWORD:
value = Poco::NumberFormatter::format(aKey.getInt(keyName)); value = Poco::NumberFormatter::format(aKey.getInt(keyName));
break; break;
default: default:
ret = false; ret = false;
} }
return ret; return ret;
} }
void WinRegistryConfiguration::setRaw(const std::string& key, const std::string& value) void WinRegistryConfiguration::setRaw(const std::string& key, const std::string& value)
{ {
std::string keyName; std::string keyName;
std::string fullPath = _rootPath+ConvertToRegFormat(key, keyName); std::string fullPath = _rootPath+ConvertToRegFormat(key, keyName);
WinRegistryKey aKey(fullPath); WinRegistryKey aKey(fullPath);
aKey.setString(keyName, value); aKey.setString(keyName, value);
} }
void WinRegistryConfiguration::enumerate(const std::string& key, Keys& range) const void WinRegistryConfiguration::enumerate(const std::string& key, Keys& range) const
{ {
if (key.empty()) if (key.empty())
{ {
// return all root level keys // return all root level keys
range.push_back("HKEY_CLASSES_ROOT"); range.push_back("HKEY_CLASSES_ROOT");
range.push_back("HKEY_CURRENT_CONFIG"); range.push_back("HKEY_CURRENT_CONFIG");
range.push_back("HKEY_CURRENT_USER"); range.push_back("HKEY_CURRENT_USER");
range.push_back("HKEY_LOCAL_MACHINE"); range.push_back("HKEY_LOCAL_MACHINE");
range.push_back("HKEY_PERFORMANCE_DATA"); range.push_back("HKEY_PERFORMANCE_DATA");
range.push_back("HKEY_USERS"); range.push_back("HKEY_USERS");
} }
else else
{ {
std::string keyName; std::string keyName;
std::string fullPath = _rootPath+ConvertToRegFormat(key, keyName); std::string fullPath = _rootPath+ConvertToRegFormat(key, keyName);
WinRegistryKey aKey(fullPath); WinRegistryKey aKey(fullPath);
aKey.values(range); aKey.values(range);
aKey.subKeys(range); aKey.subKeys(range);
} }
} }
std::string WinRegistryConfiguration::ConvertToRegFormat(const std::string& key, std::string& value) const std::string WinRegistryConfiguration::ConvertToRegFormat(const std::string& key, std::string& value) const
{ {
std::size_t pos = key.rfind('.'); std::size_t pos = key.rfind('.');
if (pos == std::string::npos) if (pos == std::string::npos)
{ {
value = key; value = key;
return std::string(); return std::string();
} }
std::string prefix(key.substr(0,pos)); std::string prefix(key.substr(0,pos));
value = key.substr(pos+1); value = key.substr(pos+1);
Poco::translateInPlace(prefix, ".", "\\"); Poco::translateInPlace(prefix, ".", "\\");
return prefix; return prefix;
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,483 +1,483 @@
// //
// WinRegistryKey.cpp // WinRegistryKey.cpp
// //
// $Id: //poco/1.2/Util/src/WinRegistryKey.cpp#1 $ // $Id: //poco/1.2/Util/src/WinRegistryKey.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Windows // Package: Windows
// Module: WinRegistryKey // Module: WinRegistryKey
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/WinRegistryKey.h" #include "Poco/Util/WinRegistryKey.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
#include "Poco/UnicodeConverter.h" #include "Poco/UnicodeConverter.h"
#endif #endif
using Poco::SystemException; using Poco::SystemException;
using Poco::NotFoundException; using Poco::NotFoundException;
using Poco::InvalidArgumentException; using Poco::InvalidArgumentException;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
WinRegistryKey::WinRegistryKey(const std::string& key): WinRegistryKey::WinRegistryKey(const std::string& key):
_hKey(0) _hKey(0)
{ {
std::string::size_type pos = key.find('\\'); std::string::size_type pos = key.find('\\');
if (pos != std::string::npos) if (pos != std::string::npos)
{ {
std::string rootKey = key.substr(0, pos); std::string rootKey = key.substr(0, pos);
_hRootKey = handleFor(rootKey); _hRootKey = handleFor(rootKey);
_subKey = key.substr(pos + 1); _subKey = key.substr(pos + 1);
} }
else throw InvalidArgumentException("Not a valid registry key", key); else throw InvalidArgumentException("Not a valid registry key", key);
} }
WinRegistryKey::WinRegistryKey(HKEY hRootKey, const std::string& subKey): WinRegistryKey::WinRegistryKey(HKEY hRootKey, const std::string& subKey):
_hRootKey(hRootKey), _hRootKey(hRootKey),
_subKey(subKey), _subKey(subKey),
_hKey(0) _hKey(0)
{ {
} }
WinRegistryKey::~WinRegistryKey() WinRegistryKey::~WinRegistryKey()
{ {
close(); close();
} }
void WinRegistryKey::setString(const std::string& name, const std::string& value) void WinRegistryKey::setString(const std::string& name, const std::string& value)
{ {
open(); open();
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring uname; std::wstring uname;
Poco::UnicodeConverter::toUTF16(name, uname); Poco::UnicodeConverter::toUTF16(name, uname);
std::wstring uvalue; std::wstring uvalue;
Poco::UnicodeConverter::toUTF16(value, uvalue); Poco::UnicodeConverter::toUTF16(value, uvalue);
if (RegSetValueExW(_hKey, uname.c_str(), 0, REG_SZ, (CONST BYTE*) uvalue.c_str(), (DWORD) (uvalue.size() + 1)*sizeof(wchar_t)) != ERROR_SUCCESS) if (RegSetValueExW(_hKey, uname.c_str(), 0, REG_SZ, (CONST BYTE*) uvalue.c_str(), (DWORD) (uvalue.size() + 1)*sizeof(wchar_t)) != ERROR_SUCCESS)
handleSetError(name); handleSetError(name);
#else #else
if (RegSetValueEx(_hKey, name.c_str(), 0, REG_SZ, (CONST BYTE*) value.c_str(), (DWORD) value.size() + 1) != ERROR_SUCCESS) if (RegSetValueEx(_hKey, name.c_str(), 0, REG_SZ, (CONST BYTE*) value.c_str(), (DWORD) value.size() + 1) != ERROR_SUCCESS)
handleSetError(name); handleSetError(name);
#endif #endif
} }
std::string WinRegistryKey::getString(const std::string& name) std::string WinRegistryKey::getString(const std::string& name)
{ {
open(); open();
DWORD type; DWORD type;
DWORD size; DWORD size;
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring uname; std::wstring uname;
Poco::UnicodeConverter::toUTF16(name, uname); Poco::UnicodeConverter::toUTF16(name, uname);
if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ) if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ)
throw NotFoundException(key(name)); throw NotFoundException(key(name));
if (size > 0) if (size > 0)
{ {
DWORD len = size/2; DWORD len = size/2;
wchar_t* buffer = new wchar_t[len + 1]; wchar_t* buffer = new wchar_t[len + 1];
RegQueryValueExW(_hKey, uname.c_str(), NULL, NULL, (BYTE*) buffer, &size); RegQueryValueExW(_hKey, uname.c_str(), NULL, NULL, (BYTE*) buffer, &size);
buffer[len] = 0; buffer[len] = 0;
std::wstring uresult(buffer); std::wstring uresult(buffer);
delete [] buffer; delete [] buffer;
std::string result; std::string result;
Poco::UnicodeConverter::toUTF8(uresult, result); Poco::UnicodeConverter::toUTF8(uresult, result);
return result; return result;
} }
#else #else
if (RegQueryValueEx(_hKey, name.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ) if (RegQueryValueEx(_hKey, name.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ)
throw NotFoundException(key(name)); throw NotFoundException(key(name));
if (size > 0) if (size > 0)
{ {
char* buffer = new char[size + 1]; char* buffer = new char[size + 1];
RegQueryValueEx(_hKey, name.c_str(), NULL, NULL, (BYTE*) buffer, &size); RegQueryValueEx(_hKey, name.c_str(), NULL, NULL, (BYTE*) buffer, &size);
buffer[size] = 0; buffer[size] = 0;
std::string result(buffer); std::string result(buffer);
delete [] buffer; delete [] buffer;
return result; return result;
} }
#endif #endif
return std::string(); return std::string();
} }
void WinRegistryKey::setStringExpand(const std::string& name, const std::string& value) void WinRegistryKey::setStringExpand(const std::string& name, const std::string& value)
{ {
open(); open();
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring uname; std::wstring uname;
Poco::UnicodeConverter::toUTF16(name, uname); Poco::UnicodeConverter::toUTF16(name, uname);
std::wstring uvalue; std::wstring uvalue;
Poco::UnicodeConverter::toUTF16(value, uvalue); Poco::UnicodeConverter::toUTF16(value, uvalue);
if (RegSetValueExW(_hKey, uname.c_str(), 0, REG_EXPAND_SZ, (CONST BYTE*) uvalue.c_str(), (DWORD) (uvalue.size() + 1)*sizeof(wchar_t)) != ERROR_SUCCESS) if (RegSetValueExW(_hKey, uname.c_str(), 0, REG_EXPAND_SZ, (CONST BYTE*) uvalue.c_str(), (DWORD) (uvalue.size() + 1)*sizeof(wchar_t)) != ERROR_SUCCESS)
handleSetError(name); handleSetError(name);
#else #else
if (RegSetValueEx(_hKey, name.c_str(), 0, REG_EXPAND_SZ, (CONST BYTE*) value.c_str(), (DWORD) value.size() + 1) != ERROR_SUCCESS) if (RegSetValueEx(_hKey, name.c_str(), 0, REG_EXPAND_SZ, (CONST BYTE*) value.c_str(), (DWORD) value.size() + 1) != ERROR_SUCCESS)
handleSetError(name); handleSetError(name);
#endif #endif
} }
std::string WinRegistryKey::getStringExpand(const std::string& name) std::string WinRegistryKey::getStringExpand(const std::string& name)
{ {
open(); open();
DWORD type; DWORD type;
DWORD size; DWORD size;
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring uname; std::wstring uname;
Poco::UnicodeConverter::toUTF16(name, uname); Poco::UnicodeConverter::toUTF16(name, uname);
if (RegQueryValueEx(_hKey, uname.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ) if (RegQueryValueEx(_hKey, uname.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ)
throw NotFoundException(key(name)); throw NotFoundException(key(name));
if (size > 0) if (size > 0)
{ {
DWORD len = size/2; DWORD len = size/2;
wchar_t* buffer = new wchar_t[len + 1]; wchar_t* buffer = new wchar_t[len + 1];
RegQueryValueExW(_hKey, uname.c_str(), NULL, NULL, (BYTE*) buffer, &size); RegQueryValueExW(_hKey, uname.c_str(), NULL, NULL, (BYTE*) buffer, &size);
buffer[len] = 0; buffer[len] = 0;
wchar_t temp; wchar_t temp;
DWORD expSize = ExpandEnvironmentStrings(buffer, &temp, 1); DWORD expSize = ExpandEnvironmentStrings(buffer, &temp, 1);
wchar_t* expBuffer = new wchar_t[expSize]; wchar_t* expBuffer = new wchar_t[expSize];
ExpandEnvironmentStringsW(buffer, expBuffer, expSize); ExpandEnvironmentStringsW(buffer, expBuffer, expSize);
std::string result; std::string result;
UnicodeConverter::toUTF8(expBuffer, result); UnicodeConverter::toUTF8(expBuffer, result);
delete [] buffer; delete [] buffer;
delete [] expBuffer; delete [] expBuffer;
return result; return result;
} }
#else #else
if (RegQueryValueEx(_hKey, name.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ) if (RegQueryValueEx(_hKey, name.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS || type != REG_SZ && type != REG_EXPAND_SZ)
throw NotFoundException(key(name)); throw NotFoundException(key(name));
if (size > 0) if (size > 0)
{ {
char* buffer = new char[size + 1]; char* buffer = new char[size + 1];
RegQueryValueEx(_hKey, name.c_str(), NULL, NULL, (BYTE*) buffer, &size); RegQueryValueEx(_hKey, name.c_str(), NULL, NULL, (BYTE*) buffer, &size);
buffer[size] = 0; buffer[size] = 0;
char temp; char temp;
DWORD expSize = ExpandEnvironmentStrings(buffer, &temp, 1); DWORD expSize = ExpandEnvironmentStrings(buffer, &temp, 1);
char* expBuffer = new char[expSize]; char* expBuffer = new char[expSize];
ExpandEnvironmentStrings(buffer, expBuffer, expSize); ExpandEnvironmentStrings(buffer, expBuffer, expSize);
std::string result(expBuffer); std::string result(expBuffer);
delete [] buffer; delete [] buffer;
delete [] expBuffer; delete [] expBuffer;
return result; return result;
} }
#endif #endif
return std::string(); return std::string();
} }
void WinRegistryKey::setInt(const std::string& name, int value) void WinRegistryKey::setInt(const std::string& name, int value)
{ {
open(); open();
DWORD data = value; DWORD data = value;
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring uname; std::wstring uname;
Poco::UnicodeConverter::toUTF16(name, uname); Poco::UnicodeConverter::toUTF16(name, uname);
if (RegSetValueExW(_hKey, uname.c_str(), 0, REG_DWORD, (CONST BYTE*) &data, sizeof(data)) != ERROR_SUCCESS) if (RegSetValueExW(_hKey, uname.c_str(), 0, REG_DWORD, (CONST BYTE*) &data, sizeof(data)) != ERROR_SUCCESS)
handleSetError(name); handleSetError(name);
#else #else
if (RegSetValueEx(_hKey, name.c_str(), 0, REG_DWORD, (CONST BYTE*) &data, sizeof(data)) != ERROR_SUCCESS) if (RegSetValueEx(_hKey, name.c_str(), 0, REG_DWORD, (CONST BYTE*) &data, sizeof(data)) != ERROR_SUCCESS)
handleSetError(name); handleSetError(name);
#endif #endif
} }
int WinRegistryKey::getInt(const std::string& name) int WinRegistryKey::getInt(const std::string& name)
{ {
open(); open();
DWORD type; DWORD type;
DWORD data; DWORD data;
DWORD size; DWORD size;
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring uname; std::wstring uname;
Poco::UnicodeConverter::toUTF16(name, uname); Poco::UnicodeConverter::toUTF16(name, uname);
if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, (BYTE*) &data, &size) != ERROR_SUCCESS || type != REG_DWORD) if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, (BYTE*) &data, &size) != ERROR_SUCCESS || type != REG_DWORD)
throw NotFoundException(key(name)); throw NotFoundException(key(name));
#else #else
if (RegQueryValueEx(_hKey, name.c_str(), NULL, &type, (BYTE*) &data, &size) != ERROR_SUCCESS || type != REG_DWORD) if (RegQueryValueEx(_hKey, name.c_str(), NULL, &type, (BYTE*) &data, &size) != ERROR_SUCCESS || type != REG_DWORD)
throw NotFoundException(key(name)); throw NotFoundException(key(name));
#endif #endif
return data; return data;
} }
void WinRegistryKey::deleteValue(const std::string& name) void WinRegistryKey::deleteValue(const std::string& name)
{ {
open(); open();
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring uname; std::wstring uname;
Poco::UnicodeConverter::toUTF16(name, uname); Poco::UnicodeConverter::toUTF16(name, uname);
if (RegDeleteValueW(_hKey, uname.c_str()) != ERROR_SUCCESS) if (RegDeleteValueW(_hKey, uname.c_str()) != ERROR_SUCCESS)
throw NotFoundException(key(name)); throw NotFoundException(key(name));
#else #else
if (RegDeleteValue(_hKey, name.c_str()) != ERROR_SUCCESS) if (RegDeleteValue(_hKey, name.c_str()) != ERROR_SUCCESS)
throw NotFoundException(key(name)); throw NotFoundException(key(name));
#endif #endif
} }
void WinRegistryKey::deleteKey() void WinRegistryKey::deleteKey()
{ {
close(); close();
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring usubKey; std::wstring usubKey;
Poco::UnicodeConverter::toUTF16(_subKey, usubKey); Poco::UnicodeConverter::toUTF16(_subKey, usubKey);
if (RegDeleteKeyW(_hRootKey, usubKey.c_str()) != ERROR_SUCCESS) if (RegDeleteKeyW(_hRootKey, usubKey.c_str()) != ERROR_SUCCESS)
throw NotFoundException(key()); throw NotFoundException(key());
#else #else
if (RegDeleteKey(_hRootKey, _subKey.c_str()) != ERROR_SUCCESS) if (RegDeleteKey(_hRootKey, _subKey.c_str()) != ERROR_SUCCESS)
throw NotFoundException(key()); throw NotFoundException(key());
#endif #endif
} }
bool WinRegistryKey::exists() bool WinRegistryKey::exists()
{ {
open(); open();
DWORD size; DWORD size;
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
wchar_t name[256]; wchar_t name[256];
return RegEnumValueW(_hKey, 0, name, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; return RegEnumValueW(_hKey, 0, name, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS;
#else #else
char name[256]; char name[256];
return RegEnumValue(_hKey, 0, name, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS; return RegEnumValue(_hKey, 0, name, &size, NULL, NULL, NULL, NULL) == ERROR_SUCCESS;
#endif #endif
} }
WinRegistryKey::Type WinRegistryKey::type(const std::string& name) WinRegistryKey::Type WinRegistryKey::type(const std::string& name)
{ {
open(); open();
DWORD type = REG_NONE; DWORD type = REG_NONE;
DWORD size; DWORD size;
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring uname; std::wstring uname;
Poco::UnicodeConverter::toUTF16(name, uname); Poco::UnicodeConverter::toUTF16(name, uname);
if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS) if (RegQueryValueExW(_hKey, uname.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS)
throw NotFoundException(key(name)); throw NotFoundException(key(name));
#else #else
if (RegQueryValueEx(_hKey, name.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS) if (RegQueryValueEx(_hKey, name.c_str(), NULL, &type, NULL, &size) != ERROR_SUCCESS)
throw NotFoundException(key(name)); throw NotFoundException(key(name));
#endif #endif
if (type != REG_SZ && type != REG_EXPAND_SZ && type != REG_DWORD) if (type != REG_SZ && type != REG_EXPAND_SZ && type != REG_DWORD)
throw NotFoundException(key(name)+": type not supported"); throw NotFoundException(key(name)+": type not supported");
Type aType = (Type)type; Type aType = (Type)type;
return aType; return aType;
} }
bool WinRegistryKey::exists(const std::string& name) bool WinRegistryKey::exists(const std::string& name)
{ {
open(); open();
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring uname; std::wstring uname;
Poco::UnicodeConverter::toUTF16(name, uname); Poco::UnicodeConverter::toUTF16(name, uname);
return RegQueryValueExW(_hKey, uname.c_str(), NULL, NULL, NULL, NULL) == ERROR_SUCCESS; return RegQueryValueExW(_hKey, uname.c_str(), NULL, NULL, NULL, NULL) == ERROR_SUCCESS;
#else #else
return RegQueryValueEx(_hKey, name.c_str(), NULL, NULL, NULL, NULL) == ERROR_SUCCESS; return RegQueryValueEx(_hKey, name.c_str(), NULL, NULL, NULL, NULL) == ERROR_SUCCESS;
#endif #endif
} }
void WinRegistryKey::open() void WinRegistryKey::open()
{ {
if (!_hKey) if (!_hKey)
{ {
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring usubKey; std::wstring usubKey;
Poco::UnicodeConverter::toUTF16(_subKey, usubKey); Poco::UnicodeConverter::toUTF16(_subKey, usubKey);
if (RegCreateKeyEx(_hRootKey, usubKey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &_hKey, NULL) != ERROR_SUCCESS) if (RegCreateKeyEx(_hRootKey, usubKey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &_hKey, NULL) != ERROR_SUCCESS)
throw SystemException("Cannot open registry key: ", key()); throw SystemException("Cannot open registry key: ", key());
#else #else
if (RegCreateKeyEx(_hRootKey, _subKey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &_hKey, NULL) != ERROR_SUCCESS) if (RegCreateKeyEx(_hRootKey, _subKey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_READ | KEY_WRITE, NULL, &_hKey, NULL) != ERROR_SUCCESS)
throw SystemException("Cannot open registry key: ", key()); throw SystemException("Cannot open registry key: ", key());
#endif #endif
} }
} }
void WinRegistryKey::close() void WinRegistryKey::close()
{ {
if (_hKey) if (_hKey)
{ {
RegCloseKey(_hKey); RegCloseKey(_hKey);
_hKey = 0; _hKey = 0;
} }
} }
std::string WinRegistryKey::key() const std::string WinRegistryKey::key() const
{ {
std::string result; std::string result;
if (_hRootKey == HKEY_CLASSES_ROOT) if (_hRootKey == HKEY_CLASSES_ROOT)
result = "HKEY_CLASSES_ROOT"; result = "HKEY_CLASSES_ROOT";
else if (_hRootKey == HKEY_CURRENT_CONFIG) else if (_hRootKey == HKEY_CURRENT_CONFIG)
result = "HKEY_CURRENT_CONFIG"; result = "HKEY_CURRENT_CONFIG";
else if (_hRootKey == HKEY_CURRENT_USER) else if (_hRootKey == HKEY_CURRENT_USER)
result = "HKEY_CURRENT_USER"; result = "HKEY_CURRENT_USER";
else if (_hRootKey == HKEY_LOCAL_MACHINE) else if (_hRootKey == HKEY_LOCAL_MACHINE)
result = "HKEY_LOCAL_MACHINE"; result = "HKEY_LOCAL_MACHINE";
else if (_hRootKey == HKEY_USERS) else if (_hRootKey == HKEY_USERS)
result = "HKEY_USERS"; result = "HKEY_USERS";
else if (_hRootKey == HKEY_PERFORMANCE_DATA) else if (_hRootKey == HKEY_PERFORMANCE_DATA)
result = "HKEY_PERFORMANCE_DATA"; result = "HKEY_PERFORMANCE_DATA";
else else
result = "(UNKNOWN)"; result = "(UNKNOWN)";
result += '\\'; result += '\\';
result += _subKey; result += _subKey;
return result; return result;
} }
std::string WinRegistryKey::key(const std::string& valueName) const std::string WinRegistryKey::key(const std::string& valueName) const
{ {
std::string& result = key(); std::string& result = key();
if (!valueName.empty()) if (!valueName.empty())
{ {
result += '\\'; result += '\\';
result += valueName; result += valueName;
} }
return result; return result;
} }
HKEY WinRegistryKey::handleFor(const std::string& rootKey) HKEY WinRegistryKey::handleFor(const std::string& rootKey)
{ {
if (rootKey == "HKEY_CLASSES_ROOT") if (rootKey == "HKEY_CLASSES_ROOT")
return HKEY_CLASSES_ROOT; return HKEY_CLASSES_ROOT;
else if (rootKey == "HKEY_CURRENT_CONFIG") else if (rootKey == "HKEY_CURRENT_CONFIG")
return HKEY_CURRENT_CONFIG; return HKEY_CURRENT_CONFIG;
else if (rootKey == "HKEY_CURRENT_USER") else if (rootKey == "HKEY_CURRENT_USER")
return HKEY_CURRENT_USER; return HKEY_CURRENT_USER;
else if (rootKey == "HKEY_LOCAL_MACHINE") else if (rootKey == "HKEY_LOCAL_MACHINE")
return HKEY_LOCAL_MACHINE; return HKEY_LOCAL_MACHINE;
else if (rootKey == "HKEY_USERS") else if (rootKey == "HKEY_USERS")
return HKEY_USERS; return HKEY_USERS;
else if (rootKey == "HKEY_PERFORMANCE_DATA") else if (rootKey == "HKEY_PERFORMANCE_DATA")
return HKEY_PERFORMANCE_DATA; return HKEY_PERFORMANCE_DATA;
else else
throw InvalidArgumentException("Not a valid root key", rootKey); throw InvalidArgumentException("Not a valid root key", rootKey);
} }
void WinRegistryKey::handleSetError(const std::string& name) void WinRegistryKey::handleSetError(const std::string& name)
{ {
std::string msg = "Failed to set registry value"; std::string msg = "Failed to set registry value";
throw SystemException(msg, key(name)); throw SystemException(msg, key(name));
} }
void WinRegistryKey::subKeys(WinRegistryKey::Keys& keys) void WinRegistryKey::subKeys(WinRegistryKey::Keys& keys)
{ {
open(); open();
DWORD subKeyCount = 0; DWORD subKeyCount = 0;
DWORD valueCount = 0; DWORD valueCount = 0;
if (RegQueryInfoKey(_hKey, NULL, NULL, NULL, &subKeyCount, NULL, NULL, &valueCount, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) if (RegQueryInfoKey(_hKey, NULL, NULL, NULL, &subKeyCount, NULL, NULL, &valueCount, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
return; return;
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
wchar_t buf[256]; wchar_t buf[256];
DWORD bufSize = sizeof(buf)/sizeof(wchar_t); DWORD bufSize = sizeof(buf)/sizeof(wchar_t);
for (DWORD i = 0; i< subKeyCount; ++i) for (DWORD i = 0; i< subKeyCount; ++i)
{ {
if (RegEnumKeyExW(_hKey, i, buf, &bufSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) if (RegEnumKeyExW(_hKey, i, buf, &bufSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{ {
std::wstring uname(buf); std::wstring uname(buf);
std::string name; std::string name;
Poco::UnicodeConverter::toUTF8(uname, name); Poco::UnicodeConverter::toUTF8(uname, name);
keys.push_back(name); keys.push_back(name);
} }
bufSize = sizeof(buf)/sizeof(wchar_t); bufSize = sizeof(buf)/sizeof(wchar_t);
} }
#else #else
char buf[256]; char buf[256];
DWORD bufSize = sizeof(buf); DWORD bufSize = sizeof(buf);
for (DWORD i = 0; i< subKeyCount; ++i) for (DWORD i = 0; i< subKeyCount; ++i)
{ {
if (RegEnumKeyEx(_hKey, i, buf, &bufSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) if (RegEnumKeyEx(_hKey, i, buf, &bufSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{ {
std::string name(buf); std::string name(buf);
keys.push_back(name); keys.push_back(name);
} }
bufSize = sizeof(buf); bufSize = sizeof(buf);
} }
#endif #endif
} }
void WinRegistryKey::values(WinRegistryKey::Values& vals) void WinRegistryKey::values(WinRegistryKey::Values& vals)
{ {
open(); open();
DWORD valueCount = 0; DWORD valueCount = 0;
if (RegQueryInfoKey(_hKey, NULL, NULL, NULL, NULL, NULL, NULL, &valueCount, NULL, NULL, NULL, NULL) != ERROR_SUCCESS) if (RegQueryInfoKey(_hKey, NULL, NULL, NULL, NULL, NULL, NULL, &valueCount, NULL, NULL, NULL, NULL) != ERROR_SUCCESS)
return ; return ;
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
wchar_t buf[256]; wchar_t buf[256];
DWORD bufSize = sizeof(buf)/sizeof(wchar_t); DWORD bufSize = sizeof(buf)/sizeof(wchar_t);
for (DWORD i = 0; i< valueCount; ++i) for (DWORD i = 0; i< valueCount; ++i)
{ {
if (RegEnumValueW(_hKey, i, buf, &bufSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) if (RegEnumValueW(_hKey, i, buf, &bufSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{ {
std::wstring uname(buf); std::wstring uname(buf);
std::string name; std::string name;
Poco::UnicodeConverter::toUTF8(uname, name); Poco::UnicodeConverter::toUTF8(uname, name);
vals.push_back(name); vals.push_back(name);
} }
bufSize = sizeof(buf)/sizeof(wchar_t); bufSize = sizeof(buf)/sizeof(wchar_t);
} }
#else #else
char buf[256]; char buf[256];
DWORD bufSize = sizeof(buf); DWORD bufSize = sizeof(buf);
for (DWORD i = 0; i< valueCount; ++i) for (DWORD i = 0; i< valueCount; ++i)
{ {
if (RegEnumValue(_hKey, i, buf, &bufSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS) if (RegEnumValue(_hKey, i, buf, &bufSize, NULL, NULL, NULL, NULL) == ERROR_SUCCESS)
{ {
std::string name(buf); std::string name(buf);
vals.push_back(name); vals.push_back(name);
} }
bufSize = sizeof(buf); bufSize = sizeof(buf);
} }
#endif #endif
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,317 +1,317 @@
// //
// WinService.cpp // WinService.cpp
// //
// $Id: //poco/1.2/Util/src/WinService.cpp#1 $ // $Id: //poco/1.2/Util/src/WinService.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Windows // Package: Windows
// Module: WinService // Module: WinService
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/WinService.h" #include "Poco/Util/WinService.h"
#include "Poco/Thread.h" #include "Poco/Thread.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
#include "Poco/UnicodeConverter.h" #include "Poco/UnicodeConverter.h"
#endif #endif
using Poco::Thread; using Poco::Thread;
using Poco::SystemException; using Poco::SystemException;
using Poco::NotFoundException; using Poco::NotFoundException;
using Poco::OutOfMemoryException; using Poco::OutOfMemoryException;
namespace Poco { namespace Poco {
namespace Util { namespace Util {
const int WinService::STARTUP_TIMEOUT = 30000; const int WinService::STARTUP_TIMEOUT = 30000;
WinService::WinService(const std::string& name): WinService::WinService(const std::string& name):
_name(name), _name(name),
_svcHandle(0) _svcHandle(0)
{ {
_scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS); _scmHandle = OpenSCManager(NULL, NULL, SC_MANAGER_ALL_ACCESS);
if (!_scmHandle) throw SystemException("cannot open Service Control Manager"); if (!_scmHandle) throw SystemException("cannot open Service Control Manager");
} }
WinService::~WinService() WinService::~WinService()
{ {
close(); close();
CloseServiceHandle(_scmHandle); CloseServiceHandle(_scmHandle);
} }
const std::string& WinService::name() const const std::string& WinService::name() const
{ {
return _name; return _name;
} }
std::string WinService::displayName() const std::string WinService::displayName() const
{ {
LPQUERY_SERVICE_CONFIG pSvcConfig = config(); LPQUERY_SERVICE_CONFIG pSvcConfig = config();
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring udispName(pSvcConfig->lpDisplayName); std::wstring udispName(pSvcConfig->lpDisplayName);
std::string dispName; std::string dispName;
Poco::UnicodeConverter::toUTF8(udispName, dispName); Poco::UnicodeConverter::toUTF8(udispName, dispName);
#else #else
std::string dispName(pSvcConfig->lpDisplayName); std::string dispName(pSvcConfig->lpDisplayName);
#endif #endif
LocalFree(pSvcConfig); LocalFree(pSvcConfig);
return dispName; return dispName;
} }
std::string WinService::path() const std::string WinService::path() const
{ {
LPQUERY_SERVICE_CONFIG pSvcConfig = config(); LPQUERY_SERVICE_CONFIG pSvcConfig = config();
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring upath(pSvcConfig->lpBinaryPathName); std::wstring upath(pSvcConfig->lpBinaryPathName);
std::string path; std::string path;
UnicodeConverter::toUTF8(upath, path); UnicodeConverter::toUTF8(upath, path);
#else #else
std::string path(pSvcConfig->lpBinaryPathName); std::string path(pSvcConfig->lpBinaryPathName);
#endif #endif
LocalFree(pSvcConfig); LocalFree(pSvcConfig);
return path; return path;
} }
void WinService::registerService(const std::string& path, const std::string& displayName) void WinService::registerService(const std::string& path, const std::string& displayName)
{ {
close(); close();
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring uname; std::wstring uname;
Poco::UnicodeConverter::toUTF16(_name, uname); Poco::UnicodeConverter::toUTF16(_name, uname);
std::wstring udisplayName; std::wstring udisplayName;
Poco::UnicodeConverter::toUTF16(displayName, udisplayName); Poco::UnicodeConverter::toUTF16(displayName, udisplayName);
std::wstring upath; std::wstring upath;
Poco::UnicodeConverter::toUTF16(path, upath); Poco::UnicodeConverter::toUTF16(path, upath);
_svcHandle = CreateService( _svcHandle = CreateService(
_scmHandle, _scmHandle,
uname.c_str(), uname.c_str(),
udisplayName.c_str(), udisplayName.c_str(),
SERVICE_ALL_ACCESS, SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS, SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START, SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL, SERVICE_ERROR_NORMAL,
upath.c_str(), upath.c_str(),
NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL);
#else #else
_svcHandle = CreateService( _svcHandle = CreateService(
_scmHandle, _scmHandle,
_name.c_str(), _name.c_str(),
displayName.c_str(), displayName.c_str(),
SERVICE_ALL_ACCESS, SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS, SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START, SERVICE_DEMAND_START,
SERVICE_ERROR_NORMAL, SERVICE_ERROR_NORMAL,
path.c_str(), path.c_str(),
NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL);
#endif #endif
if (!_svcHandle) if (!_svcHandle)
throw SystemException("cannot register service", _name); throw SystemException("cannot register service", _name);
} }
void WinService::registerService(const std::string& path) void WinService::registerService(const std::string& path)
{ {
registerService(path, _name); registerService(path, _name);
} }
void WinService::unregisterService() void WinService::unregisterService()
{ {
open(); open();
if (!DeleteService(_svcHandle)) if (!DeleteService(_svcHandle))
throw SystemException("cannot unregister service", _name); throw SystemException("cannot unregister service", _name);
} }
bool WinService::isRegistered() const bool WinService::isRegistered() const
{ {
return tryOpen(); return tryOpen();
} }
bool WinService::isRunning() const bool WinService::isRunning() const
{ {
open(); open();
SERVICE_STATUS ss; SERVICE_STATUS ss;
if (!QueryServiceStatus(_svcHandle, &ss)) if (!QueryServiceStatus(_svcHandle, &ss))
throw SystemException("cannot query service status", _name); throw SystemException("cannot query service status", _name);
return ss.dwCurrentState == SERVICE_RUNNING; return ss.dwCurrentState == SERVICE_RUNNING;
} }
void WinService::start() void WinService::start()
{ {
open(); open();
if (!StartService(_svcHandle, 0, NULL)) if (!StartService(_svcHandle, 0, NULL))
throw SystemException("cannot start service", _name); throw SystemException("cannot start service", _name);
SERVICE_STATUS svcStatus; SERVICE_STATUS svcStatus;
long msecs = 0; long msecs = 0;
while (msecs < STARTUP_TIMEOUT) while (msecs < STARTUP_TIMEOUT)
{ {
if (!QueryServiceStatus(_svcHandle, &svcStatus)) break; if (!QueryServiceStatus(_svcHandle, &svcStatus)) break;
if (svcStatus.dwCurrentState != SERVICE_START_PENDING) break; if (svcStatus.dwCurrentState != SERVICE_START_PENDING) break;
Thread::sleep(250); Thread::sleep(250);
msecs += 250; msecs += 250;
} }
if (!QueryServiceStatus(_svcHandle, &svcStatus)) if (!QueryServiceStatus(_svcHandle, &svcStatus))
throw SystemException("cannot query status of starting service", _name); throw SystemException("cannot query status of starting service", _name);
else if (svcStatus.dwCurrentState != SERVICE_RUNNING) else if (svcStatus.dwCurrentState != SERVICE_RUNNING)
throw SystemException("service failed to start within a reasonable time", _name); throw SystemException("service failed to start within a reasonable time", _name);
} }
void WinService::stop() void WinService::stop()
{ {
open(); open();
SERVICE_STATUS svcStatus; SERVICE_STATUS svcStatus;
if (!ControlService(_svcHandle, SERVICE_CONTROL_STOP, &svcStatus)) if (!ControlService(_svcHandle, SERVICE_CONTROL_STOP, &svcStatus))
throw SystemException("cannot stop service", _name); throw SystemException("cannot stop service", _name);
} }
void WinService::setStartup(WinService::Startup startup) void WinService::setStartup(WinService::Startup startup)
{ {
open(); open();
DWORD startType; DWORD startType;
switch (startup) switch (startup)
{ {
case SVC_AUTO_START: case SVC_AUTO_START:
startType = SERVICE_AUTO_START; startType = SERVICE_AUTO_START;
break; break;
case SVC_MANUAL_START: case SVC_MANUAL_START:
startType = SERVICE_DEMAND_START; startType = SERVICE_DEMAND_START;
break; break;
case SVC_DISABLED: case SVC_DISABLED:
startType = SERVICE_DISABLED; startType = SERVICE_DISABLED;
break; break;
default: default:
startType = SERVICE_NO_CHANGE; startType = SERVICE_NO_CHANGE;
} }
if (!ChangeServiceConfig(_svcHandle, SERVICE_NO_CHANGE, startType, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL)) if (!ChangeServiceConfig(_svcHandle, SERVICE_NO_CHANGE, startType, SERVICE_NO_CHANGE, NULL, NULL, NULL, NULL, NULL, NULL, NULL))
{ {
throw SystemException("cannot change service startup mode"); throw SystemException("cannot change service startup mode");
} }
} }
WinService::Startup WinService::getStartup() const WinService::Startup WinService::getStartup() const
{ {
LPQUERY_SERVICE_CONFIG pSvcConfig = config(); LPQUERY_SERVICE_CONFIG pSvcConfig = config();
Startup result; Startup result;
switch (pSvcConfig->dwStartType) switch (pSvcConfig->dwStartType)
{ {
case SERVICE_AUTO_START: case SERVICE_AUTO_START:
case SERVICE_BOOT_START: case SERVICE_BOOT_START:
case SERVICE_SYSTEM_START: case SERVICE_SYSTEM_START:
result = SVC_AUTO_START; result = SVC_AUTO_START;
break; break;
case SERVICE_DEMAND_START: case SERVICE_DEMAND_START:
result = SVC_MANUAL_START; result = SVC_MANUAL_START;
break; break;
case SERVICE_DISABLED: case SERVICE_DISABLED:
result = SVC_DISABLED; result = SVC_DISABLED;
break; break;
default: default:
poco_debugger(); poco_debugger();
result = SVC_MANUAL_START; result = SVC_MANUAL_START;
} }
LocalFree(pSvcConfig); LocalFree(pSvcConfig);
return result; return result;
} }
void WinService::open() const void WinService::open() const
{ {
if (!tryOpen()) if (!tryOpen())
throw NotFoundException("service does not exist", _name); throw NotFoundException("service does not exist", _name);
} }
bool WinService::tryOpen() const bool WinService::tryOpen() const
{ {
#if defined(POCO_WIN32_UTF8) #if defined(POCO_WIN32_UTF8)
std::wstring uname; std::wstring uname;
Poco::UnicodeConverter::toUTF16(_name, uname); Poco::UnicodeConverter::toUTF16(_name, uname);
_svcHandle = OpenService(_scmHandle, uname.c_str(), SERVICE_ALL_ACCESS); _svcHandle = OpenService(_scmHandle, uname.c_str(), SERVICE_ALL_ACCESS);
#else #else
_svcHandle = OpenService(_scmHandle, _name.c_str(), SERVICE_ALL_ACCESS); _svcHandle = OpenService(_scmHandle, _name.c_str(), SERVICE_ALL_ACCESS);
#endif #endif
return _svcHandle != 0; return _svcHandle != 0;
} }
void WinService::close() const void WinService::close() const
{ {
if (_svcHandle) if (_svcHandle)
{ {
CloseServiceHandle(_svcHandle); CloseServiceHandle(_svcHandle);
} }
} }
LPQUERY_SERVICE_CONFIG WinService::config() const LPQUERY_SERVICE_CONFIG WinService::config() const
{ {
open(); open();
int size = 4096; int size = 4096;
DWORD bytesNeeded; DWORD bytesNeeded;
LPQUERY_SERVICE_CONFIG pSvcConfig = (LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, size); LPQUERY_SERVICE_CONFIG pSvcConfig = (LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, size);
if (!pSvcConfig) throw OutOfMemoryException("cannot allocate service config buffer"); if (!pSvcConfig) throw OutOfMemoryException("cannot allocate service config buffer");
try try
{ {
while (!QueryServiceConfig(_svcHandle, pSvcConfig, size, &bytesNeeded)) while (!QueryServiceConfig(_svcHandle, pSvcConfig, size, &bytesNeeded))
{ {
if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) if (GetLastError() == ERROR_INSUFFICIENT_BUFFER)
{ {
LocalFree(pSvcConfig); LocalFree(pSvcConfig);
size = bytesNeeded; size = bytesNeeded;
pSvcConfig = (LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, size); pSvcConfig = (LPQUERY_SERVICE_CONFIG) LocalAlloc(LPTR, size);
} }
else throw SystemException("cannot query service configuration", _name); else throw SystemException("cannot query service configuration", _name);
} }
} }
catch (...) catch (...)
{ {
LocalFree(pSvcConfig); LocalFree(pSvcConfig);
throw; throw;
} }
return pSvcConfig; return pSvcConfig;
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,272 +1,272 @@
// //
// XMLConfiguration.cpp // XMLConfiguration.cpp
// //
// $Id: //poco/1.2/Util/src/XMLConfiguration.cpp#1 $ // $Id: //poco/1.2/Util/src/XMLConfiguration.cpp#1 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
// Module: XMLConfiguration // Module: XMLConfiguration
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "Poco/Util/XMLConfiguration.h" #include "Poco/Util/XMLConfiguration.h"
#include "Poco/SAX/InputSource.h" #include "Poco/SAX/InputSource.h"
#include "Poco/DOM/DOMParser.h" #include "Poco/DOM/DOMParser.h"
#include "Poco/DOM/Element.h" #include "Poco/DOM/Element.h"
#include "Poco/DOM/Attr.h" #include "Poco/DOM/Attr.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/NumberParser.h" #include "Poco/NumberParser.h"
#include "Poco/NumberFormatter.h" #include "Poco/NumberFormatter.h"
#include <set> #include <set>
namespace Poco { namespace Poco {
namespace Util { namespace Util {
XMLConfiguration::XMLConfiguration() XMLConfiguration::XMLConfiguration()
{ {
} }
XMLConfiguration::XMLConfiguration(Poco::XML::InputSource* pInputSource) XMLConfiguration::XMLConfiguration(Poco::XML::InputSource* pInputSource)
{ {
load(pInputSource); load(pInputSource);
} }
XMLConfiguration::XMLConfiguration(std::istream& istr) XMLConfiguration::XMLConfiguration(std::istream& istr)
{ {
load(istr); load(istr);
} }
XMLConfiguration::XMLConfiguration(const std::string& path) XMLConfiguration::XMLConfiguration(const std::string& path)
{ {
load(path); load(path);
} }
XMLConfiguration::XMLConfiguration(const Poco::XML::Document* pDocument) XMLConfiguration::XMLConfiguration(const Poco::XML::Document* pDocument)
{ {
load(pDocument); load(pDocument);
} }
XMLConfiguration::XMLConfiguration(const Poco::XML::Node* pNode) XMLConfiguration::XMLConfiguration(const Poco::XML::Node* pNode)
{ {
load(pNode); load(pNode);
} }
XMLConfiguration::~XMLConfiguration() XMLConfiguration::~XMLConfiguration()
{ {
} }
void XMLConfiguration::load(Poco::XML::InputSource* pInputSource) void XMLConfiguration::load(Poco::XML::InputSource* pInputSource)
{ {
poco_check_ptr (pInputSource); poco_check_ptr (pInputSource);
Poco::XML::DOMParser parser; Poco::XML::DOMParser parser;
parser.setFeature(Poco::XML::XMLReader::FEATURE_NAMESPACES, false); parser.setFeature(Poco::XML::XMLReader::FEATURE_NAMESPACES, false);
parser.setFeature(Poco::XML::DOMParser::FEATURE_WHITESPACE, true); parser.setFeature(Poco::XML::DOMParser::FEATURE_WHITESPACE, true);
Poco::XML::AutoPtr<Poco::XML::Document> pDoc = parser.parse(pInputSource); Poco::XML::AutoPtr<Poco::XML::Document> pDoc = parser.parse(pInputSource);
load(pDoc); load(pDoc);
} }
void XMLConfiguration::load(std::istream& istr) void XMLConfiguration::load(std::istream& istr)
{ {
Poco::XML::InputSource src(istr); Poco::XML::InputSource src(istr);
load(&src); load(&src);
} }
void XMLConfiguration::load(const std::string& path) void XMLConfiguration::load(const std::string& path)
{ {
Poco::XML::InputSource src(path); Poco::XML::InputSource src(path);
load(&src); load(&src);
} }
void XMLConfiguration::load(const Poco::XML::Document* pDocument) void XMLConfiguration::load(const Poco::XML::Document* pDocument)
{ {
poco_check_ptr (pDocument); poco_check_ptr (pDocument);
_pDocument = Poco::XML::AutoPtr<Poco::XML::Document>(const_cast<Poco::XML::Document*>(pDocument), true); _pDocument = Poco::XML::AutoPtr<Poco::XML::Document>(const_cast<Poco::XML::Document*>(pDocument), true);
_pRoot = Poco::XML::AutoPtr<Poco::XML::Node>(pDocument->documentElement(), true); _pRoot = Poco::XML::AutoPtr<Poco::XML::Node>(pDocument->documentElement(), true);
} }
void XMLConfiguration::load(const Poco::XML::Node* pNode) void XMLConfiguration::load(const Poco::XML::Node* pNode)
{ {
poco_check_ptr (pNode); poco_check_ptr (pNode);
if (pNode->nodeType() == Poco::XML::Node::DOCUMENT_NODE) if (pNode->nodeType() == Poco::XML::Node::DOCUMENT_NODE)
{ {
load(static_cast<const Poco::XML::Document*>(pNode)); load(static_cast<const Poco::XML::Document*>(pNode));
} }
else else
{ {
_pDocument = Poco::XML::AutoPtr<Poco::XML::Document>(pNode->ownerDocument(), true); _pDocument = Poco::XML::AutoPtr<Poco::XML::Document>(pNode->ownerDocument(), true);
_pRoot = Poco::XML::AutoPtr<Poco::XML::Node>(const_cast<Poco::XML::Node*>(pNode), true); _pRoot = Poco::XML::AutoPtr<Poco::XML::Node>(const_cast<Poco::XML::Node*>(pNode), true);
} }
} }
bool XMLConfiguration::getRaw(const std::string& key, std::string& value) const bool XMLConfiguration::getRaw(const std::string& key, std::string& value) const
{ {
const Poco::XML::Node* pNode = findNode(key); const Poco::XML::Node* pNode = findNode(key);
if (pNode) if (pNode)
{ {
value = pNode->innerText(); value = pNode->innerText();
return true; return true;
} }
else return false; else return false;
} }
void XMLConfiguration::setRaw(const std::string& key, const std::string& value) void XMLConfiguration::setRaw(const std::string& key, const std::string& value)
{ {
throw Poco::NotImplementedException("Setting a property in an XMLConfiguration"); throw Poco::NotImplementedException("Setting a property in an XMLConfiguration");
} }
void XMLConfiguration::enumerate(const std::string& key, Keys& range) const void XMLConfiguration::enumerate(const std::string& key, Keys& range) const
{ {
using Poco::NumberFormatter; using Poco::NumberFormatter;
std::multiset<std::string> keys; std::multiset<std::string> keys;
const Poco::XML::Node* pNode = findNode(key); const Poco::XML::Node* pNode = findNode(key);
if (pNode) if (pNode)
{ {
const Poco::XML::Node* pChild = pNode->firstChild(); const Poco::XML::Node* pChild = pNode->firstChild();
while (pChild) while (pChild)
{ {
if (pChild->nodeType() == Poco::XML::Node::ELEMENT_NODE) if (pChild->nodeType() == Poco::XML::Node::ELEMENT_NODE)
{ {
const std::string& nodeName = pChild->nodeName(); const std::string& nodeName = pChild->nodeName();
int n = (int) keys.count(nodeName); int n = (int) keys.count(nodeName);
if (n) if (n)
range.push_back(nodeName + "[" + NumberFormatter::format(n) + "]"); range.push_back(nodeName + "[" + NumberFormatter::format(n) + "]");
else else
range.push_back(nodeName); range.push_back(nodeName);
keys.insert(nodeName); keys.insert(nodeName);
} }
pChild = pChild->nextSibling(); pChild = pChild->nextSibling();
} }
} }
} }
const Poco::XML::Node* XMLConfiguration::findNode(const std::string& key) const const Poco::XML::Node* XMLConfiguration::findNode(const std::string& key) const
{ {
std::string::const_iterator it = key.begin(); std::string::const_iterator it = key.begin();
return findNode(it, key.end(), _pRoot); return findNode(it, key.end(), _pRoot);
} }
const Poco::XML::Node* XMLConfiguration::findNode(std::string::const_iterator& it, const std::string::const_iterator& end, const Poco::XML::Node* pNode) const Poco::XML::Node* XMLConfiguration::findNode(std::string::const_iterator& it, const std::string::const_iterator& end, const Poco::XML::Node* pNode)
{ {
if (pNode && it != end) if (pNode && it != end)
{ {
if (*it == '[') if (*it == '[')
{ {
++it; ++it;
if (it != end && *it == '@') if (it != end && *it == '@')
{ {
++it; ++it;
std::string attr; std::string attr;
while (it != end && *it != ']') attr += *it++; while (it != end && *it != ']') attr += *it++;
if (it != end) ++it; if (it != end) ++it;
return findAttribute(attr, pNode); return findAttribute(attr, pNode);
} }
else else
{ {
std::string index; std::string index;
while (it != end && *it != ']') index += *it++; while (it != end && *it != ']') index += *it++;
if (it != end) ++it; if (it != end) ++it;
return findNode(it, end, findElement(Poco::NumberParser::parse(index), pNode)); return findNode(it, end, findElement(Poco::NumberParser::parse(index), pNode));
} }
} }
else else
{ {
while (it != end && *it == '.') ++it; while (it != end && *it == '.') ++it;
std::string key; std::string key;
while (it != end && *it != '.' && *it != '[') key += *it++; while (it != end && *it != '.' && *it != '[') key += *it++;
return findNode(it, end, findElement(key, pNode)); return findNode(it, end, findElement(key, pNode));
} }
} }
else return pNode; else return pNode;
} }
const Poco::XML::Node* XMLConfiguration::findElement(const std::string& name, const Poco::XML::Node* pNode) const Poco::XML::Node* XMLConfiguration::findElement(const std::string& name, const Poco::XML::Node* pNode)
{ {
const Poco::XML::Node* pChild = pNode->firstChild(); const Poco::XML::Node* pChild = pNode->firstChild();
while (pChild) while (pChild)
{ {
if (pChild->nodeType() == Poco::XML::Node::ELEMENT_NODE && pChild->nodeName() == name) if (pChild->nodeType() == Poco::XML::Node::ELEMENT_NODE && pChild->nodeName() == name)
return pChild; return pChild;
pChild = pChild->nextSibling(); pChild = pChild->nextSibling();
} }
return 0; return 0;
} }
const Poco::XML::Node* XMLConfiguration::findElement(int index, const Poco::XML::Node* pNode) const Poco::XML::Node* XMLConfiguration::findElement(int index, const Poco::XML::Node* pNode)
{ {
const Poco::XML::Node* pRefNode = pNode; const Poco::XML::Node* pRefNode = pNode;
if (index > 0) if (index > 0)
{ {
pNode = pNode->nextSibling(); pNode = pNode->nextSibling();
while (pNode) while (pNode)
{ {
if (pNode->nodeName() == pRefNode->nodeName()) if (pNode->nodeName() == pRefNode->nodeName())
{ {
if (--index == 0) break; if (--index == 0) break;
} }
pNode = pNode->nextSibling(); pNode = pNode->nextSibling();
} }
} }
return pNode; return pNode;
} }
const Poco::XML::Node* XMLConfiguration::findAttribute(const std::string& name, const Poco::XML::Node* pNode) const Poco::XML::Node* XMLConfiguration::findAttribute(const std::string& name, const Poco::XML::Node* pNode)
{ {
const Poco::XML::Element* pElem = dynamic_cast<const Poco::XML::Element*>(pNode); const Poco::XML::Element* pElem = dynamic_cast<const Poco::XML::Element*>(pNode);
if (pElem) if (pElem)
return pElem->getAttributeNode(name); return pElem->getAttributeNode(name);
else else
return 0; return 0;
} }
} } // namespace Poco::Util } } // namespace Poco::Util

View File

@@ -1,24 +1,24 @@
# #
# Makefile # Makefile
# #
# $Id: //poco/1.2/Util/testsuite/Makefile#1 $ # $Id: //poco/1.2/Util/testsuite/Makefile#1 $
# #
# Makefile for Poco Util testsuite # Makefile for Poco Util testsuite
# #
include $(POCO_BASE)/build/rules/global include $(POCO_BASE)/build/rules/global
objects = AbstractConfigurationTest ConfigurationTestSuite \ objects = AbstractConfigurationTest ConfigurationTestSuite \
ConfigurationMapperTest ConfigurationViewTest Driver \ ConfigurationMapperTest ConfigurationViewTest Driver \
HelpFormatterTest IniFileConfigurationTest LayeredConfigurationTest \ HelpFormatterTest IniFileConfigurationTest LayeredConfigurationTest \
LoggingConfiguratorTest MapConfigurationTest \ LoggingConfiguratorTest MapConfigurationTest \
OptionProcessorTest OptionSetTest OptionTest \ OptionProcessorTest OptionSetTest OptionTest \
OptionsTestSuite PropertyFileConfigurationTest \ OptionsTestSuite PropertyFileConfigurationTest \
SystemConfigurationTest UtilTestSuite XMLConfigurationTest \ SystemConfigurationTest UtilTestSuite XMLConfigurationTest \
FilesystemConfigurationTest ValidatorTest FilesystemConfigurationTest ValidatorTest
target = testrunner target = testrunner
target_version = 1 target_version = 1
target_libs = PocoUtil PocoXML PocoFoundation CppUnit target_libs = PocoUtil PocoXML PocoFoundation CppUnit
include $(POCO_BASE)/build/rules/exec include $(POCO_BASE)/build/rules/exec

View File

@@ -1,25 +1,25 @@
# #
# TestSuite.vmsbuild # TestSuite.vmsbuild
# #
# $Id: //poco/1.2/Util/testsuite/TestSuite.vmsbuild#1 $ # $Id: //poco/1.2/Util/testsuite/TestSuite.vmsbuild#1 $
# #
EXE=TestRunner EXE=TestRunner
AbstractConfigurationTest AbstractConfigurationTest
ConfigurationTestSuite ConfigurationTestSuite
ConfigurationMapperTest ConfigurationMapperTest
ConfigurationViewTest ConfigurationViewTest
Driver Driver
HelpFormatterTest HelpFormatterTest
IniFileConfigurationTest IniFileConfigurationTest
LayeredConfigurationTest LayeredConfigurationTest
LoggingConfiguratorTest LoggingConfiguratorTest
MapConfigurationTest MapConfigurationTest
OptionProcessorTest OptionProcessorTest
OptionSetTest OptionSetTest
OptionTest OptionTest
OptionsTestSuite OptionsTestSuite
PropertyFileConfigurationTest PropertyFileConfigurationTest
SystemConfigurationTest SystemConfigurationTest
UtilTestSuite UtilTestSuite
XMLConfigurationTest XMLConfigurationTest
FilesystemConfigurationTest FilesystemConfigurationTest

View File

@@ -1,341 +1,341 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="7.10" Version="7.10"
Name="TestSuite" Name="TestSuite"
ProjectGUID="{e40e738c-447b-40f4-a878-eba9a2459270}" ProjectGUID="{e40e738c-447b-40f4-a878-eba9a2459270}"
Keyword="Win32Proj"> Keyword="Win32Proj">
<Platforms> <Platforms>
<Platform <Platform
Name="Win32"/> Name="Win32"/>
</Platforms> </Platforms>
<Configurations> <Configurations>
<Configuration <Configuration
Name="debug_shared|Win32" Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared" OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared" IntermediateDirectory="obj\debug_shared"
ConfigurationType="1" ConfigurationType="1"
UseOfMFC="2" UseOfMFC="2"
CharacterSet="2"> CharacterSet="2">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include" AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="TRUE" MinimalRebuild="TRUE"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
BufferSecurityCheck="TRUE" BufferSecurityCheck="TRUE"
TreatWChar_tAsBuiltInType="TRUE" TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE" ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE" RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="4"/> DebugInformationFormat="4"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="CppUnitd.lib WinTestRunnerd.lib PocoUtild.lib PocoFoundationd.lib PocoXMLd.lib" AdditionalDependencies="CppUnitd.lib WinTestRunnerd.lib PocoUtild.lib PocoFoundationd.lib PocoXMLd.lib"
OutputFile="bin/TestSuited.exe" OutputFile="bin/TestSuited.exe"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="..\..\lib" AdditionalLibraryDirectories="..\..\lib"
GenerateDebugInformation="TRUE" GenerateDebugInformation="TRUE"
ProgramDatabaseFile="bin/TestSuited.pdb" ProgramDatabaseFile="bin/TestSuited.pdb"
SubSystem="2" SubSystem="2"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
Name="VCPostBuildEventTool"/> Name="VCPostBuildEventTool"/>
<Tool <Tool
Name="VCPreBuildEventTool"/> Name="VCPreBuildEventTool"/>
<Tool <Tool
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool"/> Name="VCResourceCompilerTool"/>
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool"/> Name="VCWebServiceProxyGeneratorTool"/>
<Tool <Tool
Name="VCXMLDataGeneratorTool"/> Name="VCXMLDataGeneratorTool"/>
<Tool <Tool
Name="VCWebDeploymentTool"/> Name="VCWebDeploymentTool"/>
<Tool <Tool
Name="VCManagedWrapperGeneratorTool"/> Name="VCManagedWrapperGeneratorTool"/>
<Tool <Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration> </Configuration>
<Configuration <Configuration
Name="release_shared|Win32" Name="release_shared|Win32"
OutputDirectory="obj\release_shared" OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared" IntermediateDirectory="obj\release_shared"
ConfigurationType="1" ConfigurationType="1"
UseOfMFC="2" UseOfMFC="2"
CharacterSet="2"> CharacterSet="2">
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="4" Optimization="4"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
EnableIntrinsicFunctions="TRUE" EnableIntrinsicFunctions="TRUE"
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="TRUE" OmitFramePointers="TRUE"
OptimizeForWindowsApplication="TRUE" OptimizeForWindowsApplication="TRUE"
AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include" AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="TRUE" StringPooling="TRUE"
RuntimeLibrary="2" RuntimeLibrary="2"
BufferSecurityCheck="FALSE" BufferSecurityCheck="FALSE"
TreatWChar_tAsBuiltInType="TRUE" TreatWChar_tAsBuiltInType="TRUE"
ForceConformanceInForLoopScope="TRUE" ForceConformanceInForLoopScope="TRUE"
RuntimeTypeInfo="TRUE" RuntimeTypeInfo="TRUE"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="TRUE" Detect64BitPortabilityProblems="TRUE"
DebugInformationFormat="3"/> DebugInformationFormat="3"/>
<Tool <Tool
Name="VCCustomBuildTool"/> Name="VCCustomBuildTool"/>
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="CppUnit.lib WinTestRunner.lib PocoUtil.lib PocoFoundation.lib PocoXML.lib" AdditionalDependencies="CppUnit.lib WinTestRunner.lib PocoUtil.lib PocoFoundation.lib PocoXML.lib"
OutputFile="bin/TestSuite.exe" OutputFile="bin/TestSuite.exe"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="..\..\lib" AdditionalLibraryDirectories="..\..\lib"
GenerateDebugInformation="FALSE" GenerateDebugInformation="FALSE"
ProgramDatabaseFile="" ProgramDatabaseFile=""
SubSystem="2" SubSystem="2"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
TargetMachine="1"/> TargetMachine="1"/>
<Tool <Tool
Name="VCMIDLTool"/> Name="VCMIDLTool"/>
<Tool <Tool
Name="VCPostBuildEventTool"/> Name="VCPostBuildEventTool"/>
<Tool <Tool
Name="VCPreBuildEventTool"/> Name="VCPreBuildEventTool"/>
<Tool <Tool
Name="VCPreLinkEventTool"/> Name="VCPreLinkEventTool"/>
<Tool <Tool
Name="VCResourceCompilerTool"/> Name="VCResourceCompilerTool"/>
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool"/> Name="VCWebServiceProxyGeneratorTool"/>
<Tool <Tool
Name="VCXMLDataGeneratorTool"/> Name="VCXMLDataGeneratorTool"/>
<Tool <Tool
Name="VCWebDeploymentTool"/> Name="VCWebDeploymentTool"/>
<Tool <Tool
Name="VCManagedWrapperGeneratorTool"/> Name="VCManagedWrapperGeneratorTool"/>
<Tool <Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/> Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration> </Configuration>
</Configurations> </Configurations>
<References> <References>
</References> </References>
<Files> <Files>
<Filter <Filter
Name="Application" Name="Application"
Filter=""> Filter="">
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter=""> Filter="">
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="_Suite" Name="_Suite"
Filter=""> Filter="">
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\UtilTestSuite.h"> RelativePath=".\src\UtilTestSuite.h">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\UtilTestSuite.cpp"> RelativePath=".\src\UtilTestSuite.cpp">
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="_Driver" Name="_Driver"
Filter=""> Filter="">
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\WinDriver.cpp"> RelativePath=".\src\WinDriver.cpp">
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Configuration" Name="Configuration"
Filter=""> Filter="">
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\AbstractConfigurationTest.h"> RelativePath=".\src\AbstractConfigurationTest.h">
</File> </File>
<File <File
RelativePath=".\src\ConfigurationMapperTest.h"> RelativePath=".\src\ConfigurationMapperTest.h">
</File> </File>
<File <File
RelativePath=".\src\ConfigurationTestSuite.h"> RelativePath=".\src\ConfigurationTestSuite.h">
</File> </File>
<File <File
RelativePath=".\src\ConfigurationViewTest.h"> RelativePath=".\src\ConfigurationViewTest.h">
</File> </File>
<File <File
RelativePath=".\src\FilesystemConfigurationTest.h"> RelativePath=".\src\FilesystemConfigurationTest.h">
</File> </File>
<File <File
RelativePath=".\src\IniFileConfigurationTest.h"> RelativePath=".\src\IniFileConfigurationTest.h">
</File> </File>
<File <File
RelativePath=".\src\LayeredConfigurationTest.h"> RelativePath=".\src\LayeredConfigurationTest.h">
</File> </File>
<File <File
RelativePath=".\src\LoggingConfiguratorTest.h"> RelativePath=".\src\LoggingConfiguratorTest.h">
</File> </File>
<File <File
RelativePath=".\src\MapConfigurationTest.h"> RelativePath=".\src\MapConfigurationTest.h">
</File> </File>
<File <File
RelativePath=".\src\PropertyFileConfigurationTest.h"> RelativePath=".\src\PropertyFileConfigurationTest.h">
</File> </File>
<File <File
RelativePath=".\src\SystemConfigurationTest.h"> RelativePath=".\src\SystemConfigurationTest.h">
</File> </File>
<File <File
RelativePath=".\src\XMLConfigurationTest.h"> RelativePath=".\src\XMLConfigurationTest.h">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\AbstractConfigurationTest.cpp"> RelativePath=".\src\AbstractConfigurationTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\ConfigurationMapperTest.cpp"> RelativePath=".\src\ConfigurationMapperTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\ConfigurationTestSuite.cpp"> RelativePath=".\src\ConfigurationTestSuite.cpp">
</File> </File>
<File <File
RelativePath=".\src\ConfigurationViewTest.cpp"> RelativePath=".\src\ConfigurationViewTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\FilesystemConfigurationTest.cpp"> RelativePath=".\src\FilesystemConfigurationTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\IniFileConfigurationTest.cpp"> RelativePath=".\src\IniFileConfigurationTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\LayeredConfigurationTest.cpp"> RelativePath=".\src\LayeredConfigurationTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\LoggingConfiguratorTest.cpp"> RelativePath=".\src\LoggingConfiguratorTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\MapConfigurationTest.cpp"> RelativePath=".\src\MapConfigurationTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\PropertyFileConfigurationTest.cpp"> RelativePath=".\src\PropertyFileConfigurationTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\SystemConfigurationTest.cpp"> RelativePath=".\src\SystemConfigurationTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\XMLConfigurationTest.cpp"> RelativePath=".\src\XMLConfigurationTest.cpp">
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Options" Name="Options"
Filter=""> Filter="">
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\HelpFormatterTest.h"> RelativePath=".\src\HelpFormatterTest.h">
</File> </File>
<File <File
RelativePath=".\src\OptionProcessorTest.h"> RelativePath=".\src\OptionProcessorTest.h">
</File> </File>
<File <File
RelativePath=".\src\OptionSetTest.h"> RelativePath=".\src\OptionSetTest.h">
</File> </File>
<File <File
RelativePath=".\src\OptionsTestSuite.h"> RelativePath=".\src\OptionsTestSuite.h">
</File> </File>
<File <File
RelativePath=".\src\OptionTest.h"> RelativePath=".\src\OptionTest.h">
</File> </File>
<File <File
RelativePath=".\src\ValidatorTest.h"> RelativePath=".\src\ValidatorTest.h">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\HelpFormatterTest.cpp"> RelativePath=".\src\HelpFormatterTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\OptionProcessorTest.cpp"> RelativePath=".\src\OptionProcessorTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\OptionSetTest.cpp"> RelativePath=".\src\OptionSetTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\OptionsTestSuite.cpp"> RelativePath=".\src\OptionsTestSuite.cpp">
</File> </File>
<File <File
RelativePath=".\src\OptionTest.cpp"> RelativePath=".\src\OptionTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\ValidatorTest.cpp"> RelativePath=".\src\ValidatorTest.cpp">
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Windows" Name="Windows"
Filter=""> Filter="">
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\WinConfigurationTest.h"> RelativePath=".\src\WinConfigurationTest.h">
</File> </File>
<File <File
RelativePath=".\src\WindowsTestSuite.h"> RelativePath=".\src\WindowsTestSuite.h">
</File> </File>
<File <File
RelativePath=".\src\WinRegistryTest.h"> RelativePath=".\src\WinRegistryTest.h">
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
<File <File
RelativePath=".\src\WinConfigurationTest.cpp"> RelativePath=".\src\WinConfigurationTest.cpp">
</File> </File>
<File <File
RelativePath=".\src\WindowsTestSuite.cpp"> RelativePath=".\src\WindowsTestSuite.cpp">
</File> </File>
<File <File
RelativePath=".\src\WinRegistryTest.cpp"> RelativePath=".\src\WinRegistryTest.cpp">
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
</VisualStudioProject> </VisualStudioProject>

View File

@@ -1,449 +1,449 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8.00" Version="8.00"
Name="TestSuite" Name="TestSuite"
ProjectGUID="{E40E738C-447B-40F4-A878-EBA9A2459270}" ProjectGUID="{E40E738C-447B-40F4-A878-EBA9A2459270}"
Keyword="Win32Proj" Keyword="Win32Proj"
> >
<Platforms> <Platforms>
<Platform <Platform
Name="Win32" Name="Win32"
/> />
</Platforms> </Platforms>
<ToolFiles> <ToolFiles>
</ToolFiles> </ToolFiles>
<Configurations> <Configurations>
<Configuration <Configuration
Name="debug_shared|Win32" Name="debug_shared|Win32"
OutputDirectory="obj\debug_shared" OutputDirectory="obj\debug_shared"
IntermediateDirectory="obj\debug_shared" IntermediateDirectory="obj\debug_shared"
ConfigurationType="1" ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="2" UseOfMFC="2"
CharacterSet="2" CharacterSet="2"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
/> />
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
/> />
<Tool <Tool
Name="VCXMLDataGeneratorTool" Name="VCXMLDataGeneratorTool"
/> />
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool" Name="VCWebServiceProxyGeneratorTool"
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
/> />
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="0" Optimization="0"
AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include" AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500" PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
MinimalRebuild="true" MinimalRebuild="true"
BasicRuntimeChecks="3" BasicRuntimeChecks="3"
RuntimeLibrary="3" RuntimeLibrary="3"
BufferSecurityCheck="true" BufferSecurityCheck="true"
TreatWChar_tAsBuiltInType="true" TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true" ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true" RuntimeTypeInfo="true"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="true" Detect64BitPortabilityProblems="true"
DebugInformationFormat="4" DebugInformationFormat="4"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
/> />
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="CppUnitd.lib WinTestRunnerd.lib PocoUtild.lib PocoFoundationd.lib PocoXMLd.lib" AdditionalDependencies="CppUnitd.lib WinTestRunnerd.lib PocoUtild.lib PocoFoundationd.lib PocoXMLd.lib"
OutputFile="bin/TestSuited.exe" OutputFile="bin/TestSuited.exe"
LinkIncremental="2" LinkIncremental="2"
AdditionalLibraryDirectories="..\..\lib" AdditionalLibraryDirectories="..\..\lib"
GenerateDebugInformation="true" GenerateDebugInformation="true"
ProgramDatabaseFile="bin/TestSuited.pdb" ProgramDatabaseFile="bin/TestSuited.pdb"
SubSystem="2" SubSystem="2"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
/> />
<Tool <Tool
Name="VCManifestTool" Name="VCManifestTool"
/> />
<Tool <Tool
Name="VCXDCMakeTool" Name="VCXDCMakeTool"
/> />
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
/> />
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
/> />
<Tool <Tool
Name="VCWebDeploymentTool" Name="VCWebDeploymentTool"
/> />
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
<Configuration <Configuration
Name="release_shared|Win32" Name="release_shared|Win32"
OutputDirectory="obj\release_shared" OutputDirectory="obj\release_shared"
IntermediateDirectory="obj\release_shared" IntermediateDirectory="obj\release_shared"
ConfigurationType="1" ConfigurationType="1"
InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops" InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC71.vsprops"
UseOfMFC="2" UseOfMFC="2"
CharacterSet="2" CharacterSet="2"
> >
<Tool <Tool
Name="VCPreBuildEventTool" Name="VCPreBuildEventTool"
/> />
<Tool <Tool
Name="VCCustomBuildTool" Name="VCCustomBuildTool"
/> />
<Tool <Tool
Name="VCXMLDataGeneratorTool" Name="VCXMLDataGeneratorTool"
/> />
<Tool <Tool
Name="VCWebServiceProxyGeneratorTool" Name="VCWebServiceProxyGeneratorTool"
/> />
<Tool <Tool
Name="VCMIDLTool" Name="VCMIDLTool"
/> />
<Tool <Tool
Name="VCCLCompilerTool" Name="VCCLCompilerTool"
Optimization="4" Optimization="4"
InlineFunctionExpansion="1" InlineFunctionExpansion="1"
EnableIntrinsicFunctions="true" EnableIntrinsicFunctions="true"
FavorSizeOrSpeed="1" FavorSizeOrSpeed="1"
OmitFramePointers="true" OmitFramePointers="true"
AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include" AdditionalIncludeDirectories="..\include;..\..\Foundation\include;..\..\XML\include;..\..\Util\include;..\..\CppUnit\include;..\..\CppUnit\WinTestRunner\include"
PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500" PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;POCO_DLL;WINVER=0x0500"
StringPooling="true" StringPooling="true"
RuntimeLibrary="2" RuntimeLibrary="2"
BufferSecurityCheck="false" BufferSecurityCheck="false"
TreatWChar_tAsBuiltInType="true" TreatWChar_tAsBuiltInType="true"
ForceConformanceInForLoopScope="true" ForceConformanceInForLoopScope="true"
RuntimeTypeInfo="true" RuntimeTypeInfo="true"
UsePrecompiledHeader="0" UsePrecompiledHeader="0"
WarningLevel="3" WarningLevel="3"
Detect64BitPortabilityProblems="true" Detect64BitPortabilityProblems="true"
DebugInformationFormat="3" DebugInformationFormat="3"
/> />
<Tool <Tool
Name="VCManagedResourceCompilerTool" Name="VCManagedResourceCompilerTool"
/> />
<Tool <Tool
Name="VCResourceCompilerTool" Name="VCResourceCompilerTool"
/> />
<Tool <Tool
Name="VCPreLinkEventTool" Name="VCPreLinkEventTool"
/> />
<Tool <Tool
Name="VCLinkerTool" Name="VCLinkerTool"
AdditionalDependencies="CppUnit.lib WinTestRunner.lib PocoUtil.lib PocoFoundation.lib PocoXML.lib" AdditionalDependencies="CppUnit.lib WinTestRunner.lib PocoUtil.lib PocoFoundation.lib PocoXML.lib"
OutputFile="bin/TestSuite.exe" OutputFile="bin/TestSuite.exe"
LinkIncremental="1" LinkIncremental="1"
AdditionalLibraryDirectories="..\..\lib" AdditionalLibraryDirectories="..\..\lib"
GenerateDebugInformation="false" GenerateDebugInformation="false"
ProgramDatabaseFile="" ProgramDatabaseFile=""
SubSystem="2" SubSystem="2"
OptimizeReferences="2" OptimizeReferences="2"
EnableCOMDATFolding="2" EnableCOMDATFolding="2"
TargetMachine="1" TargetMachine="1"
/> />
<Tool <Tool
Name="VCALinkTool" Name="VCALinkTool"
/> />
<Tool <Tool
Name="VCManifestTool" Name="VCManifestTool"
/> />
<Tool <Tool
Name="VCXDCMakeTool" Name="VCXDCMakeTool"
/> />
<Tool <Tool
Name="VCBscMakeTool" Name="VCBscMakeTool"
/> />
<Tool <Tool
Name="VCFxCopTool" Name="VCFxCopTool"
/> />
<Tool <Tool
Name="VCAppVerifierTool" Name="VCAppVerifierTool"
/> />
<Tool <Tool
Name="VCWebDeploymentTool" Name="VCWebDeploymentTool"
/> />
<Tool <Tool
Name="VCPostBuildEventTool" Name="VCPostBuildEventTool"
/> />
</Configuration> </Configuration>
</Configurations> </Configurations>
<References> <References>
</References> </References>
<Files> <Files>
<Filter <Filter
Name="Application" Name="Application"
> >
<Filter <Filter
Name="Header Files" Name="Header Files"
> >
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="_Suite" Name="_Suite"
> >
<Filter <Filter
Name="Header Files" Name="Header Files"
> >
<File <File
RelativePath=".\src\UtilTestSuite.h" RelativePath=".\src\UtilTestSuite.h"
> >
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
<File <File
RelativePath=".\src\UtilTestSuite.cpp" RelativePath=".\src\UtilTestSuite.cpp"
> >
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="_Driver" Name="_Driver"
> >
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
<File <File
RelativePath=".\src\WinDriver.cpp" RelativePath=".\src\WinDriver.cpp"
> >
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Configuration" Name="Configuration"
> >
<Filter <Filter
Name="Header Files" Name="Header Files"
> >
<File <File
RelativePath=".\src\AbstractConfigurationTest.h" RelativePath=".\src\AbstractConfigurationTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\ConfigurationMapperTest.h" RelativePath=".\src\ConfigurationMapperTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\ConfigurationTestSuite.h" RelativePath=".\src\ConfigurationTestSuite.h"
> >
</File> </File>
<File <File
RelativePath=".\src\ConfigurationViewTest.h" RelativePath=".\src\ConfigurationViewTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\FilesystemConfigurationTest.h" RelativePath=".\src\FilesystemConfigurationTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\IniFileConfigurationTest.h" RelativePath=".\src\IniFileConfigurationTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\LayeredConfigurationTest.h" RelativePath=".\src\LayeredConfigurationTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\LoggingConfiguratorTest.h" RelativePath=".\src\LoggingConfiguratorTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\MapConfigurationTest.h" RelativePath=".\src\MapConfigurationTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\PropertyFileConfigurationTest.h" RelativePath=".\src\PropertyFileConfigurationTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\SystemConfigurationTest.h" RelativePath=".\src\SystemConfigurationTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\XMLConfigurationTest.h" RelativePath=".\src\XMLConfigurationTest.h"
> >
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
<File <File
RelativePath=".\src\AbstractConfigurationTest.cpp" RelativePath=".\src\AbstractConfigurationTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\ConfigurationMapperTest.cpp" RelativePath=".\src\ConfigurationMapperTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\ConfigurationTestSuite.cpp" RelativePath=".\src\ConfigurationTestSuite.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\ConfigurationViewTest.cpp" RelativePath=".\src\ConfigurationViewTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\FilesystemConfigurationTest.cpp" RelativePath=".\src\FilesystemConfigurationTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\IniFileConfigurationTest.cpp" RelativePath=".\src\IniFileConfigurationTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\LayeredConfigurationTest.cpp" RelativePath=".\src\LayeredConfigurationTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\LoggingConfiguratorTest.cpp" RelativePath=".\src\LoggingConfiguratorTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\MapConfigurationTest.cpp" RelativePath=".\src\MapConfigurationTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\PropertyFileConfigurationTest.cpp" RelativePath=".\src\PropertyFileConfigurationTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\SystemConfigurationTest.cpp" RelativePath=".\src\SystemConfigurationTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\XMLConfigurationTest.cpp" RelativePath=".\src\XMLConfigurationTest.cpp"
> >
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Options" Name="Options"
> >
<Filter <Filter
Name="Header Files" Name="Header Files"
> >
<File <File
RelativePath=".\src\HelpFormatterTest.h" RelativePath=".\src\HelpFormatterTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\OptionProcessorTest.h" RelativePath=".\src\OptionProcessorTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\OptionSetTest.h" RelativePath=".\src\OptionSetTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\OptionsTestSuite.h" RelativePath=".\src\OptionsTestSuite.h"
> >
</File> </File>
<File <File
RelativePath=".\src\OptionTest.h" RelativePath=".\src\OptionTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\ValidatorTest.h" RelativePath=".\src\ValidatorTest.h"
> >
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
<File <File
RelativePath=".\src\HelpFormatterTest.cpp" RelativePath=".\src\HelpFormatterTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\OptionProcessorTest.cpp" RelativePath=".\src\OptionProcessorTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\OptionSetTest.cpp" RelativePath=".\src\OptionSetTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\OptionsTestSuite.cpp" RelativePath=".\src\OptionsTestSuite.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\OptionTest.cpp" RelativePath=".\src\OptionTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\ValidatorTest.cpp" RelativePath=".\src\ValidatorTest.cpp"
> >
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
Name="Windows" Name="Windows"
> >
<Filter <Filter
Name="Header Files" Name="Header Files"
> >
<File <File
RelativePath=".\src\WinConfigurationTest.h" RelativePath=".\src\WinConfigurationTest.h"
> >
</File> </File>
<File <File
RelativePath=".\src\WindowsTestSuite.h" RelativePath=".\src\WindowsTestSuite.h"
> >
</File> </File>
<File <File
RelativePath=".\src\WinRegistryTest.h" RelativePath=".\src\WinRegistryTest.h"
> >
</File> </File>
</Filter> </Filter>
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
<File <File
RelativePath=".\src\WinConfigurationTest.cpp" RelativePath=".\src\WinConfigurationTest.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\WindowsTestSuite.cpp" RelativePath=".\src\WindowsTestSuite.cpp"
> >
</File> </File>
<File <File
RelativePath=".\src\WinRegistryTest.cpp" RelativePath=".\src\WinRegistryTest.cpp"
> >
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>
</VisualStudioProject> </VisualStudioProject>

View File

@@ -1,331 +1,331 @@
// //
// AbstractConfigurationTest.cpp // AbstractConfigurationTest.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/AbstractConfigurationTest.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/AbstractConfigurationTest.cpp#1 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "AbstractConfigurationTest.h" #include "AbstractConfigurationTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Util/MapConfiguration.h" #include "Poco/Util/MapConfiguration.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <algorithm> #include <algorithm>
using Poco::Util::AbstractConfiguration; using Poco::Util::AbstractConfiguration;
using Poco::Util::MapConfiguration; using Poco::Util::MapConfiguration;
using Poco::AutoPtr; using Poco::AutoPtr;
AbstractConfigurationTest::AbstractConfigurationTest(const std::string& name): CppUnit::TestCase(name) AbstractConfigurationTest::AbstractConfigurationTest(const std::string& name): CppUnit::TestCase(name)
{ {
} }
AbstractConfigurationTest::~AbstractConfigurationTest() AbstractConfigurationTest::~AbstractConfigurationTest()
{ {
} }
void AbstractConfigurationTest::testHasProperty() void AbstractConfigurationTest::testHasProperty()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
assert (pConf->hasProperty("prop1")); assert (pConf->hasProperty("prop1"));
assert (pConf->hasProperty("prop2")); assert (pConf->hasProperty("prop2"));
assert (pConf->hasProperty("prop3.string1")); assert (pConf->hasProperty("prop3.string1"));
assert (!pConf->hasProperty("prop3.string3")); assert (!pConf->hasProperty("prop3.string3"));
assert (!pConf->hasProperty("foobar")); assert (!pConf->hasProperty("foobar"));
} }
void AbstractConfigurationTest::testGetString() void AbstractConfigurationTest::testGetString()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
assert (pConf->getString("prop1") == "foo"); assert (pConf->getString("prop1") == "foo");
assert (pConf->getString("prop2") == "bar"); assert (pConf->getString("prop2") == "bar");
assert (pConf->getString("prop3.string1") == "foo"); assert (pConf->getString("prop3.string1") == "foo");
assert (pConf->getString("prop3.string2") == "bar"); assert (pConf->getString("prop3.string2") == "bar");
assert (pConf->getString("ref1") == "foobar"); assert (pConf->getString("ref1") == "foobar");
assert (pConf->getRawString("ref1") == "${prop3.string1}${prop3.string2}"); assert (pConf->getRawString("ref1") == "${prop3.string1}${prop3.string2}");
try try
{ {
std::string res = pConf->getString("foo"); std::string res = pConf->getString("foo");
fail("nonexistent property - must throw"); fail("nonexistent property - must throw");
} }
catch (Poco::NotFoundException&) catch (Poco::NotFoundException&)
{ {
} }
assert (pConf->getString("prop1", "FOO") == "foo"); assert (pConf->getString("prop1", "FOO") == "foo");
assert (pConf->getString("prop2", "BAR") == "bar"); assert (pConf->getString("prop2", "BAR") == "bar");
assert (pConf->getString("prop3.string1", "FOO") == "foo"); assert (pConf->getString("prop3.string1", "FOO") == "foo");
assert (pConf->getString("prop3.string2", "BAR") == "bar"); assert (pConf->getString("prop3.string2", "BAR") == "bar");
assert (pConf->getString("prop3.string3", "FOOBAR") == "FOOBAR"); assert (pConf->getString("prop3.string3", "FOOBAR") == "FOOBAR");
} }
void AbstractConfigurationTest::testGetInt() void AbstractConfigurationTest::testGetInt()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
assert (pConf->getInt("prop4.int1") == 42); assert (pConf->getInt("prop4.int1") == 42);
assert (pConf->getInt("prop4.int2") == -42); assert (pConf->getInt("prop4.int2") == -42);
assert (pConf->getInt("prop4.hex") == 0x1f); assert (pConf->getInt("prop4.hex") == 0x1f);
assert (pConf->getInt("ref2") == 42); assert (pConf->getInt("ref2") == 42);
try try
{ {
int x = pConf->getInt("prop1"); int x = pConf->getInt("prop1");
fail("not a number - must throw"); fail("not a number - must throw");
} }
catch (Poco::SyntaxException&) catch (Poco::SyntaxException&)
{ {
} }
assert (pConf->getInt("prop4.int1", 100) == 42); assert (pConf->getInt("prop4.int1", 100) == 42);
assert (pConf->getInt("prop4.int2", 100) == -42); assert (pConf->getInt("prop4.int2", 100) == -42);
assert (pConf->getInt("prop4.int3", 100) == 100); assert (pConf->getInt("prop4.int3", 100) == 100);
} }
void AbstractConfigurationTest::testGetDouble() void AbstractConfigurationTest::testGetDouble()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
assert (pConf->getDouble("prop4.double1") == 1); assert (pConf->getDouble("prop4.double1") == 1);
assert (pConf->getDouble("prop4.double2") == -1.5); assert (pConf->getDouble("prop4.double2") == -1.5);
try try
{ {
double x = pConf->getDouble("prop1"); double x = pConf->getDouble("prop1");
fail("not a number - must throw"); fail("not a number - must throw");
} }
catch (Poco::SyntaxException&) catch (Poco::SyntaxException&)
{ {
} }
assert (pConf->getDouble("prop4.double1", 123.5) == 1); assert (pConf->getDouble("prop4.double1", 123.5) == 1);
assert (pConf->getDouble("prop4.double2", 123.5) == -1.5); assert (pConf->getDouble("prop4.double2", 123.5) == -1.5);
assert (pConf->getDouble("prop4.double3", 123.5) == 123.5); assert (pConf->getDouble("prop4.double3", 123.5) == 123.5);
} }
void AbstractConfigurationTest::testGetBool() void AbstractConfigurationTest::testGetBool()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
assert (pConf->getBool("prop4.bool1")); assert (pConf->getBool("prop4.bool1"));
assert (!pConf->getBool("prop4.bool2")); assert (!pConf->getBool("prop4.bool2"));
assert (pConf->getBool("prop4.bool3")); assert (pConf->getBool("prop4.bool3"));
assert (!pConf->getBool("prop4.bool4")); assert (!pConf->getBool("prop4.bool4"));
assert (pConf->getBool("prop4.bool5")); assert (pConf->getBool("prop4.bool5"));
assert (!pConf->getBool("prop4.bool6")); assert (!pConf->getBool("prop4.bool6"));
assert (pConf->getBool("prop4.bool7")); assert (pConf->getBool("prop4.bool7"));
assert (!pConf->getBool("prop4.bool8")); assert (!pConf->getBool("prop4.bool8"));
try try
{ {
bool x = pConf->getBool("prop1"); bool x = pConf->getBool("prop1");
fail("not a boolean - must throw"); fail("not a boolean - must throw");
} }
catch (Poco::SyntaxException&) catch (Poco::SyntaxException&)
{ {
} }
assert (pConf->getBool("prop4.bool1", false)); assert (pConf->getBool("prop4.bool1", false));
assert (!pConf->getBool("prop4.bool2", true)); assert (!pConf->getBool("prop4.bool2", true));
assert (pConf->getBool("prop4.boolx", true)); assert (pConf->getBool("prop4.boolx", true));
assert (!pConf->getBool("prop4.booly", false)); assert (!pConf->getBool("prop4.booly", false));
} }
void AbstractConfigurationTest::testExpand() void AbstractConfigurationTest::testExpand()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
assert (pConf->getString("ref1") == "foobar"); assert (pConf->getString("ref1") == "foobar");
assert (pConf->getInt("ref2") == 42); assert (pConf->getInt("ref2") == 42);
try try
{ {
std::string s = pConf->getString("ref3"); std::string s = pConf->getString("ref3");
fail("circular reference - must throw"); fail("circular reference - must throw");
} }
catch (Poco::CircularReferenceException&) catch (Poco::CircularReferenceException&)
{ {
} }
assert (pConf->getString("ref5") == "${refx}"); assert (pConf->getString("ref5") == "${refx}");
assert (pConf->getString("ref6") == "${refx}"); assert (pConf->getString("ref6") == "${refx}");
assert (pConf->expand("answer=${prop4.int1}") == "answer=42"); assert (pConf->expand("answer=${prop4.int1}") == "answer=42");
assert (pConf->expand("bool5='${prop4.bool5}'") == "bool5='Yes'"); assert (pConf->expand("bool5='${prop4.bool5}'") == "bool5='Yes'");
assert (pConf->expand("undef='${undef}'") == "undef='${undef}'"); assert (pConf->expand("undef='${undef}'") == "undef='${undef}'");
assert (pConf->expand("deep='${ref1}'") == "deep='foobar'"); assert (pConf->expand("deep='${ref1}'") == "deep='foobar'");
assert (pConf->expand("deep='${ref7}'") == "deep='foobar'"); assert (pConf->expand("deep='${ref7}'") == "deep='foobar'");
} }
void AbstractConfigurationTest::testSetString() void AbstractConfigurationTest::testSetString()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
pConf->setString("set.string1", "foobar"); pConf->setString("set.string1", "foobar");
pConf->setString("set.string2", ""); pConf->setString("set.string2", "");
assert (pConf->getString("set.string1") == "foobar"); assert (pConf->getString("set.string1") == "foobar");
assert (pConf->getString("set.string2") == ""); assert (pConf->getString("set.string2") == "");
} }
void AbstractConfigurationTest::testSetInt() void AbstractConfigurationTest::testSetInt()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
pConf->setInt("set.int1", 42); pConf->setInt("set.int1", 42);
pConf->setInt("set.int2", -100); pConf->setInt("set.int2", -100);
assert (pConf->getInt("set.int1") == 42); assert (pConf->getInt("set.int1") == 42);
assert (pConf->getInt("set.int2") == -100); assert (pConf->getInt("set.int2") == -100);
} }
void AbstractConfigurationTest::testSetDouble() void AbstractConfigurationTest::testSetDouble()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
pConf->setDouble("set.double1", 1.5); pConf->setDouble("set.double1", 1.5);
pConf->setDouble("set.double2", -1.5); pConf->setDouble("set.double2", -1.5);
assert (pConf->getDouble("set.double1") == 1.5); assert (pConf->getDouble("set.double1") == 1.5);
assert (pConf->getDouble("set.double2") == -1.5); assert (pConf->getDouble("set.double2") == -1.5);
} }
void AbstractConfigurationTest::testSetBool() void AbstractConfigurationTest::testSetBool()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
pConf->setBool("set.bool1", true); pConf->setBool("set.bool1", true);
pConf->setBool("set.bool2", false); pConf->setBool("set.bool2", false);
assert (pConf->getBool("set.bool1")); assert (pConf->getBool("set.bool1"));
assert (!pConf->getBool("set.bool2")); assert (!pConf->getBool("set.bool2"));
} }
void AbstractConfigurationTest::testKeys() void AbstractConfigurationTest::testKeys()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
AbstractConfiguration::Keys keys; AbstractConfiguration::Keys keys;
pConf->keys(keys); pConf->keys(keys);
assert (keys.size() == 11); assert (keys.size() == 11);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop3") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop3") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop4") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop4") != keys.end());
assert (std::find(keys.begin(), keys.end(), "ref1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "ref1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "ref2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "ref2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "ref3") != keys.end()); assert (std::find(keys.begin(), keys.end(), "ref3") != keys.end());
assert (std::find(keys.begin(), keys.end(), "ref4") != keys.end()); assert (std::find(keys.begin(), keys.end(), "ref4") != keys.end());
assert (std::find(keys.begin(), keys.end(), "ref5") != keys.end()); assert (std::find(keys.begin(), keys.end(), "ref5") != keys.end());
assert (std::find(keys.begin(), keys.end(), "ref6") != keys.end()); assert (std::find(keys.begin(), keys.end(), "ref6") != keys.end());
assert (std::find(keys.begin(), keys.end(), "ref7") != keys.end()); assert (std::find(keys.begin(), keys.end(), "ref7") != keys.end());
pConf->keys("prop1", keys); pConf->keys("prop1", keys);
assert (keys.empty()); assert (keys.empty());
pConf->keys("prop3", keys); pConf->keys("prop3", keys);
assert (keys.size() == 2); assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "string1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "string1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "string2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "string2") != keys.end());
} }
AbstractConfiguration* AbstractConfigurationTest::createConfiguration() const AbstractConfiguration* AbstractConfigurationTest::createConfiguration() const
{ {
AbstractConfiguration* pConfig = new MapConfiguration; AbstractConfiguration* pConfig = new MapConfiguration;
pConfig->setString("prop1", "foo"); pConfig->setString("prop1", "foo");
pConfig->setString("prop2", "bar"); pConfig->setString("prop2", "bar");
pConfig->setString("prop3.string1", "foo"); pConfig->setString("prop3.string1", "foo");
pConfig->setString("prop3.string2", "bar"); pConfig->setString("prop3.string2", "bar");
pConfig->setString("prop4.int1", "42"); pConfig->setString("prop4.int1", "42");
pConfig->setString("prop4.int2", "-42"); pConfig->setString("prop4.int2", "-42");
pConfig->setString("prop4.hex", "0x1f"); pConfig->setString("prop4.hex", "0x1f");
pConfig->setString("prop4.double1", "1"); pConfig->setString("prop4.double1", "1");
pConfig->setString("prop4.double2", "-1.5"); pConfig->setString("prop4.double2", "-1.5");
pConfig->setString("prop4.bool1", "1"); pConfig->setString("prop4.bool1", "1");
pConfig->setString("prop4.bool2", "0"); pConfig->setString("prop4.bool2", "0");
pConfig->setString("prop4.bool3", "True"); pConfig->setString("prop4.bool3", "True");
pConfig->setString("prop4.bool4", "FALSE"); pConfig->setString("prop4.bool4", "FALSE");
pConfig->setString("prop4.bool5", "Yes"); pConfig->setString("prop4.bool5", "Yes");
pConfig->setString("prop4.bool6", "no"); pConfig->setString("prop4.bool6", "no");
pConfig->setString("prop4.bool7", "ON"); pConfig->setString("prop4.bool7", "ON");
pConfig->setString("prop4.bool8", "Off"); pConfig->setString("prop4.bool8", "Off");
pConfig->setString("ref1", "${prop3.string1}${prop3.string2}"); pConfig->setString("ref1", "${prop3.string1}${prop3.string2}");
pConfig->setString("ref2", "${prop4.int1}"); pConfig->setString("ref2", "${prop4.int1}");
pConfig->setString("ref3", "${ref4}"); pConfig->setString("ref3", "${ref4}");
pConfig->setString("ref4", "${ref3}"); pConfig->setString("ref4", "${ref3}");
pConfig->setString("ref5", "${refx}"); pConfig->setString("ref5", "${refx}");
pConfig->setString("ref6", "${refx"); pConfig->setString("ref6", "${refx");
pConfig->setString("ref7", "${ref1}"); pConfig->setString("ref7", "${ref1}");
return pConfig; return pConfig;
} }
void AbstractConfigurationTest::setUp() void AbstractConfigurationTest::setUp()
{ {
} }
void AbstractConfigurationTest::tearDown() void AbstractConfigurationTest::tearDown()
{ {
} }
CppUnit::Test* AbstractConfigurationTest::suite() CppUnit::Test* AbstractConfigurationTest::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("AbstractConfigurationTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("AbstractConfigurationTest");
CppUnit_addTest(pSuite, AbstractConfigurationTest, testHasProperty); CppUnit_addTest(pSuite, AbstractConfigurationTest, testHasProperty);
CppUnit_addTest(pSuite, AbstractConfigurationTest, testGetString); CppUnit_addTest(pSuite, AbstractConfigurationTest, testGetString);
CppUnit_addTest(pSuite, AbstractConfigurationTest, testGetInt); CppUnit_addTest(pSuite, AbstractConfigurationTest, testGetInt);
CppUnit_addTest(pSuite, AbstractConfigurationTest, testGetDouble); CppUnit_addTest(pSuite, AbstractConfigurationTest, testGetDouble);
CppUnit_addTest(pSuite, AbstractConfigurationTest, testGetBool); CppUnit_addTest(pSuite, AbstractConfigurationTest, testGetBool);
CppUnit_addTest(pSuite, AbstractConfigurationTest, testExpand); CppUnit_addTest(pSuite, AbstractConfigurationTest, testExpand);
CppUnit_addTest(pSuite, AbstractConfigurationTest, testSetString); CppUnit_addTest(pSuite, AbstractConfigurationTest, testSetString);
CppUnit_addTest(pSuite, AbstractConfigurationTest, testSetInt); CppUnit_addTest(pSuite, AbstractConfigurationTest, testSetInt);
CppUnit_addTest(pSuite, AbstractConfigurationTest, testSetDouble); CppUnit_addTest(pSuite, AbstractConfigurationTest, testSetDouble);
CppUnit_addTest(pSuite, AbstractConfigurationTest, testSetBool); CppUnit_addTest(pSuite, AbstractConfigurationTest, testSetBool);
CppUnit_addTest(pSuite, AbstractConfigurationTest, testKeys); CppUnit_addTest(pSuite, AbstractConfigurationTest, testKeys);
return pSuite; return pSuite;
} }

View File

@@ -1,72 +1,72 @@
// //
// AbstractConfigurationTest.h // AbstractConfigurationTest.h
// //
// $Id: //poco/1.2/Util/testsuite/src/AbstractConfigurationTest.h#1 $ // $Id: //poco/1.2/Util/testsuite/src/AbstractConfigurationTest.h#1 $
// //
// Definition of the AbstractConfigurationTest class. // Definition of the AbstractConfigurationTest 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 AbstractConfigurationTest_INCLUDED #ifndef AbstractConfigurationTest_INCLUDED
#define AbstractConfigurationTest_INCLUDED #define AbstractConfigurationTest_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
class AbstractConfigurationTest: public CppUnit::TestCase class AbstractConfigurationTest: public CppUnit::TestCase
{ {
public: public:
AbstractConfigurationTest(const std::string& name); AbstractConfigurationTest(const std::string& name);
~AbstractConfigurationTest(); ~AbstractConfigurationTest();
void testHasProperty(); void testHasProperty();
void testGetString(); void testGetString();
void testGetInt(); void testGetInt();
void testGetDouble(); void testGetDouble();
void testGetBool(); void testGetBool();
void testExpand(); void testExpand();
void testSetString(); void testSetString();
void testSetInt(); void testSetInt();
void testSetDouble(); void testSetDouble();
void testSetBool(); void testSetBool();
void testKeys(); void testKeys();
void setUp(); void setUp();
void tearDown(); void tearDown();
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
Poco::Util::AbstractConfiguration* createConfiguration() const; Poco::Util::AbstractConfiguration* createConfiguration() const;
}; };
#endif // AbstractConfigurationTest_INCLUDED #endif // AbstractConfigurationTest_INCLUDED

View File

@@ -1,207 +1,207 @@
// //
// ConfigurationMapperTest.cpp // ConfigurationMapperTest.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/ConfigurationMapperTest.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/ConfigurationMapperTest.cpp#1 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "ConfigurationMapperTest.h" #include "ConfigurationMapperTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Util/ConfigurationMapper.h" #include "Poco/Util/ConfigurationMapper.h"
#include "Poco/Util/MapConfiguration.h" #include "Poco/Util/MapConfiguration.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <algorithm> #include <algorithm>
using Poco::Util::AbstractConfiguration; using Poco::Util::AbstractConfiguration;
using Poco::Util::ConfigurationMapper; using Poco::Util::ConfigurationMapper;
using Poco::Util::MapConfiguration; using Poco::Util::MapConfiguration;
using Poco::AutoPtr; using Poco::AutoPtr;
ConfigurationMapperTest::ConfigurationMapperTest(const std::string& name): CppUnit::TestCase(name) ConfigurationMapperTest::ConfigurationMapperTest(const std::string& name): CppUnit::TestCase(name)
{ {
} }
ConfigurationMapperTest::~ConfigurationMapperTest() ConfigurationMapperTest::~ConfigurationMapperTest()
{ {
} }
void ConfigurationMapperTest::testMapper1() void ConfigurationMapperTest::testMapper1()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
AutoPtr<AbstractConfiguration> pMapper = new ConfigurationMapper("", "", pConf); AutoPtr<AbstractConfiguration> pMapper = new ConfigurationMapper("", "", pConf);
assert (pMapper->hasProperty("config.value1")); assert (pMapper->hasProperty("config.value1"));
assert (pMapper->hasProperty("config.value2")); assert (pMapper->hasProperty("config.value2"));
AbstractConfiguration::Keys keys; AbstractConfiguration::Keys keys;
pMapper->keys(keys); pMapper->keys(keys);
assert (keys.size() == 1); assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "config") != keys.end()); assert (std::find(keys.begin(), keys.end(), "config") != keys.end());
pMapper->keys("config", keys); pMapper->keys("config", keys);
assert (keys.size() == 3); assert (keys.size() == 3);
assert (std::find(keys.begin(), keys.end(), "value1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "value1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "value2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "value2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "sub") != keys.end()); assert (std::find(keys.begin(), keys.end(), "sub") != keys.end());
assert (pMapper->getString("config.value1") == "v1"); assert (pMapper->getString("config.value1") == "v1");
assert (pMapper->getString("config.sub.value2") == "v4"); assert (pMapper->getString("config.sub.value2") == "v4");
pMapper->setString("config.value3", "v5"); pMapper->setString("config.value3", "v5");
assert (pMapper->getString("config.value3") == "v5"); assert (pMapper->getString("config.value3") == "v5");
assert (pConf->getString("config.value3") == "v5"); assert (pConf->getString("config.value3") == "v5");
} }
void ConfigurationMapperTest::testMapper2() void ConfigurationMapperTest::testMapper2()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
AutoPtr<AbstractConfiguration> pMapper = new ConfigurationMapper("config", "root.conf", pConf); AutoPtr<AbstractConfiguration> pMapper = new ConfigurationMapper("config", "root.conf", pConf);
assert (pMapper->hasProperty("root.conf.value1")); assert (pMapper->hasProperty("root.conf.value1"));
assert (pMapper->hasProperty("root.conf.value2")); assert (pMapper->hasProperty("root.conf.value2"));
AbstractConfiguration::Keys keys; AbstractConfiguration::Keys keys;
pMapper->keys(keys); pMapper->keys(keys);
assert (keys.size() == 1); assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "root") != keys.end()); assert (std::find(keys.begin(), keys.end(), "root") != keys.end());
pMapper->keys("root", keys); pMapper->keys("root", keys);
assert (keys.size() == 1); assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "conf") != keys.end()); assert (std::find(keys.begin(), keys.end(), "conf") != keys.end());
pMapper->keys("root.conf", keys); pMapper->keys("root.conf", keys);
assert (keys.size() == 3); assert (keys.size() == 3);
assert (std::find(keys.begin(), keys.end(), "value1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "value1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "value2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "value2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "sub") != keys.end()); assert (std::find(keys.begin(), keys.end(), "sub") != keys.end());
assert (pMapper->getString("root.conf.value1") == "v1"); assert (pMapper->getString("root.conf.value1") == "v1");
assert (pMapper->getString("root.conf.sub.value2") == "v4"); assert (pMapper->getString("root.conf.sub.value2") == "v4");
pMapper->setString("root.conf.value3", "v5"); pMapper->setString("root.conf.value3", "v5");
assert (pMapper->getString("root.conf.value3") == "v5"); assert (pMapper->getString("root.conf.value3") == "v5");
assert (pConf->getString("config.value3") == "v5"); assert (pConf->getString("config.value3") == "v5");
} }
void ConfigurationMapperTest::testMapper3() void ConfigurationMapperTest::testMapper3()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
AutoPtr<AbstractConfiguration> pMapper = new ConfigurationMapper("", "root", pConf); AutoPtr<AbstractConfiguration> pMapper = new ConfigurationMapper("", "root", pConf);
assert (pMapper->hasProperty("root.config.value1")); assert (pMapper->hasProperty("root.config.value1"));
assert (pMapper->hasProperty("root.config.value2")); assert (pMapper->hasProperty("root.config.value2"));
AbstractConfiguration::Keys keys; AbstractConfiguration::Keys keys;
pMapper->keys(keys); pMapper->keys(keys);
assert (keys.size() == 1); assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "root") != keys.end()); assert (std::find(keys.begin(), keys.end(), "root") != keys.end());
pMapper->keys("root", keys); pMapper->keys("root", keys);
assert (keys.size() == 1); assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "config") != keys.end()); assert (std::find(keys.begin(), keys.end(), "config") != keys.end());
pMapper->keys("root.config", keys); pMapper->keys("root.config", keys);
assert (keys.size() == 3); assert (keys.size() == 3);
assert (std::find(keys.begin(), keys.end(), "value1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "value1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "value2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "value2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "sub") != keys.end()); assert (std::find(keys.begin(), keys.end(), "sub") != keys.end());
assert (pMapper->getString("root.config.value1") == "v1"); assert (pMapper->getString("root.config.value1") == "v1");
assert (pMapper->getString("root.config.sub.value2") == "v4"); assert (pMapper->getString("root.config.sub.value2") == "v4");
pMapper->setString("root.config.value3", "v5"); pMapper->setString("root.config.value3", "v5");
assert (pMapper->getString("root.config.value3") == "v5"); assert (pMapper->getString("root.config.value3") == "v5");
assert (pConf->getString("config.value3") == "v5"); assert (pConf->getString("config.value3") == "v5");
} }
void ConfigurationMapperTest::testMapper4() void ConfigurationMapperTest::testMapper4()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
AutoPtr<AbstractConfiguration> pMapper = new ConfigurationMapper("config", "", pConf); AutoPtr<AbstractConfiguration> pMapper = new ConfigurationMapper("config", "", pConf);
assert (pMapper->hasProperty("value1")); assert (pMapper->hasProperty("value1"));
assert (pMapper->hasProperty("value2")); assert (pMapper->hasProperty("value2"));
AbstractConfiguration::Keys keys; AbstractConfiguration::Keys keys;
pMapper->keys(keys); pMapper->keys(keys);
assert (keys.size() == 3); assert (keys.size() == 3);
assert (std::find(keys.begin(), keys.end(), "value1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "value1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "value2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "value2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "sub") != keys.end()); assert (std::find(keys.begin(), keys.end(), "sub") != keys.end());
assert (pMapper->getString("value1") == "v1"); assert (pMapper->getString("value1") == "v1");
assert (pMapper->getString("sub.value2") == "v4"); assert (pMapper->getString("sub.value2") == "v4");
pMapper->setString("value3", "v5"); pMapper->setString("value3", "v5");
assert (pMapper->getString("value3") == "v5"); assert (pMapper->getString("value3") == "v5");
assert (pConf->getString("config.value3") == "v5"); assert (pConf->getString("config.value3") == "v5");
} }
AbstractConfiguration* ConfigurationMapperTest::createConfiguration() const AbstractConfiguration* ConfigurationMapperTest::createConfiguration() const
{ {
AbstractConfiguration* pConfig = new MapConfiguration; AbstractConfiguration* pConfig = new MapConfiguration;
pConfig->setString("config.value1", "v1"); pConfig->setString("config.value1", "v1");
pConfig->setString("config.value2", "v2"); pConfig->setString("config.value2", "v2");
pConfig->setString("config.sub.value1", "v3"); pConfig->setString("config.sub.value1", "v3");
pConfig->setString("config.sub.value2", "v4"); pConfig->setString("config.sub.value2", "v4");
return pConfig; return pConfig;
} }
void ConfigurationMapperTest::setUp() void ConfigurationMapperTest::setUp()
{ {
} }
void ConfigurationMapperTest::tearDown() void ConfigurationMapperTest::tearDown()
{ {
} }
CppUnit::Test* ConfigurationMapperTest::suite() CppUnit::Test* ConfigurationMapperTest::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ConfigurationMapperTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ConfigurationMapperTest");
CppUnit_addTest(pSuite, ConfigurationMapperTest, testMapper1); CppUnit_addTest(pSuite, ConfigurationMapperTest, testMapper1);
CppUnit_addTest(pSuite, ConfigurationMapperTest, testMapper2); CppUnit_addTest(pSuite, ConfigurationMapperTest, testMapper2);
CppUnit_addTest(pSuite, ConfigurationMapperTest, testMapper3); CppUnit_addTest(pSuite, ConfigurationMapperTest, testMapper3);
CppUnit_addTest(pSuite, ConfigurationMapperTest, testMapper4); CppUnit_addTest(pSuite, ConfigurationMapperTest, testMapper4);
return pSuite; return pSuite;
} }

View File

@@ -1,65 +1,65 @@
// //
// ConfigurationMapperTest.h // ConfigurationMapperTest.h
// //
// $Id: //poco/1.2/Util/testsuite/src/ConfigurationMapperTest.h#1 $ // $Id: //poco/1.2/Util/testsuite/src/ConfigurationMapperTest.h#1 $
// //
// Definition of the ConfigurationMapperTest class. // Definition of the ConfigurationMapperTest 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 ConfigurationMapperTest_INCLUDED #ifndef ConfigurationMapperTest_INCLUDED
#define ConfigurationMapperTest_INCLUDED #define ConfigurationMapperTest_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
class ConfigurationMapperTest: public CppUnit::TestCase class ConfigurationMapperTest: public CppUnit::TestCase
{ {
public: public:
ConfigurationMapperTest(const std::string& name); ConfigurationMapperTest(const std::string& name);
~ConfigurationMapperTest(); ~ConfigurationMapperTest();
void testMapper1(); void testMapper1();
void testMapper2(); void testMapper2();
void testMapper3(); void testMapper3();
void testMapper4(); void testMapper4();
void setUp(); void setUp();
void tearDown(); void tearDown();
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
Poco::Util::AbstractConfiguration* createConfiguration() const; Poco::Util::AbstractConfiguration* createConfiguration() const;
}; };
#endif // ConfigurationMapperTest_INCLUDED #endif // ConfigurationMapperTest_INCLUDED

View File

@@ -1,64 +1,64 @@
// //
// ConfigurationTestSuite.cpp // ConfigurationTestSuite.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/ConfigurationTestSuite.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/ConfigurationTestSuite.cpp#1 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "ConfigurationTestSuite.h" #include "ConfigurationTestSuite.h"
#include "AbstractConfigurationTest.h" #include "AbstractConfigurationTest.h"
#include "ConfigurationViewTest.h" #include "ConfigurationViewTest.h"
#include "ConfigurationMapperTest.h" #include "ConfigurationMapperTest.h"
#include "MapConfigurationTest.h" #include "MapConfigurationTest.h"
#include "LayeredConfigurationTest.h" #include "LayeredConfigurationTest.h"
#include "SystemConfigurationTest.h" #include "SystemConfigurationTest.h"
#include "IniFileConfigurationTest.h" #include "IniFileConfigurationTest.h"
#include "PropertyFileConfigurationTest.h" #include "PropertyFileConfigurationTest.h"
#include "XMLConfigurationTest.h" #include "XMLConfigurationTest.h"
#include "FilesystemConfigurationTest.h" #include "FilesystemConfigurationTest.h"
#include "LoggingConfiguratorTest.h" #include "LoggingConfiguratorTest.h"
CppUnit::Test* ConfigurationTestSuite::suite() CppUnit::Test* ConfigurationTestSuite::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ConfigurationTestSuite"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ConfigurationTestSuite");
pSuite->addTest(AbstractConfigurationTest::suite()); pSuite->addTest(AbstractConfigurationTest::suite());
pSuite->addTest(ConfigurationViewTest::suite()); pSuite->addTest(ConfigurationViewTest::suite());
pSuite->addTest(ConfigurationMapperTest::suite()); pSuite->addTest(ConfigurationMapperTest::suite());
pSuite->addTest(MapConfigurationTest::suite()); pSuite->addTest(MapConfigurationTest::suite());
pSuite->addTest(LayeredConfigurationTest::suite()); pSuite->addTest(LayeredConfigurationTest::suite());
pSuite->addTest(SystemConfigurationTest::suite()); pSuite->addTest(SystemConfigurationTest::suite());
pSuite->addTest(IniFileConfigurationTest::suite()); pSuite->addTest(IniFileConfigurationTest::suite());
pSuite->addTest(PropertyFileConfigurationTest::suite()); pSuite->addTest(PropertyFileConfigurationTest::suite());
pSuite->addTest(XMLConfigurationTest::suite()); pSuite->addTest(XMLConfigurationTest::suite());
pSuite->addTest(FilesystemConfigurationTest::suite()); pSuite->addTest(FilesystemConfigurationTest::suite());
pSuite->addTest(LoggingConfiguratorTest::suite()); pSuite->addTest(LoggingConfiguratorTest::suite());
return pSuite; return pSuite;
} }

View File

@@ -1,49 +1,49 @@
// //
// ConfigurationTestSuite.h // ConfigurationTestSuite.h
// //
// $Id: //poco/1.2/Util/testsuite/src/ConfigurationTestSuite.h#1 $ // $Id: //poco/1.2/Util/testsuite/src/ConfigurationTestSuite.h#1 $
// //
// Definition of the ConfigurationTestSuite class. // Definition of the ConfigurationTestSuite 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 ConfigurationTestSuite_INCLUDED #ifndef ConfigurationTestSuite_INCLUDED
#define ConfigurationTestSuite_INCLUDED #define ConfigurationTestSuite_INCLUDED
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
class ConfigurationTestSuite class ConfigurationTestSuite
{ {
public: public:
static CppUnit::Test* suite(); static CppUnit::Test* suite();
}; };
#endif // ConfigurationTestSuite_INCLUDED #endif // ConfigurationTestSuite_INCLUDED

View File

@@ -1,155 +1,155 @@
// //
// ConfigurationViewTest.cpp // ConfigurationViewTest.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/ConfigurationViewTest.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/ConfigurationViewTest.cpp#1 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "ConfigurationViewTest.h" #include "ConfigurationViewTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Util/MapConfiguration.h" #include "Poco/Util/MapConfiguration.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <algorithm> #include <algorithm>
using Poco::Util::AbstractConfiguration; using Poco::Util::AbstractConfiguration;
using Poco::Util::MapConfiguration; using Poco::Util::MapConfiguration;
using Poco::AutoPtr; using Poco::AutoPtr;
ConfigurationViewTest::ConfigurationViewTest(const std::string& name): CppUnit::TestCase(name) ConfigurationViewTest::ConfigurationViewTest(const std::string& name): CppUnit::TestCase(name)
{ {
} }
ConfigurationViewTest::~ConfigurationViewTest() ConfigurationViewTest::~ConfigurationViewTest()
{ {
} }
void ConfigurationViewTest::testView() void ConfigurationViewTest::testView()
{ {
AutoPtr<AbstractConfiguration> pConf = createConfiguration(); AutoPtr<AbstractConfiguration> pConf = createConfiguration();
AutoPtr<AbstractConfiguration> pView = pConf->createView(""); AutoPtr<AbstractConfiguration> pView = pConf->createView("");
assert (pView->hasProperty("prop1")); assert (pView->hasProperty("prop1"));
assert (pView->hasProperty("prop2")); assert (pView->hasProperty("prop2"));
AbstractConfiguration::Keys keys; AbstractConfiguration::Keys keys;
pView->keys(keys); pView->keys(keys);
assert (keys.size() == 4); assert (keys.size() == 4);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop3") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop3") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop4") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop4") != keys.end());
assert (pView->getString("prop1") == "foo"); assert (pView->getString("prop1") == "foo");
assert (pView->getString("prop3.string1") == "foo"); assert (pView->getString("prop3.string1") == "foo");
pView->setString("prop5", "foobar"); pView->setString("prop5", "foobar");
assert (pConf->getString("prop5") == "foobar"); assert (pConf->getString("prop5") == "foobar");
pView = pConf->createView("prop1"); pView = pConf->createView("prop1");
pView->keys(keys); pView->keys(keys);
assert (keys.empty()); assert (keys.empty());
assert (pView->hasProperty("prop1")); assert (pView->hasProperty("prop1"));
pView->setString("prop11", "foobar"); pView->setString("prop11", "foobar");
assert (pConf->getString("prop1.prop11") == "foobar"); assert (pConf->getString("prop1.prop11") == "foobar");
pView = pConf->createView("prop3"); pView = pConf->createView("prop3");
pView->keys(keys); pView->keys(keys);
assert (keys.size() == 2); assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "string1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "string1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "string2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "string2") != keys.end());
assert (pView->getString("string1") == "foo"); assert (pView->getString("string1") == "foo");
assert (pView->getString("string2") == "bar"); assert (pView->getString("string2") == "bar");
pView->setString("string3", "foobar"); pView->setString("string3", "foobar");
assert (pConf->getString("prop3.string3") == "foobar"); assert (pConf->getString("prop3.string3") == "foobar");
pView = pConf->createView("prop4"); pView = pConf->createView("prop4");
pView->keys(keys); pView->keys(keys);
assert (keys.size() == 2); assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "prop41") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop41") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop42") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop42") != keys.end());
assert (pView->getString("prop41.string1") == "FOO"); assert (pView->getString("prop41.string1") == "FOO");
assert (pView->getString("prop42.string2") == "Bar"); assert (pView->getString("prop42.string2") == "Bar");
pView = pConf->createView("prop4.prop41"); pView = pConf->createView("prop4.prop41");
pView->keys(keys); pView->keys(keys);
assert (keys.size() == 2); assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "string1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "string1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "string2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "string2") != keys.end());
assert (pView->getString("string1") == "FOO"); assert (pView->getString("string1") == "FOO");
assert (pView->getString("string2") == "BAR"); assert (pView->getString("string2") == "BAR");
pView->setString("string3", "foobar"); pView->setString("string3", "foobar");
assert (pConf->getString("prop4.prop41.string3") == "foobar"); assert (pConf->getString("prop4.prop41.string3") == "foobar");
} }
AbstractConfiguration* ConfigurationViewTest::createConfiguration() const AbstractConfiguration* ConfigurationViewTest::createConfiguration() const
{ {
AbstractConfiguration* pConfig = new MapConfiguration; AbstractConfiguration* pConfig = new MapConfiguration;
pConfig->setString("prop1", "foo"); pConfig->setString("prop1", "foo");
pConfig->setString("prop2", "bar"); pConfig->setString("prop2", "bar");
pConfig->setString("prop3.string1", "foo"); pConfig->setString("prop3.string1", "foo");
pConfig->setString("prop3.string2", "bar"); pConfig->setString("prop3.string2", "bar");
pConfig->setString("prop4.prop41.string1", "FOO"); pConfig->setString("prop4.prop41.string1", "FOO");
pConfig->setString("prop4.prop41.string2", "BAR"); pConfig->setString("prop4.prop41.string2", "BAR");
pConfig->setString("prop4.prop42.string1", "Foo"); pConfig->setString("prop4.prop42.string1", "Foo");
pConfig->setString("prop4.prop42.string2", "Bar"); pConfig->setString("prop4.prop42.string2", "Bar");
return pConfig; return pConfig;
} }
void ConfigurationViewTest::setUp() void ConfigurationViewTest::setUp()
{ {
} }
void ConfigurationViewTest::tearDown() void ConfigurationViewTest::tearDown()
{ {
} }
CppUnit::Test* ConfigurationViewTest::suite() CppUnit::Test* ConfigurationViewTest::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ConfigurationViewTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ConfigurationViewTest");
CppUnit_addTest(pSuite, ConfigurationViewTest, testView); CppUnit_addTest(pSuite, ConfigurationViewTest, testView);
return pSuite; return pSuite;
} }

View File

@@ -1,62 +1,62 @@
// //
// ConfigurationViewTest.h // ConfigurationViewTest.h
// //
// $Id: //poco/1.2/Util/testsuite/src/ConfigurationViewTest.h#1 $ // $Id: //poco/1.2/Util/testsuite/src/ConfigurationViewTest.h#1 $
// //
// Definition of the ConfigurationViewTest class. // Definition of the ConfigurationViewTest 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 ConfigurationViewTest_INCLUDED #ifndef ConfigurationViewTest_INCLUDED
#define ConfigurationViewTest_INCLUDED #define ConfigurationViewTest_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
#include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/AbstractConfiguration.h"
class ConfigurationViewTest: public CppUnit::TestCase class ConfigurationViewTest: public CppUnit::TestCase
{ {
public: public:
ConfigurationViewTest(const std::string& name); ConfigurationViewTest(const std::string& name);
~ConfigurationViewTest(); ~ConfigurationViewTest();
void testView(); void testView();
void setUp(); void setUp();
void tearDown(); void tearDown();
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
Poco::Util::AbstractConfiguration* createConfiguration() const; Poco::Util::AbstractConfiguration* createConfiguration() const;
}; };
#endif // ConfigurationViewTest_INCLUDED #endif // ConfigurationViewTest_INCLUDED

View File

@@ -1,39 +1,39 @@
// //
// Driver.cpp // Driver.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/Driver.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/Driver.cpp#1 $
// //
// Console-based test driver for Poco Util. // Console-based test driver for Poco Util.
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "CppUnit/TestRunner.h" #include "CppUnit/TestRunner.h"
#include "UtilTestSuite.h" #include "UtilTestSuite.h"
CppUnitMain(UtilTestSuite) CppUnitMain(UtilTestSuite)

View File

@@ -1,119 +1,119 @@
// //
// FilesystemConfigurationTest.cpp // FilesystemConfigurationTest.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/FilesystemConfigurationTest.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/FilesystemConfigurationTest.cpp#1 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "FilesystemConfigurationTest.h" #include "FilesystemConfigurationTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Util/FilesystemConfiguration.h" #include "Poco/Util/FilesystemConfiguration.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include <algorithm> #include <algorithm>
using Poco::Util::FilesystemConfiguration; using Poco::Util::FilesystemConfiguration;
using Poco::Util::AbstractConfiguration; using Poco::Util::AbstractConfiguration;
using Poco::AutoPtr; using Poco::AutoPtr;
FilesystemConfigurationTest::FilesystemConfigurationTest(const std::string& name): CppUnit::TestCase(name) FilesystemConfigurationTest::FilesystemConfigurationTest(const std::string& name): CppUnit::TestCase(name)
{ {
} }
FilesystemConfigurationTest::~FilesystemConfigurationTest() FilesystemConfigurationTest::~FilesystemConfigurationTest()
{ {
} }
void FilesystemConfigurationTest::testFilesystemConfiguration() void FilesystemConfigurationTest::testFilesystemConfiguration()
{ {
AutoPtr<FilesystemConfiguration> config = new FilesystemConfiguration("TestConfiguration"); AutoPtr<FilesystemConfiguration> config = new FilesystemConfiguration("TestConfiguration");
config->setString("logging.loggers.root.channel.class", "ConsoleChannel"); config->setString("logging.loggers.root.channel.class", "ConsoleChannel");
config->setString("logging.loggers.app.name", "Application"); config->setString("logging.loggers.app.name", "Application");
config->setString("logging.loggers.app.channel", "c1"); config->setString("logging.loggers.app.channel", "c1");
config->setString("logging.formatters.f1.class", "PatternFormatter"); config->setString("logging.formatters.f1.class", "PatternFormatter");
config->setString("logging.formatters.f1.pattern", "[%p] %t"); config->setString("logging.formatters.f1.pattern", "[%p] %t");
config->setString("logging.channels.c1.class", "ConsoleChannel"); config->setString("logging.channels.c1.class", "ConsoleChannel");
assert (config->getString("logging.loggers.root.channel.class") == "ConsoleChannel"); assert (config->getString("logging.loggers.root.channel.class") == "ConsoleChannel");
assert (config->getString("logging.loggers.app.name") == "Application"); assert (config->getString("logging.loggers.app.name") == "Application");
assert (config->getString("logging.loggers.app.channel") == "c1"); assert (config->getString("logging.loggers.app.channel") == "c1");
assert (config->getString("logging.formatters.f1.class") == "PatternFormatter"); assert (config->getString("logging.formatters.f1.class") == "PatternFormatter");
assert (config->getString("logging.formatters.f1.pattern") == "[%p] %t"); assert (config->getString("logging.formatters.f1.pattern") == "[%p] %t");
config->setString("logging.loggers.app.channel", "c2"); config->setString("logging.loggers.app.channel", "c2");
assert (config->getString("logging.loggers.app.channel") == "c2"); assert (config->getString("logging.loggers.app.channel") == "c2");
AbstractConfiguration::Keys keys; AbstractConfiguration::Keys keys;
config->keys(keys); config->keys(keys);
assert (keys.size() == 1); assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "logging") != keys.end()); assert (std::find(keys.begin(), keys.end(), "logging") != keys.end());
config->keys("logging", keys); config->keys("logging", keys);
assert (keys.size() == 3); assert (keys.size() == 3);
assert (std::find(keys.begin(), keys.end(), "loggers") != keys.end()); assert (std::find(keys.begin(), keys.end(), "loggers") != keys.end());
assert (std::find(keys.begin(), keys.end(), "formatters") != keys.end()); assert (std::find(keys.begin(), keys.end(), "formatters") != keys.end());
assert (std::find(keys.begin(), keys.end(), "channels") != keys.end()); assert (std::find(keys.begin(), keys.end(), "channels") != keys.end());
config->keys("logging.formatters", keys); config->keys("logging.formatters", keys);
assert (keys.size() == 1); assert (keys.size() == 1);
assert (std::find(keys.begin(), keys.end(), "f1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "f1") != keys.end());
config->keys("logging.formatters.f1", keys); config->keys("logging.formatters.f1", keys);
assert (keys.size() == 2); assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "class") != keys.end()); assert (std::find(keys.begin(), keys.end(), "class") != keys.end());
assert (std::find(keys.begin(), keys.end(), "pattern") != keys.end()); assert (std::find(keys.begin(), keys.end(), "pattern") != keys.end());
assert (config->hasProperty("logging.loggers.root.channel.class")); assert (config->hasProperty("logging.loggers.root.channel.class"));
config->clear(); config->clear();
assert (!config->hasProperty("logging.loggers.root.channel.class")); assert (!config->hasProperty("logging.loggers.root.channel.class"));
} }
void FilesystemConfigurationTest::setUp() void FilesystemConfigurationTest::setUp()
{ {
} }
void FilesystemConfigurationTest::tearDown() void FilesystemConfigurationTest::tearDown()
{ {
} }
CppUnit::Test* FilesystemConfigurationTest::suite() CppUnit::Test* FilesystemConfigurationTest::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("FilesystemConfigurationTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("FilesystemConfigurationTest");
CppUnit_addTest(pSuite, FilesystemConfigurationTest, testFilesystemConfiguration); CppUnit_addTest(pSuite, FilesystemConfigurationTest, testFilesystemConfiguration);
return pSuite; return pSuite;
} }

View File

@@ -1,60 +1,60 @@
// //
// FilesystemConfigurationTest.h // FilesystemConfigurationTest.h
// //
// $Id: //poco/1.2/Util/testsuite/src/FilesystemConfigurationTest.h#1 $ // $Id: //poco/1.2/Util/testsuite/src/FilesystemConfigurationTest.h#1 $
// //
// Definition of the FilesystemConfigurationTest class. // Definition of the FilesystemConfigurationTest 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 FilesystemConfigurationTest_INCLUDED #ifndef FilesystemConfigurationTest_INCLUDED
#define FilesystemConfigurationTest_INCLUDED #define FilesystemConfigurationTest_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
class FilesystemConfigurationTest: public CppUnit::TestCase class FilesystemConfigurationTest: public CppUnit::TestCase
{ {
public: public:
FilesystemConfigurationTest(const std::string& name); FilesystemConfigurationTest(const std::string& name);
~FilesystemConfigurationTest(); ~FilesystemConfigurationTest();
void testFilesystemConfiguration(); void testFilesystemConfiguration();
void setUp(); void setUp();
void tearDown(); void tearDown();
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
}; };
#endif // FilesystemConfigurationTest_INCLUDED #endif // FilesystemConfigurationTest_INCLUDED

View File

@@ -1,131 +1,131 @@
// //
// HelpFormatterTest.cpp // HelpFormatterTest.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/HelpFormatterTest.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/HelpFormatterTest.cpp#1 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "HelpFormatterTest.h" #include "HelpFormatterTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Util/Option.h" #include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h" #include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h" #include "Poco/Util/HelpFormatter.h"
#include <iostream> #include <iostream>
using Poco::Util::Option; using Poco::Util::Option;
using Poco::Util::OptionSet; using Poco::Util::OptionSet;
using Poco::Util::HelpFormatter; using Poco::Util::HelpFormatter;
HelpFormatterTest::HelpFormatterTest(const std::string& name): CppUnit::TestCase(name) HelpFormatterTest::HelpFormatterTest(const std::string& name): CppUnit::TestCase(name)
{ {
} }
HelpFormatterTest::~HelpFormatterTest() HelpFormatterTest::~HelpFormatterTest()
{ {
} }
void HelpFormatterTest::testHelpFormatter() void HelpFormatterTest::testHelpFormatter()
{ {
OptionSet set; OptionSet set;
set.addOption( set.addOption(
Option("include-dir", "I", "specify a search path for locating header files") Option("include-dir", "I", "specify a search path for locating header files")
.required(false) .required(false)
.repeatable(true) .repeatable(true)
.argument("path")); .argument("path"));
set.addOption( set.addOption(
Option("library-dir", "L", "specify a search path for locating library files") Option("library-dir", "L", "specify a search path for locating library files")
.required(false) .required(false)
.repeatable(true) .repeatable(true)
.argument("path")); .argument("path"));
set.addOption( set.addOption(
Option("output", "o", "specify the output file", true) Option("output", "o", "specify the output file", true)
.argument("file", true)); .argument("file", true));
set.addOption( set.addOption(
Option("verbose", "v") Option("verbose", "v")
.description("enable verbose mode") .description("enable verbose mode")
.required(false) .required(false)
.repeatable(false)); .repeatable(false));
set.addOption( set.addOption(
Option("optimize", "O") Option("optimize", "O")
.description("enable optimization") .description("enable optimization")
.required(false) .required(false)
.repeatable(false) .repeatable(false)
.argument("level", false)); .argument("level", false));
HelpFormatter formatter(set); HelpFormatter formatter(set);
formatter.format(std::cout); formatter.format(std::cout);
formatter.setCommand("cc"); formatter.setCommand("cc");
formatter.format(std::cout); formatter.format(std::cout);
formatter.setUsage("OPTIONS FILES"); formatter.setUsage("OPTIONS FILES");
formatter.setHeader("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. " formatter.setHeader("Lorem ipsum dolor sit amet, consectetuer adipiscing elit. "
"Vivamus volutpat imperdiet massa. Nulla at ipsum vitae risus facilisis posuere. " "Vivamus volutpat imperdiet massa. Nulla at ipsum vitae risus facilisis posuere. "
"Cras convallis, lacus ac vulputate convallis, metus nisl euismod ligula, " "Cras convallis, lacus ac vulputate convallis, metus nisl euismod ligula, "
"ac euismod diam wisi in dolor.\nMauris vitae leo."); "ac euismod diam wisi in dolor.\nMauris vitae leo.");
formatter.setFooter("Cras semper mollis tellus. Mauris eleifend mauris et lorem. " formatter.setFooter("Cras semper mollis tellus. Mauris eleifend mauris et lorem. "
"Etiam odio dolor, fermentum quis, mollis nec, sodales sed, tellus. " "Etiam odio dolor, fermentum quis, mollis nec, sodales sed, tellus. "
"Quisque consequat orci eu augue. Aliquam ac nibh ac neque hendrerit iaculis."); "Quisque consequat orci eu augue. Aliquam ac nibh ac neque hendrerit iaculis.");
formatter.format(std::cout); formatter.format(std::cout);
formatter.setUnixStyle(false); formatter.setUnixStyle(false);
formatter.format(std::cout); formatter.format(std::cout);
formatter.setHeader(""); formatter.setHeader("");
formatter.setFooter("tab: a\tb\tcde\tf\n\ta\n\t\tb"); formatter.setFooter("tab: a\tb\tcde\tf\n\ta\n\t\tb");
formatter.format(std::cout); formatter.format(std::cout);
} }
void HelpFormatterTest::setUp() void HelpFormatterTest::setUp()
{ {
} }
void HelpFormatterTest::tearDown() void HelpFormatterTest::tearDown()
{ {
} }
CppUnit::Test* HelpFormatterTest::suite() CppUnit::Test* HelpFormatterTest::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("HelpFormatterTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("HelpFormatterTest");
CppUnit_addTest(pSuite, HelpFormatterTest, testHelpFormatter); CppUnit_addTest(pSuite, HelpFormatterTest, testHelpFormatter);
return pSuite; return pSuite;
} }

View File

@@ -1,60 +1,60 @@
// //
// HelpFormatterTest.h // HelpFormatterTest.h
// //
// $Id: //poco/1.2/Util/testsuite/src/HelpFormatterTest.h#1 $ // $Id: //poco/1.2/Util/testsuite/src/HelpFormatterTest.h#1 $
// //
// Definition of the HelpFormatterTest class. // Definition of the HelpFormatterTest 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 HelpFormatterTest_INCLUDED #ifndef HelpFormatterTest_INCLUDED
#define HelpFormatterTest_INCLUDED #define HelpFormatterTest_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
class HelpFormatterTest: public CppUnit::TestCase class HelpFormatterTest: public CppUnit::TestCase
{ {
public: public:
HelpFormatterTest(const std::string& name); HelpFormatterTest(const std::string& name);
~HelpFormatterTest(); ~HelpFormatterTest();
void testHelpFormatter(); void testHelpFormatter();
void setUp(); void setUp();
void tearDown(); void tearDown();
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
}; };
#endif // HelpFormatterTest_INCLUDED #endif // HelpFormatterTest_INCLUDED

View File

@@ -1,138 +1,138 @@
// //
// IniFileConfigurationTest.cpp // IniFileConfigurationTest.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/IniFileConfigurationTest.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/IniFileConfigurationTest.cpp#1 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "IniFileConfigurationTest.h" #include "IniFileConfigurationTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Util/IniFileConfiguration.h" #include "Poco/Util/IniFileConfiguration.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <sstream> #include <sstream>
#include <algorithm> #include <algorithm>
using Poco::Util::IniFileConfiguration; using Poco::Util::IniFileConfiguration;
using Poco::Util::AbstractConfiguration; using Poco::Util::AbstractConfiguration;
using Poco::AutoPtr; using Poco::AutoPtr;
using Poco::NotImplementedException; using Poco::NotImplementedException;
using Poco::NotFoundException; using Poco::NotFoundException;
IniFileConfigurationTest::IniFileConfigurationTest(const std::string& name): CppUnit::TestCase(name) IniFileConfigurationTest::IniFileConfigurationTest(const std::string& name): CppUnit::TestCase(name)
{ {
} }
IniFileConfigurationTest::~IniFileConfigurationTest() IniFileConfigurationTest::~IniFileConfigurationTest()
{ {
} }
void IniFileConfigurationTest::testLoad() void IniFileConfigurationTest::testLoad()
{ {
static const std::string iniFile = static const std::string iniFile =
"; comment\n" "; comment\n"
" ; comment \n" " ; comment \n"
"prop1=value1\n" "prop1=value1\n"
" prop2 = value2 \n" " prop2 = value2 \n"
"[section1]\n" "[section1]\n"
"prop1 = value3\r\n" "prop1 = value3\r\n"
"\tprop2=value4\r\n" "\tprop2=value4\r\n"
";prop3=value7\r\n" ";prop3=value7\r\n"
"\n" "\n"
" [ section 2 ]\n" " [ section 2 ]\n"
"prop1 = value 5\n" "prop1 = value 5\n"
"\t \n" "\t \n"
"Prop2 = value6"; "Prop2 = value6";
std::istringstream istr(iniFile); std::istringstream istr(iniFile);
AutoPtr<IniFileConfiguration> pConf = new IniFileConfiguration(istr); AutoPtr<IniFileConfiguration> pConf = new IniFileConfiguration(istr);
assert (pConf->getString("prop1") == "value1"); assert (pConf->getString("prop1") == "value1");
assert (pConf->getString("prop2") == "value2"); assert (pConf->getString("prop2") == "value2");
assert (pConf->getString("section1.prop1") == "value3"); assert (pConf->getString("section1.prop1") == "value3");
assert (pConf->getString("Section1.Prop2") == "value4"); assert (pConf->getString("Section1.Prop2") == "value4");
assert (pConf->getString("section 2.prop1") == "value 5"); assert (pConf->getString("section 2.prop1") == "value 5");
assert (pConf->getString("section 2.prop2") == "value6"); assert (pConf->getString("section 2.prop2") == "value6");
assert (pConf->getString("SECTION 2.PROP2") == "value6"); assert (pConf->getString("SECTION 2.PROP2") == "value6");
AbstractConfiguration::Keys keys; AbstractConfiguration::Keys keys;
pConf->keys(keys); pConf->keys(keys);
assert (keys.size() == 4); assert (keys.size() == 4);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "section1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "section1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "section 2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "section 2") != keys.end());
pConf->keys("Section1", keys); pConf->keys("Section1", keys);
assert (keys.size() == 2); assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
try try
{ {
pConf->setString("foo", "bar"); pConf->setString("foo", "bar");
fail("Not supported - must throw"); fail("Not supported - must throw");
} }
catch (NotImplementedException&) catch (NotImplementedException&)
{ {
} }
try try
{ {
std::string s = pConf->getString("foo"); std::string s = pConf->getString("foo");
fail("No property - must throw"); fail("No property - must throw");
} }
catch (NotFoundException&) catch (NotFoundException&)
{ {
} }
} }
void IniFileConfigurationTest::setUp() void IniFileConfigurationTest::setUp()
{ {
} }
void IniFileConfigurationTest::tearDown() void IniFileConfigurationTest::tearDown()
{ {
} }
CppUnit::Test* IniFileConfigurationTest::suite() CppUnit::Test* IniFileConfigurationTest::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("IniFileConfigurationTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("IniFileConfigurationTest");
CppUnit_addTest(pSuite, IniFileConfigurationTest, testLoad); CppUnit_addTest(pSuite, IniFileConfigurationTest, testLoad);
return pSuite; return pSuite;
} }

View File

@@ -1,60 +1,60 @@
// //
// IniFileConfigurationTest.h // IniFileConfigurationTest.h
// //
// $Id: //poco/1.2/Util/testsuite/src/IniFileConfigurationTest.h#1 $ // $Id: //poco/1.2/Util/testsuite/src/IniFileConfigurationTest.h#1 $
// //
// Definition of the IniFileConfigurationTest class. // Definition of the IniFileConfigurationTest 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 IniFileConfigurationTest_INCLUDED #ifndef IniFileConfigurationTest_INCLUDED
#define IniFileConfigurationTest_INCLUDED #define IniFileConfigurationTest_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
class IniFileConfigurationTest: public CppUnit::TestCase class IniFileConfigurationTest: public CppUnit::TestCase
{ {
public: public:
IniFileConfigurationTest(const std::string& name); IniFileConfigurationTest(const std::string& name);
~IniFileConfigurationTest(); ~IniFileConfigurationTest();
void testLoad(); void testLoad();
void setUp(); void setUp();
void tearDown(); void tearDown();
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
}; };
#endif // IniFileConfigurationTest_INCLUDED #endif // IniFileConfigurationTest_INCLUDED

View File

@@ -1,170 +1,170 @@
// //
// LayeredConfigurationTest.cpp // LayeredConfigurationTest.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/LayeredConfigurationTest.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/LayeredConfigurationTest.cpp#1 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "LayeredConfigurationTest.h" #include "LayeredConfigurationTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Util/LayeredConfiguration.h" #include "Poco/Util/LayeredConfiguration.h"
#include "Poco/Util/MapConfiguration.h" #include "Poco/Util/MapConfiguration.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <algorithm> #include <algorithm>
using Poco::Util::AbstractConfiguration; using Poco::Util::AbstractConfiguration;
using Poco::Util::LayeredConfiguration; using Poco::Util::LayeredConfiguration;
using Poco::Util::MapConfiguration; using Poco::Util::MapConfiguration;
using Poco::AutoPtr; using Poco::AutoPtr;
using Poco::NotFoundException; using Poco::NotFoundException;
using Poco::RuntimeException; using Poco::RuntimeException;
LayeredConfigurationTest::LayeredConfigurationTest(const std::string& name): CppUnit::TestCase(name) LayeredConfigurationTest::LayeredConfigurationTest(const std::string& name): CppUnit::TestCase(name)
{ {
} }
LayeredConfigurationTest::~LayeredConfigurationTest() LayeredConfigurationTest::~LayeredConfigurationTest()
{ {
} }
void LayeredConfigurationTest::testEmpty() void LayeredConfigurationTest::testEmpty()
{ {
AutoPtr<LayeredConfiguration> pLC = new LayeredConfiguration; AutoPtr<LayeredConfiguration> pLC = new LayeredConfiguration;
AbstractConfiguration::Keys keys; AbstractConfiguration::Keys keys;
pLC->keys(keys); pLC->keys(keys);
assert (keys.empty()); assert (keys.empty());
assert (!pLC->hasProperty("foo")); assert (!pLC->hasProperty("foo"));
try try
{ {
pLC->setString("foo", "bar"); pLC->setString("foo", "bar");
fail("empty LayeredConfiguration - must throw"); fail("empty LayeredConfiguration - must throw");
} }
catch (RuntimeException&) catch (RuntimeException&)
{ {
} }
try try
{ {
std::string s = pLC->getString("foo"); std::string s = pLC->getString("foo");
fail("empty LayeredConfiguration - must throw"); fail("empty LayeredConfiguration - must throw");
} }
catch (NotFoundException&) catch (NotFoundException&)
{ {
} }
} }
void LayeredConfigurationTest::testOneLayer() void LayeredConfigurationTest::testOneLayer()
{ {
AutoPtr<LayeredConfiguration> pLC = new LayeredConfiguration; AutoPtr<LayeredConfiguration> pLC = new LayeredConfiguration;
AutoPtr<MapConfiguration> pMC = new MapConfiguration; AutoPtr<MapConfiguration> pMC = new MapConfiguration;
pMC->setString("prop1", "value1"); pMC->setString("prop1", "value1");
pMC->setString("prop2", "value2"); pMC->setString("prop2", "value2");
pLC->add(pMC); pLC->add(pMC);
AbstractConfiguration::Keys keys; AbstractConfiguration::Keys keys;
pLC->keys(keys); pLC->keys(keys);
assert (keys.size() == 2); assert (keys.size() == 2);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (pLC->getString("prop1") == "value1"); assert (pLC->getString("prop1") == "value1");
assert (pLC->getString("prop2") == "value2"); assert (pLC->getString("prop2") == "value2");
pLC->setString("prop3", "value3"); pLC->setString("prop3", "value3");
assert (pLC->getString("prop3") == "value3"); assert (pLC->getString("prop3") == "value3");
} }
void LayeredConfigurationTest::testTwoLayers() void LayeredConfigurationTest::testTwoLayers()
{ {
AutoPtr<LayeredConfiguration> pLC = new LayeredConfiguration; AutoPtr<LayeredConfiguration> pLC = new LayeredConfiguration;
AutoPtr<MapConfiguration> pMC1 = new MapConfiguration; AutoPtr<MapConfiguration> pMC1 = new MapConfiguration;
AutoPtr<MapConfiguration> pMC2 = new MapConfiguration; AutoPtr<MapConfiguration> pMC2 = new MapConfiguration;
pMC1->setString("prop1", "value1"); pMC1->setString("prop1", "value1");
pMC1->setString("prop2", "value2"); pMC1->setString("prop2", "value2");
pMC2->setString("prop2", "value3"); pMC2->setString("prop2", "value3");
pMC2->setString("prop3", "value4"); pMC2->setString("prop3", "value4");
pLC->add(pMC1); pLC->add(pMC1);
pLC->add(pMC2); pLC->add(pMC2);
AbstractConfiguration::Keys keys; AbstractConfiguration::Keys keys;
pLC->keys(keys); pLC->keys(keys);
assert (keys.size() == 3); assert (keys.size() == 3);
assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop1") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop2") != keys.end());
assert (std::find(keys.begin(), keys.end(), "prop3") != keys.end()); assert (std::find(keys.begin(), keys.end(), "prop3") != keys.end());
assert (pLC->getString("prop1") == "value1"); assert (pLC->getString("prop1") == "value1");
assert (pLC->getString("prop2") == "value2"); assert (pLC->getString("prop2") == "value2");
assert (pLC->getString("prop3") == "value4"); assert (pLC->getString("prop3") == "value4");
pLC->setString("prop4", "value4"); pLC->setString("prop4", "value4");
assert (pLC->getString("prop4") == "value4"); assert (pLC->getString("prop4") == "value4");
assert (!pMC1->hasProperty("prop4")); assert (!pMC1->hasProperty("prop4"));
assert (pMC2->hasProperty("prop4")); assert (pMC2->hasProperty("prop4"));
pLC->setString("prop1", "value11"); pLC->setString("prop1", "value11");
assert (pLC->getString("prop1") == "value1"); assert (pLC->getString("prop1") == "value1");
assert (pMC2->getString("prop1") == "value11"); assert (pMC2->getString("prop1") == "value11");
} }
void LayeredConfigurationTest::setUp() void LayeredConfigurationTest::setUp()
{ {
} }
void LayeredConfigurationTest::tearDown() void LayeredConfigurationTest::tearDown()
{ {
} }
CppUnit::Test* LayeredConfigurationTest::suite() CppUnit::Test* LayeredConfigurationTest::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("LayeredConfigurationTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("LayeredConfigurationTest");
CppUnit_addTest(pSuite, LayeredConfigurationTest, testEmpty); CppUnit_addTest(pSuite, LayeredConfigurationTest, testEmpty);
CppUnit_addTest(pSuite, LayeredConfigurationTest, testOneLayer); CppUnit_addTest(pSuite, LayeredConfigurationTest, testOneLayer);
CppUnit_addTest(pSuite, LayeredConfigurationTest, testTwoLayers); CppUnit_addTest(pSuite, LayeredConfigurationTest, testTwoLayers);
return pSuite; return pSuite;
} }

View File

@@ -1,62 +1,62 @@
// //
// LayeredConfigurationTest.h // LayeredConfigurationTest.h
// //
// $Id: //poco/1.2/Util/testsuite/src/LayeredConfigurationTest.h#1 $ // $Id: //poco/1.2/Util/testsuite/src/LayeredConfigurationTest.h#1 $
// //
// Definition of the LayeredConfigurationTest class. // Definition of the LayeredConfigurationTest 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 LayeredConfigurationTest_INCLUDED #ifndef LayeredConfigurationTest_INCLUDED
#define LayeredConfigurationTest_INCLUDED #define LayeredConfigurationTest_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
class LayeredConfigurationTest: public CppUnit::TestCase class LayeredConfigurationTest: public CppUnit::TestCase
{ {
public: public:
LayeredConfigurationTest(const std::string& name); LayeredConfigurationTest(const std::string& name);
~LayeredConfigurationTest(); ~LayeredConfigurationTest();
void testEmpty(); void testEmpty();
void testOneLayer(); void testOneLayer();
void testTwoLayers(); void testTwoLayers();
void setUp(); void setUp();
void tearDown(); void tearDown();
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
}; };
#endif // LayeredConfigurationTest_INCLUDED #endif // LayeredConfigurationTest_INCLUDED

View File

@@ -1,324 +1,324 @@
// //
// LoggingConfiguratorTest.cpp // LoggingConfiguratorTest.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/LoggingConfiguratorTest.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/LoggingConfiguratorTest.cpp#1 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "LoggingConfiguratorTest.h" #include "LoggingConfiguratorTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Util/LoggingConfigurator.h" #include "Poco/Util/LoggingConfigurator.h"
#include "Poco/Util/PropertyFileConfiguration.h" #include "Poco/Util/PropertyFileConfiguration.h"
#include "Poco/LoggingRegistry.h" #include "Poco/LoggingRegistry.h"
#include "Poco/ConsoleChannel.h" #include "Poco/ConsoleChannel.h"
#include "Poco/FileChannel.h" #include "Poco/FileChannel.h"
#include "Poco/SplitterChannel.h" #include "Poco/SplitterChannel.h"
#include "Poco/FormattingChannel.h" #include "Poco/FormattingChannel.h"
#include "Poco/PatternFormatter.h" #include "Poco/PatternFormatter.h"
#include "Poco/Logger.h" #include "Poco/Logger.h"
#include "Poco/Message.h" #include "Poco/Message.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
#include <sstream> #include <sstream>
using Poco::Util::LoggingConfigurator; using Poco::Util::LoggingConfigurator;
using Poco::Util::PropertyFileConfiguration; using Poco::Util::PropertyFileConfiguration;
using Poco::LoggingRegistry; using Poco::LoggingRegistry;
using Poco::Channel; using Poco::Channel;
using Poco::ConsoleChannel; using Poco::ConsoleChannel;
using Poco::FileChannel; using Poco::FileChannel;
using Poco::SplitterChannel; using Poco::SplitterChannel;
using Poco::FormattingChannel; using Poco::FormattingChannel;
using Poco::PatternFormatter; using Poco::PatternFormatter;
using Poco::Logger; using Poco::Logger;
using Poco::Message; using Poco::Message;
using Poco::AutoPtr; using Poco::AutoPtr;
LoggingConfiguratorTest::LoggingConfiguratorTest(const std::string& name): CppUnit::TestCase(name) LoggingConfiguratorTest::LoggingConfiguratorTest(const std::string& name): CppUnit::TestCase(name)
{ {
} }
LoggingConfiguratorTest::~LoggingConfiguratorTest() LoggingConfiguratorTest::~LoggingConfiguratorTest()
{ {
} }
void LoggingConfiguratorTest::testConfigurator() void LoggingConfiguratorTest::testConfigurator()
{ {
static const std::string config = static const std::string config =
"logging.loggers.root.channel = c1\n" "logging.loggers.root.channel = c1\n"
"logging.loggers.root.level = warning\n" "logging.loggers.root.level = warning\n"
"logging.loggers.l1.name = logger1\n" "logging.loggers.l1.name = logger1\n"
"logging.loggers.l1.channel.class = FileChannel\n" "logging.loggers.l1.channel.class = FileChannel\n"
"logging.loggers.l1.channel.pattern = %s: [%p] %t\n" "logging.loggers.l1.channel.pattern = %s: [%p] %t\n"
"logging.loggers.l1.channel.path = logfile.log\n" "logging.loggers.l1.channel.path = logfile.log\n"
"logging.loggers.l1.level = information\n" "logging.loggers.l1.level = information\n"
"logging.loggers.l2.name = logger2\n" "logging.loggers.l2.name = logger2\n"
"logging.loggers.l2.channel.class = SplitterChannel\n" "logging.loggers.l2.channel.class = SplitterChannel\n"
"logging.loggers.l2.channel.channel1 = c2\n" "logging.loggers.l2.channel.channel1 = c2\n"
"logging.loggers.l2.channel.channel2 = c3\n" "logging.loggers.l2.channel.channel2 = c3\n"
"logging.loggers.l2.level = debug\n" "logging.loggers.l2.level = debug\n"
"logging.channels.c1.class = ConsoleChannel\n" "logging.channels.c1.class = ConsoleChannel\n"
"logging.channels.c1.formatter = f1\n" "logging.channels.c1.formatter = f1\n"
"logging.channels.c2.class = FileChannel\n" "logging.channels.c2.class = FileChannel\n"
"logging.channels.c2.path = ${system.tempDir}/sample.log\n" "logging.channels.c2.path = ${system.tempDir}/sample.log\n"
"logging.channels.c2.formatter.class = PatternFormatter\n" "logging.channels.c2.formatter.class = PatternFormatter\n"
"logging.channels.c2.formatter.pattern = %s: {%p} %t\n" "logging.channels.c2.formatter.pattern = %s: {%p} %t\n"
"logging.channels.c3.class = ConsoleChannel\n" "logging.channels.c3.class = ConsoleChannel\n"
"logging.channels.c3.pattern = %s: [%p] %t\n" "logging.channels.c3.pattern = %s: [%p] %t\n"
"logging.formatters.f1.class = PatternFormatter\n" "logging.formatters.f1.class = PatternFormatter\n"
"logging.formatters.f1.pattern = %s-[%p] %t\n" "logging.formatters.f1.pattern = %s-[%p] %t\n"
"logging.formatters.f1.times = UTC\n"; "logging.formatters.f1.times = UTC\n";
std::istringstream istr(config); std::istringstream istr(config);
AutoPtr<PropertyFileConfiguration> pConfig = new PropertyFileConfiguration(istr); AutoPtr<PropertyFileConfiguration> pConfig = new PropertyFileConfiguration(istr);
LoggingConfigurator configurator; LoggingConfigurator configurator;
configurator.configure(pConfig); configurator.configure(pConfig);
Logger& root = Logger::get(""); Logger& root = Logger::get("");
assert (root.getLevel() == Message::PRIO_WARNING); assert (root.getLevel() == Message::PRIO_WARNING);
FormattingChannel* pFC = dynamic_cast<FormattingChannel*>(root.getChannel()); FormattingChannel* pFC = dynamic_cast<FormattingChannel*>(root.getChannel());
assertNotNull (pFC); assertNotNull (pFC);
assertNotNull (dynamic_cast<ConsoleChannel*>(pFC->getChannel())); assertNotNull (dynamic_cast<ConsoleChannel*>(pFC->getChannel()));
assertNotNull (dynamic_cast<PatternFormatter*>(pFC->getFormatter())); assertNotNull (dynamic_cast<PatternFormatter*>(pFC->getFormatter()));
assert (static_cast<PatternFormatter*>(pFC->getFormatter())->getProperty("pattern") == "%s-[%p] %t"); assert (static_cast<PatternFormatter*>(pFC->getFormatter())->getProperty("pattern") == "%s-[%p] %t");
Logger& logger1 = Logger::get("logger1"); Logger& logger1 = Logger::get("logger1");
assert (logger1.getLevel() == Message::PRIO_INFORMATION); assert (logger1.getLevel() == Message::PRIO_INFORMATION);
pFC = dynamic_cast<FormattingChannel*>(logger1.getChannel()); pFC = dynamic_cast<FormattingChannel*>(logger1.getChannel());
assertNotNull (pFC); assertNotNull (pFC);
assertNotNull (dynamic_cast<FileChannel*>(pFC->getChannel())); assertNotNull (dynamic_cast<FileChannel*>(pFC->getChannel()));
assertNotNull (dynamic_cast<PatternFormatter*>(pFC->getFormatter())); assertNotNull (dynamic_cast<PatternFormatter*>(pFC->getFormatter()));
assert (static_cast<PatternFormatter*>(pFC->getFormatter())->getProperty("pattern") == "%s: [%p] %t"); assert (static_cast<PatternFormatter*>(pFC->getFormatter())->getProperty("pattern") == "%s: [%p] %t");
Logger& logger2 = Logger::get("logger2"); Logger& logger2 = Logger::get("logger2");
assert (logger2.getLevel() == Message::PRIO_DEBUG); assert (logger2.getLevel() == Message::PRIO_DEBUG);
assertNotNull (dynamic_cast<SplitterChannel*>(logger2.getChannel())); assertNotNull (dynamic_cast<SplitterChannel*>(logger2.getChannel()));
} }
void LoggingConfiguratorTest::testBadConfiguration1() void LoggingConfiguratorTest::testBadConfiguration1()
{ {
// this is mainly testing for memory leaks in case of // this is mainly testing for memory leaks in case of
// a bad configuration. // a bad configuration.
static const std::string config = static const std::string config =
"logging.loggers.root.channel = c1\n" "logging.loggers.root.channel = c1\n"
"logging.loggers.root.level = warning\n" "logging.loggers.root.level = warning\n"
"logging.loggers.l1.name = logger1\n" "logging.loggers.l1.name = logger1\n"
"logging.loggers.l1.channel.class = FileChannel\n" "logging.loggers.l1.channel.class = FileChannel\n"
"logging.loggers.l1.channel.pattern = %s: [%p] %t\n" "logging.loggers.l1.channel.pattern = %s: [%p] %t\n"
"logging.loggers.l1.channel.path = logfile.log\n" "logging.loggers.l1.channel.path = logfile.log\n"
"logging.loggers.l1.level = information\n" "logging.loggers.l1.level = information\n"
"logging.loggers.l2.name = logger2\n" "logging.loggers.l2.name = logger2\n"
"logging.loggers.l2.channel.class = UnknownChannel\n" "logging.loggers.l2.channel.class = UnknownChannel\n"
"logging.loggers.l2.level = debug\n" "logging.loggers.l2.level = debug\n"
"logging.channels.c1.class = ConsoleChannel\n" "logging.channels.c1.class = ConsoleChannel\n"
"logging.channels.c1.formatter = f1\n" "logging.channels.c1.formatter = f1\n"
"logging.channels.c2.class = FileChannel\n" "logging.channels.c2.class = FileChannel\n"
"logging.channels.c2.path = ${system.tempDir}/sample.log\n" "logging.channels.c2.path = ${system.tempDir}/sample.log\n"
"logging.channels.c2.formatter.class = PatternFormatter\n" "logging.channels.c2.formatter.class = PatternFormatter\n"
"logging.channels.c2.formatter.pattern = %s: {%p} %t\n" "logging.channels.c2.formatter.pattern = %s: {%p} %t\n"
"logging.channels.c3.class = ConsoleChannel\n" "logging.channels.c3.class = ConsoleChannel\n"
"logging.channels.c3.pattern = %s: [%p] %t\n" "logging.channels.c3.pattern = %s: [%p] %t\n"
"logging.formatters.f1.class = PatternFormatter\n" "logging.formatters.f1.class = PatternFormatter\n"
"logging.formatters.f1.pattern = %s-[%p] %t\n" "logging.formatters.f1.pattern = %s-[%p] %t\n"
"logging.formatters.f1.times = UTC\n"; "logging.formatters.f1.times = UTC\n";
std::istringstream istr(config); std::istringstream istr(config);
AutoPtr<PropertyFileConfiguration> pConfig = new PropertyFileConfiguration(istr); AutoPtr<PropertyFileConfiguration> pConfig = new PropertyFileConfiguration(istr);
LoggingConfigurator configurator; LoggingConfigurator configurator;
try try
{ {
configurator.configure(pConfig); configurator.configure(pConfig);
fail("bad configuration - must throw"); fail("bad configuration - must throw");
} }
catch (Poco::Exception&) catch (Poco::Exception&)
{ {
} }
} }
void LoggingConfiguratorTest::testBadConfiguration2() void LoggingConfiguratorTest::testBadConfiguration2()
{ {
// this is mainly testing for memory leaks in case of // this is mainly testing for memory leaks in case of
// a bad configuration. // a bad configuration.
static const std::string config = static const std::string config =
"logging.loggers.root.channel = c1\n" "logging.loggers.root.channel = c1\n"
"logging.loggers.root.level = unknown\n" "logging.loggers.root.level = unknown\n"
"logging.loggers.l1.name = logger1\n" "logging.loggers.l1.name = logger1\n"
"logging.loggers.l1.channel.class = FileChannel\n" "logging.loggers.l1.channel.class = FileChannel\n"
"logging.loggers.l1.channel.pattern = %s: [%p] %t\n" "logging.loggers.l1.channel.pattern = %s: [%p] %t\n"
"logging.loggers.l1.channel.path = logfile.log\n" "logging.loggers.l1.channel.path = logfile.log\n"
"logging.loggers.l1.level = information\n" "logging.loggers.l1.level = information\n"
"logging.loggers.l2.name = logger2\n" "logging.loggers.l2.name = logger2\n"
"logging.loggers.l2.channel.class = SplitterChannel\n" "logging.loggers.l2.channel.class = SplitterChannel\n"
"logging.loggers.l2.level = debug\n" "logging.loggers.l2.level = debug\n"
"logging.channels.c1.class = ConsoleChannel\n" "logging.channels.c1.class = ConsoleChannel\n"
"logging.channels.c1.formatter = f1\n" "logging.channels.c1.formatter = f1\n"
"logging.channels.c2.class = FileChannel\n" "logging.channels.c2.class = FileChannel\n"
"logging.channels.c2.path = ${system.tempDir}/sample.log\n" "logging.channels.c2.path = ${system.tempDir}/sample.log\n"
"logging.channels.c2.formatter.class = PatternFormatter\n" "logging.channels.c2.formatter.class = PatternFormatter\n"
"logging.channels.c2.formatter.pattern = %s: {%p} %t\n" "logging.channels.c2.formatter.pattern = %s: {%p} %t\n"
"logging.channels.c3.class = ConsoleChannel\n" "logging.channels.c3.class = ConsoleChannel\n"
"logging.channels.c3.pattern = %s: [%p] %t\n" "logging.channels.c3.pattern = %s: [%p] %t\n"
"logging.formatters.f1.class = PatternFormatter\n" "logging.formatters.f1.class = PatternFormatter\n"
"logging.formatters.f1.pattern = %s-[%p] %t\n" "logging.formatters.f1.pattern = %s-[%p] %t\n"
"logging.formatters.f1.times = UTC\n"; "logging.formatters.f1.times = UTC\n";
std::istringstream istr(config); std::istringstream istr(config);
AutoPtr<PropertyFileConfiguration> pConfig = new PropertyFileConfiguration(istr); AutoPtr<PropertyFileConfiguration> pConfig = new PropertyFileConfiguration(istr);
LoggingConfigurator configurator; LoggingConfigurator configurator;
try try
{ {
configurator.configure(pConfig); configurator.configure(pConfig);
fail("bad configuration - must throw"); fail("bad configuration - must throw");
} }
catch (Poco::Exception&) catch (Poco::Exception&)
{ {
} }
} }
void LoggingConfiguratorTest::testBadConfiguration3() void LoggingConfiguratorTest::testBadConfiguration3()
{ {
// this is mainly testing for memory leaks in case of // this is mainly testing for memory leaks in case of
// a bad configuration. // a bad configuration.
static const std::string config = static const std::string config =
"logging.loggers.root.channel = c1\n" "logging.loggers.root.channel = c1\n"
"logging.loggers.root.level = warning\n" "logging.loggers.root.level = warning\n"
"logging.loggers.l1.name = logger1\n" "logging.loggers.l1.name = logger1\n"
"logging.loggers.l1.channel.class = FileChannel\n" "logging.loggers.l1.channel.class = FileChannel\n"
"logging.loggers.l1.channel.pattern = %s: [%p] %t\n" "logging.loggers.l1.channel.pattern = %s: [%p] %t\n"
"logging.loggers.l1.channel.path = logfile.log\n" "logging.loggers.l1.channel.path = logfile.log\n"
"logging.loggers.l1.level = information\n" "logging.loggers.l1.level = information\n"
"logging.loggers.l2.name = logger2\n" "logging.loggers.l2.name = logger2\n"
"logging.loggers.l2.channel.class = UnknownChannel\n" "logging.loggers.l2.channel.class = UnknownChannel\n"
"logging.loggers.l2.level = debug\n" "logging.loggers.l2.level = debug\n"
"logging.channels.c1.class = ConsoleChannel\n" "logging.channels.c1.class = ConsoleChannel\n"
"logging.channels.c1.formatter = f1\n" "logging.channels.c1.formatter = f1\n"
"logging.channels.c2.class = FileChannel\n" "logging.channels.c2.class = FileChannel\n"
"logging.channels.c2.path = ${system.tempDir}/sample.log\n" "logging.channels.c2.path = ${system.tempDir}/sample.log\n"
"logging.channels.c2.formatter.class = UnknownFormatter\n" "logging.channels.c2.formatter.class = UnknownFormatter\n"
"logging.channels.c2.formatter.pattern = %s: {%p} %t\n" "logging.channels.c2.formatter.pattern = %s: {%p} %t\n"
"logging.channels.c3.class = ConsoleChannel\n" "logging.channels.c3.class = ConsoleChannel\n"
"logging.channels.c3.pattern = %s: [%p] %t\n" "logging.channels.c3.pattern = %s: [%p] %t\n"
"logging.formatters.f1.class = PatternFormatter\n" "logging.formatters.f1.class = PatternFormatter\n"
"logging.formatters.f1.pattern = %s-[%p] %t\n" "logging.formatters.f1.pattern = %s-[%p] %t\n"
"logging.formatters.f1.times = UTC\n"; "logging.formatters.f1.times = UTC\n";
std::istringstream istr(config); std::istringstream istr(config);
AutoPtr<PropertyFileConfiguration> pConfig = new PropertyFileConfiguration(istr); AutoPtr<PropertyFileConfiguration> pConfig = new PropertyFileConfiguration(istr);
LoggingConfigurator configurator; LoggingConfigurator configurator;
try try
{ {
configurator.configure(pConfig); configurator.configure(pConfig);
fail("bad configuration - must throw"); fail("bad configuration - must throw");
} }
catch (Poco::Exception&) catch (Poco::Exception&)
{ {
} }
} }
void LoggingConfiguratorTest::testBadConfiguration4() void LoggingConfiguratorTest::testBadConfiguration4()
{ {
// this is mainly testing for memory leaks in case of // this is mainly testing for memory leaks in case of
// a bad configuration. // a bad configuration.
static const std::string config = static const std::string config =
"logging.loggers.root.channel = c1\n" "logging.loggers.root.channel = c1\n"
"logging.loggers.root.level = warning\n" "logging.loggers.root.level = warning\n"
"logging.loggers.l1.name = logger1\n" "logging.loggers.l1.name = logger1\n"
"logging.loggers.l1.channel.class = FileChannel\n" "logging.loggers.l1.channel.class = FileChannel\n"
"logging.loggers.l1.channel.pattern = %s: [%p] %t\n" "logging.loggers.l1.channel.pattern = %s: [%p] %t\n"
"logging.loggers.l1.channel.path = logfile.log\n" "logging.loggers.l1.channel.path = logfile.log\n"
"logging.loggers.l1.level = information\n" "logging.loggers.l1.level = information\n"
"logging.loggers.l2.name = logger2\n" "logging.loggers.l2.name = logger2\n"
"logging.loggers.l2.channel.class = UnknownChannel\n" "logging.loggers.l2.channel.class = UnknownChannel\n"
"logging.loggers.l2.level = debug\n" "logging.loggers.l2.level = debug\n"
"logging.channels.c1.class = ConsoleChannel\n" "logging.channels.c1.class = ConsoleChannel\n"
"logging.channels.c1.formatter = f1\n" "logging.channels.c1.formatter = f1\n"
"logging.channels.c2.class = FileChannel\n" "logging.channels.c2.class = FileChannel\n"
"logging.channels.c2.path = ${system.tempDir}/sample.log\n" "logging.channels.c2.path = ${system.tempDir}/sample.log\n"
"logging.channels.c2.formatter.class = PatternFormatter\n" "logging.channels.c2.formatter.class = PatternFormatter\n"
"logging.channels.c2.formatter.pattern = %s: {%p} %t\n" "logging.channels.c2.formatter.pattern = %s: {%p} %t\n"
"logging.channels.c2.formatter.unknown = FOO\n" "logging.channels.c2.formatter.unknown = FOO\n"
"logging.channels.c3.class = ConsoleChannel\n" "logging.channels.c3.class = ConsoleChannel\n"
"logging.channels.c3.pattern = %s: [%p] %t\n" "logging.channels.c3.pattern = %s: [%p] %t\n"
"logging.formatters.f1.class = PatternFormatter\n" "logging.formatters.f1.class = PatternFormatter\n"
"logging.formatters.f1.pattern = %s-[%p] %t\n" "logging.formatters.f1.pattern = %s-[%p] %t\n"
"logging.formatters.f1.times = UTC\n"; "logging.formatters.f1.times = UTC\n";
std::istringstream istr(config); std::istringstream istr(config);
AutoPtr<PropertyFileConfiguration> pConfig = new PropertyFileConfiguration(istr); AutoPtr<PropertyFileConfiguration> pConfig = new PropertyFileConfiguration(istr);
LoggingConfigurator configurator; LoggingConfigurator configurator;
try try
{ {
configurator.configure(pConfig); configurator.configure(pConfig);
fail("bad configuration - must throw"); fail("bad configuration - must throw");
} }
catch (Poco::Exception&) catch (Poco::Exception&)
{ {
} }
} }
void LoggingConfiguratorTest::setUp() void LoggingConfiguratorTest::setUp()
{ {
LoggingRegistry::defaultRegistry().clear(); LoggingRegistry::defaultRegistry().clear();
} }
void LoggingConfiguratorTest::tearDown() void LoggingConfiguratorTest::tearDown()
{ {
} }
CppUnit::Test* LoggingConfiguratorTest::suite() CppUnit::Test* LoggingConfiguratorTest::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("LoggingConfiguratorTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("LoggingConfiguratorTest");
CppUnit_addTest(pSuite, LoggingConfiguratorTest, testConfigurator); CppUnit_addTest(pSuite, LoggingConfiguratorTest, testConfigurator);
CppUnit_addTest(pSuite, LoggingConfiguratorTest, testBadConfiguration1); CppUnit_addTest(pSuite, LoggingConfiguratorTest, testBadConfiguration1);
CppUnit_addTest(pSuite, LoggingConfiguratorTest, testBadConfiguration2); CppUnit_addTest(pSuite, LoggingConfiguratorTest, testBadConfiguration2);
CppUnit_addTest(pSuite, LoggingConfiguratorTest, testBadConfiguration3); CppUnit_addTest(pSuite, LoggingConfiguratorTest, testBadConfiguration3);
CppUnit_addTest(pSuite, LoggingConfiguratorTest, testBadConfiguration4); CppUnit_addTest(pSuite, LoggingConfiguratorTest, testBadConfiguration4);
return pSuite; return pSuite;
} }

View File

@@ -1,64 +1,64 @@
// //
// LoggingConfiguratorTest.h // LoggingConfiguratorTest.h
// //
// $Id: //poco/1.2/Util/testsuite/src/LoggingConfiguratorTest.h#1 $ // $Id: //poco/1.2/Util/testsuite/src/LoggingConfiguratorTest.h#1 $
// //
// Definition of the LoggingConfiguratorTest class. // Definition of the LoggingConfiguratorTest 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 LoggingConfiguratorTest_INCLUDED #ifndef LoggingConfiguratorTest_INCLUDED
#define LoggingConfiguratorTest_INCLUDED #define LoggingConfiguratorTest_INCLUDED
#include "Poco/Util/Util.h" #include "Poco/Util/Util.h"
#include "CppUnit/TestCase.h" #include "CppUnit/TestCase.h"
class LoggingConfiguratorTest: public CppUnit::TestCase class LoggingConfiguratorTest: public CppUnit::TestCase
{ {
public: public:
LoggingConfiguratorTest(const std::string& name); LoggingConfiguratorTest(const std::string& name);
~LoggingConfiguratorTest(); ~LoggingConfiguratorTest();
void testConfigurator(); void testConfigurator();
void testBadConfiguration1(); void testBadConfiguration1();
void testBadConfiguration2(); void testBadConfiguration2();
void testBadConfiguration3(); void testBadConfiguration3();
void testBadConfiguration4(); void testBadConfiguration4();
void setUp(); void setUp();
void tearDown(); void tearDown();
static CppUnit::Test* suite(); static CppUnit::Test* suite();
private: private:
}; };
#endif // LoggingConfiguratorTest_INCLUDED #endif // LoggingConfiguratorTest_INCLUDED

View File

@@ -1,83 +1,83 @@
// //
// MapConfigurationTest.cpp // MapConfigurationTest.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/MapConfigurationTest.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/MapConfigurationTest.cpp#1 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
// //
// Permission is hereby granted, free of charge, to any person or organization // Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by // obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute, // this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the // execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to // Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following: // do so, all subject to the following:
// //
// The copyright notices in the Software and this entire statement, including // The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer, // the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and // must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative // all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by // works are solely in the form of machine-executable object code generated by
// a source language processor. // a source language processor.
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT // FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE // SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, // FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // DEALINGS IN THE SOFTWARE.
// //
#include "MapConfigurationTest.h" #include "MapConfigurationTest.h"
#include "CppUnit/TestCaller.h" #include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h" #include "CppUnit/TestSuite.h"
#include "Poco/Util/MapConfiguration.h" #include "Poco/Util/MapConfiguration.h"
#include "Poco/AutoPtr.h" #include "Poco/AutoPtr.h"
using Poco::Util::MapConfiguration; using Poco::Util::MapConfiguration;
using Poco::AutoPtr; using Poco::AutoPtr;
MapConfigurationTest::MapConfigurationTest(const std::string& name): CppUnit::TestCase(name) MapConfigurationTest::MapConfigurationTest(const std::string& name): CppUnit::TestCase(name)
{ {
} }
MapConfigurationTest::~MapConfigurationTest() MapConfigurationTest::~MapConfigurationTest()
{ {
} }
void MapConfigurationTest::testClear() void MapConfigurationTest::testClear()
{ {
AutoPtr<MapConfiguration> pConf = new MapConfiguration; AutoPtr<MapConfiguration> pConf = new MapConfiguration;
pConf->setString("foo", "bar"); pConf->setString("foo", "bar");
assert (pConf->hasProperty("foo")); assert (pConf->hasProperty("foo"));
pConf->clear(); pConf->clear();
assert (!pConf->hasProperty("foo")); assert (!pConf->hasProperty("foo"));
} }
void MapConfigurationTest::setUp() void MapConfigurationTest::setUp()
{ {
} }
void MapConfigurationTest::tearDown() void MapConfigurationTest::tearDown()
{ {
} }
CppUnit::Test* MapConfigurationTest::suite() CppUnit::Test* MapConfigurationTest::suite()
{ {
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MapConfigurationTest"); CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("MapConfigurationTest");
CppUnit_addTest(pSuite, MapConfigurationTest, testClear); CppUnit_addTest(pSuite, MapConfigurationTest, testClear);
return pSuite; return pSuite;
} }

Some files were not shown because too many files have changed in this diff Show More