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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,235 +1,235 @@
//
// AbstractConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/AbstractConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: AbstractConfiguration
//
// Definition of the AbstractConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_AbstractConfiguration_INCLUDED
#define Util_AbstractConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Mutex.h"
#include "Poco/RefCountedObject.h"
#include <vector>
namespace Poco {
namespace Util {
class Util_API AbstractConfiguration: public Poco::RefCountedObject
/// AbstractConfiguration is an abstract base class for different
/// kinds of configuration data, such as INI files, property files,
/// XML configuration files or the Windows Registry.
///
/// Configuration property keys have a hierarchical format, consisting
/// of names separated by periods. The exact interpretation of key names
/// is up to the actual subclass implementation of AbstractConfiguration.
/// Keys are case sensitive.
///
/// All public methods are synchronized, so the class is safe for multithreaded use.
/// AbstractConfiguration implements reference counting based garbage collection.
///
/// Subclasses must override the getRaw(), setRaw() and enumerate() methods.
{
public:
typedef std::vector<std::string> Keys;
AbstractConfiguration();
/// Creates the AbstractConfiguration.
bool hasProperty(const std::string& key) const;
/// Returns true iff the property with the given key exists.
bool hasOption(const std::string& key) const;
/// Returns true iff the property with the given key exists.
/// Same as hasProperty().
std::string getString(const std::string& key) const;
/// Returns the string value of the property with the given name.
/// Throws a NotFoundException if the key does not exist.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
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,
/// otherwise returns the given default value.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
std::string getRawString(const std::string& key) const;
/// Returns the raw string value of the property with the given name.
/// Throws a NotFoundException if the key does not exist.
/// References to other properties are not expanded.
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,
/// otherwise returns the given default value.
/// References to other properties are not expanded.
int getInt(const std::string& key) const;
/// Returns the int value of the property with the given name.
/// Throws a NotFoundException if the key does not exist.
/// Throws a SyntaxException if the property can not be converted
/// to an int.
/// Numbers starting with 0x are treated as hexadecimal.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
int getInt(const std::string& key, int defaultValue) const;
/// If a property with the given key exists, returns the property's int value,
/// otherwise returns the given default value.
/// Throws a SyntaxException if the property can not be converted
/// to an int.
/// Numbers starting with 0x are treated as hexadecimal.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
double getDouble(const std::string& key) const;
/// Returns the double value of the property with the given name.
/// Throws a NotFoundException if the key does not exist.
/// Throws a SyntaxException if the property can not be converted
/// to a double.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
double getDouble(const std::string& key, double defaultValue) const;
/// If a property with the given key exists, returns the property's double value,
/// otherwise returns the given default value.
/// Throws a SyntaxException if the property can not be converted
/// to an double.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
bool getBool(const std::string& key) const;
/// Returns the double value of the property with the given name.
/// Throws a NotFoundException if the key does not exist.
/// Throws a SyntaxException if the property can not be converted
/// to a double.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
bool getBool(const std::string& key, bool defaultValue) const;
/// If a property with the given key exists, returns the property's bool value,
/// otherwise returns the given default value.
/// Throws a SyntaxException if the property can not be converted
/// to a boolean.
/// The following string values can be converted into a boolean:
/// - numerical values: non zero becomes true, zero becomes false
/// - strings: true, yes, on become true, false, no, off become false
/// Case does not matter.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
void setString(const std::string& key, const std::string& value);
/// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten.
void setInt(const std::string& key, int value);
/// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten.
void setDouble(const std::string& key, double value);
/// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten.
void setBool(const std::string& key, bool value);
/// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten.
void keys(Keys& range) const;
/// Returns in range the names of all keys at root level.
void keys(const std::string& key, Keys& range) const;
/// Returns in range the names of all subkeys under the given key.
/// If an empty key is passed, all root level keys are returned.
const AbstractConfiguration* createView(const std::string& prefix) const;
/// Creates a non-mutable view (see ConfigurationView) into the configuration.
AbstractConfiguration* createView(const std::string& prefix);
/// Creates a view (see ConfigurationView) into the configuration.
std::string expand(const std::string& value) const;
/// Replaces all occurences of ${<property>} in value with the
/// value of the <property>. If <property> does not exist,
/// nothing is changed.
///
/// If a circular property reference is detected, a
/// CircularReferenceException will be thrown.
protected:
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
/// in value and returns true. Otherwise, returns false.
///
/// Must be overridden by subclasses.
virtual void setRaw(const std::string& key, const std::string& value) = 0;
/// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten.
///
/// Must be overridden by subclasses.
virtual void enumerate(const std::string& key, Keys& range) const = 0;
/// Returns in range the names of all subkeys under the given key.
/// If an empty key is passed, all root level keys are returned.
static int parseInt(const std::string& value);
static bool parseBool(const std::string& value);
virtual ~AbstractConfiguration();
private:
std::string internalExpand(const std::string& value) const;
std::string uncheckedExpand(const std::string& value) const;
AbstractConfiguration(const AbstractConfiguration&);
AbstractConfiguration& operator = (const AbstractConfiguration&);
mutable int _depth;
mutable Poco::FastMutex _mutex;
friend class LayeredConfiguration;
friend class ConfigurationView;
friend class ConfigurationMapper;
};
} } // namespace Poco::Util
#endif // Util_AbstractConfiguration_INCLUDED
//
// AbstractConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/AbstractConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: AbstractConfiguration
//
// Definition of the AbstractConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_AbstractConfiguration_INCLUDED
#define Util_AbstractConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Mutex.h"
#include "Poco/RefCountedObject.h"
#include <vector>
namespace Poco {
namespace Util {
class Util_API AbstractConfiguration: public Poco::RefCountedObject
/// AbstractConfiguration is an abstract base class for different
/// kinds of configuration data, such as INI files, property files,
/// XML configuration files or the Windows Registry.
///
/// Configuration property keys have a hierarchical format, consisting
/// of names separated by periods. The exact interpretation of key names
/// is up to the actual subclass implementation of AbstractConfiguration.
/// Keys are case sensitive.
///
/// All public methods are synchronized, so the class is safe for multithreaded use.
/// AbstractConfiguration implements reference counting based garbage collection.
///
/// Subclasses must override the getRaw(), setRaw() and enumerate() methods.
{
public:
typedef std::vector<std::string> Keys;
AbstractConfiguration();
/// Creates the AbstractConfiguration.
bool hasProperty(const std::string& key) const;
/// Returns true iff the property with the given key exists.
bool hasOption(const std::string& key) const;
/// Returns true iff the property with the given key exists.
/// Same as hasProperty().
std::string getString(const std::string& key) const;
/// Returns the string value of the property with the given name.
/// Throws a NotFoundException if the key does not exist.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
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,
/// otherwise returns the given default value.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
std::string getRawString(const std::string& key) const;
/// Returns the raw string value of the property with the given name.
/// Throws a NotFoundException if the key does not exist.
/// References to other properties are not expanded.
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,
/// otherwise returns the given default value.
/// References to other properties are not expanded.
int getInt(const std::string& key) const;
/// Returns the int value of the property with the given name.
/// Throws a NotFoundException if the key does not exist.
/// Throws a SyntaxException if the property can not be converted
/// to an int.
/// Numbers starting with 0x are treated as hexadecimal.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
int getInt(const std::string& key, int defaultValue) const;
/// If a property with the given key exists, returns the property's int value,
/// otherwise returns the given default value.
/// Throws a SyntaxException if the property can not be converted
/// to an int.
/// Numbers starting with 0x are treated as hexadecimal.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
double getDouble(const std::string& key) const;
/// Returns the double value of the property with the given name.
/// Throws a NotFoundException if the key does not exist.
/// Throws a SyntaxException if the property can not be converted
/// to a double.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
double getDouble(const std::string& key, double defaultValue) const;
/// If a property with the given key exists, returns the property's double value,
/// otherwise returns the given default value.
/// Throws a SyntaxException if the property can not be converted
/// to an double.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
bool getBool(const std::string& key) const;
/// Returns the double value of the property with the given name.
/// Throws a NotFoundException if the key does not exist.
/// Throws a SyntaxException if the property can not be converted
/// to a double.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
bool getBool(const std::string& key, bool defaultValue) const;
/// If a property with the given key exists, returns the property's bool value,
/// otherwise returns the given default value.
/// Throws a SyntaxException if the property can not be converted
/// to a boolean.
/// The following string values can be converted into a boolean:
/// - numerical values: non zero becomes true, zero becomes false
/// - strings: true, yes, on become true, false, no, off become false
/// Case does not matter.
/// If the value contains references to other properties (${<property>}), these
/// are expanded.
void setString(const std::string& key, const std::string& value);
/// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten.
void setInt(const std::string& key, int value);
/// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten.
void setDouble(const std::string& key, double value);
/// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten.
void setBool(const std::string& key, bool value);
/// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten.
void keys(Keys& range) const;
/// Returns in range the names of all keys at root level.
void keys(const std::string& key, Keys& range) const;
/// Returns in range the names of all subkeys under the given key.
/// If an empty key is passed, all root level keys are returned.
const AbstractConfiguration* createView(const std::string& prefix) const;
/// Creates a non-mutable view (see ConfigurationView) into the configuration.
AbstractConfiguration* createView(const std::string& prefix);
/// Creates a view (see ConfigurationView) into the configuration.
std::string expand(const std::string& value) const;
/// Replaces all occurences of ${<property>} in value with the
/// value of the <property>. If <property> does not exist,
/// nothing is changed.
///
/// If a circular property reference is detected, a
/// CircularReferenceException will be thrown.
protected:
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
/// in value and returns true. Otherwise, returns false.
///
/// Must be overridden by subclasses.
virtual void setRaw(const std::string& key, const std::string& value) = 0;
/// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten.
///
/// Must be overridden by subclasses.
virtual void enumerate(const std::string& key, Keys& range) const = 0;
/// Returns in range the names of all subkeys under the given key.
/// If an empty key is passed, all root level keys are returned.
static int parseInt(const std::string& value);
static bool parseBool(const std::string& value);
virtual ~AbstractConfiguration();
private:
std::string internalExpand(const std::string& value) const;
std::string uncheckedExpand(const std::string& value) const;
AbstractConfiguration(const AbstractConfiguration&);
AbstractConfiguration& operator = (const AbstractConfiguration&);
mutable int _depth;
mutable Poco::FastMutex _mutex;
friend class LayeredConfiguration;
friend class ConfigurationView;
friend class ConfigurationMapper;
};
} } // namespace Poco::Util
#endif // Util_AbstractConfiguration_INCLUDED

View File

