Renamed date/date_time to day_point/time_point

This commit is contained in:
rbock
2015-10-29 16:41:45 +01:00
parent 5e83929555
commit 84ab264702
11 changed files with 146 additions and 145 deletions

View File

@@ -28,8 +28,8 @@
#define SQLPP_COLUMN_TYPES_H
#include <sqlpp11/boolean.h>
#include <sqlpp11/date.h>
#include <sqlpp11/date_time.h>
#include <sqlpp11/day_point.h>
#include <sqlpp11/time_point.h>
#include <sqlpp11/integral.h>
#include <sqlpp11/floating_point.h>
#include <sqlpp11/text.h>

View File

@@ -39,8 +39,8 @@ namespace sqlpp
using mus_point = std::chrono::time_point<std::chrono::system_clock, std::chrono::microseconds>;
}
struct date;
struct date_time;
struct day_point;
struct time_point;
}
#endif

View File

@@ -24,11 +24,11 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SQLPP_DATE_H
#define SQLPP_DATE_H
#ifndef SQLPP_DAY_POINT_H
#define SQLPP_DAY_POINT_H
#include <date.h>
#include <sqlpp11/date_time.h>
#include <sqlpp11/time_point.h>
#include <sqlpp11/basic_expression_operators.h>
#include <sqlpp11/type_traits.h>
#include <sqlpp11/exception.h>
@@ -38,10 +38,10 @@
namespace sqlpp
{
// date value type
struct date
// day_point value type
struct day_point
{
using _traits = make_traits<date, tag::is_value_type>;
using _traits = make_traits<day_point, tag::is_value_type>;
using _tag = tag::is_date;
using _cpp_value_type = ::sqlpp::chrono::day_point;
@@ -51,11 +51,11 @@ namespace sqlpp
using _is_valid_assignment_operand = is_date_t<T>;
};
// date parameter value
// day_point parameter value
template <>
struct parameter_value_t<date>
struct parameter_value_t<day_point>
{
using _value_type = date;
using _value_type = day_point;
using _cpp_value_type = typename _value_type::_cpp_value_type;
parameter_value_t() : _value{}, _is_null(true)
@@ -120,28 +120,29 @@ namespace sqlpp
bool _is_null;
};
// date expression operators
// day_point expression operators
template <typename Base>
struct expression_operators<Base, date> : public basic_expression_operators<Base, date>
struct expression_operators<Base, day_point> : public basic_expression_operators<Base, day_point>
{
template <typename T>
using _is_valid_operand = is_valid_operand<date, T>;
using _is_valid_operand = is_valid_operand<day_point, T>;
};
// date column operators
// day_point column operators
template <typename Base>
struct column_operators<Base, date>
struct column_operators<Base, day_point>
{
template <typename T>
using _is_valid_operand = is_valid_operand<date, T>;
using _is_valid_operand = is_valid_operand<day_point, T>;
};
// date result field
// day_point result field
template <typename Db, typename FieldSpec>
struct result_field_t<date, Db, FieldSpec> : public result_field_methods_t<result_field_t<date, Db, FieldSpec>>
struct result_field_t<day_point, Db, FieldSpec>
: public result_field_methods_t<result_field_t<day_point, Db, FieldSpec>>
{
static_assert(std::is_same<value_type_of<FieldSpec>, date>::value, "field type mismatch");
using _cpp_value_type = typename sqlpp::date::_cpp_value_type;
static_assert(std::is_same<value_type_of<FieldSpec>, day_point>::value, "field type mismatch");
using _cpp_value_type = typename sqlpp::day_point::_cpp_value_type;
result_field_t() : _is_valid(false), _is_null(true), _value{}
{
@@ -206,10 +207,10 @@ namespace sqlpp
};
template <typename Context, typename Db, typename FieldSpec>
struct serializer_t<Context, result_field_t<date, Db, FieldSpec>>
struct serializer_t<Context, result_field_t<day_point, Db, FieldSpec>>
{
using _serialize_check = consistent_t;
using T = result_field_t<date, Db, FieldSpec>;
using T = result_field_t<day_point, Db, FieldSpec>;
static Context& _(const T& t, Context& context)
{
@@ -227,7 +228,7 @@ namespace sqlpp
};
template <typename Db, typename FieldSpec>
inline std::ostream& operator<<(std::ostream& os, const result_field_t<date, Db, FieldSpec>& e)
inline std::ostream& operator<<(std::ostream& os, const result_field_t<day_point, Db, FieldSpec>& e)
{
return serialize(e, os);
}

View File

@@ -24,8 +24,8 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef SQLPP_DATE_TIME_H
#define SQLPP_DATE_TIME_H
#ifndef SQLPP_TIME_POINT_H
#define SQLPP_TIME_POINT_H
#include <sqlpp11/date_time_fwd.h>
#include <sqlpp11/basic_expression_operators.h>
@@ -37,10 +37,10 @@
namespace sqlpp
{
// date_time value type
struct date_time
// time_point value type
struct time_point
{
using _traits = make_traits<date_time, tag::is_value_type>;
using _traits = make_traits<time_point, tag::is_value_type>;
using _tag = tag::is_date_time;
using _cpp_value_type = ::sqlpp::chrono::mus_point;
@@ -48,11 +48,11 @@ namespace sqlpp
using _is_valid_operand = is_time_point_t<T>;
};
// date_time parameter value
// time_point parameter value
template <>
struct parameter_value_t<date_time>
struct parameter_value_t<time_point>
{
using _value_type = date_time;
using _value_type = time_point;
using _cpp_value_type = typename _value_type::_cpp_value_type;
parameter_value_t() : _value{}, _is_null(true)
@@ -117,29 +117,29 @@ namespace sqlpp
bool _is_null;
};
// date_time expression operators
// time_point expression operators
template <typename Base>
struct expression_operators<Base, date_time> : public basic_expression_operators<Base, date_time>
struct expression_operators<Base, time_point> : public basic_expression_operators<Base, time_point>
{
template <typename T>
using _is_valid_operand = is_valid_operand<date_time, T>;
using _is_valid_operand = is_valid_operand<time_point, T>;
};
// date_time column operators
// time_point column operators
template <typename Base>
struct column_operators<Base, date_time>
struct column_operators<Base, time_point>
{
template <typename T>
using _is_valid_operand = is_valid_operand<date_time, T>;
using _is_valid_operand = is_valid_operand<time_point, T>;
};
// date_time result field
// time_point result field
template <typename Db, typename FieldSpec>
struct result_field_t<date_time, Db, FieldSpec>
: public result_field_methods_t<result_field_t<date_time, Db, FieldSpec>>
struct result_field_t<time_point, Db, FieldSpec>
: public result_field_methods_t<result_field_t<time_point, Db, FieldSpec>>
{
static_assert(std::is_same<value_type_of<FieldSpec>, date_time>::value, "field type mismatch");
using _cpp_value_type = typename date_time::_cpp_value_type;
static_assert(std::is_same<value_type_of<FieldSpec>, time_point>::value, "field type mismatch");
using _cpp_value_type = typename time_point::_cpp_value_type;
result_field_t() : _is_valid(false), _is_null(true), _value{}
{
@@ -204,10 +204,10 @@ namespace sqlpp
};
template <typename Context, typename Db, typename FieldSpec>
struct serializer_t<Context, result_field_t<date_time, Db, FieldSpec>>
struct serializer_t<Context, result_field_t<time_point, Db, FieldSpec>>
{
using _serialize_check = consistent_t;
using T = result_field_t<date_time, Db, FieldSpec>;
using T = result_field_t<time_point, Db, FieldSpec>;
static Context& _(const T& t, Context& context)
{
@@ -227,7 +227,7 @@ namespace sqlpp
};
template <typename Db, typename FieldSpec>
inline std::ostream& operator<<(std::ostream& os, const result_field_t<date_time, Db, FieldSpec>& e)
inline std::ostream& operator<<(std::ostream& os, const result_field_t<time_point, Db, FieldSpec>& e)
{
return serialize(e, os);
}

View File

@@ -85,27 +85,27 @@ namespace sqlpp
}
};
struct date_operand : public alias_operators<date_operand>
struct day_point_operand : public alias_operators<day_point_operand>
{
using _traits = make_traits<date, tag::is_expression, tag::is_wrapped_value>;
using _traits = make_traits<day_point, tag::is_expression, tag::is_wrapped_value>;
using _nodes = detail::type_vector<>;
using _is_aggregate_expression = std::true_type;
using _value_t = ::sqlpp::chrono::day_point;
date_operand() : _t{}
day_point_operand() : _t{}
{
}
date_operand(_value_t t) : _t(t)
day_point_operand(_value_t t) : _t(t)
{
}
date_operand(const date_operand&) = default;
date_operand(date_operand&&) = default;
date_operand& operator=(const date_operand&) = default;
date_operand& operator=(date_operand&&) = default;
~date_operand() = default;
day_point_operand(const day_point_operand&) = default;
day_point_operand(day_point_operand&&) = default;
day_point_operand& operator=(const day_point_operand&) = default;
day_point_operand& operator=(day_point_operand&&) = default;
~day_point_operand() = default;
bool _is_trivial() const
{
@@ -116,10 +116,10 @@ namespace sqlpp
};
template <typename Context>
struct serializer_t<Context, date_operand>
struct serializer_t<Context, day_point_operand>
{
using _serialize_check = consistent_t;
using Operand = date_operand;
using Operand = day_point_operand;
static Context& _(const Operand& t, Context& context)
{
@@ -130,27 +130,27 @@ namespace sqlpp
};
template <typename Period>
struct date_time_operand : public alias_operators<date_time_operand<Period>>
struct time_point_operand : public alias_operators<time_point_operand<Period>>
{
using _traits = make_traits<date_time, tag::is_expression, tag::is_wrapped_value>;
using _traits = make_traits<time_point, tag::is_expression, tag::is_wrapped_value>;
using _nodes = detail::type_vector<>;
using _is_aggregate_expression = std::true_type;
using _value_t = std::chrono::time_point<std::chrono::system_clock, Period>;
date_time_operand() : _t{}
time_point_operand() : _t{}
{
}
date_time_operand(_value_t t) : _t(t)
time_point_operand(_value_t t) : _t(t)
{
}
date_time_operand(const date_time_operand&) = default;
date_time_operand(date_time_operand&&) = default;
date_time_operand& operator=(const date_time_operand&) = default;
date_time_operand& operator=(date_time_operand&&) = default;
~date_time_operand() = default;
time_point_operand(const time_point_operand&) = default;
time_point_operand(time_point_operand&&) = default;
time_point_operand& operator=(const time_point_operand&) = default;
time_point_operand& operator=(time_point_operand&&) = default;
~time_point_operand() = default;
bool _is_trivial() const
{
@@ -161,10 +161,10 @@ namespace sqlpp
};
template <typename Context, typename Period>
struct serializer_t<Context, date_time_operand<Period>>
struct serializer_t<Context, time_point_operand<Period>>
{
using _serialize_check = consistent_t;
using Operand = date_time_operand<Period>;
using Operand = time_point_operand<Period>;
static Context& _(const Operand& t, Context& context)
{
@@ -320,13 +320,13 @@ namespace sqlpp
template <typename Period>
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, Period>, void>
{
using type = date_time_operand<Period>;
using type = time_point_operand<Period>;
};
template <>
struct wrap_operand<std::chrono::time_point<std::chrono::system_clock, sqlpp::chrono::days>, void>
{
using type = date_operand;
using type = day_point_operand;
};
template <typename T>