aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--build/bootstrap.make72
-rw-r--r--build/import/cli/LICENSE21
-rw-r--r--build/import/cli/cli-cxx.make49
-rw-r--r--build/import/cli/configuration-rules.make15
-rwxr-xr-xbuild/import/cli/configure55
-rw-r--r--build/import/cli/stub.make30
-rw-r--r--build/import/libodb/LICENSE12
-rw-r--r--build/import/libodb/configuration-rules.make15
-rwxr-xr-xbuild/import/libodb/configure55
-rw-r--r--build/import/libodb/stub.make30
-rw-r--r--makefile36
-rw-r--r--odb/mssql/details/config.h.in14
-rw-r--r--odb/mssql/details/config.hxx20
-rw-r--r--odb/mssql/details/export.hxx41
-rw-r--r--odb/mssql/details/options.cli57
-rw-r--r--odb/mssql/exceptions.cxx82
-rw-r--r--odb/mssql/exceptions.hxx116
-rw-r--r--odb/mssql/forward.hxx63
-rw-r--r--odb/mssql/makefile131
-rw-r--r--odb/mssql/mssql-fwd.hxx22
-rw-r--r--odb/mssql/odbc.hxx25
-rw-r--r--odb/mssql/version.hxx45
22 files changed, 1006 insertions, 0 deletions
diff --git a/build/bootstrap.make b/build/bootstrap.make
new file mode 100644
index 0000000..40f62a1
--- /dev/null
+++ b/build/bootstrap.make
@@ -0,0 +1,72 @@
+# file : build/bootstrap.make
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : ODB NCUEL; see accompanying LICENSE file
+
+project_name := libodb-mssql
+
+# First try to include the bundled bootstrap.make if it exist. If that
+# fails, let make search for the external bootstrap.make.
+#
+build := build-0.3
+
+-include $(dir $(lastword $(MAKEFILE_LIST)))../../$(build)/bootstrap.make
+
+ifeq ($(patsubst %build/bootstrap.make,,$(lastword $(MAKEFILE_LIST))),)
+include $(build)/bootstrap.make
+endif
+
+
+# Aliases
+#
+.PHONY: $(out_base)/ \
+ $(out_base)/.test \
+ $(out_base)/.dist \
+ $(out_base)/.clean
+
+ifdef %interactive%
+
+.PHONY: test dist clean
+
+test: $(out_base)/.test
+dist: $(out_base)/.dist
+clean: $(out_base)/.clean
+
+ifneq ($(filter $(.DEFAULT_GOAL),test dist clean),)
+.DEFAULT_GOAL :=
+endif
+
+endif
+
+# Make sure the distribution prefix is set if the goal is dist.
+#
+ifneq ($(filter $(MAKECMDGOALS),dist),)
+ifeq ($(dist_prefix),)
+$(error dist_prefix is not set)
+endif
+endif
+
+# If we don't have dependency auto-generation then we need to manually
+# make sure that generated files are generated before C++ file are
+# compiler. To do this we make the object files ($2) depend in order-
+# only on generated files ($3).
+#
+ifeq ($(cxx_id),generic)
+
+define include-dep
+$(if $2,$(eval $2: | $3))
+endef
+
+else
+
+define include-dep
+$(call -include,$1)
+endef
+
+endif
+
+# Don't include dependency info for certain targets.
+#
+ifneq ($(filter $(MAKECMDGOALS),clean disfigure dist),)
+include-dep =
+endif
diff --git a/build/import/cli/LICENSE b/build/import/cli/LICENSE
new file mode 100644
index 0000000..3fe3ab2
--- /dev/null
+++ b/build/import/cli/LICENSE
@@ -0,0 +1,21 @@
+Copyright (c) 2009-2011 Code Synthesis Tools CC.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
diff --git a/build/import/cli/cli-cxx.make b/build/import/cli/cli-cxx.make
new file mode 100644
index 0000000..5d4293e
--- /dev/null
+++ b/build/import/cli/cli-cxx.make
@@ -0,0 +1,49 @@
+# file : build/import/cli/cli-cxx.make
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : MIT; see accompanying LICENSE file
+
+# Here we are operating in the importing project's space, not in
+# cli's.
+#
+
+# Get the C++ file extensions.
+#
+$(call include,$(bld_root)/cxx/configuration-static.make)
+
+cli_pattern := \
+$(out_base)/%.$(cxx_s_suffix) \
+$(out_base)/%.$(cxx_h_suffix) \
+$(out_base)/%.$(cxx_i_suffix)
+
+$(cli_pattern): cli_options := \
+--hxx-suffix .$(cxx_h_suffix) \
+--ixx-suffix .$(cxx_i_suffix) \
+--cxx-suffix .$(cxx_s_suffix)
+
+.PRECIOUS: $(cli_pattern)
+
+ifeq ($(out_base),$(src_base))
+
+$(cli_pattern): $(src_base)/%.cli
+ $(call message,cli $<,$(cli) $(cli_options) --output-dir $(dir $@) $<)
+
+else
+
+$(cli_pattern): $(src_base)/%.cli | $$(dir $$@).
+ $(call message,cli $<,$(cli) $(cli_options) --output-dir $(dir $@) $<)
+
+$(cli_pattern): $(out_base)/%.cli | $$(dir $$@).
+ $(call message,cli $<,$(cli) $(cli_options) --output-dir $(dir $@) $<)
+endif
+
+.PHONY: $(out_base)/%.cxx.cli.clean
+
+$(out_base)/%.cxx.cli.clean: cxx_s_suffix := $(cxx_s_suffix)
+$(out_base)/%.cxx.cli.clean: cxx_h_suffix := $(cxx_h_suffix)
+$(out_base)/%.cxx.cli.clean: cxx_i_suffix := $(cxx_i_suffix)
+
+$(out_base)/%.cxx.cli.clean:
+ $(call message,rm $$1,rm -f $$1,$(@:.cxx.cli.clean=.$(cxx_s_suffix)))
+ $(call message,rm $$1,rm -f $$1,$(@:.cxx.cli.clean=.$(cxx_h_suffix)))
+ $(call message,rm $$1,rm -f $$1,$(@:.cxx.cli.clean=.$(cxx_i_suffix)))
diff --git a/build/import/cli/configuration-rules.make b/build/import/cli/configuration-rules.make
new file mode 100644
index 0000000..e5a77f2
--- /dev/null
+++ b/build/import/cli/configuration-rules.make
@@ -0,0 +1,15 @@
+# file : build/import/cli/configuration-rules.make
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : MIT; see accompanying LICENSE file
+
+$(dcf_root)/import/cli/configuration-dynamic.make: | $(dcf_root)/import/cli/.
+ $(call message,,$(scf_root)/import/cli/configure $@)
+
+ifndef %foreign%
+
+$(dcf_root)/.disfigure::
+ $(call message,rm $(dcf_root)/import/cli/configuration-dynamic.make,\
+rm -f $(dcf_root)/import/cli/configuration-dynamic.make)
+
+endif
diff --git a/build/import/cli/configure b/build/import/cli/configure
new file mode 100755
index 0000000..612301c
--- /dev/null
+++ b/build/import/cli/configure
@@ -0,0 +1,55 @@
+#! /usr/bin/env bash
+
+# file : build/import/cli/configure
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : MIT; see accompanying LICENSE file
+
+
+# $1 - out file
+#
+# bld_root - build root
+# project_name - project name
+#
+
+source $bld_root/dialog.bash
+
+
+$echo
+$echo "Configuring external dependency on 'cli' for '$project_name'."
+$echo
+
+$echo
+$echo "Would you like to configure dependency on the installed "
+$echo "version of 'cli' as opposed to the development build?"
+$echo
+
+installed=`read_y_n y`
+
+path=
+
+if [ "$installed" = "n" ]; then
+
+$echo
+$echo "Please enter the src_root for 'cli'."
+$echo
+
+src_root=`read_path --directory --exist`
+
+$echo
+$echo "Please enter the out_root for 'cli'."
+$eche
+
+out_root=`read_path --directory $src_root`
+
+fi
+
+echo cli_installed := $installed >$1
+
+if [ "$installed" = "n" ]; then
+
+echo src_root := $src_root >>$1
+echo scf_root := \$\(src_root\)/build >>$1
+echo out_root := $out_root >>$1
+
+fi
diff --git a/build/import/cli/stub.make b/build/import/cli/stub.make
new file mode 100644
index 0000000..20cf45a
--- /dev/null
+++ b/build/import/cli/stub.make
@@ -0,0 +1,30 @@
+# file : build/import/cli/stub.make
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : MIT; see accompanying LICENSE file
+
+$(call include-once,$(scf_root)/import/cli/configuration-rules.make,$(dcf_root))
+
+cli_installed :=
+
+$(call -include,$(dcf_root)/import/cli/configuration-dynamic.make)
+
+ifdef cli_installed
+
+ifeq ($(cli_installed),y)
+
+$(call export,cli: cli,cli-rules: $(scf_root)/import/cli/cli-cxx.make)
+
+else
+
+# Include export stub.
+#
+$(call include,$(scf_root)/export/cli/stub.make)
+
+endif
+
+else
+
+.NOTPARALLEL:
+
+endif
diff --git a/build/import/libodb/LICENSE b/build/import/libodb/LICENSE
new file mode 100644
index 0000000..ed9c55c
--- /dev/null
+++ b/build/import/libodb/LICENSE
@@ -0,0 +1,12 @@
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License version 2 as
+published by the Free Software Foundation.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+GNU General Public License for details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
diff --git a/build/import/libodb/configuration-rules.make b/build/import/libodb/configuration-rules.make
new file mode 100644
index 0000000..529d9da
--- /dev/null
+++ b/build/import/libodb/configuration-rules.make
@@ -0,0 +1,15 @@
+# file : build/import/libodb/configuration-rules.make
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : ODB NCUEL; see accompanying LICENSE file
+
+$(dcf_root)/import/libodb/configuration-dynamic.make: | $(dcf_root)/import/libodb/.
+ $(call message,,$(scf_root)/import/libodb/configure $@)
+
+ifndef %foreign%
+
+$(dcf_root)/.disfigure::
+ $(call message,rm $(dcf_root)/import/libodb/configuration-dynamic.make,\
+rm -f $(dcf_root)/import/libodb/configuration-dynamic.make)
+
+endif
diff --git a/build/import/libodb/configure b/build/import/libodb/configure
new file mode 100755
index 0000000..6c24b15
--- /dev/null
+++ b/build/import/libodb/configure
@@ -0,0 +1,55 @@
+#! /usr/bin/env bash
+
+# file : build/import/libodb/configure
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : ODB NCUEL; see accompanying LICENSE file
+
+
+# $1 - out file
+#
+# bld_root - build root
+# project_name - project name
+#
+
+source $bld_root/dialog.bash
+
+
+$echo
+$echo "Configuring external dependency on 'libodb' for '$project_name'."
+$echo
+
+$echo
+$echo "Would you like to configure dependency on the installed "
+$echo "version of 'libodb' as opposed to the development build?"
+$echo
+
+installed=`read_y_n y`
+
+path=
+
+if [ "$installed" = "n" ]; then
+
+$echo
+$echo "Please enter the src_root for 'libodb'."
+$echo
+
+src_root=`read_path --directory --exist`
+
+$echo
+$echo "Please enter the out_root for 'libodb'."
+$echo
+
+out_root=`read_path --directory $src_root`
+
+fi
+
+echo libodb_installed := $installed >$1
+
+if [ "$installed" = "n" ]; then
+
+echo src_root := $src_root >>$1
+echo scf_root := \$\(src_root\)/build >>$1
+echo out_root := $out_root >>$1
+
+fi
diff --git a/build/import/libodb/stub.make b/build/import/libodb/stub.make
new file mode 100644
index 0000000..aa643a3
--- /dev/null
+++ b/build/import/libodb/stub.make
@@ -0,0 +1,30 @@
+# file : build/import/libodb/stub.make
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+# license : ODB NCUEL; see accompanying LICENSE file
+
+$(call include-once,$(scf_root)/import/libodb/configuration-rules.make,$(dcf_root))
+
+libodb_installed :=
+
+$(call -include,$(dcf_root)/import/libodb/configuration-dynamic.make)
+
+ifdef libodb_installed
+
+ifeq ($(libodb_installed),y)
+
+$(call export,l: -lodb,cpp-options: )
+
+else
+
+# Include export stub.
+#
+$(call include,$(scf_root)/export/libodb/stub.make)
+
+endif
+
+else
+
+.NOTPARALLEL:
+
+endif
diff --git a/makefile b/makefile
new file mode 100644
index 0000000..d5b6cd4
--- /dev/null
+++ b/makefile
@@ -0,0 +1,36 @@
+# file : 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
+
+dirs := odb/mssql
+
+default := $(out_base)/
+dist := $(out_base)/.dist
+clean := $(out_base)/.clean
+
+$(default): $(addprefix $(out_base)/,$(addsuffix /,$(dirs)))
+
+$(dist): export dirs := $(dirs)
+$(dist): export docs := GPLv2 LICENSE README NEWS version
+$(dist): data_dist := INSTALL libodb-mssql-vc9.sln libodb-mssql-vc10.sln
+$(dist): exec_dist := bootstrap
+$(dist): export extra_dist := $(data_dist) $(exec_dist)
+$(dist): export version = $(shell cat $(src_root)/version)
+
+$(dist): $(addprefix $(out_base)/,$(addsuffix /.dist,$(dirs)))
+ $(call dist-data,$(docs) $(data_dist) libodb-mssql.pc.in)
+ $(call dist-exec,$(exec_dist))
+ $(call dist-dir,m4)
+ $(call meta-automake)
+ $(call meta-autoconf)
+
+$(clean): $(addprefix $(out_base)/,$(addsuffix /.clean,$(dirs)))
+
+$(call include,$(bld_root)/dist.make)
+$(call include,$(bld_root)/meta/automake.make)
+$(call include,$(bld_root)/meta/autoconf.make)
+
+$(foreach d,$(dirs),$(call import,$(src_base)/$d/makefile))
diff --git a/odb/mssql/details/config.h.in b/odb/mssql/details/config.h.in
new file mode 100644
index 0000000..de88c81
--- /dev/null
+++ b/odb/mssql/details/config.h.in
@@ -0,0 +1,14 @@
+/* file : odb/mssql/details/config.h.in
+ * author : Constantin Michael <constantin@codesynthesis.com>
+ * copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+ * license : ODB NCUEL; see accompanying LICENSE file
+ */
+
+/* This file is automatically processed by configure. */
+
+#ifndef ODB_MSSQL_DETAILS_CONFIG_H
+#define ODB_MSSQL_DETAILS_CONFIG_H
+
+#undef LIBODB_MSSQL_STATIC_LIB
+
+#endif /* ODB_MSSQL_DETAILS_CONFIG_H */
diff --git a/odb/mssql/details/config.hxx b/odb/mssql/details/config.hxx
new file mode 100644
index 0000000..f66d567
--- /dev/null
+++ b/odb/mssql/details/config.hxx
@@ -0,0 +1,20 @@
+// file : odb/mssql/details/config.hxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+#ifndef ODB_MSSQL_DETAILS_CONFIG_HXX
+#define ODB_MSSQL_DETAILS_CONFIG_HXX
+
+// no pre
+
+#ifdef _MSC_VER
+#elif defined(ODB_COMPILER)
+# error libodb-mssql header included in odb-compiled header
+#else
+# include <odb/mssql/details/config.h>
+#endif
+
+// no post
+
+#endif // ODB_MSSQL_DETAILS_CONFIG_HXX
diff --git a/odb/mssql/details/export.hxx b/odb/mssql/details/export.hxx
new file mode 100644
index 0000000..3f24f3c
--- /dev/null
+++ b/odb/mssql/details/export.hxx
@@ -0,0 +1,41 @@
+// file : odb/mssql/details/export.hxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+#ifndef ODB_MSSQL_DETAILS_EXPORT_HXX
+#define ODB_MSSQL_DETAILS_EXPORT_HXX
+
+#include <odb/pre.hxx>
+
+#include <odb/mssql/details/config.hxx>
+
+#ifdef LIBODB_MSSQL_STATIC_LIB
+# define LIBODB_MSSQL_EXPORT
+#else
+# ifdef _WIN32
+# ifdef _MSC_VER
+# ifdef LIBODB_MSSQL_DYNAMIC_LIB
+# define LIBODB_MSSQL_EXPORT __declspec(dllexport)
+# else
+# define LIBODB_MSSQL_EXPORT __declspec(dllimport)
+# endif
+# else
+# ifdef LIBODB_MSSQL_DYNAMIC_LIB
+# ifdef DLL_EXPORT
+# define LIBODB_MSSQL_EXPORT __declspec(dllexport)
+# else
+# define LIBODB_MSSQL_EXPORT
+# endif
+# else
+# define LIBODB_MSSQL_EXPORT __declspec(dllimport)
+# endif
+# endif
+# else
+# define LIBODB_MSSQL_EXPORT
+# endif
+#endif
+
+#include <odb/post.hxx>
+
+#endif // ODB_MSSQL_DETAILS_EXPORT_HXX
diff --git a/odb/mssql/details/options.cli b/odb/mssql/details/options.cli
new file mode 100644
index 0000000..693f644
--- /dev/null
+++ b/odb/mssql/details/options.cli
@@ -0,0 +1,57 @@
+// file : odb/mssql/details/options.cli
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+include <string>;
+
+namespace odb
+{
+ namespace mssql
+ {
+ namespace details
+ {
+ class options
+ {
+ std::string --user | --username
+ {
+ "<name>",
+ "PostgreSQL database user."
+ };
+
+ std::string --password
+ {
+ "<str>",
+ "PostgreSQL database password."
+ };
+
+ std::string --database | --dbname
+ {
+ "<name>",
+ "PostgreSQL database name."
+ };
+
+ std::string --host
+ {
+ "<str>",
+ "PostgreSQL database host name or address (localhost by default)."
+ };
+
+ std::string --port
+ {
+ "<str>",
+ "PostgreSQL database port number or socket file name extension for
+ Unix-domain connections."
+ };
+
+ 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/odb/mssql/exceptions.cxx b/odb/mssql/exceptions.cxx
new file mode 100644
index 0000000..1b415a7
--- /dev/null
+++ b/odb/mssql/exceptions.cxx
@@ -0,0 +1,82 @@
+// file : odb/mssql/exceptions.cxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+#include <sstream>
+
+#include <odb/mssql/exceptions.hxx>
+
+using namespace std;
+
+namespace odb
+{
+ namespace mssql
+ {
+ //
+ // database_exception
+ //
+
+ database_exception::record::
+ record (SQLINTEGER e, const string& s, const string& m)
+ : error_ (e), sqlstate_ (s), message_ (m)
+ {
+ }
+
+ database_exception::
+ ~database_exception () throw ()
+ {
+ }
+
+ database_exception::
+ database_exception ()
+ {
+ }
+
+ database_exception::
+ database_exception (SQLINTEGER e, const string& s, const string& m)
+ {
+ append (e, s, m);
+ }
+
+ void database_exception::
+ append (SQLINTEGER e, const string& s, const string& m)
+ {
+ records_.push_back (record (e, s, m));
+
+ if (!what_.empty ())
+ what_ += '\n';
+
+ ostringstream ostr;
+ ostr << e << " (" << s << "): " << m;
+ what_ += ostr.str ();
+ }
+
+ const char* database_exception::
+ what () const throw ()
+ {
+ return what_.c_str ();
+ }
+
+ //
+ // cli_exception
+ //
+
+ cli_exception::
+ cli_exception (const string& what)
+ : what_ (what)
+ {
+ }
+
+ cli_exception::
+ ~cli_exception () throw ()
+ {
+ }
+
+ const char* cli_exception::
+ what () const throw ()
+ {
+ return what_.c_str ();
+ }
+ }
+}
diff --git a/odb/mssql/exceptions.hxx b/odb/mssql/exceptions.hxx
new file mode 100644
index 0000000..321a41d
--- /dev/null
+++ b/odb/mssql/exceptions.hxx
@@ -0,0 +1,116 @@
+// file : odb/mssql/exceptions.hxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+#ifndef ODB_MSSQL_EXCEPTIONS_HXX
+#define ODB_MSSQL_EXCEPTIONS_HXX
+
+#include <odb/pre.hxx>
+
+#include <string>
+#include <vector>
+
+#include <odb/exceptions.hxx>
+
+#include <odb/mssql/version.hxx>
+#include <odb/mssql/mssql-fwd.hxx>
+#include <odb/mssql/details/export.hxx>
+
+namespace odb
+{
+ namespace mssql
+ {
+ struct LIBODB_MSSQL_EXPORT database_exception: odb::database_exception
+ {
+ struct record
+ {
+ record (SQLINTEGER error,
+ const std::string& sqlstate,
+ const std::string& message);
+
+ SQLINTEGER
+ error () const
+ {
+ return error_;
+ }
+
+ const std::string&
+ sqlstate () const
+ {
+ return sqlstate_;
+ }
+
+ const std::string&
+ message () const
+ {
+ return message_;
+ }
+
+ private:
+ SQLINTEGER error_;
+ std::string sqlstate_;
+ std::string message_;
+ };
+
+ typedef std::vector<record> records;
+
+ typedef records::size_type size_type;
+ typedef records::const_iterator iterator;
+
+ iterator
+ begin () const
+ {
+ return records_.begin ();
+ }
+
+ iterator
+ end () const
+ {
+ return records_.end ();
+ }
+
+ size_type
+ size () const
+ {
+ return records_.size ();
+ }
+
+ virtual const char*
+ what () const throw ();
+
+ public:
+ ~database_exception () throw ();
+
+ database_exception ();
+ database_exception (SQLINTEGER error,
+ const std::string& sqlstate,
+ const std::string& message);
+
+ void
+ append (SQLINTEGER error,
+ const std::string& sqlstate,
+ const std::string& message);
+
+ private:
+ records records_;
+ std::string what_;
+ };
+
+ struct LIBODB_MSSQL_EXPORT cli_exception: odb::exception
+ {
+ cli_exception (const std::string& what);
+ ~cli_exception () throw ();
+
+ virtual const char*
+ what () const throw ();
+
+ private:
+ std::string what_;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_MSSQL_EXCEPTIONS_HXX
diff --git a/odb/mssql/forward.hxx b/odb/mssql/forward.hxx
new file mode 100644
index 0000000..c81ebf9
--- /dev/null
+++ b/odb/mssql/forward.hxx
@@ -0,0 +1,63 @@
+// file : odb/mssql/forward.hxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+#ifndef ODB_MSSQL_FORWARD_HXX
+#define ODB_MSSQL_FORWARD_HXX
+
+#include <odb/pre.hxx>
+
+#include <odb/forward.hxx>
+
+namespace odb
+{
+ namespace mssql
+ {
+ class database;
+ class connection;
+ typedef details::shared_ptr<connection> connection_ptr;
+ class connection_factory;
+ class statement;
+ class transaction;
+ class tracer;
+ class query;
+
+ // Implementation details.
+ //
+ enum statement_kind
+ {
+ statement_select,
+ statement_insert,
+ statement_update
+ };
+
+ class binding;
+ class select_statement;
+
+ template <typename T>
+ class object_statements;
+
+ template <typename T>
+ class object_statements_no_id;
+
+ template <typename T>
+ class view_statements;
+
+ template <typename T>
+ class container_statements;
+ }
+
+ namespace details
+ {
+ template <>
+ struct counter_type<mssql::connection>
+ {
+ typedef shared_base counter;
+ };
+ }
+}
+
+#include <odb/post.hxx>
+
+#endif // ODB_MSSQL_FORWARD_HXX
diff --git a/odb/mssql/makefile b/odb/mssql/makefile
new file mode 100644
index 0000000..98749c1
--- /dev/null
+++ b/odb/mssql/makefile
@@ -0,0 +1,131 @@
+# file : odb/mssql/makefile
+# author : Boris Kolpackov <boris@codesynthesis.com>
+# author : Constantin Michael <constantin@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 := \
+exceptions.cxx
+
+
+cli_tun := details/options.cli
+cxx_tun := $(cxx)
+cxx_obj := $(addprefix $(out_base)/,$(cxx_tun:.cxx=.o) $(cli_tun:.cli=.o))
+cxx_od := $(cxx_obj:.o=.o.d)
+
+odb_mssql.l := $(out_base)/odb-mssql.l
+odb_mssql.l.cpp-options := $(out_base)/odb-mssql.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)
+
+# @@ TODO
+#
+#$(call import,\
+# $(scf_root)/import/libpq/stub.make,\
+# l: pq.l,\
+# cpp-options: pq.l.cpp-options,\
+# cpp-options-inline: pq_cpp_options)
+
+# Build.
+#
+$(odb_mssql.l): $(cxx_obj) $(odb.l) -lodbc32 # @@ TODO
+$(odb_mssql.l.cpp-options): value := -I$(out_root) -I$(src_root)
+$(odb_mssql.l.cpp-options): $(odb.l.cpp-options)
+
+$(cxx_obj) $(cxx_od): $(odb_mssql.l.cpp-options) $(out_base)/details/config.h
+
+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 += \
+--long-usage \
+--generate-specifier \
+--generate-file-scanner \
+--cli-namespace odb::mssql::details::cli \
+--guard-prefix LIBODB_MSSQL_DETAILS
+
+$(out_base)/details/config.h: | $(out_base)/details/.
+ @echo '/* file : odb/mssql/details/config.h' >$@
+ @echo ' * author : automatically generated' >>$@
+ @echo ' */' >>$@
+ @echo '' >>$@
+ @echo '#ifndef ODB_MSSQL_DETAILS_CONFIG_H' >>$@
+ @echo '#define ODB_MSSQL_DETAILS_CONFIG_H' >>$@
+ @echo '' >>$@
+ @echo '#endif /* ODB_MSSQL_DETAILS_CONFIG_H */' >>$@
+
+$(call include-dep,$(cxx_od),$(cxx_obj),$(gen) $(out_base)/details/config.h)
+
+# Convenience alias for default target.
+#
+$(out_base)/: $(odb_mssql.l)
+
+# Dist.
+#
+$(dist): sources_dist := $(cxx)
+$(dist): export sources := $(sources_dist) $(cli_tun:.cli=.cxx)
+$(dist): headers_dist = $(subst $(src_base)/,,$(shell find $(src_base) \
+-name '*.hxx' -o -name '*.ixx' -o -name '*.txx'))
+$(dist): gen_headers := $(cli_tun:.cli=.hxx) $(cli_tun:.cli=.ixx)
+$(dist): export headers = $(sort $(headers_dist) $(gen_headers))
+$(dist): gen_dist := $(gen)
+$(dist): data_dist := $(cli_tun) details/config.h.in
+$(dist): export extra_dist := $(data_dist) libodb-mssql-vc9.vcproj \
+libodb-mssql-vc10.vcxproj libodb-mssql-vc10.vcxproj.filters
+$(dist): export interface_version = $(shell sed -e \
+'s/^\([0-9]*\.[0-9]*\).*/\1/' $(src_root)/version)
+
+$(dist): $(gen)
+ $(call dist-data,$(sources_dist) $(headers_dist) $(data_dist))
+ $(call dist-data,$(gen_dist),$(dist_prefix)/odb/mssql/details)
+ $(call meta-vc9proj,$(src_base)/libodb-mssql-vc9.vcproj)
+ $(call meta-vc10proj,$(src_base)/libodb-mssql-vc10.vcxproj)
+ $(call meta-automake)
+
+# Clean.
+#
+$(clean): $(odb_mssql.l).o.clean \
+ $(odb_mssql.l.cpp-options).clean \
+ $(addsuffix .cxx.clean,$(cxx_obj)) \
+ $(addsuffix .cxx.clean,$(cxx_od)) \
+ $(addprefix $(out_base)/,$(cli_tun:.cli=.cxx.cli.clean))
+ $(call message,rm $$1,rm -f $$1,$(out_base)/details/config.h)
+
+# Generated .gitignore.
+#
+ifeq ($(out_base),$(src_base))
+$(odb_mssql.l): | $(out_base)/.gitignore
+
+$(out_base)/.gitignore: files := details/config.h $(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,$(cli_rules))
+$(call include,$(bld_root)/cxx/o-l.make)
+$(call include,$(bld_root)/cxx/cxx-o.make)
+$(call include,$(bld_root)/cxx/cxx-d.make)
diff --git a/odb/mssql/mssql-fwd.hxx b/odb/mssql/mssql-fwd.hxx
new file mode 100644
index 0000000..434edb1
--- /dev/null
+++ b/odb/mssql/mssql-fwd.hxx
@@ -0,0 +1,22 @@
+// file : odb/mssql/mssql-fwd.hxx
+// author : Boris Kolpackov <boris@codesynthesis.com>
+// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
+// license : GNU GPL v2; see accompanying LICENSE file
+
+#ifndef ODB_MSSQL_MSSQL_FWD_HXX
+#define ODB_MSSQL_MSSQL_FWD_HXX
+
+#include <odb/pre.hxx>
+
+// Forward declaration for some of the types defined in sqltypes.h or
+// sqlncli.h. This allows us to avoid having to include these files
+// in public headers.
+//
+#ifdef _WIN32
+typedef long SQLINTEGER;
+typedef unsigned long SQLUINTEGER;
+#endif
+
+#include <odb/post.hxx>
+
+#endif // ODB_MSSQL_MSSQL_FWD_HXX
diff --git a/odb/mssql/odbc.hxx b/odb/mssql/odbc.hxx
new file mode 100644
index 0000000..91023b3
--- /dev/null
+++ b/odb/mssql/odbc.hxx
@@ -0,0 +1,25 @@
+// file : odb/mssql/odbc.hxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2009-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+#ifndef ODB_MSSQL_ODBC_HXX
+#define ODB_MSSQL_ODBC_HXX
+
+#include <odb/pre.hxx>
+
+#ifdef _WIN32
+# ifndef WIN32_LEAN_AND_MEAN
+# define WIN32_LEAN_AND_MEAN
+# endif
+# include <windows.h>
+#endif
+
+#include <sqlext.h> // Standard ODBC.
+
+//#define _SQLNCLI_ODBC_
+//#include <sqlncli.h> // SQL Server native client driver specifics.
+
+#include <odb/post.hxx>
+
+#endif // ODB_MSSQL_ODBC_HXX
diff --git a/odb/mssql/version.hxx b/odb/mssql/version.hxx
new file mode 100644
index 0000000..ca474ea
--- /dev/null
+++ b/odb/mssql/version.hxx
@@ -0,0 +1,45 @@
+// file : odb/mssql/version.hxx
+// author : Constantin Michael <constantin@codesynthesis.com>
+// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
+// license : ODB NCUEL; see accompanying LICENSE file
+
+#ifndef ODB_MSSQL_VERSION_HXX
+#define ODB_Mssql_VERSION_HXX
+
+#include <odb/pre.hxx>
+
+#include <odb/version.hxx>
+#include <odb/mssql/details/config.hxx>
+
+// Version format is AABBCCDD where
+//
+// AA - major version number
+// BB - minor version number
+// CC - bugfix version number
+// DD - alpha / beta (DD + 50) version number
+//
+// When DD is not 00, 1 is subtracted from AABBCC. For example:
+//
+// Version AABBCCDD
+// 2.0.0 02000000
+// 2.1.0 02010000
+// 2.1.1 02010100
+// 2.2.0.a1 02019901
+// 3.0.0.b2 02999952
+//
+
+// Check that we have compatible ODB version.
+//
+#if ODB_VERSION != 10601
+# error incompatible odb interface version detected
+#endif
+
+// libodb-mssql version: odb interface version plus the bugfix
+// version.
+//
+#define LIBODB_MSSQL_VERSION 1069901
+#define LIBODB_MSSQL_VERSION_STR "1.7.0.a1"
+
+#include <odb/post.hxx>
+
+#endif // ODB_MSSQL_VERSION_HXX