You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by dm...@apache.org on 2017/03/25 00:13:14 UTC
[34/56] [abbrv] ignite git commit: IGNITE-4690: CPP: Added
ignite::Time type
IGNITE-4690: CPP: Added ignite::Time type
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/02991d30
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/02991d30
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/02991d30
Branch: refs/heads/ignite-1192
Commit: 02991d3066b73c1a006afb55b4138e33a2e99ed3
Parents: 19ba8f4
Author: Igor Sapego <is...@gridgain.com>
Authored: Tue Mar 21 14:53:29 2017 +0300
Committer: Igor Sapego <is...@gridgain.com>
Committed: Tue Mar 21 14:53:29 2017 +0300
----------------------------------------------------------------------
.../include/ignite/binary/binary_raw_reader.h | 19 +
.../include/ignite/binary/binary_raw_writer.h | 15 +
.../include/ignite/binary/binary_reader.h | 21 +
.../include/ignite/binary/binary_writer.h | 17 +
.../include/ignite/impl/binary/binary_common.h | 6 +
.../ignite/impl/binary/binary_reader_impl.h | 128 ++-
.../include/ignite/impl/binary/binary_utils.h | 25 +-
.../ignite/impl/binary/binary_writer_impl.h | 46 +-
.../cpp/binary/src/binary/binary_raw_reader.cpp | 10 +
.../cpp/binary/src/binary/binary_raw_writer.cpp | 10 +
.../cpp/binary/src/binary/binary_reader.cpp | 12 +-
.../cpp/binary/src/binary/binary_writer.cpp | 10 +
.../src/impl/binary/binary_reader_impl.cpp | 177 +++-
.../cpp/binary/src/impl/binary/binary_utils.cpp | 12 +
.../src/impl/binary/binary_writer_impl.cpp | 105 ++-
modules/platforms/cpp/common/Makefile.am | 3 +-
.../platforms/cpp/common/include/Makefile.am | 1 +
.../cpp/common/include/ignite/common/utils.h | 53 +-
.../platforms/cpp/common/include/ignite/time.h | 138 +++
.../cpp/common/project/vs/common.vcxproj | 2 +
.../common/project/vs/common.vcxproj.filters | 6 +
.../platforms/cpp/common/src/common/utils.cpp | 30 +
modules/platforms/cpp/common/src/time.cpp | 83 ++
modules/platforms/cpp/core-test/Makefile.am | 1 +
.../cpp/core-test/config/cache-query.xml | 23 +
.../include/ignite/binary_test_utils.h | 53 ++
.../cpp/core-test/include/ignite/test_type.h | 11 +-
.../cpp/core-test/project/vs/core-test.vcxproj | 1 +
.../project/vs/core-test.vcxproj.filters | 3 +
.../cpp/core-test/src/binary_object_test.cpp | 110 +--
.../src/binary_reader_writer_raw_test.cpp | 712 +++------------
.../core-test/src/binary_reader_writer_test.cpp | 913 +++----------------
.../cpp/core-test/src/binary_session_test.cpp | 18 +
.../cpp/core-test/src/cache_query_test.cpp | 65 +-
.../platforms/cpp/core-test/src/cache_test.cpp | 12 +
.../cpp/core-test/src/date_time_test.cpp | 265 ++++++
36 files changed, 1491 insertions(+), 1625 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h
index d15848b..d110078 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_reader.h
@@ -275,6 +275,25 @@ namespace ignite
int32_t ReadTimestampArray(Timestamp* res, int32_t len);
/**
+ * Read Time. Maps to "Time" type in Java.
+ *
+ * @return Result.
+ */
+ Time ReadTime();
+
+ /**
+ * Read array of Times. Maps to "Time[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadTimeArray(Time* res, int32_t len);
+
+ /**
* Read string.
*
* @param res Array to store data to.
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h
index c960406..88a8014 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_raw_writer.h
@@ -230,6 +230,21 @@ namespace ignite
void WriteTimestampArray(const Timestamp* val, int32_t len);
/**
+ * Write Time. Maps to "Time" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteTime(const Time& val);
+
+ /**
+ * Write array of Time. Maps to "Time[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteTimeArray(const Time* val, const int32_t len);
+
+ /**
* Write string.
*
* @param val Null-terminated character array.
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h
index e4eb690..e07ec14 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_reader.h
@@ -296,6 +296,27 @@ namespace ignite
int32_t ReadTimestampArray(const char* fieldName, Timestamp* res, const int32_t len);
/**
+ * Read Time. Maps to "Time" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ Time ReadTime(const char* fieldName);
+
+ /**
+ * Read array of Times. Maps to "Time[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadTimeArray(const char* fieldName, Time* res, const int32_t len);
+
+ /**
* Read string.
*
* @param fieldName Field name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h b/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
index 1923694..e3962cf 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
@@ -248,6 +248,23 @@ namespace ignite
void WriteTimestampArray(const char* fieldName, const Timestamp* val, const int32_t len);
/**
+ * Write Time. Maps to "Time" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteTime(const char* fieldName, const Time& val);
+
+ /**
+ * Write array of Times. Maps to "Time[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteTimeArray(const char* fieldName, const Time* val, const int32_t len);
+
+ /**
* Write string.
*
* @param fieldName Field name.
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h
index aa15cc5..a4275c7 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_common.h
@@ -164,6 +164,12 @@ namespace ignite
/** Type: timestamp array. */
const int8_t IGNITE_TYPE_ARRAY_TIMESTAMP = 34;
+ /** Type: time. */
+ const int8_t IGNITE_TYPE_TIME = 36;
+
+ /** Type: time array. */
+ const int8_t IGNITE_TYPE_ARRAY_TIME = 37;
+
/** Read/write single object. */
const int32_t IGNITE_BINARY_MODE_SINGLE = 0;
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
index 814651d..242bb1e 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_reader_impl.h
@@ -33,6 +33,7 @@
#include "ignite/guid.h"
#include "ignite/date.h"
#include "ignite/timestamp.h"
+#include "ignite/time.h"
namespace ignite
{
@@ -513,6 +514,46 @@ namespace ignite
int32_t ReadTimestampArray(const char* fieldName, Timestamp* res, const int32_t len);
/**
+ * Read Time. Maps to "Time" type in Java.
+ *
+ * @return Result.
+ */
+ Time ReadTime();
+
+ /**
+ * Read array of Times. Maps to "Time[]" type in Java.
+ *
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadTimeArray(Time* res, int32_t len);
+
+ /**
+ * Read Time. Maps to "Time" type in Java.
+ *
+ * @param fieldName Field name.
+ * @return Result.
+ */
+ Time ReadTime(const char* fieldName);
+
+ /**
+ * Read array of Times. Maps to "Time[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param res Array to store data to.
+ * @param len Expected length of array.
+ * @return Actual amount of elements read. If "len" argument is less than actual
+ * array size or resulting array is set to null, nothing will be written
+ * to resulting array and returned value will contain required array length.
+ * -1 will be returned in case array in stream was null.
+ */
+ int32_t ReadTimeArray(const char* fieldName, Time* res, const int32_t len);
+
+ /**
* Read string.
*
* @param len Expected length of string.
@@ -1065,16 +1106,26 @@ namespace ignite
);
/**
+ * Internal routine to read Time array.
+ *
+ * @param stream Stream.
+ * @param res Resulting array.
+ * @param len Length.
+ */
+ static void ReadTimeArrayInternal(
+ interop::InteropInputStream* stream,
+ Time* res,
+ const int32_t len
+ );
+
+ /**
* Read single value in raw mode.
*
- * @param stream Stream.
* @param func Function to be invoked on stream.
* @return Result.
*/
template<typename T>
- T ReadRaw(
- T(*func) (interop::InteropInputStream*)
- )
+ T ReadRaw(T(*func)(interop::InteropInputStream*))
{
{
CheckRawMode(true);
@@ -1347,43 +1398,7 @@ namespace ignite
* @param func Function to be applied to the stream.
*/
template<typename T>
- T ReadTopObject0(const int8_t expHdr, T(*func) (ignite::impl::interop::InteropInputStream*))
- {
- int8_t typeId = stream->ReadInt8();
-
- if (typeId == expHdr)
- return func(stream);
- else if (typeId == IGNITE_HDR_NULL)
- return GetNull<T>();
- else {
- int32_t pos = stream->Position() - 1;
-
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)expHdr, "actual", (int)typeId)
- }
- }
-
- /**
- * Read value.
- *
- * @param expHdr Expected header.
- * @param func Function to be applied to the stream.
- * @param dflt Default value.
- */
- template<typename T>
- T ReadTopObject0(const int8_t expHdr, T(*func) (ignite::impl::interop::InteropInputStream*), T dflt)
- {
- int8_t typeId = stream->ReadInt8();
-
- if (typeId == expHdr)
- return func(stream);
- else if (typeId == IGNITE_HDR_NULL)
- return dflt;
- else {
- int32_t pos = stream->Position() - 1;
-
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)expHdr, "actual", (int)typeId)
- }
- }
+ T ReadTopObject0(const int8_t expHdr, T (*func)(ignite::impl::interop::InteropInputStream*));
};
template<>
@@ -1420,35 +1435,10 @@ namespace ignite
Timestamp IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Timestamp>();
template<>
- inline std::string IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<std::string>()
- {
- int8_t typeId = stream->ReadInt8();
-
- if (typeId == IGNITE_TYPE_STRING)
- {
- int32_t realLen = stream->ReadInt32();
-
- std::string res;
+ Time IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Time>();
- if (realLen > 0)
- {
- res.resize(realLen, 0);
-
- stream->ReadInt8Array(reinterpret_cast<int8_t*>(&res[0]), realLen);
- }
-
- return res;
- }
- else if (typeId == IGNITE_HDR_NULL)
- return std::string();
- else
- {
- int32_t pos = stream->Position() - 1;
-
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos,
- "expected", static_cast<int>(IGNITE_TYPE_STRING), "actual", static_cast<int>(typeId))
- }
- }
+ template<>
+ std::string IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<std::string>();
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
index b541483..6cd90b0 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_utils.h
@@ -25,6 +25,7 @@
#include "ignite/guid.h"
#include "ignite/date.h"
#include "ignite/timestamp.h"
+#include "ignite/time.h"
#include "ignite/binary/binary_type.h"
@@ -424,7 +425,7 @@ namespace ignite
* Utility method to read Timestamp from stream.
*
* @param stream Stream.
- * @param res Value.
+ * @return Value.
*/
static Timestamp ReadTimestamp(interop::InteropInputStream* stream);
@@ -437,6 +438,22 @@ namespace ignite
static void WriteTimestamp(interop::InteropOutputStream* stream, const Timestamp val);
/**
+ * Utility method to read Time from stream.
+ *
+ * @param stream Stream.
+ * @return Value.
+ */
+ static Time ReadTime(interop::InteropInputStream* stream);
+
+ /**
+ * Utility method to write Timestamp to stream.
+ *
+ * @param stream Stream.
+ * @param val Value.
+ */
+ static void WriteTime(interop::InteropOutputStream* stream, const Time val);
+
+ /**
* Utility method to write string to stream.
*
* @param stream Stream.
@@ -526,6 +543,12 @@ namespace ignite
}
template<>
+ inline Time BinaryUtils::GetDefaultValue<Time>()
+ {
+ return Time();
+ }
+
+ template<>
inline std::string BinaryUtils::GetDefaultValue<std::string>()
{
return std::string();
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
index fc38837..ea5f81f 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_writer_impl.h
@@ -424,6 +424,38 @@ namespace ignite
void WriteTimestampArray(const char* fieldName, const Timestamp* val, const int32_t len);
/**
+ * Write Time. Maps to "Time" type in Java.
+ *
+ * @param val Value.
+ */
+ void WriteTime(const Time& val);
+
+ /**
+ * Write array of Time. Maps to "Time[]" type in Java.
+ *
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteTimeArray(const Time* val, const int32_t len);
+
+ /**
+ * Write Time. Maps to "Time" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Value.
+ */
+ void WriteTime(const char* fieldName, const Time& val);
+
+ /**
+ * Write array of Times. Maps to "Time[]" type in Java.
+ *
+ * @param fieldName Field name.
+ * @param val Array.
+ * @param len Array length.
+ */
+ void WriteTimeArray(const char* fieldName, const Time* val, const int32_t len);
+
+ /**
* Write string.
*
* @param val String.
@@ -914,7 +946,7 @@ namespace ignite
/**
* Check whether session ID matches.
*
- * @param ses Expected session ID.
+ * @param expSes Expected session ID.
*/
void CheckSession(int32_t expSes) const;
@@ -975,16 +1007,10 @@ namespace ignite
void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Timestamp& obj);
template<>
- inline void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const std::string& obj)
- {
- const char* obj0 = obj.c_str();
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Time& obj);
- int32_t len = static_cast<int32_t>(obj.size());
-
- stream->WriteInt8(IGNITE_TYPE_STRING);
-
- BinaryUtils::WriteString(stream, obj0, len);
- }
+ template<>
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const std::string& obj);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/binary/binary_raw_reader.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/binary/binary_raw_reader.cpp b/modules/platforms/cpp/binary/src/binary/binary_raw_reader.cpp
index e472588..9c1d6d9 100644
--- a/modules/platforms/cpp/binary/src/binary/binary_raw_reader.cpp
+++ b/modules/platforms/cpp/binary/src/binary/binary_raw_reader.cpp
@@ -139,6 +139,16 @@ namespace ignite
return impl->ReadTimestampArray(res, len);
}
+ Time BinaryRawReader::ReadTime()
+ {
+ return impl->ReadTime();
+ }
+
+ int32_t BinaryRawReader::ReadTimeArray(Time* res, int32_t len)
+ {
+ return impl->ReadTimeArray(res, len);
+ }
+
int32_t BinaryRawReader::ReadString(char* res, const int32_t len)
{
return impl->ReadString(res, len);
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/binary/binary_raw_writer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/binary/binary_raw_writer.cpp b/modules/platforms/cpp/binary/src/binary/binary_raw_writer.cpp
index a83c74b..f2e94a5 100644
--- a/modules/platforms/cpp/binary/src/binary/binary_raw_writer.cpp
+++ b/modules/platforms/cpp/binary/src/binary/binary_raw_writer.cpp
@@ -139,6 +139,16 @@ namespace ignite
impl->WriteTimestampArray(val, len);
}
+ void BinaryRawWriter::WriteTime(const Time& val)
+ {
+ impl->WriteTime(val);
+ }
+
+ void BinaryRawWriter::WriteTimeArray(const Time* val, const int32_t len)
+ {
+ impl->WriteTimeArray(val, len);
+ }
+
void BinaryRawWriter::WriteString(const char* val)
{
if (val)
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/binary/binary_reader.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/binary/binary_reader.cpp b/modules/platforms/cpp/binary/src/binary/binary_reader.cpp
index 814db83..f9fa72e 100644
--- a/modules/platforms/cpp/binary/src/binary/binary_reader.cpp
+++ b/modules/platforms/cpp/binary/src/binary/binary_reader.cpp
@@ -138,7 +138,17 @@ namespace ignite
{
return impl->ReadTimestampArray(fieldName, res, len);
}
-
+
+ Time BinaryReader::ReadTime(const char* fieldName)
+ {
+ return impl->ReadTime(fieldName);
+ }
+
+ int32_t BinaryReader::ReadTimeArray(const char* fieldName, Time* res, const int32_t len)
+ {
+ return impl->ReadTimeArray(fieldName, res, len);
+ }
+
int32_t BinaryReader::ReadString(const char* fieldName, char* res, int32_t len)
{
return impl->ReadString(fieldName, res, len);
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/binary/binary_writer.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/binary/binary_writer.cpp b/modules/platforms/cpp/binary/src/binary/binary_writer.cpp
index efbc0ce..6c549bb 100644
--- a/modules/platforms/cpp/binary/src/binary/binary_writer.cpp
+++ b/modules/platforms/cpp/binary/src/binary/binary_writer.cpp
@@ -139,6 +139,16 @@ namespace ignite
impl->WriteTimestampArray(fieldName, val, len);
}
+ void BinaryWriter::WriteTime(const char* fieldName, const Time& val)
+ {
+ impl->WriteTime(fieldName, val);
+ }
+
+ void BinaryWriter::WriteTimeArray(const char* fieldName, const Time* val, const int32_t len)
+ {
+ impl->WriteTimeArray(fieldName, val, len);
+ }
+
void BinaryWriter::WriteString(const char* fieldName, const char* val)
{
if (val)
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
index c128df6..1c4104b 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_reader_impl.cpp
@@ -378,7 +378,63 @@ namespace ignite
void BinaryReaderImpl::ReadTimestampArrayInternal(interop::InteropInputStream* stream, Timestamp* res, const int32_t len)
{
for (int i = 0; i < len; i++)
- *(res + i) = ReadNullable<Timestamp>(stream, BinaryUtils::ReadTimestamp, IGNITE_TYPE_TIMESTAMP);
+ res[i] = ReadNullable<Timestamp>(stream, BinaryUtils::ReadTimestamp, IGNITE_TYPE_TIMESTAMP);
+ }
+
+ Time BinaryReaderImpl::ReadTime()
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ return ReadNullable(stream, BinaryUtils::ReadTime, IGNITE_TYPE_TIME);
+ }
+
+ int32_t BinaryReaderImpl::ReadTimeArray(Time * res, int32_t len)
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ return ReadArrayInternal<Time>(res, len, stream, ReadTimeArrayInternal, IGNITE_TYPE_ARRAY_TIME);
+ }
+
+ Time BinaryReaderImpl::ReadTime(const char * fieldName)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return Time();
+
+ stream->Position(fieldPos);
+
+ return ReadNullable(stream, BinaryUtils::ReadTime, IGNITE_TYPE_TIME);
+ }
+
+ int32_t BinaryReaderImpl::ReadTimeArray(const char * fieldName, Time * res, const int32_t len)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ int32_t fieldId = idRslvr->GetFieldId(typeId, fieldName);
+ int32_t fieldPos = FindField(fieldId);
+
+ if (fieldPos <= 0)
+ return -1;
+
+ stream->Position(fieldPos);
+
+ int32_t realLen = ReadArrayInternal<Time>(res, len, stream, ReadTimeArrayInternal, IGNITE_TYPE_ARRAY_TIME);
+
+ return realLen;
+ }
+
+ void BinaryReaderImpl::ReadTimeArrayInternal(interop::InteropInputStream* stream, Time* res, const int32_t len)
+ {
+ for (int i = 0; i < len; i++)
+ res[i] = ReadNullable<Time>(stream, BinaryUtils::ReadTime, IGNITE_TYPE_TIME);
}
int32_t BinaryReaderImpl::ReadString(char* res, const int32_t len)
@@ -692,73 +748,55 @@ namespace ignite
template <>
int8_t BinaryReaderImpl::ReadTopObject<int8_t>()
{
- return ReadTopObject0(IGNITE_TYPE_BYTE, BinaryUtils::ReadInt8,
- BinaryUtils::GetDefaultValue<int8_t>());
+ return ReadTopObject0<int8_t>(IGNITE_TYPE_BYTE, BinaryUtils::ReadInt8);
}
template <>
bool BinaryReaderImpl::ReadTopObject<bool>()
{
- return ReadTopObject0(IGNITE_TYPE_BOOL, BinaryUtils::ReadBool,
- BinaryUtils::GetDefaultValue<bool>());
+ return ReadTopObject0<bool>(IGNITE_TYPE_BOOL, BinaryUtils::ReadBool);
}
template <>
int16_t BinaryReaderImpl::ReadTopObject<int16_t>()
{
- return ReadTopObject0(IGNITE_TYPE_SHORT, BinaryUtils::ReadInt16,
- BinaryUtils::GetDefaultValue<int16_t>());
+ return ReadTopObject0<int16_t>(IGNITE_TYPE_SHORT, BinaryUtils::ReadInt16);
}
template <>
uint16_t BinaryReaderImpl::ReadTopObject<uint16_t>()
{
- return ReadTopObject0(IGNITE_TYPE_CHAR, BinaryUtils::ReadUInt16,
- BinaryUtils::GetDefaultValue<uint16_t>());
+ return ReadTopObject0<uint16_t>(IGNITE_TYPE_CHAR, BinaryUtils::ReadUInt16);
}
template <>
int32_t BinaryReaderImpl::ReadTopObject<int32_t>()
{
- return ReadTopObject0(IGNITE_TYPE_INT, BinaryUtils::ReadInt32,
- BinaryUtils::GetDefaultValue<int32_t>());
+ return ReadTopObject0<int32_t>(IGNITE_TYPE_INT, BinaryUtils::ReadInt32);
}
template <>
int64_t BinaryReaderImpl::ReadTopObject<int64_t>()
{
- return ReadTopObject0(IGNITE_TYPE_LONG, BinaryUtils::ReadInt64,
- BinaryUtils::GetDefaultValue<int64_t>());
+ return ReadTopObject0<int64_t>(IGNITE_TYPE_LONG, BinaryUtils::ReadInt64);
}
template <>
float BinaryReaderImpl::ReadTopObject<float>()
{
- return ReadTopObject0(IGNITE_TYPE_FLOAT, BinaryUtils::ReadFloat,
- BinaryUtils::GetDefaultValue<float>());
+ return ReadTopObject0<float>(IGNITE_TYPE_FLOAT, BinaryUtils::ReadFloat);
}
template <>
double BinaryReaderImpl::ReadTopObject<double>()
{
- return ReadTopObject0(IGNITE_TYPE_DOUBLE, BinaryUtils::ReadDouble,
- BinaryUtils::GetDefaultValue<double>());
+ return ReadTopObject0<double>(IGNITE_TYPE_DOUBLE, BinaryUtils::ReadDouble);
}
template <>
Guid BinaryReaderImpl::ReadTopObject<Guid>()
{
- int8_t typeId = stream->ReadInt8();
-
- if (typeId == IGNITE_TYPE_UUID)
- return BinaryUtils::ReadGuid(stream);
- else if (typeId == IGNITE_HDR_NULL)
- return BinaryUtils::GetDefaultValue<Guid>();
- else {
- int32_t pos = stream->Position() - 1;
-
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)IGNITE_TYPE_UUID, "actual", (int)typeId)
- }
+ return ReadTopObject0<Guid>(IGNITE_TYPE_UUID, BinaryUtils::ReadGuid);
}
template <>
@@ -775,23 +813,69 @@ namespace ignite
else {
int32_t pos = stream->Position() - 1;
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)IGNITE_TYPE_DATE, "actual", (int)typeId)
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY,
+ "Invalid header", "position", pos, "expected", (int)IGNITE_TYPE_DATE, "actual", (int)typeId)
}
}
template <>
Timestamp BinaryReaderImpl::ReadTopObject<Timestamp>()
{
+ return ReadTopObject0<Timestamp>(IGNITE_TYPE_TIMESTAMP, BinaryUtils::ReadTimestamp);
+ }
+
+ template<>
+ Time BinaryReaderImpl::ReadTopObject<Time>()
+ {
+ return ReadTopObject0<Time>(IGNITE_TYPE_TIME, BinaryUtils::ReadTime);
+ }
+
+ template<>
+ std::string BinaryReaderImpl::ReadTopObject<std::string>()
+ {
+ int8_t typeId = stream->ReadInt8();
+
+ if (typeId == IGNITE_TYPE_STRING)
+ {
+ int32_t realLen = stream->ReadInt32();
+
+ std::string res;
+
+ if (realLen > 0)
+ {
+ res.resize(realLen, 0);
+
+ stream->ReadInt8Array(reinterpret_cast<int8_t*>(&res[0]), realLen);
+ }
+
+ return res;
+ }
+ else if (typeId == IGNITE_HDR_NULL)
+ return std::string();
+ else
+ {
+ int32_t pos = stream->Position() - 1;
+
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos,
+ "expected", static_cast<int>(IGNITE_TYPE_STRING), "actual", static_cast<int>(typeId))
+ }
+ }
+
+ template <typename T>
+ T BinaryReaderImpl::ReadTopObject0(const int8_t expHdr, T(*func)(ignite::impl::interop::InteropInputStream*))
+ {
int8_t typeId = stream->ReadInt8();
- if (typeId == IGNITE_TYPE_TIMESTAMP)
- return BinaryUtils::ReadTimestamp(stream);
+ if (typeId == expHdr)
+ return func(stream);
else if (typeId == IGNITE_HDR_NULL)
- return BinaryUtils::GetDefaultValue<Timestamp>();
- else {
+ return BinaryUtils::GetDefaultValue<T>();
+ else
+ {
int32_t pos = stream->Position() - 1;
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)IGNITE_TYPE_TIMESTAMP, "actual", (int)typeId)
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY,
+ "Invalid header", "position", pos, "expected", (int)expHdr, "actual", (int)typeId)
}
}
@@ -814,9 +898,7 @@ namespace ignite
{
int32_t currentFieldId = stream->ReadInt32(schemaPos);
- if (fieldId != currentFieldId)
- continue;
- else
+ if (fieldId == currentFieldId)
return static_cast<uint8_t>(stream->ReadInt8(schemaPos + 4)) + pos;
}
break;
@@ -828,9 +910,7 @@ namespace ignite
{
int32_t currentFieldId = stream->ReadInt32(schemaPos);
- if (fieldId != currentFieldId)
- continue;
- else
+ if (fieldId == currentFieldId)
return static_cast<uint16_t>(stream->ReadInt16(schemaPos + 4)) + pos;
}
break;
@@ -842,9 +922,7 @@ namespace ignite
{
int32_t currentFieldId = stream->ReadInt32(schemaPos);
- if (fieldId != currentFieldId)
- continue;
- else
+ if (fieldId == currentFieldId)
return stream->ReadInt32(schemaPos + 4) + pos;
}
break;
@@ -867,10 +945,12 @@ namespace ignite
void BinaryReaderImpl::CheckSingleMode(bool expected) const
{
if (expected && elemId != 0) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Operation cannot be performed when container is being read.");
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY,
+ "Operation cannot be performed when container is being read.");
}
else if (!expected && elemId == 0) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Operation can be performed only when container is being read.");
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY,
+ "Operation can be performed only when container is being read.");
}
}
@@ -917,13 +997,16 @@ namespace ignite
void BinaryReaderImpl::CheckSession(int32_t expSes) const
{
if (elemId != expSes) {
- IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY, "Containter read session has been finished or is not started yet.");
+ IGNITE_ERROR_1(IgniteError::IGNITE_ERR_BINARY,
+ "Containter read session has been finished or is not started yet.");
}
}
void BinaryReaderImpl::ThrowOnInvalidHeader(int32_t pos, int8_t expHdr, int8_t hdr)
{
- IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY, "Invalid header", "position", pos, "expected", (int)expHdr, "actual", (int)hdr)
+ IGNITE_ERROR_FORMATTED_3(IgniteError::IGNITE_ERR_BINARY,
+ "Invalid header", "position", pos, "expected",
+ static_cast<int>(expHdr), "actual", static_cast<int>(hdr))
}
void BinaryReaderImpl::ThrowOnInvalidHeader(int8_t expHdr, int8_t hdr) const
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
index 5fe8d83..a583128 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_utils.cpp
@@ -328,6 +328,18 @@ namespace ignite
stream->WriteInt32(val.GetSecondFraction() % 1000000);
}
+ Time BinaryUtils::ReadTime(interop::InteropInputStream* stream)
+ {
+ int64_t ms = stream->ReadInt64();
+
+ return Time(ms);
+ }
+
+ void BinaryUtils::WriteTime(interop::InteropOutputStream* stream, const Time val)
+ {
+ stream->WriteInt64(val.GetMilliseconds());
+ }
+
void BinaryUtils::WriteString(interop::InteropOutputStream* stream, const char* val, const int32_t len)
{
stream->WriteInt32(len);
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp b/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
index b8f95b3..15e1ab9 100644
--- a/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
+++ b/modules/platforms/cpp/binary/src/impl/binary/binary_writer_impl.cpp
@@ -227,10 +227,8 @@ namespace ignite
for (int i = 0; i < len; i++)
{
- Guid elem = *(val + i);
-
stream->WriteInt8(IGNITE_TYPE_UUID);
- BinaryUtils::WriteGuid(stream, elem);
+ BinaryUtils::WriteGuid(stream, val[i]);
}
}
else
@@ -262,11 +260,7 @@ namespace ignite
stream->WriteInt32(len);
for (int i = 0; i < len; i++)
- {
- Guid elem = *(val + i);
-
- WriteTopObject(elem);
- }
+ WriteTopObject(val[i]);
}
else
{
@@ -296,10 +290,8 @@ namespace ignite
for (int i = 0; i < len; i++)
{
- const Date& elem = *(val + i);
-
stream->WriteInt8(IGNITE_TYPE_DATE);
- BinaryUtils::WriteDate(stream, elem);
+ BinaryUtils::WriteDate(stream, val[i]);
}
}
else
@@ -331,11 +323,7 @@ namespace ignite
stream->WriteInt32(len);
for (int i = 0; i < len; i++)
- {
- const Date& elem = *(val + i);
-
- WriteTopObject(elem);
- }
+ WriteTopObject(val[i]);
}
else
stream->WriteInt8(IGNITE_HDR_NULL);
@@ -363,10 +351,8 @@ namespace ignite
for (int i = 0; i < len; i++)
{
- const Timestamp& elem = *(val + i);
-
stream->WriteInt8(IGNITE_TYPE_TIMESTAMP);
- BinaryUtils::WriteTimestamp(stream, elem);
+ BinaryUtils::WriteTimestamp(stream, val[i]);
}
}
else
@@ -398,16 +384,73 @@ namespace ignite
stream->WriteInt32(len);
for (int i = 0; i < len; i++)
- {
- const Timestamp& elem = *(val + i);
+ WriteTopObject(val[i]);
+ }
+ else
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ }
+
+ void BinaryWriterImpl::WriteTime(const Time& val)
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ stream->WriteInt8(IGNITE_TYPE_TIME);
+
+ BinaryUtils::WriteTime(stream, val);
+ }
+
+ void BinaryWriterImpl::WriteTimeArray(const Time* val, const int32_t len)
+ {
+ CheckRawMode(true);
+ CheckSingleMode(true);
+
+ if (val)
+ {
+ stream->WriteInt8(IGNITE_TYPE_ARRAY_TIME);
+ stream->WriteInt32(len);
- WriteTopObject(elem);
+ for (int i = 0; i < len; i++)
+ {
+ stream->WriteInt8(IGNITE_TYPE_TIME);
+ BinaryUtils::WriteTime(stream, val[i]);
}
}
else
stream->WriteInt8(IGNITE_HDR_NULL);
}
+ void BinaryWriterImpl::WriteTime(const char* fieldName, const Time& val)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ WriteFieldId(fieldName, IGNITE_TYPE_TIME);
+
+ stream->WriteInt8(IGNITE_TYPE_TIME);
+
+ BinaryUtils::WriteTime(stream, val);
+ }
+
+ void BinaryWriterImpl::WriteTimeArray(const char* fieldName, const Time* val, const int32_t len)
+ {
+ CheckRawMode(false);
+ CheckSingleMode(true);
+
+ WriteFieldId(fieldName, IGNITE_TYPE_ARRAY_TIME);
+
+ if (val)
+ {
+ stream->WriteInt8(IGNITE_TYPE_ARRAY_TIME);
+ stream->WriteInt32(len);
+
+ for (int i = 0; i < len; i++)
+ WriteTopObject(val[i]);
+ }
+ else
+ stream->WriteInt8(IGNITE_HDR_NULL);
+ }
+
void BinaryWriterImpl::WriteString(const char* val, const int32_t len)
{
CheckRawMode(true);
@@ -705,6 +748,24 @@ namespace ignite
WriteTopObject0<Timestamp>(obj, BinaryUtils::WriteTimestamp, IGNITE_TYPE_TIMESTAMP);
}
+ template <>
+ void BinaryWriterImpl::WriteTopObject<Time>(const Time& obj)
+ {
+ WriteTopObject0<Time>(obj, BinaryUtils::WriteTime, IGNITE_TYPE_TIME);
+ }
+
+ template<>
+ void BinaryWriterImpl::WriteTopObject(const std::string& obj)
+ {
+ const char* obj0 = obj.c_str();
+
+ int32_t len = static_cast<int32_t>(obj.size());
+
+ stream->WriteInt8(IGNITE_TYPE_STRING);
+
+ BinaryUtils::WriteString(stream, obj0, len);
+ }
+
void BinaryWriterImpl::PostWrite()
{
int32_t lenWithoutSchema = stream->Position() - start;
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/Makefile.am b/modules/platforms/cpp/common/Makefile.am
index c4f4827..8515d5b 100644
--- a/modules/platforms/cpp/common/Makefile.am
+++ b/modules/platforms/cpp/common/Makefile.am
@@ -53,7 +53,8 @@ libignite_common_la_SOURCES = \
src/date.cpp \
src/ignite_error.cpp \
src/guid.cpp \
- src/timestamp.cpp
+ src/timestamp.cpp \
+ src/time.cpp
clean-local:
$(RM) *.gcno *.gcda
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/include/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/Makefile.am b/modules/platforms/cpp/common/include/Makefile.am
index 7f7ab83..cba68e9 100644
--- a/modules/platforms/cpp/common/include/Makefile.am
+++ b/modules/platforms/cpp/common/include/Makefile.am
@@ -32,6 +32,7 @@ nobase_include_HEADERS = \
ignite/guid.h \
ignite/ignite_error.h \
ignite/timestamp.h \
+ ignite/time.h \
ignite/reference.h
uninstall-hook:
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/include/ignite/common/utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/common/utils.h b/modules/platforms/cpp/common/include/ignite/common/utils.h
index bf1f39b..32d250f 100644
--- a/modules/platforms/cpp/common/include/ignite/common/utils.h
+++ b/modules/platforms/cpp/common/include/ignite/common/utils.h
@@ -29,6 +29,7 @@
#include <ignite/date.h>
#include <ignite/timestamp.h>
+#include "ignite/time.h"
#ifdef IGNITE_FRIEND
# define IGNITE_FRIEND_EXPORT IGNITE_EXPORT
@@ -217,7 +218,7 @@ namespace ignite
}
/**
- * Convert standard C type time_t to Date struct tm.
+ * Convert standard C type time_t to Date.
*
* @param ctime Standard C type time_t.
* @return Corresponding value of Date.
@@ -228,6 +229,17 @@ namespace ignite
}
/**
+ * Convert standard C type time_t to Time.
+ *
+ * @param ctime Standard C type time_t.
+ * @return Corresponding value of Time.
+ */
+ inline Time CTimeToTime(time_t ctime)
+ {
+ return Time(ctime * 1000);
+ }
+
+ /**
* Convert standard C type time_t to Timestamp type.
*
* @param ctime Standard C type time_t.
@@ -253,6 +265,19 @@ namespace ignite
}
/**
+ * Convert standard C type struct tm to Time type.
+ *
+ * @param ctime Standard C type struct tm.
+ * @return Corresponding value of Time.
+ */
+ inline Time CTmToTime(const tm& ctime)
+ {
+ time_t time = common::IgniteTimeGm(ctime);
+
+ return CTimeToTime(time);
+ }
+
+ /**
* Convert standard C type struct tm to Timestamp type.
*
* @param ctime Standard C type struct tm.
@@ -299,7 +324,31 @@ namespace ignite
int day = 1, int hour = 0, int min = 0, int sec = 0);
/**
- * Make Date in human understandable way.
+ * Make Time in human understandable way.
+ *
+ * Created Time uses GMT timezone.
+ *
+ * @param hour Hour.
+ * @param min Minute.
+ * @param sec Second.
+ * @return Time.
+ */
+ Time MakeTimeGmt(int hour = 0, int min = 0, int sec = 0);
+
+ /**
+ * Make Time in human understandable way.
+ *
+ * Created Time uses Local timezone.
+ *
+ * @param hour Hour.
+ * @param min Minute.
+ * @param sec Second.
+ * @return Time.
+ */
+ Time MakeTimeLocal(int hour = 0, int min = 0, int sec = 0);
+
+ /**
+ * Make Timestamp in human understandable way.
*
* Created Timestamp uses GMT timezone.
*
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/include/ignite/time.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/include/ignite/time.h b/modules/platforms/cpp/common/include/ignite/time.h
new file mode 100644
index 0000000..b922c6a
--- /dev/null
+++ b/modules/platforms/cpp/common/include/ignite/time.h
@@ -0,0 +1,138 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * @file
+ * Declares ignite::Time class.
+ */
+
+#ifndef _IGNITE_TIME
+#define _IGNITE_TIME
+
+#include <stdint.h>
+
+#include <ignite/common/common.h>
+
+namespace ignite
+{
+ /**
+ * %Time type.
+ */
+ class IGNITE_IMPORT_EXPORT Time
+ {
+ public:
+ /**
+ * Default constructor.
+ */
+ Time();
+
+ /**
+ * Copy constructor.
+ *
+ * @param another Another instance.
+ */
+ Time(const Time& another);
+
+ /**
+ * Constructor.
+ *
+ * @param ms Time in milliseconds since 00:00:00 UTC.
+ */
+ Time(int64_t ms);
+
+ /**
+ * Copy operator.
+ *
+ * @param another Another instance.
+ * @return This.
+ */
+ Time& operator=(const Time& another);
+
+ /**
+ * Returns number of milliseconds since 00:00:00 UTC.
+ *
+ * @return Number of milliseconds since 00:00:00 UTC.
+ */
+ int64_t GetMilliseconds() const;
+
+ /**
+ * Returns number of seconds since 00:00:00 UTC.
+ *
+ * @return Number of seconds since 00:00:00 UTC.
+ */
+ int64_t GetSeconds() const;
+
+ /**
+ * Comparison operator override.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if equal.
+ */
+ friend bool IGNITE_IMPORT_EXPORT operator==(const Time& val1, const Time& val2);
+
+ /**
+ * Comparison operator override.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if not equal.
+ */
+ friend bool IGNITE_IMPORT_EXPORT operator!=(const Time& val1, const Time& val2);
+
+ /**
+ * Comparison operator override.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if less.
+ */
+ friend bool IGNITE_IMPORT_EXPORT operator<(const Time& val1, const Time& val2);
+
+ /**
+ * Comparison operator override.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if less or equal.
+ */
+ friend bool IGNITE_IMPORT_EXPORT operator<=(const Time& val1, const Time& val2);
+
+ /**
+ * Comparison operator override.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if gretter.
+ */
+ friend bool IGNITE_IMPORT_EXPORT operator>(const Time& val1, const Time& val2);
+
+ /**
+ * Comparison operator override.
+ *
+ * @param val1 First value.
+ * @param val2 Second value.
+ * @return True if gretter or equal.
+ */
+ friend bool IGNITE_IMPORT_EXPORT operator>=(const Time& val1, const Time& val2);
+ private:
+ /** Time in milliseconds since 00:00:00 UTC. */
+ int64_t milliseconds;
+ };
+}
+
+#endif //_IGNITE_TIME
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/project/vs/common.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/common.vcxproj b/modules/platforms/cpp/common/project/vs/common.vcxproj
index 45ac15e..3062112 100644
--- a/modules/platforms/cpp/common/project/vs/common.vcxproj
+++ b/modules/platforms/cpp/common/project/vs/common.vcxproj
@@ -179,6 +179,7 @@
<ClInclude Include="..\..\include\ignite\guid.h" />
<ClInclude Include="..\..\include\ignite\ignite_error.h" />
<ClInclude Include="..\..\include\ignite\reference.h" />
+ <ClInclude Include="..\..\include\ignite\time.h" />
<ClInclude Include="..\..\include\ignite\timestamp.h" />
<ClInclude Include="..\..\os\win\include\ignite\common\common.h" />
<ClInclude Include="..\..\os\win\include\ignite\common\concurrent_os.h" />
@@ -196,6 +197,7 @@
<ClCompile Include="..\..\src\date.cpp" />
<ClCompile Include="..\..\src\guid.cpp" />
<ClCompile Include="..\..\src\ignite_error.cpp" />
+ <ClCompile Include="..\..\src\time.cpp" />
<ClCompile Include="..\..\src\timestamp.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/project/vs/common.vcxproj.filters b/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
index 1613d5d..ed709f7 100644
--- a/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
+++ b/modules/platforms/cpp/common/project/vs/common.vcxproj.filters
@@ -64,6 +64,9 @@
<ClInclude Include="..\..\include\ignite\common\platform_utils.h">
<Filter>Code\common</Filter>
</ClInclude>
+ <ClInclude Include="..\..\include\ignite\time.h">
+ <Filter>Code</Filter>
+ </ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\src\date.cpp">
@@ -102,5 +105,8 @@
<ClCompile Include="..\..\src\common\utils.cpp">
<Filter>Code\common</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\time.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
</ItemGroup>
</Project>
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/src/common/utils.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/common/utils.cpp b/modules/platforms/cpp/common/src/common/utils.cpp
index 2b425c1..786d0fb 100644
--- a/modules/platforms/cpp/common/src/common/utils.cpp
+++ b/modules/platforms/cpp/common/src/common/utils.cpp
@@ -119,6 +119,36 @@ namespace ignite
return CTimeToDate(localTime);
}
+ Time MakeTimeGmt(int hour, int min, int sec)
+ {
+ tm date = { 0 };
+
+ date.tm_year = 70;
+ date.tm_mon = 0;
+ date.tm_mday = 1;
+ date.tm_hour = hour;
+ date.tm_min = min;
+ date.tm_sec = sec;
+
+ return CTmToTime(date);
+ }
+
+ Time MakeTimeLocal(int hour, int min, int sec)
+ {
+ tm date = { 0 };
+
+ date.tm_year = 70;
+ date.tm_mon = 0;
+ date.tm_mday = 1;
+ date.tm_hour = hour;
+ date.tm_min = min;
+ date.tm_sec = sec;
+
+ time_t localTime = common::IgniteTimeLocal(date);
+
+ return CTimeToTime(localTime);
+ }
+
Timestamp MakeTimestampGmt(int year, int month, int day,
int hour, int min, int sec, long ns)
{
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/common/src/time.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/common/src/time.cpp b/modules/platforms/cpp/common/src/time.cpp
new file mode 100644
index 0000000..a37a9c9
--- /dev/null
+++ b/modules/platforms/cpp/common/src/time.cpp
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ignite/time.h"
+
+namespace ignite
+{
+ Time::Time() : milliseconds(0)
+ {
+ // No-op.
+ }
+
+ Time::Time(const Time& another) : milliseconds(another.milliseconds)
+ {
+ // No-op.
+ }
+
+ Time::Time(int64_t ms) : milliseconds(ms)
+ {
+ // No-op.
+ }
+
+ Time& Time::operator=(const Time& another)
+ {
+ milliseconds = another.milliseconds;
+
+ return *this;
+ }
+
+ int64_t Time::GetMilliseconds() const
+ {
+ return milliseconds;
+ }
+
+ int64_t Time::GetSeconds() const
+ {
+ return milliseconds / 1000;
+ }
+
+ bool operator==(const Time& val1, const Time& val2)
+ {
+ return val1.milliseconds == val2.milliseconds;
+ }
+
+ bool operator!=(const Time& val1, const Time& val2)
+ {
+ return val1.milliseconds != val2.milliseconds;
+ }
+
+ bool operator<(const Time& val1, const Time& val2)
+ {
+ return val1.milliseconds < val2.milliseconds;
+ }
+
+ bool operator<=(const Time& val1, const Time& val2)
+ {
+ return val1.milliseconds <= val2.milliseconds;
+ }
+
+ bool operator>(const Time& val1, const Time& val2)
+ {
+ return val1.milliseconds > val2.milliseconds;
+ }
+
+ bool operator>=(const Time& val1, const Time& val2)
+ {
+ return val1.milliseconds >= val2.milliseconds;
+ }
+}
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/Makefile.am
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/Makefile.am b/modules/platforms/cpp/core-test/Makefile.am
index 873db71..25dee58 100644
--- a/modules/platforms/cpp/core-test/Makefile.am
+++ b/modules/platforms/cpp/core-test/Makefile.am
@@ -73,6 +73,7 @@ ignite_tests_SOURCES = \
src/binary_reader_writer_raw_test.cpp \
src/binary_reader_writer_test.cpp \
src/binary_session_test.cpp \
+ src/date_time_test.cpp \
src/decimal_test.cpp \
src/dynamic_size_array_test.cpp \
src/fixed_size_array_test.cpp \
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/config/cache-query.xml
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/config/cache-query.xml b/modules/platforms/cpp/core-test/config/cache-query.xml
index bb18f7c..036c464 100644
--- a/modules/platforms/cpp/core-test/config/cache-query.xml
+++ b/modules/platforms/cpp/core-test/config/cache-query.xml
@@ -99,6 +99,29 @@
</list>
</property>
</bean>
+
+ <bean class="org.apache.ignite.configuration.CacheConfiguration">
+ <property name="name" value="TimeCache"/>
+ <property name="cacheMode" value="PARTITIONED"/>
+ <property name="atomicityMode" value="TRANSACTIONAL"/>
+ <property name="writeSynchronizationMode" value="FULL_SYNC"/>
+
+ <property name="affinity">
+ <bean class="org.apache.ignite.cache.affinity.rendezvous.RendezvousAffinityFunction">
+ <property name="partitions" value="256"/>
+ </bean>
+ </property>
+
+ <!-- Configure type metadata to enable queries. -->
+ <property name="queryEntities">
+ <list>
+ <bean class="org.apache.ignite.cache.QueryEntity">
+ <property name="keyType" value="java.lang.Integer"/>
+ <property name="valueType" value="java.sql.Time"/>
+ </bean>
+ </list>
+ </property>
+ </bean>
</list>
</property>
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h b/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h
index bcec9fe..7701253 100644
--- a/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h
+++ b/modules/platforms/cpp/core-test/include/ignite/binary_test_utils.h
@@ -30,6 +30,11 @@ namespace ignite_test
{
namespace binary
{
+ inline bool IsBinaryError(const IgniteError& err)
+ {
+ return err.GetCode() == IgniteError::IGNITE_ERR_BINARY;
+ }
+
template<typename T>
inline void Write(BinaryRawWriter& writer, T val)
{
@@ -163,6 +168,18 @@ namespace ignite_test
}
template<>
+ inline void Write(BinaryRawWriter& writer, Time val)
+ {
+ writer.WriteTime(val);
+ }
+
+ template<>
+ inline Time Read(BinaryRawReader& reader)
+ {
+ return reader.ReadTime();
+ }
+
+ template<>
inline void Write(BinaryRawWriter& writer, Timestamp val)
{
writer.WriteTimestamp(val);
@@ -307,6 +324,18 @@ namespace ignite_test
}
template<>
+ inline void WriteArray(BinaryRawWriter& writer, Time* val, int32_t len)
+ {
+ writer.WriteTimeArray(val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryRawReader& reader, Time* val, int32_t len)
+ {
+ return reader.ReadTimeArray(val, len);
+ }
+
+ template<>
inline void WriteArray(BinaryRawWriter& writer, Timestamp* val, int32_t len)
{
writer.WriteTimestampArray(val, len);
@@ -451,6 +480,18 @@ namespace ignite_test
}
template<>
+ inline void Write(BinaryWriter& writer, const char* fieldName, Time val)
+ {
+ writer.WriteTime(fieldName, val);
+ }
+
+ template<>
+ inline Time Read(BinaryReader& reader, const char* fieldName)
+ {
+ return reader.ReadTime(fieldName);
+ }
+
+ template<>
inline void Write(BinaryWriter& writer, const char* fieldName, Timestamp val)
{
writer.WriteTimestamp(fieldName, val);
@@ -595,6 +636,18 @@ namespace ignite_test
}
template<>
+ inline void WriteArray(BinaryWriter& writer, const char* fieldName, Time* val, int32_t len)
+ {
+ writer.WriteTimeArray(fieldName, val, len);
+ }
+
+ template<>
+ inline int32_t ReadArray(BinaryReader& reader, const char* fieldName, Time* val, int32_t len)
+ {
+ return reader.ReadTimeArray(fieldName, val, len);
+ }
+
+ template<>
inline void WriteArray(BinaryWriter& writer, const char* fieldName, Timestamp* val, int32_t len)
{
writer.WriteTimestampArray(fieldName, val, len);
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/include/ignite/test_type.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/include/ignite/test_type.h b/modules/platforms/cpp/core-test/include/ignite/test_type.h
index b399afe..7c7e6a2 100644
--- a/modules/platforms/cpp/core-test/include/ignite/test_type.h
+++ b/modules/platforms/cpp/core-test/include/ignite/test_type.h
@@ -37,6 +37,7 @@ namespace ignite
doubleField(0.0),
boolField(false),
dateField(),
+ timeField(),
timestampField()
{
// No-op.
@@ -45,7 +46,7 @@ namespace ignite
TestType(int8_t i8Field, int16_t i16Field, int32_t i32Field,
int64_t i64Field, const std::string& strField, float floatField,
double doubleField, bool boolField, const Guid& guidField,
- const Date& dateField, const Timestamp& timestampField) :
+ const Date& dateField, const Time& timeField, const Timestamp& timestampField) :
allNulls(false),
i8Field(i8Field),
i16Field(i16Field),
@@ -57,6 +58,7 @@ namespace ignite
boolField(boolField),
guidField(guidField),
dateField(dateField),
+ timeField(timeField),
timestampField(timestampField)
{
// No-op.
@@ -76,6 +78,7 @@ namespace ignite
one.boolField == two.boolField &&
one.guidField == two.guidField &&
one.dateField == two.dateField &&
+ one.timeField == two.timeField &&
one.timestampField == two.timestampField &&
one.i8ArrayField == two.i8ArrayField;
}
@@ -91,6 +94,7 @@ namespace ignite
bool boolField;
Guid guidField;
Date dateField;
+ Time timeField;
Timestamp timestampField;
std::vector<int8_t> i8ArrayField;
};
@@ -125,6 +129,7 @@ namespace ignite
writer.WriteBool("boolField", obj.boolField);
writer.WriteGuid("guidField", obj.guidField);
writer.WriteDate("dateField", obj.dateField);
+ writer.WriteTime("timeField", obj.timeField);
writer.WriteTimestamp("timestampField", obj.timestampField);
if (obj.i8ArrayField.empty())
{
@@ -147,6 +152,7 @@ namespace ignite
writer.WriteNull("boolField");
writer.WriteNull("guidField");
writer.WriteNull("dateField");
+ writer.WriteNull("timeField");
writer.WriteNull("timestampField");
writer.WriteNull("i8ArrayField");
}
@@ -164,11 +170,12 @@ namespace ignite
bool boolField = reader.ReadBool("boolField");
Guid guidField = reader.ReadGuid("guidField");
Date dateField = reader.ReadDate("dateField");
+ Time timeField = reader.ReadTime("timeField");
Timestamp timestampField = reader.ReadTimestamp("timestampField");
TestType result(i8Field, i16Field, i32Field, i64Field, strField,
floatField, doubleField, boolField, guidField, dateField,
- timestampField);
+ timeField, timestampField);
int32_t len = reader.ReadInt8Array("i8ArrayField", 0, 0);
if (len > 0)
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
index 4d252b9..f22e885 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj
@@ -50,6 +50,7 @@
<ClCompile Include="..\..\src\cluster_test.cpp" />
<ClCompile Include="..\..\src\cache_invoke_test.cpp" />
<ClCompile Include="..\..\src\concurrent_test.cpp" />
+ <ClCompile Include="..\..\src\date_time_test.cpp" />
<ClCompile Include="..\..\src\decimal_test.cpp" />
<ClCompile Include="..\..\src\dynamic_size_array_test.cpp" />
<ClCompile Include="..\..\src\fixed_size_array_test.cpp" />
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
index c318644..fb0be1b 100644
--- a/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
+++ b/modules/platforms/cpp/core-test/project/vs/core-test.vcxproj.filters
@@ -79,6 +79,9 @@
<ClCompile Include="..\..\src\test_utils.cpp">
<Filter>Code</Filter>
</ClCompile>
+ <ClCompile Include="..\..\src\date_time_test.cpp">
+ <Filter>Code</Filter>
+ </ClCompile>
<ClCompile Include="..\..\src\cache_store_test.cpp">
<Filter>Code</Filter>
</ClCompile>
http://git-wip-us.apache.org/repos/asf/ignite/blob/02991d30/modules/platforms/cpp/core-test/src/binary_object_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_object_test.cpp b/modules/platforms/cpp/core-test/src/binary_object_test.cpp
index fb3725f..6378266 100644
--- a/modules/platforms/cpp/core-test/src/binary_object_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_object_test.cpp
@@ -112,119 +112,12 @@ void CheckData(const T& obj)
BOOST_AUTO_TEST_SUITE(BinaryObjectTestSuite)
-#ifdef CHECK_BINARY_OBJECT_WITH_PRIMITIVES
-
-BOOST_AUTO_TEST_CASE(PrimitiveInt8)
-{
- CheckSimple<int8_t>(0);
- CheckSimple<int8_t>(INT8_MAX);
- CheckSimple<int8_t>(INT8_MIN);
- CheckSimple<int8_t>(42);
- CheckSimple<int8_t>(-12);
- CheckSimple<int8_t>(0x7D);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveInt16)
-{
- CheckSimple<int32_t>(0);
- CheckSimple<int32_t>(INT16_MAX);
- CheckSimple<int32_t>(INT16_MIN);
- CheckSimple<int32_t>(42);
- CheckSimple<int32_t>(12321);
- CheckSimple<int32_t>(0x7AB0);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveInt32)
-{
- CheckSimple<int32_t>(0);
- CheckSimple<int32_t>(INT32_MAX);
- CheckSimple<int32_t>(INT32_MIN);
- CheckSimple<int32_t>(42);
- CheckSimple<int32_t>(1337);
- CheckSimple<int32_t>(0xA2496BC9);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveInt64)
-{
- CheckSimple<int64_t>(0);
- CheckSimple<int64_t>(INT64_MAX);
- CheckSimple<int64_t>(INT64_MIN);
- CheckSimple<int64_t>(42);
- CheckSimple<int64_t>(13371337133713371337LL);
- CheckSimple<int64_t>(0xA928673F501CC09E);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveBool)
-{
- CheckSimple<bool>(true);
- CheckSimple<bool>(false);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveFloat)
-{
- CheckSimple<float>(0.0);
- CheckSimple<float>(1E38f);
- CheckSimple<float>(-1E38f);
- CheckSimple<float>(1E-38f);
- CheckSimple<float>(-1E-38f);
- CheckSimple<float>(42.0f);
- CheckSimple<float>(42.42f);
- CheckSimple<float>(1337.1337f);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveDouble)
-{
- CheckSimple<double>(0);
- CheckSimple<double>(1E127);
- CheckSimple<double>(-1E127);
- CheckSimple<double>(1E-127);
- CheckSimple<double>(-1E-127);
- CheckSimple<double>(42);
- CheckSimple<double>(42.42);
- CheckSimple<double>(1337.1337 * 1337.1337);
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveString)
-{
- CheckSimple<std::string>("");
- CheckSimple<std::string>("Lorem ipsum");
- CheckSimple<std::string>("Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do "
- "eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, "
- "quis nostrud exercitation");
-
- CheckSimple<std::string>(std::string(1000, '.'));
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveGuid)
-{
- CheckSimple<Guid>(Guid(0, 0));
- CheckSimple<Guid>(Guid(0xFFFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF));
- CheckSimple<Guid>(Guid(0x4F9039DEF0FB8000, 0x905AE8A2D6FD49C1));
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveDate)
-{
- CheckSimpleNP<Date>(Date(0));
- CheckSimpleNP<Date>(common::MakeDateGmt(1998, 12, 3, 18, 32, 01));
- CheckSimpleNP<Date>(common::MakeDateGmt(2017, 1, 18, 20, 50, 41));
- CheckSimpleNP<Date>(common::MakeDateLocal(1998, 12, 3, 18, 32, 01));
-}
-
-BOOST_AUTO_TEST_CASE(PrimitiveTimestamp)
-{
- CheckSimpleNP<Timestamp>(Timestamp(0));
- CheckSimpleNP<Timestamp>(common::MakeTimestampGmt(1998, 12, 3, 18, 32, 01, 593846589));
- CheckSimpleNP<Timestamp>(common::MakeTimestampGmt(2017, 1, 18, 20, 50, 41, 920700532));
- CheckSimpleNP<Timestamp>(common::MakeTimestampLocal(1998, 12, 3, 18, 32, 01, 2385));
-}
-
-#endif //CHECK_BINARY_OBJECT_WITH_PRIMITIVES
-
BOOST_AUTO_TEST_CASE(UserTestType)
{
CheckSimpleNP(TestType());
CheckSimpleNP(TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9),
common::MakeDateGmt(1987, 6, 5),
+ common::MakeTimeGmt(13, 32, 9),
common::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456)));
}
@@ -270,6 +163,7 @@ BOOST_AUTO_TEST_CASE(UserTestTypeGetData)
CheckData(TestType());
CheckData(TestType(1, 2, 3, 4, "5", 6.0f, 7.0, true, Guid(8, 9),
common::MakeDateGmt(1987, 6, 5),
+ common::MakeTimeGmt(13, 32, 9),
common::MakeTimestampGmt(1998, 12, 27, 1, 2, 3, 456)));
}