@ -1,452 +1,452 @@
//
// Application.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/Application.h#2 $
//
// Library: Util
// Package: Application
// Module: Application
//
// Definition of the Application class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_Application_INCLUDED
#define Util_Application_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/Subsystem.h"
#include "Poco/Util/LayeredConfiguration.h"
#include "Poco/Util/OptionSet.h"
#include "Poco/AutoPtr.h"
#include "Poco/Logger.h"
#include "Poco/Path.h"
#include "Poco/Timestamp.h"
#include "Poco/Timespan.h"
#include <vector>
namespace Poco {
namespace Util {
class OptionSet;
class Util_API Application: public Subsystem
/// The Application class implements the main subsystem
/// in a process. The application class is responsible for
/// initializing all its subsystems.
///
/// Subclasses can and should override the following virtual methods:
/// - initialize() (the one-argument, protected variant)
/// - uninitialize()
/// - reinitialize()
/// - defineOptions()
/// - handleOption()
/// - main()
///
/// The application's main logic should be implemented in
/// the main() method.
///
/// There may be at most one instance of the Application class
/// in a process.
///
/// The Application class sets a few default properties in
/// its configuration (available via the config() method).
/// These are:
/// - application.path: the absolute path to application executable
/// - application.name: the file name 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.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.
///
/// 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
/// Unicode command line arguments.
{
public:
enum ExitCode
/// Commonly used exit status codes.
/// Based on the definitions in the 4.3BSD <sysexits.h> header file.
{
EXIT_OK = 0, /// successful termination
EXIT_USAGE = 64, /// command line usage error
EXIT_DATAERR = 65, /// data format error
EXIT_NOINPUT = 66, /// cannot open input
EXIT_NOUSER = 67, /// addressee unknown
EXIT_NOHOST = 68, /// host name unknown
EXIT_UNAVAILABLE = 69, /// service unavailable
EXIT_SOFTWARE = 70, /// internal software error
EXIT_OSERR = 71, /// system error (e.g., can't fork)
EXIT_OSFILE = 72, /// critical OS file missing
EXIT_CANTCREAT = 73, /// can't create (user) output file
EXIT_IOERR = 74, /// input/output error
EXIT_TEMPFAIL = 75, /// temp failure; user is invited to retry
EXIT_PROTOCOL = 76, /// remote error in protocol
EXIT_NOPERM = 77, /// permission denied
EXIT_CONFIG = 78 /// configuration error
};
Application();
/// Creates the Application.
Application(int argc, char* argv[]);
/// Creates the Application and calls init(argc, argv).
void addSubsystem(Subsystem* pSubsystem);
/// Adds a new subsystem to the application. The
/// application immediately takes ownership of it, so that a
/// call in the form
/// Application::instance().addSubsystem(new MySubsystem);
/// is okay.
void init(int argc, char* argv[]);
/// Initializes the application and all registered subsystems,
/// using the given command line arguments.
#if defined(POCO_WIN32_UTF8)
void init(int argc, wchar_t* argv[]);
/// Initializes the application and all registered subsystems,
/// using the given command line arguments.
///
/// This Windows-specific version of init is used for passing
/// Unicode command line arguments from wmain().
#endif
void init(const std::vector<std::string>& args);
/// Initializes the application and all registered subsystems,
/// using the given command line arguments.
bool initialized() const;
/// Returns true iff the application is in initialized state
/// (that means, has been initialized but not yet uninitialized).
void setUnixOptions(bool flag);
/// Specify whether command line option handling is Unix-style
/// (flag == true; default) or Windows/OpenVMS-style (flag == false).
int loadConfiguration();
/// Loads configuration information from a default location.
///
/// The configuration file(s) must be located in the same directory
/// 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:
/// .properties, .ini or .xml.
///
/// The .properties file, if it exists, is loaded first, followed
/// by the .ini file and the .xml file.
///
/// If the application is built in debug mode (the _DEBUG preprocessor
/// 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
/// also found.
///
/// Example: Given the application "SampleAppd.exe", built in debug mode.
/// Then loadConfiguration() will automatically find a configuration file
/// named "SampleApp.properties" if it exists and if "SampleAppd.properties"
/// cannot be found.
///
/// Returns the number of configuration files loaded, which may be zero.
///
/// This method must not be called before initialize(argc, argv)
/// has been called.
void loadConfiguration(const std::string& path);
/// Loads configuration information from the file specified by
/// the given path. The file type is determined by the file
/// extension. The following extensions are supported:
/// - .properties - properties file (PropertyFileConfiguration)
/// - .ini - initialization file (IniFileConfiguration)
/// - .xml - XML file (XMLConfiguration)
///
/// Extensions are not case sensitive.
template <class C> C& getSubsystem() const;
/// Returns a reference to the subsystem of the class
/// given as template argument.
///
/// Throws a NotFoundException if such a subsystem has
/// not been registered.
virtual int run();
/// Runs the application by performing additional initializations
/// and calling the main() method.
std::string commandName() const;
/// Returns the command name used to invoke the application.
LayeredConfiguration& config() const;
/// Returns the application's configuration.
Poco::Logger& logger() const;
/// Returns the application's logger.
///
/// Before the logging subsystem has been initialized, the
/// application's logger is "ApplicationStartup", which is
/// connected to a ConsoleChannel.
///
/// After the logging subsystem has been initialized, which
/// usually happens as the first action in Application::initialize(),
/// the application's logger is the one specified by the
/// "application.logger" configuration property. If that property
/// is not specified, the logger is "Application".
const OptionSet& options() const;
/// Returns the application's option set.
static Application& instance();
/// Returns a reference to the Application singleton.
///
/// Throws a NullPointerException if no Application instance exists.
const Poco::Timestamp& startTime() const;
/// Returns the application start time (UTC).
Poco::Timespan uptime() const;
/// Returns the application uptime.
void stopOptionsProcessing();
/// If called from an option callback, stops all further
/// options processing.
///
/// If called, the following options on the command line
/// will not be processed, and required options will not
/// be checked.
///
/// This is useful, for example, if an option for displaying
/// help information has been encountered and no other things
/// besides displaying help shall be done.
const char* name() const;
protected:
void initialize(Application& self);
/// Initializes the application and all registered subsystems.
/// Subsystems are always initialized in the exact same order
/// in which they have been registered.
///
/// Overriding implementations must call the base class implementation.
void uninitialize();
/// Uninitializes the application and all registered subsystems.
/// Subsystems are always uninitialized in reverse order in which
/// they have been initialized.
///
/// Overriding implementations must call the base class implementation.
void reinitialize(Application& self);
/// Re-nitializes the application and all registered subsystems.
/// Subsystems are always reinitialized in the exact same order
/// in which they have been registered.
///
/// Overriding implementations must call the base class implementation.
virtual void defineOptions(OptionSet& options);
/// Called before command line processing begins.
/// If a subclass wants to support command line arguments,
/// it must override this method.
/// The default implementation does not define any options.
///
/// Overriding implementations should call the base class implementation.
virtual void handleOption(const std::string& name, const std::string& value);
/// Called when the option with the given name is encountered
/// during command line arguments processing.
///
/// The default implementation does option validation, bindings
/// and callback handling.
///
/// Overriding implementations must call the base class implementation.
void setLogger(Poco::Logger& logger);
/// Sets the logger used by the application.
virtual int main(const std::vector<std::string>& args);
/// The application's main logic.
///
/// Unprocessed command line arguments are passed in args.
/// Note that all original command line arguments are available
/// via the properties application.argc and application.argv[<n>].
///
/// Returns an exit code which should be one of the values
/// from the ExitCode enumeration.
bool findFile(Poco::Path& path) const;
/// Searches for the file in path in the application directory.
///
/// If path is absolute, the method immediately returns true and
/// leaves path unchanged.
///
/// If path is relative, searches for the file in the application
/// directory and in all subsequent parent directories.
/// Returns true and stores the absolute path to the file in
/// path if the file could be found. Returns false and leaves path
/// unchanged otherwise.
void init();
/// Common initialization code.
~Application();
/// Destroys the Application and deletes all registered subsystems.
private:
void setup();
void setArgs(int argc, char* argv[]);
void setArgs(const std::vector<std::string>& args);
void getApplicationPath(Poco::Path& path) const;
void processOptions();
bool findAppConfigFile(const std::string& appName, const std::string& extension, Poco::Path& path) const;
typedef Poco::AutoPtr<Subsystem> SubsystemPtr;
typedef std::vector<SubsystemPtr> SubsystemVec;
typedef Poco::AutoPtr<LayeredConfiguration> ConfigPtr;
typedef std::vector<std::string> ArgVec;
ConfigPtr _pConfig;
SubsystemVec _subsystems;
bool _initialized;
std::string _command;
ArgVec _args;
OptionSet _options;
bool _unixOptions;
Poco::Logger* _pLogger;
Poco::Timestamp _startTime;
bool _stopOptionsProcessing;
static Application* _pInstance;
friend class LoggingSubsystem;
};
//
// inlines
//
template <class C> C& Application::getSubsystem() const
{
for (SubsystemVec::const_iterator it = _subsystems.begin(); it != _subsystems.end(); ++it)
{
if (dynamic_cast<C*>(*it))
return **it;
}
throw Poco::NotFoundException("The subsystem has not been registered");
}
inline bool Application::initialized() const
{
return _initialized;
}
inline LayeredConfiguration& Application::config() const
{
return *const_cast<LayeredConfiguration*>(_pConfig.get());
}
inline Poco::Logger& Application::logger() const
{
poco_check_ptr (_pLogger);
return *_pLogger;
}
inline const OptionSet& Application::options() const
{
return _options;
}
inline Application& Application::instance()
{
poco_check_ptr (_pInstance);
return *_pInstance;
}
inline const Poco::Timestamp& Application::startTime() const
{
return _startTime;
}
inline Poco::Timespan Application::uptime() const
{
Poco::Timestamp now;
Poco::Timespan uptime = now - _startTime;
return uptime;
}
} } // namespace Poco::Util
//
// Macro to implement main()
//
#if defined(POCO_WIN32_UTF8)
#define POCO_APP_MAIN(App) \
int wmain(int argc, wchar_t** argv) \
{ \
AutoPtr<App> pApp = new App; \
try \
{ \
pApp->init(argc, argv); \
} \
catch (Poco::Exception& exc) \
{ \
pApp->logger().log(exc); \
return Application::EXIT_CONFIG;\
} \
return pApp->run(); \
}
#else
#define POCO_APP_MAIN(App) \
int main(int argc, char** argv) \
{ \
AutoPtr<App> pApp = new App; \
try \
{ \
pApp->init(argc, argv); \
} \
catch (Poco::Exception& exc) \
{ \
pApp->logger().log(exc); \
return Application::EXIT_CONFIG;\
} \
return pApp->run(); \
}
#endif
#endif // Util_Application_INCLUDED
//
// Application.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/Application.h#2 $
//
// Library: Util
// Package: Application
// Module: Application
//
// Definition of the Application class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_Application_INCLUDED
#define Util_Application_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/Subsystem.h"
#include "Poco/Util/LayeredConfiguration.h"
#include "Poco/Util/OptionSet.h"
#include "Poco/AutoPtr.h"
#include "Poco/Logger.h"
#include "Poco/Path.h"
#include "Poco/Timestamp.h"
#include "Poco/Timespan.h"
#include <vector>
namespace Poco {
namespace Util {
class OptionSet;
class Util_API Application: public Subsystem
/// The Application class implements the main subsystem
/// in a process. The application class is responsible for
/// initializing all its subsystems.
///
/// Subclasses can and should override the following virtual methods:
/// - initialize() (the one-argument, protected variant)
/// - uninitialize()
/// - reinitialize()
/// - defineOptions()
/// - handleOption()
/// - main()
///
/// The application's main logic should be implemented in
/// the main() method.
///
/// There may be at most one instance of the Application class
/// in a process.
///
/// The Application class sets a few default properties in
/// its configuration (available via the config() method).
/// These are:
/// - application.path: the absolute path to application executable
/// - application.name: the file name 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.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.
///
/// 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
/// Unicode command line arguments.
{
public:
enum ExitCode
/// Commonly used exit status codes.
/// Based on the definitions in the 4.3BSD <sysexits.h> header file.
{
EXIT_OK = 0, /// successful termination
EXIT_USAGE = 64, /// command line usage error
EXIT_DATAERR = 65, /// data format error
EXIT_NOINPUT = 66, /// cannot open input
EXIT_NOUSER = 67, /// addressee unknown
EXIT_NOHOST = 68, /// host name unknown
EXIT_UNAVAILABLE = 69, /// service unavailable
EXIT_SOFTWARE = 70, /// internal software error
EXIT_OSERR = 71, /// system error (e.g., can't fork)
EXIT_OSFILE = 72, /// critical OS file missing
EXIT_CANTCREAT = 73, /// can't create (user) output file
EXIT_IOERR = 74, /// input/output error
EXIT_TEMPFAIL = 75, /// temp failure; user is invited to retry
EXIT_PROTOCOL = 76, /// remote error in protocol
EXIT_NOPERM = 77, /// permission denied
EXIT_CONFIG = 78 /// configuration error
};
Application();
/// Creates the Application.
Application(int argc, char* argv[]);
/// Creates the Application and calls init(argc, argv).
void addSubsystem(Subsystem* pSubsystem);
/// Adds a new subsystem to the application. The
/// application immediately takes ownership of it, so that a
/// call in the form
/// Application::instance().addSubsystem(new MySubsystem);
/// is okay.
void init(int argc, char* argv[]);
/// Initializes the application and all registered subsystems,
/// using the given command line arguments.
#if defined(POCO_WIN32_UTF8)
void init(int argc, wchar_t* argv[]);
/// Initializes the application and all registered subsystems,
/// using the given command line arguments.
///
/// This Windows-specific version of init is used for passing
/// Unicode command line arguments from wmain().
#endif
void init(const std::vector<std::string>& args);
/// Initializes the application and all registered subsystems,
/// using the given command line arguments.
bool initialized() const;
/// Returns true iff the application is in initialized state
/// (that means, has been initialized but not yet uninitialized).
void setUnixOptions(bool flag);
/// Specify whether command line option handling is Unix-style
/// (flag == true; default) or Windows/OpenVMS-style (flag == false).
int loadConfiguration();
/// Loads configuration information from a default location.
///
/// The configuration file(s) must be located in the same directory
/// 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:
/// .properties, .ini or .xml.
///
/// The .properties file, if it exists, is loaded first, followed
/// by the .ini file and the .xml file.
///
/// If the application is built in debug mode (the _DEBUG preprocessor
/// 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
/// also found.
///
/// Example: Given the application "SampleAppd.exe", built in debug mode.
/// Then loadConfiguration() will automatically find a configuration file
/// named "SampleApp.properties" if it exists and if "SampleAppd.properties"
/// cannot be found.
///
/// Returns the number of configuration files loaded, which may be zero.
///
/// This method must not be called before initialize(argc, argv)
/// has been called.
void loadConfiguration(const std::string& path);
/// Loads configuration information from the file specified by
/// the given path. The file type is determined by the file
/// extension. The following extensions are supported:
/// - .properties - properties file (PropertyFileConfiguration)
/// - .ini - initialization file (IniFileConfiguration)
/// - .xml - XML file (XMLConfiguration)
///
/// Extensions are not case sensitive.
template <class C> C& getSubsystem() const;
/// Returns a reference to the subsystem of the class
/// given as template argument.
///
/// Throws a NotFoundException if such a subsystem has
/// not been registered.
virtual int run();
/// Runs the application by performing additional initializations
/// and calling the main() method.
std::string commandName() const;
/// Returns the command name used to invoke the application.
LayeredConfiguration& config() const;
/// Returns the application's configuration.
Poco::Logger& logger() const;
/// Returns the application's logger.
///
/// Before the logging subsystem has been initialized, the
/// application's logger is "ApplicationStartup", which is
/// connected to a ConsoleChannel.
///
/// After the logging subsystem has been initialized, which
/// usually happens as the first action in Application::initialize(),
/// the application's logger is the one specified by the
/// "application.logger" configuration property. If that property
/// is not specified, the logger is "Application".
const OptionSet& options() const;
/// Returns the application's option set.
static Application& instance();
/// Returns a reference to the Application singleton.
///
/// Throws a NullPointerException if no Application instance exists.
const Poco::Timestamp& startTime() const;
/// Returns the application start time (UTC).
Poco::Timespan uptime() const;
/// Returns the application uptime.
void stopOptionsProcessing();
/// If called from an option callback, stops all further
/// options processing.
///
/// If called, the following options on the command line
/// will not be processed, and required options will not
/// be checked.
///
/// This is useful, for example, if an option for displaying
/// help information has been encountered and no other things
/// besides displaying help shall be done.
const char* name() const;
protected:
void initialize(Application& self);
/// Initializes the application and all registered subsystems.
/// Subsystems are always initialized in the exact same order
/// in which they have been registered.
///
/// Overriding implementations must call the base class implementation.
void uninitialize();
/// Uninitializes the application and all registered subsystems.
/// Subsystems are always uninitialized in reverse order in which
/// they have been initialized.
///
/// Overriding implementations must call the base class implementation.
void reinitialize(Application& self);
/// Re-nitializes the application and all registered subsystems.
/// Subsystems are always reinitialized in the exact same order
/// in which they have been registered.
///
/// Overriding implementations must call the base class implementation.
virtual void defineOptions(OptionSet& options);
/// Called before command line processing begins.
/// If a subclass wants to support command line arguments,
/// it must override this method.
/// The default implementation does not define any options.
///
/// Overriding implementations should call the base class implementation.
virtual void handleOption(const std::string& name, const std::string& value);
/// Called when the option with the given name is encountered
/// during command line arguments processing.
///
/// The default implementation does option validation, bindings
/// and callback handling.
///
/// Overriding implementations must call the base class implementation.
void setLogger(Poco::Logger& logger);
/// Sets the logger used by the application.
virtual int main(const std::vector<std::string>& args);
/// The application's main logic.
///
/// Unprocessed command line arguments are passed in args.
/// Note that all original command line arguments are available
/// via the properties application.argc and application.argv[<n>].
///
/// Returns an exit code which should be one of the values
/// from the ExitCode enumeration.
bool findFile(Poco::Path& path) const;
/// Searches for the file in path in the application directory.
///
/// If path is absolute, the method immediately returns true and
/// leaves path unchanged.
///
/// If path is relative, searches for the file in the application
/// directory and in all subsequent parent directories.
/// Returns true and stores the absolute path to the file in
/// path if the file could be found. Returns false and leaves path
/// unchanged otherwise.
void init();
/// Common initialization code.
~Application();
/// Destroys the Application and deletes all registered subsystems.
private:
void setup();
void setArgs(int argc, char* argv[]);
void setArgs(const std::vector<std::string>& args);
void getApplicationPath(Poco::Path& path) const;
void processOptions();
bool findAppConfigFile(const std::string& appName, const std::string& extension, Poco::Path& path) const;
typedef Poco::AutoPtr<Subsystem> SubsystemPtr;
typedef std::vector<SubsystemPtr> SubsystemVec;
typedef Poco::AutoPtr<LayeredConfiguration> ConfigPtr;
typedef std::vector<std::string> ArgVec;
ConfigPtr _pConfig;
SubsystemVec _subsystems;
bool _initialized;
std::string _command;
ArgVec _args;
OptionSet _options;
bool _unixOptions;
Poco::Logger* _pLogger;
Poco::Timestamp _startTime;
bool _stopOptionsProcessing;
static Application* _pInstance;
friend class LoggingSubsystem;
};
//
// inlines
//
template <class C> C& Application::getSubsystem() const
{
for (SubsystemVec::const_iterator it = _subsystems.begin(); it != _subsystems.end(); ++it)
{
if (dynamic_cast<C*>(*it))
return **it;
}
throw Poco::NotFoundException("The subsystem has not been registered");
}
inline bool Application::initialized() const
{
return _initialized;
}
inline LayeredConfiguration& Application::config() const
{
return *const_cast<LayeredConfiguration*>(_pConfig.get());
}
inline Poco::Logger& Application::logger() const
{
poco_check_ptr (_pLogger);
return *_pLogger;
}
inline const OptionSet& Application::options() const
{
return _options;
}
inline Application& Application::instance()
{
poco_check_ptr (_pInstance);
return *_pInstance;
}
inline const Poco::Timestamp& Application::startTime() const
{
return _startTime;
}
inline Poco::Timespan Application::uptime() const
{
Poco::Timestamp now;
Poco::Timespan uptime = now - _startTime;
return uptime;
}
} } // namespace Poco::Util
//
// Macro to implement main()
//
#if defined(POCO_WIN32_UTF8)
#define POCO_APP_MAIN(App) \
int wmain(int argc, wchar_t** argv) \
{ \
AutoPtr<App> pApp = new App; \
try \
{ \
pApp->init(argc, argv); \
} \
catch (Poco::Exception& exc) \
{ \
pApp->logger().log(exc); \
return Application::EXIT_CONFIG;\
} \
return pApp->run(); \
}
#else
#define POCO_APP_MAIN(App) \
int main(int argc, char** argv) \
{ \
AutoPtr<App> pApp = new App; \
try \
{ \
pApp->init(argc, argv); \
} \
catch (Poco::Exception& exc) \
{ \
pApp->logger().log(exc); \
return Application::EXIT_CONFIG;\
} \
return pApp->run(); \
}
#endif
#endif // Util_Application_INCLUDED

View File

@ -1,115 +1,115 @@
//
// ConfigurationMapper.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/ConfigurationMapper.h#1 $
//
// Library: Util
// Package: Configuration
// Module: ConfigurationMapper
//
// Definition of the ConfigurationMapper class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_ConfigurationMapper_INCLUDED
#define Util_ConfigurationMapper_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
namespace Poco {
namespace Util {
class Util_API ConfigurationMapper: public AbstractConfiguration
/// This configuration maps a property hierarchy into another
/// hierarchy.
///
/// For example, given a configuration with the following properties:
/// config.value1
/// config.value2
/// config.sub.value1
/// config.sub.value2
/// and a ConfigurationView with fromPrefix == "config" and toPrefix == "root.conf", then
/// the above properties will be available via the mapper as
/// root.conf.value1
/// root.conf.value2
/// root.conf.sub.value1
/// root.conf.sub.value2
///
/// FromPrefix can be empty, in which case, and given toPrefix == "root",
/// the properties will be available as
/// root.config.value1
/// root.config.value2
/// root.config.sub.value1
/// root.config.sub.value2
///
/// This is equivalent to the functionality of the ConfigurationView class.
///
/// Similarly, toPrefix can also be empty. Given fromPrefix == "config" and
/// toPrefix == "", the properties will be available as
/// value1
/// value2
/// sub.value1
/// sub.value2
///
/// If both fromPrefix and toPrefix are empty, no mapping is performed.
///
/// A ConfigurationMapper is most useful in combination with a
/// LayeredConfiguration.
{
public:
ConfigurationMapper(const std::string& fromPrefix, const std::string& toPrefix, AbstractConfiguration* pConfig);
/// Creates the ConfigurationMapper. The ConfigurationMapper does not take
/// ownership of the passed configuration.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
std::string translateKey(const std::string& key) const;
~ConfigurationMapper();
private:
ConfigurationMapper(const ConfigurationMapper&);
ConfigurationMapper& operator = (const ConfigurationMapper&);
std::string _fromPrefix;
std::string _toPrefix;
AbstractConfiguration* _pConfig;
};
} } // namespace Poco::Util
#endif // Util_ConfigurationMapper_INCLUDED
//
// ConfigurationMapper.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/ConfigurationMapper.h#1 $
//
// Library: Util
// Package: Configuration
// Module: ConfigurationMapper
//
// Definition of the ConfigurationMapper class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_ConfigurationMapper_INCLUDED
#define Util_ConfigurationMapper_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
namespace Poco {
namespace Util {
class Util_API ConfigurationMapper: public AbstractConfiguration
/// This configuration maps a property hierarchy into another
/// hierarchy.
///
/// For example, given a configuration with the following properties:
/// config.value1
/// config.value2
/// config.sub.value1
/// config.sub.value2
/// and a ConfigurationView with fromPrefix == "config" and toPrefix == "root.conf", then
/// the above properties will be available via the mapper as
/// root.conf.value1
/// root.conf.value2
/// root.conf.sub.value1
/// root.conf.sub.value2
///
/// FromPrefix can be empty, in which case, and given toPrefix == "root",
/// the properties will be available as
/// root.config.value1
/// root.config.value2
/// root.config.sub.value1
/// root.config.sub.value2
///
/// This is equivalent to the functionality of the ConfigurationView class.
///
/// Similarly, toPrefix can also be empty. Given fromPrefix == "config" and
/// toPrefix == "", the properties will be available as
/// value1
/// value2
/// sub.value1
/// sub.value2
///
/// If both fromPrefix and toPrefix are empty, no mapping is performed.
///
/// A ConfigurationMapper is most useful in combination with a
/// LayeredConfiguration.
{
public:
ConfigurationMapper(const std::string& fromPrefix, const std::string& toPrefix, AbstractConfiguration* pConfig);
/// Creates the ConfigurationMapper. The ConfigurationMapper does not take
/// ownership of the passed configuration.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
std::string translateKey(const std::string& key) const;
~ConfigurationMapper();
private:
ConfigurationMapper(const ConfigurationMapper&);
ConfigurationMapper& operator = (const ConfigurationMapper&);
std::string _fromPrefix;
std::string _toPrefix;
AbstractConfiguration* _pConfig;
};
} } // namespace Poco::Util
#endif // Util_ConfigurationMapper_INCLUDED

View File

@ -1,103 +1,103 @@
//
// ConfigurationView.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/ConfigurationView.h#1 $
//
// Library: Util
// Package: Configuration
// Module: ConfigurationView
//
// Definition of the ConfigurationView class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_ConfigurationView_INCLUDED
#define Util_ConfigurationView_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
namespace Poco {
namespace Util {
class Util_API ConfigurationView: public AbstractConfiguration
/// This configuration implements a "view" into a sub-hierarchy
/// of another configuration.
///
/// For example, given a configuration with the following properties:
/// config.value1
/// config.value2
/// config.sub.value1
/// config.sub.value2
/// and a ConfigurationView with the prefix "config", then
/// the above properties will be available via the view as
/// value1
/// value2
/// sub.value1
/// sub.value2
///
/// A ConfigurationView is most useful in combination with a
/// LayeredConfiguration.
///
/// If a property is not found in the view, it is searched in
/// the original configuration. Given the above example configuration,
/// the property named "config.value1" will still be found in the view.
///
/// The main reason for this is that placeholder expansion (${property})
/// still works as expected given a ConfigurationView.
{
public:
ConfigurationView(const std::string& prefix, AbstractConfiguration* pConfig);
/// Creates the ConfigurationView. The ConfigurationView does not take
/// ownership of the passed configuration.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
std::string translateKey(const std::string& key) const;
~ConfigurationView();
private:
ConfigurationView(const ConfigurationView&);
ConfigurationView& operator = (const ConfigurationView&);
std::string _prefix;
AbstractConfiguration* _pConfig;
};
} } // namespace Poco::Util
#endif // Util_ConfigurationView_INCLUDED
//
// ConfigurationView.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/ConfigurationView.h#1 $
//
// Library: Util
// Package: Configuration
// Module: ConfigurationView
//
// Definition of the ConfigurationView class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_ConfigurationView_INCLUDED
#define Util_ConfigurationView_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
namespace Poco {
namespace Util {
class Util_API ConfigurationView: public AbstractConfiguration
/// This configuration implements a "view" into a sub-hierarchy
/// of another configuration.
///
/// For example, given a configuration with the following properties:
/// config.value1
/// config.value2
/// config.sub.value1
/// config.sub.value2
/// and a ConfigurationView with the prefix "config", then
/// the above properties will be available via the view as
/// value1
/// value2
/// sub.value1
/// sub.value2
///
/// A ConfigurationView is most useful in combination with a
/// LayeredConfiguration.
///
/// If a property is not found in the view, it is searched in
/// the original configuration. Given the above example configuration,
/// the property named "config.value1" will still be found in the view.
///
/// The main reason for this is that placeholder expansion (${property})
/// still works as expected given a ConfigurationView.
{
public:
ConfigurationView(const std::string& prefix, AbstractConfiguration* pConfig);
/// Creates the ConfigurationView. The ConfigurationView does not take
/// ownership of the passed configuration.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
std::string translateKey(const std::string& key) const;
~ConfigurationView();
private:
ConfigurationView(const ConfigurationView&);
ConfigurationView& operator = (const ConfigurationView&);
std::string _prefix;
AbstractConfiguration* _pConfig;
};
} } // namespace Poco::Util
#endif // Util_ConfigurationView_INCLUDED

