diff --git a/include/sqlpp11/boolean.h b/include/sqlpp11/boolean.h index 8358da7f..7959acc2 100644 --- a/include/sqlpp11/boolean.h +++ b/include/sqlpp11/boolean.h @@ -103,19 +103,19 @@ namespace sqlpp return _is_null; } - bool value() const + _cpp_value_type value() const { if (not _is_valid) throw exception("accessing value in non-existing row"); return _value; } - operator bool() const { return value(); } + operator _cpp_value_type() const { return value(); } private: bool _is_valid; bool _is_null; - bool _value; + _cpp_value_type _value; }; template diff --git a/include/sqlpp11/floating_point.h b/include/sqlpp11/floating_point.h index eb030ee9..c8926c9b 100644 --- a/include/sqlpp11/floating_point.h +++ b/include/sqlpp11/floating_point.h @@ -52,6 +52,13 @@ namespace sqlpp struct _result_entry_t { using _value_type = floating_point; + + _result_entry_t(): + _is_valid(false), + _is_null(true), + _value(0) + {} + _result_entry_t(const raw_result_row_t& row): _is_valid(row.data != nullptr), _is_null(row.data == nullptr or row.data[index] == nullptr), @@ -81,19 +88,19 @@ namespace sqlpp return _is_null; } - double value() const + _cpp_value_type value() const { if (not _is_valid) throw exception("accessing value in non-existing row"); return _value; } - operator double() const { return value(); } + operator _cpp_value_type() const { return value(); } private: bool _is_valid; bool _is_null; - double _value; + _cpp_value_type _value; }; struct plus_ diff --git a/include/sqlpp11/integral.h b/include/sqlpp11/integral.h index fca44822..524dbb74 100644 --- a/include/sqlpp11/integral.h +++ b/include/sqlpp11/integral.h @@ -52,6 +52,13 @@ namespace sqlpp struct _result_entry_t { using _value_type = integral; + + _result_entry_t(): + _is_valid(false), + _is_null(true), + _value(0) + {} + _result_entry_t(const raw_result_row_t& row): _is_valid(row.data != nullptr), _is_null(row.data == nullptr or row.data[index] == nullptr), @@ -81,19 +88,19 @@ namespace sqlpp return _is_null; } - int64_t value() const + _cpp_value_type value() const { if (not _is_valid) throw exception("accessing value in non-existing row"); return _value; } - operator int64_t() const { return value(); } + operator _cpp_value_type() const { return value(); } private: bool _is_valid; bool _is_null; - int64_t _value; + _cpp_value_type _value; }; template diff --git a/include/sqlpp11/text.h b/include/sqlpp11/text.h index e2470242..f8da60d6 100644 --- a/include/sqlpp11/text.h +++ b/include/sqlpp11/text.h @@ -54,14 +54,14 @@ namespace sqlpp _result_entry_t(const raw_result_row_t& row): _is_valid(row.data != nullptr), _is_null(row.data == nullptr or row.data[index] == nullptr), - _value(_is_null ? "" : std::string(row.data[index], row.data[index] + row.len[index])) + _value(_is_null ? "" : _cpp_value_type(row.data[index], row.data[index] + row.len[index])) {} _result_entry_t& operator=(const raw_result_row_t& row) { _is_valid = (row.data != nullptr); _is_null = row.data == nullptr or row.data[index] == nullptr; - _value = _is_null ? "" : std::string(row.data[index], row.data[index] + row.len[index]); + _value = _is_null ? "" : _cpp_value_type(row.data[index], row.data[index] + row.len[index]); return *this; } @@ -73,8 +73,8 @@ namespace sqlpp bool _is_trivial() const { return value().empty(); } - bool operator==(const std::string& rhs) const { return value() == rhs; } - bool operator!=(const std::string& rhs) const { return not operator==(rhs); } + bool operator==(const _cpp_value_type& rhs) const { return value() == rhs; } + bool operator!=(const _cpp_value_type& rhs) const { return not operator==(rhs); } bool is_null() const { @@ -83,19 +83,19 @@ namespace sqlpp return _is_null; } - std::string value() const + _cpp_value_type value() const { if (not _is_valid) throw exception("accessing value in non-existing row"); return _value; } - operator std::string() const { return value(); } + operator _cpp_value_type() const { return value(); } private: bool _is_valid; bool _is_null; - std::string _value; + _cpp_value_type _value; }; template