aboutsummaryrefslogtreecommitdiff
path: root/libcommon/common
diff options
context:
space:
mode:
Diffstat (limited to 'libcommon/common')
-rw-r--r--libcommon/common/Makefile.am12
-rw-r--r--libcommon/common/common.cxx49
-rw-r--r--libcommon/common/common.hxx18
-rw-r--r--libcommon/common/config.h.in15
-rw-r--r--libcommon/common/export.hxx39
-rw-r--r--libcommon/common/libcommon-vc10.vcxproj174
-rw-r--r--libcommon/common/libcommon-vc10.vcxproj.filters19
-rw-r--r--libcommon/common/libcommon-vc9.vcproj359
-rw-r--r--libcommon/common/makefile124
-rw-r--r--libcommon/common/options.cli58
-rw-r--r--libcommon/common/options.cxx796
-rw-r--r--libcommon/common/options.hxx396
-rw-r--r--libcommon/common/options.ixx256
13 files changed, 2315 insertions, 0 deletions
diff --git a/libcommon/common/Makefile.am b/libcommon/common/Makefile.am
new file mode 100644
index 0000000..6712eaa
--- /dev/null
+++ b/libcommon/common/Makefile.am
@@ -0,0 +1,12 @@
+# file : libcommon/common/Makefile.am
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+noinst_LTLIBRARIES = libcommon.la
+libcommon_la_SOURCES = __path__(sources) __path__(headers)
+
+EXTRA_DIST = __file__(extra_dist)
+
+libcommon_la_CPPFLAGS= -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon' -DLIBCOMMON_DYNAMIC_LIB
+libcommon_la_LDFLAGS = -no-undefined -rpath '$(libdir)'
diff --git a/libcommon/common/common.cxx b/libcommon/common/common.cxx
new file mode 100644
index 0000000..d68d579
--- /dev/null
+++ b/libcommon/common/common.cxx
@@ -0,0 +1,49 @@
+// file : libcommon/common/common.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#include <cstdlib> // std::exit
+#include <iostream>
+
+#ifndef _MSC_VER
+# include <common/config.h>
+#endif
+
+#ifdef DB_ID_MYSQL
+# include <odb/mysql/database.hxx>
+#endif
+
+#include <common/common.hxx>
+#include <common/options.hxx>
+
+using namespace std;
+using namespace odb;
+
+auto_ptr<database>
+create_database (int argc, char* argv[])
+{
+#ifdef DB_ID_MYSQL
+ cli::argv_file_scanner scan (argc, argv, "--options-file");
+ cli::mysql_options ops (scan);
+
+ if (ops.help ())
+ {
+ cerr << "Usage: " << argv[0] << " [options]" << endl
+ << "Options:" << endl;
+ cli::mysql_options::print_usage (cerr);
+ exit (0);
+ }
+
+ return auto_ptr<database> (
+ new mysql::database (
+ ops.user (),
+ ops.passwd_specified () ? &ops.passwd () : 0,
+ ops.db_name (),
+ ops.host (),
+ ops.port (),
+ ops.socket_specified () ? &ops.socket () : 0));
+#else
+ return auto_ptr<database> (0);
+#endif
+}
diff --git a/libcommon/common/common.hxx b/libcommon/common/common.hxx
new file mode 100644
index 0000000..87b08f0
--- /dev/null
+++ b/libcommon/common/common.hxx
@@ -0,0 +1,18 @@
+// file : libcommon/common/common.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef LIBCOMMON_COMMON_COMMON_HXX
+#define LIBCOMMON_COMMON_COMMON_HXX
+
+#include <memory> // std::auto_ptr
+
+#include <odb/database.hxx>
+
+#include <common/export.hxx>
+
+LIBCOMMON_EXPORT std::auto_ptr<odb::database>
+create_database (int argc, char* argv[]);
+
+#endif // LIBCOMMON_COMMON_COMMON_HXX
diff --git a/libcommon/common/config.h.in b/libcommon/common/config.h.in
new file mode 100644
index 0000000..06318c4
--- /dev/null
+++ b/libcommon/common/config.h.in
@@ -0,0 +1,15 @@
+/* file : libcommon/common/config.h.in
+ * author : Boris Kolpackov <boris@codesynthesis.com>
+ * copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+ * license : GNU GPL v2; see accompanying LICENSE file
+ */
+
+/* This file is automatically processed by configure. */
+
+#ifndef LIBCOMMON_COMMON_CONFIG_H
+#define LIBCOMMON_COMMON_CONFIG_H
+
+#undef DB_ID_MYSQL
+#undef LIBCOMMON_STATIC_LIB
+
+#endif /* LIBCOMMON_COMMON_CONFIG_H */
diff --git a/libcommon/common/export.hxx b/libcommon/common/export.hxx
new file mode 100644
index 0000000..4ea2d33
--- /dev/null
+++ b/libcommon/common/export.hxx
@@ -0,0 +1,39 @@
+// file : libcommon/common/export.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef LIBCOMMON_COMMON_EXPORT_HXX
+#define LIBCOMMON_COMMON_EXPORT_HXX
+
+#ifndef _MSC_VER
+# include <common/config.h>
+#endif
+
+#ifdef LIBCOMMON_STATIC_LIB
+# define LIBCOMMON_EXPORT
+#else
+# ifdef _WIN32
+# ifdef _MSC_VER
+# ifdef LIBCOMMON_DYNAMIC_LIB
+# define LIBCOMMON_EXPORT __declspec(dllexport)
+# else
+# define LIBCOMMON_EXPORT __declspec(dllimport)
+# endif
+# else
+# ifdef LIBCOMMON_DYNAMIC_LIB
+# ifdef DLL_EXPORT
+# define LIBCOMMON_EXPORT __declspec(dllexport)
+# else
+# define LIBCOMMON_EXPORT
+# endif
+# else
+# define LIBCOMMON_EXPORT __declspec(dllimport)
+# endif
+# endif
+# else
+# define LIBCOMMON_EXPORT
+# endif
+#endif
+
+#endif // LIBCOMMON_COMMON_EXPORT_HXX
diff --git a/libcommon/common/libcommon-vc10.vcxproj b/libcommon/common/libcommon-vc10.vcxproj
new file mode 100644
index 0000000..74d704b
--- /dev/null
+++ b/libcommon/common/libcommon-vc10.vcxproj
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{019C2E51-BF41-4490-AB96-4156741B8CC9}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>libcommon</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>..\bin\</OutDir>
+ <TargetName>common-d</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>..\bin64\</OutDir>
+ <TargetName>common-d</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <OutDir>..\bin\</OutDir>
+ <TargetName>common</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <OutDir>..\bin64\</OutDir>
+ <TargetName>common</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;__upcase__(db_id_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..</AdditionalIncludeDirectories>
+ <DisableSpecificWarnings>4355;4800;4290;4251;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <OutputFile>$(TargetPath)</OutputFile>
+ <ImportLibrary>..\lib\common-d.lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;__upcase__(db_id_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..</AdditionalIncludeDirectories>
+ <DisableSpecificWarnings>4355;4800;4290;4251;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>odb-__value__(database)-d.lib;odb-d.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <OutputFile>$(TargetPath)</OutputFile>
+ <ImportLibrary>..\lib64\common-d.lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;__upcase__(db_id_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..</AdditionalIncludeDirectories>
+ <DisableSpecificWarnings>4355;4800;4290;4251;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>odb-__value__(database).lib;odb.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <OutputFile>$(TargetPath)</OutputFile>
+ <ImportLibrary>..\lib\common.lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <ClCompile>
+ <WarningLevel>Level3</WarningLevel>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <Optimization>MaxSpeed</Optimization>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;__upcase__(db_id_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>..</AdditionalIncludeDirectories>
+ <DisableSpecificWarnings>4355;4800;4290;4251;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>odb-__value__(database).lib;odb.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem>Windows</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ <OutputFile>$(TargetPath)</OutputFile>
+ <ImportLibrary>..\lib64\common.lib</ImportLibrary>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+__header_entries__(headers)
+ </ItemGroup>
+ <ItemGroup>
+__source_entries__(sources)
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
diff --git a/libcommon/common/libcommon-vc10.vcxproj.filters b/libcommon/common/libcommon-vc10.vcxproj.filters
new file mode 100644
index 0000000..ecc3613
--- /dev/null
+++ b/libcommon/common/libcommon-vc10.vcxproj.filters
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup>
+ <Filter Include="Source Files">
+ <UniqueIdentifier>{6B7BDACA-0BDC-48B2-B5BD-BEFC5826ABC9}</UniqueIdentifier>
+ <Extensions>cxx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{F2B8743C-E39C-4FE0-AA8F-FF7FA2DA7191}</UniqueIdentifier>
+ <Extensions>h;hxx;ixx;txx</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+__header_filter_entries__(headers)
+ </ItemGroup>
+ <ItemGroup>
+__source_filter_entries__(sources)
+ </ItemGroup>
+</Project>
diff --git a/libcommon/common/libcommon-vc9.vcproj b/libcommon/common/libcommon-vc9.vcproj
new file mode 100644
index 0000000..412480b
--- /dev/null
+++ b/libcommon/common/libcommon-vc9.vcproj
@@ -0,0 +1,359 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="libcommon"
+ ProjectGUID="{8575F058-1BD6-4F97-8901-83D0110C2B6B}"
+ RootNamespace="libcommon"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory=".."
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4355 /wd4800 /wd4290"
+ Optimization="0"
+ AdditionalIncludeDirectories=".."
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;__upcase__(db_id_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ CommandLine="if not exist ..\lib mkdir ..\lib"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="odb-__value__(database)-d.lib;odb-d.lib"
+ OutputFile="$(OutDir)\bin\common-d.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)\lib\common-d.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ OutputDirectory=".."
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4355 /wd4800 /wd4290"
+ Optimization="0"
+ AdditionalIncludeDirectories=".."
+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL;__upcase__(db_id_)__upcase__(__value__(database));__upcase__(db_id_)__upcase__(__value__(database));__upcase__(db_id_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ CommandLine="if not exist ..\lib64 mkdir ..\lib64"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="odb-__value__(database)-d.lib;odb-d.lib"
+ OutputFile="$(OutDir)\bin64\common-d.dll"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ ImportLibrary="$(OutDir)\lib64\common-d.lib"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory=".."
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4355 /wd4800 /wd4290"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=".."
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;__upcase__(db_id_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ CommandLine="if not exist ..\lib mkdir ..\lib"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="odb-__value__(database).lib;odb.lib"
+ OutputFile="$(OutDir)\bin\common.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)\lib\common.lib"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|x64"
+ OutputDirectory=".."
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="2"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4355 /wd4800 /wd4290"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories=".."
+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL;__upcase__(db_id_)__upcase__(__value__(database));LIBCOMMON_DYNAMIC_LIB"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ CommandLine="if not exist ..\lib64 mkdir ..\lib64"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="odb-__value__(database)-d.lib;odb.lib"
+ OutputFile="$(OutDir)\bin64\common.dll"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ ImportLibrary="$(OutDir)\lib64\common.lib"
+ TargetMachine="17"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cxx"
+ UniqueIdentifier="{AC9C925E-DBC7-4706-85E4-BD38199359F7}"
+ >
+__source_entries__(sources)
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hxx;ixx;txx"
+ UniqueIdentifier="{D30085A2-1A37-43F8-9B2E-D82BD026A113}"
+ >
+__file_entries__(headers)
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/libcommon/common/makefile b/libcommon/common/makefile
new file mode 100644
index 0000000..2987959
--- /dev/null
+++ b/libcommon/common/makefile
@@ -0,0 +1,124 @@
+# file : libcommon/common/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
+
+# Options file.
+#
+cli_tun := options.cli
+cxx_tun := common.cxx
+
+cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(cli_tun:.cli=.o))
+cxx_od := $(cxx_obj:.o=.o.d)
+
+common.l := $(out_base)/common.l
+common.l.cpp-options := $(out_base)/common.l.cpp-options
+
+default := $(out_base)/
+dist := $(out_base)/.dist
+clean := $(out_base)/.clean
+
+# Import.
+#
+$(call import,\
+ $(scf_root)/import/cli/stub.make,\
+ cli: cli,cli-rules: cli_rules)
+
+$(call import,\
+ $(scf_root)/import/libodb/stub.make,\
+ l: odb.l,cpp-options: odb.l.cpp-options)
+
+ifdef db_id
+$(call import,\
+ $(scf_root)/import/libodb-$(db_id)/stub.make,\
+ l: odb_db.l,cpp-options: odb_db.l.cpp-options)
+endif
+
+ifeq ($(odb_db.l.cpp-options),)
+odb_db.l.cpp-options := $(out_base)/.unbuildable
+endif
+
+# Build.
+#
+$(common.l): $(cxx_obj) $(odb.l) $(odb_db.l)
+
+$(cxx_obj) $(cxx_od): $(common.l.cpp-options) $(out_base)/config.h
+$(common.l.cpp-options): value := -I$(out_root)/libcommon -I$(src_root)/libcommon
+$(common.l.cpp-options): $(odb_db.l.cpp-options) $(odb.l.cpp-options)
+
+genf := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx) $(cli_tun:.cli=.cxx)
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(cli)
+$(gen): cli := $(cli)
+$(gen): cli_options += \
+--generate-specifier \
+--generate-file-scanner \
+--guard-prefix LIBCOMMON_COMMON
+
+$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
+
+$(out_base)/config.h: $(dcf_root)/configuration-dynamic.make
+ @echo '// file : libcommon/config.h' >$@
+ @echo '// author : automatically generated' >>$@
+ @echo '' >>$@
+ @echo '#ifndef LIBCOMMON_COMMON_CONFIG_H' >>$@
+ @echo '#define LIBCOMMON_COMMON_CONFIG_H' >>$@
+ @echo '' >>$@
+ifeq ($(db_id),mysql)
+ @echo '#define DB_ID_MYSQL 1' >>$@
+endif
+ @echo '' >>$@
+ @echo '#endif // LIBCOMMON_COMMON_CONFIG_H' >>$@
+
+# Convenience alias for default target.
+#
+$(out_base)/: $(common.l)
+
+# Dist.
+#
+$(dist): export sources := $(cxx_tun) $(cli_tun:.cli=.cxx)
+$(dist): export headers = $(subst $(src_base)/,,$(shell find $(src_base) \
+-name '*.hxx' -o -name '*.ixx' -o -name '*.txx'))
+$(dist): data_dist := $(cli_tun)
+$(dist): export extra_dist := $(data_dist) $(call vc9projs,libcommon) \
+$(call vc10projs,libcommon)
+
+$(dist): $(gen)
+ $(call dist-data,$(sources) $(headers) $(data_dist) config.h.in)
+ $(call meta-automake)
+ $(call meta-vc9projs,libcommon)
+ $(call meta-vc10projs,libcommon)
+
+# Clean.
+#
+$(clean): $(common.l).o.clean \
+ $(common.l.cpp-options).clean \
+ $(addsuffix .cxx.clean,$(cxx_obj)) \
+ $(addsuffix .cxx.clean,$(cxx_od))
+ $(call message,rm $$1,rm -f $$1,$(out_base)/config.h)
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(common.l): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := config.h
+$(clean): $(out_base)/.gitignore.clean
+
+$(call include,$(bld_root)/git/gitignore.make)
+endif
+
+# How to.
+#
+$(call include,$(bld_root)/dist.make)
+$(call include,$(bld_root)/meta/vc9proj.make)
+$(call include,$(bld_root)/meta/vc10proj.make)
+$(call include,$(bld_root)/meta/automake.make)
+
+$(call include,$(cli_rules))
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/o-l.make)
diff --git a/libcommon/common/options.cli b/libcommon/common/options.cli
new file mode 100644
index 0000000..5b87d70
--- /dev/null
+++ b/libcommon/common/options.cli
@@ -0,0 +1,58 @@
+// file : libcommon/common/options.cli
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2010 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+include <string>;
+
+namespace cli
+{
+ class mysql_options
+ {
+ bool --help {"Print usage information and exit."};
+
+ std::string --user
+ {
+ "<name>",
+ "MySQL database user."
+ };
+
+ std::string --passwd
+ {
+ "<str>",
+ "MySQL database password"
+ };
+
+ std::string --db-name
+ {
+ "<name>",
+ "MySQL database name."
+ };
+
+ std::string --host
+ {
+ "<addr>",
+ "MySQL database host name or address (localhost by default)."
+ };
+
+ unsigned int --port = 0
+ {
+ "<integer>",
+ "MySQL database port number."
+ };
+
+ std::string --socket
+ {
+ "<name>",
+ "MySQL database socket name."
+ };
+
+ std::string --options-file
+ {
+ "<file>",
+ "Read additional options from <file>. Each option appearing on a separate
+ line optionally followed by space and an option value. Empty lines and
+ lines starting with \cb{#} are ignored."
+ };
+ };
+}
diff --git a/libcommon/common/options.cxx b/libcommon/common/options.cxx
new file mode 100644
index 0000000..9d15251
--- /dev/null
+++ b/libcommon/common/options.cxx
@@ -0,0 +1,796 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+#include "options.hxx"
+
+#include <map>
+#include <set>
+#include <string>
+#include <vector>
+#include <ostream>
+#include <sstream>
+#include <cstring>
+#include <fstream>
+
+namespace cli
+{
+ // unknown_option
+ //
+ unknown_option::
+ ~unknown_option () throw ()
+ {
+ }
+
+ void unknown_option::
+ print (std::ostream& os) const
+ {
+ os << "unknown option '" << option () << "'";
+ }
+
+ const char* unknown_option::
+ what () const throw ()
+ {
+ return "unknown option";
+ }
+
+ // unknown_argument
+ //
+ unknown_argument::
+ ~unknown_argument () throw ()
+ {
+ }
+
+ void unknown_argument::
+ print (std::ostream& os) const
+ {
+ os << "unknown argument '" << argument () << "'";
+ }
+
+ const char* unknown_argument::
+ what () const throw ()
+ {
+ return "unknown argument";
+ }
+
+ // missing_value
+ //
+ missing_value::
+ ~missing_value () throw ()
+ {
+ }
+
+ void missing_value::
+ print (std::ostream& os) const
+ {
+ os << "missing value for option '" << option () << "'";
+ }
+
+ const char* missing_value::
+ what () const throw ()
+ {
+ return "missing option value";
+ }
+
+ // invalid_value
+ //
+ invalid_value::
+ ~invalid_value () throw ()
+ {
+ }
+
+ void invalid_value::
+ print (std::ostream& os) const
+ {
+ os << "invalid value '" << value () << "' for option '"
+ << option () << "'";
+ }
+
+ const char* invalid_value::
+ what () const throw ()
+ {
+ return "invalid option value";
+ }
+
+ // eos_reached
+ //
+ void eos_reached::
+ print (std::ostream& os) const
+ {
+ os << what ();
+ }
+
+ const char* eos_reached::
+ what () const throw ()
+ {
+ return "end of argument stream reached";
+ }
+
+ // file_io_failure
+ //
+ file_io_failure::
+ ~file_io_failure () throw ()
+ {
+ }
+
+ void file_io_failure::
+ print (std::ostream& os) const
+ {
+ os << "unable to open file '" << file () << "' or read failure";
+ }
+
+ const char* file_io_failure::
+ what () const throw ()
+ {
+ return "unable to open file or read failure";
+ }
+
+ // unmatched_quote
+ //
+ unmatched_quote::
+ ~unmatched_quote () throw ()
+ {
+ }
+
+ void unmatched_quote::
+ print (std::ostream& os) const
+ {
+ os << "unmatched quote in argument '" << argument () << "'";
+ }
+
+ const char* unmatched_quote::
+ what () const throw ()
+ {
+ return "unmatched quote";
+ }
+
+ // scanner
+ //
+ scanner::
+ ~scanner ()
+ {
+ }
+
+ // argv_scanner
+ //
+ bool argv_scanner::
+ more ()
+ {
+ return i_ < argc_;
+ }
+
+ const char* argv_scanner::
+ peek ()
+ {
+ if (i_ < argc_)
+ return argv_[i_];
+ else
+ throw eos_reached ();
+ }
+
+ const char* argv_scanner::
+ next ()
+ {
+ if (i_ < argc_)
+ {
+ const char* r (argv_[i_]);
+
+ if (erase_)
+ {
+ for (int i (i_ + 1); i < argc_; ++i)
+ argv_[i - 1] = argv_[i];
+
+ --argc_;
+ argv_[argc_] = 0;
+ }
+ else
+ ++i_;
+
+ return r;
+ }
+ else
+ throw eos_reached ();
+ }
+
+ void argv_scanner::
+ skip ()
+ {
+ if (i_ < argc_)
+ ++i_;
+ else
+ throw eos_reached ();
+ }
+
+ // argv_file_scanner
+ //
+ bool argv_file_scanner::
+ more ()
+ {
+ if (!args_.empty ())
+ return true;
+
+ while (base::more ())
+ {
+ // See if the next argument is the file option.
+ //
+ const char* a (base::peek ());
+
+ if (!skip_ && a == option_)
+ {
+ base::next ();
+
+ if (!base::more ())
+ throw missing_value (option_);
+
+ load (base::next ());
+
+ if (!args_.empty ())
+ return true;
+ }
+ else
+ {
+ if (!skip_)
+ skip_ = (std::strcmp (a, "--") == 0);
+
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ const char* argv_file_scanner::
+ peek ()
+ {
+ if (!more ())
+ throw eos_reached ();
+
+ return args_.empty () ? base::peek () : args_.front ().c_str ();
+ }
+
+ const char* argv_file_scanner::
+ next ()
+ {
+ if (!more ())
+ throw eos_reached ();
+
+ if (args_.empty ())
+ return base::next ();
+ else
+ {
+ hold_.swap (args_.front ());
+ args_.pop_front ();
+ return hold_.c_str ();
+ }
+ }
+
+ void argv_file_scanner::
+ skip ()
+ {
+ if (!more ())
+ throw eos_reached ();
+
+ if (args_.empty ())
+ return base::skip ();
+ else
+ args_.pop_front ();
+ }
+
+ void argv_file_scanner::
+ load (const char* file)
+ {
+ using namespace std;
+
+ ifstream is (file);
+
+ if (!is.is_open ())
+ throw file_io_failure (file);
+
+ while (!is.eof ())
+ {
+ string line;
+ getline (is, line);
+
+ if (is.fail () && !is.eof ())
+ throw file_io_failure (file);
+
+ string::size_type n (line.size ());
+
+ // Trim the line from leading and trailing whitespaces.
+ //
+ if (n != 0)
+ {
+ const char* f (line.c_str ());
+ const char* l (f + n);
+
+ const char* of (f);
+ while (f < l && (*f == ' ' || *f == '\t' || *f == '\r'))
+ ++f;
+
+ --l;
+
+ const char* ol (l);
+ while (l > f && (*l == ' ' || *l == '\t' || *l == '\r'))
+ --l;
+
+ if (f != of || l != ol)
+ line = f <= l ? string (f, l - f + 1) : string ();
+ }
+
+ // Ignore empty lines, those that start with #.
+ //
+ if (line.empty () || line[0] == '#')
+ continue;
+
+ string::size_type p (line.find (' '));
+
+ if (p == string::npos)
+ {
+ if (!skip_)
+ skip_ = (line == "--");
+
+ args_.push_back (line);
+ }
+ else
+ {
+ string s1 (line, 0, p);
+
+ // Skip leading whitespaces in the argument.
+ //
+ n = line.size ();
+ for (++p; p < n; ++p)
+ {
+ char c (line[p]);
+
+ if (c != ' ' && c != '\t' && c != '\r')
+ break;
+ }
+
+ string s2 (line, p);
+
+ // If the string is wrapped in quotes, remove them.
+ //
+ n = s2.size ();
+ char cf (s2[0]), cl (s2[n - 1]);
+
+ if (cf == '"' || cf == '\'' || cl == '"' || cl == '\'')
+ {
+ if (n == 1 || cf != cl)
+ throw unmatched_quote (s2);
+
+ s2 = string (s2, 1, n - 2);
+ }
+
+ if (!skip_ && s1 == option_)
+ load (s2.c_str ());
+ else
+ {
+ args_.push_back (s1);
+ args_.push_back (s2);
+ }
+ }
+ }
+ }
+
+ template <typename X>
+ struct parser
+ {
+ static void
+ parse (X& x, bool& xs, scanner& s)
+ {
+ const char* o (s.next ());
+
+ if (s.more ())
+ {
+ const char* v (s.next ());
+ std::istringstream is (v);
+ if (!(is >> x && is.eof ()))
+ throw invalid_value (o, v);
+ }
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <>
+ struct parser<bool>
+ {
+ static void
+ parse (bool& x, scanner& s)
+ {
+ s.next ();
+ x = true;
+ }
+ };
+
+ template <>
+ struct parser<std::string>
+ {
+ static void
+ parse (std::string& x, bool& xs, scanner& s)
+ {
+ const char* o (s.next ());
+
+ if (s.more ())
+ x = s.next ();
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <typename X>
+ struct parser<std::vector<X> >
+ {
+ static void
+ parse (std::vector<X>& c, bool& xs, scanner& s)
+ {
+ X x;
+ bool dummy;
+ parser<X>::parse (x, dummy, s);
+ c.push_back (x);
+ xs = true;
+ }
+ };
+
+ template <typename X>
+ struct parser<std::set<X> >
+ {
+ static void
+ parse (std::set<X>& c, bool& xs, scanner& s)
+ {
+ X x;
+ bool dummy;
+ parser<X>::parse (x, dummy, s);
+ c.insert (x);
+ xs = true;
+ }
+ };
+
+ template <typename K, typename V>
+ struct parser<std::map<K, V> >
+ {
+ static void
+ parse (std::map<K, V>& m, bool& xs, scanner& s)
+ {
+ const char* o (s.next ());
+
+ if (s.more ())
+ {
+ std::string ov (s.next ());
+ std::string::size_type p = ov.find ('=');
+
+ if (p == std::string::npos)
+ {
+ K k = K ();
+
+ if (!ov.empty ())
+ {
+ std::istringstream ks (ov);
+
+ if (!(ks >> k && ks.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ m[k] = V ();
+ }
+ else
+ {
+ K k = K ();
+ V v = V ();
+ std::string kstr (ov, 0, p);
+ std::string vstr (ov, p + 1);
+
+ if (!kstr.empty ())
+ {
+ std::istringstream ks (kstr);
+
+ if (!(ks >> k && ks.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ if (!vstr.empty ())
+ {
+ std::istringstream vs (vstr);
+
+ if (!(vs >> v && vs.eof ()))
+ throw invalid_value (o, ov);
+ }
+
+ m[k] = v;
+ }
+ }
+ else
+ throw missing_value (o);
+
+ xs = true;
+ }
+ };
+
+ template <typename X, typename T, T X::*M>
+ void
+ thunk (X& x, scanner& s)
+ {
+ parser<T>::parse (x.*M, s);
+ }
+
+ template <typename X, typename T, T X::*M, bool X::*S>
+ void
+ thunk (X& x, scanner& s)
+ {
+ parser<T>::parse (x.*M, x.*S, s);
+ }
+}
+
+#include <map>
+#include <cstring>
+
+namespace cli
+{
+ // mysql_options
+ //
+
+ mysql_options::
+ mysql_options (int& argc,
+ char** argv,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : help_ (),
+ user_ (),
+ user_specified_ (false),
+ passwd_ (),
+ passwd_specified_ (false),
+ db_name_ (),
+ db_name_specified_ (false),
+ host_ (),
+ host_specified_ (false),
+ port_ (0),
+ port_specified_ (false),
+ socket_ (),
+ socket_specified_ (false),
+ options_file_ (),
+ options_file_specified_ (false)
+ {
+ ::cli::argv_scanner s (argc, argv, erase);
+ _parse (s, opt, arg);
+ }
+
+ mysql_options::
+ mysql_options (int start,
+ int& argc,
+ char** argv,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : help_ (),
+ user_ (),
+ user_specified_ (false),
+ passwd_ (),
+ passwd_specified_ (false),
+ db_name_ (),
+ db_name_specified_ (false),
+ host_ (),
+ host_specified_ (false),
+ port_ (0),
+ port_specified_ (false),
+ socket_ (),
+ socket_specified_ (false),
+ options_file_ (),
+ options_file_specified_ (false)
+ {
+ ::cli::argv_scanner s (start, argc, argv, erase);
+ _parse (s, opt, arg);
+ }
+
+ mysql_options::
+ mysql_options (int& argc,
+ char** argv,
+ int& end,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : help_ (),
+ user_ (),
+ user_specified_ (false),
+ passwd_ (),
+ passwd_specified_ (false),
+ db_name_ (),
+ db_name_specified_ (false),
+ host_ (),
+ host_specified_ (false),
+ port_ (0),
+ port_specified_ (false),
+ socket_ (),
+ socket_specified_ (false),
+ options_file_ (),
+ options_file_specified_ (false)
+ {
+ ::cli::argv_scanner s (argc, argv, erase);
+ _parse (s, opt, arg);
+ end = s.end ();
+ }
+
+ mysql_options::
+ mysql_options (int start,
+ int& argc,
+ char** argv,
+ int& end,
+ bool erase,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : help_ (),
+ user_ (),
+ user_specified_ (false),
+ passwd_ (),
+ passwd_specified_ (false),
+ db_name_ (),
+ db_name_specified_ (false),
+ host_ (),
+ host_specified_ (false),
+ port_ (0),
+ port_specified_ (false),
+ socket_ (),
+ socket_specified_ (false),
+ options_file_ (),
+ options_file_specified_ (false)
+ {
+ ::cli::argv_scanner s (start, argc, argv, erase);
+ _parse (s, opt, arg);
+ end = s.end ();
+ }
+
+ mysql_options::
+ mysql_options (::cli::scanner& s,
+ ::cli::unknown_mode opt,
+ ::cli::unknown_mode arg)
+ : help_ (),
+ user_ (),
+ user_specified_ (false),
+ passwd_ (),
+ passwd_specified_ (false),
+ db_name_ (),
+ db_name_specified_ (false),
+ host_ (),
+ host_specified_ (false),
+ port_ (0),
+ port_specified_ (false),
+ socket_ (),
+ socket_specified_ (false),
+ options_file_ (),
+ options_file_specified_ (false)
+ {
+ _parse (s, opt, arg);
+ }
+
+ void mysql_options::
+ print_usage (::std::ostream& os)
+ {
+ os << "--help Print usage information and exit." << ::std::endl;
+
+ os << "--user <name> MySQL database user." << ::std::endl;
+
+ os << "--passwd <str> MySQL database password" << ::std::endl;
+
+ os << "--db-name <name> MySQL database name." << ::std::endl;
+
+ os << "--host <addr> MySQL database host name or address (localhost by" << ::std::endl
+ << " default)." << ::std::endl;
+
+ os << "--port <integer> MySQL database port number." << ::std::endl;
+
+ os << "--socket <name> MySQL database socket name." << ::std::endl;
+
+ os << "--options-file <file> Read additional options from <file>." << ::std::endl;
+ }
+
+ typedef
+ std::map<std::string, void (*) (mysql_options&, ::cli::scanner&)>
+ _cli_mysql_options_map;
+
+ static _cli_mysql_options_map _cli_mysql_options_map_;
+
+ struct _cli_mysql_options_map_init
+ {
+ _cli_mysql_options_map_init ()
+ {
+ _cli_mysql_options_map_["--help"] =
+ &::cli::thunk< mysql_options, bool, &mysql_options::help_ >;
+ _cli_mysql_options_map_["--user"] =
+ &::cli::thunk< mysql_options, std::string, &mysql_options::user_,
+ &mysql_options::user_specified_ >;
+ _cli_mysql_options_map_["--passwd"] =
+ &::cli::thunk< mysql_options, std::string, &mysql_options::passwd_,
+ &mysql_options::passwd_specified_ >;
+ _cli_mysql_options_map_["--db-name"] =
+ &::cli::thunk< mysql_options, std::string, &mysql_options::db_name_,
+ &mysql_options::db_name_specified_ >;
+ _cli_mysql_options_map_["--host"] =
+ &::cli::thunk< mysql_options, std::string, &mysql_options::host_,
+ &mysql_options::host_specified_ >;
+ _cli_mysql_options_map_["--port"] =
+ &::cli::thunk< mysql_options, unsigned int, &mysql_options::port_,
+ &mysql_options::port_specified_ >;
+ _cli_mysql_options_map_["--socket"] =
+ &::cli::thunk< mysql_options, std::string, &mysql_options::socket_,
+ &mysql_options::socket_specified_ >;
+ _cli_mysql_options_map_["--options-file"] =
+ &::cli::thunk< mysql_options, std::string, &mysql_options::options_file_,
+ &mysql_options::options_file_specified_ >;
+ }
+ } _cli_mysql_options_map_init_;
+
+ void mysql_options::
+ _parse (::cli::scanner& s,
+ ::cli::unknown_mode opt_mode,
+ ::cli::unknown_mode arg_mode)
+ {
+ bool opt = true;
+
+ while (s.more ())
+ {
+ const char* o = s.peek ();
+
+ if (std::strcmp (o, "--") == 0)
+ {
+ s.skip ();
+ opt = false;
+ continue;
+ }
+
+ _cli_mysql_options_map::const_iterator i (
+ opt ? _cli_mysql_options_map_.find (o) : _cli_mysql_options_map_.end ());
+
+ if (i != _cli_mysql_options_map_.end ())
+ {
+ (*(i->second)) (*this, s);
+ }
+ else if (opt && std::strncmp (o, "-", 1) == 0 && o[1] != '\0')
+ {
+ switch (opt_mode)
+ {
+ case ::cli::unknown_mode::skip:
+ {
+ s.skip ();
+ continue;
+ }
+ case ::cli::unknown_mode::stop:
+ {
+ break;
+ }
+ case ::cli::unknown_mode::fail:
+ {
+ throw ::cli::unknown_option (o);
+ }
+ }
+
+ break;
+ }
+ else
+ {
+ switch (arg_mode)
+ {
+ case ::cli::unknown_mode::skip:
+ {
+ s.skip ();
+ continue;
+ }
+ case ::cli::unknown_mode::stop:
+ {
+ break;
+ }
+ case ::cli::unknown_mode::fail:
+ {
+ throw ::cli::unknown_argument (o);
+ }
+ }
+
+ break;
+ }
+ }
+ }
+}
+
diff --git a/libcommon/common/options.hxx b/libcommon/common/options.hxx
new file mode 100644
index 0000000..7d043a3
--- /dev/null
+++ b/libcommon/common/options.hxx
@@ -0,0 +1,396 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+#ifndef LIBCOMMON_COMMON_OPTIONS_HXX
+#define LIBCOMMON_COMMON_OPTIONS_HXX
+
+#include <deque>
+#include <iosfwd>
+#include <string>
+#include <exception>
+
+namespace cli
+{
+ class unknown_mode
+ {
+ public:
+ enum value
+ {
+ skip,
+ stop,
+ fail
+ };
+
+ unknown_mode (value v);
+
+ operator value () const
+ {
+ return v_;
+ }
+
+ private:
+ value v_;
+ };
+
+ // Exceptions.
+ //
+
+ class exception: public std::exception
+ {
+ public:
+ virtual void
+ print (std::ostream&) const = 0;
+ };
+
+ std::ostream&
+ operator<< (std::ostream&, const exception&);
+
+ class unknown_option: public exception
+ {
+ public:
+ virtual
+ ~unknown_option () throw ();
+
+ unknown_option (const std::string& option);
+
+ const std::string&
+ option () const;
+
+ virtual void
+ print (std::ostream&) const;
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string option_;
+ };
+
+ class unknown_argument: public exception
+ {
+ public:
+ virtual
+ ~unknown_argument () throw ();
+
+ unknown_argument (const std::string& argument);
+
+ const std::string&
+ argument () const;
+
+ virtual void
+ print (std::ostream&) const;
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string argument_;
+ };
+
+ class missing_value: public exception
+ {
+ public:
+ virtual
+ ~missing_value () throw ();
+
+ missing_value (const std::string& option);
+
+ const std::string&
+ option () const;
+
+ virtual void
+ print (std::ostream&) const;
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string option_;
+ };
+
+ class invalid_value: public exception
+ {
+ public:
+ virtual
+ ~invalid_value () throw ();
+
+ invalid_value (const std::string& option,
+ const std::string& value);
+
+ const std::string&
+ option () const;
+
+ const std::string&
+ value () const;
+
+ virtual void
+ print (std::ostream&) const;
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string option_;
+ std::string value_;
+ };
+
+ class eos_reached: public exception
+ {
+ public:
+ virtual void
+ print (std::ostream&) const;
+
+ virtual const char*
+ what () const throw ();
+ };
+
+ class file_io_failure: public exception
+ {
+ public:
+ virtual
+ ~file_io_failure () throw ();
+
+ file_io_failure (const std::string& file);
+
+ const std::string&
+ file () const;
+
+ virtual void
+ print (std::ostream&) const;
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string file_;
+ };
+
+ class unmatched_quote: public exception
+ {
+ public:
+ virtual
+ ~unmatched_quote () throw ();
+
+ unmatched_quote (const std::string& argument);
+
+ const std::string&
+ argument () const;
+
+ virtual void
+ print (std::ostream&) const;
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string argument_;
+ };
+
+ class scanner
+ {
+ public:
+ virtual
+ ~scanner ();
+
+ virtual bool
+ more () = 0;
+
+ virtual const char*
+ peek () = 0;
+
+ virtual const char*
+ next () = 0;
+
+ virtual void
+ skip () = 0;
+ };
+
+ class argv_scanner: public scanner
+ {
+ public:
+ argv_scanner (int& argc, char** argv, bool erase = false);
+ argv_scanner (int start, int& argc, char** argv, bool erase = false);
+
+ int
+ end () const;
+
+ virtual bool
+ more ();
+
+ virtual const char*
+ peek ();
+
+ virtual const char*
+ next ();
+
+ virtual void
+ skip ();
+
+ private:
+ int i_;
+ int& argc_;
+ char** argv_;
+ bool erase_;
+ };
+
+ class argv_file_scanner: public argv_scanner
+ {
+ public:
+ argv_file_scanner (int& argc,
+ char** argv,
+ const std::string& file_option,
+ bool erase = false);
+
+ argv_file_scanner (int start,
+ int& argc,
+ char** argv,
+ const std::string& file_option,
+ bool erase = false);
+
+ virtual bool
+ more ();
+
+ virtual const char*
+ peek ();
+
+ virtual const char*
+ next ();
+
+ virtual void
+ skip ();
+
+ private:
+ void
+ load (const char* file);
+
+ typedef argv_scanner base;
+
+ const std::string option_;
+ std::string hold_;
+ std::deque<std::string> args_;
+ bool skip_;
+ };
+}
+
+#include <string>
+
+namespace cli
+{
+ class mysql_options
+ {
+ public:
+
+ mysql_options (int& argc,
+ char** argv,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ mysql_options (int start,
+ int& argc,
+ char** argv,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ mysql_options (int& argc,
+ char** argv,
+ int& end,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ mysql_options (int start,
+ int& argc,
+ char** argv,
+ int& end,
+ bool erase = false,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ mysql_options (::cli::scanner&,
+ ::cli::unknown_mode option = ::cli::unknown_mode::fail,
+ ::cli::unknown_mode argument = ::cli::unknown_mode::stop);
+
+ // Option accessors.
+ //
+
+ const bool&
+ help () const;
+
+ const std::string&
+ user () const;
+
+ bool
+ user_specified () const;
+
+ const std::string&
+ passwd () const;
+
+ bool
+ passwd_specified () const;
+
+ const std::string&
+ db_name () const;
+
+ bool
+ db_name_specified () const;
+
+ const std::string&
+ host () const;
+
+ bool
+ host_specified () const;
+
+ const unsigned int&
+ port () const;
+
+ bool
+ port_specified () const;
+
+ const std::string&
+ socket () const;
+
+ bool
+ socket_specified () const;
+
+ const std::string&
+ options_file () const;
+
+ bool
+ options_file_specified () const;
+
+ // Print usage information.
+ //
+ static void
+ print_usage (::std::ostream&);
+
+ private:
+ void
+ _parse (::cli::scanner&,
+ ::cli::unknown_mode option,
+ ::cli::unknown_mode argument);
+
+ public:
+ bool help_;
+ std::string user_;
+ bool user_specified_;
+ std::string passwd_;
+ bool passwd_specified_;
+ std::string db_name_;
+ bool db_name_specified_;
+ std::string host_;
+ bool host_specified_;
+ unsigned int port_;
+ bool port_specified_;
+ std::string socket_;
+ bool socket_specified_;
+ std::string options_file_;
+ bool options_file_specified_;
+ };
+}
+
+#include "options.ixx"
+
+#endif // LIBCOMMON_COMMON_OPTIONS_HXX
diff --git a/libcommon/common/options.ixx b/libcommon/common/options.ixx
new file mode 100644
index 0000000..0fa60e5
--- /dev/null
+++ b/libcommon/common/options.ixx
@@ -0,0 +1,256 @@
+// This code was generated by CLI, a command line interface
+// compiler for C++.
+//
+
+namespace cli
+{
+ // unknown_mode
+ //
+ inline unknown_mode::
+ unknown_mode (value v)
+ : v_ (v)
+ {
+ }
+
+ // exception
+ //
+ inline std::ostream&
+ operator<< (std::ostream& os, const exception& e)
+ {
+ e.print (os);
+ return os;
+ }
+
+ // unknown_option
+ //
+ inline unknown_option::
+ unknown_option (const std::string& option)
+ : option_ (option)
+ {
+ }
+
+ inline const std::string& unknown_option::
+ option () const
+ {
+ return option_;
+ }
+
+ // unknown_argument
+ //
+ inline unknown_argument::
+ unknown_argument (const std::string& argument)
+ : argument_ (argument)
+ {
+ }
+
+ inline const std::string& unknown_argument::
+ argument () const
+ {
+ return argument_;
+ }
+
+ // missing_value
+ //
+ inline missing_value::
+ missing_value (const std::string& option)
+ : option_ (option)
+ {
+ }
+
+ inline const std::string& missing_value::
+ option () const
+ {
+ return option_;
+ }
+
+ // invalid_value
+ //
+ inline invalid_value::
+ invalid_value (const std::string& option,
+ const std::string& value)
+ : option_ (option), value_ (value)
+ {
+ }
+
+ inline const std::string& invalid_value::
+ option () const
+ {
+ return option_;
+ }
+
+ inline const std::string& invalid_value::
+ value () const
+ {
+ return value_;
+ }
+
+ // file_io_failure
+ //
+ inline file_io_failure::
+ file_io_failure (const std::string& file)
+ : file_ (file)
+ {
+ }
+
+ inline const std::string& file_io_failure::
+ file () const
+ {
+ return file_;
+ }
+
+ // unmatched_quote
+ //
+ inline unmatched_quote::
+ unmatched_quote (const std::string& argument)
+ : argument_ (argument)
+ {
+ }
+
+ inline const std::string& unmatched_quote::
+ argument () const
+ {
+ return argument_;
+ }
+
+ // argv_scanner
+ //
+ inline argv_scanner::
+ argv_scanner (int& argc, char** argv, bool erase)
+ : i_ (1), argc_ (argc), argv_ (argv), erase_ (erase)
+ {
+ }
+
+ inline argv_scanner::
+ argv_scanner (int start, int& argc, char** argv, bool erase)
+ : i_ (start), argc_ (argc), argv_ (argv), erase_ (erase)
+ {
+ }
+
+ inline int argv_scanner::
+ end () const
+ {
+ return i_;
+ }
+
+ // argv_file_scanner
+ //
+ inline argv_file_scanner::
+ argv_file_scanner (int& argc,
+ char** argv,
+ const std::string& option,
+ bool erase)
+ : argv_scanner (argc, argv, erase),
+ option_ (option),
+ skip_ (false)
+ {
+ }
+
+ inline argv_file_scanner::
+ argv_file_scanner (int start,
+ int& argc,
+ char** argv,
+ const std::string& option,
+ bool erase)
+ : argv_scanner (start, argc, argv, erase),
+ option_ (option),
+ skip_ (false)
+ {
+ }
+}
+
+namespace cli
+{
+ // mysql_options
+ //
+
+ inline const bool& mysql_options::
+ help () const
+ {
+ return this->help_;
+ }
+
+ inline const std::string& mysql_options::
+ user () const
+ {
+ return this->user_;
+ }
+
+ inline bool mysql_options::
+ user_specified () const
+ {
+ return this->user_specified_;
+ }
+
+ inline const std::string& mysql_options::
+ passwd () const
+ {
+ return this->passwd_;
+ }
+
+ inline bool mysql_options::
+ passwd_specified () const
+ {
+ return this->passwd_specified_;
+ }
+
+ inline const std::string& mysql_options::
+ db_name () const
+ {
+ return this->db_name_;
+ }
+
+ inline bool mysql_options::
+ db_name_specified () const
+ {
+ return this->db_name_specified_;
+ }
+
+ inline const std::string& mysql_options::
+ host () const
+ {
+ return this->host_;
+ }
+
+ inline bool mysql_options::
+ host_specified () const
+ {
+ return this->host_specified_;
+ }
+
+ inline const unsigned int& mysql_options::
+ port () const
+ {
+ return this->port_;
+ }
+
+ inline bool mysql_options::
+ port_specified () const
+ {
+ return this->port_specified_;
+ }
+
+ inline const std::string& mysql_options::
+ socket () const
+ {
+ return this->socket_;
+ }
+
+ inline bool mysql_options::
+ socket_specified () const
+ {
+ return this->socket_specified_;
+ }
+
+ inline const std::string& mysql_options::
+ options_file () const
+ {
+ return this->options_file_;
+ }
+
+ inline bool mysql_options::
+ options_file_specified () const
+ {
+ return this->options_file_specified_;
+ }
+}
+