View File

@ -1,114 +1,114 @@
//
// FilesystemConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/FilesystemConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: FilesystemConfiguration
//
// Definition of the FilesystemConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_FilesystemConfiguration_INCLUDED
#define Util_FilesystemConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/Path.h"
namespace Poco {
namespace Util {
class Util_API FilesystemConfiguration: public AbstractConfiguration
/// An implementation of AbstractConfiguration that stores configuration data
/// in a directory hierarchy in the filesystem.
///
/// Every period-separated part of a property name is represented
/// as a directory in the filesystem, relative to the base directory.
/// Values are stored in files named "data".
///
/// All changes to properties are immediately persisted in the filesystem.
///
/// For example, a configuration consisting of the properties
///
/// logging.loggers.root.channel.class = ConsoleChannel
/// logging.loggers.app.name = Application
/// logging.loggers.app.channel = c1
/// logging.formatters.f1.class = PatternFormatter
/// logging.formatters.f1.pattern = [%p] %t
///
/// is stored in the filesystem as follows:
///
/// logging/
/// loggers/
/// root/
/// channel/
/// class/
/// data ("ConsoleChannel")
/// app/
/// name/
/// data ("Application")
/// channel/
/// data ("c1")
/// formatters/
/// f1/
/// class/
/// data ("PatternFormatter")
/// pattern/
/// data ("[%p] %t")
{
public:
FilesystemConfiguration(const std::string& path);
/// Creates a FilesystemConfiguration using the given path.
/// All directories are created as necessary.
void clear();
/// Clears the configuration by erasing the configuration
/// directory and all its subdirectories and files.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
Poco::Path keyToPath(const std::string& key) const;
~FilesystemConfiguration();
private:
Poco::Path _path;
};
} } // namespace Poco::Util
#endif // Util_FilesystemConfiguration_INCLUDED
//
// FilesystemConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/FilesystemConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: FilesystemConfiguration
//
// Definition of the FilesystemConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_FilesystemConfiguration_INCLUDED
#define Util_FilesystemConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/Path.h"
namespace Poco {
namespace Util {
class Util_API FilesystemConfiguration: public AbstractConfiguration
/// An implementation of AbstractConfiguration that stores configuration data
/// in a directory hierarchy in the filesystem.
///
/// Every period-separated part of a property name is represented
/// as a directory in the filesystem, relative to the base directory.
/// Values are stored in files named "data".
///
/// All changes to properties are immediately persisted in the filesystem.
///
/// For example, a configuration consisting of the properties
///
/// logging.loggers.root.channel.class = ConsoleChannel
/// logging.loggers.app.name = Application
/// logging.loggers.app.channel = c1
/// logging.formatters.f1.class = PatternFormatter
/// logging.formatters.f1.pattern = [%p] %t
///
/// is stored in the filesystem as follows:
///
/// logging/
/// loggers/
/// root/
/// channel/
/// class/
/// data ("ConsoleChannel")
/// app/
/// name/
/// data ("Application")
/// channel/
/// data ("c1")
/// formatters/
/// f1/
/// class/
/// data ("PatternFormatter")
/// pattern/
/// data ("[%p] %t")
{
public:
FilesystemConfiguration(const std::string& path);
/// Creates a FilesystemConfiguration using the given path.
/// All directories are created as necessary.
void clear();
/// Clears the configuration by erasing the configuration
/// directory and all its subdirectories and files.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
Poco::Path keyToPath(const std::string& key) const;
~FilesystemConfiguration();
private:
Poco::Path _path;
};
} } // namespace Poco::Util
#endif // Util_FilesystemConfiguration_INCLUDED

View File

@ -1,221 +1,221 @@
//
// HelpFormatter.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/HelpFormatter.h#1 $
//
// Library: Util
// Package: Options
// Module: HelpFormatter
//
// Definition of the HelpFormatter class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_HelpFormatter_INCLUDED
#define Util_HelpFormatter_INCLUDED
#include "Poco/Util/Util.h"
#include <ostream>
namespace Poco {
namespace Util {
class OptionSet;
class Option;
class Util_API HelpFormatter
/// This class formats a help message from an OptionSet.
{
public:
HelpFormatter(const OptionSet& options);
/// Creates the HelpFormatter, using the given
/// options.
///
/// The HelpFormatter just stores a reference
/// to the given OptionSet, so the OptionSet must not
/// be destroyed during the lifetime of the HelpFormatter.
~HelpFormatter();
/// Destroys the HelpFormatter.
void setCommand(const std::string& command);
/// Sets the command name.
const std::string& getCommand() const;
/// Returns the command name.
void setUsage(const std::string& usage);
/// Sets the usage string.
const std::string& getUsage() const;
/// Returns the usage string.
void setHeader(const std::string& header);
/// Sets the header string.
const std::string& getHeader() const;
/// Returns the header string.
void setFooter(const std::string& footer);
/// Sets the footer string.
const std::string& getFooter() const;
/// Returns the footer string.
void format(std::ostream& ostr) const;
/// Writes the formatted help text to the given stream.
void setWidth(int width);
/// Sets the line width for the formatted help text.
int getWidth() const;
/// Returns the line width for the formatted help text.
///
/// The default width is 72.
void setIndent(int indent);
/// Sets the indentation for description continuation lines.
int getIndent() const;
/// Returns the indentation for description continuation lines.
void setAutoIndent();
/// Sets the indentation for description continuation lines so that
/// the description text is left-aligned.
void setUnixStyle(bool flag);
/// Enables Unix-style options. Both short and long option names
/// are printed if Unix-style is set. Otherwise, only long option
/// names are printed.
bool isUnixStyle() const;
/// Returns if Unix-style options are set.
std::string shortPrefix() const;
/// Returns the platform-specific prefix for short options.
/// "-" on Unix, "/" on Windows and OpenVMS.
std::string longPrefix() const;
/// Returns the platform-specific prefix for long options.
/// "--" on Unix, "/" on Windows and OpenVMS.
protected:
int calcIndent() const;
/// Calculates the indentation for the option descriptions
/// from the given options.
void formatOptions(std::ostream& ostr) const;
/// Formats all options.
void formatOption(std::ostream& ostr, const Option& option, int width) const;
/// Formats an option, using the platform-specific
/// prefixes.
void formatText(std::ostream& ostr, const std::string& text, int indent) const;
/// Formats the given text.
void formatText(std::ostream& ostr, const std::string& text, int indent, int firstIndent) const;
/// Formats the given text.
void formatWord(std::ostream& ostr, int& pos, const std::string& word, int indent) const;
/// Formats the given word.
void clearWord(std::ostream& ostr, int& pos, std::string& word, int indent) const;
/// Formats and then clears the given word.
private:
HelpFormatter(const HelpFormatter&);
HelpFormatter& operator = (const HelpFormatter&);
const OptionSet& _options;
int _width;
int _indent;
std::string _command;
std::string _usage;
std::string _header;
std::string _footer;
bool _unixStyle;
static const int TAB_WIDTH;
static const int LINE_WIDTH;
};
//
// inlines
//
inline int HelpFormatter::getWidth() const
{
return _width;
}
inline int HelpFormatter::getIndent() const
{
return _indent;
}
inline const std::string& HelpFormatter::getCommand() const
{
return _command;
}
inline const std::string& HelpFormatter::getUsage() const
{
return _usage;
}
inline const std::string& HelpFormatter::getHeader() const
{
return _header;
}
inline const std::string& HelpFormatter::getFooter() const
{
return _footer;
}
inline bool HelpFormatter::isUnixStyle() const
{
return _unixStyle;
}
} } // namespace Poco::Util
#endif // Util_HelpFormatter_INCLUDED
//
// HelpFormatter.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/HelpFormatter.h#1 $
//
// Library: Util
// Package: Options
// Module: HelpFormatter
//
// Definition of the HelpFormatter class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_HelpFormatter_INCLUDED
#define Util_HelpFormatter_INCLUDED
#include "Poco/Util/Util.h"
#include <ostream>
namespace Poco {
namespace Util {
class OptionSet;
class Option;
class Util_API HelpFormatter
/// This class formats a help message from an OptionSet.
{
public:
HelpFormatter(const OptionSet& options);
/// Creates the HelpFormatter, using the given
/// options.
///
/// The HelpFormatter just stores a reference
/// to the given OptionSet, so the OptionSet must not
/// be destroyed during the lifetime of the HelpFormatter.
~HelpFormatter();
/// Destroys the HelpFormatter.
void setCommand(const std::string& command);
/// Sets the command name.
const std::string& getCommand() const;
/// Returns the command name.
void setUsage(const std::string& usage);
/// Sets the usage string.
const std::string& getUsage() const;
/// Returns the usage string.
void setHeader(const std::string& header);
/// Sets the header string.
const std::string& getHeader() const;
/// Returns the header string.
void setFooter(const std::string& footer);
/// Sets the footer string.
const std::string& getFooter() const;
/// Returns the footer string.
void format(std::ostream& ostr) const;
/// Writes the formatted help text to the given stream.
void setWidth(int width);
/// Sets the line width for the formatted help text.
int getWidth() const;
/// Returns the line width for the formatted help text.
///
/// The default width is 72.
void setIndent(int indent);
/// Sets the indentation for description continuation lines.
int getIndent() const;
/// Returns the indentation for description continuation lines.
void setAutoIndent();
/// Sets the indentation for description continuation lines so that
/// the description text is left-aligned.
void setUnixStyle(bool flag);
/// Enables Unix-style options. Both short and long option names
/// are printed if Unix-style is set. Otherwise, only long option
/// names are printed.
bool isUnixStyle() const;
/// Returns if Unix-style options are set.
std::string shortPrefix() const;
/// Returns the platform-specific prefix for short options.
/// "-" on Unix, "/" on Windows and OpenVMS.
std::string longPrefix() const;
/// Returns the platform-specific prefix for long options.
/// "--" on Unix, "/" on Windows and OpenVMS.
protected:
int calcIndent() const;
/// Calculates the indentation for the option descriptions
/// from the given options.
void formatOptions(std::ostream& ostr) const;
/// Formats all options.
void formatOption(std::ostream& ostr, const Option& option, int width) const;
/// Formats an option, using the platform-specific
/// prefixes.
void formatText(std::ostream& ostr, const std::string& text, int indent) const;
/// Formats the given text.
void formatText(std::ostream& ostr, const std::string& text, int indent, int firstIndent) const;
/// Formats the given text.
void formatWord(std::ostream& ostr, int& pos, const std::string& word, int indent) const;
/// Formats the given word.
void clearWord(std::ostream& ostr, int& pos, std::string& word, int indent) const;
/// Formats and then clears the given word.
private:
HelpFormatter(const HelpFormatter&);
HelpFormatter& operator = (const HelpFormatter&);
const OptionSet& _options;
int _width;
int _indent;
std::string _command;
std::string _usage;
std::string _header;
std::string _footer;
bool _unixStyle;
static const int TAB_WIDTH;
static const int LINE_WIDTH;
};
//
// inlines
//
inline int HelpFormatter::getWidth() const
{
return _width;
}
inline int HelpFormatter::getIndent() const
{
return _indent;
}
inline const std::string& HelpFormatter::getCommand() const
{
return _command;
}
inline const std::string& HelpFormatter::getUsage() const
{
return _usage;
}
inline const std::string& HelpFormatter::getHeader() const
{
return _header;
}
inline const std::string& HelpFormatter::getFooter() const
{
return _footer;
}
inline bool HelpFormatter::isUnixStyle() const
{
return _unixStyle;
}
} } // namespace Poco::Util
#endif // Util_HelpFormatter_INCLUDED

View File

@ -1,115 +1,115 @@
//
// IniFileConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/IniFileConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: IniFileConfiguration
//
// Definition of the IniFileConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_IniFileConfiguration_INCLUDED
#define Util_IniFileConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
#include <map>
#include <istream>
namespace Poco {
namespace Util {
class Util_API IniFileConfiguration: public AbstractConfiguration
/// This implementation of a Configuration reads properties
/// from a legacy Windows initialization (.ini) file.
///
/// 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 square bracket denotes a section key [<key>]
/// - every other line denotes a property assignment in the form
/// <value key> = <value>
///
/// The name of a property is composed of the section key and the value key,
/// separated by a period (<section key>.<value key>).
///
/// Property names are not case sensitive. Leading and trailing whitespace is
/// removed from both keys and values.
///
/// Setting properties is not supported. An attempt to set a property results
/// in a NotImplementedException being thrown.
{
public:
IniFileConfiguration();
/// Creates an empty IniFileConfiguration.
IniFileConfiguration(std::istream& istr);
/// Creates an IniFileConfiguration and loads the configuration data
/// from the given stream, which must be in initialization file format.
IniFileConfiguration(const std::string& path);
/// Creates an IniFileConfiguration and loads the configuration data
/// from the given file, which must be in initialization file format.
void load(std::istream& istr);
/// Loads the configuration data from the given stream, which
/// must be in initialization file format.
void load(const std::string& path);
/// Loads the configuration data from the given file, which
/// must be in initialization file format.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
~IniFileConfiguration();
private:
void parseLine(std::istream& istr);
struct ICompare
{
bool operator () (const std::string& s1, const std::string& s2) const;
};
typedef std::map<std::string, std::string, ICompare> IStringMap;
IStringMap _map;
std::string _sectionKey;
};
} } // namespace Poco::Util
#endif // Util_IniFileConfiguration_INCLUDED
//
// IniFileConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/IniFileConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: IniFileConfiguration
//
// Definition of the IniFileConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_IniFileConfiguration_INCLUDED
#define Util_IniFileConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
#include <map>
#include <istream>
namespace Poco {
namespace Util {
class Util_API IniFileConfiguration: public AbstractConfiguration
/// This implementation of a Configuration reads properties
/// from a legacy Windows initialization (.ini) file.
///
/// 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 square bracket denotes a section key [<key>]
/// - every other line denotes a property assignment in the form
/// <value key> = <value>
///
/// The name of a property is composed of the section key and the value key,
/// separated by a period (<section key>.<value key>).
///
/// Property names are not case sensitive. Leading and trailing whitespace is
/// removed from both keys and values.
///
/// Setting properties is not supported. An attempt to set a property results
/// in a NotImplementedException being thrown.
{
public:
IniFileConfiguration();
/// Creates an empty IniFileConfiguration.
IniFileConfiguration(std::istream& istr);
/// Creates an IniFileConfiguration and loads the configuration data
/// from the given stream, which must be in initialization file format.
IniFileConfiguration(const std::string& path);
/// Creates an IniFileConfiguration and loads the configuration data
/// from the given file, which must be in initialization file format.
void load(std::istream& istr);
/// Loads the configuration data from the given stream, which
/// must be in initialization file format.
void load(const std::string& path);
/// Loads the configuration data from the given file, which
/// must be in initialization file format.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
~IniFileConfiguration();
private:
void parseLine(std::istream& istr);
struct ICompare
{
bool operator () (const std::string& s1, const std::string& s2) const;
};
typedef std::map<std::string, std::string, ICompare> IStringMap;
IStringMap _map;
std::string _sectionKey;
};
} } // namespace Poco::Util
#endif // Util_IniFileConfiguration_INCLUDED

View File

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

View File

@ -1,110 +1,110 @@
//
// LayeredConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/LayeredConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: LayeredConfiguration
//
// Definition of the LayeredConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_LayeredConfiguration_INCLUDED
#define Util_LayeredConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/AutoPtr.h"
#include <vector>
namespace Poco {
namespace Util {
class Util_API LayeredConfiguration: public AbstractConfiguration
/// A LayeredConfiguration consists of a number of AbstractConfigurations.
///
/// When reading a configuration property in a LayeredConfiguration,
/// 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
/// added. If no configurations have been added to the LayeredConfiguration, and an
/// attempt is made to set a property, a RuntimeException is thrown.
{
public:
LayeredConfiguration();
/// Creates the LayeredConfiguration.
void add(AbstractConfiguration* pConfig);
/// Adds a configuration to the back of the LayeredConfiguration.
/// The LayeredConfiguration does not take ownership of the given
/// configuration. In other words, the configuration's reference
/// count is incremented.
void add(AbstractConfiguration* pConfig, bool shared);
/// Adds a configuration to the back of the LayeredConfiguration.
/// If shared is false, the LayeredConfiguration takes ownership
/// of the given configuration (and the configuration's reference
/// count remains unchanged).
void addFront(AbstractConfiguration* pConfig);
/// Adds a configuration to the front of the LayeredConfiguration.
/// The LayeredConfiguration does not take ownership of the given
/// configuration. In other words, the configuration's reference
/// count is incremented.
void addFront(AbstractConfiguration* pConfig, bool shared);
/// Adds a configuration to the front of the LayeredConfiguration.
/// If shared is true, the LayeredConfiguration takes ownership
/// of the given configuration.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
~LayeredConfiguration();
private:
LayeredConfiguration(const LayeredConfiguration&);
LayeredConfiguration& operator = (const LayeredConfiguration&);
typedef Poco::AutoPtr<AbstractConfiguration> ConfigPtr;
typedef std::vector<ConfigPtr> ConfigVec;
ConfigVec _configs;
};
} } // namespace Poco::Util
#endif // Util_LayeredConfiguration_INCLUDED
//
// LayeredConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/LayeredConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: LayeredConfiguration
//
// Definition of the LayeredConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_LayeredConfiguration_INCLUDED
#define Util_LayeredConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/AutoPtr.h"
#include <vector>
namespace Poco {
namespace Util {
class Util_API LayeredConfiguration: public AbstractConfiguration
/// A LayeredConfiguration consists of a number of AbstractConfigurations.
///
/// When reading a configuration property in a LayeredConfiguration,
/// 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
/// added. If no configurations have been added to the LayeredConfiguration, and an
/// attempt is made to set a property, a RuntimeException is thrown.
{
public:
LayeredConfiguration();
/// Creates the LayeredConfiguration.
void add(AbstractConfiguration* pConfig);
/// Adds a configuration to the back of the LayeredConfiguration.
/// The LayeredConfiguration does not take ownership of the given
/// configuration. In other words, the configuration's reference
/// count is incremented.
void add(AbstractConfiguration* pConfig, bool shared);
/// Adds a configuration to the back of the LayeredConfiguration.
/// If shared is false, the LayeredConfiguration takes ownership
/// of the given configuration (and the configuration's reference
/// count remains unchanged).
void addFront(AbstractConfiguration* pConfig);
/// Adds a configuration to the front of the LayeredConfiguration.
/// The LayeredConfiguration does not take ownership of the given
/// configuration. In other words, the configuration's reference
/// count is incremented.
void addFront(AbstractConfiguration* pConfig, bool shared);
/// Adds a configuration to the front of the LayeredConfiguration.
/// If shared is true, the LayeredConfiguration takes ownership
/// of the given configuration.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
~LayeredConfiguration();
private:
LayeredConfiguration(const LayeredConfiguration&);
LayeredConfiguration& operator = (const LayeredConfiguration&);
typedef Poco::AutoPtr<AbstractConfiguration> ConfigPtr;
typedef std::vector<ConfigPtr> ConfigVec;
ConfigVec _configs;
};
} } // namespace Poco::Util
#endif // Util_LayeredConfiguration_INCLUDED

