Commit 9d2d63cd authored by msobczak's avatar msobczak

Cleanup.

parent a6512c5a
# $Id: Makefile.am,v 1.6 2007/06/11 06:27:33 msobczak Exp $
# $Id: Makefile.am,v 1.7 2007/06/21 21:34:31 msobczak Exp $
#
# Copyright (C) 2006, Mateusz Loskot
#
......@@ -33,7 +33,9 @@ socidir = $(includedir)/soci
soci_HEADERS = \
blob.h \
into-row.h \
blob-exchange.h \
exchange-traits.h \
into.h \
into-type.h \
once-temp-type.h \
prepare-temp-type.h \
......@@ -41,7 +43,9 @@ soci_HEADERS = \
ref-counted-prepare-info.h \
ref-counted-statement.h \
row.h \
row-exchange.h \
rowid.h \
rowid-exchange.h \
rowset.h \
session.h \
soci-backend.h \
......@@ -50,10 +54,13 @@ soci_HEADERS = \
soci.h \
statement.h \
type-conversion.h \
type-conversion-traits.h \
type-holder.h \
type-ptr.h \
use.h \
use-type.h \
values.h
values.h \
values-exchange.h
EXTRA_DIST = Makefile.basic
......
......@@ -4,6 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_SOURCE
#include "blob.h"
#include "session.h"
......
......@@ -8,7 +8,9 @@
#ifndef SOCI_BLOB_H_INCLUDED
#define SOCI_BLOB_H_INCLUDED
#include "soci-backend.h"
#include "soci-config.h"
#include <cstddef>
namespace soci
{
......@@ -16,6 +18,11 @@ namespace soci
class session;
namespace details
{
class blob_backend;
} // namespace details
class SOCI_DECL blob
{
public:
......
//
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef BOOST_OPTIONAL_H_INCLUDED
#define BOOST_OPTIONAL_H_INCLUDED
#include "type-conversion-traits.h"
#include "exchange-traits.h"
#include <boost/optional.hpp>
namespace soci
{
// simple fall-back for boost::optional
template <typename T>
struct type_conversion<boost::optional<T> >
{
typedef typename type_conversion<T>::base_type base_type;
static void from_base(base_type const &in, eIndicator ind,
boost::optional<T> &out)
{
if (ind == eNull)
{
out.reset();
}
else
{
T tmp;
type_conversion<T>::from_base(in, ind, tmp);
out = tmp;
}
}
static void to_base(boost::optional<T> &in,
base_type &out, eIndicator &ind)
{
if (in.is_initialized())
{
type_conversion<T>::to_base(in.get(), out, ind);
}
else
{
ind = eNull;
}
}
};
namespace details
{
template <typename T>
struct exchange_traits<boost::optional<T> >
{
// this forces the conversion engine to kick in
typedef user_type_tag type_family;
enum { eXType = exchange_traits<T>::eXType };
};
} // namespace details
} // namespace soci
#endif // BOOST_OPTIONAL_H_INCLUDED
......@@ -4,17 +4,16 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_SOURCE
#include "soci-backend.h"
#include <stdexcept>
#include <string>
namespace soci
{
using namespace soci;
soci_error::soci_error(std::string const & msg)
: std::runtime_error(msg)
{
}
} // namespace soci
//
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef EXCHANGE_TRAITS_H_INCLUDED
#define EXCHANGE_TRAITS_H_INCLUDED
#include "type-conversion-traits.h"
#include "soci-backend.h"
#include <vector>
#include <boost/optional.hpp>
namespace soci
{
......@@ -19,6 +28,9 @@ struct exchange_traits
// this is used for tag-dispatch between implementations for basic types
// and user-defined types
typedef user_type_tag type_family;
enum { eXType =
exchange_traits<typename type_conversion<T>::base_type>::eXType };
};
template <>
......@@ -82,17 +94,6 @@ struct exchange_traits<std::tm>
enum { eXType = eXStdTm };
};
// for complete tag dispatch
template <typename T>
struct exchange_traits<boost::optional<T> >
{
// this forces the conversion engine to kick in
typedef user_type_tag type_family;
enum { eXType = exchange_traits<T>::eXType };
};
template <typename T>
struct exchange_traits<std::vector<T> >
{
......@@ -101,6 +102,7 @@ struct exchange_traits<std::vector<T> >
};
} // namespace details
} // namespace soci
#endif // EXCHANGE_TRAITS_H_INCLUDED
......@@ -4,6 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_SOURCE
#include "into-type.h"
#include "statement.h"
......
......@@ -17,10 +17,12 @@
namespace soci
{
class session;
namespace details
{
class prepare_temp_type;
class standard_into_type_backend;
class vector_into_type_backend;
......@@ -42,6 +44,7 @@ public:
virtual void resize(std::size_t /* sz */) {} // used for vectors only
};
typedef type_ptr<into_type_base> into_type_ptr;
// standard types
......
//
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef INTO_H_INCLUDED
#define INTO_H_INCLUDED
#include "into-type.h"
#include "exchange-traits.h"
#include "type-conversion.h"
namespace soci
......@@ -14,7 +22,8 @@ namespace soci
template <typename T>
details::into_type_ptr into(T &t)
{
return details::do_into(t, typename details::exchange_traits<T>::type_family());
return details::do_into(t,
typename details::exchange_traits<T>::type_family());
}
template <typename T>
......
......@@ -4,6 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_SOURCE
#include "once-temp-type.h"
#include "ref-counted-statement.h"
......
......@@ -8,15 +8,18 @@
#ifndef SOCI_ONCE_TEMP_TYPE_H_INCLUDED
#define SOCI_ONCE_TEMP_TYPE_H_INCLUDED
#include "ref-counted-statement.h"
#include "prepare-temp-type.h"
namespace soci
{
class session;
namespace details
{
class ref_counted_statement;
// this needs to be lightweight and copyable
class SOCI_DECL once_temp_type
{
......@@ -80,6 +83,7 @@ private:
};
} // namespace details
} // namespace soci
#endif
......@@ -4,6 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_SOURCE
#include "prepare-temp-type.h"
#include "ref-counted-prepare-info.h"
......
......@@ -14,6 +14,7 @@
namespace soci
{
namespace details
{
......@@ -43,8 +44,8 @@ private:
ref_counted_prepare_info *rcpi_;
};
} // namespace details
} // namespace soci
#endif
......@@ -4,6 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_SOURCE
#include "procedure.h"
#include "statement.h"
......
......@@ -12,6 +12,7 @@
namespace soci
{
namespace details
{
......
......@@ -4,6 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_SOURCE
#include "ref-counted-prepare-info.h"
......
......@@ -8,17 +8,18 @@
#ifndef SOCI_REF_COUNTED_PREPARE_INFO_INCLUDED
#define SOCI_REF_COUNTED_PREPARE_INFO_INCLUDED
#include "ref-counted-prepare-info.h"
#include "ref-counted-statement.h"
#include <vector>
namespace soci
{
class session;
namespace details
{
class procedure_impl;
class statement_impl;
class into_type_base;
......@@ -48,6 +49,7 @@ private:
};
} // namespace details
} // namespace soci
#endif
......@@ -4,6 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_SOURCE
#include "ref-counted-statement.h"
#include "statement.h"
......
......@@ -16,6 +16,7 @@
namespace soci
{
namespace details
{
......@@ -75,8 +76,8 @@ private:
statement st_;
};
} // namespace details
} // namespace soci
#endif
......@@ -9,22 +9,25 @@
#define SOCI_INTO_ROW_H_INCLUDED
#include "into-type.h"
#include "exchange-traits.h"
#include "row.h"
#include "statement.h"
namespace soci
{
namespace details
{
// Support selecting into a Row for dynamic queries
//
// Support selecting into a row for dynamic queries
template <>
class into_type<soci::row>
class into_type<row>
: public into_type_base // bypass the standard_into_type
{
public:
into_type(soci::row &r) : r_(r) {}
into_type(soci::row &r, eIndicator &ind) : r_(r) {}
into_type(row &r) : r_(r) {}
into_type(row &r, eIndicator &ind) : r_(r) {}
private:
// special handling for Row
......@@ -56,15 +59,17 @@ private:
virtual void convert_from_base() {}
soci::row &r_;
row &r_;
};
template <>
struct exchange_traits<soci::row>
struct exchange_traits<row>
{
typedef basic_type_tag type_family;
};
} // namespace details
} // namespace soci
#endif
......@@ -4,9 +4,9 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_SOURCE
#include "row.h"
#include "statement.h"
#include <sstream>
......
......@@ -10,8 +10,6 @@
#include "type-holder.h"
#include "soci-backend.h"
#include "into-type.h"
#include "use-type.h"
#include "type-conversion.h"
#include <string>
......
......@@ -11,6 +11,7 @@
#include "rowid.h"
#include "into-type.h"
#include "use-type.h"
#include "exchange-traits.h"
namespace soci
{
......
......@@ -4,6 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_SOURCE
#include "rowid.h"
#include "session.h"
......
......@@ -8,12 +8,20 @@
#ifndef SOCI_ROWID_H_INCLUDED
#define SOCI_ROWID_H_INCLUDED
#include "soci-backend.h"
#include "soci-config.h"
namespace soci
{
class session;
namespace details
{
class rowid_backend;
} // namespace details
// ROWID support
class SOCI_DECL rowid
......
......@@ -12,6 +12,7 @@
namespace soci
{
//
// rowset iterator of input category.
//
......
......@@ -4,6 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_SOURCE
#include "session.h"
#include "soci-backend.h"
......
......@@ -9,7 +9,6 @@
#define SOCI_SESSION_H_INCLUDED
#include "once-temp-type.h"
#include "prepare-temp-type.h"
#include <ostream>
#include <string>
......
......@@ -8,13 +8,13 @@
#ifndef SOCI_BACKEND_H_INCLUDED
#define SOCI_BACKEND_H_INCLUDED
#include "soci-config.h"
#include <cstddef>
#include <map>
#include <stdexcept>
#include <string>
#include "soci-config.h"
namespace soci
{
......@@ -207,4 +207,3 @@ struct SOCI_DECL backend_factory
} // namespace soci
#endif
......@@ -4,6 +4,7 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef SOCI_PLATFORM_H_INCLUDED
#define SOCI_PLATFORM_H_INCLUDED
......
......@@ -16,8 +16,9 @@
#include "blob.h"
#include "blob-exchange.h"
#include "boost-optional.h"
#include "exchange-traits.h"
#include "into.h"
#include "into-row.h"
#include "into-type.h"
#include "once-temp-type.h"
#include "prepare-temp-type.h"
......@@ -25,6 +26,7 @@
#include "ref-counted-prepare-info.h"
#include "ref-counted-statement.h"
#include "row.h"
#include "row-exchange.h"
#include "rowid.h"
#include "rowid-exchange.h"
#include "rowset.h"
......@@ -34,10 +36,12 @@
#include "soci-platform.h"
#include "statement.h"
#include "type-conversion.h"
#include "type-conversion-traits.h"
#include "type-holder.h"
#include "type-ptr.h"
#include "use.h"
#include "use-type.h"
#include "values.h"
#include "values-exchange.h"
#endif // SOCI_H_INCLUDED
......@@ -4,10 +4,11 @@
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#define SOCI_SOURCE
#include "statement.h"
#include "into-type.h"
#include "session.h"
#include "into-type.h"
#include "use-type.h"
#include "values.h"
......
......@@ -8,8 +8,8 @@
#ifndef SOCI_STATEMENT_H_INCLUDED
#define SOCI_STATEMENT_H_INCLUDED
#include "into.h"
#include "into-type.h"
#include "into.h"
#include "use-type.h"
#include "soci-backend.h"
#include "row.h"
......@@ -18,11 +18,13 @@
namespace soci
{
class session;
class values;
namespace details
{
class into_type_base;
class use_type_base;
class prepare_temp_type;
......
//
// Copyright (C) 2004-2007 Maciej Sobczak, Stephen Hutton
// Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at
// http://www.boost.org/LICENSE_1_0.txt)
//
#ifndef TYPE_CONVERSION_TRAITS_H_INCLUDED
#define TYPE_CONVERSION_TRAITS_H_INCLUDED
#include "soci-backend.h"
namespace soci
{
// default traits class type_conversion, acts as pass through for Row::get()
// when no actual conversion is needed.
template <typename T>
struct type_conversion
{
typedef T base_type;
static void from_base(base_type const &in, eIndicator ind, T &out)
{
if (ind == eNull)
{
throw soci_error("Null value not allowed for this type");
}
out = in;
}
static void to_base(T const &in, base_type &out, eIndicator &ind)
{
out = in;
ind = eOK;
}
};
} // namespace soci
#endif // TYPE_CONVERSION_TRAITS_H_INCLUDED
......@@ -8,71 +8,15 @@
#ifndef SOCI_TYPE_CONVERSION_H_INCLUDED
#define SOCI_TYPE_CONVERSION_H_INCLUDED
#include "type-conversion-traits.h"
#include "into-type.h"
#include "use-type.h"
#include <boost/optional.hpp>
#include <vector>
namespace soci
{
// default traits class type_conversion, acts as pass through for Row::get()
// when no actual conversion is needed.
template <typename T>
struct type_conversion
{
typedef T base_type;
static void from_base(base_type const &in, eIndicator ind, T &out)
{
if (ind == eNull)
{
throw soci_error("Null value not allowed for this type");
}
out = in;
}
static void to_base(T const &in, base_type &out, eIndicator &ind)
{
out = in;
ind = eOK;
}
};
// simple fall-back for boost::optional
template <typename T>
struct type_conversion<boost::optional<T> >
{
typedef typename type_conversion<T>::base_type base_type;
static void from_base(T const &in, eIndicator ind, boost::optional<T> &out)
{
if (ind == eNull)
{
out.reset();
}
else
{
T tmp;
type_conversion<T>::from_base(in, ind, tmp);
out = tmp;
}
}
static void to_base(boost::optional<T> const &in, T &out, eIndicator &ind)
{
if (in.is_initialized())
{
type_conversion<T>::to_base(in.get(), out, ind);
}
else
{
ind = eNull;
}
}
};
namespace details
{
......@@ -294,12 +238,25 @@ into_type_ptr do_into(T &t, user_type_tag)
return into_type_ptr(new conversion_into_type<T>(t));
}</