Index: /sandbox/trunk/pdp/build/vc71/antlr/antlr.vcproj
===================================================================
--- /sandbox/trunk/pdp/build/vc71/antlr/antlr.vcproj (revision 939)
+++ /sandbox/trunk/pdp/build/vc71/antlr/antlr.vcproj (revision 939)
@@ -0,0 +1,314 @@
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="antlr"
+	ProjectGUID="{A31A9E8B-57D0-4C84-824C-17EAE8F6AE3A}"
+	RootNamespace="antlr"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="../Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="4"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="../../../tools/antlr-2.7.6/lib/cpp"
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;ANTLR_SUPPORT_XML"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				EnableFunctionLevelLinking="TRUE"
+				TreatWChar_tAsBuiltInType="TRUE"
+				ForceConformanceInForLoopScope="TRUE"
+				RuntimeTypeInfo="TRUE"
+				UsePrecompiledHeader="2"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)/antlrd.lib"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				Description="copying $(TargetPath) to $(SolutionDir)lib\"
+				CommandLine="copy $(TargetPath) $(SolutionDir)lib\"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="../Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="4"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				AdditionalIncludeDirectories="../../../tools/antlr-2.7.6/lib/cpp"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_WINDOWS;ANTLR_SUPPORT_XML"
+				RuntimeLibrary="2"
+				TreatWChar_tAsBuiltInType="TRUE"
+				ForceConformanceInForLoopScope="TRUE"
+				RuntimeTypeInfo="TRUE"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)/antlr.lib"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				Description="copying $(TargetPath) to $(SolutionDir)lib\"
+				CommandLine="copy $(TargetPath) $(SolutionDir)lib\"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Source Files"
+			Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
+			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\ANTLRUtil.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\ASTFactory.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\ASTNULLType.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\ASTRefCount.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\BaseAST.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\BitSet.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\CharBuffer.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\CharScanner.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\CommonAST.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\CommonASTWithHiddenTokens.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\CommonHiddenStreamToken.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\CommonToken.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\InputBuffer.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\LLkParser.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\Makefile.in">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\MismatchedCharException.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\MismatchedTokenException.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\NoViableAltException.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\NoViableAltForCharException.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\Parser.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\RecognitionException.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\String.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\Token.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\TokenBuffer.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\TokenRefCount.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\TokenStreamBasicFilter.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\TokenStreamHiddenTokenFilter.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\TokenStreamRewriteEngine.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\TokenStreamSelector.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\src\TreeParser.cpp">
+			</File>
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\ANTLRException.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\ANTLRUtil.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\AST.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\ASTArray.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\ASTFactory.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\ASTNULLType.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\ASTPair.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\ASTRefCount.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\BaseAST.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\BitSet.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\CharBuffer.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\CharInputBuffer.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\CharScanner.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\CharStreamException.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\CharStreamIOException.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\CircularQueue.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\CommonAST.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\CommonASTWithHiddenTokens.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\CommonHiddenStreamToken.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\CommonToken.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\config.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\InputBuffer.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\IOException.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\LexerSharedInputState.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\LLkParser.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\Makefile.in">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\MismatchedCharException.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\MismatchedTokenException.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\NoViableAltException.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\NoViableAltForCharException.hpp">
+			</File>
+			<File
+				RelativePath="..\..\..\tools\antlr-2.7.6\lib\cpp\antlr\Parser.hpp">
+			</File>
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+		</Filter>
+		<File
+			RelativePath=".\ReadMe.txt">
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /sandbox/trunk/pdp/build/vc71/xerial_util/xerial_util.vcproj
===================================================================
--- /sandbox/trunk/pdp/build/vc71/xerial_util/xerial_util.vcproj (revision 939)
+++ /sandbox/trunk/pdp/build/vc71/xerial_util/xerial_util.vcproj (revision 939)
@@ -0,0 +1,310 @@
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="xerial_util"
+	ProjectGUID="{6B5B4036-E8C8-4C33-85C0-AA519562D9AC}"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="../Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="4"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="../../../src; ../../../tools/antlr-2.7.6/lib/cpp"
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="1"
+				TreatWChar_tAsBuiltInType="TRUE"
+				ForceConformanceInForLoopScope="TRUE"
+				RuntimeTypeInfo="TRUE"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)/xerial_utild.lib"
+				AdditionalLibraryDirectories="../lib"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"
+				Description="copy $(TargetPath) to $(SolutionDir)lib\"
+				CommandLine="copy $(TargetPath) $(SolutionDir)lib\"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="4"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB"
+				RuntimeLibrary="4"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLibrarianTool"
+				OutputFile="$(OutDir)/xerial_util.lib"/>
+			<Tool
+				Name="VCMIDLTool"/>
+			<Tool
+				Name="VCPostBuildEventTool"/>
+			<Tool
+				Name="VCPreBuildEventTool"/>
+			<Tool
+				Name="VCPreLinkEventTool"/>
+			<Tool
+				Name="VCResourceCompilerTool"/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"/>
+			<Tool
+				Name="VCManagedWrapperGeneratorTool"/>
+			<Tool
+				Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+		</Filter>
+		<Filter
+			Name="Source Files">
+			<Filter
+				Name="common">
+				<File
+					RelativePath="..\..\..\src\xerial\common\xerial.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\common\xerial_last.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\common\xerial_types.hpp">
+				</File>
+			</Filter>
+			<Filter
+				Name="log">
+				<File
+					RelativePath="..\..\..\src\xerial\log\LogConfiguration.g">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\log\LogConfigurationLexer.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\log\LogConfigurationLexer.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\log\LogConfigurationLexerTokenTypes.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\log\LogConfigurationLexerTokenTypes.txt">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\log\LogConfigurationParser.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\log\LogConfigurationParser.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\log\LogConfigurationTreeParser.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\log\LogConfigurationTreeParser.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\log\Logger.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\log\Logger.hpp">
+				</File>
+			</Filter>
+			<Filter
+				Name="exception">
+				<File
+					RelativePath="..\..\..\src\xerial\exception\assert.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\AssertionFailure.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\AssertionFailure.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\Exception.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\Exception.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\ExceptionUtil.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\InvalidNumberFormatException.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\InvalidNumberFormatException.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\InvalidParameterException.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\InvalidParameterException.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\OutOfRangeException.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\OutOfRangeException.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\UnsupportedOperation.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\exception\UnsupportedOperation.hpp">
+				</File>
+			</Filter>
+			<Filter
+				Name="util">
+				<File
+					RelativePath="..\..\..\src\xerial\util\Format.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\hash_map.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\Integer.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\Integer.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\Message.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\Message.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\NonConstructable.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\NonConstructable.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\NonCopyable.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\Printable.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\Printable.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\STLUtil.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\StringUtil.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\StringUtil.hpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\ustring.cpp">
+				</File>
+				<File
+					RelativePath="..\..\..\src\xerial\util\ustring.hpp">
+				</File>
+				<Filter
+					Name="cui">
+					<File
+						RelativePath="..\..\..\src\xerial\util\cui\OptionParser.cpp">
+					</File>
+					<File
+						RelativePath="..\..\..\src\xerial\util\cui\OptionParser.hpp">
+					</File>
+				</Filter>
+				<Filter
+					Name="thread">
+					<File
+						RelativePath="..\..\..\src\xerial\util\thread\CompareAndSwap.cpp">
+					</File>
+					<File
+						RelativePath="..\..\..\src\xerial\util\thread\CompareAndSwap.hpp">
+					</File>
+					<File
+						RelativePath="..\..\..\src\xerial\util\thread\LightMutex.hpp">
+					</File>
+					<File
+						RelativePath="..\..\..\src\xerial\util\thread\Lock.hpp">
+					</File>
+					<File
+						RelativePath="..\..\..\src\xerial\util\thread\ScopeGuard.hpp">
+					</File>
+				</Filter>
+				<Filter
+					Name="io"
+					Filter="">
+					<File
+						RelativePath="..\..\..\src\xerial\util\io\FileUtil.cpp">
+					</File>
+					<File
+						RelativePath="..\..\..\src\xerial\util\io\FileUtil.hpp">
+					</File>
+				</Filter>
+			</Filter>
+			<Filter
+				Name="antlr"
+				Filter="">
+				<File
+					RelativePath="..\..\..\src\xerial\util\antlr\AntlrHelper.hpp">
+				</File>
+			</Filter>
+		</Filter>
+		<File
+			RelativePath=".\ReadMe.txt">
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /sandbox/trunk/pdp/build/vc71/N-body.sln
===================================================================
--- /sandbox/trunk/pdp/build/vc71/N-body.sln (revision 939)
+++ /sandbox/trunk/pdp/build/vc71/N-body.sln (revision 939)
@@ -0,0 +1,50 @@
+Microsoft Visual Studio Solution File, Format Version 8.00
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "N-body", "N-body\N-body.vcproj", "{A053B03E-06E7-4AA8-AD0E-B5017B668233}"
+	ProjectSection(ProjectDependencies) = postProject
+		{6B5B4036-E8C8-4C33-85C0-AA519562D9AC} = {6B5B4036-E8C8-4C33-85C0-AA519562D9AC}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Replication", "Replication\Replication.vcproj", "{8730E6B6-A280-4DD1-ABDA-7C4631F40635}"
+	ProjectSection(ProjectDependencies) = postProject
+		{6B5B4036-E8C8-4C33-85C0-AA519562D9AC} = {6B5B4036-E8C8-4C33-85C0-AA519562D9AC}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xerial_util", "xerial_util\xerial_util.vcproj", "{6B5B4036-E8C8-4C33-85C0-AA519562D9AC}"
+	ProjectSection(ProjectDependencies) = postProject
+		{A31A9E8B-57D0-4C84-824C-17EAE8F6AE3A} = {A31A9E8B-57D0-4C84-824C-17EAE8F6AE3A}
+	EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "antlr", "antlr\antlr.vcproj", "{A31A9E8B-57D0-4C84-824C-17EAE8F6AE3A}"
+	ProjectSection(ProjectDependencies) = postProject
+	EndProjectSection
+EndProject
+Global
+	GlobalSection(SolutionConfiguration) = preSolution
+		Debug = Debug
+		Release = Release
+	EndGlobalSection
+	GlobalSection(ProjectDependencies) = postSolution
+	EndGlobalSection
+	GlobalSection(ProjectConfiguration) = postSolution
+		{A053B03E-06E7-4AA8-AD0E-B5017B668233}.Debug.ActiveCfg = Debug|Win32
+		{A053B03E-06E7-4AA8-AD0E-B5017B668233}.Debug.Build.0 = Debug|Win32
+		{A053B03E-06E7-4AA8-AD0E-B5017B668233}.Release.ActiveCfg = Release|Win32
+		{A053B03E-06E7-4AA8-AD0E-B5017B668233}.Release.Build.0 = Release|Win32
+		{8730E6B6-A280-4DD1-ABDA-7C4631F40635}.Debug.ActiveCfg = Debug|Win32
+		{8730E6B6-A280-4DD1-ABDA-7C4631F40635}.Debug.Build.0 = Debug|Win32
+		{8730E6B6-A280-4DD1-ABDA-7C4631F40635}.Release.ActiveCfg = Release|Win32
+		{8730E6B6-A280-4DD1-ABDA-7C4631F40635}.Release.Build.0 = Release|Win32
+		{6B5B4036-E8C8-4C33-85C0-AA519562D9AC}.Debug.ActiveCfg = Debug|Win32
+		{6B5B4036-E8C8-4C33-85C0-AA519562D9AC}.Debug.Build.0 = Debug|Win32
+		{6B5B4036-E8C8-4C33-85C0-AA519562D9AC}.Release.ActiveCfg = Release|Win32
+		{6B5B4036-E8C8-4C33-85C0-AA519562D9AC}.Release.Build.0 = Release|Win32
+		{A31A9E8B-57D0-4C84-824C-17EAE8F6AE3A}.Debug.ActiveCfg = Debug|Win32
+		{A31A9E8B-57D0-4C84-824C-17EAE8F6AE3A}.Debug.Build.0 = Debug|Win32
+		{A31A9E8B-57D0-4C84-824C-17EAE8F6AE3A}.Release.ActiveCfg = Release|Win32
+		{A31A9E8B-57D0-4C84-824C-17EAE8F6AE3A}.Release.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ExtensibilityGlobals) = postSolution
+	EndGlobalSection
+	GlobalSection(ExtensibilityAddIns) = postSolution
+	EndGlobalSection
+EndGlobal
Index: /sandbox/trunk/pdp/build/vc71/N-body/N-body.vcproj
===================================================================
--- /sandbox/trunk/pdp/build/vc71/N-body/N-body.vcproj (revision 936)
+++ /sandbox/trunk/pdp/build/vc71/N-body/N-body.vcproj (revision 939)
@@ -23,5 +23,8 @@
 				MinimalRebuild="TRUE"
 				BasicRuntimeChecks="3"
-				RuntimeLibrary="5"
+				RuntimeLibrary="1"
+				TreatWChar_tAsBuiltInType="TRUE"
+				ForceConformanceInForLoopScope="TRUE"
+				RuntimeTypeInfo="TRUE"
 				UsePrecompiledHeader="0"
 				WarningLevel="3"
@@ -32,6 +35,9 @@
 			<Tool
 				Name="VCLinkerTool"
+				AdditionalDependencies="cxxd.lib mpi.lib xerial_utild.lib"
 				OutputFile="$(OutDir)/N-body.exe"
 				LinkIncremental="2"
+				AdditionalLibraryDirectories="../lib"
+				IgnoreAllDefaultLibraries="FALSE"
 				GenerateDebugInformation="TRUE"
 				ProgramDatabaseFile="$(OutDir)/N-body.pdb"
@@ -114,4 +120,10 @@
 			UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}">
 			<File
+				RelativePath="..\..\..\src\MPIInitializer.cpp">
+			</File>
+			<File
+				RelativePath="..\..\..\src\MPIInitializer.hpp">
+			</File>
+			<File
 				RelativePath="..\..\..\src\N-body.cpp">
 			</File>