View File

@ -1,161 +1,161 @@
//
// LoggingConfigurator.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/LoggingConfigurator.h#2 $
//
// Library: Util
// Package: Configuration
// Module: LoggingConfigurator
//
// Definition of the LoggingConfigurator class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_LoggingConfigurator_INCLUDED
#define Util_LoggingConfigurator_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Formatter.h"
#include "Poco/Channel.h"
namespace Poco {
namespace Util {
class AbstractConfiguration;
class Util_API LoggingConfigurator
/// This utility class uses a configuration object to configure the
/// logging subsystem of an application.
///
/// The LoggingConfigurator sets up and connects formatters, channels
/// and loggers. To accomplish its work, the LoggingConfigurator relies on the
/// functionality provided by the LoggingFactory und LoggingRegistry classes.
///
/// The LoggingConfigurator expects all configuration data to be under a root
/// property named "logging".
///
/// Configuring Formatters
///
/// A formatter is configured using the "logging.formatters" property. Every
/// formatter has an internal name, which is only used for referring to it
/// during configuration time. This name becomes part of the property name.
/// Every formatter has a mandatory "class" property, which specifies the actual
/// class implementing the formatter. Any other properties are passed on to
/// the formatter by calling its setProperty() method.
///
/// A typical formatter definition looks as follows:
/// logging.formatters.f1.class = PatternFormatter
/// logging.formatters.f1.pattern = %s: [%p] %t
/// logging.formatters.f1.times = UTC
///
/// Configuring Channels
///
/// A channel is configured using the "logging.channels" property. Like with
/// Formatters, every channel has an internal name, which is used during
/// configuration only. The name becomes part of the property name.
/// Every channel has a mandatory "class" property, which specifies the actual
/// class implementing the channel. Any other properties are passed on to
/// the formatter by calling its setProperty() method.
///
/// For convenience, the "formatter" property of a channel is treated
/// specifically. The "formatter" property can either be used to refer to
/// an already defined formatter, or it can be used to specify an "inline"
/// formatter definition. In either case, when a "formatter" property is
/// present, the channel is automatically "wrapped" in a FormattingChannel
/// object.
///
/// Similarly, a channel supports also a "pattern" property, which results
/// in the automatic instantiation of a FormattingChannel object with a
/// connected PatternFormatter.
///
/// Examples:
/// logging.channels.c1.class = ConsoleChannel
/// logging.channels.c1.formatter = f1
/// logging.channels.c2.class = FileChannel
/// logging.channels.c2.path = ${system.tempDir}/sample.log
/// logging.channels.c2.formatter.class = PatternFormatter
/// logging.channels.c2.formatter.pattern = %s: [%p] %t
/// logging.channels.c3.class = ConsoleChannel
/// logging.channels.c3.pattern = %s: [%p] %t
///
/// Configuring Loggers
///
/// A logger is configured using the "logging.loggers" property. Like with
/// 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
/// name is different from the logger's full name, which is used to access
/// the logger at runtime.
/// Every logger except the root logger has a mandatory "name" property which
/// is used to specify the logger's full name.
/// Furthermore, a "channel" property is supported, which can either refer
/// to a named channel, or which can contain an inline channel definition.
///
/// Examples:
/// logging.loggers.root.channel = c1
/// logging.loggers.root.level = warning
/// logging.loggers.l1.name = logger1
/// logging.loggers.l1.channel.class = ConsoleChannel
/// logging.loggers.l1.channel.pattern = %s: [%p] %t
/// logging.loggers.l1.level = information
{
public:
LoggingConfigurator();
/// Creates the LoggingConfigurator.
~LoggingConfigurator();
/// Destroys the LoggingConfigurator.
void configure(AbstractConfiguration* pConfig);
/// Configures the logging subsystem based on
/// the given configuration.
///
/// A ConfigurationView can be used to pass only
/// a part of a larger configuration.
private:
void configureFormatters(AbstractConfiguration* pConfig);
void configureChannels(AbstractConfiguration* pConfig);
void configureLoggers(AbstractConfiguration* pConfig);
Poco::Formatter* createFormatter(AbstractConfiguration* pConfig);
Poco::Channel* createChannel(AbstractConfiguration* pConfig);
void configureChannel(Channel* pChannel, AbstractConfiguration* pConfig);
void configureLogger(AbstractConfiguration* pConfig);
LoggingConfigurator(const LoggingConfigurator&);
LoggingConfigurator& operator = (const LoggingConfigurator&);
};
} } // namespace Poco::Util
#endif // Util_LoggingConfigurator_INCLUDED
//
// LoggingConfigurator.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/LoggingConfigurator.h#2 $
//
// Library: Util
// Package: Configuration
// Module: LoggingConfigurator
//
// Definition of the LoggingConfigurator class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_LoggingConfigurator_INCLUDED
#define Util_LoggingConfigurator_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Formatter.h"
#include "Poco/Channel.h"
namespace Poco {
namespace Util {
class AbstractConfiguration;
class Util_API LoggingConfigurator
/// This utility class uses a configuration object to configure the
/// logging subsystem of an application.
///
/// The LoggingConfigurator sets up and connects formatters, channels
/// and loggers. To accomplish its work, the LoggingConfigurator relies on the
/// functionality provided by the LoggingFactory und LoggingRegistry classes.
///
/// The LoggingConfigurator expects all configuration data to be under a root
/// property named "logging".
///
/// Configuring Formatters
///
/// A formatter is configured using the "logging.formatters" property. Every
/// formatter has an internal name, which is only used for referring to it
/// during configuration time. This name becomes part of the property name.
/// Every formatter has a mandatory "class" property, which specifies the actual
/// class implementing the formatter. Any other properties are passed on to
/// the formatter by calling its setProperty() method.
///
/// A typical formatter definition looks as follows:
/// logging.formatters.f1.class = PatternFormatter
/// logging.formatters.f1.pattern = %s: [%p] %t
/// logging.formatters.f1.times = UTC
///
/// Configuring Channels
///
/// A channel is configured using the "logging.channels" property. Like with
/// Formatters, every channel has an internal name, which is used during
/// configuration only. The name becomes part of the property name.
/// Every channel has a mandatory "class" property, which specifies the actual
/// class implementing the channel. Any other properties are passed on to
/// the formatter by calling its setProperty() method.
///
/// For convenience, the "formatter" property of a channel is treated
/// specifically. The "formatter" property can either be used to refer to
/// an already defined formatter, or it can be used to specify an "inline"
/// formatter definition. In either case, when a "formatter" property is
/// present, the channel is automatically "wrapped" in a FormattingChannel
/// object.
///
/// Similarly, a channel supports also a "pattern" property, which results
/// in the automatic instantiation of a FormattingChannel object with a
/// connected PatternFormatter.
///
/// Examples:
/// logging.channels.c1.class = ConsoleChannel
/// logging.channels.c1.formatter = f1
/// logging.channels.c2.class = FileChannel
/// logging.channels.c2.path = ${system.tempDir}/sample.log
/// logging.channels.c2.formatter.class = PatternFormatter
/// logging.channels.c2.formatter.pattern = %s: [%p] %t
/// logging.channels.c3.class = ConsoleChannel
/// logging.channels.c3.pattern = %s: [%p] %t
///
/// Configuring Loggers
///
/// A logger is configured using the "logging.loggers" property. Like with
/// 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
/// name is different from the logger's full name, which is used to access
/// the logger at runtime.
/// Every logger except the root logger has a mandatory "name" property which
/// is used to specify the logger's full name.
/// Furthermore, a "channel" property is supported, which can either refer
/// to a named channel, or which can contain an inline channel definition.
///
/// Examples:
/// logging.loggers.root.channel = c1
/// logging.loggers.root.level = warning
/// logging.loggers.l1.name = logger1
/// logging.loggers.l1.channel.class = ConsoleChannel
/// logging.loggers.l1.channel.pattern = %s: [%p] %t
/// logging.loggers.l1.level = information
{
public:
LoggingConfigurator();
/// Creates the LoggingConfigurator.
~LoggingConfigurator();
/// Destroys the LoggingConfigurator.
void configure(AbstractConfiguration* pConfig);
/// Configures the logging subsystem based on
/// the given configuration.
///
/// A ConfigurationView can be used to pass only
/// a part of a larger configuration.
private:
void configureFormatters(AbstractConfiguration* pConfig);
void configureChannels(AbstractConfiguration* pConfig);
void configureLoggers(AbstractConfiguration* pConfig);
Poco::Formatter* createFormatter(AbstractConfiguration* pConfig);
Poco::Channel* createChannel(AbstractConfiguration* pConfig);
void configureChannel(Channel* pChannel, AbstractConfiguration* pConfig);
void configureLogger(AbstractConfiguration* pConfig);
LoggingConfigurator(const LoggingConfigurator&);
LoggingConfigurator& operator = (const LoggingConfigurator&);
};
} } // namespace Poco::Util
#endif // Util_LoggingConfigurator_INCLUDED

View File

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

View File

@ -1,82 +1,82 @@
//
// MapConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/MapConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: MapConfiguration
//
// Definition of the MapConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_MapConfiguration_INCLUDED
#define Util_MapConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
#include <map>
namespace Poco {
namespace Util {
class Util_API MapConfiguration: public AbstractConfiguration
/// An implementation of AbstractConfiguration that stores configuration data in a map.
{
public:
MapConfiguration();
/// Creates an empty MapConfiguration.
void clear();
/// Clears the configuration.
protected:
typedef std::map<std::string, std::string> StringMap;
typedef StringMap::const_iterator iterator;
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
~MapConfiguration();
iterator begin() const;
iterator end() const;
private:
StringMap _map;
};
} } // namespace Poco::Util
#endif // Util_MapConfiguration_INCLUDED
//
// MapConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/MapConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: MapConfiguration
//
// Definition of the MapConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_MapConfiguration_INCLUDED
#define Util_MapConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
#include <map>
namespace Poco {
namespace Util {
class Util_API MapConfiguration: public AbstractConfiguration
/// An implementation of AbstractConfiguration that stores configuration data in a map.
{
public:
MapConfiguration();
/// Creates an empty MapConfiguration.
void clear();
/// Clears the configuration.
protected:
typedef std::map<std::string, std::string> StringMap;
typedef StringMap::const_iterator iterator;
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
~MapConfiguration();
iterator begin() const;
iterator end() const;
private:
StringMap _map;
};
} } // namespace Poco::Util
#endif // Util_MapConfiguration_INCLUDED

View File

@ -1,337 +1,337 @@
//
// Option.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/Option.h#2 $
//
// Library: Util
// Package: Options
// Module: Option
//
// Definition of the Option class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_Option_INCLUDED
#define Util_Option_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/OptionCallback.h"
namespace Poco {
namespace Util {
class Application;
class Validator;
class Util_API Option
/// This class represents and stores the properties
/// of a command line option.
///
/// An option has a full name, an optional short name,
/// a description (used for printing a usage statement),
/// and an optional argument name.
/// An option can be optional or required.
/// An option can be repeatable, which means that it can
/// be given more than once on the command line.
///
/// An option can be part of an option group. At most one
/// option of each group may be specified on the command
/// line.
///
/// An option can be bound to a configuration property.
/// In this case, a configuration property will automatically
/// receive the option's argument value.
///
/// A callback method can be specified for options. This method
/// is called whenever an option is specified on the command line.
///
/// Option argument values can be automatically validated using a
/// Validator.
///
/// Option instances are value objects.
///
/// Typcally, after construction, an Option object is immediately
/// passed to an Options object.
///
/// An Option object can be created by chaining the constructor
/// with any of the setter methods, as in the following example:
///
/// Option versionOpt("include", "I", "specify an include directory")
/// .required(false)
/// .repeatable(true)
/// .argument("directory");
{
public:
Option();
/// Creates an empty Option.
Option(const Option& option);
/// Creates an option from another one.
Option(const std::string& fullName, const std::string& shortName);
/// Creates an option with the given properties.
Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required = false);
/// 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);
/// Creates an option with the given properties.
~Option();
/// Destroys the Option.
Option& operator = (const Option& option);
/// Assignment operator.
void swap(Option& option);
/// Swaps the option with another one.
Option& shortName(const std::string& name);
/// Sets the short name of the option.
Option& fullName(const std::string& name);
/// Sets the full name of the option.
Option& description(const std::string& text);
/// Sets the description of the option.
Option& required(bool flag);
/// Sets whether the option is required (flag == true)
/// or optional (flag == false).
Option& repeatable(bool flag);
/// Sets whether the option can be specified more than once
/// (flag == true) or at most once (flag == false).
Option& argument(const std::string& name, bool required = true);
/// Specifies that the option takes an (optional or required)
/// argument.
Option& noArgument();
/// Specifies that the option does not take an argument (default).
Option& group(const std::string& group);
/// Specifies the option group the option is part of.
Option& binding(const std::string& propertyName);
/// Binds the option to the configuration property with the given name.
///
/// The configuration will automatically receive the option's argument.
Option& callback(const AbstractOptionCallback& cb);
/// Binds the option to the given method.
///
/// The callback method will be called when the option
/// has been specified on the command line.
///
/// Usage:
/// callback(OptionCallback<MyApplication>(this, &MyApplication::myCallback));
Option& validator(Validator* pValidator);
/// Sets the validator for the given option.
///
/// The Option takes ownership of the Validator and
/// deletes it when it's no longer needed.
const std::string& shortName() const;
/// Returns the short name of the option.
const std::string& fullName() const;
/// Returns the full name of the option.
const std::string& description() const;
/// Returns the description of the option.
bool required() const;
/// Returns true if the option is required, false if not.
bool repeatable() const;
/// Returns true if the option can be specified more than
/// once, or false if at most once.
bool takesArgument() const;
/// Returns true if the options takes an (optional) argument.
bool argumentRequired() const;
/// Returns true if the argument is required.
const std::string& argumentName() const;
/// Returns the argument name, if specified.
const std::string& group() const;
/// Returns the option group the option is part of,
/// or an empty string, if the option is not part of
/// a group.
const std::string& binding() const;
/// Returns the property name the option is bound to,
/// or an empty string in case it is not bound.
AbstractOptionCallback* callback() const;
/// Returns a pointer to the callback method for the option,
/// or NULL if no callback has been specified.
Validator* validator() const;
/// Returns the option's Validator, if one has been specified,
/// or NULL otherwise.
bool matchesShort(const std::string& option) const;
/// Returns true if the given option string matches the
/// short name.
///
/// The first characters of the option string must match
/// the short name of the option (case sensitive),
/// or the option string must partially match the full
/// name (case insensitive).
bool matchesFull(const std::string& option) const;
/// Returns true if the given option string matches the
/// full name.
///
/// The option string must match the full
/// name (case insensitive).
bool matchesPartial(const std::string& option) const;
/// Returns true if the given option string partially matches the
/// full name.
///
/// The option string must partially match the full
/// name (case insensitive).
void process(const std::string& option, std::string& arg) const;
/// Verifies that the given option string matches the
/// requirements of the option, and extracts the option argument,
/// if present.
///
/// If the option string is okay and carries an argument,
/// the argument is returned in arg.
///
/// Throws a MissingArgumentException if a required argument
/// is missing. Throws an UnexpectedArgumentException if an
/// argument has been found, but none is expected.
private:
std::string _shortName;
std::string _fullName;
std::string _description;
bool _required;
bool _repeatable;
std::string _argName;
bool _argRequired;
std::string _group;
std::string _binding;
Validator* _pValidator;
AbstractOptionCallback* _pCallback;
};
//
// inlines
//
inline const std::string& Option::shortName() const
{
return _shortName;
}
inline const std::string& Option::fullName() const
{
return _fullName;
}
inline const std::string& Option::description() const
{
return _description;
}
inline bool Option::required() const
{
return _required;
}
inline bool Option::repeatable() const
{
return _repeatable;
}
inline bool Option::takesArgument() const
{
return !_argName.empty();
}
inline bool Option::argumentRequired() const
{
return _argRequired;
}
inline const std::string& Option::argumentName() const
{
return _argName;
}
inline const std::string& Option::group() const
{
return _group;
}
inline const std::string& Option::binding() const
{
return _binding;
}
inline AbstractOptionCallback* Option::callback() const
{
return _pCallback;
}
inline Validator* Option::validator() const
{
return _pValidator;
}
} } // namespace Poco::Util
#endif // Util_Option_INCLUDED
//
// Option.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/Option.h#2 $
//
// Library: Util
// Package: Options
// Module: Option
//
// Definition of the Option class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_Option_INCLUDED
#define Util_Option_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/OptionCallback.h"
namespace Poco {
namespace Util {
class Application;
class Validator;
class Util_API Option
/// This class represents and stores the properties
/// of a command line option.
///
/// An option has a full name, an optional short name,
/// a description (used for printing a usage statement),
/// and an optional argument name.
/// An option can be optional or required.
/// An option can be repeatable, which means that it can
/// be given more than once on the command line.
///
/// An option can be part of an option group. At most one
/// option of each group may be specified on the command
/// line.
///
/// An option can be bound to a configuration property.
/// In this case, a configuration property will automatically
/// receive the option's argument value.
///
/// A callback method can be specified for options. This method
/// is called whenever an option is specified on the command line.
///
/// Option argument values can be automatically validated using a
/// Validator.
///
/// Option instances are value objects.
///
/// Typcally, after construction, an Option object is immediately
/// passed to an Options object.
///
/// An Option object can be created by chaining the constructor
/// with any of the setter methods, as in the following example:
///
/// Option versionOpt("include", "I", "specify an include directory")
/// .required(false)
/// .repeatable(true)
/// .argument("directory");
{
public:
Option();
/// Creates an empty Option.
Option(const Option& option);
/// Creates an option from another one.
Option(const std::string& fullName, const std::string& shortName);
/// Creates an option with the given properties.
Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required = false);
/// 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);
/// Creates an option with the given properties.
~Option();
/// Destroys the Option.
Option& operator = (const Option& option);
/// Assignment operator.
void swap(Option& option);
/// Swaps the option with another one.
Option& shortName(const std::string& name);
/// Sets the short name of the option.
Option& fullName(const std::string& name);
/// Sets the full name of the option.
Option& description(const std::string& text);
/// Sets the description of the option.
Option& required(bool flag);
/// Sets whether the option is required (flag == true)
/// or optional (flag == false).
Option& repeatable(bool flag);
/// Sets whether the option can be specified more than once
/// (flag == true) or at most once (flag == false).
Option& argument(const std::string& name, bool required = true);
/// Specifies that the option takes an (optional or required)
/// argument.
Option& noArgument();
/// Specifies that the option does not take an argument (default).
Option& group(const std::string& group);
/// Specifies the option group the option is part of.
Option& binding(const std::string& propertyName);
/// Binds the option to the configuration property with the given name.
///
/// The configuration will automatically receive the option's argument.
Option& callback(const AbstractOptionCallback& cb);
/// Binds the option to the given method.
///
/// The callback method will be called when the option
/// has been specified on the command line.
///
/// Usage:
/// callback(OptionCallback<MyApplication>(this, &MyApplication::myCallback));
Option& validator(Validator* pValidator);
/// Sets the validator for the given option.
///
/// The Option takes ownership of the Validator and
/// deletes it when it's no longer needed.
const std::string& shortName() const;
/// Returns the short name of the option.
const std::string& fullName() const;
/// Returns the full name of the option.
const std::string& description() const;
/// Returns the description of the option.
bool required() const;
/// Returns true if the option is required, false if not.
bool repeatable() const;
/// Returns true if the option can be specified more than
/// once, or false if at most once.
bool takesArgument() const;
/// Returns true if the options takes an (optional) argument.
bool argumentRequired() const;
/// Returns true if the argument is required.
const std::string& argumentName() const;
/// Returns the argument name, if specified.
const std::string& group() const;
/// Returns the option group the option is part of,
/// or an empty string, if the option is not part of
/// a group.
const std::string& binding() const;
/// Returns the property name the option is bound to,
/// or an empty string in case it is not bound.
AbstractOptionCallback* callback() const;
/// Returns a pointer to the callback method for the option,
/// or NULL if no callback has been specified.
Validator* validator() const;
/// Returns the option's Validator, if one has been specified,
/// or NULL otherwise.
bool matchesShort(const std::string& option) const;
/// Returns true if the given option string matches the
/// short name.
///
/// The first characters of the option string must match
/// the short name of the option (case sensitive),
/// or the option string must partially match the full
/// name (case insensitive).
bool matchesFull(const std::string& option) const;
/// Returns true if the given option string matches the
/// full name.
///
/// The option string must match the full
/// name (case insensitive).
bool matchesPartial(const std::string& option) const;
/// Returns true if the given option string partially matches the
/// full name.
///
/// The option string must partially match the full
/// name (case insensitive).
void process(const std::string& option, std::string& arg) const;
/// Verifies that the given option string matches the
/// requirements of the option, and extracts the option argument,
/// if present.
///
/// If the option string is okay and carries an argument,
/// the argument is returned in arg.
///
/// Throws a MissingArgumentException if a required argument
/// is missing. Throws an UnexpectedArgumentException if an
/// argument has been found, but none is expected.
private:
std::string _shortName;
std::string _fullName;
std::string _description;
bool _required;
bool _repeatable;
std::string _argName;
bool _argRequired;
std::string _group;
std::string _binding;
Validator* _pValidator;
AbstractOptionCallback* _pCallback;
};
//
// inlines
//
inline const std::string& Option::shortName() const
{
return _shortName;
}
inline const std::string& Option::fullName() const
{
return _fullName;
}
inline const std::string& Option::description() const
{
return _description;
}
inline bool Option::required() const
{
return _required;
}
inline bool Option::repeatable() const
{
return _repeatable;
}
inline bool Option::takesArgument() const
{
return !_argName.empty();
}
inline bool Option::argumentRequired() const
{
return _argRequired;
}
inline const std::string& Option::argumentName() const
{
return _argName;
}
inline const std::string& Option::group() const
{
return _group;
}
inline const std::string& Option::binding() const
{
return _binding;
}
inline AbstractOptionCallback* Option::callback() const
{
return _pCallback;
}
inline Validator* Option::validator() const
{
return _pValidator;
}
} } // namespace Poco::Util
#endif // Util_Option_INCLUDED

