You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ignite.apache.org by ag...@apache.org on 2017/08/01 09:27:25 UTC
[40/50] [abbrv] ignite git commit: IGNITE-5758: CPP: Added pointers
semantics for primitive types
IGNITE-5758: CPP: Added pointers semantics for primitive types
Project: http://git-wip-us.apache.org/repos/asf/ignite/repo
Commit: http://git-wip-us.apache.org/repos/asf/ignite/commit/1597a186
Tree: http://git-wip-us.apache.org/repos/asf/ignite/tree/1597a186
Diff: http://git-wip-us.apache.org/repos/asf/ignite/diff/1597a186
Branch: refs/heads/ignite-5757
Commit: 1597a186e9d158d12e7e35e9db1158e5252c2e04
Parents: ab899cf
Author: Igor Sapego <is...@gridgain.com>
Authored: Fri Jul 28 13:51:25 2017 +0300
Committer: Igor Sapego <is...@gridgain.com>
Committed: Fri Jul 28 13:51:25 2017 +0300
----------------------------------------------------------------------
.../include/ignite/binary/binary_writer.h | 4 +-
.../ignite/impl/binary/binary_reader_impl.h | 50 ++++---
.../ignite/impl/binary/binary_type_impl.h | 67 +++++++++
.../ignite/impl/binary/binary_writer_impl.h | 43 ++++--
.../src/impl/binary/binary_reader_impl.cpp | 63 ++++-----
.../src/impl/binary/binary_writer_impl.cpp | 41 +++---
.../src/binary_reader_writer_raw_test.cpp | 36 +++++
.../core-test/src/binary_reader_writer_test.cpp | 135 ++++++++++++++-----
.../cpp/core/include/ignite/impl/ignite_impl.h | 6 -
.../platforms/cpp/core/src/impl/ignite_impl.cpp | 4 +
10 files changed, 326 insertions(+), 123 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ignite/blob/1597a186/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 1489494..e609591 100644
--- a/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
+++ b/modules/platforms/cpp/binary/include/ignite/binary/binary_writer.h
@@ -58,7 +58,7 @@ namespace ignite
*
* @param impl Implementation.
*/
- BinaryWriter(ignite::impl::binary::BinaryWriterImpl* impl);
+ BinaryWriter(impl::binary::BinaryWriterImpl* impl);
/**
* Write 8-byte signed integer. Maps to "byte" type in Java.
@@ -337,7 +337,7 @@ namespace ignite
* Start collection write.
*
* @param fieldName Field name.
- * @param type Collection type.
+ * @param typ Collection type.
* @return Collection writer.
*/
template<typename T>
http://git-wip-us.apache.org/repos/asf/ignite/blob/1597a186/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 5621c0d..4a0e2d4 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
@@ -884,6 +884,17 @@ namespace ignite
template<typename T>
T ReadTopObject()
{
+ return ignite::binary::ReadHelper<T>::Read(*this);
+ }
+
+ /**
+ * Read object.
+ *
+ * @return Read object.
+ */
+ template<typename T>
+ void ReadTopObject0(T& res)
+ {
int32_t pos = stream->Position();
int8_t hdr = stream->ReadInt8();
@@ -891,7 +902,9 @@ namespace ignite
{
case IGNITE_HDR_NULL:
{
- return GetNull<T>();
+ res = GetNull<T>();
+
+ return;
}
case IGNITE_HDR_HND:
@@ -908,11 +921,11 @@ namespace ignite
stream->Position(curPos + portOff); // Position stream right on the object.
- T val = ReadTopObject<T>();
+ ReadTopObject0<T>(res);
stream->Position(curPos + portLen + 4); // Position stream after binary.
- return val;
+ return;
}
case IGNITE_HDR_FULL:
@@ -985,12 +998,11 @@ namespace ignite
footerBegin, footerEnd, schemaType);
ignite::binary::BinaryReader reader(&readerImpl);
- T val;
- BType::Read(reader, val);
+ BType::Read(reader, res);
stream->Position(pos + len);
- return val;
+ return;
}
default:
@@ -1407,43 +1419,43 @@ namespace ignite
};
template<>
- int8_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<int8_t>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<int8_t>(int8_t& res);
template<>
- bool IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<bool>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<bool>(bool& res);
template<>
- int16_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<int16_t>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<int16_t>(int16_t& res);
template<>
- uint16_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<uint16_t>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<uint16_t>(uint16_t& res);
template<>
- int32_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<int32_t>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<int32_t>(int32_t& res);
template<>
- int64_t IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<int64_t>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<int64_t>(int64_t& res);
template<>
- float IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<float>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<float>(float& res);
template<>
- double IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<double>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<double>(double& res);
template<>
- Guid IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Guid>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<Guid>(Guid& res);
template<>
- Date IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Date>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<Date>(Date& res);
template<>
- Timestamp IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Timestamp>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<Timestamp>(Timestamp& res);
template<>
- Time IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<Time>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<Time>(Time& res);
template<>
- std::string IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject<std::string>();
+ void IGNITE_IMPORT_EXPORT BinaryReaderImpl::ReadTopObject0<std::string>(std::string& res);
template<>
inline int8_t BinaryReaderImpl::GetNull() const
http://git-wip-us.apache.org/repos/asf/ignite/blob/1597a186/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
index 2548a83..3183d4b 100644
--- a/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
+++ b/modules/platforms/cpp/binary/include/ignite/impl/binary/binary_type_impl.h
@@ -18,6 +18,7 @@
#ifndef _IGNITE_IMPL_BINARY_BINARY_TYPE_IMPL
#define _IGNITE_IMPL_BINARY_BINARY_TYPE_IMPL
+#include <memory>
#include <stdint.h>
#include <ignite/ignite_error.h>
@@ -55,6 +56,72 @@ namespace ignite
static void Read(BinaryReader& reader, IgniteError& dst);
};
+
+ /**
+ * Write helper. Takes care of proper writing of pointers.
+ */
+ template<typename T>
+ struct WriteHelper
+ {
+ template<typename W>
+ static void Write(W& writer, const T& val)
+ {
+ writer.WriteTopObject0(val);
+ }
+ };
+
+ /**
+ * Specialization for the pointer case.
+ */
+ template<typename T>
+ struct WriteHelper<T*>
+ {
+ template<typename W>
+ static void Write(W& writer, const T* val)
+ {
+ if (!val)
+ writer.WriteNull0();
+ else
+ writer.WriteTopObject0(*val);
+ }
+ };
+
+ /**
+ * Read helper. Takes care of proper reading of pointers.
+ */
+ template<typename T>
+ struct ReadHelper
+ {
+ template<typename R>
+ static T Read(R& reader)
+ {
+ T res;
+
+ reader.template ReadTopObject0<T>(res);
+
+ return res;
+ }
+ };
+
+ /**
+ * Specialization for the pointer case.
+ */
+ template<typename T>
+ struct ReadHelper<T*>
+ {
+ template<typename R>
+ static T* Read(R& reader)
+ {
+ if (reader.SkipIfNull())
+ return 0;
+
+ std::auto_ptr<T> res(new T());
+
+ reader.template ReadTopObject0<T>(*res);
+
+ return res.release();
+ }
+ };
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1597a186/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 32801ec..d896f3e 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
@@ -510,6 +510,11 @@ namespace ignite
void WriteNull(const char* fieldName);
/**
+ * Write NULL value.
+ */
+ void WriteNull0();
+
+ /**
* Start array write.
*
* @param typ Collection type.
@@ -681,6 +686,18 @@ namespace ignite
template<typename T>
void WriteTopObject(const T& obj)
{
+ ignite::binary::WriteHelper<T>::Write(*this, obj);
+ }
+
+ /**
+ * Write object.
+ * Does not work for primitive pointer types.
+ *
+ * @param obj Object to write.
+ */
+ template<typename T>
+ void WriteTopObject0(const T& obj)
+ {
typedef ignite::binary::BinaryType<T> BType;
if (BType::IsNull(obj))
@@ -982,43 +999,43 @@ namespace ignite
};
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const int8_t& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const int8_t& obj);
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const bool& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const bool& obj);
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const int16_t& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const int16_t& obj);
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const uint16_t& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const uint16_t& obj);
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const int32_t& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const int32_t& obj);
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const int64_t& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const int64_t& obj);
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const float& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const float& obj);
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const double& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const double& obj);
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Guid& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const Guid& obj);
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Date& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const Date& obj);
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Timestamp& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const Timestamp& obj);
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const Time& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const Time& obj);
template<>
- void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject(const std::string& obj);
+ void IGNITE_IMPORT_EXPORT BinaryWriterImpl::WriteTopObject0(const std::string& obj);
}
}
}
http://git-wip-us.apache.org/repos/asf/ignite/blob/1597a186/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 c6bb4f3..6fd5aea 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
@@ -721,9 +721,6 @@ namespace ignite
bool BinaryReaderImpl::SkipIfNull()
{
- CheckRawMode(true);
- CheckSingleMode(true);
-
InteropStreamPositionGuard<InteropInputStream> positionGuard(*stream);
int8_t hdr = stream->ReadInt8();
@@ -746,70 +743,70 @@ namespace ignite
}
template <>
- int8_t BinaryReaderImpl::ReadTopObject<int8_t>()
+ void BinaryReaderImpl::ReadTopObject0<int8_t>(int8_t& res)
{
- return ReadTopObject0<int8_t>(IGNITE_TYPE_BYTE, BinaryUtils::ReadInt8);
+ res = ReadTopObject0<int8_t>(IGNITE_TYPE_BYTE, BinaryUtils::ReadInt8);
}
template <>
- bool BinaryReaderImpl::ReadTopObject<bool>()
+ void BinaryReaderImpl::ReadTopObject0<bool>(bool& res)
{
- return ReadTopObject0<bool>(IGNITE_TYPE_BOOL, BinaryUtils::ReadBool);
+ res = ReadTopObject0<bool>(IGNITE_TYPE_BOOL, BinaryUtils::ReadBool);
}
template <>
- int16_t BinaryReaderImpl::ReadTopObject<int16_t>()
+ void BinaryReaderImpl::ReadTopObject0<int16_t>(int16_t& res)
{
- return ReadTopObject0<int16_t>(IGNITE_TYPE_SHORT, BinaryUtils::ReadInt16);
+ res = ReadTopObject0<int16_t>(IGNITE_TYPE_SHORT, BinaryUtils::ReadInt16);
}
template <>
- uint16_t BinaryReaderImpl::ReadTopObject<uint16_t>()
+ void BinaryReaderImpl::ReadTopObject0<uint16_t>(uint16_t& res)
{
- return ReadTopObject0<uint16_t>(IGNITE_TYPE_CHAR, BinaryUtils::ReadUInt16);
+ res = ReadTopObject0<uint16_t>(IGNITE_TYPE_CHAR, BinaryUtils::ReadUInt16);
}
template <>
- int32_t BinaryReaderImpl::ReadTopObject<int32_t>()
+ void BinaryReaderImpl::ReadTopObject0<int32_t>(int32_t& res)
{
- return ReadTopObject0<int32_t>(IGNITE_TYPE_INT, BinaryUtils::ReadInt32);
+ res = ReadTopObject0<int32_t>(IGNITE_TYPE_INT, BinaryUtils::ReadInt32);
}
template <>
- int64_t BinaryReaderImpl::ReadTopObject<int64_t>()
+ void BinaryReaderImpl::ReadTopObject0<int64_t>(int64_t& res)
{
- return ReadTopObject0<int64_t>(IGNITE_TYPE_LONG, BinaryUtils::ReadInt64);
+ res = ReadTopObject0<int64_t>(IGNITE_TYPE_LONG, BinaryUtils::ReadInt64);
}
template <>
- float BinaryReaderImpl::ReadTopObject<float>()
+ void BinaryReaderImpl::ReadTopObject0<float>(float& res)
{
- return ReadTopObject0<float>(IGNITE_TYPE_FLOAT, BinaryUtils::ReadFloat);
+ res = ReadTopObject0<float>(IGNITE_TYPE_FLOAT, BinaryUtils::ReadFloat);
}
template <>
- double BinaryReaderImpl::ReadTopObject<double>()
+ void BinaryReaderImpl::ReadTopObject0<double>(double& res)
{
- return ReadTopObject0<double>(IGNITE_TYPE_DOUBLE, BinaryUtils::ReadDouble);
+ res = ReadTopObject0<double>(IGNITE_TYPE_DOUBLE, BinaryUtils::ReadDouble);
}
template <>
- Guid BinaryReaderImpl::ReadTopObject<Guid>()
+ void BinaryReaderImpl::ReadTopObject0<Guid>(Guid& res)
{
- return ReadTopObject0<Guid>(IGNITE_TYPE_UUID, BinaryUtils::ReadGuid);
+ res = ReadTopObject0<Guid>(IGNITE_TYPE_UUID, BinaryUtils::ReadGuid);
}
template <>
- Date BinaryReaderImpl::ReadTopObject<Date>()
+ void BinaryReaderImpl::ReadTopObject0<Date>(Date& res)
{
int8_t typeId = stream->ReadInt8();
if (typeId == IGNITE_TYPE_DATE)
- return BinaryUtils::ReadDate(stream);
+ res = BinaryUtils::ReadDate(stream);
else if (typeId == IGNITE_TYPE_TIMESTAMP)
- return Date(BinaryUtils::ReadTimestamp(stream).GetMilliseconds());
+ res = Date(BinaryUtils::ReadTimestamp(stream).GetMilliseconds());
else if (typeId == IGNITE_HDR_NULL)
- return BinaryUtils::GetDefaultValue<Date>();
+ res = BinaryUtils::GetDefaultValue<Date>();
else {
int32_t pos = stream->Position() - 1;
@@ -819,19 +816,19 @@ namespace ignite
}
template <>
- Timestamp BinaryReaderImpl::ReadTopObject<Timestamp>()
+ void BinaryReaderImpl::ReadTopObject0<Timestamp>(Timestamp& res)
{
- return ReadTopObject0<Timestamp>(IGNITE_TYPE_TIMESTAMP, BinaryUtils::ReadTimestamp);
+ res = ReadTopObject0<Timestamp>(IGNITE_TYPE_TIMESTAMP, BinaryUtils::ReadTimestamp);
}
template<>
- Time BinaryReaderImpl::ReadTopObject<Time>()
+ void BinaryReaderImpl::ReadTopObject0<Time>(Time& res)
{
- return ReadTopObject0<Time>(IGNITE_TYPE_TIME, BinaryUtils::ReadTime);
+ res = ReadTopObject0<Time>(IGNITE_TYPE_TIME, BinaryUtils::ReadTime);
}
template<>
- std::string BinaryReaderImpl::ReadTopObject<std::string>()
+ void BinaryReaderImpl::ReadTopObject0<std::string>(std::string& res)
{
int8_t typeId = stream->ReadInt8();
@@ -839,19 +836,15 @@ namespace ignite
{
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();
+ res.clear();
else
{
int32_t pos = stream->Position() - 1;
http://git-wip-us.apache.org/repos/asf/ignite/blob/1597a186/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 f93f0d3..2ac783a 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
@@ -260,7 +260,7 @@ namespace ignite
stream->WriteInt32(len);
for (int i = 0; i < len; i++)
- WriteTopObject(val[i]);
+ WriteTopObject0(val[i]);
}
else
{
@@ -323,7 +323,7 @@ namespace ignite
stream->WriteInt32(len);
for (int i = 0; i < len; i++)
- WriteTopObject(val[i]);
+ WriteTopObject0(val[i]);
}
else
stream->WriteInt8(IGNITE_HDR_NULL);
@@ -384,7 +384,7 @@ namespace ignite
stream->WriteInt32(len);
for (int i = 0; i < len; i++)
- WriteTopObject(val[i]);
+ WriteTopObject0(val[i]);
}
else
stream->WriteInt8(IGNITE_HDR_NULL);
@@ -445,7 +445,7 @@ namespace ignite
stream->WriteInt32(len);
for (int i = 0; i < len; i++)
- WriteTopObject(val[i]);
+ WriteTopObject0(val[i]);
}
else
stream->WriteInt8(IGNITE_HDR_NULL);
@@ -526,7 +526,7 @@ namespace ignite
CheckRawMode(true);
CheckSingleMode(true);
- stream->WriteInt8(IGNITE_HDR_NULL);
+ WriteNull0();
}
void BinaryWriterImpl::WriteNull(const char* fieldName)
@@ -535,6 +535,11 @@ namespace ignite
CheckSingleMode(true);
WriteFieldId(fieldName, IGNITE_TYPE_OBJECT);
+ WriteNull0();
+ }
+
+ void BinaryWriterImpl::WriteNull0()
+ {
stream->WriteInt8(IGNITE_HDR_NULL);
}
@@ -683,79 +688,79 @@ namespace ignite
}
template <>
- void BinaryWriterImpl::WriteTopObject<int8_t>(const int8_t& obj)
+ void BinaryWriterImpl::WriteTopObject0<int8_t>(const int8_t& obj)
{
WriteTopObject0<int8_t>(obj, BinaryUtils::WriteInt8, IGNITE_TYPE_BYTE);
}
template <>
- void BinaryWriterImpl::WriteTopObject<bool>(const bool& obj)
+ void BinaryWriterImpl::WriteTopObject0<bool>(const bool& obj)
{
WriteTopObject0<bool>(obj, BinaryUtils::WriteBool, IGNITE_TYPE_BOOL);
}
template <>
- void BinaryWriterImpl::WriteTopObject<int16_t>(const int16_t& obj)
+ void BinaryWriterImpl::WriteTopObject0<int16_t>(const int16_t& obj)
{
WriteTopObject0<int16_t>(obj, BinaryUtils::WriteInt16, IGNITE_TYPE_SHORT);
}
template <>
- void BinaryWriterImpl::WriteTopObject<uint16_t>(const uint16_t& obj)
+ void BinaryWriterImpl::WriteTopObject0<uint16_t>(const uint16_t& obj)
{
WriteTopObject0<uint16_t>(obj, BinaryUtils::WriteUInt16, IGNITE_TYPE_CHAR);
}
template <>
- void BinaryWriterImpl::WriteTopObject<int32_t>(const int32_t& obj)
+ void BinaryWriterImpl::WriteTopObject0<int32_t>(const int32_t& obj)
{
WriteTopObject0<int32_t>(obj, BinaryUtils::WriteInt32, IGNITE_TYPE_INT);
}
template <>
- void BinaryWriterImpl::WriteTopObject<int64_t>(const int64_t& obj)
+ void BinaryWriterImpl::WriteTopObject0<int64_t>(const int64_t& obj)
{
WriteTopObject0<int64_t>(obj, BinaryUtils::WriteInt64, IGNITE_TYPE_LONG);
}
template <>
- void BinaryWriterImpl::WriteTopObject<float>(const float& obj)
+ void BinaryWriterImpl::WriteTopObject0<float>(const float& obj)
{
WriteTopObject0<float>(obj, BinaryUtils::WriteFloat, IGNITE_TYPE_FLOAT);
}
template <>
- void BinaryWriterImpl::WriteTopObject<double>(const double& obj)
+ void BinaryWriterImpl::WriteTopObject0<double>(const double& obj)
{
WriteTopObject0<double>(obj, BinaryUtils::WriteDouble, IGNITE_TYPE_DOUBLE);
}
template <>
- void BinaryWriterImpl::WriteTopObject<Guid>(const Guid& obj)
+ void BinaryWriterImpl::WriteTopObject0<Guid>(const Guid& obj)
{
WriteTopObject0<Guid>(obj, BinaryUtils::WriteGuid, IGNITE_TYPE_UUID);
}
template <>
- void BinaryWriterImpl::WriteTopObject<Date>(const Date& obj)
+ void BinaryWriterImpl::WriteTopObject0<Date>(const Date& obj)
{
WriteTopObject0<Date>(obj, BinaryUtils::WriteDate, IGNITE_TYPE_DATE);
}
template <>
- void BinaryWriterImpl::WriteTopObject<Timestamp>(const Timestamp& obj)
+ void BinaryWriterImpl::WriteTopObject0<Timestamp>(const Timestamp& obj)
{
WriteTopObject0<Timestamp>(obj, BinaryUtils::WriteTimestamp, IGNITE_TYPE_TIMESTAMP);
}
template <>
- void BinaryWriterImpl::WriteTopObject<Time>(const Time& obj)
+ void BinaryWriterImpl::WriteTopObject0<Time>(const Time& obj)
{
WriteTopObject0<Time>(obj, BinaryUtils::WriteTime, IGNITE_TYPE_TIME);
}
template<>
- void BinaryWriterImpl::WriteTopObject(const std::string& obj)
+ void BinaryWriterImpl::WriteTopObject0(const std::string& obj)
{
const char* obj0 = obj.c_str();
http://git-wip-us.apache.org/repos/asf/ignite/blob/1597a186/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp b/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
index 53e584f..10a0bb2 100644
--- a/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_reader_writer_raw_test.cpp
@@ -1279,4 +1279,40 @@ BOOST_AUTO_TEST_CASE(TestUserType)
BOOST_REQUIRE(actual == expected);
}
+BOOST_AUTO_TEST_CASE(TestPrimitivePointers)
+{
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writer(&out, 0);
+ BinaryRawWriter rawWriter(&writer);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ std::string field1 = "Lorem ipsum";
+ int32_t field2 = 42;
+
+ rawWriter.WriteObject(&field1);
+ rawWriter.WriteObject<int8_t*>(0);
+ rawWriter.WriteObject(&field2);
+
+ writer.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+ BinaryReaderImpl reader(&in);
+ BinaryRawReader rawReader(&reader);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ std::auto_ptr<std::string> field1Res(rawReader.ReadObject<std::string*>());
+ std::auto_ptr<int8_t> fieldNullRes(rawReader.ReadObject<int8_t*>());
+ std::auto_ptr<int32_t> field2Res(rawReader.ReadObject<int32_t*>());
+
+ BOOST_CHECK_EQUAL(*field1Res, field1);
+ BOOST_CHECK(fieldNullRes.get() == 0);
+ BOOST_CHECK_EQUAL(*field2Res, field2);
+}
+
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1597a186/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
index f494cb0..b76bcc1 100644
--- a/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
+++ b/modules/platforms/cpp/core-test/src/binary_reader_writer_test.cpp
@@ -19,6 +19,8 @@
# define BOOST_TEST_DYN_LINK
#endif
+#include <memory>
+
#include <boost/test/unit_test.hpp>
#include "ignite/impl/interop/interop.h"
@@ -61,7 +63,8 @@ void CheckPrimitive(T val)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
BOOST_CHECK_EXCEPTION(Read<T>(reader, NULL), IgniteError, IsBinaryError);
@@ -116,7 +119,8 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -149,7 +153,8 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -186,7 +191,8 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -226,7 +232,8 @@ void CheckPrimitiveArray(T dflt, T val1, T val2)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -335,7 +342,8 @@ void CheckCollectionEmpty(CollectionType::Type* colType)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -398,7 +406,8 @@ void CheckCollection(CollectionType::Type* colType)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -466,7 +475,8 @@ void CheckCollectionIterators(CollectionType::Type* colType)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -524,7 +534,8 @@ void CheckMapEmpty(MapType::Type* mapType)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -589,7 +600,8 @@ void CheckMap(MapType::Type* mapType)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -801,7 +813,8 @@ BOOST_AUTO_TEST_CASE(TestGuidNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -839,7 +852,8 @@ BOOST_AUTO_TEST_CASE(TestDateNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -877,7 +891,8 @@ BOOST_AUTO_TEST_CASE(TestTimeNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -915,7 +930,8 @@ BOOST_AUTO_TEST_CASE(TestTimestampNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -964,7 +980,8 @@ BOOST_AUTO_TEST_CASE(TestString) {
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 5;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1023,7 +1040,8 @@ BOOST_AUTO_TEST_CASE(TestStringArrayNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1079,7 +1097,8 @@ BOOST_AUTO_TEST_CASE(TestStringArrayEmpty)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1146,7 +1165,8 @@ BOOST_AUTO_TEST_CASE(TestStringArray)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1241,7 +1261,8 @@ BOOST_AUTO_TEST_CASE(TestObject)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 3;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1285,7 +1306,8 @@ BOOST_AUTO_TEST_CASE(TestNestedObject)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 3;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1327,7 +1349,8 @@ BOOST_AUTO_TEST_CASE(TestArrayNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1376,7 +1399,8 @@ BOOST_AUTO_TEST_CASE(TestArrayEmpty)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1433,7 +1457,8 @@ BOOST_AUTO_TEST_CASE(TestArray)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1485,7 +1510,8 @@ BOOST_AUTO_TEST_CASE(TestCollectionNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1562,7 +1588,8 @@ BOOST_AUTO_TEST_CASE(TestMapNull)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 5 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1634,7 +1661,8 @@ BOOST_AUTO_TEST_CASE(TestRawMode)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, footerBegin, footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 1000, footerBegin,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1824,7 +1852,8 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset2ByteFields)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 6 * fieldsNum;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::TWO_BYTES);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::TWO_BYTES);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1869,7 +1898,8 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset4ByteFields)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 8 * fieldsNum;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::FOUR_BYTES);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::FOUR_BYTES);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1909,7 +1939,8 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset2ByteArray)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 6 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::TWO_BYTES);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::TWO_BYTES);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1943,7 +1974,8 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset4ByteArray)
int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
int32_t footerEnd = footerBegin + 8 * 2;
- BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100, footerBegin, footerEnd, BinaryOffsetType::FOUR_BYTES);
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::FOUR_BYTES);
BinaryReader reader(&readerImpl);
in.Position(IGNITE_DFLT_HDR_LEN);
@@ -1951,4 +1983,47 @@ BOOST_AUTO_TEST_CASE(TestSchemaOffset4ByteArray)
BOOST_REQUIRE(reader.ReadInt32("field2") == 42);
}
+BOOST_AUTO_TEST_CASE(TestPrimitivePointers)
+{
+ TemplatedBinaryIdResolver<BinaryDummy> idRslvr;
+
+ InteropUnpooledMemory mem(1024);
+
+ InteropOutputStream out(&mem);
+ BinaryWriterImpl writerImpl(&out, &idRslvr, 0, 0, 0);
+ BinaryWriter writer(&writerImpl);
+
+ out.Position(IGNITE_DFLT_HDR_LEN);
+
+ std::string field1 = "Lorem ipsum";
+ int32_t field2 = 42;
+
+ writer.WriteObject("field1", &field1);
+ writer.WriteObject<int8_t*>("null", 0);
+ writer.WriteObject("field2", &field2);
+
+ writerImpl.PostWrite();
+
+ out.Synchronize();
+
+ InteropInputStream in(&mem);
+
+ int32_t footerBegin = in.ReadInt32(IGNITE_OFFSET_SCHEMA_OR_RAW_OFF);
+ int32_t footerEnd = footerBegin + 5 * 3;
+
+ BinaryReaderImpl readerImpl(&in, &idRslvr, 0, true, idRslvr.GetTypeId(), 0, 100, 100,
+ footerBegin, footerEnd, BinaryOffsetType::ONE_BYTE);
+ BinaryReader reader(&readerImpl);
+
+ in.Position(IGNITE_DFLT_HDR_LEN);
+
+ std::auto_ptr<int32_t> field2Res(reader.ReadObject<int32_t*>("field2"));
+ std::auto_ptr<int8_t> fieldNullRes(reader.ReadObject<int8_t*>("null"));
+ std::auto_ptr<std::string> field1Res(reader.ReadObject<std::string*>("field1"));
+
+ BOOST_CHECK_EQUAL(*field1Res, field1);
+ BOOST_CHECK(fieldNullRes.get() == 0);
+ BOOST_CHECK_EQUAL(*field2Res, field2);
+}
+
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/1597a186/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
index 5461d1c..8dddf43 100644
--- a/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
+++ b/modules/platforms/cpp/core/include/ignite/impl/ignite_impl.h
@@ -28,11 +28,6 @@
#include <ignite/impl/cluster/cluster_group_impl.h>
#include <ignite/impl/compute/compute_impl.h>
-using namespace ignite::impl::interop;
-using namespace ignite::common::concurrent;
-using namespace ignite::impl::binary;
-using namespace ignite::binary;
-
namespace ignite
{
namespace impl
@@ -66,7 +61,6 @@ namespace ignite
* Constructor used to create new instance.
*
* @param env Environment.
- * @param javaRef Reference to java object.
*/
IgniteImpl(SP_IgniteEnvironment env);
http://git-wip-us.apache.org/repos/asf/ignite/blob/1597a186/modules/platforms/cpp/core/src/impl/ignite_impl.cpp
----------------------------------------------------------------------
diff --git a/modules/platforms/cpp/core/src/impl/ignite_impl.cpp b/modules/platforms/cpp/core/src/impl/ignite_impl.cpp
index f2132d4..e9d79d3 100644
--- a/modules/platforms/cpp/core/src/impl/ignite_impl.cpp
+++ b/modules/platforms/cpp/core/src/impl/ignite_impl.cpp
@@ -19,6 +19,10 @@
using namespace ignite::common::concurrent;
using namespace ignite::jni::java;
+using namespace ignite::impl::interop;
+using namespace ignite::impl::binary;
+
+using namespace ignite::binary;
namespace ignite
{