aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--makefile4
-rw-r--r--sqlite/Makefile.am7
-rw-r--r--sqlite/makefile38
-rw-r--r--sqlite/mysql-vc10.sln15
-rw-r--r--sqlite/mysql-vc9.sln15
-rw-r--r--sqlite/native/driver.cxx66
-rw-r--r--sqlite/native/makefile85
-rw-r--r--sqlite/native/test.std0
-rw-r--r--sqlite/template/Makefile.am31
-rw-r--r--sqlite/template/driver.cxx44
-rw-r--r--sqlite/template/makefile105
-rw-r--r--sqlite/template/template-vc10.vcxproj180
-rw-r--r--sqlite/template/template-vc10.vcxproj.filters25
-rw-r--r--sqlite/template/template-vc9.vcproj361
-rw-r--r--sqlite/template/test.hxx27
-rw-r--r--sqlite/template/test.std1
-rw-r--r--sqlite/test.bat70
-rw-r--r--sqlite/truncation/driver.cxx162
-rw-r--r--sqlite/truncation/makefile106
-rw-r--r--sqlite/truncation/test.hxx48
-rw-r--r--sqlite/truncation/test.std0
-rw-r--r--sqlite/types/driver.cxx64
-rw-r--r--sqlite/types/makefile108
-rw-r--r--sqlite/types/test.hxx145
-rw-r--r--sqlite/types/test.std0
-rw-r--r--sqlite/types/traits.hxx96
26 files changed, 1803 insertions, 0 deletions
diff --git a/makefile b/makefile
index 896f788..0eaf04d 100644
--- a/makefile
+++ b/makefile
@@ -12,6 +12,10 @@ ifeq ($(db_id),mysql)
dirs += mysql
endif
+ifeq ($(db_id),sqlite)
+dirs += sqlite
+endif
+
default := $(out_base)/
dist := $(out_base)/.dist
test := $(out_base)/.test
diff --git a/sqlite/Makefile.am b/sqlite/Makefile.am
new file mode 100644
index 0000000..7661bd9
--- /dev/null
+++ b/sqlite/Makefile.am
@@ -0,0 +1,7 @@
+# file : sqlite/Makefile.am
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+SUBDIRS = __path__(dirs)
+EXTRA_DIST = __file__(extra_dist)
diff --git a/sqlite/makefile b/sqlite/makefile
new file mode 100644
index 0000000..b421807
--- /dev/null
+++ b/sqlite/makefile
@@ -0,0 +1,38 @@
+# file : sqlite/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : GNU GPL; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../build/bootstrap.make
+
+tests := \
+template \
+native \
+truncation \
+types
+
+default := $(out_base)/
+dist := $(out_base)/.dist
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+$(default): $(addprefix $(out_base)/,$(addsuffix /,$(tests)))
+
+$(dist): name := sqlite
+$(dist): export dirs := $(tests)
+$(dist): export extra_dist := $(name)-vc9.sln $(name)-vc10.sln test.bat
+$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(tests)))
+ $(call meta-automake)
+ $(call meta-vc9sln,$(name)-vc9.sln)
+ $(call meta-vc10sln,$(name)-vc10.sln)
+ $(call meta-vctest,$(name)-vc10.sln,test.bat)
+
+$(test): $(addprefix $(out_base)/,$(addsuffix /.test,$(tests)))
+$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(tests)))
+
+$(call include,$(bld_root)/meta/vc9sln.make)
+$(call include,$(bld_root)/meta/vc10sln.make)
+$(call include,$(bld_root)/meta/vctest.make)
+$(call include,$(bld_root)/meta/automake.make)
+
+$(foreach t,$(tests),$(call import,$(src_base)/$t/makefile))
diff --git a/sqlite/mysql-vc10.sln b/sqlite/mysql-vc10.sln
new file mode 100644
index 0000000..9a5dc32
--- /dev/null
+++ b/sqlite/mysql-vc10.sln
@@ -0,0 +1,15 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+__projects__
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+__solution_configurations__
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+__project_configurations__
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/sqlite/mysql-vc9.sln b/sqlite/mysql-vc9.sln
new file mode 100644
index 0000000..2ec9432
--- /dev/null
+++ b/sqlite/mysql-vc9.sln
@@ -0,0 +1,15 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
+__projects__
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+__solution_configurations__
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+__project_configurations__
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
diff --git a/sqlite/native/driver.cxx b/sqlite/native/driver.cxx
new file mode 100644
index 0000000..73e0450
--- /dev/null
+++ b/sqlite/native/driver.cxx
@@ -0,0 +1,66 @@
+// file : sqlite/native/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+// Test native SQL execution.
+//
+
+#include <memory> // std::auto_ptr
+#include <cassert>
+#include <iostream>
+
+#include <odb/sqlite/database.hxx>
+#include <odb/sqlite/transaction.hxx>
+
+#include <common/common.hxx>
+
+using namespace std;
+using namespace odb::core;
+
+int
+main (int argc, char* argv[])
+{
+ try
+ {
+ auto_ptr<database> db (create_database (argc, argv, false));
+
+ // Create the database schema.
+ //
+ {
+ transaction t (db->begin ());
+
+ db->execute ("DROP TABLE IF EXISTS test");
+ db->execute ("CREATE TABLE test (n INTEGER PRIMARY KEY)");
+
+ t.commit ();
+ }
+
+ // Insert a few rows.
+ //
+ {
+ transaction t (db->begin ());
+
+ assert (db->execute ("INSERT INTO test (n) VALUES (1)") == 1);
+ assert (db->execute ("INSERT INTO test (n) VALUES (2)") == 1);
+
+ t.commit ();
+ }
+
+ // Select a few rows.
+ //
+ {
+ transaction t (db->begin ());
+
+ assert (db->execute ("SELECT n FROM test WHERE n < 3") == 2);
+ assert (db->execute ("SELECT n FROM test WHERE n > 3") == 0);
+
+ t.commit ();
+ }
+ }
+ catch (const odb::exception& e)
+ {
+ cerr << e.what () << endl;
+ return 1;
+ }
+}
diff --git a/sqlite/native/makefile b/sqlite/native/makefile
new file mode 100644
index 0000000..6a111e3
--- /dev/null
+++ b/sqlite/native/makefile
@@ -0,0 +1,85 @@
+# file : sqlite/native/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
+
+cxx_tun := driver.cxx
+cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o))
+cxx_od := $(cxx_obj:.o=.o.d)
+
+common.l := $(out_root)/libcommon/common/common.l
+common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options
+
+driver := $(out_base)/driver
+dist := $(out_base)/.dist
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+# Build.
+#
+$(driver): $(cxx_obj) $(common.l)
+$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
+$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
+
+$(call include-dep,$(cxx_od))
+
+# Alias for default target.
+#
+$(out_base)/: $(driver)
+
+# Dist
+#
+$(dist): sources := $(cxx_tun)
+$(dist): data_dist := test.std
+$(dist): export name := $(subst /,-,$(subst $(src_root)/sqlite/,,$(src_base)))
+$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \
+$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters
+$(dist):
+ $(call dist-data,$(sources) $(data_dist))
+ $(call meta-automake,../template/Makefile.am)
+ $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj)
+ $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj)
+
+# Test.
+#
+$(test): $(driver) $(src_base)/test.std
+ $(call message,test $<,$< --options-file $(dcf_root)/db.options \
+>$(out_base)/test.out)
+ $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out)
+ $(call message,,rm -f $(out_base)/test.out)
+
+# Clean.
+#
+$(clean): \
+ $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(cxx_obj)) \
+ $(addsuffix .cxx.clean,$(cxx_od))
+ $(call message,,rm -f $(out_base)/test.out)
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver
+$(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,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/o-e.make)
+
+# Dependencies.
+#
+$(call import,$(src_root)/libcommon/makefile)
diff --git a/sqlite/native/test.std b/sqlite/native/test.std
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/sqlite/native/test.std
diff --git a/sqlite/template/Makefile.am b/sqlite/template/Makefile.am
new file mode 100644
index 0000000..5591b10
--- /dev/null
+++ b/sqlite/template/Makefile.am
@@ -0,0 +1,31 @@
+# file : sqlite/template/Makefile.am
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+EXTRA_DIST = __file__(extra_dist)
+
+noinst_PROGRAMS = driver
+driver_SOURCES = driver.cxx __path__(extra_sources) __path__(extra_headers)
+LDADD = $(top_builddir)/libcommon/common/libcommon.la
+AM_CPPFLAGS = -I'$(top_builddir)/libcommon' -I'$(top_srcdir)/libcommon'
+
+TESTS=$(top_builddir)/tester
+TESTS_ENVIRONMENT=top_builddir=$(top_builddir); export top_builddir;
+
+m4_ifelse(__value__(odb_options),,,
+
+# ODB compilation.
+#
+driver_SOURCES += test.hxx
+nodist_driver_SOURCES = test-odb.cxx
+BUILT_SOURCES = test-odb.hxx
+CLEANFILES = test-odb.hxx test-odb.ixx test-odb.cxx
+
+ODB = @ODB@
+ODBFLAGS = @ODBFLAGS@
+ODBCPPFLAGS = @ODBCPPFLAGS@
+
+test-odb.hxx: test.hxx
+ $(ODB) $(AM_CPPFLAGS) $(ODBCPPFLAGS) $(CPPFLAGS) $(ODBFLAGS) __value__(odb_options) $<
+)
diff --git a/sqlite/template/driver.cxx b/sqlite/template/driver.cxx
new file mode 100644
index 0000000..d7847f7
--- /dev/null
+++ b/sqlite/template/driver.cxx
@@ -0,0 +1,44 @@
+// file : sqlite/template/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+// PLACE TEST DESCRIPTION HERE
+//
+
+#include <memory> // std::auto_ptr
+#include <cassert>
+#include <iostream>
+
+#include <odb/sqlite/database.hxx>
+#include <odb/sqlite/transaction.hxx>
+
+#include <common/common.hxx>
+
+#include "test.hxx"
+#include "test-odb.hxx"
+
+using namespace std;
+using namespace odb::core;
+
+int
+main (int argc, char* argv[])
+{
+ try
+ {
+ auto_ptr<database> db (create_database (argc, argv));
+
+ //
+ //
+ cout << "test 001" << endl;
+ {
+ transaction t (db->begin ());
+ t.commit ();
+ }
+ }
+ catch (const odb::exception& e)
+ {
+ cerr << e.what () << endl;
+ return 1;
+ }
+}
diff --git a/sqlite/template/makefile b/sqlite/template/makefile
new file mode 100644
index 0000000..bf2f178
--- /dev/null
+++ b/sqlite/template/makefile
@@ -0,0 +1,105 @@
+# file : sqlite/template/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
+
+cxx_tun := driver.cxx
+odb_hdr := test.hxx
+cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o))
+cxx_od := $(cxx_obj:.o=.o.d)
+
+common.l := $(out_root)/libcommon/common/common.l
+common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options
+
+driver := $(out_base)/driver
+dist := $(out_base)/.dist
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+# Import.
+#
+$(call import,\
+ $(scf_root)/import/odb/stub.make,\
+ odb: odb,odb-rules: odb_rules)
+
+# Build.
+#
+$(driver): $(cxx_obj) $(common.l)
+$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
+$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
+
+genf := $(addprefix $(odb_hdr:.hxx=-odb),.hxx .ixx .cxx) $(odb_hdr:.hxx=.sql)
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(odb)
+$(gen): odb := $(odb)
+$(gen) $(dist): export odb_options += --database sqlite --generate-schema
+$(gen): cpp_options := -I$(src_base)
+$(gen): $(common.l.cpp-options)
+
+$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
+
+# Alias for default target.
+#
+$(out_base)/: $(driver)
+
+# Dist
+#
+$(dist): sources := $(cxx_tun)
+$(dist): headers := $(odb_hdr)
+$(dist): data_dist := test.std
+$(dist): export name := $(subst /,-,$(subst $(src_root)/sqlite/,,$(src_base)))
+$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \
+$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters
+$(dist):
+ $(call dist-data,$(sources) $(headers) $(data_dist))
+ $(call meta-automake,../template/Makefile.am)
+ $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj)
+ $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj)
+
+# Test.
+#
+$(test): $(driver) $(src_base)/test.std
+ $(call schema)
+ $(call message,test $<,$< --options-file $(dcf_root)/db.options \
+>$(out_base)/test.out)
+ $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out)
+ $(call message,,rm -f $(out_base)/test.out)
+
+# Clean.
+#
+$(clean): \
+ $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(cxx_obj)) \
+ $(addsuffix .cxx.clean,$(cxx_od)) \
+ $(addprefix $(out_base)/,$(odb_hdr:.hxx=-odb.cxx.hxx.clean))
+ $(call message,,rm -f $(out_base)/test.out)
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(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,$(odb_rules))
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/o-e.make)
+
+# Dependencies.
+#
+$(call import,$(src_root)/libcommon/makefile)
diff --git a/sqlite/template/template-vc10.vcxproj b/sqlite/template/template-vc10.vcxproj
new file mode 100644
index 0000000..3f7ddf9
--- /dev/null
+++ b/sqlite/template/template-vc10.vcxproj
@@ -0,0 +1,180 @@
+<?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>{__uuid__()}</ProjectGuid>
+ <Keyword>Win32Proj</Keyword>
+ <RootNamespace>__value__(name)</RootNamespace>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>true</UseDebugLibraries>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>Application</ConfigurationType>
+ <UseDebugLibraries>false</UseDebugLibraries>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <CharacterSet>Unicode</CharacterSet>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>Application</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>$(Configuration)\</OutDir>
+ <TargetName>driver</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <LinkIncremental>true</LinkIncremental>
+ <OutDir>$(Platform)\$(Configuration)\</OutDir>
+ <TargetName>driver</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <LinkIncremental>false</LinkIncremental>
+ <OutDir>$(Configuration)\</OutDir>
+ <TargetName>driver</TargetName>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <LinkIncremental>false</LinkIncremental>
+ <OutDir>$(Platform)\$(Configuration)\</OutDir>
+ <TargetName>driver</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\..\libcommon</AdditionalIncludeDirectories>
+ <DisableSpecificWarnings>4068;4355;4800;4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>$(SolutionDir)\..\libcommon\lib\common-d.lib;odb-sqlite-d.lib;odb-d.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <ClCompile>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level3</WarningLevel>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\..\libcommon</AdditionalIncludeDirectories>
+ <DisableSpecificWarnings>4068;4355;4800;4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>$(SolutionDir)\..\libcommon\lib64\common-d.lib;odb-sqlite-d.lib;odb-d.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ </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;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\..\libcommon</AdditionalIncludeDirectories>
+ <DisableSpecificWarnings>4068;4355;4800;4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>$(SolutionDir)\..\libcommon\lib\common.lib;odb-sqlite.lib;odb.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </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;_CONSOLE;HAVE_CONFIG_VC_H;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <AdditionalIncludeDirectories>$(SolutionDir)\..\libcommon</AdditionalIncludeDirectories>
+ <DisableSpecificWarnings>4068;4355;4800;4290;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ </ClCompile>
+ <Link>
+ <AdditionalDependencies>$(SolutionDir)\..\libcommon\lib64\common.lib;odb-sqlite.lib;odb.lib;%(AdditionalDependencies)</AdditionalDependencies>
+ <SubSystem>Console</SubSystem>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <OptimizeReferences>true</OptimizeReferences>
+ </Link>
+ </ItemDefinitionGroup>
+m4_ifelse(__value__(odb_options),,,
+m4_dnl
+ <ItemGroup>
+__custom_build_entry__(
+test.hxx,
+odb test.hxx,
+odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -I$(SolutionDir)\..\libcommon)) test.hxx,
+test-odb.hxx;test-odb.ixx;test-odb.cxx)
+ </ItemGroup>)
+ <ItemGroup>
+m4_ifelse(__value__(odb_options),,,
+__header_entry__(test-odb.hxx)
+__header_entry__(test-odb.ixx))
+__header_entries__(extra_headers)
+ </ItemGroup>
+ <ItemGroup>
+__source_entry__(driver.cxx)
+m4_ifelse(__value__(odb_options),,,__source_entry__(test-odb.cxx))
+__source_entries__(extra_sources)
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project>
diff --git a/sqlite/template/template-vc10.vcxproj.filters b/sqlite/template/template-vc10.vcxproj.filters
new file mode 100644
index 0000000..951015b
--- /dev/null
+++ b/sqlite/template/template-vc10.vcxproj.filters
@@ -0,0 +1,25 @@
+<?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>{__uuid__()}</UniqueIdentifier>
+ <Extensions>cxx</Extensions>
+ </Filter>
+ <Filter Include="Header Files">
+ <UniqueIdentifier>{__uuid__()}</UniqueIdentifier>
+ <Extensions>h;hxx;ixx;txx</Extensions>
+ </Filter>
+ </ItemGroup>
+ <ItemGroup>
+m4_ifelse(__value__(odb_options),,,
+__header_filter_entry__(test.hxx)
+__header_filter_entry__(test-odb.hxx)
+__header_filter_entry__(test-odb.ixx))
+__header_filter_entries__(extra_headers)
+ </ItemGroup>
+ <ItemGroup>
+__source_filter_entry__(driver.cxx)
+m4_ifelse(__value__(odb_options),,,__source_filter_entry__(test-odb.cxx))
+__source_filter_entries__(extra_sources)
+ </ItemGroup>
+</Project> \ No newline at end of file
diff --git a/sqlite/template/template-vc9.vcproj b/sqlite/template/template-vc9.vcproj
new file mode 100644
index 0000000..48516cd
--- /dev/null
+++ b/sqlite/template/template-vc9.vcproj
@@ -0,0 +1,361 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9.00"
+ Name="__value__(name)"
+ ProjectGUID="{__uuid__()}"
+ RootNamespace="__value__(name)"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="196613"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ <Platform
+ Name="x64"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4068 /wd4355 /wd4800 /wd4290"
+ Optimization="0"
+ AdditionalIncludeDirectories="$(SolutionDir)\..\libcommon"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="$(SolutionDir)\..\libcommon\lib\common-d.lib odb-sqlite-d.lib odb-d.lib"
+ OutputFile="$(OutDir)\driver.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ 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|Win32"
+ OutputDirectory="$(ConfigurationName)"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4068 /wd4355 /wd4800 /wd4290"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="$(SolutionDir)\..\libcommon"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_VC_H"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="$(SolutionDir)\..\libcommon\lib\common.lib odb-sqlite.lib odb.lib"
+ OutputFile="$(OutDir)\driver.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ TargetEnvironment="3"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalOptions="/wd4068 /wd4355 /wd4800 /wd4290"
+ Optimization="0"
+ AdditionalIncludeDirectories="$(SolutionDir)\..\libcommon"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;HAVE_CONFIG_VC_H"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="$(SolutionDir)\..\libcommon\lib64\common-d.lib odb-sqlite-d.lib odb-d.lib"
+ OutputFile="$(OutDir)\driver.exe"
+ LinkIncremental="2"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ 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|x64"
+ OutputDirectory="$(PlatformName)\$(ConfigurationName)"
+ IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
+ ConfigurationType="1"
+ 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="/wd4068 /wd4355 /wd4800 /wd4290"
+ Optimization="2"
+ EnableIntrinsicFunctions="true"
+ AdditionalIncludeDirectories="$(SolutionDir)\..\libcommon"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;HAVE_CONFIG_VC_H"
+ RuntimeLibrary="2"
+ EnableFunctionLevelLinking="true"
+ UsePrecompiledHeader="0"
+ WarningLevel="3"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="$(SolutionDir)\..\libcommon\lib64\common.lib odb-sqlite.lib odb.lib"
+ OutputFile="$(OutDir)\driver.exe"
+ LinkIncremental="1"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ 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="{__uuid__()}"
+ >
+__source_entry__(driver.cxx)
+m4_ifelse(__value__(odb_options),,,__source_entry__(test-odb.cxx))
+__source_entries__(extra_sources)
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h;hxx;ixx;txx"
+ UniqueIdentifier="{__uuid__()}"
+ >
+m4_ifelse(__value__(odb_options),,,
+__file_entry_custom_build__(
+test.hxx,
+odb test.hxx,
+odb.exe __xml__(__shell_quotes__(__value__(odb_options) -DHAVE_CONFIG_VC_H -I$(SolutionDir)\..\libcommon)) test.hxx,
+test-odb.hxx;test-odb.ixx;test-odb.cxx)
+__file_entry__(test-odb.hxx)
+__file_entry__(test-odb.ixx))
+__file_entries__(extra_headers)
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/sqlite/template/test.hxx b/sqlite/template/test.hxx
new file mode 100644
index 0000000..45b1d82
--- /dev/null
+++ b/sqlite/template/test.hxx
@@ -0,0 +1,27 @@
+// file : sqlite/template/test.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef TEST_HXX
+#define TEST_HXX
+
+#include <odb/core.hxx>
+
+#pragma db object
+struct object
+{
+ object (unsigned long id)
+ : id_ (id)
+ {
+ }
+
+ object ()
+ {
+ }
+
+ #pragma db id
+ unsigned long id_;
+};
+
+#endif // TEST_HXX
diff --git a/sqlite/template/test.std b/sqlite/template/test.std
new file mode 100644
index 0000000..af8d8e7
--- /dev/null
+++ b/sqlite/template/test.std
@@ -0,0 +1 @@
+test 001
diff --git a/sqlite/test.bat b/sqlite/test.bat
new file mode 100644
index 0000000..f653557
--- /dev/null
+++ b/sqlite/test.bat
@@ -0,0 +1,70 @@
+@echo off
+rem file : sqlite/test.bat
+rem author : Boris Kolpackov <boris@codesynthesis.com>
+rem copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+rem license : GNU GPL v2; see accompanying LICENSE file
+
+setlocal
+
+set "tests=__path__(dirs)"
+set "confs=__path__(configurations)"
+set "plats=__path__(platforms)"
+set "curdir=%CD%"
+set "topdir=%curdir%\.."
+set "failed="
+
+goto start
+
+rem
+rem %1 - test directory
+rem %2 - configuration
+rem %3 - platform
+rem
+:run_test
+ cd %1
+
+ if "_%3_" == "_Win32_" (
+ set "dir=%2"
+ ) else (
+ set "dir=%3\%2"
+ )
+
+ if exist %dir%\driver.exe (
+ echo %1\%3\%2
+ call %topdir%\tester.bat sqlite %2 %3
+ if errorlevel 1 (
+ set "failed=%failed% %1\%3\%2"
+ )
+ )
+
+ cd %curdir%
+goto :eof
+
+:start
+
+for %%t in (%tests%) do (
+ for %%c in (%confs%) do (
+ for %%p in (%plats%) do (
+ call :run_test %%t %%c %%p
+ )
+ )
+)
+
+if not "_%failed%_" == "__" goto error
+
+echo.
+echo ALL TESTS PASSED
+echo.
+goto end
+
+:error
+if not "_%failed%_" == "__" (
+ echo.
+ for %%t in (%failed%) do echo FAILED: %%t
+ echo.
+)
+endlocal
+exit /b 1
+
+:end
+endlocal
diff --git a/sqlite/truncation/driver.cxx b/sqlite/truncation/driver.cxx
new file mode 100644
index 0000000..a48bdc2
--- /dev/null
+++ b/sqlite/truncation/driver.cxx
@@ -0,0 +1,162 @@
+// file : sqlite/truncation/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+// Test insufficient buffer/truncation handling.
+//
+
+#include <memory> // std::auto_ptr
+#include <cassert>
+#include <iostream>
+
+#include <odb/sqlite/database.hxx>
+#include <odb/sqlite/transaction.hxx>
+
+#include <common/common.hxx>
+
+#include "test.hxx"
+#include "test-odb.hxx"
+
+using namespace std;
+using namespace odb::core;
+
+int
+main (int argc, char* argv[])
+{
+ // The default pre-allocated buffer is 512 bytes long.
+ //
+ string long_str (640, 'c'); // This will get the buffer to 1024
+ string longer_str (1025, 'b');
+
+ try
+ {
+ // Test basic operations.
+ //
+ {
+ auto_ptr<database> db (create_database (argc, argv));
+
+ // Run persist/load so that the initial bindings are established
+ // (version == 0).
+ //
+ {
+ object1 o (1);
+ o.str_ = "test string";
+
+ transaction t (db->begin ());
+ db->persist (o);
+ db->load (1, o);
+ t.commit ();
+ }
+
+ {
+ object2 o (2);
+ o.str_ = "test string";
+
+ transaction t (db->begin ());
+ db->persist (o);
+ db->load (2, o);
+ t.commit ();
+ }
+
+ // Store/load the long string which should trigger buffer growth.
+ //
+ {
+ object1 o (3);
+ o.str_ = long_str;
+
+ transaction t (db->begin ());
+ db->persist (o);
+ t.commit ();
+ }
+
+ {
+ transaction t (db->begin ());
+ auto_ptr<object2> o (db->load<object2> (3));
+ assert (o->str_ == long_str);
+ t.commit ();
+ }
+
+ // Store/load longer string.
+ //
+ {
+ object1 o (3);
+ o.str_ = longer_str;
+
+ transaction t (db->begin ());
+ db->update (o);
+ t.commit ();
+ }
+
+ {
+ transaction t (db->begin ());
+ auto_ptr<object2> o (db->load<object2> (3));
+ assert (o->str_ == longer_str);
+ t.commit ();
+ }
+ }
+
+ // Test query.
+ //
+ {
+ typedef odb::query<object1> query;
+ typedef odb::result<object1> result;
+
+ auto_ptr<database> db (create_database (argc, argv));
+
+ // Run persist/query so that the initial bindings are established
+ // (version == 0).
+ //
+ {
+ object1 o (20);
+ o.str_ = "test string";
+
+ transaction t (db->begin ());
+ db->persist (o);
+ o.id_++;
+ db->persist (o);
+ o.id_++;
+ db->persist (o);
+
+ result r (db->query<object1> (query::id == 20));
+ assert (r.begin ()->id_ == 20);
+ t.commit ();
+ }
+
+ // Test buffer growth with cached result.
+ //
+ {
+ object1 o;
+
+ transaction t (db->begin ());
+
+ result r (db->query<object1> (query::id >= 20));
+ result::iterator i (r.begin ());
+
+ o.id_ = i->id_;
+ o.str_ = long_str;
+
+ // This forces buffer growth in the middle of result iteration.
+ //
+ db->update (o);
+
+ ++i;
+ assert (i->str_ == "test string");
+
+ o.id_ = i->id_;
+ o.str_ = longer_str;
+ db->update (o);
+
+ ++i;
+ assert (i->str_ == "test string");
+
+ t.commit ();
+ }
+ }
+ }
+ catch (const odb::exception& e)
+ {
+ cerr << e.what () << endl;
+ return 1;
+ }
+}
diff --git a/sqlite/truncation/makefile b/sqlite/truncation/makefile
new file mode 100644
index 0000000..8b00a1c
--- /dev/null
+++ b/sqlite/truncation/makefile
@@ -0,0 +1,106 @@
+# file : sqlite/truncation/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
+
+cxx_tun := driver.cxx
+odb_hdr := test.hxx
+cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o))
+cxx_od := $(cxx_obj:.o=.o.d)
+
+common.l := $(out_root)/libcommon/common/common.l
+common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options
+
+driver := $(out_base)/driver
+dist := $(out_base)/.dist
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+# Import.
+#
+$(call import,\
+ $(scf_root)/import/odb/stub.make,\
+ odb: odb,odb-rules: odb_rules)
+
+# Build.
+#
+$(driver): $(cxx_obj) $(common.l)
+$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
+$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
+
+genf := $(addprefix $(odb_hdr:.hxx=-odb),.hxx .ixx .cxx) $(odb_hdr:.hxx=.sql)
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(odb)
+$(gen): odb := $(odb)
+$(gen) $(dist): export odb_options += --database sqlite --generate-query \
+--generate-schema
+$(gen): cpp_options := -I$(src_base)
+$(gen): $(common.l.cpp-options)
+
+$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
+
+# Alias for default target.
+#
+$(out_base)/: $(driver)
+
+# Dist
+#
+$(dist): sources := $(cxx_tun)
+$(dist): headers := $(odb_hdr)
+$(dist): data_dist := test.std
+$(dist): export name := $(subst /,-,$(subst $(src_root)/sqlite/,,$(src_base)))
+$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \
+$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters
+$(dist):
+ $(call dist-data,$(sources) $(headers) $(data_dist))
+ $(call meta-automake,../template/Makefile.am)
+ $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj)
+ $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj)
+
+# Test.
+#
+$(test): $(driver) $(src_base)/test.std
+ $(call schema)
+ $(call message,test $<,$< --options-file $(dcf_root)/db.options \
+>$(out_base)/test.out)
+ $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out)
+ $(call message,,rm -f $(out_base)/test.out)
+
+# Clean.
+#
+$(clean): \
+ $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(cxx_obj)) \
+ $(addsuffix .cxx.clean,$(cxx_od)) \
+ $(addprefix $(out_base)/,$(odb_hdr:.hxx=-odb.cxx.hxx.clean))
+ $(call message,,rm -f $(out_base)/test.out)
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(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,$(odb_rules))
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/o-e.make)
+
+# Dependencies.
+#
+$(call import,$(src_root)/libcommon/makefile)
diff --git a/sqlite/truncation/test.hxx b/sqlite/truncation/test.hxx
new file mode 100644
index 0000000..824c0e8
--- /dev/null
+++ b/sqlite/truncation/test.hxx
@@ -0,0 +1,48 @@
+// file : sqlite/truncation/test.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef TEST_HXX
+#define TEST_HXX
+
+#include <string>
+#include <odb/core.hxx>
+
+#pragma db object table ("test")
+struct object1
+{
+ object1 (unsigned long id)
+ : id_ (id)
+ {
+ }
+
+ object1 ()
+ {
+ }
+
+ #pragma db id
+ unsigned long id_;
+
+ std::string str_;
+};
+
+#pragma db object table ("test")
+struct object2
+{
+ object2 (unsigned long id)
+ : id_ (id)
+ {
+ }
+
+ object2 ()
+ {
+ }
+
+ #pragma db id
+ unsigned long id_;
+
+ std::string str_;
+};
+
+#endif // TEST_HXX
diff --git a/sqlite/truncation/test.std b/sqlite/truncation/test.std
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/sqlite/truncation/test.std
diff --git a/sqlite/types/driver.cxx b/sqlite/types/driver.cxx
new file mode 100644
index 0000000..855cada
--- /dev/null
+++ b/sqlite/types/driver.cxx
@@ -0,0 +1,64 @@
+// file : sqlite/types/driver.cxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+// Test SQLite type conversion.
+//
+
+#include <memory> // std::auto_ptr
+#include <cassert>
+#include <iostream>
+
+#include <odb/sqlite/database.hxx>
+#include <odb/sqlite/transaction.hxx>
+
+#include <common/common.hxx>
+
+#include "test.hxx"
+#include "test-odb.hxx"
+
+using namespace std;
+using namespace odb::core;
+
+int
+main (int argc, char* argv[])
+{
+ try
+ {
+ auto_ptr<database> db (create_database (argc, argv));
+
+ object o (1);
+
+ o.bool_ = true;
+ o.integer_ = -123456;
+ o.real_ = 1.123;
+
+ string long_str (2040, 'l');
+ buffer long_buf (long_str.c_str (), long_str.size ());
+
+ o.text_ = long_str;
+ o.blob_ = long_buf;
+
+ {
+ transaction t (db->begin ());
+ db->persist (o);
+ t.commit ();
+ }
+
+ //
+ //
+ {
+ transaction t (db->begin ());
+ auto_ptr<object> o1 (db->load<object> (1));
+ t.commit ();
+
+ assert (o == *o1);
+ }
+ }
+ catch (const odb::exception& e)
+ {
+ cerr << e.what () << endl;
+ return 1;
+ }
+}
diff --git a/sqlite/types/makefile b/sqlite/types/makefile
new file mode 100644
index 0000000..7836a39
--- /dev/null
+++ b/sqlite/types/makefile
@@ -0,0 +1,108 @@
+# file : sqlite/types/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : GNU GPL v2; see accompanying LICENSE file
+
+include $(dir $(lastword $(MAKEFILE_LIST)))../../build/bootstrap.make
+
+cxx_tun := driver.cxx
+odb_hdr := test.hxx
+cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(odb_hdr:.hxx=-odb.o))
+cxx_od := $(cxx_obj:.o=.o.d)
+
+common.l := $(out_root)/libcommon/common/common.l
+common.l.cpp-options := $(out_root)/libcommon/common/common.l.cpp-options
+
+driver := $(out_base)/driver
+dist := $(out_base)/.dist
+test := $(out_base)/.test
+clean := $(out_base)/.clean
+
+# Import.
+#
+$(call import,\
+ $(scf_root)/import/odb/stub.make,\
+ odb: odb,odb-rules: odb_rules)
+
+# Build.
+#
+$(driver): $(cxx_obj) $(common.l)
+$(cxx_obj) $(cxx_od): cpp_options := -I$(out_base) -I$(src_base)
+$(cxx_obj) $(cxx_od): $(common.l.cpp-options)
+
+genf := $(addprefix $(odb_hdr:.hxx=-odb),.hxx .ixx .cxx) $(odb_hdr:.hxx=.sql)
+gen := $(addprefix $(out_base)/,$(genf))
+
+$(gen): $(odb)
+$(gen): odb := $(odb)
+$(gen) $(dist): export odb_options += --database sqlite --generate-schema \
+--generate-query --cxx-prologue '\#include "traits.hxx"'
+
+$(gen): cpp_options := -I$(src_base)
+$(gen): $(common.l.cpp-options)
+
+$(call include-dep,$(cxx_od),$(cxx_obj),$(gen))
+
+# Alias for default target.
+#
+$(out_base)/: $(driver)
+
+# Dist
+#
+$(dist): sources := $(cxx_tun)
+$(dist): headers := $(odb_hdr)
+$(dist): export extra_headers := traits.hxx
+$(dist): data_dist := test.std
+$(dist): export name := $(subst /,-,$(subst $(src_root)/sqlite/,,$(src_base)))
+$(dist): export extra_dist := $(data_dist) $(name)-vc9.vcproj \
+$(name)-vc10.vcxproj $(name)-vc10.vcxproj.filters
+$(dist):
+ $(call dist-data,$(sources) $(headers) $(extra_headers) $(data_dist))
+ $(call meta-automake,../template/Makefile.am)
+ $(call meta-vc9proj,../template/template-vc9.vcproj,$(name)-vc9.vcproj)
+ $(call meta-vc10proj,../template/template-vc10.vcxproj,$(name)-vc10.vcxproj)
+
+# Test.
+#
+$(test): $(driver) $(src_base)/test.std
+ $(call schema)
+ $(call message,test $<,$< --options-file $(dcf_root)/db.options \
+>$(out_base)/test.out)
+ $(call message,,diff -u $(src_base)/test.std $(out_base)/test.out)
+ $(call message,,rm -f $(out_base)/test.out)
+
+# Clean.
+#
+$(clean): \
+ $(driver).o.clean \
+ $(addsuffix .cxx.clean,$(cxx_obj)) \
+ $(addsuffix .cxx.clean,$(cxx_od)) \
+ $(addprefix $(out_base)/,$(odb_hdr:.hxx=-odb.cxx.hxx.clean))
+ $(call message,,rm -f $(out_base)/test.out)
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(driver): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := driver $(genf)
+$(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,$(odb_rules))
+$(call include,$(bld_root)/cxx/cxx-d.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/o-e.make)
+
+# Dependencies.
+#
+$(call import,$(src_root)/libcommon/makefile)
diff --git a/sqlite/types/test.hxx b/sqlite/types/test.hxx
new file mode 100644
index 0000000..971a89f
--- /dev/null
+++ b/sqlite/types/test.hxx
@@ -0,0 +1,145 @@
+// file : sqlite/types/test.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef TEST_HXX
+#define TEST_HXX
+
+#include <set>
+#include <string>
+#include <memory> // std::auto_ptr
+#include <cstddef> // std::size_t
+#include <cstring> // std::{memcmp,memcpy}
+
+#include <odb/core.hxx>
+
+struct buffer
+{
+ ~buffer ()
+ {
+ delete[] data_;
+ }
+
+ buffer ()
+ : data_ (0), size_ (0)
+ {
+ }
+
+ buffer (const void* data, std::size_t size)
+ : data_ (0), size_ (size)
+ {
+ data_ = new char[size_];
+ std::memcpy (data_, data, size_);
+ }
+
+ buffer (const buffer& y)
+ : data_ (0), size_ (0)
+ {
+ assign (y.data_, y.size_);
+ }
+
+ buffer&
+ operator= (const buffer& y)
+ {
+ if (this != &y)
+ assign (y.data_, y.size_);
+
+ return *this;
+ }
+
+ void
+ assign (const void* data, std::size_t size)
+ {
+ if (size_ < size)
+ {
+ char* p (new char[size]);
+ delete[] data_;
+ data_ = p;
+ }
+
+ std::memcpy (data_, data, size);
+ size_ = size;
+ }
+
+ char*
+ data ()
+ {
+ return data_;
+ }
+
+ const char*
+ data () const
+ {
+ return data_;
+ }
+
+ std::size_t
+ size () const
+ {
+ return size_;
+ }
+
+ bool
+ operator== (const buffer& y) const
+ {
+ return size_ == y.size_ && std::memcmp (data_, y.data_, size_) == 0;
+ }
+
+private:
+ char* data_;
+ std::size_t size_;
+};
+
+typedef std::auto_ptr<std::string> string_ptr;
+
+#pragma db object
+struct object
+{
+ object (unsigned long id)
+ : id_ (id)
+ {
+ }
+
+ object ()
+ {
+ }
+
+ #pragma db id
+ unsigned long id_;
+
+ #pragma db type ("BOOL NOT NULL")
+ bool bool_;
+
+ #pragma db type ("INTEGER NOT NULL")
+ int integer_;
+
+ #pragma db type ("REAL NOT NULL")
+ double real_;
+
+ #pragma db type ("TEXT NOT NULL")
+ std::string text_;
+
+ #pragma db type ("BLOB NOT NULL")
+ buffer blob_;
+
+ // Test NULL value.
+ //
+ #pragma db type ("TEXT")
+ string_ptr null_;
+
+ bool
+ operator== (const object& y) const
+ {
+ return
+ id_ == y.id_ &&
+ bool_ == y.bool_ &&
+ integer_ == y.integer_ &&
+ real_ == y.real_ &&
+ text_ == y.text_ &&
+ blob_ == y.blob_ &&
+ ((null_.get () == 0 && y.null_.get () == 0) || *null_ == *y.null_);
+ }
+};
+
+#endif // TEST_HXX
diff --git a/sqlite/types/test.std b/sqlite/types/test.std
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/sqlite/types/test.std
diff --git a/sqlite/types/traits.hxx b/sqlite/types/traits.hxx
new file mode 100644
index 0000000..0f9c253
--- /dev/null
+++ b/sqlite/types/traits.hxx
@@ -0,0 +1,96 @@
+// file : sqlite/types/traits.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef TRAITS_HXX
+#define TRAITS_HXX
+
+#include <cstring> // std::memcpy, std::memset
+
+#include <odb/sqlite/traits.hxx>
+
+#include "test.hxx" // buffer
+
+namespace odb
+{
+ namespace sqlite
+ {
+ template <>
+ class value_traits<buffer, details::buffer, id_blob>
+ {
+ public:
+ typedef buffer value_type;
+ typedef buffer query_type;
+ typedef details::buffer image_type;
+
+ static void
+ set_value (buffer& v,
+ const details::buffer& b,
+ std::size_t n,
+ bool is_null)
+ {
+ if (!is_null)
+ v.assign (b.data (), n);
+ else
+ v.assign (0, 0);
+ }
+
+ static void
+ set_image (details::buffer& b,
+ std::size_t& n,
+ bool& is_null,
+ const buffer& v)
+ {
+ is_null = false;
+ n = v.size ();
+
+ if (n > b.capacity ())
+ b.capacity (n);
+
+ if (n != 0)
+ std::memcpy (b.data (), v.data (), n);
+ }
+ };
+
+ template <>
+ class value_traits<string_ptr, details::buffer, id_text>
+ {
+ public:
+ typedef string_ptr value_type;
+ typedef std::string query_type;
+ typedef details::buffer image_type;
+
+ static void
+ set_value (string_ptr& v,
+ const details::buffer& b,
+ std::size_t n,
+ bool is_null)
+ {
+ v.reset (is_null ? 0 : new std::string (b.data (), n));
+ }
+
+ static void
+ set_image (details::buffer& b,
+ std::size_t& n,
+ bool& is_null,
+ const string_ptr& v)
+ {
+ is_null = v.get () == 0;
+
+ if (!is_null)
+ {
+ n = v->size ();
+
+ if (n > b.capacity ())
+ b.capacity (n);
+
+ if (n != 0)
+ std::memcpy (b.data (), v->c_str (), n);
+ }
+ }
+ };
+ }
+}
+
+#endif // TRAITS_HXX