View File

@ -1,131 +1,131 @@
//
// OptionCallback.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/OptionCallback.h#1 $
//
// Library: Util
// Package: Options
// Module: OptionCallback
//
// Definition of the OptionCallback class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_OptionCallback_INCLUDED
#define Util_OptionCallback_INCLUDED
#include "Poco/Util/Util.h"
namespace Poco {
namespace Util {
class Util_API AbstractOptionCallback
/// Base class for OptionCallback.
{
public:
virtual void invoke(const std::string& name, const std::string& value) const = 0;
/// Invokes the callback member function.
virtual AbstractOptionCallback* clone() const = 0;
/// Creates and returns a copy of the object.
virtual ~AbstractOptionCallback();
/// Destroys the AbstractOptionCallback.
protected:
AbstractOptionCallback();
AbstractOptionCallback(const AbstractOptionCallback&);
};
template <class C>
class OptionCallback: public AbstractOptionCallback
/// This class is used as an argument to Option::callback().
///
/// It stores a pointer to an object and a pointer to a member
/// function of the object's class.
{
public:
typedef void (C::*Callback)(const std::string& name, const std::string& value);
OptionCallback(C* pObject, Callback method):
_pObject(pObject),
_method(method)
/// Creates the OptionCallback for the given object and member function.
{
poco_check_ptr (pObject);
}
OptionCallback(const OptionCallback& cb):
AbstractOptionCallback(cb),
_pObject(cb._pObject),
_method(cb._method)
/// Creates an OptionCallback from another one.
{
}
~OptionCallback()
/// Destroys the OptionCallback.
{
}
OptionCallback& operator = (const OptionCallback& cb)
{
if (&cb != this)
{
this->_pObject = cb._pObject;
this->_method = cb._method;
}
return *this;
}
void invoke(const std::string& name, const std::string& value) const
{
(_pObject->*_method)(name, value);
}
AbstractOptionCallback* clone() const
{
return new OptionCallback(_pObject, _method);
}
private:
OptionCallback();
C* _pObject;
Callback _method;
};
} } // namespace Poco::Util
#endif // Util_OptionCallback_INCLUDED
//
// OptionCallback.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/OptionCallback.h#1 $
//
// Library: Util
// Package: Options
// Module: OptionCallback
//
// Definition of the OptionCallback class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_OptionCallback_INCLUDED
#define Util_OptionCallback_INCLUDED
#include "Poco/Util/Util.h"
namespace Poco {
namespace Util {
class Util_API AbstractOptionCallback
/// Base class for OptionCallback.
{
public:
virtual void invoke(const std::string& name, const std::string& value) const = 0;
/// Invokes the callback member function.
virtual AbstractOptionCallback* clone() const = 0;
/// Creates and returns a copy of the object.
virtual ~AbstractOptionCallback();
/// Destroys the AbstractOptionCallback.
protected:
AbstractOptionCallback();
AbstractOptionCallback(const AbstractOptionCallback&);
};
template <class C>
class OptionCallback: public AbstractOptionCallback
/// This class is used as an argument to Option::callback().
///
/// It stores a pointer to an object and a pointer to a member
/// function of the object's class.
{
public:
typedef void (C::*Callback)(const std::string& name, const std::string& value);
OptionCallback(C* pObject, Callback method):
_pObject(pObject),
_method(method)
/// Creates the OptionCallback for the given object and member function.
{
poco_check_ptr (pObject);
}
OptionCallback(const OptionCallback& cb):
AbstractOptionCallback(cb),
_pObject(cb._pObject),
_method(cb._method)
/// Creates an OptionCallback from another one.
{
}
~OptionCallback()
/// Destroys the OptionCallback.
{
}
OptionCallback& operator = (const OptionCallback& cb)
{
if (&cb != this)
{
this->_pObject = cb._pObject;
this->_method = cb._method;
}
return *this;
}
void invoke(const std::string& name, const std::string& value) const
{
(_pObject->*_method)(name, value);
}
AbstractOptionCallback* clone() const
{
return new OptionCallback(_pObject, _method);
}
private:
OptionCallback();
C* _pObject;
Callback _method;
};
} } // namespace Poco::Util
#endif // Util_OptionCallback_INCLUDED

View File

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

View File

@ -1,148 +1,148 @@
//
// OptionProcessor.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/OptionProcessor.h#1 $
//
// Library: Util
// Package: Options
// Module: OptionProcessor
//
// Definition of the OptionProcessor class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_OptionProcessor_INCLUDED
#define Util_OptionProcessor_INCLUDED
#include "Poco/Util/Util.h"
#include <set>
namespace Poco {
namespace Util {
class OptionSet;
class Util_API OptionProcessor
/// An OptionProcessor is used to process the command line
/// arguments of an application.
///
/// The process() method takes an argument from the command line.
/// If that argument starts with an option prefix, the argument
/// is further processed. Otherwise, the argument is ignored and
/// false is ignored. The argument must match one of the options
/// given in the OptionSet that is passed to the OptionProcessor
/// with the constructor. If an option is part of a group, at most
/// one option of the group can be passed to the OptionProcessor.
/// Otherwise an IncompatibleOptionsException is thrown.
/// If the same option is given multiple times, but the option
/// is not repeatable, a DuplicateOptionException is thrown.
/// If the option is not recognized, a UnexpectedArgumentException
/// is thrown.
/// If the option requires an argument, but none is given, an
/// MissingArgumentException is thrown.
/// If no argument is expected, but one is present, a
/// UnexpectedArgumentException is thrown.
/// If a partial option name is ambiguous, an AmbiguousOptionException
/// is thrown.
///
/// The OptionProcessor supports two modes: Unix mode and default mode.
/// 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)
/// long option name.
/// In default mode, the option prefix is a slash '/', followed by
/// a (partial) long option name.
/// If the special option '--' is encountered in Unix mode, all following
/// options are ignored.
{
public:
OptionProcessor(const OptionSet& options);
/// Creates the OptionProcessor, using the given OptionSet.
~OptionProcessor();
/// Destroys the OptionProcessor.
void setUnixStyle(bool flag);
/// Enables (flag == true) or disables (flag == false) Unix-style
/// option processing.
///
/// If Unix-style processing is enabled, options are expected to
/// begin with a single or a double dash ('-' or '--', respectively).
/// A single dash must be followed by a short option name. A double
/// dash must be followed by a (partial) full option name.
///
/// If Unix-style processing is disabled, options are expected to
/// begin with a slash ('/'), followed by a (partial) full option name.
bool isUnixStyle() const;
/// Returns true iff Unix-style option processing is enabled.
bool process(const std::string& argument, std::string& optionName, std::string& optionArg);
/// Examines and processes the given command line argument.
///
/// 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
/// option argument, if present, is stored in optionArg.
///
/// If the option does not begin with an option prefix, false is returned.
void checkRequired() const;
/// Checks if all required options have been processed.
///
/// Does nothing if all required options have been processed.
/// Throws a MissingOptionException otherwise.
private:
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 processCommon(const std::string& option, bool isShort, std::string& optionName, std::string& optionArg);
const OptionSet& _options;
bool _unixStyle;
bool _ignore;
std::set<std::string> _groups;
std::set<std::string> _specifiedOptions;
};
//
// inlines
//
inline bool OptionProcessor::isUnixStyle() const
{
return _unixStyle;
}
} } // namespace Poco::Util
#endif // Util_OptionProcessor_INCLUDED
//
// OptionProcessor.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/OptionProcessor.h#1 $
//
// Library: Util
// Package: Options
// Module: OptionProcessor
//
// Definition of the OptionProcessor class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_OptionProcessor_INCLUDED
#define Util_OptionProcessor_INCLUDED
#include "Poco/Util/Util.h"
#include <set>
namespace Poco {
namespace Util {
class OptionSet;
class Util_API OptionProcessor
/// An OptionProcessor is used to process the command line
/// arguments of an application.
///
/// The process() method takes an argument from the command line.
/// If that argument starts with an option prefix, the argument
/// is further processed. Otherwise, the argument is ignored and
/// false is ignored. The argument must match one of the options
/// given in the OptionSet that is passed to the OptionProcessor
/// with the constructor. If an option is part of a group, at most
/// one option of the group can be passed to the OptionProcessor.
/// Otherwise an IncompatibleOptionsException is thrown.
/// If the same option is given multiple times, but the option
/// is not repeatable, a DuplicateOptionException is thrown.
/// If the option is not recognized, a UnexpectedArgumentException
/// is thrown.
/// If the option requires an argument, but none is given, an
/// MissingArgumentException is thrown.
/// If no argument is expected, but one is present, a
/// UnexpectedArgumentException is thrown.
/// If a partial option name is ambiguous, an AmbiguousOptionException
/// is thrown.
///
/// The OptionProcessor supports two modes: Unix mode and default mode.
/// 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)
/// long option name.
/// In default mode, the option prefix is a slash '/', followed by
/// a (partial) long option name.
/// If the special option '--' is encountered in Unix mode, all following
/// options are ignored.
{
public:
OptionProcessor(const OptionSet& options);
/// Creates the OptionProcessor, using the given OptionSet.
~OptionProcessor();
/// Destroys the OptionProcessor.
void setUnixStyle(bool flag);
/// Enables (flag == true) or disables (flag == false) Unix-style
/// option processing.
///
/// If Unix-style processing is enabled, options are expected to
/// begin with a single or a double dash ('-' or '--', respectively).
/// A single dash must be followed by a short option name. A double
/// dash must be followed by a (partial) full option name.
///
/// If Unix-style processing is disabled, options are expected to
/// begin with a slash ('/'), followed by a (partial) full option name.
bool isUnixStyle() const;
/// Returns true iff Unix-style option processing is enabled.
bool process(const std::string& argument, std::string& optionName, std::string& optionArg);
/// Examines and processes the given command line argument.
///
/// 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
/// option argument, if present, is stored in optionArg.
///
/// If the option does not begin with an option prefix, false is returned.
void checkRequired() const;
/// Checks if all required options have been processed.
///
/// Does nothing if all required options have been processed.
/// Throws a MissingOptionException otherwise.
private:
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 processCommon(const std::string& option, bool isShort, std::string& optionName, std::string& optionArg);
const OptionSet& _options;
bool _unixStyle;
bool _ignore;
std::set<std::string> _groups;
std::set<std::string> _specifiedOptions;
};
//
// inlines
//
inline bool OptionProcessor::isUnixStyle() const
{
return _unixStyle;
}
} } // namespace Poco::Util
#endif // Util_OptionProcessor_INCLUDED

View File

@ -1,110 +1,110 @@
//
// OptionSet.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/OptionSet.h#1 $
//
// Library: Util
// Package: Options
// Module: OptionSet
//
// Definition of the OptionSet class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_OptionSet_INCLUDED
#define Util_OptionSet_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/Option.h"
#include <vector>
namespace Poco {
namespace Util {
class Util_API OptionSet
/// A collection of Option objects.
{
public:
typedef std::vector<Option> OptionVec;
typedef OptionVec::const_iterator Iterator;
OptionSet();
/// Creates the OptionSet.
OptionSet(const OptionSet& options);
/// Creates an option set from another one.
~OptionSet();
/// Destroys the OptionSet.
OptionSet& operator = (const OptionSet& options);
/// Assignment operator.
void addOption(const Option& option);
/// Adds an option to the collection.
bool hasOption(const std::string& name, bool matchShort = false) const;
/// Returns a true iff an option with the given name exists.
///
/// The given name can either be a fully specified short name,
/// or a partially specified full name. If a partial name
/// matches more than one full name, false is returned.
/// The name must either match the short or full name of an
/// option. Comparison case sensitive for the short name and
/// not case sensitive for the full name.
const Option& getOption(const std::string& name, bool matchShort = false) const;
/// Returns a reference to the option with the given name.
///
/// The given name can either be a fully specified short name,
/// or a partially specified full name.
/// The name must either match the short or full name of an
/// option. Comparison case sensitive for the short name and
/// not case sensitive for the full name.
/// Throws a NotFoundException if no matching option has been found.
/// Throws an UnknownOptionException if a partial full name matches
/// more than one option.
Iterator begin() const;
/// Supports iterating over all options.
Iterator end() const;
/// Supports iterating over all options.
private:
OptionVec _options;
};
} } // namespace Poco::Util
#endif // Util_OptionSet_INCLUDED
//
// OptionSet.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/OptionSet.h#1 $
//
// Library: Util
// Package: Options
// Module: OptionSet
//
// Definition of the OptionSet class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_OptionSet_INCLUDED
#define Util_OptionSet_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/Option.h"
#include <vector>
namespace Poco {
namespace Util {
class Util_API OptionSet
/// A collection of Option objects.
{
public:
typedef std::vector<Option> OptionVec;
typedef OptionVec::const_iterator Iterator;
OptionSet();
/// Creates the OptionSet.
OptionSet(const OptionSet& options);
/// Creates an option set from another one.
~OptionSet();
/// Destroys the OptionSet.
OptionSet& operator = (const OptionSet& options);
/// Assignment operator.
void addOption(const Option& option);
/// Adds an option to the collection.
bool hasOption(const std::string& name, bool matchShort = false) const;
/// Returns a true iff an option with the given name exists.
///
/// The given name can either be a fully specified short name,
/// or a partially specified full name. If a partial name
/// matches more than one full name, false is returned.
/// The name must either match the short or full name of an
/// option. Comparison case sensitive for the short name and
/// not case sensitive for the full name.
const Option& getOption(const std::string& name, bool matchShort = false) const;
/// Returns a reference to the option with the given name.
///
/// The given name can either be a fully specified short name,
/// or a partially specified full name.
/// The name must either match the short or full name of an
/// option. Comparison case sensitive for the short name and
/// not case sensitive for the full name.
/// Throws a NotFoundException if no matching option has been found.
/// Throws an UnknownOptionException if a partial full name matches
/// more than one option.
Iterator begin() const;
/// Supports iterating over all options.
Iterator end() const;
/// Supports iterating over all options.
private:
OptionVec _options;
};
} } // namespace Poco::Util
#endif // Util_OptionSet_INCLUDED

View File