Index: /ndbox/trunk/pdp/build/vc71/N-body/N-body.sln
===================================================================
--- /sandbox/trunk/pdp/build/vc71/N-body/N-body.sln (revision 936)
+++  (revision )
@@ -1,23 +1,0 @@
-Microsoft Visual Studio Solution File, Format Version 8.00
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "N-body", "N-body.vcproj", "{A053B03E-06E7-4AA8-AD0E-B5017B668233}"
-	ProjectSection(ProjectDependencies) = postProject
-	EndProjectSection
-EndProject
-Global
-	GlobalSection(SolutionConfiguration) = preSolution
-		Debug = Debug
-		Release = Release
-	EndGlobalSection
-	GlobalSection(ProjectDependencies) = postSolution
-	EndGlobalSection
-	GlobalSection(ProjectConfiguration) = postSolution
-		{A053B03E-06E7-4AA8-AD0E-B5017B668233}.Debug.ActiveCfg = Debug|Win32
-		{A053B03E-06E7-4AA8-AD0E-B5017B668233}.Debug.Build.0 = Debug|Win32
-		{A053B03E-06E7-4AA8-AD0E-B5017B668233}.Release.ActiveCfg = Release|Win32
-		{A053B03E-06E7-4AA8-AD0E-B5017B668233}.Release.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ExtensibilityGlobals) = postSolution
-	EndGlobalSection
-	GlobalSection(ExtensibilityAddIns) = postSolution
-	EndGlobalSection
-EndGlobal
Index: /sandbox/trunk/pdp/build/vc71/Replication/Replication.vcproj
===================================================================
--- /sandbox/trunk/pdp/build/vc71/Replication/Replication.vcproj (revision 939)
+++ /sandbox/trunk/pdp/build/vc71/Replication/Replication.vcproj (revision 939)
@@ -0,0 +1,128 @@
+<?xml version="1.0" encoding="shift_jis"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="7.10"
+	Name="Replication"
+	ProjectGUID="{8730E6B6-A280-4DD1-ABDA-7C4631F40635}"
+	Keyword="Win32Proj">
+	<Platforms>
+		<Platform
+			Name="Win32"/>
+	</Platforms>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="Debug"
+			IntermediateDirectory="Debug"
+			ConfigurationType="1"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+				MinimalRebuild="TRUE"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="5"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="4"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/Replication.exe"
+				LinkIncremental="2"
+				GenerateDebugInformation="TRUE"
+				ProgramDatabaseFile="$(OutDir)/Replication.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|Win32"
+			OutputDirectory="Release"
+			IntermediateDirectory="Release"
+			ConfigurationType="1"
+			CharacterSet="2">
+			<Tool
+				Name="VCCLCompilerTool"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+				RuntimeLibrary="4"
+				UsePrecompiledHeader="0"
+				WarningLevel="3"
+				Detect64BitPortabilityProblems="TRUE"
+				DebugInformationFormat="3"/>
+			<Tool
+				Name="VCCustomBuildTool"/>
+			<Tool
+				Name="VCLinkerTool"
+				OutputFile="$(OutDir)/Replication.exe"
+				LinkIncremental="1"
+				GenerateDebugInformation="TRUE"
+				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="Source Files"
+			Filter="">
+		</Filter>
+		<Filter
+			Name="Header Files"
+			Filter="h;hpp;hxx;hm;inl;inc;xsd"
+			UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}">
+		</Filter>
+		<Filter
+			Name="Resource Files"
+			Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
+			UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}">
+		</Filter>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>
Index: /sandbox/trunk/pdp/src/MPIInitializer.hpp
===================================================================
--- /sandbox/trunk/pdp/src/MPIInitializer.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/MPIInitializer.hpp (revision 939)
@@ -0,0 +1,22 @@
+//--------------------------------------------------
+// MPIInitializer.hpp
+// Since  2006/10/17 10:49:02
+// 
+// $Date$ 
+// $Author$ 
+//--------------------------------------------------
+#pragma once
+#ifndef __MPIINITIALIZER_HPP20061017104902
+#define __MPIINITIALIZER_HPP20061017104902
+
+class MPIInitializer
+{
+public:
+	MPIInitializer(int argc, char** argv);
+	virtual ~MPIInitializer();
+private:
+
+};
+
+
+#endif //__MPIINITIALIZER_HPP20061017104902
Index: /sandbox/trunk/pdp/src/xerial/log/LogConfigurationLexer.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/log/LogConfigurationLexer.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/log/LogConfigurationLexer.hpp (revision 939)
@@ -0,0 +1,79 @@
+#ifndef INC_LogConfigurationLexer_hpp_
+#define INC_LogConfigurationLexer_hpp_
+
+#line 11 "LogConfiguration.g"
+
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Since  2006/08/03 16:19:06
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/branches/leo/btree-devel-0.1/src/xerial/log/LogConfigurationLexer.hpp $
+// $Author: leo $ 
+//--------------------------------------------------	
+#include "xerial/common/xerial.hpp"
+#include <iosfwd>
+#include <string>
+#define CUSTOM_API XERIAL_API
+#ifdef WIN32
+// disable warnings for unused local variables and int to char conversion within ANTLR codes
+#pragma warning(disable: 4100 4244)
+#endif // WIN32
+
+#line 25 "LogConfigurationLexer.hpp"
+#include <antlr/config.hpp>
+/* $ANTLR 2.7.6 (2005-12-22): "LogConfiguration.g" -> "LogConfigurationLexer.hpp"$ */
+#include <antlr/CommonToken.hpp>
+#include <antlr/InputBuffer.hpp>
+#include <antlr/BitSet.hpp>
+#include "LogConfigurationLexerTokenTypes.hpp"
+#include <antlr/CharScanner.hpp>
+#line 30 "LogConfiguration.g"
+
+
+#line 36 "LogConfigurationLexer.hpp"
+ANTLR_BEGIN_NAMESPACE(xerial)
+#line 52 "LogConfiguration.g"
+
+    // gets inserted after generated namespace specifications in the header
+    // file. But outside the generated class.
+
+#line 42 "LogConfigurationLexer.hpp"
+class CUSTOM_API LogConfigurationLexer : public ANTLR_USE_NAMESPACE(antlr)CharScanner, public LogConfigurationLexerTokenTypes
+{
+#line 70 "LogConfiguration.g"
+
+	// lexer class members;
+
+#line 46 "LogConfigurationLexer.hpp"
+private:
+	void initLiterals();
+public:
+	bool getCaseSensitiveLiterals() const
+	{
+		return true;
+	}
+public:
+	LogConfigurationLexer(ANTLR_USE_NAMESPACE(std)istream& in);
+	LogConfigurationLexer(ANTLR_USE_NAMESPACE(antlr)InputBuffer& ib);
+	LogConfigurationLexer(const ANTLR_USE_NAMESPACE(antlr)LexerSharedInputState& state);
+	ANTLR_USE_NAMESPACE(antlr)RefToken nextToken();
+	protected: void mLetter(bool _createToken);
+	protected: void mDigit(bool _createToken);
+	public: void mDigits(bool _createToken);
+	protected: void mChar(bool _createToken);
+	public: void mEq(bool _createToken);
+	public: void mLiteral(bool _createToken);
+	public: void mWhiteSpaceChar(bool _createToken);
+	public: void mSL_COMMENT(bool _createToken);
+private:
+	
+	static const unsigned long _tokenSet_0_data_[];
+	static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_0;
+	static const unsigned long _tokenSet_1_data_[];
+	static const ANTLR_USE_NAMESPACE(antlr)BitSet _tokenSet_1;
+};
+
+ANTLR_END_NAMESPACE
+#endif /*INC_LogConfigurationLexer_hpp_*/
Index: /sandbox/trunk/pdp/src/xerial/log/Logger.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/log/Logger.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/log/Logger.cpp (revision 939)
@@ -0,0 +1,412 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Logger.cpp
+// Since  2006/02/07 15:12:49
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/branches/leo/btree-devel-0.1/src/xerial/log/Logger.cpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#include "xerial/log/Logger.hpp"
+#include "xerial/exception/ExceptionUtil.hpp"
+#include "xerial/util/hash_map.hpp"
+#include "xerial/util/StringUtil.hpp"
+#include "xerial/exception/assert.hpp"
+#include "xerial/util/thread/LightMutex.hpp"
+#include <iostream>
+#include <fstream>
+#include <sstream>
+#include <map>
+#include "xerial/util/io/FileUtil.hpp"
+#include "xerial/util/Message.hpp"
+#include "xerial/util/thread/LightMutex.hpp"
+#include "xerial/util/Singleton.hpp"
+#include "xerial/log/LogConfigurationLexer.hpp"
+#include "xerial/log/LogConfigurationParser.hpp"
+#include "xerial/log/LogConfigurationTreeParser.hpp"
+#include "xerial/util/antlr/AntlrHelper.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+XERIAL_EXECUTABLE_ENTRY(list_logger, Logger::main_listLogger);
+
+MAKE_XERIAL_EXCEPTION_DECLARATION(UnknownLogLevelException)
+
+MAKE_XERIAL_EXCEPTION_DEFINITION(UnknownLogLevelException)
+
+/**
+ * LoggerHolder has the responsibility to delete Logger objects in proper manner 
+ * when the application terminates.
+ */
+class LoggerHolder : public Singleton<LoggerHolder>
+{
+public:
+	typedef hash_map<string, Logger*> LoggerTable;
+private:
+	LoggerTable _loggerTable;
+	LightMutex _mutex;
+public:
+
+ 
+ 	const LoggerTable& getLoggerTable() const
+	{
+		return _loggerTable;
+	}
+
+	static const string& getRootLoggerName()
+	{
+		static const string ROOT_LOGGER_NAME = "main";
+		return ROOT_LOGGER_NAME;
+	}
+
+	LoggerHolder()
+	{
+	}
+	virtual ~LoggerHolder()
+	{
+		for(LoggerTable::iterator i = _loggerTable.begin(); i != _loggerTable.end(); ++i)
+			if(i->second)	
+				delete i->second;	// deallocate the loggers
+	}
+	
+	/**
+	* find a logger object from the holder
+	* @param name	a logger name
+	* @return	a pointer to the specified logger object, or null if no logger with the given name is found
+	*/
+	Logger* getLogger(const std::string& name)
+	{
+		ScopeGuard<LightMutex> g(_mutex);
+		return getLogger_internal(name);
+	}
+private:
+	Logger* getLogger_internal(const std::string& name)
+	{
+		static const string loggerDelimiter = ".";
+
+		XERIAL_ASSERT(name != "");
+		LoggerTable::iterator i = _loggerTable.find(name);
+		if(i != _loggerTable.end())
+			return i->second;
+		else
+		{
+			// create a new logger
+			vector<string> loggerHierarchy = StringUtil::split(name, loggerDelimiter);
+			Logger* logger = 0;
+			if(loggerHierarchy.size() == 1)	
+			{
+				if(name == getRootLoggerName())
+				{
+					// create root logger
+					// create the root logger
+					logger = new Logger(0, getRootLoggerName());
+					// set the default log level
+					logger->defaultLevel();
+					logger->defaultOutput();
+				}
+				else
+				{
+					// its logger's parent is the root logger
+					Logger* rootLogger = getLogger_internal(getRootLoggerName());
+					logger = new Logger(rootLogger, name);
+				}
+			}
+			else
+			{
+				loggerHierarchy.pop_back();
+				string parentLoggerName = StringUtil::join(loggerHierarchy, loggerDelimiter);
+				// the following code may recursively call the addLogger method.
+				logger = new Logger(getLogger_internal(parentLoggerName), name);
+			}
+			addLogger(logger);
+			return logger;
+		}
+	}
+	/**
+	* add a new Logger object to the holder
+	* @param logger	
+	* @return	
+	*/
+	void addLogger(Logger* logger)
+	{
+		_loggerTable.insert(make_pair(logger->getName(), logger));
+	}
+
+};
+
+
+
+Logger::Logger(Logger* parentLogger, const std::string& name) 
+: _name(name), _parentLogger(parentLogger), _out(0), _logLevel(LOG_UNSPECIFIED)
+{
+
+	
+}
+
+Logger::~Logger() 
+{
+	
+}
+
+
+
+Logger*
+Logger::getLogger(const std::string& loggerName) 
+{
+	return LoggerHolder::getInstance().getLogger(loggerName);
+}
+
+Logger*
+Logger::getRootLogger()
+{
+	return LoggerHolder::getInstance().getLogger(LoggerHolder::getRootLoggerName());
+}
+
+void
+Logger::trace(const std::string& message, bool forceOutput) 
+{
+	outputLog(LOG_TRACE, "\033[0;32m", message, forceOutput);
+}
+
+void
+Logger::debug(const std::string& message, bool forceOutput) 
+{
+	outputLog(LOG_DEBUG, "", message, forceOutput);
+}
+void
+Logger::info(const std::string& message, bool forceOutput) 
+{
+	outputLog(LOG_INFO, "\033[1;36m", message, forceOutput);
+}
+void
+Logger::warn(const std::string& message, bool forceOutput) 
+{
+	outputLog(LOG_WARN, "\033[1;33m", message, forceOutput);
+
+}
+void
+Logger::error(const std::string& message, bool forceOutput) 
+{
+	outputLog(LOG_ERROR, "\033[1;35m", message, forceOutput);
+
+}
+void
+Logger::fatal(const std::string& message, bool forceOutput) 
+{
+	outputLog(LOG_FATAL, "\033[1;31m", message, forceOutput);
+}
+
+int
+Logger::getLevel() const
+{
+	return _logLevel;
+}
+
+void
+Logger::setLevel(int level) 
+{
+	XERIAL_ASSERT(level >= LOG_ALL && level <= LOG_UNSPECIFIED);
+	_logLevel = level;
+}
+
+const string&
+Logger::getName() const
+{
+	return _name;
+}
+
+
+
+void
+Logger::outputLog(int logLevel, const std::string& escapeSeq, const std::string& message, bool forceOutput) 
+{
+	if(!forceOutput && !isEnabled(logLevel))
+		return;
+
+	Logger* outputLogger = this;
+	ostream* out;
+    do
+	{
+		XERIAL_ASSERT(outputLogger != NULL);
+		out = outputLogger->_out;
+		outputLogger = outputLogger->_parentLogger;		
+	}
+	while(out == NULL);
+
+	// output the log messages
+	(*out) << escapeSeq << "[" << _name << "] " << message << "\033[0m" << endl;
+}
+
+void
+Logger::setOutputFile(const std::string& fileName) 
+{
+	if(!FileUtil::existFile(fileName))
+		XERIAL_THROW(Exception, "file " << fileName << " doesn't exist");
+
+	resetOutput(new fstream(fileName.c_str(), ios::out | ios::app));
+}
+
+void
+Logger::resetOutput(std::ostream* out) 
+{
+	if(_out != 0 && _out != &std::cout)
+	{
+		_out->flush();
+//		delete _out;
+	}
+	_out = out;
+}
+
+void
+Logger::defaultOutput() 
+{
+	if(_name == LoggerHolder::getRootLoggerName())
+		resetOutput(&cout);
+	else
+		resetOutput(0);
+}
+
+void
+Logger::defaultLevel() 
+{
+	if(_name == LoggerHolder::getRootLoggerName())
+	{
+#ifdef _DEBUG
+		setLevel(LOG_DEBUG);
+#else
+		setLevel(LOG_INFO);
+#endif
+	}
+	else
+		setLevel(LOG_UNSPECIFIED);
+}
+
+
+bool
+Logger::isEnabled(int logLevel) const
+{
+	if(this->_logLevel == LOG_UNSPECIFIED)
+	{
+		if(_parentLogger)
+			return _parentLogger->isEnabled(logLevel);
+		else
+			return false;	// the root logger's log level is unspecified, so turn off the log messages
+	}
+	return _logLevel <= logLevel; // for example, a relation INFO <= DEBUG returns false
+}
+
+void
+Logger::configure(const std::string& fileName) 
+{
+	using namespace antlr;
+	
+	typedef LogConfigurationLexerTokenTypes LLT;
+
+	try
+	{
+		ifstream fileStream(fileName.c_str());
+		if(!fileStream)
+			XERIAL_THROW(Exception, "cannot open log configuation file: " << fileName);
+		AntlrParser<LogConfigurationLexer, LogConfigurationParser> parser(fileStream);
+		parser.getParser().config();
+		RefAST t = parser.getParser().getAST();
+		XERIAL_ASSERT(t->getType() == LLT::Config);
+		LogConfigurationTreeParser treeParser;
+		treeParser.config(t);
+
+		fileStream.close();
+	}
+	catch(ANTLRException& e)
+	{
+		XERIAL_THROW(Exception, e.getMessage());
+	}
+
+}
+
+void
+Logger::setLevel(const std::string& logLevelString) 
+{
+	try
+	{
+		int logLevel = convertToLogLevel(logLevelString);
+		_logLevel = logLevel;
+	}
+	catch(UnknownLogLevelException& e)
+	{
+		XERIAL_THROW(Exception, e.what());
+	}
+}
+
+std::string 
+Logger::toString() const
+{
+	static const string logLevelString[] = { "all", "trace", "debug", "info", "warn", "error", "fatal", "off", "unspecified"};
+	XERIAL_ASSERT(_logLevel <= LOG_UNSPECIFIED);
+	return XERIAL_MESSAGE(_name << " = " << logLevelString[_logLevel]);
+}
+
+std::string 
+Logger::loggerList() 
+{
+	std::ostringstream os;
+	map<string, string> sortedLoggerName;
+	LoggerHolder::LoggerTable t = LoggerHolder::getInstance().getLoggerTable();
+	for(LoggerHolder::LoggerTable::const_iterator it = t.begin(); it != t.end(); ++it)
+	{
+		sortedLoggerName.insert(make_pair(it->second->getName(), it->second->toString()));
+	}
+
+	for(map<string, string>::const_iterator it = sortedLoggerName.begin(); it != sortedLoggerName.end(); ++it)
+		os << it->second << "\n";
+
+	return os.str();
+}
+
+int 
+Logger::main_listLogger(int, char**)
+{
+	cout << Logger::loggerList();
+	return RETURN_WITH_SUCCESS;
+}
+
+
+
+const std::string&
+Logger::convertToString(int logLevel) 
+{
+	static const string logLevelString[] = { "all", "trace", "debug", "info", "warn", "error", "fatal", "off", "unspecified"};
+	XERIAL_ASSERT(LOG_ALL <= logLevel && logLevel <= LOG_UNSPECIFIED);
+	return logLevelString[logLevel];
+}
+
+namespace 
+{
+	class LogLevelMap
+	{
+		typedef hash_map<string, int> LogLevelTable;
+		LogLevelTable _logLevelMap;
+	public:
+		LogLevelMap()
+		{
+			for(int logLevel=0; logLevel<=Logger::LOG_UNSPECIFIED; ++logLevel)
+				_logLevelMap[Logger::convertToString(logLevel)] = logLevel;
+		}
+		int getLogLevel(const string& logLevelStr) 
+		{
+			if(_logLevelMap.count(logLevelStr) > 0)
+				return _logLevelMap[logLevelStr];
+			else
+				XERIAL_THROW(UnknownLogLevelException, "unknown log level: " << logLevelStr);
+		}
+	};
+}
+
+int
+Logger::convertToLogLevel(const std::string& logLevelStr) 
+{
+    static LogLevelMap logLevelMap;
+	return logLevelMap.getLogLevel(logLevelStr);
+}
+
+XERIAL_NAMESPACE_END
Index: /sandbox/trunk/pdp/src/xerial/log/LogConfigurationLexerTokenTypes.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/log/LogConfigurationLexerTokenTypes.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/log/LogConfigurationLexerTokenTypes.hpp (revision 939)
@@ -0,0 +1,33 @@
+#ifndef INC_LogConfigurationLexerTokenTypes_hpp_
+#define INC_LogConfigurationLexerTokenTypes_hpp_
+
+ANTLR_BEGIN_NAMESPACE(xerial)
+/* $ANTLR 2.7.6 (2005-12-22): "LogConfiguration.g" -> "LogConfigurationLexerTokenTypes.hpp"$ */
+
+#ifndef CUSTOM_API
+# define CUSTOM_API
+#endif
+
+#ifdef __cplusplus
+struct CUSTOM_API LogConfigurationLexerTokenTypes {
+#endif
+	enum {
+		EOF_ = 1,
+		Letter = 4,
+		Digit = 5,
+		Digits = 6,
+		Char = 7,
+		Eq = 8,
+		Literal = 9,
+		WhiteSpaceChar = 10,
+		SL_COMMENT = 11,
+		Config = 12,
+		LogLevel = 13,
+		// "=" = 14
+		NULL_TREE_LOOKAHEAD = 3
+	};
+#ifdef __cplusplus
+};
+#endif
+ANTLR_END_NAMESPACE
+#endif /*INC_LogConfigurationLexerTokenTypes_hpp_*/
Index: /sandbox/trunk/pdp/src/xerial/log/Logger.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/log/Logger.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/log/Logger.hpp (revision 939)
@@ -0,0 +1,195 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Logger.hpp
+// Since  2006/02/07 14:25:10
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/branches/leo/btree-devel-0.1/src/xerial/log/Logger.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __LOGGER_HPP_20060207_142510
+#define __LOGGER_HPP_20060207_142510
+
+#include "xerial/common/xerial.hpp"
+#include <sstream>
+#include <iosfwd>
+#include "xerial/util/NonCopyable.hpp"
+#include "xerial/util/NonConstructable.hpp"
+#include "xerial/util/Message.hpp"
+#include "xerial/util/Printable.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+
+class LoggerHolder;
+
+/**
+ * The Logger class is used to report runtime information within the programs for debugging, warning, or something else.
+ * The basic usage of the Logger is:
+ *   Logger* logger = Logger::getLogger("db.BTree");	// get logger "db.BTree"
+ *   logger->debug("debug message");					// output debug messages to the logger
+ *   logger->info("various information");				// output informations
+ *
+ * There is no need to deallocate the logger by calling "delete logger", since the Loggers are automatically initialized and properly deallocated when the 
+ * program terminates.
+ *
+ * Each logger has a log level, which determines whether the given log messages will be reported or not. 
+ * When the log level of "db.BTree" is LOG_INFO, only the info messages will be reported in the previous example. 
+ * 
+ * The log levels have the following order, LOG_ALL <  LOG_TRACE < LOG_DEBUG < LOG_INFO < LOG_WARN < LOG_ERROR < LOG_FATAL.
+ * If the log level of repoting messages are lower than that of the logger, these messages are shut down.
+ * 
+ * 
+ * 
+ * Some useful macros are provided for efficienty of hacking and runtime performance.
+ *
+ *   XERIAL_LOGGER(_logger, db.BTree) 
+ *
+ * that generates a logger instance named _logger within annonymous namespace. 
+ *
+ * It is identical to 
+ *    namespace{ Logger* _logger = Logger::getLogger("db.BTree"); }
+ *
+ * Annonymous namespace is useful to create a global variable that can be used in the target file only. Thus, 
+ * XERIAL_LOGGER is usually written in .cpp files. 
+ * After this declaration, you can report log messages as follows:
+ * 
+ *   XERIAL_DEBUG(_logger, "debug message");
+ *   XERIAL_INFO(_logger, "various information");
+ * 
+ * When the log level of the logger is higher than the LOG_DEBUG or LOG_INFO, i.e. when the log messages will not be reported, 
+ * these styles of logging is far more efficient than the first example that directly calls logger->debug(), etc. since 
+ * these macros never perform instantiation of debug messages when the log level checks fail.
+ *
+ * 
+ * You can configure the log level of loggers from a configuration file.
+ * In the configuration file, you have to write pairs of a logger name and log level. 
+ *
+ *  Logger::configure("log.config");	// load a configuration file
+ *
+ * (log.config)
+ *  db = info
+ *  db.BTree = off
+ *  db.PageManageer = debug
+ *
+ */
+class XERIAL_API Logger : NonCopyable, public Printable
+{
+public:
+	enum
+	{
+		LOG_ALL = 0,
+		LOG_TRACE = 1,
+		LOG_DEBUG = 2,
+		LOG_INFO = 3,
+		LOG_WARN = 4 ,
+		LOG_ERROR = 5,
+		LOG_FATAL = 6,
+		LOG_OFF = 7,
+		LOG_UNSPECIFIED = 8
+	};
+
+	/**
+	 * Return the pointer to the logger corresponding to the given logger name
+	 *
+	 * You can organize the hierarchy of loggers using dots in the logger name. For example, two loggers 
+	 * "container.Vector" and  "container.Hash" belong to the same parent "container" logger.
+	 * If you set the log level of the "container" 'LOG_OFF', both of the log messages from "container.Vector" and "container.Hash" will be shut out when
+	 * their log levels are unspecified. 
+	 * 
+	 * Even though the log level of the "container" is 'LOG_OFF', you can output the logs by setting the log level of, for example "container.Vector", to LOG_DEBUG etc., but 
+	 * the log from "container.Hash" still will not be reported since the log reporting mechanism we implemented looks up the parent logger when the log level of the 
+	 * current logger is LOG_UNSPECIFIED.
+	 *
+	 * DEVELOPER_NOTE: 
+	 * This method might be better to return the references to loggers, however, a reference variable in a class definition requires 
+	 * explicit initialization of the reference in the constructor; it sometimes reduces the usability when we cannot specify the logger name in the construction time.
+	 * 
+	 * @param loggerName	
+	 * @return	the pointer to the logger
+	 */
+	static Logger* getLogger(const std::string& loggerName);
+	static Logger* getRootLogger();
+	virtual ~Logger();
+
+	static void configure(const std::string& fileName);
+	std::string toString() const;
+	
+	static std::string loggerList();
+
+	bool isEnabled(int logLevel) const;
+
+	/**
+	* Output the given log messages with the corresponding log level. If the value of forceOutput is true, it outputs the log messages without performing isEnabled(logLevel) check. 
+	* @param message	
+	* @param forceOutput
+	*/
+	void trace(const std::string& message, bool forceOutput = false);
+	void debug(const std::string& message, bool forceOutput = false);
+	void info(const std::string& message, bool forceOutput = false);
+	void warn(const std::string& message, bool forceOutput = false);
+	void error(const std::string& message, bool forceOutput = false);
+	void fatal(const std::string& message, bool forceOutput = false);
+
+
+	int getLevel() const;
+	const std::string& getName() const;
+
+	void setLevel(int level);
+	void setLevel(const std::string& logLevelString);
+	void setOutputFile(const std::string& fileName);
+
+	void defaultOutput();
+	void defaultLevel();
+
+
+	static int main_listLogger(int argc, char** argv);
+
+	static const std::string& convertToString(int logLevel);
+	static int convertToLogLevel(const std::string& logLevelStr);
+protected:
+
+	void resetOutput(std::ostream* out);
+	Logger(Logger* parentLogger, const std::string& name);
+private:
+	bool validLogLevel(int level);
+	void outputLog(int logLevel, const std::string& escapeSeq, const std::string& message, bool forceOutput);
+	
+	int _logLevel;
+	std::ostream* _out;
+	std::string _name;
+	Logger* _parentLogger;
+
+	friend LoggerHolder;
+};
+
+
+
+#define XERIAL_LOGGER_HELPER(messages) StringBuffer log; log << messages
+
+/*
+ * These macro can be used to avoid actual instantiations of messages when they are not reported.
+ * The macro encloses the Message class generation (XERIAL_MESSAGE) within the 'if' clause, so that
+ * the given messages never be evaluated when the test isEnabled fails.
+ */
+#define XERIAL_TRACE(logger, messages) { if(logger->isEnabled(Logger::LOG_TRACE)) { logger->trace(XERIAL_MESSAGE(messages), true); } }
+#define XERIAL_DEBUG(logger, messages) { if(logger->isEnabled(Logger::LOG_DEBUG)) { logger->debug(XERIAL_MESSAGE(messages), true); } }
+#define XERIAL_INFO(logger, messages) {if(logger->isEnabled(Logger::LOG_INFO)) { logger->info(XERIAL_MESSAGE(messages), true); }}
+#define XERIAL_WARN(logger, messages) {if(logger->isEnabled(Logger::LOG_WARN)) { logger->warn(XERIAL_MESSAGE(messages), true); }}
+#define XERIAL_ERROR(logger, messages) {if(logger->isEnabled(Logger::LOG_ERROR)) { logger->error(XERIAL_MESSAGE(messages), true); }}
+#define XERIAL_FATAL(logger, messages) {if(logger->isEnabled(Logger::LOG_FATAL)) { logger->fatal(XERIAL_MESSAGE(messages), true); }}
+
+#define XERIAL_ASSERT_LOG(messages)  XERIAL_FATAL(Logger::getLogger("assert"), messages)
+#define XERIAL_EXCEPTION_LOG(messages) XERIAL_WARN(Logger::getLogger("exception"), messages)
+
+
+#define XERIAL_LOGGER(var, name) namespace { xerial::Logger* var = xerial::Logger::getLogger(#name); } 
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__LOGGER_HPP_20060207_142510
+
+
Index: /sandbox/trunk/pdp/src/xerial/log/LogConfigurationParser.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/log/LogConfigurationParser.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/log/LogConfigurationParser.cpp (revision 939)
@@ -0,0 +1,148 @@
+/* $ANTLR 2.7.6 (2005-12-22): "LogConfiguration.g" -> "LogConfigurationParser.cpp"$ */
+#line 33 "LogConfiguration.g"
+
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Since  2006/08/03 16:19:06
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/branches/leo/btree-devel-0.1/src/xerial/log/LogConfigurationParser.cpp $
+// $Author: leo $ 
+//--------------------------------------------------	
+
+#line 15 "LogConfigurationParser.cpp"
+#include "LogConfigurationParser.hpp"
+#include <antlr/NoViableAltException.hpp>
+#include <antlr/SemanticException.hpp>
+#include <antlr/ASTFactory.hpp>
+#line 45 "LogConfiguration.g"
+    
+#include <iostream>
+#include <string>
+#include "xerial/log/Logger.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+#line 27 "LogConfigurationParser.cpp"
+ANTLR_BEGIN_NAMESPACE(xerial)
+#line 128 "LogConfiguration.g"
+
+#include <vector>
+#include <string>
+
+
+
+#line 35 "LogConfigurationParser.cpp"
+LogConfigurationParser::LogConfigurationParser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf, int k)
+: ANTLR_USE_NAMESPACE(antlr)LLkParser(tokenBuf,k)
+{
+}
+
+LogConfigurationParser::LogConfigurationParser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf)
+: ANTLR_USE_NAMESPACE(antlr)LLkParser(tokenBuf,2)
+{
+}
+
+LogConfigurationParser::LogConfigurationParser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer, int k)
+: ANTLR_USE_NAMESPACE(antlr)LLkParser(lexer,k)
+{
+}
+
+LogConfigurationParser::LogConfigurationParser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer)
+: ANTLR_USE_NAMESPACE(antlr)LLkParser(lexer,2)
+{
+}
+
+LogConfigurationParser::LogConfigurationParser(const ANTLR_USE_NAMESPACE(antlr)ParserSharedInputState& state)
+: ANTLR_USE_NAMESPACE(antlr)LLkParser(state,2)
+{
+}
+
+void LogConfigurationParser::config() {
+	returnAST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST config_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	
+	{ // ( ... )*
+	for (;;) {
+		if ((LA(1) == Literal)) {
+			logLevelDef();
+			astFactory->addASTChild( currentAST, returnAST );
+		}
+		else {
+			goto _loop21;
+		}
+		
+	}
+	_loop21:;
+	} // ( ... )*
+	config_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(currentAST.root);
+#line 156 "LogConfiguration.g"
+	config_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(astFactory->make((new ANTLR_USE_NAMESPACE(antlr)ASTArray(2))->add(astFactory->create(Config,"Config"))->add(config_AST)));
+#line 82 "LogConfigurationParser.cpp"
+	currentAST.root = config_AST;
+	if ( config_AST!=ANTLR_USE_NAMESPACE(antlr)nullAST &&
+		config_AST->getFirstChild() != ANTLR_USE_NAMESPACE(antlr)nullAST )
+		  currentAST.child = config_AST->getFirstChild();
+	else
+		currentAST.child = config_AST;
+	currentAST.advanceChildToEnd();
+	config_AST = currentAST.root;
+	returnAST = config_AST;
+}
+
+void LogConfigurationParser::logLevelDef() {
+	returnAST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)ASTPair currentAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST logLevelDef_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	
+	ANTLR_USE_NAMESPACE(antlr)RefAST tmp3_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	tmp3_AST = astFactory->create(LT(1));
+	astFactory->addASTChild(currentAST, tmp3_AST);
+	match(Literal);
+	match(14);
+	ANTLR_USE_NAMESPACE(antlr)RefAST tmp5_AST = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	tmp5_AST = astFactory->create(LT(1));
+	astFactory->addASTChild(currentAST, tmp5_AST);
+	match(Literal);
+	logLevelDef_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(currentAST.root);
+#line 161 "LogConfiguration.g"
+	logLevelDef_AST = ANTLR_USE_NAMESPACE(antlr)RefAST(astFactory->make((new ANTLR_USE_NAMESPACE(antlr)ASTArray(2))->add(astFactory->create(LogLevel,"LogLevel"))->add(logLevelDef_AST)));
+#line 111 "LogConfigurationParser.cpp"
+	currentAST.root = logLevelDef_AST;
+	if ( logLevelDef_AST!=ANTLR_USE_NAMESPACE(antlr)nullAST &&
+		logLevelDef_AST->getFirstChild() != ANTLR_USE_NAMESPACE(antlr)nullAST )
+		  currentAST.child = logLevelDef_AST->getFirstChild();
+	else
+		currentAST.child = logLevelDef_AST;
+	currentAST.advanceChildToEnd();
+	logLevelDef_AST = currentAST.root;
+	returnAST = logLevelDef_AST;
+}
+
+void LogConfigurationParser::initializeASTFactory( ANTLR_USE_NAMESPACE(antlr)ASTFactory& factory )
+{
+	factory.setMaxNodeType(14);
+}
+const char* LogConfigurationParser::tokenNames[] = {
+	"<0>",
+	"EOF",
+	"<2>",
+	"NULL_TREE_LOOKAHEAD",
+	"Letter",
+	"Digit",
+	"Digits",
+	"Char",
+	"Eq",
+	"Literal",
+	"WhiteSpaceChar",
+	"SL_COMMENT",
+	"Config",
+	"LogLevel",
+	"\"=\"",
+	0
+};
+
+
+
+ANTLR_END_NAMESPACE
Index: /sandbox/trunk/pdp/src/xerial/log/LogConfigurationTreeParser.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/log/LogConfigurationTreeParser.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/log/LogConfigurationTreeParser.cpp (revision 939)
@@ -0,0 +1,137 @@
+/* $ANTLR 2.7.6 (2005-12-22): "LogConfiguration.g" -> "LogConfigurationTreeParser.cpp"$ */
+#line 33 "LogConfiguration.g"
+
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Since  2006/08/03 16:19:06
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/branches/leo/btree-devel-0.1/src/xerial/log/LogConfigurationTreeParser.cpp $
+// $Author: leo $ 
+//--------------------------------------------------	
+
+#line 15 "LogConfigurationTreeParser.cpp"
+#include "LogConfigurationTreeParser.hpp"
+#include <antlr/Token.hpp>
+#include <antlr/AST.hpp>
+#include <antlr/NoViableAltException.hpp>
+#include <antlr/MismatchedTokenException.hpp>
+#include <antlr/SemanticException.hpp>
+#include <antlr/BitSet.hpp>
+#line 45 "LogConfiguration.g"
+    
+#include <iostream>
+#include <string>
+#include "xerial/log/Logger.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+#line 30 "LogConfigurationTreeParser.cpp"
+ANTLR_BEGIN_NAMESPACE(xerial)
+#line 170 "LogConfiguration.g"
+
+
+
+
+void 
+LogConfigurationTreeParser::setLogLevel(const std::string& loggerName, const std::string& logLevel)
+{
+	Logger* logger = (loggerName != "root") ? Logger::getLogger(loggerName) : Logger::getRootLogger();
+	logger->setLevel(logLevel);
+}
+
+
+#line 44 "LogConfigurationTreeParser.cpp"
+LogConfigurationTreeParser::LogConfigurationTreeParser()
+	: ANTLR_USE_NAMESPACE(antlr)TreeParser() {
+}
+
+void LogConfigurationTreeParser::config(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
+	ANTLR_USE_NAMESPACE(antlr)RefAST config_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
+	
+	try {      // for error handling
+		ANTLR_USE_NAMESPACE(antlr)RefAST __t24 = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp1_AST_in = _t;
+		match(_t,Config);
+		_t = _t->getFirstChild();
+		{ // ( ... )*
+		for (;;) {
+			if (_t == ANTLR_USE_NAMESPACE(antlr)nullAST )
+				_t = ASTNULL;
+			if ((_t->getType() == LogLevel)) {
+				loglevel(_t);
+				_t = _retTree;
+			}
+			else {
+				goto _loop26;
+			}
+			
+		}
+		_loop26:;
+		} // ( ... )*
+		_t = __t24;
+		_t = _t->getNextSibling();
+	}
+	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
+		reportError(ex);
+		if ( _t != ANTLR_USE_NAMESPACE(antlr)nullAST )
+			_t = _t->getNextSibling();
+	}
+	_retTree = _t;
+}
+
+void LogConfigurationTreeParser::loglevel(ANTLR_USE_NAMESPACE(antlr)RefAST _t) {
+	ANTLR_USE_NAMESPACE(antlr)RefAST loglevel_AST_in = (_t == ANTLR_USE_NAMESPACE(antlr)RefAST(ASTNULL)) ? ANTLR_USE_NAMESPACE(antlr)nullAST : _t;
+	ANTLR_USE_NAMESPACE(antlr)RefAST a = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST b = ANTLR_USE_NAMESPACE(antlr)nullAST;
+	
+	try {      // for error handling
+		ANTLR_USE_NAMESPACE(antlr)RefAST __t28 = _t;
+		ANTLR_USE_NAMESPACE(antlr)RefAST tmp2_AST_in = _t;
+		match(_t,LogLevel);
+		_t = _t->getFirstChild();
+		a = _t;
+		match(_t,Literal);
+		_t = _t->getNextSibling();
+		b = _t;
+		match(_t,Literal);
+		_t = _t->getNextSibling();
+		_t = __t28;
+		_t = _t->getNextSibling();
+#line 195 "LogConfiguration.g"
+		setLogLevel(a->getText(), b->getText());
+#line 103 "LogConfigurationTreeParser.cpp"
+	}
+	catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& ex) {
+		reportError(ex);
+		if ( _t != ANTLR_USE_NAMESPACE(antlr)nullAST )
+			_t = _t->getNextSibling();
+	}
+	_retTree = _t;
+}
+
+void LogConfigurationTreeParser::initializeASTFactory( ANTLR_USE_NAMESPACE(antlr)ASTFactory& )
+{
+}
+const char* LogConfigurationTreeParser::tokenNames[] = {
+	"<0>",
+	"EOF",
+	"<2>",
+	"NULL_TREE_LOOKAHEAD",
+	"Letter",
+	"Digit",
+	"Digits",
+	"Char",
+	"Eq",
+	"Literal",
+	"WhiteSpaceChar",
+	"SL_COMMENT",
+	"Config",
+	"LogLevel",
+	"\"=\"",
+	0
+};
+
+
+
+ANTLR_END_NAMESPACE
Index: /sandbox/trunk/pdp/src/xerial/log/LogConfigurationLexer.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/log/LogConfigurationLexer.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/log/LogConfigurationLexer.cpp (revision 939)
@@ -0,0 +1,766 @@
+/* $ANTLR 2.7.6 (2005-12-22): "LogConfiguration.g" -> "LogConfigurationLexer.cpp"$ */
+#line 33 "LogConfiguration.g"
+
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Since  2006/08/03 16:19:06
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/branches/leo/btree-devel-0.1/src/xerial/log/LogConfigurationLexer.cpp $
+// $Author: leo $ 
+//--------------------------------------------------	
+
+#line 15 "LogConfigurationLexer.cpp"
+#include "LogConfigurationLexer.hpp"
+#include <antlr/CharBuffer.hpp>
+#include <antlr/TokenStreamException.hpp>
+#include <antlr/TokenStreamIOException.hpp>
+#include <antlr/TokenStreamRecognitionException.hpp>
+#include <antlr/CharStreamException.hpp>
+#include <antlr/CharStreamIOException.hpp>
+#include <antlr/NoViableAltForCharException.hpp>
+
+#line 45 "LogConfiguration.g"
+    
+#include <iostream>
+#include <string>
+#include "xerial/log/Logger.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+#line 32 "LogConfigurationLexer.cpp"
+ANTLR_BEGIN_NAMESPACE(xerial)
+#line 1 "LogConfiguration.g"
+#line 34 "LogConfigurationLexer.cpp"
+LogConfigurationLexer::LogConfigurationLexer(ANTLR_USE_NAMESPACE(std)istream& in)
+	: ANTLR_USE_NAMESPACE(antlr)CharScanner(new ANTLR_USE_NAMESPACE(antlr)CharBuffer(in),true)
+{
+	initLiterals();
+}
+
+LogConfigurationLexer::LogConfigurationLexer(ANTLR_USE_NAMESPACE(antlr)InputBuffer& ib)
+	: ANTLR_USE_NAMESPACE(antlr)CharScanner(ib,true)
+{
+	initLiterals();
+}
+
+LogConfigurationLexer::LogConfigurationLexer(const ANTLR_USE_NAMESPACE(antlr)LexerSharedInputState& state)
+	: ANTLR_USE_NAMESPACE(antlr)CharScanner(state,true)
+{
+	initLiterals();
+}
+
+void LogConfigurationLexer::initLiterals()
+{
+	literals["="] = 14;
+}
+
+ANTLR_USE_NAMESPACE(antlr)RefToken LogConfigurationLexer::nextToken()
+{
+	ANTLR_USE_NAMESPACE(antlr)RefToken theRetToken;
+	for (;;) {
+		ANTLR_USE_NAMESPACE(antlr)RefToken theRetToken;
+		int _ttype = ANTLR_USE_NAMESPACE(antlr)Token::INVALID_TYPE;
+		resetText();
+		try {   // for lexical and char stream error handling
+			switch ( LA(1)) {
+			case 0x30 /* '0' */ :
+			case 0x31 /* '1' */ :
+			case 0x32 /* '2' */ :
+			case 0x33 /* '3' */ :
+			case 0x34 /* '4' */ :
+			case 0x35 /* '5' */ :
+			case 0x36 /* '6' */ :
+			case 0x37 /* '7' */ :
+			case 0x38 /* '8' */ :
+			case 0x39 /* '9' */ :
+			{
+				mDigits(true);
+				theRetToken=_returnToken;
+				break;
+			}
+			case 0x3d /* '=' */ :
+			{
+				mEq(true);
+				theRetToken=_returnToken;
+				break;
+			}
+			case 0x41 /* 'A' */ :
+			case 0x42 /* 'B' */ :
+			case 0x43 /* 'C' */ :
+			case 0x44 /* 'D' */ :
+			case 0x45 /* 'E' */ :
+			case 0x46 /* 'F' */ :
+			case 0x47 /* 'G' */ :
+			case 0x48 /* 'H' */ :
+			case 0x49 /* 'I' */ :
+			case 0x4a /* 'J' */ :
+			case 0x4b /* 'K' */ :
+			case 0x4c /* 'L' */ :
+			case 0x4d /* 'M' */ :
+			case 0x4e /* 'N' */ :
+			case 0x4f /* 'O' */ :
+			case 0x50 /* 'P' */ :
+			case 0x51 /* 'Q' */ :
+			case 0x52 /* 'R' */ :
+			case 0x53 /* 'S' */ :
+			case 0x54 /* 'T' */ :
+			case 0x55 /* 'U' */ :
+			case 0x56 /* 'V' */ :
+			case 0x57 /* 'W' */ :
+			case 0x58 /* 'X' */ :
+			case 0x59 /* 'Y' */ :
+			case 0x5a /* 'Z' */ :
+			case 0x61 /* 'a' */ :
+			case 0x62 /* 'b' */ :
+			case 0x63 /* 'c' */ :
+			case 0x64 /* 'd' */ :
+			case 0x65 /* 'e' */ :
+			case 0x66 /* 'f' */ :
+			case 0x67 /* 'g' */ :
+			case 0x68 /* 'h' */ :
+			case 0x69 /* 'i' */ :
+			case 0x6a /* 'j' */ :
+			case 0x6b /* 'k' */ :
+			case 0x6c /* 'l' */ :
+			case 0x6d /* 'm' */ :
+			case 0x6e /* 'n' */ :
+			case 0x6f /* 'o' */ :
+			case 0x70 /* 'p' */ :
+			case 0x71 /* 'q' */ :
+			case 0x72 /* 'r' */ :
+			case 0x73 /* 's' */ :
+			case 0x74 /* 't' */ :
+			case 0x75 /* 'u' */ :
+			case 0x76 /* 'v' */ :
+			case 0x77 /* 'w' */ :
+			case 0x78 /* 'x' */ :
+			case 0x79 /* 'y' */ :
+			case 0x7a /* 'z' */ :
+			case 0xc0:
+			case 0xc1:
+			case 0xc2:
+			case 0xc3:
+			case 0xc4:
+			case 0xc5:
+			case 0xc6:
+			case 0xc7:
+			case 0xc8:
+			case 0xc9:
+			case 0xca:
+			case 0xcb:
+			case 0xcc:
+			case 0xcd:
+			case 0xce:
+			case 0xcf:
+			case 0xd0:
+			case 0xd1:
+			case 0xd2:
+			case 0xd3:
+			case 0xd4:
+			case 0xd5:
+			case 0xd6:
+			case 0xd8:
+			case 0xd9:
+			case 0xda:
+			case 0xdb:
+			case 0xdc:
+			case 0xdd:
+			case 0xde:
+			case 0xdf:
+			case 0xe0:
+			case 0xe1:
+			case 0xe2:
+			case 0xe3:
+			case 0xe4:
+			case 0xe5:
+			case 0xe6:
+			case 0xe7:
+			case 0xe8:
+			case 0xe9:
+			case 0xea:
+			case 0xeb:
+			case 0xec:
+			case 0xed:
+			case 0xee:
+			case 0xef:
+			case 0xf0:
+			case 0xf1:
+			case 0xf2:
+			case 0xf3:
+			case 0xf4:
+			case 0xf5:
+			case 0xf6:
+			case 0xf8:
+			case 0xf9:
+			case 0xfa:
+			case 0xfb:
+			case 0xfc:
+			case 0xfd:
+			case 0xfe:
+			case 0xff:
+			{
+				mLiteral(true);
+				theRetToken=_returnToken;
+				break;
+			}
+			case 0x9 /* '\t' */ :
+			case 0xa /* '\n' */ :
+			case 0xd /* '\r' */ :
+			case 0x20 /* ' ' */ :
+			{
+				mWhiteSpaceChar(true);
+				theRetToken=_returnToken;
+				break;
+			}
+			case 0x2f /* '/' */ :
+			{
+				mSL_COMMENT(true);
+				theRetToken=_returnToken;
+				break;
+			}
+			default:
+			{
+				if (LA(1)==EOF_CHAR)
+				{
+					uponEOF();
+					_returnToken = makeToken(ANTLR_USE_NAMESPACE(antlr)Token::EOF_TYPE);
+				}
+				else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
+			}
+			}
+			if ( !_returnToken )
+				goto tryAgain; // found SKIP token
+
+			_ttype = _returnToken->getType();
+			_ttype = testLiteralsTable(_ttype);
+			_returnToken->setType(_ttype);
+			return _returnToken;
+		}
+		catch (ANTLR_USE_NAMESPACE(antlr)RecognitionException& e) {
+				throw ANTLR_USE_NAMESPACE(antlr)TokenStreamRecognitionException(e);
+		}
+		catch (ANTLR_USE_NAMESPACE(antlr)CharStreamIOException& csie) {
+			throw ANTLR_USE_NAMESPACE(antlr)TokenStreamIOException(csie.io);
+		}
+		catch (ANTLR_USE_NAMESPACE(antlr)CharStreamException& cse) {
+			throw ANTLR_USE_NAMESPACE(antlr)TokenStreamException(cse.getMessage());
+		}
+tryAgain:;
+	}
+}
+
+void LogConfigurationLexer::mLetter(bool _createToken) {
+	int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
+	_ttype = Letter;
+	ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
+	
+	switch ( LA(1)) {
+	case 0x41 /* 'A' */ :
+	case 0x42 /* 'B' */ :
+	case 0x43 /* 'C' */ :
+	case 0x44 /* 'D' */ :
+	case 0x45 /* 'E' */ :
+	case 0x46 /* 'F' */ :
+	case 0x47 /* 'G' */ :
+	case 0x48 /* 'H' */ :
+	case 0x49 /* 'I' */ :
+	case 0x4a /* 'J' */ :
+	case 0x4b /* 'K' */ :
+	case 0x4c /* 'L' */ :
+	case 0x4d /* 'M' */ :
+	case 0x4e /* 'N' */ :
+	case 0x4f /* 'O' */ :
+	case 0x50 /* 'P' */ :
+	case 0x51 /* 'Q' */ :
+	case 0x52 /* 'R' */ :
+	case 0x53 /* 'S' */ :
+	case 0x54 /* 'T' */ :
+	case 0x55 /* 'U' */ :
+	case 0x56 /* 'V' */ :
+	case 0x57 /* 'W' */ :
+	case 0x58 /* 'X' */ :
+	case 0x59 /* 'Y' */ :
+	case 0x5a /* 'Z' */ :
+	{
+		matchRange('A','Z');
+		break;
+	}
+	case 0x61 /* 'a' */ :
+	case 0x62 /* 'b' */ :
+	case 0x63 /* 'c' */ :
+	case 0x64 /* 'd' */ :
+	case 0x65 /* 'e' */ :
+	case 0x66 /* 'f' */ :
+	case 0x67 /* 'g' */ :
+	case 0x68 /* 'h' */ :
+	case 0x69 /* 'i' */ :
+	case 0x6a /* 'j' */ :
+	case 0x6b /* 'k' */ :
+	case 0x6c /* 'l' */ :
+	case 0x6d /* 'm' */ :
+	case 0x6e /* 'n' */ :
+	case 0x6f /* 'o' */ :
+	case 0x70 /* 'p' */ :
+	case 0x71 /* 'q' */ :
+	case 0x72 /* 'r' */ :
+	case 0x73 /* 's' */ :
+	case 0x74 /* 't' */ :
+	case 0x75 /* 'u' */ :
+	case 0x76 /* 'v' */ :
+	case 0x77 /* 'w' */ :
+	case 0x78 /* 'x' */ :
+	case 0x79 /* 'y' */ :
+	case 0x7a /* 'z' */ :
+	{
+		matchRange('a','z');
+		break;
+	}
+	case 0xc0:
+	case 0xc1:
+	case 0xc2:
+	case 0xc3:
+	case 0xc4:
+	case 0xc5:
+	case 0xc6:
+	case 0xc7:
+	case 0xc8:
+	case 0xc9:
+	case 0xca:
+	case 0xcb:
+	case 0xcc:
+	case 0xcd:
+	case 0xce:
+	case 0xcf:
+	case 0xd0:
+	case 0xd1:
+	case 0xd2:
+	case 0xd3:
+	case 0xd4:
+	case 0xd5:
+	case 0xd6:
+	{
+		matchRange(static_cast<unsigned char>('\300'),static_cast<unsigned char>('\326'));
+		break;
+	}
+	case 0xd8:
+	case 0xd9:
+	case 0xda:
+	case 0xdb:
+	case 0xdc:
+	case 0xdd:
+	case 0xde:
+	case 0xdf:
+	case 0xe0:
+	case 0xe1:
+	case 0xe2:
+	case 0xe3:
+	case 0xe4:
+	case 0xe5:
+	case 0xe6:
+	case 0xe7:
+	case 0xe8:
+	case 0xe9:
+	case 0xea:
+	case 0xeb:
+	case 0xec:
+	case 0xed:
+	case 0xee:
+	case 0xef:
+	case 0xf0:
+	case 0xf1:
+	case 0xf2:
+	case 0xf3:
+	case 0xf4:
+	case 0xf5:
+	case 0xf6:
+	{
+		matchRange(static_cast<unsigned char>('\330'),static_cast<unsigned char>('\366'));
+		break;
+	}
+	case 0xf8:
+	case 0xf9:
+	case 0xfa:
+	case 0xfb:
+	case 0xfc:
+	case 0xfd:
+	case 0xfe:
+	case 0xff:
+	{
+		matchRange(static_cast<unsigned char>('\370'),static_cast<unsigned char>('\377'));
+		break;
+	}
+	default:
+	{
+		throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
+	}
+	}
+	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
+	   _token = makeToken(_ttype);
+	   _token->setText(text.substr(_begin, text.length()-_begin));
+	}
+	_returnToken = _token;
+	_saveIndex=0;
+}
+
+void LogConfigurationLexer::mDigit(bool _createToken) {
+	int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
+	_ttype = Digit;
+	ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
+	
+	matchRange('0','9');
+	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
+	   _token = makeToken(_ttype);
+	   _token->setText(text.substr(_begin, text.length()-_begin));
+	}
+	_returnToken = _token;
+	_saveIndex=0;
+}
+
+void LogConfigurationLexer::mDigits(bool _createToken) {
+	int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
+	_ttype = Digits;
+	ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
+	
+	{ // ( ... )+
+	int _cnt5=0;
+	for (;;) {
+		if (((LA(1) >= 0x30 /* '0' */  && LA(1) <= 0x39 /* '9' */ ))) {
+			mDigit(false);
+		}
+		else {
+			if ( _cnt5>=1 ) { goto _loop5; } else {throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());}
+		}
+		
+		_cnt5++;
+	}
+	_loop5:;
+	}  // ( ... )+
+	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
+	   _token = makeToken(_ttype);
+	   _token->setText(text.substr(_begin, text.length()-_begin));
+	}
+	_returnToken = _token;
+	_saveIndex=0;
+}
+
+void LogConfigurationLexer::mChar(bool _createToken) {
+	int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
+	_ttype = Char;
+	ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
+	
+	switch ( LA(1)) {
+	case 0x41 /* 'A' */ :
+	case 0x42 /* 'B' */ :
+	case 0x43 /* 'C' */ :
+	case 0x44 /* 'D' */ :
+	case 0x45 /* 'E' */ :
+	case 0x46 /* 'F' */ :
+	case 0x47 /* 'G' */ :
+	case 0x48 /* 'H' */ :
+	case 0x49 /* 'I' */ :
+	case 0x4a /* 'J' */ :
+	case 0x4b /* 'K' */ :
+	case 0x4c /* 'L' */ :
+	case 0x4d /* 'M' */ :
+	case 0x4e /* 'N' */ :
+	case 0x4f /* 'O' */ :
+	case 0x50 /* 'P' */ :
+	case 0x51 /* 'Q' */ :
+	case 0x52 /* 'R' */ :
+	case 0x53 /* 'S' */ :
+	case 0x54 /* 'T' */ :
+	case 0x55 /* 'U' */ :
+	case 0x56 /* 'V' */ :
+	case 0x57 /* 'W' */ :
+	case 0x58 /* 'X' */ :
+	case 0x59 /* 'Y' */ :
+	case 0x5a /* 'Z' */ :
+	case 0x61 /* 'a' */ :
+	case 0x62 /* 'b' */ :
+	case 0x63 /* 'c' */ :
+	case 0x64 /* 'd' */ :
+	case 0x65 /* 'e' */ :
+	case 0x66 /* 'f' */ :
+	case 0x67 /* 'g' */ :
+	case 0x68 /* 'h' */ :
+	case 0x69 /* 'i' */ :
+	case 0x6a /* 'j' */ :
+	case 0x6b /* 'k' */ :
+	case 0x6c /* 'l' */ :
+	case 0x6d /* 'm' */ :
+	case 0x6e /* 'n' */ :
+	case 0x6f /* 'o' */ :
+	case 0x70 /* 'p' */ :
+	case 0x71 /* 'q' */ :
+	case 0x72 /* 'r' */ :
+	case 0x73 /* 's' */ :
+	case 0x74 /* 't' */ :
+	case 0x75 /* 'u' */ :
+	case 0x76 /* 'v' */ :
+	case 0x77 /* 'w' */ :
+	case 0x78 /* 'x' */ :
+	case 0x79 /* 'y' */ :
+	case 0x7a /* 'z' */ :
+	case 0xc0:
+	case 0xc1:
+	case 0xc2:
+	case 0xc3:
+	case 0xc4:
+	case 0xc5:
+	case 0xc6:
+	case 0xc7:
+	case 0xc8:
+	case 0xc9:
+	case 0xca:
+	case 0xcb:
+	case 0xcc:
+	case 0xcd:
+	case 0xce:
+	case 0xcf:
+	case 0xd0:
+	case 0xd1:
+	case 0xd2:
+	case 0xd3:
+	case 0xd4:
+	case 0xd5:
+	case 0xd6:
+	case 0xd8:
+	case 0xd9:
+	case 0xda:
+	case 0xdb:
+	case 0xdc:
+	case 0xdd:
+	case 0xde:
+	case 0xdf:
+	case 0xe0:
+	case 0xe1:
+	case 0xe2:
+	case 0xe3:
+	case 0xe4:
+	case 0xe5:
+	case 0xe6:
+	case 0xe7:
+	case 0xe8:
+	case 0xe9:
+	case 0xea:
+	case 0xeb:
+	case 0xec:
+	case 0xed:
+	case 0xee:
+	case 0xef:
+	case 0xf0:
+	case 0xf1:
+	case 0xf2:
+	case 0xf3:
+	case 0xf4:
+	case 0xf5:
+	case 0xf6:
+	case 0xf8:
+	case 0xf9:
+	case 0xfa:
+	case 0xfb:
+	case 0xfc:
+	case 0xfd:
+	case 0xfe:
+	case 0xff:
+	{
+		mLetter(false);
+		break;
+	}
+	case 0x30 /* '0' */ :
+	case 0x31 /* '1' */ :
+	case 0x32 /* '2' */ :
+	case 0x33 /* '3' */ :
+	case 0x34 /* '4' */ :
+	case 0x35 /* '5' */ :
+	case 0x36 /* '6' */ :
+	case 0x37 /* '7' */ :
+	case 0x38 /* '8' */ :
+	case 0x39 /* '9' */ :
+	{
+		mDigit(false);
+		break;
+	}
+	case 0x2e /* '.' */ :
+	{
+		match('.' /* charlit */ );
+		break;
+	}
+	case 0x2d /* '-' */ :
+	{
+		match('-' /* charlit */ );
+		break;
+	}
+	case 0x5f /* '_' */ :
+	{
+		match('_' /* charlit */ );
+		break;
+	}
+	default:
+	{
+		throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
+	}
+	}
+	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
+	   _token = makeToken(_ttype);
+	   _token->setText(text.substr(_begin, text.length()-_begin));
+	}
+	_returnToken = _token;
+	_saveIndex=0;
+}
+
+void LogConfigurationLexer::mEq(bool _createToken) {
+	int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
+	_ttype = Eq;
+	ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
+	
+	match('=' /* charlit */ );
+	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
+	   _token = makeToken(_ttype);
+	   _token->setText(text.substr(_begin, text.length()-_begin));
+	}
+	_returnToken = _token;
+	_saveIndex=0;
+}
+
+void LogConfigurationLexer::mLiteral(bool _createToken) {
+	int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
+	_ttype = Literal;
+	ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
+	
+	mLetter(false);
+	{ // ( ... )*
+	for (;;) {
+		if ((_tokenSet_0.member(LA(1)))) {
+			mChar(false);
+		}
+		else {
+			goto _loop10;
+		}
+		
+	}
+	_loop10:;
+	} // ( ... )*
+	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
+	   _token = makeToken(_ttype);
+	   _token->setText(text.substr(_begin, text.length()-_begin));
+	}
+	_returnToken = _token;
+	_saveIndex=0;
+}
+
+void LogConfigurationLexer::mWhiteSpaceChar(bool _createToken) {
+	int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
+	_ttype = WhiteSpaceChar;
+	ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
+	
+	{
+	switch ( LA(1)) {
+	case 0x20 /* ' ' */ :
+	{
+		match(' ' /* charlit */ );
+		break;
+	}
+	case 0x9 /* '\t' */ :
+	{
+		match('\t' /* charlit */ );
+		break;
+	}
+	case 0xa /* '\n' */ :
+	{
+		match('\n' /* charlit */ );
+#line 101 "LogConfiguration.g"
+		newline();
+#line 675 "LogConfigurationLexer.cpp"
+		break;
+	}
+	case 0xd /* '\r' */ :
+	{
+		match('\r' /* charlit */ );
+		break;
+	}
+	default:
+	{
+		throw ANTLR_USE_NAMESPACE(antlr)NoViableAltForCharException(LA(1), getFilename(), getLine(), getColumn());
+	}
+	}
+	}
+#line 102 "LogConfiguration.g"
+	_ttype = antlr::Token::SKIP;
+#line 691 "LogConfigurationLexer.cpp"
+	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
+	   _token = makeToken(_ttype);
+	   _token->setText(text.substr(_begin, text.length()-_begin));
+	}
+	_returnToken = _token;
+	_saveIndex=0;
+}
+
+void LogConfigurationLexer::mSL_COMMENT(bool _createToken) {
+	int _ttype; ANTLR_USE_NAMESPACE(antlr)RefToken _token; ANTLR_USE_NAMESPACE(std)string::size_type _begin = text.length();
+	_ttype = SL_COMMENT;
+	ANTLR_USE_NAMESPACE(std)string::size_type _saveIndex;
+	
+	match("//");
+	{ // ( ... )*
+	for (;;) {
+		if ((_tokenSet_1.member(LA(1)))) {
+			{
+			match(_tokenSet_1);
+			}
+		}
+		else {
+			goto _loop16;
+		}
+		
+	}
+	_loop16:;
+	} // ( ... )*
+	{
+	switch ( LA(1)) {
+	case 0xa /* '\n' */ :
+	{
+		match('\n' /* charlit */ );
+		break;
+	}
+	case 0xd /* '\r' */ :
+	{
+		match('\r' /* charlit */ );
+		{
+		if ((LA(1) == 0xa /* '\n' */ )) {
+			match('\n' /* charlit */ );
+		}
+		else {
+		}
+		
+		}
+		break;
+	}
+	default:
+		{
+		}
+	}
+	}
+#line 107 "LogConfiguration.g"
+	
+				_ttype = antlr::Token::SKIP;
+				newline();
+			
+#line 750 "LogConfigurationLexer.cpp"
+	if ( _createToken && _token==ANTLR_USE_NAMESPACE(antlr)nullToken && _ttype!=ANTLR_USE_NAMESPACE(antlr)Token::SKIP ) {
+	   _token = makeToken(_ttype);
+	   _token->setText(text.substr(_begin, text.length()-_begin));
+	}
+	_returnToken = _token;
+	_saveIndex=0;
+}
+
+
+const unsigned long LogConfigurationLexer::_tokenSet_0_data_[] = { 0UL, 67067904UL, 2281701374UL, 134217726UL, 0UL, 0UL, 4286578687UL, 4286578687UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
+const ANTLR_USE_NAMESPACE(antlr)BitSet LogConfigurationLexer::_tokenSet_0(_tokenSet_0_data_,16);
+const unsigned long LogConfigurationLexer::_tokenSet_1_data_[] = { 4294958079UL, 4294967295UL, 4294967295UL, 4294967295UL, 0UL, 0UL, 4286578687UL, 4286578687UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL, 0UL };
+// 0x0 0x1 0x2 0x3 0x4 0x5 0x6 0x7 0x8 0x9 0xb 0xc 0xe 
+const ANTLR_USE_NAMESPACE(antlr)BitSet LogConfigurationLexer::_tokenSet_1(_tokenSet_1_data_,16);
+
+ANTLR_END_NAMESPACE
Index: /sandbox/trunk/pdp/src/xerial/log/LogConfigurationParser.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/log/LogConfigurationParser.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/log/LogConfigurationParser.hpp (revision 939)
@@ -0,0 +1,95 @@
+#ifndef INC_LogConfigurationParser_hpp_
+#define INC_LogConfigurationParser_hpp_
+
+#line 11 "LogConfiguration.g"
+
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Since  2006/08/03 16:19:06
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/branches/leo/btree-devel-0.1/src/xerial/log/LogConfigurationParser.hpp $
+// $Author: leo $ 
+//--------------------------------------------------	
+#include "xerial/common/xerial.hpp"
+#include <iosfwd>
+#include <string>
+#define CUSTOM_API XERIAL_API
+#ifdef WIN32
+// disable warnings for unused local variables and int to char conversion within ANTLR codes
+#pragma warning(disable: 4100 4244)
+#endif // WIN32
+
+#line 25 "LogConfigurationParser.hpp"
+#include <antlr/config.hpp>
+/* $ANTLR 2.7.6 (2005-12-22): "LogConfiguration.g" -> "LogConfigurationParser.hpp"$ */
+#include <antlr/TokenStream.hpp>
+#include <antlr/TokenBuffer.hpp>
+#include "LogConfigurationLexerTokenTypes.hpp"
+#include <antlr/LLkParser.hpp>
+
+#line 30 "LogConfiguration.g"
+
+
+#line 36 "LogConfigurationParser.hpp"
+ANTLR_BEGIN_NAMESPACE(xerial)
+#line 52 "LogConfiguration.g"
+
+    // gets inserted after generated namespace specifications in the header
+    // file. But outside the generated class.
+
+#line 42 "LogConfigurationParser.hpp"
+class CUSTOM_API LogConfigurationParser : public ANTLR_USE_NAMESPACE(antlr)LLkParser, public LogConfigurationLexerTokenTypes
+{
+#line 150 "LogConfiguration.g"
+
+#line 46 "LogConfigurationParser.hpp"
+public:
+	void initializeASTFactory( ANTLR_USE_NAMESPACE(antlr)ASTFactory& factory );
+protected:
+	LogConfigurationParser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf, int k);
+public:
+	LogConfigurationParser(ANTLR_USE_NAMESPACE(antlr)TokenBuffer& tokenBuf);
+protected:
+	LogConfigurationParser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer, int k);
+public:
+	LogConfigurationParser(ANTLR_USE_NAMESPACE(antlr)TokenStream& lexer);
+	LogConfigurationParser(const ANTLR_USE_NAMESPACE(antlr)ParserSharedInputState& state);
+	int getNumTokens() const
+	{
+		return LogConfigurationParser::NUM_TOKENS;
+	}
+	const char* getTokenName( int type ) const
+	{
+		if( type > getNumTokens() ) return 0;
+		return LogConfigurationParser::tokenNames[type];
+	}
+	const char* const* getTokenNames() const
+	{
+		return LogConfigurationParser::tokenNames;
+	}
+	public: void config();
+	public: void logLevelDef();
+public:
+	ANTLR_USE_NAMESPACE(antlr)RefAST getAST()
+	{
+		return returnAST;
+	}
+	
+protected:
+	ANTLR_USE_NAMESPACE(antlr)RefAST returnAST;
+private:
+	static const char* tokenNames[];
+#ifndef NO_STATIC_CONSTS
+	static const int NUM_TOKENS = 15;
+#else
+	enum {
+		NUM_TOKENS = 15
+	};
+#endif
+	
+};
+
+ANTLR_END_NAMESPACE
+#endif /*INC_LogConfigurationParser_hpp_*/
Index: /sandbox/trunk/pdp/src/xerial/log/LogConfigurationTreeParser.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/log/LogConfigurationTreeParser.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/log/LogConfigurationTreeParser.hpp (revision 939)
@@ -0,0 +1,87 @@
+#ifndef INC_LogConfigurationTreeParser_hpp_
+#define INC_LogConfigurationTreeParser_hpp_
+
+#line 11 "LogConfiguration.g"
+
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Since  2006/08/03 16:19:06
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/branches/leo/btree-devel-0.1/src/xerial/log/LogConfigurationTreeParser.hpp $
+// $Author: leo $ 
+//--------------------------------------------------	
+#include "xerial/common/xerial.hpp"
+#include <iosfwd>
+#include <string>
+#define CUSTOM_API XERIAL_API
+#ifdef WIN32
+// disable warnings for unused local variables and int to char conversion within ANTLR codes
+#pragma warning(disable: 4100 4244)
+#endif // WIN32
+
+#line 25 "LogConfigurationTreeParser.hpp"
+#include <antlr/config.hpp>
+#include "LogConfigurationLexerTokenTypes.hpp"
+/* $ANTLR 2.7.6 (2005-12-22): "LogConfiguration.g" -> "LogConfigurationTreeParser.hpp"$ */
+#include <antlr/TreeParser.hpp>
+
+#line 30 "LogConfiguration.g"
+
+
+#line 34 "LogConfigurationTreeParser.hpp"
+ANTLR_BEGIN_NAMESPACE(xerial)
+#line 52 "LogConfiguration.g"
+
+    // gets inserted after generated namespace specifications in the header
+    // file. But outside the generated class.
+
+#line 40 "LogConfigurationTreeParser.hpp"
+class CUSTOM_API LogConfigurationTreeParser : public ANTLR_USE_NAMESPACE(antlr)TreeParser, public LogConfigurationLexerTokenTypes
+{
+#line 187 "LogConfiguration.g"
+
+	void setLogLevel(const std::string& loggerName, const std::string& logLevel);
+#line 44 "LogConfigurationTreeParser.hpp"
+public:
+	LogConfigurationTreeParser();
+	static void initializeASTFactory( ANTLR_USE_NAMESPACE(antlr)ASTFactory& factory );
+	int getNumTokens() const
+	{
+		return LogConfigurationTreeParser::NUM_TOKENS;
+	}
+	const char* getTokenName( int type ) const
+	{
+		if( type > getNumTokens() ) return 0;
+		return LogConfigurationTreeParser::tokenNames[type];
+	}
+	const char* const* getTokenNames() const
+	{
+		return LogConfigurationTreeParser::tokenNames;
+	}
+	public: void config(ANTLR_USE_NAMESPACE(antlr)RefAST _t);
+	public: void loglevel(ANTLR_USE_NAMESPACE(antlr)RefAST _t);
+public:
+	ANTLR_USE_NAMESPACE(antlr)RefAST getAST()
+	{
+		return returnAST;
+	}
+	
+protected:
+	ANTLR_USE_NAMESPACE(antlr)RefAST returnAST;
+	ANTLR_USE_NAMESPACE(antlr)RefAST _retTree;
+private:
+	static const char* tokenNames[];
+#ifndef NO_STATIC_CONSTS
+	static const int NUM_TOKENS = 15;
+#else
+	enum {
+		NUM_TOKENS = 15
+	};
+#endif
+	
+};
+
+ANTLR_END_NAMESPACE
+#endif /*INC_LogConfigurationTreeParser_hpp_*/
Index: /sandbox/trunk/pdp/src/xerial/log/LogConfigurationLexerTokenTypes.txt
===================================================================
--- /sandbox/trunk/pdp/src/xerial/log/LogConfigurationLexerTokenTypes.txt (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/log/LogConfigurationLexerTokenTypes.txt (revision 939)
@@ -0,0 +1,13 @@
+// $ANTLR 2.7.6 (2005-12-22): LogConfiguration.g -> LogConfigurationLexerTokenTypes.txt$
+LogConfigurationLexer    // output token vocab name
+Letter=4
+Digit=5
+Digits=6
+Char=7
+Eq=8
+Literal=9
+WhiteSpaceChar=10
+SL_COMMENT=11
+Config=12
+LogLevel=13
+"="=14
Index: /sandbox/trunk/pdp/src/xerial/log/LogConfiguration.g
===================================================================
--- /sandbox/trunk/pdp/src/xerial/log/LogConfiguration.g (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/log/LogConfiguration.g (revision 939)
@@ -0,0 +1,198 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// LogConfiguration.h
+// Since  2006/08/03 16:19:06
+// 
+// $Date$ 
+// $Author$ 
+//--------------------------------------------------
+
+header "pre_include_hpp" {
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Since  2006/08/03 16:19:06
+// 
+// $Date$ 
+// $URL$
+// $Author$ 
+//--------------------------------------------------	
+#include "xerial/common/xerial.hpp"
+#include <iosfwd>
+#include <string>
+#define CUSTOM_API XERIAL_API
+#ifdef WIN32
+// disable warnings for unused local variables and int to char conversion within ANTLR codes
+#pragma warning(disable: 4100 4244)
+#endif // WIN32
+}
+header "post_include_hpp" {
+}
+
+header "pre_include_cpp" {
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Since  2006/08/03 16:19:06
+// 
+// $Date$ 
+// $URL$
+// $Author$ 
+//--------------------------------------------------	
+}
+ 
+header "post_include_cpp" {    
+#include <iostream>
+#include <string>
+#include "xerial/log/Logger.hpp"
+#include "xerial/common/xerial_last.hpp"
+}
+
+header {
+    // gets inserted after generated namespace specifications in the header
+    // file. But outside the generated class.
+}
+
+options
+{
+	language = "Cpp";
+	namespace="xerial";
+}
+
+class LogConfigurationLexer extends Lexer;
+options 
+{
+	// some lexer options
+	k=3;	// number of look-ahead characters 
+	
+}
+{
+	// lexer class members;
+
+}
+
+//-----------------------------------
+// lexical rules
+//-----------------------------------
+protected Letter 
+: 'A'..'Z' | 'a'..'z' 
+| '\u00C0'..'\u00D6' 
+| '\u00D8'..'\u00F6' | '\u00F8'..'\u00FF' ;
+
+
+protected Digit	   
+: '0' .. '9';
+
+Digits : (Digit)+;
+
+protected Char
+	: Letter
+	| Digit
+	| '.'
+	| '-'
+	| '_'
+	;
+
+Eq : '=';
+
+Literal: Letter (Char)*;
+
+WhiteSpaceChar: ( ' ' | '\t' | '\n' { newline(); } | '\r' ) 
+{ $setType(antlr::Token::SKIP); };
+
+SL_COMMENT
+	:	"//"
+		(~('\n'|'\r'))* ('\n'|'\r'('\n')?)?
+		{
+			$setType(antlr::Token::SKIP);
+			newline();
+		}
+	;
+
+/*
+LogLevelStr 	
+	: "off" 
+	| "trace" 
+	| "debug" 
+	| "info" 
+	| "warn" 
+	| "error" 
+	| "fatal"
+	| "all"
+	;
+*/
+//---------------------------------------------------
+// Parser Definitions
+//---------------------------------------------------
+{
+#include <vector>
+#include <string>
+
+
+}
+class LogConfigurationParser extends Parser;
+options
+{
+	k = 2;
+	//ignore=WhiteSpaceChar;
+	buildAST = true;
+	defaultErrorHandler=false;
+}
+
+tokens 
+{
+	// imaginary token
+	Config;
+	LogLevel;
+}
+
+{
+}
+
+
+config
+	: (logLevelDef)*
+	{ #config = #([Config, "Config"], #config); }
+	;
+
+logLevelDef
+	:  Literal "="! Literal
+	{ #logLevelDef = #([LogLevel, "LogLevel"], #logLevelDef); }
+	;
+
+
+
+//---------------------------------------------------
+// Tree Parser Definitions
+//---------------------------------------------------
+
+{
+
+
+
+void 
+LogConfigurationTreeParser::setLogLevel(const std::string& loggerName, const std::string& logLevel)
+{
+	Logger* logger = (loggerName != "root") ? Logger::getLogger(loggerName) : Logger::getRootLogger();
+	logger->setLevel(logLevel);
+}
+
+}
+
+class LogConfigurationTreeParser extends TreeParser;
+options {
+
+}
+{
+	void setLogLevel(const std::string& loggerName, const std::string& logLevel);
+}
+
+config: #(Config (loglevel)*)
+	  ;
+	 	 
+loglevel: #(LogLevel a:Literal b:Literal)
+	   { setLogLevel(a->getText(), b->getText()); }
+	  ;	 
+
+
Index: /sandbox/trunk/pdp/src/xerial/detail/MemoryChunkAllocator.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/detail/MemoryChunkAllocator.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/detail/MemoryChunkAllocator.hpp (revision 939)
@@ -0,0 +1,143 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// MemoryChunkAllocator.hpp
+// Since  2006/05/16 14:40:07
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/detail/MemoryChunkAllocator.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __MEMORYCHUNKALLOCATOR_HPP_20060516_144006
+#define __MEMORYCHUNKALLOCATOR_HPP_20060516_144006
+#include "xerial/common/xerial.hpp"
+#include "xerial/common/xerial_types.hpp"
+#include "xerial/util/thread/LightMutex.hpp"
+#include "xerial/util/thread/ScopeGuard.hpp"
+#include "xerial/log/Logger.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+namespace detail 
+{
+
+	template <unsigned int size>
+	union MemoryChunk
+	{
+		uint8 bytes[size];
+		MemoryChunk* nextChunk;
+	};
+
+	template <unsigned int size, unsigned int PageSize = 512>
+	struct MemoryChunkAllocatorImpl
+	{
+		static Logger* _logger;
+
+		typedef MemoryChunk<size> MemoryChunk;
+		enum { ITEMS_PER_PAGE = PageSize / size }; 
+
+		static void *allocate()
+		{
+			ScopeGuard<LightMutex> g(_mutex);
+			if(MemoryChunk* x = _freeChunk)
+			{
+				_freeChunk = x->nextChunk;
+				return x;
+			}
+			else
+			{
+				if(_lastItemLocation == ITEMS_PER_PAGE)
+				{
+					XERIAL_TRACE(_logger, "default allocator was invoked");
+					_currentPage = ::new MemoryChunk[ITEMS_PER_PAGE];
+					_lastItemLocation = 0;
+				}
+				return &_currentPage[_lastItemLocation++];
+			}
+		}
+
+		static void *allocate(std::size_t n)
+		{
+			if(n != size)
+			{
+				XERIAL_TRACE(_logger, "default allocator was invoked");
+				return ::operator new(n);
+			}
+			else
+			{
+				ScopeGuard<LightMutex> g(_mutex);
+				if(MemoryChunk* x = _freeChunk)
+				{
+					_freeChunk = x->nextChunk;
+					return x;
+				}
+				else
+				{
+					if(_lastItemLocation == ITEMS_PER_PAGE)
+					{
+						_currentPage = ::new MemoryChunk[ITEMS_PER_PAGE];
+						_lastItemLocation = 0;
+					}
+					return &_currentPage[_lastItemLocation++];
+				}
+			}
+		}
+		static void deallocate(void *pv)
+		{
+			if(pv != 0)
+			{
+				ScopeGuard<LightMutex> g(_mutex);
+				MemoryChunk* c = static_cast<MemoryChunk*>(pv);
+				c->nextChunk = _freeChunk;
+				_freeChunk = c;
+			}
+		}
+
+		static void deallocate(void *pv, std::size_t n)
+		{
+			if(n != size) // dealloc is called for an another object whose size is larger than the default size
+			{
+				::operator delete(pv);
+			}
+			else
+			{
+				ScopeGuard<LightMutex> g(_mutex);
+				MemoryChunk* c = static_cast<MemoryChunk*>(pv);
+				c->nextChunk = _freeChunk;
+				_freeChunk = c;
+			}
+		}
+
+	private:
+		static LightMutex _mutex;
+		static MemoryChunk* _freeChunk;
+		static MemoryChunk* _currentPage;
+		static unsigned int _lastItemLocation;
+	};
+
+// definition of the private members in MemoryChunkImpl
+template <unsigned int size, unsigned int PageSize>
+LightMutex MemoryChunkAllocatorImpl<size, PageSize>::_mutex;
+
+template <unsigned int size, unsigned int PageSize>
+MemoryChunk<size>* MemoryChunkAllocatorImpl<size, PageSize>::_freeChunk = 0;
+
+template <unsigned int size, unsigned int PageSize>
+MemoryChunk<size>* MemoryChunkAllocatorImpl<size, PageSize>::_currentPage = 0;
+
+template <unsigned int size, unsigned int PageSize>
+unsigned int MemoryChunkAllocatorImpl<size, PageSize>::_lastItemLocation = MemoryChunkAllocatorImpl<size>::ITEMS_PER_PAGE;
+
+template <unsigned int size, unsigned int PageSize>
+Logger* MemoryChunkAllocatorImpl<size, PageSize>::_logger = Logger::getLogger("MemoryChunkAllocator");
+
+template<class T, unsigned int PageSize = 512>
+struct MemoryChunkAllocator : public MemoryChunkAllocatorImpl<sizeof(T), PageSize> {};
+
+} // namespace detail
+
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__MEMORYCHUNKALLOCATOR_HPP_20060516_144006
Index: /sandbox/trunk/pdp/src/xerial/common/xerial.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/common/xerial.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/common/xerial.hpp (revision 939)
@@ -0,0 +1,79 @@
+//------------------------------------------------
+// Xerial -- Transactional XML Database System
+//
+// xerial.hpp
+// Since  2004/09/28 15:11:20
+//
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $
+// $Author: leo $
+//------------------------------------------------
+#pragma once
+#ifndef __XERIAL_HPP
+#define __XERIAL_HPP
+
+// declarations for Visual C++
+#ifdef WIN32
+// get rid of troublesome STL warning on Visual C++ 6.0
+#pragma warning(disable:4786)
+
+// ignore warning related to the Boost library
+#pragma warning(disable:4275)
+#pragma warning(disable:4251)
+
+// ignore warnings related type conversion (possible loss of data)
+//#pragma warning(disable: 4267)	
+
+#ifdef XERIAL_DLL_EXPORTS
+#define XERIAL_API __declspec(dllexport)
+#else
+#define XERIAL_API
+#endif // XERIAL_DLL_EXPORTS
+
+/*
+ * By using XERIAL_EXECUTABLE_ENTRY, you can make an entry point i.e. main(argc, argv) function
+ * in the DLL of Xerial. (It is also needed to add the corresponding entry to the xerial_dll.def)
+ * 
+ * For example, you can use it as follows:
+ * XERIAL_EXECUTABLE_ENTRY(xerial_amoeba_index, SequentialIndexGenerator::main)
+ *
+ * Now, the loader (xerial/win32/loader.cpp) program can invoke 
+ * this function (SequentialIndexGenerator::main), by performing
+ * ./loader xerial_amoeba_index [args ...]
+ * 
+ * It helps to avoid creating new Visual Studio Projects for each executable.
+ */
+#define XERIAL_EXECUTABLE_ENTRY(entryName, funcName) \
+extern "C" { int entryName(int argc, char** argv) { return funcName(argc, argv); } }
+
+#ifdef _DEBUG
+#define _CRTDBG_MAP_ALLOC
+#include <cstdlib>
+#include <crtdbg.h>
+#endif	// _DEBUG
+
+
+#endif // WIN32
+
+// boost options
+#define BOOST_SPIRIT_THREADSAFE
+
+// some useful type definitions
+namespace xerial 
+{
+	enum
+	{
+		RETURN_WITH_SUCCESS = 0,
+		RETURN_WITH_FAILURE = -1
+	};
+
+
+}	// namespace xerial
+
+#define XERIAL_NAMESPACE_BEGIN namespace xerial {
+#define XERIAL_NAMESPACE_END } // namespace xerial
+#define XERIAL_NS xerial
+
+
+
+
+#endif // __XERIAL_HPP
Index: /sandbox/trunk/pdp/src/xerial/common/xerial_last.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/common/xerial_last.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/common/xerial_last.hpp (revision 939)
@@ -0,0 +1,17 @@
+//------------------------------------------------
+// Xerial -- Transactional XML Database System
+//
+// xerial_last.hpp
+// Since  2004/09/28 15:27:56
+//
+// $Date: 2004-10-08 10:56:44 +0900 (驥� 08 10 2004) $
+// $Author: leo $
+//------------------------------------------------
+
+#ifndef __XERIAL_LAST_H
+#define __XERIAL_LAST_H
+
+using namespace xerial;
+using namespace std;
+
+#endif // __XERIAL_LAST_H
Index: /sandbox/trunk/pdp/src/xerial/common/xerial_types.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/common/xerial_types.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/common/xerial_types.hpp (revision 939)
@@ -0,0 +1,36 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// xerial_types.hpp
+// Since  2005/05/12 10:51:57
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#ifndef __XERIAL_TYPES_HPP
+#define __XERIAL_TYPES_HPP
+#include "xerial/common/xerial.hpp"
+#include <boost/cstdint.hpp>
+
+XERIAL_NAMESPACE_BEGIN
+
+// The types uintN (uint8, uint16, ...) are unsigned integer types having at least N bits 
+// Note that this does not mean  uint16 is a 16 bit integer because it might be an 32-bit integer
+// in some platforms.
+
+typedef boost::uint8_t uint8;
+typedef boost::uint16_t uint16;
+typedef boost::uint32_t uint32;
+typedef boost::uint64_t uint64;
+
+typedef boost::int8_t int8;
+typedef boost::int16_t int16;
+typedef boost::int32_t int32;
+typedef boost::int64_t int64;
+
+
+
+
+XERIAL_NAMESPACE_END
+
+#endif //__XERIAL_TYPES_HPP
Index: /sandbox/trunk/pdp/src/xerial/util/cui/OptionParser.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/cui/OptionParser.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/cui/OptionParser.cpp (revision 939)
@@ -0,0 +1,576 @@
+//------------------------------------------------
+// Xerial -- Transactional XML Database System
+//
+// OptionParser.cpp
+// Since  2004/10/13 16:26:34
+//
+// $Date: 2006-09-18 23:00:27 +0900 (譛� 18 9 2006) $
+// $Author: leo $
+//------------------------------------------------
+
+#include <algorithm>
+#include <sstream>
+#include "xerial/exception/OutOfRangeException.hpp"
+#include "xerial/util/cui/OptionParser.hpp"
+#include "xerial/exception/assert.hpp"
+#include "xerial/util/STLUtil.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+//--------------------------------------------------
+// OptionParser
+//--------------------------------------------------
+OptionParser::OptionParser() 
+: _defaultGroup(OptionGroup(""))
+{
+
+}
+
+OptionParser::~OptionParser() 
+{
+
+}
+
+void
+OptionParser::add(const Option& option) 
+{
+	int optionID = option.getOptionID();
+	ID2OptionMap::iterator it = _id2optMap.find(optionID);
+	if(it != _id2optMap.end())
+	{
+		// duplicate option
+		XERIAL_THROW(InvalidParameterException, "duplicate option ID: " << optionID);
+	}
+
+	// add to the default group
+	OptionPtr optPtr(option.clone());
+	_id2optMap.insert(make_pair(optionID, optPtr));
+	_defaultGroup.add(optPtr);	
+}
+
+
+
+void
+OptionParser::addOptionGroup(const OptionGroup& optionGroup) 
+{
+	OptionGroup::const_iterator it = optionGroup.begin();
+	while(it != optionGroup.end())	
+	{				
+		Option* opt = dynamic_cast<Option*>(it->get());
+		if(opt != 0)
+		{			
+			_id2optMap.insert(make_pair(opt->getOptionID(), *it));
+			_id2groupMap.insert(make_pair(opt->getOptionID(), optionGroup.getGroupName()));
+		}
+		++it;
+	}
+	_defaultGroup.add(OptionPtr(optionGroup.clone()));
+	if(optionGroup.isExclusive())
+		_incompatibleGroupNameList.push_back(optionGroup.getGroupName());
+}
+
+
+OptionParser&
+OptionParser::operator<<(const Option& option) 
+{
+	this->add(option);
+	return *this;
+}
+OptionParser&
+OptionParser::operator<<(const OptionGroup& optionGroup) 
+{
+	this->addOptionGroup(optionGroup);
+	return *this;
+}
+
+
+bool
+OptionParser::isSet(int optionID) const
+{
+	return findOption(optionID)->isSet();
+}
+
+
+std::string
+OptionParser::getValue(int optionID, const std::string& defaultValue) const
+{
+	Option* optPtr = findOption(optionID);
+	OptionWithArgument* optWithArgPtr = dynamic_cast<OptionWithArgument*>(optPtr);
+	return (optWithArgPtr == 0) ? defaultValue : optWithArgPtr->getValue(defaultValue);
+}
+
+
+Option*
+OptionParser::findOption(int optionID) const
+{
+	ID2OptionMap::const_iterator it = _id2optMap.find(optionID);
+	if(it == _id2optMap.end())
+	{
+		XERIAL_THROW(InvalidParameterException, "unknwon optionID: " << optionID);		
+	}
+	Option* opt = dynamic_cast<Option*>((it->second).get());
+	XERIAL_ASSERT(opt != 0);
+	return opt;
+}
+
+void
+OptionParser::getContext(int argc, char** argv) 
+{
+	int index = 1;
+	while(index < argc)
+	{
+		std::string arg(argv[index]);
+		if(arg.find("--") == 0)	// startsWith "--"
+		{
+			// long name option
+			size_t splitPos = arg.find('=');
+			std::string longOptionName, value;
+			if(splitPos == string::npos)
+			{
+				// no value is found
+				longOptionName = arg.substr(2);
+				int optionID = _defaultGroup.findByLongOptionName(longOptionName);
+				if(optionID == -1)
+					XERIAL_THROW(InvalidParameterException, "unknown option --" <<  longOptionName);
+				Option* opt = findOption(optionID);
+				if(opt->takesArgument())
+					XERIAL_THROW(InvalidParameterException, "parameter value is required for --" << longOptionName);
+				opt->set();
+				activateGroupOf(opt);
+			}
+			else
+			{
+				// an argument value is found
+				longOptionName = arg.substr(2, splitPos-2);
+				value = arg.substr(splitPos+1);
+				int optionID = _defaultGroup.findByLongOptionName(longOptionName);
+				if(optionID == -1)
+					XERIAL_THROW(InvalidParameterException, "unknown option --" << longOptionName);
+				Option* opt = findOption(optionID);
+				opt->set();
+				OptionWithArgument* optWithArg = dynamic_cast<OptionWithArgument*>(opt);
+				if(optWithArg != 0)
+				{
+					activateGroupOf(optWithArg);
+					optWithArg->setValue(value);
+				}
+				else
+					XERIAL_THROW(InvalidParameterException, "syntax error --" << longOptionName);
+			}
+		}
+		else if(arg.find("-") == 0) // starts with "-"
+		{
+			// short name option
+			std::string shortOptionList = arg.substr(1);
+			for(size_t i=0; i<shortOptionList.size(); i++)
+			{
+				string shortOption = shortOptionList.substr(i, i+1);
+				int optionID = _defaultGroup.findByShortOptionName(shortOption);
+				if(optionID == -1)
+					XERIAL_THROW(InvalidParameterException, "unknown option -" << shortOption);
+				Option* opt = findOption(optionID);
+				if(opt->takesArgument())
+				{
+					if(shortOptionList.size() != 1)
+						XERIAL_THROW(InvalidParameterException, "options with argument must be isolated: -" << shortOption);
+					OptionWithArgument* optWithArg = dynamic_cast<OptionWithArgument*>(opt);
+					if(optWithArg != 0)
+					{
+						if(++index < argc)
+							optWithArg->setValue(string(argv[index]));
+						else
+							XERIAL_THROW(InvalidParameterException, "parameter value is required for -" << shortOption);								
+					}
+				}
+				opt->set();
+				activateGroupOf(opt);
+			}
+		}
+		else 
+		{
+			// plain argument 
+			_argList.push_back(arg);
+		}
+		index++;	
+	}
+
+	// validate not to be set the options belonging in the incompatible groups
+	int incompatibleGroupCount = 0;
+	vector<string> incompatibleGroupNameList;
+	for(vector<string>::const_iterator it = _incompatibleGroupNameList.begin(); it != _incompatibleGroupNameList.end(); ++it)
+	{
+		string groupName = *it;
+		if(_activeGroupSet.find(groupName) != _activeGroupSet.end())
+		{
+			incompatibleGroupCount++;
+			incompatibleGroupNameList.push_back(groupName);				
+		}
+	}
+	if(incompatibleGroupCount >= 2)
+		XERIAL_THROW(InvalidParameterException, "options in incompatible groups " <<
+		STLUtil::toString(incompatibleGroupNameList) << " are set simultaneously");
+}
+
+void
+OptionParser::set(int optionID, bool flag) 
+{
+	findOption(optionID)->set(flag);
+}
+
+std::string
+OptionParser::getArgument(int index) const
+{
+	if(static_cast<size_t>(index) >= _argList.size())
+		XERIAL_THROW(InvalidParameterException, "invalid argument index " << index);
+	return _argList[index];
+}
+
+
+const std::vector<std::string>& 
+OptionParser::getArgumentList() const
+{
+	return _argList;
+}
+
+
+
+std::string
+OptionParser::createHelpMessage() const
+{	
+	OptionDescriptionContainer helpMessageContainer;
+	_defaultGroup.collectOptionDescriptions(helpMessageContainer);
+	return helpMessageContainer.toString();
+}
+
+//--------------------------------------------------
+// OptionGroup 
+//--------------------------------------------------
+OptionGroup::iterator
+OptionGroup::begin() 
+{
+	return _optionList.begin();
+}
+
+OptionGroup::const_iterator
+OptionGroup::begin() const
+{
+	return _optionList.begin();
+}
+
+OptionComposite*
+OptionGroup::clone() const
+{
+	OptionGroup* clone = new OptionGroup(*this);
+	return clone;
+}
+
+
+OptionGroup::iterator
+OptionGroup::end() 
+{
+	return _optionList.end();
+}
+
+OptionGroup::const_iterator
+OptionGroup::end() const
+{
+	return _optionList.end();
+}
+
+
+OptionGroup::OptionGroup(const std::string& groupName, bool isExclusive) 
+: _groupName(groupName), _isExclusive(isExclusive)
+{
+	
+}
+
+OptionGroup::~OptionGroup()
+{}
+
+void
+OptionGroup::add(const Option& option) 
+{
+	_optionList.push_back(OptionPtr(option.clone()));
+}
+
+OptionGroup&
+OptionGroup::operator<<(const Option& option) 
+{
+	this->add(option);
+	return *this;
+}
+
+bool
+OptionGroup::isExclusive() const
+{
+	return _isExclusive;
+}
+
+void
+OptionGroup::collectOptionDescriptions(OptionDescriptionContainer& container) const
+{
+	container.addDescription(_groupName);
+	for(OptionGroup::const_iterator it = begin(); it!=end(); ++it)
+	{
+		(*it)->collectOptionDescriptions(container);
+	}
+}
+
+int
+OptionGroup::findByLongOptionName(const std::string& longOption) const
+{
+	// iterate into option list
+	for(OptionGroup::const_iterator it = begin(); it!=end(); ++it)
+	{
+		int optionID = (*it)->findByLongOptionName(longOption);
+		if(optionID != -1)
+			return optionID;
+	}
+	return -1;
+}
+
+int
+OptionGroup::findByShortOptionName(const std::string& shortOption) const
+{
+	// iterate into option list
+	for(OptionGroup::const_iterator it = begin(); it!=end(); ++it)
+	{
+		int optionID = (*it)->findByShortOptionName(shortOption);
+		if(optionID != -1)
+			return optionID;
+	}
+	return -1;
+}
+
+
+
+bool
+OptionGroup::isGroup() const
+{
+	return true;
+}
+
+//--------------------------------------------------
+// Option
+//--------------------------------------------------
+
+
+Option::Option(int optionID, std::string shortName, std::string longName, std::string description) 
+: _optionID(optionID), _shortName(shortName), _longName(longName), _description(description), _isSet(false)
+{
+	XERIAL_ASSERT1(_optionID != -1, "-1 is not a valid optionID");
+}
+
+Option::~Option()
+{}
+
+
+
+void
+Option::collectOptionDescriptions(OptionDescriptionContainer& container) const
+{
+	container.addDescription((_shortName != "" ? "-" + _shortName : ""), "--" + _longName, _description);
+}
+
+//--------------------------------------------------
+// OptionDescriptionContainer
+//--------------------------------------------------
+
+
+OptionDescriptionContainer::OptionDescriptionContainer() 
+{
+	
+}
+
+OptionDescriptionContainer::~OptionDescriptionContainer() 
+{
+	
+}
+
+void
+OptionDescriptionContainer::addDescription(const std::string& shortOptionColumn, const std::string& longOptionColumn, const std::string& descriptionColumn) 
+{
+	vector<string> line;
+	line.push_back(shortOptionColumn);
+	line.push_back(longOptionColumn);
+	line.push_back(descriptionColumn);
+	_columnList.push_back(line);
+}
+
+void
+OptionDescriptionContainer::addDescription(const string& groupName) 
+{
+	vector<string> line;
+	line.push_back(groupName);
+	_columnList.push_back(line);
+}
+
+std::string
+OptionDescriptionContainer::toString() const
+{
+	// calculate necessary width for each column
+	size_t width[] = { 0, 0, 0 };
+	for (ArrayList::const_iterator ci = _columnList.begin(); ci != _columnList.end(); ++ci)
+	{
+		const vector<string>& line = *ci;
+		if (line.size() != 3)
+			continue; // skip the group name line 
+		for (size_t i = 0; i < line.size(); i++)
+			width[i] = width[i] < line[i].size() ? line[i].size() : width[i];
+	}
+	for(int i=0; i<3; i++)
+		width[i]++;
+	
+	// print each options
+	ostringstream os;
+	for (ArrayList::const_iterator ci = _columnList.begin(); ci != _columnList.end(); ++ci)
+	{
+		const vector<string>& line = *ci;
+		if(line.size() == 1)
+			os << line[0];  // group name
+		else
+		{
+			os << " "; /// left margin
+			for (size_t i = 0; i < line.size(); i++)
+			{
+				os << line[i];
+				size_t numSpace = width[i] - line[i].size();
+				for (size_t j = 0; j < numSpace; j++)
+					os << " ";
+			}	
+		}
+		os << endl;
+	}
+	return os.str();
+}
+
+
+int
+Option::findByLongOptionName(const std::string& longOption) const
+{
+	return (longOption == _longName) ? _optionID : -1;
+}
+int
+Option::findByShortOptionName(const std::string& shortOption) const
+{
+	return (shortOption == _shortName) ? _optionID : -1;
+}
+
+const std::string&
+Option::getShortName() const
+{
+	return _shortName;
+}
+const std::string&
+Option::getLongName() const
+{
+	return _longName;
+}
+
+
+OptionWithArgument::OptionWithArgument(int optionID, std::string shortName, std::string longName, std::string argName, std::string description) 
+: Option(optionID, shortName, longName, description), _argName(argName)
+{
+	
+}
+
+OptionWithArgument::~OptionWithArgument()
+{
+
+}
+
+
+bool
+Option::isGroup() const
+{
+	return false;
+}
+
+
+
+bool
+Option::takesArgument() const
+{
+	return false;
+}
+
+bool
+OptionWithArgument::takesArgument() const
+{
+	return true;
+}
+const std::string&
+OptionGroup::getGroupName() const
+{
+	return _groupName;
+}
+void
+OptionParser::activateGroupOf(const Option* opt) 
+{
+	int optionID = opt->getOptionID();
+	ID2GroupMap::const_iterator it = _id2groupMap.find(optionID);
+	if(it != _id2groupMap.end())
+		_activeGroupSet.insert(it->second);
+}
+void
+OptionGroup::add(const OptionPtr& option) 
+{
+	_optionList.push_back(option);
+}
+void
+Option::set(bool flag) 
+{
+	_isSet = flag;
+}
+
+void
+OptionWithArgument::setValue(const std::string& value) 
+{
+	_value = value;	
+}
+bool
+Option::isSet() const
+{
+	return _isSet;
+}
+
+OptionComposite*
+Option::clone() const
+{
+	OptionComposite* opt = new Option(*this);
+	return opt;
+}
+void
+OptionWithArgument::collectOptionDescriptions(OptionDescriptionContainer& container) const
+{
+	container.addDescription((this->getShortName() != "" ? "-" + this->getShortName() : ""), "--" + this->getLongName() + "=" + _argName, this->getDescription());
+}
+
+const std::string&
+Option::getDescription() const
+{
+	return _description;	
+}
+int
+Option::getOptionID() const
+{
+	return _optionID;
+}
+
+const std::string&
+OptionWithArgument::getValue(const std::string& defaultValue) const
+{
+	return (_value.size() == 0) ? defaultValue : _value;
+}
+
+OptionComposite* 
+OptionWithArgument::clone() const
+{
+	OptionComposite* p = new OptionWithArgument(*this);
+	return p;
+}
+size_t
+OptionParser::getArgumentLength() const
+{
+	return _argList.size();	
+}
+
Index: /sandbox/trunk/pdp/src/xerial/util/cui/OptionParser.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/cui/OptionParser.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/cui/OptionParser.hpp (revision 939)
@@ -0,0 +1,255 @@
+//------------------------------------------------
+// Xerial -- Transactional XML Database System
+//
+// OptionParser.hpp
+// Since  2004/10/13 16:26:16
+//
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $
+// $Author: leo $
+//------------------------------------------------
+
+#pragma once
+#ifndef __OPTIONPARSER_H
+#define __OPTIONPARSER_H
+
+#include <string>
+#include <map>
+#include <vector>
+#include <list>
+#include <set>
+#include <boost/shared_ptr.hpp>
+#include "xerial/exception/InvalidParameterException.hpp"
+#include "xerial/util/NonConstructable.hpp"
+
+
+class Option;
+class OptionWithArgument;
+class OptionGroup;
+class OptionDescriptionContainer;
+class OptionComposite;
+
+typedef boost::shared_ptr<OptionComposite> OptionPtr;
+
+/**
+ * A base class of Option and OptionGroup. 
+ * The benefit of deriving these classes from the OptionComposite is that 
+ * we can traverse options and grouped options in the same way 
+ * (collectOptionDescriptions, findBy{Long, Short}OptionName
+ */
+class OptionComposite : NonConstructable
+{
+public:
+	/**
+	 * 
+	 * @param container	
+	 */
+	virtual void collectOptionDescriptions(OptionDescriptionContainer &container) const = 0;
+	virtual int findByLongOptionName(const std::string &longOption) const = 0;
+	virtual int findByShortOptionName(const std::string &shortOption) const = 0;
+	virtual bool isGroup() const = 0;
+
+};
+
+
+/**
+ * This Option class can be added to an OptionParser class. 
+ */
+class XERIAL_API Option : public OptionComposite
+{
+public:
+	/**
+	 * @param optionID	a unique ID assigned to this option
+	 * @param shortName	short name option (ex. "h" represents "-h" in the command line)
+	 * @param longName	long name option, which is the another name of the short option.  (ex. "help" represents "--help")
+	 * @param description an description of this option, which appears in the help message.
+	 */
+	Option(int optionID, std::string shortName = "", std::string longName = "", std::string description = "");
+	virtual ~Option();
+	virtual void collectOptionDescriptions(OptionDescriptionContainer &container) const;
+	virtual int findByLongOptionName(const std::string &longOption) const;
+	virtual int findByShortOptionName(const std::string &shortOption) const;
+	virtual bool isGroup() const;
+
+	virtual bool takesArgument() const;
+
+	bool isSet() const;
+	void set(bool flag = true);
+
+	int getOptionID() const;
+
+	virtual OptionComposite* clone() const;
+
+	const std::string& getShortName() const;
+	const std::string& getLongName() const;
+	const std::string& getDescription() const;
+private:
+	int _optionID;
+	std::string _shortName;
+	std::string _longName;
+	std::string _description;
+	bool _isSet;
+};
+
+class XERIAL_API OptionWithArgument : public Option
+{
+public:
+	/**
+	 * 
+	 * @param optionID		a unique ID assigned to this option
+	 * @param shortName		short name option (ex. "h" represents "-h" in the command line)
+	 * @param longName		long name option, which is the another name of the short option.  (ex. "help" represents "--help")
+	 * @param argName		argument name for creating help message 
+	 *						(ex. "FILE" for "outfile" long option is to be displayed as "--outfile=FILE")
+	 * @param description	an description of this option, which appears in the help message.
+	 */
+	OptionWithArgument(int optionID, std::string shortName, std::string longName, std::string argName, std::string description);
+	virtual ~OptionWithArgument();
+	
+	virtual bool takesArgument() const;
+	
+	const std::string& getValue(const std::string& defaultValue = "") const;
+	void setValue(const std::string& value);
+
+	virtual OptionComposite* clone() const;
+
+	virtual void collectOptionDescriptions(OptionDescriptionContainer &container) const;
+private:
+	std::string _argName;
+	std::string _value;
+};
+
+class XERIAL_API OptionGroup : public OptionComposite
+{
+public:
+	typedef std::list<OptionPtr>::iterator iterator;
+	typedef std::list<OptionPtr>::const_iterator const_iterator;
+
+	OptionGroup(const std::string &groupName, bool isExclusive=false);
+	virtual ~OptionGroup();
+
+	void add(const Option& option);
+	OptionGroup& operator<<(const Option& option);
+
+	bool isExclusive() const;
+
+	virtual void collectOptionDescriptions(OptionDescriptionContainer &container) const;
+	virtual int findByLongOptionName(const std::string &longOption) const;
+	virtual int findByShortOptionName(const std::string &shortOption) const;
+	virtual bool isGroup() const;
+
+	const std::string& getGroupName() const;
+
+	iterator begin();
+	const_iterator begin() const;
+	iterator end();
+	const_iterator end() const;
+	
+	virtual OptionComposite* clone() const;
+
+	void add(const OptionPtr& option);
+protected:
+
+private:
+	std::string _groupName;
+	bool _isExclusive;
+	std::list<OptionPtr> _optionList;
+};
+
+
+
+
+class XERIAL_API OptionParser
+{
+public:
+	OptionParser();
+	virtual ~OptionParser();
+
+	void add(const Option& option);
+	void addOptionGroup(const OptionGroup& optionGroup);
+	OptionParser& operator<<(const Option& option);
+	OptionParser& operator<<(const OptionGroup& optionGroup);
+
+	void getContext(int argc, char** argv);
+
+	/**
+	 * 
+	 * @param optionID	
+	 * @return	
+	 * @throw InvalidParameterException
+	 */
+	bool isSet(int optionID) const;
+	/**
+	 * 
+	 * @param optionID	
+	 * @param flag	
+	 * @throw InvalidParameterException
+	 */
+	void set(int optionID, bool flag=true);
+	/**
+	 * 
+	 * @param optionID	
+	 * @return	
+	 * @throw InvalidParameterException
+	 */
+	std::string getValue(int optionID, const std::string& defalutValue = "") const;
+
+	/**
+	 * 
+	 * @param index	
+	 * @return	
+	 * @throw OutOfRangeException
+	 */
+	std::string getArgument(int index) const;
+	const std::vector<std::string>& getArgumentList() const;
+	size_t getArgumentLength() const;
+	
+	std::string createHelpMessage() const;
+protected:
+	/**
+	 * 
+	 * @param optionID	
+	 * @return	
+	 * @throw InvalidParameterException
+	 */
+	Option* findOption(int optionID) const;
+	void addToOptionID2GroupMap(Option* opt);
+
+	void activateGroupOf(const Option* opt);
+	
+private:
+	typedef std::map<int, OptionPtr> ID2OptionMap;
+	typedef std::map<int, std::string> ID2GroupMap;
+ 	ID2OptionMap _id2optMap;
+	ID2GroupMap _id2groupMap;
+	
+
+	OptionGroup _defaultGroup;
+	std::vector<std::string> _argList;	
+	std::vector<std::string> _incompatibleGroupNameList;
+	std::set<std::string> _activeGroupSet;
+};	
+
+
+
+
+/**
+ * A container of help messages of the options
+ * @author leo
+ */
+class OptionDescriptionContainer
+{
+public:
+	OptionDescriptionContainer();
+	virtual ~OptionDescriptionContainer();
+	
+	
+	void addDescription(const std::string& shortOptionColumn, const std::string& longOptionColumn, const std::string& descriptionColumn);
+	void addDescription(const std::string& groupName);
+	std::string toString() const;
+private:	
+	typedef std::list<std::vector<std::string> > ArrayList;
+	ArrayList  _columnList;
+};
+
+
+#endif // __OPTIONPARSER_H
Index: /sandbox/trunk/pdp/src/xerial/util/antlr/AntlrHelper.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/antlr/AntlrHelper.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/antlr/AntlrHelper.hpp (revision 939)
@@ -0,0 +1,58 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// AntlrHelper.hpp
+// Since  2006/08/03 10:51:31
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/amoeba/AntlrHelper.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __ANTLRHELPER_HPP_20060803_105131
+#define __ANTLRHELPER_HPP_20060803_105131
+#include "xerial/common/xerial.hpp"
+#include <boost/shared_ptr.hpp>
+#include <iosfwd>
+#include <antlr/ASTFactory.hpp>
+
+XERIAL_NAMESPACE_BEGIN
+
+template <class Lexer, class Parser>
+class XERIAL_API AntlrParser
+{
+	Parser* _parser;
+	Lexer* _lexer;
+	antlr::ASTFactory _astFactory;
+public:
+	AntlrParser(std::istream& is)
+	{
+		_lexer = new Lexer(is);
+		_parser = new Parser(*_lexer);
+		
+		initialize();
+	}
+	virtual ~AntlrParser()
+	{		
+		delete _parser;
+		delete _lexer;
+	}
+
+	Parser& getParser()
+	{
+		return *_parser;
+	}
+
+private:
+	void initialize()
+	{
+		_parser->initializeASTFactory(_astFactory);
+		_parser->setASTFactory(&_astFactory);
+	}
+
+};
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__ANTLRHELPER_HPP_20060803_105131
Index: /sandbox/trunk/pdp/src/xerial/util/ustring.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/ustring.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/ustring.hpp (revision 939)
@@ -0,0 +1,33 @@
+//------------------------------------------------
+// Xerial -- Transaction Enabled XML Database
+//
+// ustring.hpp
+// Since  2003/11/26 16:27:36
+//
+// $Date: 2006-02-08 15:45:19 +0900 (豌ｴ, 08 2 2006) $ 
+// $Author: leo $
+//------------------------------------------------
+
+#ifndef __USTRING_H
+#define __USTRING_H
+
+#include "xerial/common/xerial.hpp"
+#include "xerial/common/xerial_types.hpp"
+#include <string>
+
+//--------------------------------------------------
+// it provides a typedef of a string class which using 'unsigned' char.
+// default basic_string<char> may use a 'signed' char type, which causes 
+// undesirable effect when shifting them.
+//--------------------------------------------------
+XERIAL_NAMESPACE_BEGIN
+
+typedef std::basic_string<uint8> XERIAL_API ustring;
+std::string XERIAL_API transform(const ustring& str);
+ustring XERIAL_API transform(const std::string &str);
+
+XERIAL_NAMESPACE_END
+
+
+#endif // __USTRING_H
+
Index: /sandbox/trunk/pdp/src/xerial/util/Collection.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/Collection.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/Collection.hpp (revision 939)
@@ -0,0 +1,48 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Collection.hpp
+// Since  2006/05/16 12:51:54
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/util/Collection.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __COLLECTION_HPP_20060516_125154
+#define __COLLECTION_HPP_20060516_125154
+#include "xerial/common/xerial.hpp"
+#include "xerial/util/NonConstructable.hpp"
+#include "xerial/util/Iterable.hpp"
+#include "xerial/util/Printable.hpp"
+#include <string>
+#include <sstream>
+
+XERIAL_NAMESPACE_BEGIN
+
+template <class T>
+class XERIAL_API Collection : public Iterable<T>, public Printable
+{
+public:
+	virtual void add(ConstReference element) = 0;
+	virtual void addAll(const Collection& other)
+	{
+		Collection<T>::ConstIterator it = other.getIterator();
+		while(it.hasNext())
+			this->add(it.next());
+	}
+	virtual void remove(ConstReference element) = 0;	
+	virtual void clear() = 0;
+	
+	virtual bool contains(ConstReference element) const = 0;
+	virtual bool empty() const = 0;
+
+	virtual size_t size() const = 0;
+private:
+
+};
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__COLLECTION_HPP_20060516_125154
Index: /sandbox/trunk/pdp/src/xerial/util/Integer.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/Integer.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/Integer.hpp (revision 939)
@@ -0,0 +1,47 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Integer.hpp
+// Since  2004/10/07 16:18:36
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $
+// $Author: leo $
+//--------------------------------------------------
+#pragma once
+#ifndef __INTEGER_HPP
+#define __INTEGER_HPP
+#include "xerial/common/xerial.hpp"
+#include "xerial/exception/InvalidNumberFormatException.hpp"
+#include <string>
+
+XERIAL_NAMESPACE_BEGIN
+
+/**
+ * an utility to convert integers between int and string
+ */
+class XERIAL_API Integer
+{
+public:
+	/**
+	 * int -> string
+	 * @param val
+	 * @return 
+	 */
+	static std::string toString(int val);
+	static std::string toString(unsigned int val);
+	/**
+	 * string -> int
+	 * throws InvalidNumberFormatException when fail to convert
+	 * @param val
+	 * @return int value
+	 * @throw InvalidNumberForamtException
+	 */
+	static int parseInt(const std::string &val);// throw(InvalidNumberFormatException);
+private:
+	Integer();
+};
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__INTEGER_HPP
Index: /sandbox/trunk/pdp/src/xerial/util/StringUtil.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/StringUtil.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/StringUtil.cpp (revision 939)
@@ -0,0 +1,88 @@
+//------------------------------------------------
+// Xerial -- Transactional XML Database System
+//
+// StringUtil.cpp
+// Since  2004/10/13 16:03:33
+//
+// $Date: 2006-05-22 02:58:08 +0900 (譛� 22 5 2006) $
+// $Author: leo $
+//------------------------------------------------
+
+#include "xerial/util/StringUtil.hpp"
+
+#include <sstream>
+#include "xerial/common/xerial_last.hpp"
+
+string StringUtil::_whiteSpaces = " \n\r\t";
+
+
+ 
+StringUtil::StringVector
+StringUtil::split(const string& data, const string& splitPattern) 
+{
+	StringVector result;
+	size_t patternSize = splitPattern.size();
+	size_t tokenBegin = 0;
+	size_t delimiterPosition = 0;
+	while((delimiterPosition = data.find(splitPattern, tokenBegin)) != string::npos)
+	{
+		if(delimiterPosition > tokenBegin)
+			result.push_back(data.substr(tokenBegin, delimiterPosition - tokenBegin));
+		tokenBegin = delimiterPosition + patternSize;
+	}
+	if(tokenBegin < data.size())
+		result.push_back(data.substr(tokenBegin));
+	return result;
+}
+
+string
+StringUtil::join(const StringVector& data, const string& concatinator) 
+{
+	StringVector::const_iterator i = data.begin();
+	ostringstream r;
+	if(data.size() > 0)
+		r << data[0];
+	for(i = boost::next(i); i!=data.end(); ++i)
+		r << concatinator << *i;
+	return r.str();
+}
+
+
+string
+StringUtil::trim(const string &data)
+{
+	size_t dataBegin = data.find_first_not_of(_whiteSpaces);
+	size_t dataEnd = data.find_last_not_of(_whiteSpaces);
+	if(dataBegin == (size_t) std::string::npos || dataEnd == (size_t) std::string::npos)
+		return string("");
+	else
+		return data.substr(dataBegin, dataEnd-dataBegin+1);
+}
+bool
+StringUtil::isWhiteSpaceString(const std::string &data)
+{
+	return data.find_first_not_of(_whiteSpaces) == (size_t) string::npos;
+}
+
+
+/*	
+string
+StringUtil::transform(const xerial::String &data)
+{
+// treat unsigned char as char (somewhat dangerous)
+string transformedString((char*) data.data(), data.size());
+return transformedString;
+}
+
+*/
+string
+StringUtil::toString(const std::ostringstream& os) 
+{
+	return os.str();
+}
+
+bool
+StringUtil::beginsWith(const String& data, const String& prefix) 
+{
+    return data.compare(0, prefix.size(), prefix) == 0;
+}
Index: /sandbox/trunk/pdp/src/xerial/util/STLUtil.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/STLUtil.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/STLUtil.hpp (revision 939)
@@ -0,0 +1,64 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// STLUtil.hpp
+// Since  2004/10/13 20:31:14
+// 
+// $Date: 2006-02-07 17:35:50 +0900 (轣ｫ, 07 2 2006) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#ifndef __STLUTIL_HPP
+#define __STLUTIL_HPP
+#include "xerial/common/xerial.hpp"
+#include <string>
+#include <sstream>
+#include <algorithm>
+#include <iterator>
+#include "xerial/util/NonConstructable.hpp"
+XERIAL_NAMESPACE_BEGIN
+
+class XERIAL_API STLUtil : NonConstructable
+{
+public:
+	/**
+	 * apply operator<< for each of element in the container, and returns its string representation
+	 * ex. a vector (1, 4, 5, ...)  ->   returns 1, 4, 5, ...
+	 * @param container
+	 * @return	
+	 */
+	template<class T>
+	static std::string toString(const T& container, const std::string &delimiter=", ")
+	{
+		std::ostringstream out;
+		for(T::const_iterator it = container.begin(); it != container.end(); ++it)
+		{
+			out << *it << delimiter;
+		}
+		std::string result(out.str());
+		if(result.size() > delimiter.size())
+			return result.substr(0, result.size() - delimiter.size());
+		else
+			return "";
+	}
+
+	/*
+	class ValueContainer
+	{
+	};
+
+	template <class Map, class Key = typename Map::key_type, class Value = typename Map::mapped_type>
+	static Value find(const Map& m, const Key& key)
+	{
+		Map::const_iterator i = m.find(key);
+		if(i != m.end())
+			return i->second;
+		else
+			return Value(0);
+	}
+	*/
+};
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__STLUTIL_HPP
Index: /sandbox/trunk/pdp/src/xerial/util/Vector.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/Vector.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/Vector.hpp (revision 939)
@@ -0,0 +1,123 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Vector.hpp
+// Since  2006/02/19 17:43:47
+// 
+// $Date$ 
+// $Author$ 
+//--------------------------------------------------
+#pragma once
+#ifndef __VECTOR_HPP_20060219_174347
+#define __VECTOR_HPP_20060219_174347
+#include "xerial/common/xerial.hpp"
+#include <vector>
+#include "xerial/util/Iterable.hpp"
+#include "xerial/util/List.hpp"
+#include "xerial/util/StringUtil.hpp"
+#include "xerial/util/detail/STLIteratorWrapper.hpp"
+#include "xerial/exception/UnsupportedOperation.hpp"
+#include <sstream>
+#include <algorithm>
+
+XERIAL_NAMESPACE_BEGIN
+
+/**
+ * It is a wrapper of the STL's vector template
+ */
+template <class T>
+class XERIAL_API Vector : public virtual List<T>, public std::vector<T>
+{
+	typedef std::vector<T> Impl;
+public:
+	Vector()
+	{}
+	Vector(size_t n, ConstReference element)
+		: Impl(n, element)
+	{}
+	
+	/**
+	 * This constructor is used for moving the content of the input Vetor (other) to this Vector instance
+	 * @param other	
+	 * @param replace if true uses swap() method to initialize Vector, otherwise it uses default copy constructor
+	 */
+	Vector(Vector& other, bool swap)
+	{
+	   if(swap)
+		   this->swap(other);
+	   else
+		   *this = other;
+	}
+		
+	virtual ~Vector()
+	{}
+
+	Vector& operator<<(ConstReference element)
+	{
+		this->add(element);
+		return *this;
+	}
+	virtual size_t size() const { return Impl::size(); }
+
+	virtual	void add(ConstReference element)
+	{
+		this->push_back(element);
+	}
+	virtual void remove(ConstReference element)
+	{
+		XERIAL_THROW(UnsupportedOperation, "Vector::remove()");
+	}
+	virtual void clear()
+	{
+		Impl::clear();
+	}
+
+	virtual bool contains(ConstReference element) const
+	{
+		return std::find(begin(), end(), element) != end();
+	}
+
+	bool empty() const
+	{
+		return Impl::empty();
+	}
+
+	Reference operator[](size_t n)
+	{
+		return Impl::operator[](n);
+	}
+	ConstReference operator[](size_t n) const
+	{
+		return Impl::operator[](n);
+	}
+	
+	Iterator getIterator() 
+	{
+		return Iterator(new STLIterator<T, Vector<T>, std::vector<T>::iterator, Reference>(*this));
+	}
+	ConstIterator getIterator() const
+	{
+		return ConstIterator(new STLIterator<T, const Vector<T>, std::vector<T>::const_iterator, ConstReference>(*this));
+	}
+	
+	virtual std::string toString() const
+	{
+		std::ostringstream os;
+		os << "[" << StringUtil::join(*this, ", ") << "]";
+		return os.str();
+	}
+
+	void swap(Vector& other)
+	{
+		Impl::swap(other);
+	}
+
+private:
+};
+
+
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__VECTOR_HPP_20060219_174347
Index: /sandbox/trunk/pdp/src/xerial/util/Singleton.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/Singleton.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/Singleton.hpp (revision 939)
@@ -0,0 +1,55 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Singleton.hpp
+// Since  2006/02/08 11:43:35
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/branches/leo/btree-devel-0.1/src/xerial/util/Singleton.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __SINGLETON_HPP_20060208_114335
+#define __SINGLETON_HPP_20060208_114335
+#include "xerial/common/xerial.hpp"
+#include "xerial/util/thread/LightMutex.hpp"
+#include "xerial/util/thread/ScopeGuard.hpp"
+#include "xerial/util/NonConstructable.hpp"
+#include "NonCopyable.hpp"
+#include <boost/shared_ptr.hpp>
+
+XERIAL_NAMESPACE_BEGIN
+
+template <class T, class Lock = LightMutex>
+class XERIAL_API Singleton : NonCopyable, NonConstructable
+{
+	/*
+	* We utilize shared_ptr to property deallocate objects, when 
+	* 
+	*/
+	typedef boost::shared_ptr<T> InstancePtr;
+public:
+	static T& getInstance()
+	{
+		static Lock lock;
+		static InstancePtr _instance;
+
+		T* ptr = _instance.get();
+		if(ptr == 0)
+		{
+			ScopeGuard<Lock> g(lock);
+			if(_instance.get() == 0)
+			{
+				ptr = new T();
+				_instance.reset(ptr);
+			}
+		}
+		return *ptr;
+	}
+private:
+};
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__SINGLETON_HPP_20060208_114335
Index: /sandbox/trunk/pdp/src/xerial/util/StringUtil.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/StringUtil.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/StringUtil.hpp (revision 939)
@@ -0,0 +1,162 @@
+//------------------------------------------------
+// Xerial -- Transactional XML Database System
+//
+// StringUtil.hpp
+// Since  2004/10/13 16:03:22
+//
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $
+// $Author: leo $
+//------------------------------------------------
+
+#pragma once
+#ifndef __STRINGUTIL_H_01
+#define __STRINGUTIL_H_01
+
+#include "xerial/common/xerial.hpp"
+#include "xerial/common/xerial_types.hpp"
+#include <string>
+#include <vector>
+#include <list>
+#include "xerial/util/NonConstructable.hpp"
+#include "xerial/util/ustring.hpp"
+#include <boost/next_prior.hpp>
+#include <boost/type_traits.hpp>
+#include <sstream>
+#include <limits.h>
+#include "xerial/util/Printable.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+
+
+typedef struct InvokeToString
+{
+	template <class T>
+	std::string operator()(const T* obj) const
+	{
+		if(obj)
+		{
+			std::ostringstream os;
+			os << *obj;
+			return os.str();
+		}
+		else
+			return "";
+	}
+
+	template <class T>
+	std::string operator()(T* obj) const
+	{
+		if(obj)
+		{
+			std::ostringstream os;
+			os << *obj;
+			return os.str();
+		}
+		else
+			return "";
+	}
+
+	
+	template <class T>
+	std::string operator()(const T& obj) const
+	{
+		std::ostringstream os;
+		os << obj;
+		return os.str();
+	}
+
+
+	
+
+} InvokeToString;
+
+class XERIAL_API StringUtil : NonConstructable
+{
+public:
+	typedef std::string String;
+	typedef std::vector<String> StringVector;
+
+
+	static bool beginsWith(const String& data, const String& prefix);
+
+	static StringVector split(const String& data, const String& splitPattern);
+	static String join(const StringVector& data, const String& concatinator);
+
+
+	template <class Iterator>
+	static String join(Iterator start, Iterator end, const String& concatinator)
+	{
+		std::ostringstream r;
+		if(start == end)
+			return r.str();
+		r << *start;
+		start++;
+		while(start != end)
+		{
+			r << concatinator << *start;
+			start++;
+		}
+		return r.str();
+	}
+
+	template <class Iterable>
+	static String join(const Iterable& collection, const String& concatinator)
+	{
+		InvokeToString invokeToString;
+
+		std::ostringstream os;
+		Iterable::ConstIterator it = collection.getIterator();
+		std::list<String> l;
+		while(it.hasNext())
+		{
+			Iterable::ConstReference r = it.next();
+			l.push_back(invokeToString(r));
+		}
+
+		return join(l.begin(), l.end(), concatinator);
+	}
+
+	static String trim(const String &data);
+	static bool isWhiteSpaceString(const String &data);
+
+	template <class T>
+		static String toString(const T& t)
+	{
+		std::ostringstream os;
+		os << t;
+		return os.str();
+	}
+
+
+	static String toString(const std::ostringstream &os);
+	
+	template <class T>
+	static ustring toUString(const T& t)
+	{
+		std::basic_stringstream<ustring::value_type> os;
+		os << t;
+		return os.str();
+	}
+
+	template <class T>
+	static String toBitString(T val)
+	{
+		std::ostringstream os;
+		T mask = 0x01 << (CHAR_BIT * sizeof(T) - 1);
+		while(mask != 0)
+		{
+			os << ((val & mask) ? "1" : "0");
+			mask >>= 1;
+		}
+		return os.str();
+	}
+
+private:
+	static String _whiteSpaces;
+};
+
+XERIAL_NAMESPACE_END
+
+#endif // __STRINGUTIL_H_01
+
Index: /sandbox/trunk/pdp/src/xerial/util/NonCopyable.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/NonCopyable.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/NonCopyable.hpp (revision 939)
@@ -0,0 +1,48 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// NonCopyable.hpp
+// Since  2005/07/13 15:25:58
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __NONCOPYABLE_HPP
+#define __NONCOPYABLE_HPP
+#include "xerial/common/xerial.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+/**
+ * A class NonCopyable is useful to protect duplication of objects which should not be copied.
+ * By inheriting NonCopyable (no matter which inheritance you choose (public, protected, or private), it works well), 
+ * you can see invocations of copy constructors and assignment operations at compile time (statically).
+ *
+ * usage: 
+ *
+ * <pre>
+ * class YourClass : private NonCopyable 
+ * {
+ *    .....
+ * } 
+ * </pre>
+ *
+ * This class is based on <boost/noncopyable.hpp> by Dave Abrahams.
+ */
+class NonCopyable
+{
+protected:
+	NonCopyable() {}
+	~NonCopyable() {}
+private:
+	// restrict the copy constructor
+	NonCopyable(const NonCopyable& );
+	// restrict the assignment operator
+	const NonCopyable& operator=(const NonCopyable& );
+};
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__NONCOPYABLE_HPP
Index: /sandbox/trunk/pdp/src/xerial/util/List.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/List.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/List.hpp (revision 939)
@@ -0,0 +1,38 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// List.hpp
+// Since  2006/05/16 12:55:10
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/util/List.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __LIST_HPP_20060516_125509
+#define __LIST_HPP_20060516_125509
+#include "xerial/common/xerial.hpp"
+#include "xerial/util/NonConstructable.hpp"
+#include "xerial/util/Collection.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+namespace impl
+{
+
+} // impl
+
+template <class T>
+class XERIAL_API List : public virtual Collection<T>
+{
+public:
+	virtual Reference operator[](size_t index) = 0;
+	virtual ConstReference operator[](size_t index) const = 0;
+private:
+
+};
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__LIST_HPP_20060516_125509
Index: /sandbox/trunk/pdp/src/xerial/util/Printable.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/Printable.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/Printable.cpp (revision 939)
@@ -0,0 +1,33 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Printable.cpp
+// Since  2006/07/26 14:19:24
+// 
+// $Date: 2006-09-18 17:03:25 +0900 (譛� 18 9 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/util/Printable.cpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#include "xerial/util/Printable.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+std::ostream&
+Printable::operator<<(std::ostream& os) const
+{
+	os << this->toString();
+	return os;	
+}
+
+
+
+std::ostream& 
+operator<<(std::ostream& os, const Printable& obj) 
+{
+	os << obj.toString();
+	return os;	   
+}
+
+
+XERIAL_NAMESPACE_END
Index: /sandbox/trunk/pdp/src/xerial/util/detail/IteratorImpl.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/detail/IteratorImpl.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/detail/IteratorImpl.hpp (revision 939)
@@ -0,0 +1,89 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// IteratorImpl.hpp
+// Since  2006/08/22 13:55:01
+// 
+// $Date$ 
+// $Author$ 
+//--------------------------------------------------
+#ifndef __ITERATORIMPL_HPP_20060822_135501
+#define __ITERATORIMPL_HPP_20060822_135501
+#include "xerial/common/xerial.hpp"
+#include "xerial/exception/ExceptionUtil.hpp"
+#include "xerial/exception/assert.hpp"
+#include <boost/type_traits.hpp>
+
+XERIAL_NAMESPACE_BEGIN
+
+namespace detail
+{
+	template <class T>
+	class IteratorBase : NonConstructable
+	{
+	protected:
+		typedef typename boost::add_const<T>::type const_type;
+	public:
+		typedef T& Reference;
+		typedef const_type& ConstReference;
+
+	};
+
+	template <class T>
+	class ConstIteratorBase : NonConstructable
+	{
+	protected:
+		typedef typename boost::add_const<T>::type const_type;
+	public:
+		typedef const_type& Reference;
+		typedef const_type& ConstReference;
+	};
+
+	// specialized version for pointers
+	/*
+	template <class T>
+	class IteratorBase<T*> : NonConstructable
+	{
+	protected:
+		typedef typename boost::add_const<T>::type const_type;
+	public:
+		typedef T* Reference;
+		typedef const_type* ConstReference;
+
+	};
+
+	template <class T>
+	class ConstIteratorBase<T*> : NonConstructable
+	{
+	protected:
+		typedef typename boost::add_const<T>::type const_type;
+	public:
+		typedef const_type* Reference;
+		typedef const_type* ConstReference;
+	};
+	*/
+
+	template <class T, class Reference>
+	class IteratorImpl : NonConstructable
+	{
+	public:
+		virtual bool hasNext() const = 0;
+		virtual bool hasPrevious() const = 0;
+		virtual Reference next() = 0;
+		virtual Reference previous() = 0;
+		virtual Reference peekNext() const = 0;
+		virtual Reference peekPrevious() const = 0;
+		virtual void remove() 
+		{
+			XERIAL_THROW(UnsupportedOperation, "remove() is not supported");
+		}
+
+		virtual IteratorImpl* clone() const = 0;
+	};
+
+} // namespace detail
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__ITERATORIMPL_HPP_20060822_135501
Index: /sandbox/trunk/pdp/src/xerial/util/detail/STLIteratorWrapper.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/detail/STLIteratorWrapper.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/detail/STLIteratorWrapper.hpp (revision 939)
@@ -0,0 +1,129 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// STLIteratorWrapper.hpp
+// Since  2006/08/25 0:23:06
+// 
+// $Date$ 
+// $Author$ 
+//--------------------------------------------------
+#pragma once
+#ifndef __STLITERATORWRAPPER_HPP_20060825_02306
+#define __STLITERATORWRAPPER_HPP_20060825_02306
+#include "xerial/common/xerial.hpp"
+#include "xerial/util/detail/IteratorImpl.hpp"
+#include "xerial/exception/OutOfRangeException.hpp"
+#include <boost/next_prior.hpp>
+
+XERIAL_NAMESPACE_BEGIN
+
+template <class Element, class Container, class IteratorType, class ReferenceType>
+class STLIterator : public detail::IteratorImpl<Element, ReferenceType>
+{
+	typedef detail::IteratorImpl<Element, ReferenceType> Base;
+
+	Container& _container;		
+	IteratorType _previous;
+	IteratorType _next;
+public:
+	STLIterator(Container& container)
+		: _container(container)
+	{
+		_previous = _container.end();
+		_next = _container.begin();
+	}
+	STLIterator(Container& container, IteratorType nextIterator)
+		: _container(container)
+	{
+		_next = nextIterator;
+		_previous = boost::prior(_next);
+	}
+	virtual ~STLIterator() {}
+
+	virtual bool hasNext() const
+	{
+		return (_next != _container.end());
+	}
+	virtual bool hasPrevious() const
+	{
+		return (_next != _container.begin());
+	}
+	virtual ReferenceType next() 
+	{
+		if(!hasNext())
+		{
+			XERIAL_THROW(Exception, "no such element");
+		}
+		else
+		{
+			_previous = _next;
+			++_next;
+			return *_previous;
+		}
+	}
+	virtual ReferenceType previous()
+	{
+		if(!hasPrevious())
+		{
+			XERIAL_THROW(Exception, "no such element");
+		}
+		else
+		{
+			_previous = boost::prior(_previous);
+			_next = boost::prior(_next);
+			return *_next;
+		}
+	}
+	virtual ReferenceType peekNext() const
+	{
+		return *_next;
+	}
+	virtual ReferenceType peekPrevious() const
+	{
+		return *_previous;
+	}
+
+	virtual detail::IteratorImpl<Element, ReferenceType>* clone() const
+	{
+		return new STLIterator(*this);
+	}
+
+};
+
+namespace detail
+{
+	template <class Container, class ConstRef>
+	ConstRef getNthElement(const Container& container, size_t n)
+	{
+		Container::ConstIterator it = container.getIterator();
+		size_t count = 0;
+		while(it.hasNext())
+		{
+			Container::ConstReference r = it.next();
+			if(count++ == n)
+				return r;
+		}
+		XERIAL_THROW(OutOfRangeException, "out of range: " << n << " is out of container sieze " << container.size() );
+	}
+	
+	template <class Container, class Ref>
+	Ref getNthElement(Container& container, size_t n)
+	{
+		Container::Iterator it = container.getIterator();
+		size_t count = 0;
+		while(it.hasNext())
+		{
+			Container::Reference r = it.next();
+			if(count++ == n)
+				return r;
+		}
+		XERIAL_THROW(OutOfRangeException, "out of range: " << n << " is out of container sieze " << container.size() );
+	}
+
+}
+
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__STLITERATORWRAPPER_HPP_20060825_02306
Index: /sandbox/trunk/pdp/src/xerial/util/ScopedPointer.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/ScopedPointer.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/ScopedPointer.hpp (revision 939)
@@ -0,0 +1,193 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// ScopedPointer.hpp
+// Since  2006/05/16 13:57:18
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/util/ScopedPointer.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __SCOPEDPOINTER_HPP_20060516_135717
+#define __SCOPEDPOINTER_HPP_20060516_135717
+#include "xerial/common/xerial.hpp"
+#include "xerial/util/NonCopyable.hpp"
+#include "xerial/util/NonConstructable.hpp"
+#include "xerial/exception/assert.hpp"
+#include "xerial/exception/UnsupportedOperation.hpp"
+#include "xerial/detail/MemoryChunkAllocator.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+namespace detail 
+{
+	template<class T> struct ScopedPtrTypeTraits { typedef T& reference; };
+	template<> struct ScopedPtrTypeTraits<void> { typedef void reference; };
+	template<> struct ScopedPtrTypeTraits<void const> { typedef void reference; };
+	template<> struct ScopedPtrTypeTraits<void volatile> { typedef void reference; };
+	template<> struct ScopedPtrTypeTraits<void const volatile> { typedef void reference; };
+
+	template<class T> inline void checked_delete(T * x)
+	{
+		// intentionally complex - simplification causes regressions
+		typedef char type_must_be_complete[ sizeof(T)? 1: -1 ];
+		(void) sizeof(type_must_be_complete);
+		delete x;
+	}
+
+} // namespace detail
+
+template <class T>
+class ScopedPtr : NonCopyable
+{
+	class DeleteProcessHolder : NonCopyable
+	{
+	public:
+		virtual void dispose() = 0;
+	};
+
+	template<class Ptr, class DeleteProcess>
+	class UserDefinedDeleteProcess : public DeleteProcessHolder
+	{
+		typedef UserDefinedDeleteProcess<Ptr, DeleteProcess> ThisType;
+
+		DeleteProcess _dp;
+		Ptr* _ptr;
+	public:
+		explicit UserDefinedDeleteProcess(Ptr* ptr, DeleteProcess d)
+			: _dp(d), _ptr(ptr)
+		{}
+		void* operator new(std::size_t)
+		{
+			return detail::MemoryChunkAllocator<ThisType>::allocate();
+		}
+		void operator delete(void* p)
+		{
+			return detail::MemoryChunkAllocator<ThisType>::deallocate(p);
+		}
+		
+		virtual void dispose()
+		{
+			_dp(_ptr);
+		}
+	};
+
+	T * _ptr;
+	DeleteProcessHolder* _deleteProcess;
+public:
+	typedef typename detail::ScopedPtrTypeTraits<T>::reference reference;
+
+	ScopedPtr()
+		: _ptr(0), _deleteProcess(0)
+	{
+
+	}
+
+	template <class V>
+	explicit ScopedPtr(V* ptr)
+		: _ptr(ptr), _deleteProcess(0)
+	{
+	}
+
+
+
+	template <class V, class DeleteProcess>
+	explicit ScopedPtr(V * ptr, DeleteProcess deleteProcess)
+		: _ptr(ptr), _deleteProcess(0)
+	{
+		try
+		{
+			_deleteProcess = new UserDefinedDeleteProcess<V, DeleteProcess>(ptr, deleteProcess);
+		}
+		catch(...)
+		{
+			deleteProcess(ptr);
+			throw;
+		}
+	}
+
+	~ScopedPtr() 
+	{
+		if(_deleteProcess)
+		{
+			_deleteProcess->dispose();
+			delete _deleteProcess;
+		}
+		else
+		{
+			detail::checked_delete(_ptr);
+		}
+	}
+
+	void reset(T* p = 0)
+	{
+		XERIAL_ASSERT(p == 0 || p != _ptr); // avoid self-reset
+		if(_deleteProcess)
+			XERIAL_THROW(UnsupportedOperation, "reset() of SharedPtr with user defined deleter is not supported");
+
+		ScopedPtr<T>(p).swap(*this);
+	}
+	
+	reference operator*() const
+	{
+		XERIAL_ASSERT(_ptr != 0);
+		return *_ptr;
+	}
+	T* operator->() const
+	{
+		XERIAL_ASSERT(_ptr != 0);
+		return _ptr;
+	}
+	T* get() const
+	{
+		return _ptr;
+	}
+
+	void swap(ScopedPtr &other)
+	{
+		if(_deleteProcess)
+			XERIAL_THROW(UnsupportedOperation, "swap() of SharedPtr with user defined deleter is not supported");
+
+		T* tmp = other._ptr;
+		other._ptr = _ptr;
+		_ptr = tmp;
+	}
+
+	/**
+	 * Reset the ScopedPtr, and release the management of the allocated resource
+	 * @return  A pointer that have been managed by this ScopedPtr. Deallocation of 
+	 * the returned pointer must be performed by the callee of this release() function.
+	 */
+	T* release()
+	{
+		if(_deleteProcess)
+			XERIAL_THROW(UnsupportedOperation, "release() of SharedPtr with user defined deleter is not supported");
+		
+		T* tmp = _ptr;
+		_ptr = 0;
+		return tmp;
+	}
+
+private:
+
+};
+
+template <>
+ScopedPtr<void>::~ScopedPtr()
+{
+	if(_deleteProcess)
+	{
+		_deleteProcess->dispose();
+		delete _deleteProcess;
+	}
+
+}
+
+
+
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__SCOPEDPOINTER_HPP_20060516_135717
Index: /sandbox/trunk/pdp/src/xerial/util/NonConstructable.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/NonConstructable.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/NonConstructable.cpp (revision 939)
@@ -0,0 +1,14 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// NonConstructable.cpp
+// Since  2006/05/16 23:45:19
+// 
+// $Date$ 
+// $Author$ 
+//--------------------------------------------------
+#include "xerial/util/NonConstructable.hpp"
+
+using namespace xerial;
+
+NonConstructable::~NonConstructable() {}
Index: /sandbox/trunk/pdp/src/xerial/util/Message.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/Message.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/Message.cpp (revision 939)
@@ -0,0 +1,38 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Message.cpp
+// Since  2006/08/26 7:07:56
+// 
+// $Date$ 
+// $Author$ 
+//--------------------------------------------------
+#include "xerial/util/Message.hpp"
+#include "xerial/util/Printable.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+std::string
+Message::toString() const
+{
+	return _message.str();
+}
+
+Message&
+Message::operator<<(size_t message) 
+{
+	_message << static_cast<unsigned int>(message);
+	return *this;
+}
+Message&
+Message::operator<<(uint8 message) 
+{
+	_message << static_cast<int>(message);
+	return *this;
+}
+
+Message&
+Message::operator<<(const Printable& printable) 
+{
+	_message << printable.toString();
+	return *this;
+}
Index: /sandbox/trunk/pdp/src/xerial/util/Printable.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/Printable.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/Printable.hpp (revision 939)
@@ -0,0 +1,35 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Printable.hpp
+// Since  2006/07/24 16:31:40
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/util/Printable.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __PRINTABLE_HPP_20060724_163140
+#define __PRINTABLE_HPP_20060724_163140
+#include "xerial/common/xerial.hpp"
+#include "xerial/util/NonConstructable.hpp"
+#include <string>
+#include <iosfwd>
+
+XERIAL_NAMESPACE_BEGIN
+
+class XERIAL_API Printable : NonConstructable
+{
+public:
+	virtual std::string toString() const = 0;
+	virtual	std::ostream& operator<<(std::ostream& os) const;
+
+private:
+};
+
+std::ostream& operator<<(std::ostream& os, const Printable& obj);
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__PRINTABLE_HPP_20060724_163140
Index: /sandbox/trunk/pdp/src/xerial/util/hash_map.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/hash_map.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/hash_map.hpp (revision 939)
@@ -0,0 +1,24 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// hash_map.hpp
+// Since  2005/11/15 12:01:06
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/util/hash_map.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __HASH_MAP_HPP_20051115_120106
+#define __HASH_MAP_HPP_20051115_120106
+#include "xerial/common/xerial.hpp"
+
+
+#ifdef _WIN32
+
+#pragma warning(disable:4996)
+#include <hash_map>
+#endif	// _WIN32
+
+
+#endif //__HASH_MAP_HPP_20051115_120106
Index: /sandbox/trunk/pdp/src/xerial/util/io/FileUtil.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/io/FileUtil.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/io/FileUtil.hpp (revision 939)
@@ -0,0 +1,70 @@
+//------------------------------------------------
+// Xerial -- Transaction Enabled XML Database
+//
+// FileUtil.hpp
+// Since  2003/08/30 03:01:38
+//
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $Author: leo $
+//------------------------------------------------
+
+#pragma once
+#ifndef __FILEUTIL_HPP_33
+#define __FILEUTIL_HPP_33
+
+#include <string>
+#include "xerial/common/xerial.hpp"
+#include "xerial/common/xerial_types.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+/**
+ * an utility package for handling files, directories, and paths
+ */
+class XERIAL_API FileUtil
+{
+public:
+	/**
+	 * test whether the file exists or not
+	 * @param fileName	
+	 * @return	true if the file exists.
+	 */
+	static bool existFile(const std::string &fileName);
+	static bool existDir(const std::string &dirName);
+
+	static uint64 fileSize(const std::string& filePath);
+	/**
+	 * 
+	 * @param fileName	
+	 * @return	
+	 */
+	static int removeFile(const std::string &fileName);
+	static void mkdir(const std::string &fileName);
+	/**
+	 * replace extension in the filename. ex. somefile.hpp to somefile.cpp
+	 * @param fileName	
+	 * @param ext	a new extension
+	 * @return	a new file name after the replacement of its extension
+	 */
+	static std::string replaceExtension(const std::string &fileName, const std::string &ext);
+	/**
+	 * remove a file extension. ex. sample.txt -> sample
+	 * @param path	
+	 * @rXeturn	no extension filename
+	 */
+	static std::string removeExtension(const std::string &path);
+	/**
+	 * 
+	 * @param path	
+	 * @return	an only filename without its precedent path
+	 */
+	static std::string getLeaf(const std::string &path);
+
+	static std::string appendPath(const std::string &parentPath, const std::string& file);
+
+
+};
+
+XERIAL_NAMESPACE_END
+
+#endif // __FILEUTIL_HPP_33
Index: /sandbox/trunk/pdp/src/xerial/util/io/FileUtil.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/io/FileUtil.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/io/FileUtil.cpp (revision 939)
@@ -0,0 +1,160 @@
+//------------------------------------------------
+// Xerial -- Transaction Enabled XML Database
+//
+// FileUtil.cpp
+// Since  2003/10/10 17:43:51
+//
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $Author: leo $
+//------------------------------------------------
+
+#include "xerial/util/io/FileUtil.hpp"
+#include <iostream>
+#include <stdexcept>
+#include <fstream>
+#include <stack>
+#include "xerial/exception/ExceptionUtil.hpp"
+#include <boost/filesystem/operations.hpp>
+#include "xerial/common/xerial_last.hpp"
+
+
+
+XERIAL_NAMESPACE_BEGIN
+
+void
+FileUtil::mkdir(const string &dirName)
+{
+	using namespace boost::filesystem;
+	try
+	{
+		path dir(dirName);
+		stack<path> nonExistentPath;
+		while(!exists(dir))
+		{
+			nonExistentPath.push(dir);
+			if(!dir.empty())
+				dir = dir.branch_path();
+			else
+				break;
+		}
+		while(!nonExistentPath.empty())
+		{
+			create_directory(nonExistentPath.top());
+			nonExistentPath.pop();
+		}
+	}
+	catch(std::runtime_error &e)
+	{
+		XERIAL_THROW(Exception, "filesystem error: " << e.what());
+	}
+}
+
+bool
+FileUtil::existFile(const string &fileName)
+{
+	if(fileName == "")
+		return false;
+	FILE *tmp;
+	if((tmp = fopen(fileName.c_str(), "r")) == NULL)
+	{
+		return false;
+	}
+	fclose(tmp);
+	return true;
+}
+	
+int
+FileUtil::removeFile(const string &fileName)
+{
+	if(fileName == "")
+		return -1;
+	return remove(fileName.c_str());
+}
+
+string
+FileUtil::replaceExtension(const string &fileName, const string &ext)
+{
+	size_t dotPosition = fileName.find_last_of(".");
+		
+	if(dotPosition == (size_t) string::npos)
+	{
+		return fileName + "." + ext;		
+	}
+		
+	string tmp = fileName;
+	tmp.erase(dotPosition+1, tmp.size()-dotPosition+1);
+	return tmp + ext;
+}
+
+string
+FileUtil::removeExtension(const string &path)
+{
+	string leafFileName = getLeaf(path);
+	size_t dotPosition = leafFileName.find_last_of(".");	
+	if(dotPosition == (size_t) string::npos)
+	{
+		return path;
+	}
+		
+	string tmp = path;
+	size_t noLeafSize = path.size() - leafFileName.size();
+	size_t absoluteDotPos = noLeafSize + dotPosition;
+	tmp.erase(absoluteDotPos, tmp.size()-absoluteDotPos);
+	return tmp;
+}
+
+string
+FileUtil::getLeaf(const string &path)
+{
+	size_t lastSeparatorPosition = path.find_last_of("/\\");
+	if(lastSeparatorPosition == (size_t) string::npos)
+	{
+		return path;
+	}
+
+	string tmp = path;
+	tmp.erase(0, lastSeparatorPosition+1);
+	return tmp;
+}
+
+bool
+FileUtil::existDir(const std::string& dirName) 
+{ 
+	using namespace boost::filesystem;
+	try
+	{	
+		path dir(dirName);
+		return exists(dir);		
+	}
+	catch(exception &e)
+	{
+		XERIAL_THROW(Exception, "filesystem error: " << e.what());
+	}
+}
+
+std::string 
+FileUtil::appendPath(const std::string &parentPath, const std::string &file)
+{
+	using namespace boost::filesystem;
+	path p(parentPath, native);
+	p /= file;
+	return p.string();
+}
+
+uint64 
+FileUtil::fileSize(const std::string& filePath)
+{
+	using namespace boost::filesystem;
+	try
+	{	
+		path p(filePath);
+		return static_cast<uint64>(file_size(p));		
+	}
+	catch(exception &e)
+	{
+		XERIAL_THROW(Exception, "filesystem error: " << e.what());
+	}
+}
+
+
+XERIAL_NAMESPACE_END
Index: /sandbox/trunk/pdp/src/xerial/util/thread/LightMutex.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/thread/LightMutex.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/thread/LightMutex.hpp (revision 939)
@@ -0,0 +1,74 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// LightMutex.hpp
+// Since  2005/07/19 15:29:29
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __LIGHTMUTEX_HPP
+#define __LIGHTMUTEX_HPP
+#include "xerial/common/xerial.hpp"
+#include "xerial/util/thread/ScopeGuard.hpp"
+#include "xerial/util/NonCopyable.hpp"
+#include "xerial/util/thread/Lock.hpp"
+#include "xerial/util/thread/CompareAndSwap.hpp"
+#include "xerial/exception/assert.hpp"
+
+#ifdef WIN32
+// Exclude rarely-used stuff from Windows headers
+#define WIN32_LEAN_AND_MEAN 
+#include <windows.h>
+// ignore warnings for unreferenced formal parameters
+#pragma warning(disable : 4100)
+#else
+#error LightMutex is not supported yet in other than win32
+#endif
+
+XERIAL_NAMESPACE_BEGIN
+
+/**
+ * LightMutex is a user-mode lock that uses atomic compare-and-swap operations
+ * in order to manage simultaneous access to the lock object.
+ *
+ * Note that the LightMutex cannot protect concurrent accesses 
+ * of threads belonging to different processes. 
+ *
+ * @author leo
+ */
+class XERIAL_API LightMutex : private Lock, private NonCopyable
+{
+public:
+	LightMutex()
+		: _lock(0)
+	{}
+	~LightMutex()
+	{ XERIAL_ASSERT(_lock == 0); }
+
+	void acquire() 
+	{
+		while(AtomicCompareAndSwap32(&_lock, 0, 1) != 0)
+			::Sleep(0);
+	}
+
+	bool tryAcquire(unsigned long timeout = 0)
+	{
+		return AtomicCompareAndSwap32(&_lock, 0, 1) == 0;
+	}	
+
+	void release()
+	{
+		XERIAL_ASSERT(_lock == 1);	// the caller must be the lock owner
+		AtomicSwap32(&_lock, 0);
+	}
+
+private:
+	uint32 volatile _lock;
+};
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__LIGHTMUTEX_HPP
Index: /sandbox/trunk/pdp/src/xerial/util/thread/ScopeGuard.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/thread/ScopeGuard.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/thread/ScopeGuard.hpp (revision 939)
@@ -0,0 +1,127 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// ScopeGuard.hpp
+// Since  2005/07/19 10:16:20
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __SCOPEGUARD_HPP
+#define __SCOPEGUARD_HPP
+#include "xerial/common/xerial.hpp"
+#include "xerial/util/NonCopyable.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+/**
+* LockHolder holds any type of lock object.
+* This design is modeled on <boost/any.hpp> in Boost C++ library.
+*/
+template <class LockType>
+class LockHolder : private NonCopyable
+{
+	LockType& _lock;
+public:
+	template <class T>
+		LockHolder(T& lock)
+		: _lock(cast(t)._lock) 
+	{}
+
+	LockHolder(LockHolder& holder) 
+		: _lock(holder._lock)
+	{}
+
+	LockHolder(LockType& lock) 
+		: _lock(lock) 
+	{}
+
+	LockType& getLock() { return _lock; }
+
+
+	template <class T>
+	static LockHolder& cast(T& t)
+	{
+		return static_cast<LockHolder&>(t);
+	}
+}; 
+
+class ScopeLocking;
+class ScopeUnlocking;
+
+template <class LockType, class LockingPolicy = ScopeLocking>
+class ScopeGuard : private NonCopyable
+{
+public:
+	ScopeGuard(LockType& lock)
+		: _lockHolder(lock)
+	{
+		LockingPolicy::enterScope(_lockHolder);
+	}
+
+	template <class U, class V>
+	ScopeGuard(ScopeGuard<U, V>& guard)
+		: _lockHolder(guard.getLockHolder())
+	{
+		LockingPolicy::enterNestedScope(_lockHolder);
+	}
+
+	~ScopeGuard() throw()	// no throw
+	{
+		LockingPolicy::leaveScope(_lockHolder);
+	}
+
+	LockHolder<LockType>& getLockHolder() 
+	{
+		return _lockHolder;
+	}
+private:
+	LockHolder<LockType> _lockHolder;	
+};
+
+
+
+class ScopeLocking
+{
+public:
+	template <class LockType>
+	static void enterScope(LockHolder<LockType>& lockHolder)
+	{
+		lockHolder.getLock().acquire();
+	}
+
+	template <class LockType>
+	static void leaveScope(LockHolder<LockType>& lockHolder)
+	{
+		lockHolder.getLock().release();
+	}
+};
+
+class ScopeUnlocking
+{
+public:
+	template <class LockType>
+	static void enterScope(LockHolder<LockType>& lockHolder)
+	{
+		lockHolder.getLock().release();
+	}
+
+	template <class LockType>
+	static void enterNestedScope(LockHolder<LockType>& lockHolder)
+	{
+		lockHolder.getLock().release();
+	}
+
+	template <class LockType>
+	static void leaveScope(LockHolder<LockType>& lockHolder)
+	{
+		lockHolder.getLock().acquire();
+	}
+};
+
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__SCOPEGUARD_HPP
Index: /sandbox/trunk/pdp/src/xerial/util/thread/CompareAndSwap.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/thread/CompareAndSwap.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/thread/CompareAndSwap.cpp (revision 939)
@@ -0,0 +1,28 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// CompareAndSwap.cpp
+// Since  2005/07/22 0:27:58
+// 
+// $Date$ 
+// $Author$ 
+//--------------------------------------------------
+#include "xerial/util/thread/CompareAndSwap.hpp"
+#include <windows.h>
+#include "xerial/common/xerial_last.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+uint32
+AtomicCompareAndSwap32(uint32 volatile *destination, uint32 oldValue, uint32 newValue) 
+{
+	return (uint32) ::InterlockedCompareExchange((LONG*) destination, (LONG) newValue, (LONG) oldValue);
+}
+
+void AtomicSwap32(uint32 volatile *destination, uint32 newValue) 
+{
+	::InterlockedExchange((LONG*) destination, (LONG) newValue);
+}
+
+XERIAL_NAMESPACE_END
+
Index: /sandbox/trunk/pdp/src/xerial/util/thread/CompareAndSwap.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/thread/CompareAndSwap.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/thread/CompareAndSwap.hpp (revision 939)
@@ -0,0 +1,41 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// CompareAndSwap.hpp
+// Since  2005/06/28 11:34:41
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __COMPAREANDSWAP_HPP_20050722_01803
+#define __COMPAREANDSWAP_HPP_20050722_01803
+
+#include "xerial/common/xerial.hpp"
+#include "xerial/common/xerial_types.hpp"
+
+
+XERIAL_NAMESPACE_BEGIN
+
+
+/**
+ * The function CompareAndSwap performs an atomic comparison of the destination value with the oldValue. 
+ * If the destination value is equal to the oldValue, this function stores the newValue to the address space specified 
+ * by the destination.
+ *
+ * @param destination
+ * @param oldValue	
+ * @param newValue	
+ * @return the initial value of the destination
+ */
+
+XERIAL_API uint32 AtomicCompareAndSwap32(uint32 volatile *destination, uint32 oldValue, uint32 newValue);
+
+XERIAL_API void AtomicSwap32(uint32 volatile *destination, uint32 newValue);
+
+
+XERIAL_NAMESPACE_END
+
+
+
+#endif //__COMPAREANDSWAP_HPP_20050722_01803
Index: /sandbox/trunk/pdp/src/xerial/util/thread/Lock.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/thread/Lock.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/thread/Lock.hpp (revision 939)
@@ -0,0 +1,47 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Lock.hpp
+// Since  2005/07/19 10:08:51
+// 
+// $Date: 2005-10-12 13:03:09 +0900 (豌ｴ, 12 10 2005) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#ifndef __LOCK_HPP
+#define __LOCK_HPP
+#include "xerial/common/xerial.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+/**
+ * A common interface of lock objects
+ * @author leo
+ */
+class Lock
+{
+public:
+	virtual ~Lock() {}
+
+	/**
+	 * Acquire the Lock object
+	 */
+	virtual void acquire() = 0;
+	/**
+	 * Try to acquire the Lock object
+	 * @param long	- maximum amount of time (milliseconds) that caller can wait
+	 * @return 
+	 *  - true if the acquisition completes 
+	 *  - false if the acquisition times out before the Lock can be acquired
+	 */
+	virtual bool tryAcquire(unsigned long timeout = 0) = 0;
+	/**
+	 * Release the Lock object;
+	 */
+	virtual void release() = 0;
+
+};
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__LOCK_HPP
Index: /sandbox/trunk/pdp/src/xerial/util/NonConstructable.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/NonConstructable.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/NonConstructable.hpp (revision 939)
@@ -0,0 +1,27 @@
+//--------------------------------------------------
+// NonConstructable.hpp
+// Since  2006/02/07 16:05:11
+// 
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/branches/leo/btree-devel-0.1/src/xerial/util/NonConstructable.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __NONCONSTRUCTABLE_HPP_20060207_160511
+#define __NONCONSTRUCTABLE_HPP_20060207_160511
+#include "xerial/common/xerial.hpp"
+
+#ifdef WIN32
+// Do not issue compiler warnings that say 'cannot automatically generate a copy constructor or default constructor'.
+#pragma warning(disable:4511 4512)	
+#endif // WIN32
+
+class NonConstructable
+{
+public:
+	virtual ~NonConstructable() = 0;
+protected:
+	inline NonConstructable() {}
+};
+
+#endif //__NONCONSTRUCTABLE_HPP_20060207_160511
Index: /sandbox/trunk/pdp/src/xerial/util/Message.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/Message.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/Message.hpp (revision 939)
@@ -0,0 +1,66 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Message.hpp
+// Since  2006/08/26 6:56:42
+// 
+// $Date$ 
+// $Author$ 
+//--------------------------------------------------
+#pragma once
+#ifndef __MESSAGE_HPP_20060826_65642
+#define __MESSAGE_HPP_20060826_65642
+#include "xerial/common/xerial.hpp"
+#include "xerial/common/xerial_types.hpp"
+#include "xerial/util/Printable.hpp"
+#include <string>
+#include <sstream>
+
+XERIAL_NAMESPACE_BEGIN
+
+class Printable;
+class Message;
+
+#define XERIAL_MESSAGE(m) (Message() << m).toString() 
+
+/**
+ * Message class reads various types of data, and convert them into strings.
+ * This class is useful to generate string object in a short-hand notation.
+ * For example, 
+ *   string w = "World!";
+ *   XERIAL_MESSAGE("Hello" << ", " << w)
+ * generates a string object, string("Hello, World!").
+ * 
+ * The trick behind the scene is as follows:
+ * The macro XERIAL_MESSAGE is expanded into 
+ *	(Message() << "Hello" << ", " << w).toString()
+ * It first creates a temporary Message object, then appends message strings by contiguously calling operator<<.
+ * Message class holds a buffer for strings, and toString() method generates a string object from the buffer contents.
+ *
+ * Embeded types such as integer, float etc. can be used as inputs to Message object.
+ * If you want to pass user-defined objects to the Message class, you must implement
+ * void operator<<(std::ostream& os) in these objects, or derived them from Printable interface.
+ * Without doing this, the memory addresses of the objects will be added to the Message.
+ */
+class XERIAL_API Message : public Printable
+{
+public:
+	Message& operator<<(size_t message);
+	Message& operator<<(uint8 message);
+	Message& operator<<(const Printable& printable);
+	template <class T>
+	Message& operator<<(const T &message)
+	{
+		_message << message;
+		return *this;
+	}
+
+	std::string toString() const;
+private:
+	std::ostringstream _message;
+};
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__MESSAGE_HPP_20060826_65642
Index: /sandbox/trunk/pdp/src/xerial/util/ustring.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/ustring.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/ustring.cpp (revision 939)
@@ -0,0 +1,28 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// ustring.cpp
+// Since  2004/10/22 15:09:25
+// 
+// $Date: 2004-10-26 15:50:32 +0900 (轣ｫ, 26 10 2004) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#include "xerial/util/ustring.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+
+namespace xerial
+{
+	
+	std::string
+	transform(const ustring& str) 
+	{
+		return string((char*) str.data(), str.size());
+	}
+	
+	ustring
+	transform(const std::string& str) 
+	{
+		return ustring((boost::uint8_t*) str.data(), str.size());
+	}
+}
Index: /sandbox/trunk/pdp/src/xerial/util/Iterable.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/Iterable.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/Iterable.hpp (revision 939)
@@ -0,0 +1,171 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Iterable.hpp
+// Since  2006/05/16 11:56:52
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/util/Iterable.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __ITERABLE_HPP_20060516_115652
+#define __ITERABLE_HPP_20060516_115652
+#include "xerial/common/xerial.hpp"
+#include "xerial/util/NonCopyable.hpp"
+#include "xerial/exception/ExceptionUtil.hpp"
+#include "xerial/exception/assert.hpp"
+#include "xerial/exception/UnsupportedOperation.hpp"
+#include "xerial/util/ScopedPointer.hpp"
+#include <boost/type_traits.hpp>
+#include "xerial/util/detail/IteratorImpl.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+template<class T>
+class XERIAL_API Iterator : public detail::IteratorBase<T>
+{
+public:
+	typedef typename detail::IteratorImpl<T, Reference> IteratorImpl;
+	Iterator(IteratorImpl* impl)
+		: _impl(impl)
+	{
+		XERIAL_ASSERT(impl != 0);
+	}
+	
+	Iterator(const Iterator& other)
+		: _impl(0)
+	{
+		*this = other;
+	}
+	
+	Iterator& operator=(const Iterator& other)
+	{
+		if(this == &other)
+			return *this;
+
+		if(_impl)
+			delete _impl;
+		ScopedPtr<IteratorImpl> tmp(other._impl->clone());
+		_impl = tmp.release();
+		return *this;
+	}
+	virtual ~Iterator() 
+	{
+		if(_impl)
+			delete _impl;
+	}
+
+	Iterator* clone() const 
+	{
+		return new Iterator(_impl->clone());
+	}
+
+	virtual bool hasNext() const { return _impl->hasNext(); }
+	virtual bool hasPrevious() const { return _impl->hasPrevious(); }
+	virtual	Reference next() { return _impl->next(); }
+	virtual Reference previous() { return _impl->previous(); }
+	virtual Reference peekNext() const { return _impl->peekNext(); }
+	virtual Reference peekPrevious() const { return _impl->peekPrevious(); }
+	virtual void remove() { return _impl->remove(); }
+private:
+	IteratorImpl* _impl;
+};
+
+template<class T>
+class XERIAL_API ConstIterator : public detail::ConstIteratorBase<T>
+{
+	typedef typename boost::add_const<T>::type const_type;
+public:
+	typedef typename detail::IteratorImpl<T, ConstReference> IteratorImpl;
+	ConstIterator(IteratorImpl* impl)
+		: _impl(impl)
+	{
+		XERIAL_ASSERT(impl != 0);
+	}
+
+	ConstIterator(const ConstIterator& other)
+		: _impl(0)
+	{
+		*this = other;
+	}
+
+	ConstIterator& operator=(const ConstIterator& other)
+	{
+		if(this == &other)
+			return *this;
+
+		if(_impl)
+			delete _impl;
+		ScopedPtr<IteratorImpl> tmp(other._impl->clone());
+		_impl = tmp.release();
+		return *this;
+	}
+	virtual ~ConstIterator() 
+	{
+		if(_impl)
+			delete _impl;
+	}
+	ConstIterator* clone() const 
+	{
+		return new ConstIterator(_impl->clone());
+	}
+
+	virtual bool hasNext() const { return _impl->hasNext(); }
+	virtual bool hasPrevious() const { return _impl->hasPrevious(); }
+	virtual	Reference next() { return _impl->next(); }
+	virtual Reference previous() { return _impl->previous(); }
+	virtual Reference peekNext() const { return _impl->peekNext(); }
+	virtual Reference peekPrevious() const { return _impl->peekPrevious(); }
+	virtual void remove() { return _impl->remove(); }
+
+private:
+	IteratorImpl* _impl;
+};
+
+
+
+template <class T>
+class XERIAL_API Iterable : NonConstructable
+{
+public:
+	//typedef boost::add_reference<T> Reference;
+	//typedef boost::add_reference<const_type> ConstReference;
+	typedef typename Iterator<T>::Reference Reference;
+	typedef typename Iterator<T>::ConstReference ConstReference;
+
+	typedef Iterator<T> Iterator;
+	typedef ConstIterator<T> ConstIterator; 
+
+	virtual Iterator getIterator() = 0;
+	virtual ConstIterator getIterator() const = 0;
+
+private:
+};
+
+/*
+// A specialized version of Iterable<T> for pointer classes; Iterable<T*>
+// Its iterator handles pointer directly, not the reference of the pointer.
+template <class T>
+class XERIAL_API Iterable<T*> : NonConstructable
+{
+public:
+	//typedef boost::add_reference<T> Reference;
+	//typedef boost::add_reference<const_type> ConstReference;
+
+	typedef Iterator<T*> Iterator;
+	typedef ConstIterator<T*> ConstIterator; 
+
+	virtual Iterator getIterator() = 0;
+	virtual ConstIterator getIterator() const = 0;
+
+private:
+};
+*/
+
+
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__ITERABLE_HPP_20060516_115652
Index: /sandbox/trunk/pdp/src/xerial/util/Integer.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/Integer.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/Integer.cpp (revision 939)
@@ -0,0 +1,47 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Integer.cpp
+// Since  2004/10/07 16:19:59
+// 
+// $Date: 2005-12-13 23:09:39 +0900 (轣ｫ, 13 12 2005) $
+// $Author: leo $
+//--------------------------------------------------
+
+#include <sstream>
+#include <boost/lexical_cast.hpp>
+#include "xerial/util/Integer.hpp"
+#include "xerial/exception/ExceptionUtil.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+
+std::string
+Integer::toString(int val) 
+{
+	std::ostringstream os;
+	os << val;
+	return os.str();
+}
+
+
+std::string
+Integer::toString(unsigned int val) 
+{
+	std::ostringstream os;
+	os << val;
+	return os.str();
+}
+
+int
+Integer::parseInt(const std::string& val) 
+{
+	try
+	{
+		int num = boost::lexical_cast<int>(val);
+		return num;
+	}
+	catch(const boost::bad_lexical_cast& e)
+	{
+		XERIAL_THROW(InvalidNumberFormatException, e.what());
+	}
+}
Index: /sandbox/trunk/pdp/src/xerial/util/Format.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/util/Format.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/util/Format.hpp (revision 939)
@@ -0,0 +1,25 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// Format.hpp
+// Since  2006/10/06 12:17:27
+// 
+// $Date$ 
+// $Author$ 
+//--------------------------------------------------
+#ifndef __FORMAT_HPP
+#define __FORMAT_HPP
+#include "xerial/common/xerial.hpp"
+#ifdef WIN32
+// disable warnings that report size_t or _w64 int conversions
+#pragma warning(disable : 4244 4267)
+#endif // WIN32
+#include <boost/format.hpp>
+
+XERIAL_NAMESPACE_BEGIN
+
+typedef boost::format format;
+
+XERIAL_NAMESPACE_END
+
+#endif //__FORMAT_HPP
Index: /sandbox/trunk/pdp/src/xerial/exception/Exception.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/Exception.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/Exception.cpp (revision 939)
@@ -0,0 +1,111 @@
+//------------------------------------------------
+// Xerial -- Transactional XML Database System
+//
+// Exception.cpp
+// Since  2004/09/28 15:08:15
+//
+// $Date: 2006-08-26 07:09:42 +0900 (蝨� 26 8 2006) $
+// $Author: leo $
+//------------------------------------------------
+
+#include "xerial/exception/Exception.hpp"
+#include <algorithm>
+#include <sstream>
+#include <ostream>
+#include "xerial/common/xerial_last.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+const std::string Exception::_exceptionName = "Exception";
+
+Exception::Exception(const std::string &message)
+: exception(message.c_str()), _srcFileName("unknown source"), _srcLineNumber(-1)
+{}
+
+Exception::Exception(const std::string &srcFileName, 
+					 int srcLineNumber,	
+					 const std::string &message)
+					 : exception(message.c_str()), _srcFileName(srcFileName), _srcLineNumber(srcLineNumber)
+{}
+
+Exception::Exception(const exception &e)
+: exception(e)
+{}
+
+Exception::Exception(const Exception &e)
+: exception(e), _srcFileName(e._srcFileName), _srcLineNumber(e._srcLineNumber)
+{}
+
+Exception::~Exception()
+{}	
+
+Exception &
+Exception::operator=(const Exception& e)
+{
+	Exception tmp(e);
+	swap(tmp);
+	return *this;
+}
+
+void 
+Exception::swap(Exception &e) throw()
+{
+	std::swap(_srcFileName, e._srcFileName);
+	std::swap(_srcLineNumber, e._srcLineNumber);
+}
+
+std::string 
+Exception::getExceptionName() const
+{
+	return _exceptionName;
+}
+
+
+const char* 
+Exception::what() const
+{
+	return exception::what();
+}
+
+std::string
+Exception::detail() const
+{
+	// print source file name & line number where the exception is throw
+	ostringstream message;
+	message << "<exception src=\"" << _srcFileName << "\" "
+		<< "line=\"" << _srcLineNumber << "\">"
+		<< what()  << "</exception>\n";
+	return message.str();
+}
+
+
+
+
+int 
+Exception::getSrcLineNumber() const
+{
+   return _srcLineNumber;
+}
+
+
+std::string 
+Exception::getSourceFileName() const
+{
+	return _srcFileName;
+}
+
+std::ostream&
+Exception::operator<<(std::ostream& out) const
+{
+	out << what() << std::endl;
+	return out;
+}
+
+std::ostream&
+operator<<(std::ostream& out, const Exception& e) 
+{
+	out << e.what() << std::endl;
+	return out;
+}
+
+XERIAL_NAMESPACE_END
Index: /sandbox/trunk/pdp/src/xerial/exception/UnsupportedOperation.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/UnsupportedOperation.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/UnsupportedOperation.hpp (revision 939)
@@ -0,0 +1,22 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// UnsupportedOperation.hpp
+// Since  2005/10/13 11:17:21
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/exception/UnsupportedOperation.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __UNSUPPORTEDOPERATION_HPP_20051013_111721
+#define __UNSUPPORTEDOPERATION_HPP_20051013_111721
+#include "xerial/common/xerial.hpp"
+#include "xerial/exception/ExceptionUtil.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+MAKE_XERIAL_EXCEPTION_DECLARATION(UnsupportedOperation)
+XERIAL_NAMESPACE_END
+
+
+#endif //__UNSUPPORTEDOPERATION_HPP_20051013_111721
Index: /sandbox/trunk/pdp/src/xerial/exception/AssertionFailure.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/AssertionFailure.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/AssertionFailure.cpp (revision 939)
@@ -0,0 +1,18 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// AssertionFailure.cpp
+// Since  2005/09/10 16:31:10
+// 
+// $Date: 2005-10-12 13:03:09 +0900 (豌ｴ, 12 10 2005) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/exception/AssertionFailure.cpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#include "xerial/exception/AssertionFailure.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+
+MAKE_XERIAL_EXCEPTION_DEFINITION(AssertionFailure)
+
+
+
Index: /sandbox/trunk/pdp/src/xerial/exception/ExceptionUtil.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/ExceptionUtil.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/ExceptionUtil.hpp (revision 939)
@@ -0,0 +1,86 @@
+//------------------------------------------------
+// Xerial -- Transactional XML Database System
+//
+// ExceptionUtil.hpp
+// Since  2004/09/28 16:29:15
+//
+// $Date: 2006-10-06 16:23:13 +0900 (驥� 06 10 2006) $
+// $Author: leo $
+//------------------------------------------------
+
+#pragma once
+#ifndef __EXCEPTIONUTIL_HPP
+#define __EXCEPTIONUTIL_HPP
+
+#include "xerial/common/xerial.hpp"
+#include "xerial/exception/Exception.hpp"
+#include "xerial/log/Logger.hpp"
+
+#include <cassert>
+#include <iosfwd>
+#include <string>
+#include <sstream>
+
+//--------------------------------------------------
+// a macro for creating new subclasses of Exception class
+//--------------------------------------------------
+#define MAKE_XERIAL_EXCEPTION_DECLARATION(theType) \
+class XERIAL_API theType : public Exception \
+{\
+public:\
+	theType(const std::string &message);\
+	theType(const std::string &srcFileName, int lineNumber, const std::string &message = "");\
+	theType(const exception &e);\
+	theType(const Exception &e);\
+	virtual ~theType();\
+};\
+
+#define MAKE_DERIVED_XERIAL_EXCEPTION_DECLARATION(theType, baseType) \
+class XERIAL_API theType : public baseType \
+{\
+public:\
+	theType(const std::string &message);\
+	theType(const std::string &srcFileName, int lineNumber, const std::string &message = "");\
+	theType(const exception &e);\
+	theType(const Exception &e);\
+	virtual ~theType();\
+};\
+
+#define MAKE_XERIAL_EXCEPTION_DEFINITION(theType) \
+theType::theType(const std::string &message) : xerial::Exception(message) {}\
+theType::theType(const std::string &srcFileName, int lineNumber, const std::string &message)\
+: xerial::Exception(srcFileName, lineNumber, message) {}\
+theType::theType(const exception &e) : xerial::Exception(e) {}\
+theType::theType(const xerial::Exception &e) : xerial::Exception(e) {}\
+theType::~theType() {}\
+
+#define MAKE_DERIVED_XERIAL_EXCEPTION_DEFINITION(theType, baseType) \
+theType::theType(const std::string &message) : xerial::baseType(message) {}\
+theType::theType(const std::string &srcFileName, int lineNumber, const std::string &message)\
+: xerial::baseType(srcFileName, lineNumber, message) {}\
+theType::theType(const exception &e) : xerial::baseType(e) {}\
+theType::theType(const xerial::Exception &e) : xerial::baseType(e) {}\
+theType::~theType() {}\
+
+
+//-----------------------------------------------
+// useful macros for reporting the occurring point of an exception
+//-----------------------------------------------
+#define XERIAL_THROW_FOR_EXIT(type) \
+{{ \
+	using namespace xerial; \
+	throw type(__FILE__, __LINE__); \
+}}
+
+#define XERIAL_THROW(type, m1) \
+{{ \
+	using namespace xerial; \
+	Message message; \
+	message << m1; \
+	XERIAL_EXCEPTION_LOG(__FILE__ << "(" << __LINE__ << ") " << " An exception occured: " << message.toString()); \
+	throw type(__FILE__, __LINE__, message.toString()); \
+}}
+
+
+
+#endif // __EXCEPTIONUTIL_HPP
Index: /sandbox/trunk/pdp/src/xerial/exception/Exception.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/Exception.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/Exception.hpp (revision 939)
@@ -0,0 +1,77 @@
+//------------------------------------------------
+// Xerial -- Transactional XML Database System
+//
+// Exception.hpp
+// Since  2004/09/28 15:07:03
+//
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $
+// $Author: leo $
+//------------------------------------------------
+
+#pragma once
+#ifndef __EXCEPTION_HPP
+#define __EXCEPTION_HPP
+
+#include "xerial/common/xerial.hpp"
+#include <exception>
+#include <string>
+#include <iosfwd>
+#include <sstream>
+#include "xerial/util/Message.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+/**
+ * It is a base class of an exception object in Xerial 
+ */
+class XERIAL_API Exception : public std::exception
+{
+public:
+	Exception(const std::string &message);
+	Exception(const std::string &srcFileName, 
+			  int srcLineNumber,		
+			  const std::string &message = "");
+	Exception(const exception &e);
+	/**
+	 * copy constructor
+	 * @param e	
+	 */
+	Exception(const Exception &e);
+	 
+	Exception& operator=(const Exception& e);
+	
+	std::ostream& operator<<(std::ostream& out) const;
+	friend std::ostream& operator<<(std::ostream& out, const Exception& e);
+	
+	virtual ~Exception();
+	virtual const char* what() const;
+
+	/**
+	 * @return detail messages including the source file name and 
+	 *		   line number where this exception was thrown
+	 */
+	std::string detail() const;	
+	/**
+	 * @return an exception ID
+	 */
+	virtual std::string getExceptionName() const;
+
+	std::string getSourceFileName() const;
+	int getSrcLineNumber() const;
+protected:
+	void swap(Exception &e) throw();
+
+private:
+	Exception();
+
+	std::string _srcFileName;
+	int _srcLineNumber;
+
+private:
+	static const std::string _exceptionName;
+};
+
+
+XERIAL_NAMESPACE_END
+
+#endif // __EXCEPTION_HPP
Index: /sandbox/trunk/pdp/src/xerial/exception/AssertionFailure.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/AssertionFailure.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/AssertionFailure.hpp (revision 939)
@@ -0,0 +1,22 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// AssertionFailure.hpp
+// Since  2005/09/10 16:24:35
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/exception/AssertionFailure.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __ASSERTIONFAILURE_HPP_20050910_162435
+#define __ASSERTIONFAILURE_HPP_20050910_162435
+#include "xerial/common/xerial.hpp"
+#include "xerial/exception/ExceptionUtil.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+MAKE_XERIAL_EXCEPTION_DECLARATION(AssertionFailure)
+XERIAL_NAMESPACE_END
+
+
+#endif //__ASSERTIONFAILURE_HPP_20050910_162435
Index: /sandbox/trunk/pdp/src/xerial/exception/InvalidParameterException.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/InvalidParameterException.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/InvalidParameterException.cpp (revision 939)
@@ -0,0 +1,13 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// InvalidParameterException.cpp
+// Since  2004/10/13 16:41:48
+// 
+// $Date: 2004-10-13 22:08:03 +0900 (豌ｴ, 13 10 2004) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#include "xerial/exception/InvalidParameterException.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+MAKE_XERIAL_EXCEPTION_DEFINITION(InvalidParameterException)
Index: /sandbox/trunk/pdp/src/xerial/exception/assert.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/assert.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/assert.hpp (revision 939)
@@ -0,0 +1,45 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// assert.hpp
+// Since  2005/09/10 16:33:05
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/exception/assert.hpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __ASSERT_HPP_20050910_163305
+#define __ASSERT_HPP_20050910_163305
+
+#include "xerial/exception/AssertionFailure.hpp"
+#include "xerial/log/Logger.hpp"
+
+// enable assertion only in debug mode compile (i.e. _DEBUG is set)
+#ifdef _DEBUG
+#define XERIAL_ASSERT1(condition, message) \
+{{ \
+	if(!(condition)) \
+	{ \
+	XERIAL_ASSERT_LOG(__FILE__ << "(" << __LINE__ << ") " << #condition << " failed: " << message); \
+	XERIAL_THROW(AssertionFailure, message); \
+	} \
+}} 
+
+#define XERIAL_ASSERT(condition) \
+{{ \
+	if(!(condition)) \
+	{ \
+	   XERIAL_ASSERT_LOG(__FILE__ << "(" << __LINE__ << ") " << #condition << " failed"); \
+	   XERIAL_THROW(AssertionFailure, "assertion failed"); \
+	} \
+}} 
+#else
+#define XERIAL_ASSERT1(condition, message)
+#define XERIAL_ASSERT(condition)
+#endif // _DEBUG
+
+#define XERIAL_FAIL(message) XERIAL_THROW(AssertionFailure, message)
+
+
+#endif //__ASSERT_HPP_20050910_163305
Index: /sandbox/trunk/pdp/src/xerial/exception/InvalidNumberFormatException.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/InvalidNumberFormatException.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/InvalidNumberFormatException.cpp (revision 939)
@@ -0,0 +1,56 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// InvalidNumberFormatException.cpp
+// Since  2004/10/13 14:31:24
+// 
+// $Date: 2004-10-13 14:58:52 +0900 (豌ｴ, 13 10 2004) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+
+#include "xerial/exception/InvalidNumberFormatException.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+
+InvalidNumberFormatException::~InvalidNumberFormatException()
+{}
+
+InvalidNumberFormatException::InvalidNumberFormatException(const std::string& message) 
+: Exception(message)
+{
+
+}
+
+InvalidNumberFormatException::InvalidNumberFormatException(const std::string& srcFileName, int srcLineNumber, const std::string& message) 
+: Exception(srcFileName, srcLineNumber, message)
+{
+	
+}
+
+
+
+InvalidNumberFormatException::InvalidNumberFormatException(const exception& e) 
+: Exception(e)
+{
+	
+}
+
+InvalidNumberFormatException::InvalidNumberFormatException(const Exception& e) 
+: Exception(e)
+{
+	
+}
+
+InvalidNumberFormatException&
+InvalidNumberFormatException::operator=(const Exception& e) 
+{
+	InvalidNumberFormatException tmp(e);
+	swap(tmp);
+	return *this;	
+}
+
+std::string
+InvalidNumberFormatException::getExceptionName() const
+{
+	return "InvalidNumberFormatException";
+}
Index: /sandbox/trunk/pdp/src/xerial/exception/OutOfRangeException.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/OutOfRangeException.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/OutOfRangeException.cpp (revision 939)
@@ -0,0 +1,13 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// OutOfRangeException.cpp
+// Since  2004/10/26 12:03:57
+// 
+// $Date: 2004-10-26 15:50:32 +0900 (轣ｫ, 26 10 2004) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#include "xerial/exception/OutOfRangeException.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+MAKE_XERIAL_EXCEPTION_DEFINITION(OutOfRangeException);
Index: /sandbox/trunk/pdp/src/xerial/exception/UnsupportedOperation.cpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/UnsupportedOperation.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/UnsupportedOperation.cpp (revision 939)
@@ -0,0 +1,17 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// UnsupportedOperation.cpp
+// Since  2005/10/13 11:17:55
+// 
+// $Date: 2005-10-13 14:57:16 +0900 (譛ｨ, 13 10 2005) $ 
+// $URL: http://www.xerial.org/svn/project/Xerial/trunk/src/xerial/exception/UnsupportedOperation.cpp $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#include "xerial/exception/UnsupportedOperation.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+MAKE_XERIAL_EXCEPTION_DEFINITION(UnsupportedOperation)
+
+
+
Index: /sandbox/trunk/pdp/src/xerial/exception/InvalidParameterException.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/InvalidParameterException.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/InvalidParameterException.hpp (revision 939)
@@ -0,0 +1,21 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// InvalidParameterException.hpp
+// Since  2004/10/13 16:41:05
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __INVALIDPARAMETEREXCEPTION_HPP
+#define __INVALIDPARAMETEREXCEPTION_HPP
+#include "xerial/common/xerial.hpp"
+
+#include "xerial/exception/ExceptionUtil.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+MAKE_XERIAL_EXCEPTION_DECLARATION(InvalidParameterException)
+XERIAL_NAMESPACE_END
+
+#endif //__INVALIDPARAMETEREXCEPTION_HPP
Index: /sandbox/trunk/pdp/src/xerial/exception/InvalidNumberFormatException.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/InvalidNumberFormatException.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/InvalidNumberFormatException.hpp (revision 939)
@@ -0,0 +1,43 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// InvalidNumberFormatException.hpp
+// Since  2004/10/13 14:28:43
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __INVALIDNUMERFORMATEXCEPTION_HPP
+#define __INVALIDNUMERFORMATEXCEPTION_HPP
+
+#include "xerial/common/xerial.hpp"
+#include "xerial/exception/Exception.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+
+class XERIAL_API InvalidNumberFormatException : public Exception
+{
+public:
+	InvalidNumberFormatException(const std::string &message);
+	InvalidNumberFormatException(const std::string &srcFileName, int srcLineNumber,	const std::string &message = "");
+	InvalidNumberFormatException(const exception &e);
+	/**
+	* copy constructor
+	* @param e	
+	*/
+	InvalidNumberFormatException(const Exception &e);
+	InvalidNumberFormatException& operator=(const Exception& e);
+
+	virtual ~InvalidNumberFormatException();
+	/**
+	* @return an exception ID
+	*/
+	virtual std::string getExceptionName() const;
+};
+
+
+XERIAL_NAMESPACE_END
+
+
+#endif //__INVALIDNUMERFORMATEXCEPTION_HPP
Index: /sandbox/trunk/pdp/src/xerial/exception/OutOfRangeException.hpp
===================================================================
--- /sandbox/trunk/pdp/src/xerial/exception/OutOfRangeException.hpp (revision 939)
+++ /sandbox/trunk/pdp/src/xerial/exception/OutOfRangeException.hpp (revision 939)
@@ -0,0 +1,20 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// OutOfRangeException.hpp
+// Since  2004/10/26 12:03:06
+// 
+// $Date: 2006-10-04 12:29:44 +0900 (豌ｴ, 04 10 2006) $ 
+// $Author: leo $ 
+//--------------------------------------------------
+#pragma once
+#ifndef __OUTOFRANGEEXCEPTION_HPP
+#define __OUTOFRANGEEXCEPTION_HPP
+#include "xerial/common/xerial.hpp"
+#include "xerial/exception/ExceptionUtil.hpp"
+
+XERIAL_NAMESPACE_BEGIN
+MAKE_XERIAL_EXCEPTION_DECLARATION(OutOfRangeException);
+XERIAL_NAMESPACE_END
+
+#endif //__OUTOFRANGEEXCEPTION_HPP
Index: /sandbox/trunk/pdp/src/N-body.cpp
===================================================================
--- /sandbox/trunk/pdp/src/N-body.cpp (revision 936)
+++ /sandbox/trunk/pdp/src/N-body.cpp (revision 939)
@@ -21,5 +21,136 @@
 // $Author$ 
 //--------------------------------------------------
+#include <mpi.h>
+#include <iostream>
 #include "N-body.hpp"
+#include "MPIInitializer.hpp"
+#include <boost/random.hpp>
+#include "xerial/util/cui/OptionParser.hpp"
+#include "xerial/log/Logger.hpp"
+#include "xerial/util/Message.hpp"
+#include "xerial/util/Format.hpp"
+#include "xerial/util/StringUtil.hpp"
+#include "xerial/util/Integer.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+XERIAL_LOGGER(_logger, NBodySimulator)
+
+std::string
+Particle::toString() const
+{
+	return XERIAL_MESSAGE(Triplet<double>::toString() << format(" m=%1%, v=%2%, a=%3%") % _mass % _velocity.toString() % _acceleration.toString());
+}
+
+NBodySimulator::NBodySimulator(Vector<Particle>& particle, double gravity) 
+: _particle(particle), _gravity(gravity), _time(0)
+{
+	
+}
+
+NBodySimulator::~NBodySimulator()
+{
+
+}
+
+void
+NBodySimulator::naiveUpdate(double dt) 
+{
+	for(Vector<Particle>::iterator i = _particle.begin(); i != _particle.end(); ++i)
+	{
+		// update the acceleration of each particle by computing mutual gravitational force between it and the other particles
+		i->updateAcceleration(_particle.begin(), _particle.end(), _gravity);
+		i->move(dt); 		// update the location 
+	}
+	_time += dt;
+}
+
+void
+NBodySimulator::naiveSimulation(double dt, size_t times) 
+{
+	for(size_t step=0; step<times; ++step)
+	{
+		XERIAL_DEBUG(_logger, "step " << step);
+		naiveUpdate(dt);
+		XERIAL_DEBUG(_logger, "\n" << StringUtil::join(_particle, "\n"));
+	}
+}
+
+void
+NBodySimulator::parallelSimulation(double dt, size_t times) 
+{
+	int numParticle = _particle.size();
+	MPI::COMM_WORLD.BCast(&numParticle, )
+
+	for(size_t step=0; step<times; ++step)
+	{
+		XERIAL_DEBUG(_logger, "step " << step);
+		naiveUpdate(dt);
+		XERIAL_DEBUG(_logger, "\n" << StringUtil::join(_particle, "\n"));
+	}
+}
 
 
+int main(int argc, char** argv)
+{
+	MPIInitializer m(argc, argv);
+	int processID = MPI::COMM_WORLD.Get_rank();
+
+	XERIAL_INFO(_logger, "process id = " << processID);
+	enum
+	{
+		OPT_HELP,
+		OPT_VERBOSE,
+		OPT_DISTRIBUTE,
+		OPT_STEP,
+		OPT_NUM_PARTICLE
+	};
+    OptionParser opt;
+	opt.add(Option(OPT_HELP, "h", "help", "display help messages"));
+	opt.add(Option(OPT_VERBOSE, "v", "verbose", "display verbose log messages"));
+	opt.add(Option(OPT_DISTRIBUTE, "d", "distribute", "distribute mode"));
+	opt.add(OptionWithArgument(OPT_STEP, "s", "step", "STEP", "num calculation steps (default = 100)"));
+	opt.add(OptionWithArgument(OPT_PARTICLE, "p", "particle", "NUM", "num particles (default = 10)"));
+
+	try
+	{
+		opt.getContext(argc, argv);
+		if(opt.isSet(OPT_HELP))
+		{
+			cerr << opt.createHelpMessage() << endl; 
+			return RETURN_WITH_SUCCESS;
+		}
+
+		// prepare random particles
+		boost::mt19937 mt;
+		boost::uniform_real<double> randomNumberRange(0, 10000);
+		boost::variate_generator<boost::mt19937, boost::uniform_real<double> > die(mt, randomNumberRange);
+		Vector<Particle> randomParticle;
+		int numParticle = Integer::parseInt(opt.getValue(OPT_NUM_PARTICLE, "10"));
+		for(int i=0; i<numParticle; i++)
+		{
+			Particle p(die(), die(), die(), die());
+			p.setVelocity(Velocity(die(), die(), die()));
+			XERIAL_DEBUG(_logger, p);
+			randomParticle.add(p);
+		}
+		NBodySimulator simulator(randomParticle);
+		
+		int step = Integer::parseInt(opt.getValue(OPT_STEP, "100"));
+		if(opt.isSet(OPT_DISTRIBUTE))
+			simulator.parallelSimulation(1, step);
+		else
+			simulator.naiveSimulation(1, step);
+
+	}
+	catch(InvalidParameterException& e)
+	{
+		cerr << e.what();
+		cerr << opt.createHelpMessage() << endl;
+	}
+	catch(exception& e)
+	{
+		cerr << e.what();
+	}
+
+}
+
Index: /sandbox/trunk/pdp/src/Triplet.hpp
===================================================================
--- /sandbox/trunk/pdp/src/Triplet.hpp (revision 936)
+++ /sandbox/trunk/pdp/src/Triplet.hpp (revision 939)
@@ -25,9 +25,12 @@
 #define __TRIPLET_HPP20061016161105
 
+#include "xerial/util/Printable.hpp"
+#include "xerial/util/Message.hpp"
+#include "xerial/util/Format.hpp"
 /*
  * Triplet class represents a 3-dimensional vector
  */ 
 template <class T>
-struct Triplet
+struct Triplet : public xerial::Printable
 {
 	T x;
@@ -59,4 +62,10 @@
 		return Triplet(x / val, y / val, z / val);
 	}
+
+	std::string toString() const
+	{
+		using namespace xerial;
+		return XERIAL_MESSAGE(format("(%1%, %2%, %3%)") % x % y % z);
+	}
 };
 
Index: /sandbox/trunk/pdp/src/MPIInitializer.cpp
===================================================================
--- /sandbox/trunk/pdp/src/MPIInitializer.cpp (revision 939)
+++ /sandbox/trunk/pdp/src/MPIInitializer.cpp (revision 939)
@@ -0,0 +1,27 @@
+//--------------------------------------------------
+// Xerial -- Transactional XML Database System      
+// 
+// MPIInitializer.cpp
+// Since  2006/10/17 10:49:33
+// 
+// $Date$ 
+// $Author$ 
+//--------------------------------------------------
+#include "MPIInitializer.hpp"
+#include <mpi.h>
+#include "xerial/log/Logger.hpp"
+#include "xerial/common/xerial_last.hpp"
+
+XERIAL_LOGGER(_logger, MPIInitializer)
+
+MPIInitializer::MPIInitializer(int argc, char** argv) 
+{
+	MPI::Init(argc, argv);
+	XERIAL_INFO(_logger, "MPI is initialized");
+}
+
+MPIInitializer::~MPIInitializer()
+{
+	MPI::Finalize();
+	XERIAL_INFO(_logger, "MPI is finalized");
+}
Index: /sandbox/trunk/pdp/src/N-body.hpp
===================================================================
--- /sandbox/trunk/pdp/src/N-body.hpp (revision 936)
+++ /sandbox/trunk/pdp/src/N-body.hpp (revision 939)
@@ -28,7 +28,10 @@
 #include <vector>
 #include "Triplet.hpp"
+#include <boost/utility/addressof.hpp>
+#include "xerial/util/Printable.hpp"
+#include "xerial/util/Vector.hpp"
 
 /*
- * The class Universe defines global constant values;
+ * The class Universe defines global constant values.
  */ 
 class Universe
@@ -41,4 +44,5 @@
 struct Force : public Triplet<double>
 {
+	Force() : Triplet<double>(0, 0, 0) {}
 	Force(double fx, double fy, double fz)	: Triplet<double>(fx, fy, fz) {}
 
@@ -55,5 +59,4 @@
 typedef Triplet<double> Velocity;
 typedef Triplet<double> Acceleration;
-
 
 /**
@@ -79,5 +82,5 @@
 		// double r = std::sqrt(distSquare);
 		// double F = (Universe::gravity() * _mass * other._mass) / (r * r);
-		// return Force(F * (dx / r), F * (dy / r), F * (dz / r));	
+		// return Force(F * (dx / r), F * (dy / r), F * (dz / r));	//  dx / r = cosign of the angle between F and x axis
 	}
 
@@ -88,9 +91,9 @@
 		for(ParticleIter i = begin; i != end; ++i)
 		{
-			if(this != i)
+			if(this != boost::addressof(*i))
 				force.push_back(gravitationalForce(*i, G));
 		}
 		Force currentForce = Force::superposition(force.begin(), force.end());
-		_acceleration = currentForce / _mass;	// F = ma
+		_acceleration = currentForce / _mass;	// F = ma i.e. a = F / m
 	}
 
@@ -108,4 +111,11 @@
 	const Acceleration& getAcceleration() const { return _acceleration; }
 	void setAcceleration(const Acceleration& a) { _acceleration = a; }
+
+	std::string toString() const;
+
+	bool operator==(const Particle& other) const
+	{
+		return this == boost::addressof(other);
+	}
 private:
 	double _mass;
@@ -114,4 +124,22 @@
 };
 
+class NBodySimulator
+{
+public:
+	NBodySimulator(xerial::Vector<Particle>& particle, double gravity = Universe::gravity());
+	virtual ~NBodySimulator();
+
+	void naiveSimulation(double dt, size_t times);
+	void parallelSimulation(double dt, size_t times);
+
+protected:
+	void naiveUpdate(double dt);
+
+private:
+	xerial::Vector<Particle>& _particle;
+	double _time;
+	double _gravity;
+};
+
 
 #endif //__NBODY_HPP20061016161026
Index: /sandbox/trunk/pdp/README
===================================================================
--- /sandbox/trunk/pdp/README (revision 936)
+++ /sandbox/trunk/pdp/README (revision 939)
@@ -0,0 +1,7 @@
+
+
+* required libraries
+- Boost C++ Library (http://www.boost.org)
+- MPICH library 
+
+