@ -1,121 +1,121 @@
//
// PropertyFileConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/PropertyFileConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: PropertyFileConfiguration
//
// Definition of the PropertyFileConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_PropertyFileConfiguration_INCLUDED
#define Util_PropertyFileConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/MapConfiguration.h"
#include <istream>
#include <ostream>
namespace Poco {
namespace Util {
class Util_API PropertyFileConfiguration: public MapConfiguration
/// This implementation of a Configuration reads properties
/// from a Java-style properties file.
///
/// The file syntax is implemented as follows.
/// - 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
/// <key> = <value> or
/// <key> : <value>
///
/// Keys and values may contain special characters represented by the following escape sequences:
/// - \t: tab (0x09)
/// - \n: line feed (0x0a)
/// - \r: carriage return (0x0d)
/// - \f: form feed (0x0c)
///
/// For every other sequence that starts with a backslash, the backslash is removed.
/// 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
/// immediately before the carriage return or line feed character) is a single backslash.
///
/// Property names are case sensitive. Leading and trailing whitespace is
/// removed from both keys and values. A property name can neither contain
/// a colon ':' nor an equal sign '=' character.
{
public:
PropertyFileConfiguration();
/// Creates an empty PropertyFileConfiguration.
PropertyFileConfiguration(std::istream& istr);
/// Creates an PropertyFileConfiguration and loads the configuration data
/// from the given stream, which must be in properties file format.
PropertyFileConfiguration(const std::string& path);
/// Creates an PropertyFileConfiguration and loads the configuration data
/// from the given file, which must be in properties file format.
void load(std::istream& istr);
/// Loads the configuration data from the given stream, which
/// must be in properties file format.
void load(const std::string& path);
/// Loads the configuration data from the given file, which
/// must be in properties file format.
void save(std::ostream& ostr) const;
/// Writes the configuration data to the given stream.
///
/// The data is written as a sequence of statements in the form
/// <key>: <value>
/// separated by a newline character.
void save(const std::string& path) const;
/// Writes the configuration data to the given file.
protected:
~PropertyFileConfiguration();
private:
void parseLine(std::istream& istr);
static int readChar(std::istream& istr);
};
} } // namespace Poco::Util
#endif // Util_PropertyFileConfiguration_INCLUDED
//
// PropertyFileConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/PropertyFileConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: PropertyFileConfiguration
//
// Definition of the PropertyFileConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_PropertyFileConfiguration_INCLUDED
#define Util_PropertyFileConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/MapConfiguration.h"
#include <istream>
#include <ostream>
namespace Poco {
namespace Util {
class Util_API PropertyFileConfiguration: public MapConfiguration
/// This implementation of a Configuration reads properties
/// from a Java-style properties file.
///
/// The file syntax is implemented as follows.
/// - 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
/// <key> = <value> or
/// <key> : <value>
///
/// Keys and values may contain special characters represented by the following escape sequences:
/// - \t: tab (0x09)
/// - \n: line feed (0x0a)
/// - \r: carriage return (0x0d)
/// - \f: form feed (0x0c)
///
/// For every other sequence that starts with a backslash, the backslash is removed.
/// 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
/// immediately before the carriage return or line feed character) is a single backslash.
///
/// Property names are case sensitive. Leading and trailing whitespace is
/// removed from both keys and values. A property name can neither contain
/// a colon ':' nor an equal sign '=' character.
{
public:
PropertyFileConfiguration();
/// Creates an empty PropertyFileConfiguration.
PropertyFileConfiguration(std::istream& istr);
/// Creates an PropertyFileConfiguration and loads the configuration data
/// from the given stream, which must be in properties file format.
PropertyFileConfiguration(const std::string& path);
/// Creates an PropertyFileConfiguration and loads the configuration data
/// from the given file, which must be in properties file format.
void load(std::istream& istr);
/// Loads the configuration data from the given stream, which
/// must be in properties file format.
void load(const std::string& path);
/// Loads the configuration data from the given file, which
/// must be in properties file format.
void save(std::ostream& ostr) const;
/// Writes the configuration data to the given stream.
///
/// The data is written as a sequence of statements in the form
/// <key>: <value>
/// separated by a newline character.
void save(const std::string& path) const;
/// Writes the configuration data to the given file.
protected:
~PropertyFileConfiguration();
private:
void parseLine(std::istream& istr);
static int readChar(std::istream& istr);
};
} } // namespace Poco::Util
#endif // Util_PropertyFileConfiguration_INCLUDED

View File

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

View File

@ -1,214 +1,214 @@
//
// ServerApplication.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/ServerApplication.h#1 $
//
// Library: Util
// Package: Application
// Module: ServerApplication
//
// Definition of the ServerApplication class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_ServerApplication_INCLUDED
#define Util_ServerApplication_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/Application.h"
#include "Poco/Event.h"
namespace Poco {
namespace Util {
class Util_API ServerApplication: public Application
/// A subclass of the Application class that is used
/// for implementing server applications.
///
/// A ServerApplication allows for the application
/// to run as a Windows service or as a Unix daemon
/// without the need to add extra code.
///
/// For a ServerApplication to work both from the command line
/// and as a daemon or service, a few rules must be met:
/// - Subsystems must be registered in the constructor.
/// - All non-trivial initializations must be made in the
/// initialize() method.
/// - At the end of the main() method, waitForTerminationRequest()
/// should be called.
/// - The main(argc, argv) function must look as follows:
///
/// int main(int argc, char** argv)
/// {
/// MyServerApplication app;
/// return app.run(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
/// Unicode command line arguments.
///
/// On Windows platforms, an application built on top of the
/// ServerApplication class can be run both from the command line
/// or as a service.
///
/// To run an application as a Windows service, it must be registered
/// with the Windows Service Control Manager (SCM). To do this, the application
/// can be started from the command line, with the /registerService option
/// specified. This causes the application to register itself with the
/// SCM, and then exit. Similarly, an application registered as a service can
/// be unregistered, by specifying the /unregisterService option.
/// 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
/// specified, using the /displayName option (e.g., /displayName="Demo Service").
///
/// An application can determine whether it is running as a service by checking
/// for the "application.runAsService" configuration property.
///
/// if (config().getBool("application.runAsService", false))
/// {
/// // do service specific things
/// }
///
/// Note that the working directory for an application running as a service
/// is the Windows system directory (e.g., C:\Windows\system32). Take this
/// into account when working with relative filesystem paths.
///
/// An application registered as a Windows service can be started
/// with the NET START <name> command and stopped with the NET STOP <name>
/// command. Alternatively, the Services MMC applet can be used.
///
/// On Unix platforms, an application built on top of the ServerApplication
/// 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
/// the background process, the foreground process exits.
///
/// After the initialization is complete, but before entering the main() method,
/// the current working directory for the daemon process is changed to the root
/// directory ("/"), as it is common practice for daemon processes. Therefore, be
/// careful when working with files, as relative paths may not point to where
/// you expect them point to.
///
/// An application can determine whether it is running as a daemon by checking
/// for the "application.runAsDaemon" configuration property.
///
/// if (config().getBool("application.runAsDaemon", false))
/// {
/// // do daemon specific things
/// }
{
public:
ServerApplication();
/// Creates the ServerApplication.
~ServerApplication();
/// Destroys the ServerApplication.
bool isInteractive() const;
/// Returns true if the application runs from the command line.
/// Returns false if the application runs as a Unix daemon
/// or Windows service.
int run(int argc, char** argv);
/// Runs the application by performing additional initializations
/// and calling the main() method.
#if defined(POCO_WIN32_UTF8)
int run(int argc, wchar_t** argv);
/// Runs the application by performing additional initializations
/// and calling the main() method.
///
/// This Windows-specific version of init is used for passing
/// Unicode command line arguments from wmain().
#endif
protected:
int run();
void waitForTerminationRequest();
void defineOptions(OptionSet& options);
void handleOption(const std::string& name, const std::string& value);
static void terminate();
private:
#if defined(POCO_OS_FAMILY_UNIX)
bool isDaemon(int argc, char** argv);
void beDaemon();
#elif defined(POCO_OS_FAMILY_WINDOWS)
enum Action
{
SRV_RUN,
SRV_REGISTER,
SRV_UNREGISTER
};
static BOOL __stdcall ConsoleCtrlHandler(DWORD ctrlType);
static void __stdcall ServiceControlHandler(DWORD control);
static void __stdcall ServiceMain(DWORD argc, LPTSTR* argv);
bool hasConsole();
bool isService();
void beService();
void registerService();
void unregisterService();
Action _action;
std::string _displayName;
static Poco::Event _terminated;
static SERVICE_STATUS _serviceStatus;
static SERVICE_STATUS_HANDLE _serviceStatusHandle;
#endif
};
} } // namespace Poco::Util
//
// Macro to implement main()
//
#if defined(POCO_WIN32_UTF8)
#define POCO_SERVER_MAIN(App) \
int wmain(int argc, wchar_t** argv) \
{ \
App app; \
return app.run(argc, argv); \
}
#else
#define POCO_SERVER_MAIN(App) \
int main(int argc, char** argv) \
{ \
App app; \
return app.run(argc, argv); \
}
#endif
#endif // Util_ServerApplication_INCLUDED
//
// ServerApplication.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/ServerApplication.h#1 $
//
// Library: Util
// Package: Application
// Module: ServerApplication
//
// Definition of the ServerApplication class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_ServerApplication_INCLUDED
#define Util_ServerApplication_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/Application.h"
#include "Poco/Event.h"
namespace Poco {
namespace Util {
class Util_API ServerApplication: public Application
/// A subclass of the Application class that is used
/// for implementing server applications.
///
/// A ServerApplication allows for the application
/// to run as a Windows service or as a Unix daemon
/// without the need to add extra code.
///
/// For a ServerApplication to work both from the command line
/// and as a daemon or service, a few rules must be met:
/// - Subsystems must be registered in the constructor.
/// - All non-trivial initializations must be made in the
/// initialize() method.
/// - At the end of the main() method, waitForTerminationRequest()
/// should be called.
/// - The main(argc, argv) function must look as follows:
///
/// int main(int argc, char** argv)
/// {
/// MyServerApplication app;
/// return app.run(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
/// Unicode command line arguments.
///
/// On Windows platforms, an application built on top of the
/// ServerApplication class can be run both from the command line
/// or as a service.
///
/// To run an application as a Windows service, it must be registered
/// with the Windows Service Control Manager (SCM). To do this, the application
/// can be started from the command line, with the /registerService option
/// specified. This causes the application to register itself with the
/// SCM, and then exit. Similarly, an application registered as a service can
/// be unregistered, by specifying the /unregisterService option.
/// 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
/// specified, using the /displayName option (e.g., /displayName="Demo Service").
///
/// An application can determine whether it is running as a service by checking
/// for the "application.runAsService" configuration property.
///
/// if (config().getBool("application.runAsService", false))
/// {
/// // do service specific things
/// }
///
/// Note that the working directory for an application running as a service
/// is the Windows system directory (e.g., C:\Windows\system32). Take this
/// into account when working with relative filesystem paths.
///
/// An application registered as a Windows service can be started
/// with the NET START <name> command and stopped with the NET STOP <name>
/// command. Alternatively, the Services MMC applet can be used.
///
/// On Unix platforms, an application built on top of the ServerApplication
/// 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
/// the background process, the foreground process exits.
///
/// After the initialization is complete, but before entering the main() method,
/// the current working directory for the daemon process is changed to the root
/// directory ("/"), as it is common practice for daemon processes. Therefore, be
/// careful when working with files, as relative paths may not point to where
/// you expect them point to.
///
/// An application can determine whether it is running as a daemon by checking
/// for the "application.runAsDaemon" configuration property.
///
/// if (config().getBool("application.runAsDaemon", false))
/// {
/// // do daemon specific things
/// }
{
public:
ServerApplication();
/// Creates the ServerApplication.
~ServerApplication();
/// Destroys the ServerApplication.
bool isInteractive() const;
/// Returns true if the application runs from the command line.
/// Returns false if the application runs as a Unix daemon
/// or Windows service.
int run(int argc, char** argv);
/// Runs the application by performing additional initializations
/// and calling the main() method.
#if defined(POCO_WIN32_UTF8)
int run(int argc, wchar_t** argv);
/// Runs the application by performing additional initializations
/// and calling the main() method.
///
/// This Windows-specific version of init is used for passing
/// Unicode command line arguments from wmain().
#endif
protected:
int run();
void waitForTerminationRequest();
void defineOptions(OptionSet& options);
void handleOption(const std::string& name, const std::string& value);
static void terminate();
private:
#if defined(POCO_OS_FAMILY_UNIX)
bool isDaemon(int argc, char** argv);
void beDaemon();
#elif defined(POCO_OS_FAMILY_WINDOWS)
enum Action
{
SRV_RUN,
SRV_REGISTER,
SRV_UNREGISTER
};
static BOOL __stdcall ConsoleCtrlHandler(DWORD ctrlType);
static void __stdcall ServiceControlHandler(DWORD control);
static void __stdcall ServiceMain(DWORD argc, LPTSTR* argv);
bool hasConsole();
bool isService();
void beService();
void registerService();
void unregisterService();
Action _action;
std::string _displayName;
static Poco::Event _terminated;
static SERVICE_STATUS _serviceStatus;
static SERVICE_STATUS_HANDLE _serviceStatusHandle;
#endif
};
} } // namespace Poco::Util
//
// Macro to implement main()
//
#if defined(POCO_WIN32_UTF8)
#define POCO_SERVER_MAIN(App) \
int wmain(int argc, wchar_t** argv) \
{ \
App app; \
return app.run(argc, argv); \
}
#else
#define POCO_SERVER_MAIN(App) \
int main(int argc, char** argv) \
{ \
App app; \
return app.run(argc, argv); \
}
#endif
#endif // Util_ServerApplication_INCLUDED

View File

@ -1,105 +1,105 @@
//
// Subsystem.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/Subsystem.h#1 $
//
// Library: Util
// Package: Application
// Module: Subsystem
//
// Definition of the Subsystem class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_Subsystem_INCLUDED
#define Util_Subsystem_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/RefCountedObject.h"
namespace Poco {
namespace Util {
class Application;
class Util_API Subsystem: public Poco::RefCountedObject
/// Subsystems extend an application in a modular way.
///
/// The Subsystem class provides a common interface
/// for subsystems so that subsystems can be automatically
/// initialized at startup and uninitialized at shutdown.
///
/// Subsystems should also support dynamic reconfiguration,
/// so that they can be reconfigured anytime during the
/// life of a running application.
///
/// The degree to which dynamic reconfiguration is supported
/// is up to the actual subsystem implementation. It can
/// range from ignoring the reconfiguration request (not
/// recommended), to changing certain settings that affect
/// the performance, to a complete reinitialization.
{
public:
Subsystem();
/// Creates the Subsystem.
protected:
virtual const char* name() const = 0;
/// Returns the name of the subsystem.
/// Must be implemented by subclasses.
virtual void initialize(Application& app) = 0;
/// Initializes the subsystem.
virtual void uninitialize() = 0;
/// Uninitializes the subsystem.
virtual void reinitialize(Application& app);
/// Re-initializes the subsystem.
///
/// The default implementation just calls
/// uninitialize() followed by initialize().
/// Actual implementations might want to use a
/// less radical and possibly more performant
/// approach.
virtual ~Subsystem();
/// Destroys the Subsystem.
friend class Application;
};
} } // namespace Poco::Util
#endif // Util_Subsystem_INCLUDED
//
// Subsystem.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/Subsystem.h#1 $
//
// Library: Util
// Package: Application
// Module: Subsystem
//
// Definition of the Subsystem class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_Subsystem_INCLUDED
#define Util_Subsystem_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/RefCountedObject.h"
namespace Poco {
namespace Util {
class Application;
class Util_API Subsystem: public Poco::RefCountedObject
/// Subsystems extend an application in a modular way.
///
/// The Subsystem class provides a common interface
/// for subsystems so that subsystems can be automatically
/// initialized at startup and uninitialized at shutdown.
///
/// Subsystems should also support dynamic reconfiguration,
/// so that they can be reconfigured anytime during the
/// life of a running application.
///
/// The degree to which dynamic reconfiguration is supported
/// is up to the actual subsystem implementation. It can
/// range from ignoring the reconfiguration request (not
/// recommended), to changing certain settings that affect
/// the performance, to a complete reinitialization.
{
public:
Subsystem();
/// Creates the Subsystem.
protected:
virtual const char* name() const = 0;
/// Returns the name of the subsystem.
/// Must be implemented by subclasses.
virtual void initialize(Application& app) = 0;
/// Initializes the subsystem.
virtual void uninitialize() = 0;
/// Uninitializes the subsystem.
virtual void reinitialize(Application& app);
/// Re-initializes the subsystem.
///
/// The default implementation just calls
/// uninitialize() followed by initialize().
/// Actual implementations might want to use a
/// less radical and possibly more performant
/// approach.
virtual ~Subsystem();
/// Destroys the Subsystem.
friend class Application;
};
} } // namespace Poco::Util
#endif // Util_Subsystem_INCLUDED

View File

@ -1,98 +1,98 @@
//
// SystemConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/SystemConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: SystemConfiguration
//
// Definition of the SystemConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_SystemConfiguration_INCLUDED
#define Util_SystemConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
namespace Poco {
namespace Util {
class Util_API SystemConfiguration: public AbstractConfiguration
/// This class implements a Configuration interface to
/// various system properties and environment variables.
///
/// The following properties are supported:
/// - system.osName: the operating system name
/// - system.osVersion: the operating system version
/// - system.osArchitecture: the operating system architecture
/// - system.nodeName: the node (or host) name
/// - system.currentDir: the current working directory
/// - system.homeDir: the user's home directory
/// - system.tempDir: the system's temporary directory
/// - system.env.<NAME>: the environment variable with the given <NAME>.
///
/// An attempt to set a system variable will result in an
/// InvalidAccessException being thrown.
///
/// Enumerating environment variables is not supported.
/// An attemp to call keys("system.env") will return an empty range.
{
public:
SystemConfiguration();
/// Creates the SystemConfiguration.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
~SystemConfiguration();
private:
static bool getEnv(const std::string& name, std::string& value);
static const std::string OSNAME;
static const std::string OSVERSION;
static const std::string OSARCHITECTURE;
static const std::string NODENAME;
static const std::string CURRENTDIR;
static const std::string HOMEDIR;
static const std::string TEMPDIR;
static const std::string ENV;
};
} } // namespace Poco::Util
#endif // Util_SystemConfiguration_INCLUDED
//
// SystemConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/SystemConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: SystemConfiguration
//
// Definition of the SystemConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_SystemConfiguration_INCLUDED
#define Util_SystemConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
namespace Poco {
namespace Util {
class Util_API SystemConfiguration: public AbstractConfiguration
/// This class implements a Configuration interface to
/// various system properties and environment variables.
///
/// The following properties are supported:
/// - system.osName: the operating system name
/// - system.osVersion: the operating system version
/// - system.osArchitecture: the operating system architecture
/// - system.nodeName: the node (or host) name
/// - system.currentDir: the current working directory
/// - system.homeDir: the user's home directory
/// - system.tempDir: the system's temporary directory
/// - system.env.<NAME>: the environment variable with the given <NAME>.
///
/// An attempt to set a system variable will result in an
/// InvalidAccessException being thrown.
///
/// Enumerating environment variables is not supported.
/// An attemp to call keys("system.env") will return an empty range.
{
public:
SystemConfiguration();
/// Creates the SystemConfiguration.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
~SystemConfiguration();
private:
static bool getEnv(const std::string& name, std::string& value);
static const std::string OSNAME;
static const std::string OSVERSION;
static const std::string OSARCHITECTURE;
static const std::string NODENAME;
static const std::string CURRENTDIR;
static const std::string HOMEDIR;
static const std::string TEMPDIR;
static const std::string ENV;
};
} } // namespace Poco::Util
#endif // Util_SystemConfiguration_INCLUDED

View File

@ -1,70 +1,70 @@
//
// Util.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/Util.h#1 $
//
// Library: Util
// Package: Util
// Module: Util
//
// Basic definitions for the Poco Util library.
// This file must be the first file included by every other Util
// header file.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_Util_INCLUDED
#define Util_Util_INCLUDED
#include "Poco/Foundation.h"
//
// The following block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the Util_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// Util_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
//
#if defined(_WIN32) && defined(POCO_DLL)
#if defined(Util_EXPORTS)
#define Util_API __declspec(dllexport)
#else
#define Util_API __declspec(dllimport)
#endif
#endif
#if !defined(Util_API)
#define Util_API
#endif
#endif // Util_Util_INCLUDED
//
// Util.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/Util.h#1 $
//
// Library: Util
// Package: Util
// Module: Util
//
// Basic definitions for the Poco Util library.
// This file must be the first file included by every other Util
// header file.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_Util_INCLUDED
#define Util_Util_INCLUDED
#include "Poco/Foundation.h"
//
// The following block is the standard way of creating macros which make exporting
// from a DLL simpler. All files within this DLL are compiled with the Util_EXPORTS
// symbol defined on the command line. this symbol should not be defined on any project
// that uses this DLL. This way any other project whose source files include this file see
// Util_API functions as being imported from a DLL, wheras this DLL sees symbols
// defined with this macro as being exported.
//
#if defined(_WIN32) && defined(POCO_DLL)
#if defined(Util_EXPORTS)
#define Util_API __declspec(dllexport)
#else
#define Util_API __declspec(dllimport)
#endif
#endif
#if !defined(Util_API)
#define Util_API
#endif
#endif // Util_Util_INCLUDED

View File

@ -1,79 +1,79 @@
//
// Validator.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/Validator.h#1 $
//
// Library: Util
// Package: Options
// Module: Validator
//
// Definition of the Validator class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_Validator_INCLUDED
#define Util_Validator_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/RefCountedObject.h"
namespace Poco {
namespace Util {
class Option;
class Util_API Validator: public Poco::RefCountedObject
/// Validator specifies the interface for option validators.
///
/// Option validators provide a simple way for the automatic
/// validation of command line argument values.
{
public:
virtual void validate(const Option& option, const std::string& value) = 0;
/// Validates the value for the given option.
/// Does nothing if the value is valid.
///
/// Throws an InvalidOptionException otherwise.
protected:
Validator();
/// Creates the Validator.
virtual ~Validator();
/// Destroys the Validator.
};
} } // namespace Poco::Util
#endif // Util_Validator_INCLUDED
//
// Validator.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/Validator.h#1 $
//
// Library: Util
// Package: Options
// Module: Validator
//
// Definition of the Validator class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_Validator_INCLUDED
#define Util_Validator_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/RefCountedObject.h"
namespace Poco {
namespace Util {
class Option;
class Util_API Validator: public Poco::RefCountedObject
/// Validator specifies the interface for option validators.
///
/// Option validators provide a simple way for the automatic
/// validation of command line argument values.
{
public:
virtual void validate(const Option& option, const std::string& value) = 0;
/// Validates the value for the given option.
/// Does nothing if the value is valid.
///
/// Throws an InvalidOptionException otherwise.
protected:
Validator();
/// Creates the Validator.
virtual ~Validator();
/// Destroys the Validator.
};
} } // namespace Poco::Util
#endif // Util_Validator_INCLUDED

View File

@ -1,97 +1,97 @@
//
// WinRegistryConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/WinRegistryConfiguration.h#1 $
//
// Library: Util
// Package: Windows
// Module: WinRegistryConfiguration
//
// Definition of the WinRegistryConfiguration class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_WinRegistryConfiguration_INCLUDED
#define Util_WinRegistryConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/String.h"
namespace Poco {
namespace Util {
class Util_API WinRegistryConfiguration: public AbstractConfiguration
/// An implementation of AbstractConfiguration that stores configuration data
/// in the Windows registry.
{
public:
WinRegistryConfiguration(const std::string& rootPath);
/// Creates the WinRegistryConfiguration.
/// The rootPath must start with one of the root key names
/// like HKEY_CLASSES_ROOT, e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.
/// All further keys are relativ to the root path and can be
/// dot seperated, e.g. the path MyService.ServiceName will be converted to
/// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\ServiceName.
bool getRaw(const std::string& key, std::string& value) const;
/// If the property with the given key exists, stores the property's value
/// in value and returns true. Otherwise, returns false.
///
/// Must be overridden by subclasses.
void setRaw(const std::string& key, const std::string& value);
/// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten.
///
/// Must be overridden by subclasses.
void enumerate(const std::string& key, Keys& range) const;
/// Returns in range the names of all subkeys under the given key.
/// If an empty key is passed, all root level keys are returned.
protected:
~WinRegistryConfiguration();
/// Destroys the WinRegistryConfiguration.
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
/// registry format A\B\C, the last entry is the keyName, the rest is returned as path
private:
std::string _rootPath;
};
} } // namespace Poco::Util
#endif // Util_WinRegistryConfiguration_INCLUDED
//
// WinRegistryConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/WinRegistryConfiguration.h#1 $
//
// Library: Util
// Package: Windows
// Module: WinRegistryConfiguration
//
// Definition of the WinRegistryConfiguration class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_WinRegistryConfiguration_INCLUDED
#define Util_WinRegistryConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/String.h"
namespace Poco {
namespace Util {
class Util_API WinRegistryConfiguration: public AbstractConfiguration
/// An implementation of AbstractConfiguration that stores configuration data
/// in the Windows registry.
{
public:
WinRegistryConfiguration(const std::string& rootPath);
/// Creates the WinRegistryConfiguration.
/// The rootPath must start with one of the root key names
/// like HKEY_CLASSES_ROOT, e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.
/// All further keys are relativ to the root path and can be
/// dot seperated, e.g. the path MyService.ServiceName will be converted to
/// HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MyService\ServiceName.
bool getRaw(const std::string& key, std::string& value) const;
/// If the property with the given key exists, stores the property's value
/// in value and returns true. Otherwise, returns false.
///
/// Must be overridden by subclasses.
void setRaw(const std::string& key, const std::string& value);
/// Sets the property with the given key to the given value.
/// An already existing value for the key is overwritten.
///
/// Must be overridden by subclasses.
void enumerate(const std::string& key, Keys& range) const;
/// Returns in range the names of all subkeys under the given key.
/// If an empty key is passed, all root level keys are returned.
protected:
~WinRegistryConfiguration();
/// Destroys the WinRegistryConfiguration.
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
/// registry format A\B\C, the last entry is the keyName, the rest is returned as path
private:
std::string _rootPath;
};
} } // namespace Poco::Util
#endif // Util_WinRegistryConfiguration_INCLUDED

View File

@ -1,159 +1,159 @@
//
// WinRegistryKey.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/WinRegistryKey.h#1 $
//
// Library: Util
// Package: Windows
// Module: WinRegistryKey
//
// Definition of the WinRegistryKey class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_WinRegistryKey_INCLUDED
#define Util_WinRegistryKey_INCLUDED
#include "Poco/Util/Util.h"
#include <windows.h>
#include <vector>
namespace Poco {
namespace Util {
class Util_API WinRegistryKey
/// This class implements a convenient interface to the
/// Windows Registry.
///
/// This class is only available on Windows platforms.
{
public:
typedef std::vector<std::string> Keys;
typedef std::vector<std::string> Values;
enum Type
{
REGT_NONE = 0,
REGT_STRING = 1,
REGT_STRING_EXPAND = 2,
REGT_DWORD = 4
};
WinRegistryKey(const std::string& key);
/// Creates the WinRegistryKey.
///
/// The key must start with one of the root key names
/// like HKEY_CLASSES_ROOT, e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.
WinRegistryKey(HKEY hRootKey, const std::string& subKey);
/// Creates the WinRegistryKey.
~WinRegistryKey();
/// Destroys the WinRegistryKey.
void setString(const std::string& name, const std::string& value);
/// Sets the string value (REG_SZ) with the given name.
/// An empty name denotes the default value.
std::string getString(const std::string& name);
/// Returns the string value (REG_SZ) with the given name.
/// An empty name denotes the default value.
///
/// Throws a NotFoundException if the value does not exist.
void setStringExpand(const std::string& name, const std::string& value);
/// Sets the expandable string value (REG_EXPAND_SZ) with the given name.
/// An empty name denotes the default value.
std::string getStringExpand(const std::string& name);
/// Returns the string value (REG_EXPAND_SZ) with the given name.
/// An empty name denotes the default value.
/// All references to environment variables (%VAR%) in the string
/// are expanded.
///
/// Throws a NotFoundException if the value does not exist.
void setInt(const std::string& name, int value);
/// Sets the numeric (REG_DWORD) value with the given name.
/// An empty name denotes the default value.
int getInt(const std::string& name);
/// Returns the numeric value (REG_DWORD) with the given name.
/// An empty name denotes the default value.
///
/// Throws a NotFoundException if the value does not exist.
void deleteValue(const std::string& name);
/// Deletes the value with the given name.
///
/// Throws a NotFoundException if the value does not exist.
void deleteKey();
/// Deletes the key. The key must not have subkeys.
bool exists();
/// Returns true iff the key exists.
Type type(const std::string& name);
/// Returns the type of the key value.
bool exists(const std::string& name);
/// Returns true iff the given value exists under that key.
void subKeys(Keys& keys);
/// Appends all subKey names to keys.
void values(Values& vals);
/// Appends all value names to vals;
protected:
void open();
void close();
std::string key() const;
std::string key(const std::string& valueName) const;
void handleSetError(const std::string& name);
static HKEY handleFor(const std::string& rootKey);
private:
WinRegistryKey();
WinRegistryKey(const WinRegistryKey&);
WinRegistryKey& operator = (const WinRegistryKey&);
HKEY _hRootKey;
std::string _subKey;
HKEY _hKey;
};
} } // namespace Poco::Util
#endif // Util_WinRegistryKey_INCLUDED
//
// WinRegistryKey.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/WinRegistryKey.h#1 $
//
// Library: Util
// Package: Windows
// Module: WinRegistryKey
//
// Definition of the WinRegistryKey class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_WinRegistryKey_INCLUDED
#define Util_WinRegistryKey_INCLUDED
#include "Poco/Util/Util.h"
#include <windows.h>
#include <vector>
namespace Poco {
namespace Util {
class Util_API WinRegistryKey
/// This class implements a convenient interface to the
/// Windows Registry.
///
/// This class is only available on Windows platforms.
{
public:
typedef std::vector<std::string> Keys;
typedef std::vector<std::string> Values;
enum Type
{
REGT_NONE = 0,
REGT_STRING = 1,
REGT_STRING_EXPAND = 2,
REGT_DWORD = 4
};
WinRegistryKey(const std::string& key);
/// Creates the WinRegistryKey.
///
/// The key must start with one of the root key names
/// like HKEY_CLASSES_ROOT, e.g. HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services.
WinRegistryKey(HKEY hRootKey, const std::string& subKey);
/// Creates the WinRegistryKey.
~WinRegistryKey();
/// Destroys the WinRegistryKey.
void setString(const std::string& name, const std::string& value);
/// Sets the string value (REG_SZ) with the given name.
/// An empty name denotes the default value.
std::string getString(const std::string& name);
/// Returns the string value (REG_SZ) with the given name.
/// An empty name denotes the default value.
///
/// Throws a NotFoundException if the value does not exist.
void setStringExpand(const std::string& name, const std::string& value);
/// Sets the expandable string value (REG_EXPAND_SZ) with the given name.
/// An empty name denotes the default value.
std::string getStringExpand(const std::string& name);
/// Returns the string value (REG_EXPAND_SZ) with the given name.
/// An empty name denotes the default value.
/// All references to environment variables (%VAR%) in the string
/// are expanded.
///
/// Throws a NotFoundException if the value does not exist.
void setInt(const std::string& name, int value);
/// Sets the numeric (REG_DWORD) value with the given name.
/// An empty name denotes the default value.
int getInt(const std::string& name);
/// Returns the numeric value (REG_DWORD) with the given name.
/// An empty name denotes the default value.
///
/// Throws a NotFoundException if the value does not exist.
void deleteValue(const std::string& name);
/// Deletes the value with the given name.
///
/// Throws a NotFoundException if the value does not exist.
void deleteKey();
/// Deletes the key. The key must not have subkeys.
bool exists();
/// Returns true iff the key exists.
Type type(const std::string& name);
/// Returns the type of the key value.
bool exists(const std::string& name);
/// Returns true iff the given value exists under that key.
void subKeys(Keys& keys);
/// Appends all subKey names to keys.
void values(Values& vals);
/// Appends all value names to vals;
protected:
void open();
void close();
std::string key() const;
std::string key(const std::string& valueName) const;
void handleSetError(const std::string& name);
static HKEY handleFor(const std::string& rootKey);
private:
WinRegistryKey();
WinRegistryKey(const WinRegistryKey&);
WinRegistryKey& operator = (const WinRegistryKey&);
HKEY _hRootKey;
std::string _subKey;
HKEY _hKey;
};
} } // namespace Poco::Util
#endif // Util_WinRegistryKey_INCLUDED

View File

@ -1,146 +1,146 @@
//
// WinService.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/WinService.h#1 $
//
// Library: Util
// Package: Windows
// Module: WinService
//
// Definition of the WinService class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_WinService_INCLUDED
#define Util_WinService_INCLUDED
#include "Poco/Util/Util.h"
#include <windows.h>
namespace Poco {
namespace Util {
class Util_API WinService
/// This class provides an object-oriented interface to
/// the Windows Service Control Manager for registering,
/// unregistering, configuring, starting and stopping
/// services.
///
/// This class is only available on Windows platforms.
{
public:
enum Startup
{
SVC_AUTO_START,
SVC_MANUAL_START,
SVC_DISABLED
};
WinService(const std::string& name);
/// Creates the WinService, using the given service name.
~WinService();
/// Destroys the WinService.
const std::string& name() const;
/// Returns the service name.
std::string displayName() const;
/// Returns the service's display name.
std::string path() const;
/// Returns the path to the service executable.
///
/// Throws a NotFoundException if the service has not been registered.
void registerService(const std::string& path, const std::string& displayName);
/// Creates a Windows service with the executable specified by path
/// and the given displayName.
///
/// Throws a ExistsException if the service has already been registered.
void registerService(const std::string& path);
/// Creates a Windows service with the executable specified by path
/// and the given displayName. The service name is used as display name.
///
/// Throws a ExistsException if the service has already been registered.
void unregisterService();
/// Deletes the Windows service.
///
/// Throws a NotFoundException if the service has not been registered.
bool isRegistered() const;
/// Returns true if the service has been registered with the Service Control Manager.
bool isRunning() const;
/// Returns true if the service is currently running.
void start();
/// Starts the service.
/// Does nothing if the service is already running.
///
/// Throws a NotFoundException if the service has not been registered.
void stop();
/// Stops the service.
/// Does nothing if the service is not running.
///
/// Throws a NotFoundException if the service has not been registered.
void setStartup(Startup startup);
/// Sets the startup mode for the service.
Startup getStartup() const;
/// Returns the startup mode for the service.
static const int STARTUP_TIMEOUT;
private:
void open() const;
bool tryOpen() const;
void close() const;
LPQUERY_SERVICE_CONFIG config() const;
WinService();
WinService(const WinService&);
WinService& operator = (const WinService&);
std::string _name;
SC_HANDLE _scmHandle;
mutable SC_HANDLE _svcHandle;
};
} } // namespace Poco::Util
#endif // Util_WinService_INCLUDED
//
// WinService.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/WinService.h#1 $
//
// Library: Util
// Package: Windows
// Module: WinService
//
// Definition of the WinService class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_WinService_INCLUDED
#define Util_WinService_INCLUDED
#include "Poco/Util/Util.h"
#include <windows.h>
namespace Poco {
namespace Util {
class Util_API WinService
/// This class provides an object-oriented interface to
/// the Windows Service Control Manager for registering,
/// unregistering, configuring, starting and stopping
/// services.
///
/// This class is only available on Windows platforms.
{
public:
enum Startup
{
SVC_AUTO_START,
SVC_MANUAL_START,
SVC_DISABLED
};
WinService(const std::string& name);
/// Creates the WinService, using the given service name.
~WinService();
/// Destroys the WinService.
const std::string& name() const;
/// Returns the service name.
std::string displayName() const;
/// Returns the service's display name.
std::string path() const;
/// Returns the path to the service executable.
///
/// Throws a NotFoundException if the service has not been registered.
void registerService(const std::string& path, const std::string& displayName);
/// Creates a Windows service with the executable specified by path
/// and the given displayName.
///
/// Throws a ExistsException if the service has already been registered.
void registerService(const std::string& path);
/// Creates a Windows service with the executable specified by path
/// and the given displayName. The service name is used as display name.
///
/// Throws a ExistsException if the service has already been registered.
void unregisterService();
/// Deletes the Windows service.
///
/// Throws a NotFoundException if the service has not been registered.
bool isRegistered() const;
/// Returns true if the service has been registered with the Service Control Manager.
bool isRunning() const;
/// Returns true if the service is currently running.
void start();
/// Starts the service.
/// Does nothing if the service is already running.
///
/// Throws a NotFoundException if the service has not been registered.
void stop();
/// Stops the service.
/// Does nothing if the service is not running.
///
/// Throws a NotFoundException if the service has not been registered.
void setStartup(Startup startup);
/// Sets the startup mode for the service.
Startup getStartup() const;
/// Returns the startup mode for the service.
static const int STARTUP_TIMEOUT;
private:
void open() const;
bool tryOpen() const;
void close() const;
LPQUERY_SERVICE_CONFIG config() const;
WinService();
WinService(const WinService&);
WinService& operator = (const WinService&);
std::string _name;
SC_HANDLE _scmHandle;
mutable SC_HANDLE _svcHandle;
};
} } // namespace Poco::Util
#endif // Util_WinService_INCLUDED

View File

@ -1,156 +1,156 @@
//
// XMLConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/XMLConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: XMLConfiguration
//
// Definition of the XMLConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_XMLConfiguration_INCLUDED
#define Util_XMLConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/MapConfiguration.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/AutoPtr.h"
#include "Poco/SAX/InputSource.h"
#include <istream>
namespace Poco {
namespace Util {
class Util_API XMLConfiguration: public AbstractConfiguration
/// This configuration class extracts configuration properties
/// from an XML document. An XPath-like syntax for property
/// names is supported to allow full access to the XML document.
/// XML namespaces are not supported. The name of the root element
/// of an XML document is not significant. Periods in tag names
/// are not supported.
///
/// Given the following XML document as an example:
///
/// <config>
/// <prop1>value1</prop1>
/// <prop2>value2</prop2>
/// <prop3>
/// <prop4 attr="value3"/>
/// <prop4 attr="value4"/>
/// </prop3>
/// <prop5>value5</prop5>
/// <prop5>value6</prop5>
/// </config>
///
/// The following property names would be valid and would
/// yield the shown values:
///
/// prop1 -> value1
/// prop2 -> value2
/// prop3.prop4 -> (empty string)
/// prop3.prop4[@attr] -> value3
/// prop3.prop4[1][@attr] -> value4
/// prop5[0] -> value5
/// prop5[1] -> value6
///
/// Enumerating attributes is not supported.
/// Calling keys("prop3.prop4") will return an empty range.
///
/// Setting properties is not supported. An attempt to set a property results
/// in a NotImplementedException being thrown.
{
public:
XMLConfiguration();
/// Creates an empty XMLConfiguration.
XMLConfiguration(Poco::XML::InputSource* pInputSource);
/// Creates an XMLConfiguration and loads the XML document from
/// the given InputSource.
XMLConfiguration(std::istream& istr);
/// Creates an XMLConfiguration and loads the XML document from
/// the given stream.
XMLConfiguration(const std::string& path);
/// Creates an XMLConfiguration and loads the XML document from
/// the given path.
XMLConfiguration(const Poco::XML::Document* pDocument);
/// Creates the XMLConfiguration using the given XML document.
XMLConfiguration(const Poco::XML::Node* pNode);
/// Creates the XMLConfiguration using the given XML node.
void load(Poco::XML::InputSource* pInputSource);
/// Loads the XML document containing the configuration data
/// from the given InputSource.
void load(std::istream& istr);
/// Loads the XML document containing the configuration data
/// from the given stream.
void load(const std::string& path);
/// Loads the XML document containing the configuration data
/// from the given file.
void load(const Poco::XML::Document* pDocument);
/// Loads the XML document containing the configuration data
/// from the given XML document.
void load(const Poco::XML::Node* pNode);
/// Loads the XML document containing the configuration data
/// from the given XML node.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
~XMLConfiguration();
private:
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* 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* findAttribute(const std::string& name, const Poco::XML::Node* pNode);
Poco::XML::AutoPtr<Poco::XML::Node> _pRoot;
Poco::XML::AutoPtr<Poco::XML::Document> _pDocument;
};
} } // namespace Poco::Util
#endif // Util_XMLConfiguration_INCLUDED
//
// XMLConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/XMLConfiguration.h#1 $
//
// Library: Util
// Package: Configuration
// Module: XMLConfiguration
//
// Definition of the XMLConfiguration class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Util_XMLConfiguration_INCLUDED
#define Util_XMLConfiguration_INCLUDED
#include "Poco/Util/Util.h"
#include "Poco/Util/MapConfiguration.h"
#include "Poco/DOM/Document.h"
#include "Poco/DOM/AutoPtr.h"
#include "Poco/SAX/InputSource.h"
#include <istream>
namespace Poco {
namespace Util {
class Util_API XMLConfiguration: public AbstractConfiguration
/// This configuration class extracts configuration properties
/// from an XML document. An XPath-like syntax for property
/// names is supported to allow full access to the XML document.
/// XML namespaces are not supported. The name of the root element
/// of an XML document is not significant. Periods in tag names
/// are not supported.
///
/// Given the following XML document as an example:
///
/// <config>
/// <prop1>value1</prop1>
/// <prop2>value2</prop2>
/// <prop3>
/// <prop4 attr="value3"/>
/// <prop4 attr="value4"/>
/// </prop3>
/// <prop5>value5</prop5>
/// <prop5>value6</prop5>
/// </config>
///
/// The following property names would be valid and would
/// yield the shown values:
///
/// prop1 -> value1
/// prop2 -> value2
/// prop3.prop4 -> (empty string)
/// prop3.prop4[@attr] -> value3
/// prop3.prop4[1][@attr] -> value4
/// prop5[0] -> value5
/// prop5[1] -> value6
///
/// Enumerating attributes is not supported.
/// Calling keys("prop3.prop4") will return an empty range.
///
/// Setting properties is not supported. An attempt to set a property results
/// in a NotImplementedException being thrown.
{
public:
XMLConfiguration();
/// Creates an empty XMLConfiguration.
XMLConfiguration(Poco::XML::InputSource* pInputSource);
/// Creates an XMLConfiguration and loads the XML document from
/// the given InputSource.
XMLConfiguration(std::istream& istr);
/// Creates an XMLConfiguration and loads the XML document from
/// the given stream.
XMLConfiguration(const std::string& path);
/// Creates an XMLConfiguration and loads the XML document from
/// the given path.
XMLConfiguration(const Poco::XML::Document* pDocument);
/// Creates the XMLConfiguration using the given XML document.
XMLConfiguration(const Poco::XML::Node* pNode);
/// Creates the XMLConfiguration using the given XML node.
void load(Poco::XML::InputSource* pInputSource);
/// Loads the XML document containing the configuration data
/// from the given InputSource.
void load(std::istream& istr);
/// Loads the XML document containing the configuration data
/// from the given stream.
void load(const std::string& path);
/// Loads the XML document containing the configuration data
/// from the given file.
void load(const Poco::XML::Document* pDocument);
/// Loads the XML document containing the configuration data
/// from the given XML document.
void load(const Poco::XML::Node* pNode);
/// Loads the XML document containing the configuration data
/// from the given XML node.
protected:
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
~XMLConfiguration();
private:
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* 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* findAttribute(const std::string& name, const Poco::XML::Node* pNode);
Poco::XML::AutoPtr<Poco::XML::Node> _pRoot;
Poco::XML::AutoPtr<Poco::XML::Document> _pDocument;
};
} } // namespace Poco::Util
#endif // Util_XMLConfiguration_INCLUDED

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,204 +1,204 @@
//
// SampleApp.cpp
//
// $Id: //poco/1.2/Util/samples/SampleApp/src/SampleApp.cpp#1 $
//
// This sample demonstrates the Application class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/Util/Application.h"
#include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h"
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/AutoPtr.h"
#include <iostream>
using Poco::Util::Application;
using Poco::Util::Option;
using Poco::Util::OptionSet;
using Poco::Util::HelpFormatter;
using Poco::Util::AbstractConfiguration;
using Poco::Util::OptionCallback;
using Poco::AutoPtr;
class SampleApp: public Application
/// This sample demonstrates some of the features of the Util::Application class,
/// such as configuration file handling and command line arguments processing.
///
/// Try SampleApp --help (on Unix platforms) or SampleApp /help (elsewhere) for
/// more information.
{
public:
SampleApp(): _helpRequested(false)
{
}
protected:
void initialize(Application& self)
{
loadConfiguration(); // load default configuration files, if present
Application::initialize(self);
// add your own initialization code here
}
void uninitialize()
{
// add your own uninitialization code here
Application::uninitialize();
}
void reinitialize(Application& self)
{
Application::reinitialize(self);
// add your own reinitialization code here
}
void defineOptions(OptionSet& options)
{
Application::defineOptions(options);
options.addOption(
Option("help", "h", "display help information on command line arguments")
.required(false)
.repeatable(false)
.callback(OptionCallback<SampleApp>(this, &SampleApp::handleHelp)));
options.addOption(
Option("define", "D", "define a configuration property")
.required(false)
.repeatable(true)
.argument("name=value")
.callback(OptionCallback<SampleApp>(this, &SampleApp::handleDefine)));
options.addOption(
Option("config-file", "f", "load configuration data from a file")
.required(false)
.repeatable(true)
.argument("file")
.callback(OptionCallback<SampleApp>(this, &SampleApp::handleConfig)));
options.addOption(
Option("bind", "b", "bind option value to test.property")
.required(false)
.repeatable(false)
.argument("value")
.binding("test.property"));
}
void handleHelp(const std::string& name, const std::string& value)
{
_helpRequested = true;
displayHelp();
stopOptionsProcessing();
}
void handleDefine(const std::string& name, const std::string& value)
{
defineProperty(value);
}
void handleConfig(const std::string& name, const std::string& value)
{
loadConfiguration(value);
}
void displayHelp()
{
HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName());
helpFormatter.setUsage("OPTIONS");
helpFormatter.setHeader("A sample application that demonstrates some of the features of the Poco::Util::Application class.");
helpFormatter.format(std::cout);
}
void defineProperty(const std::string& def)
{
std::string name;
std::string value;
std::string::size_type pos = def.find('=');
if (pos != std::string::npos)
{
name.assign(def, 0, pos);
value.assign(def, pos + 1, def.length() - pos);
}
else name = def;
config().setString(name, value);
}
int main(const std::vector<std::string>& args)
{
if (!_helpRequested)
{
logger().information("Arguments to main():");
for (std::vector<std::string>::const_iterator it = args.begin(); it != args.end(); ++it)
{
logger().information(*it);
}
logger().information("Application properties:");
printProperties("");
}
return Application::EXIT_OK;
}
void printProperties(const std::string& base)
{
AbstractConfiguration::Keys keys;
config().keys(base, keys);
if (keys.empty())
{
if (config().hasProperty(base))
{
std::string msg;
msg.append(base);
msg.append(" = ");
msg.append(config().getString(base));
logger().information(msg);
}
}
else
{
for (AbstractConfiguration::Keys::const_iterator it = keys.begin(); it != keys.end(); ++it)
{
std::string fullKey = base;
if (!fullKey.empty()) fullKey += '.';
fullKey.append(*it);
printProperties(fullKey);
}
}
}
private:
bool _helpRequested;
};
POCO_APP_MAIN(SampleApp)
//
// SampleApp.cpp
//
// $Id: //poco/1.2/Util/samples/SampleApp/src/SampleApp.cpp#1 $
//
// This sample demonstrates the Application class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/Util/Application.h"
#include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h"
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/AutoPtr.h"
#include <iostream>
using Poco::Util::Application;
using Poco::Util::Option;
using Poco::Util::OptionSet;
using Poco::Util::HelpFormatter;
using Poco::Util::AbstractConfiguration;
using Poco::Util::OptionCallback;
using Poco::AutoPtr;
class SampleApp: public Application
/// This sample demonstrates some of the features of the Util::Application class,
/// such as configuration file handling and command line arguments processing.
///
/// Try SampleApp --help (on Unix platforms) or SampleApp /help (elsewhere) for
/// more information.
{
public:
SampleApp(): _helpRequested(false)
{
}
protected:
void initialize(Application& self)
{
loadConfiguration(); // load default configuration files, if present
Application::initialize(self);
// add your own initialization code here
}
void uninitialize()
{
// add your own uninitialization code here
Application::uninitialize();
}
void reinitialize(Application& self)
{
Application::reinitialize(self);
// add your own reinitialization code here
}
void defineOptions(OptionSet& options)
{
Application::defineOptions(options);
options.addOption(
Option("help", "h", "display help information on command line arguments")
.required(false)
.repeatable(false)
.callback(OptionCallback<SampleApp>(this, &SampleApp::handleHelp)));
options.addOption(
Option("define", "D", "define a configuration property")
.required(false)
.repeatable(true)
.argument("name=value")
.callback(OptionCallback<SampleApp>(this, &SampleApp::handleDefine)));
options.addOption(
Option("config-file", "f", "load configuration data from a file")
.required(false)
.repeatable(true)
.argument("file")
.callback(OptionCallback<SampleApp>(this, &SampleApp::handleConfig)));
options.addOption(
Option("bind", "b", "bind option value to test.property")
.required(false)
.repeatable(false)
.argument("value")
.binding("test.property"));
}
void handleHelp(const std::string& name, const std::string& value)
{
_helpRequested = true;
displayHelp();
stopOptionsProcessing();
}
void handleDefine(const std::string& name, const std::string& value)
{
defineProperty(value);
}
void handleConfig(const std::string& name, const std::string& value)
{
loadConfiguration(value);
}
void displayHelp()
{
HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName());
helpFormatter.setUsage("OPTIONS");
helpFormatter.setHeader("A sample application that demonstrates some of the features of the Poco::Util::Application class.");
helpFormatter.format(std::cout);
}
void defineProperty(const std::string& def)
{
std::string name;
std::string value;
std::string::size_type pos = def.find('=');
if (pos != std::string::npos)
{
name.assign(def, 0, pos);
value.assign(def, pos + 1, def.length() - pos);
}
else name = def;
config().setString(name, value);
}
int main(const std::vector<std::string>& args)
{
if (!_helpRequested)
{
logger().information("Arguments to main():");
for (std::vector<std::string>::const_iterator it = args.begin(); it != args.end(); ++it)
{
logger().information(*it);
}
logger().information("Application properties:");
printProperties("");
}
return Application::EXIT_OK;
}
void printProperties(const std::string& base)
{
AbstractConfiguration::Keys keys;
config().keys(base, keys);
if (keys.empty())
{
if (config().hasProperty(base))
{
std::string msg;
msg.append(base);
msg.append(" = ");
msg.append(config().getString(base));
logger().information(msg);
}
}
else
{
for (AbstractConfiguration::Keys::const_iterator it = keys.begin(); it != keys.end(); ++it)
{
std::string fullKey = base;
if (!fullKey.empty()) fullKey += '.';
fullKey.append(*it);
printProperties(fullKey);
}
}
}
private:
bool _helpRequested;
};
POCO_APP_MAIN(SampleApp)

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,144 +1,144 @@
//
// SampleServer.cpp
//
// $Id: //poco/1.2/Util/samples/SampleServer/src/SampleServer.cpp#1 $
//
// This sample demonstrates the ServerApplication class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/Util/ServerApplication.h"
#include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h"
#include "Poco/Task.h"
#include "Poco/TaskManager.h"
#include "Poco/DateTimeFormatter.h"
#include <iostream>
using Poco::Util::Application;
using Poco::Util::ServerApplication;
using Poco::Util::Option;
using Poco::Util::OptionSet;
using Poco::Util::OptionCallback;
using Poco::Util::HelpFormatter;
using Poco::Task;
using Poco::TaskManager;
using Poco::DateTimeFormatter;
class SampleTask: public Task
{
public:
SampleTask(): Task("SampleTask")
{
}
void runTask()
{
Application& app = Application::instance();
while (!sleep(5000))
{
Application::instance().logger().information("busy doing nothing... " + DateTimeFormatter::format(app.uptime()));
}
}
};
class SampleServer: public ServerApplication
{
public:
SampleServer(): _helpRequested(false)
{
}
~SampleServer()
{
}
protected:
void initialize(Application& self)
{
loadConfiguration(); // load default configuration files, if present
ServerApplication::initialize(self);
logger().information("starting up");
}
void uninitialize()
{
logger().information("shutting down");
ServerApplication::uninitialize();
}
void defineOptions(OptionSet& options)
{
ServerApplication::defineOptions(options);
options.addOption(
Option("help", "h", "display help information on command line arguments")
.required(false)
.repeatable(false)
.callback(OptionCallback<SampleServer>(this, &SampleServer::handleHelp)));
}
void handleHelp(const std::string& name, const std::string& value)
{
_helpRequested = true;
displayHelp();
stopOptionsProcessing();
}
void displayHelp()
{
HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName());
helpFormatter.setUsage("OPTIONS");
helpFormatter.setHeader("A sample server application that demonstrates some of the features of the Util::ServerApplication class.");
helpFormatter.format(std::cout);
}
int main(const std::vector<std::string>& args)
{
if (!_helpRequested)
{
TaskManager tm;
tm.start(new SampleTask);
waitForTerminationRequest();
tm.cancelAll();
tm.joinAll();
}
return Application::EXIT_OK;
}
private:
bool _helpRequested;
};
POCO_SERVER_MAIN(SampleServer)
//
// SampleServer.cpp
//
// $Id: //poco/1.2/Util/samples/SampleServer/src/SampleServer.cpp#1 $
//
// This sample demonstrates the ServerApplication class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#include "Poco/Util/ServerApplication.h"
#include "Poco/Util/Option.h"
#include "Poco/Util/OptionSet.h"
#include "Poco/Util/HelpFormatter.h"
#include "Poco/Task.h"
#include "Poco/TaskManager.h"
#include "Poco/DateTimeFormatter.h"
#include <iostream>
using Poco::Util::Application;
using Poco::Util::ServerApplication;
using Poco::Util::Option;
using Poco::Util::OptionSet;
using Poco::Util::OptionCallback;
using Poco::Util::HelpFormatter;
using Poco::Task;
using Poco::TaskManager;
using Poco::DateTimeFormatter;
class SampleTask: public Task
{
public:
SampleTask(): Task("SampleTask")
{
}
void runTask()
{
Application& app = Application::instance();
while (!sleep(5000))
{
Application::instance().logger().information("busy doing nothing... " + DateTimeFormatter::format(app.uptime()));
}
}
};
class SampleServer: public ServerApplication
{
public:
SampleServer(): _helpRequested(false)
{
}
~SampleServer()
{
}
protected:
void initialize(Application& self)
{
loadConfiguration(); // load default configuration files, if present
ServerApplication::initialize(self);
logger().information("starting up");
}
void uninitialize()
{
logger().information("shutting down");
ServerApplication::uninitialize();
}
void defineOptions(OptionSet& options)
{
ServerApplication::defineOptions(options);
options.addOption(
Option("help", "h", "display help information on command line arguments")
.required(false)
.repeatable(false)
.callback(OptionCallback<SampleServer>(this, &SampleServer::handleHelp)));
}
void handleHelp(const std::string& name, const std::string& value)
{
_helpRequested = true;
displayHelp();
stopOptionsProcessing();
}
void displayHelp()
{
HelpFormatter helpFormatter(options());
helpFormatter.setCommand(commandName());
helpFormatter.setUsage("OPTIONS");
helpFormatter.setHeader("A sample server application that demonstrates some of the features of the Util::ServerApplication class.");
helpFormatter.format(std::cout);
}
int main(const std::vector<std::string>& args)
{
if (!_helpRequested)
{
TaskManager tm;
tm.start(new SampleTask);
waitForTerminationRequest();
tm.cancelAll();
tm.joinAll();
}
return Application::EXIT_OK;
}
private:
bool _helpRequested;
};
POCO_SERVER_MAIN(SampleServer)

View File

@ -1,29 +1,29 @@
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}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleServer", "SampleServer\SampleServer_vs71.vcproj", "{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
debug_shared = debug_shared
release_shared = release_shared
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{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}.release_shared.ActiveCfg = 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.Build.0 = debug_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
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal
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}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SampleServer", "SampleServer\SampleServer_vs71.vcproj", "{0CFFC7B0-04F4-4A60-B6E4-84D78EDA2C73}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfiguration) = preSolution
debug_shared = debug_shared
release_shared = release_shared
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{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}.release_shared.ActiveCfg = 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.Build.0 = debug_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
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

File diff suppressed because it is too large Load Diff

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,72 +1,72 @@
//
// AbstractConfigurationTest.h
//
// $Id: //poco/1.2/Util/testsuite/src/AbstractConfigurationTest.h#1 $
//
// Definition of the AbstractConfigurationTest class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef AbstractConfigurationTest_INCLUDED
#define AbstractConfigurationTest_INCLUDED
#include "Poco/Util/Util.h"
#include "CppUnit/TestCase.h"
#include "Poco/Util/AbstractConfiguration.h"
class AbstractConfigurationTest: public CppUnit::TestCase
{
public:
AbstractConfigurationTest(const std::string& name);
~AbstractConfigurationTest();
void testHasProperty();
void testGetString();
void testGetInt();
void testGetDouble();
void testGetBool();
void testExpand();
void testSetString();
void testSetInt();
void testSetDouble();
void testSetBool();
void testKeys();
void setUp();
void tearDown();
static CppUnit::Test* suite();
private:
Poco::Util::AbstractConfiguration* createConfiguration() const;
};
#endif // AbstractConfigurationTest_INCLUDED
//
// AbstractConfigurationTest.h
//
// $Id: //poco/1.2/Util/testsuite/src/AbstractConfigurationTest.h#1 $
//
// Definition of the AbstractConfigurationTest class.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef AbstractConfigurationTest_INCLUDED
#define AbstractConfigurationTest_INCLUDED
#include "Poco/Util/Util.h"
#include "CppUnit/TestCase.h"
#include "Poco/Util/AbstractConfiguration.h"
class AbstractConfigurationTest: public CppUnit::TestCase
{
public:
AbstractConfigurationTest(const std::string& name);
~AbstractConfigurationTest();
void testHasProperty();
void testGetString();
void testGetInt();
void testGetDouble();
void testGetBool();
void testExpand();
void testSetString();
void testSetInt();
void testSetDouble();
void testSetBool();
void testKeys();
void setUp();
void tearDown();
static CppUnit::Test* suite();
private:
Poco::Util::AbstractConfiguration* createConfiguration() const;
};
#endif // AbstractConfigurationTest_INCLUDED

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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