http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h b/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h deleted file mode 100644 index d0533fd..0000000 --- a/modules/platforms/cpp/core/include/ignite/portable/portable_reader.h +++ /dev/null @@ -1,384 +0,0 @@ -/* - * 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. - */ - -#ifndef _IGNITE_PORTABLE_READER -#define _IGNITE_PORTABLE_READER - -#include <stdint.h> -#include <string> - -#include <ignite/common/common.h> - -#include "ignite/portable/portable_raw_reader.h" -#include "ignite/guid.h" - -namespace ignite -{ - namespace portable - { - /** - * Portable reader. - */ - class IGNITE_IMPORT_EXPORT PortableReader - { - public: - /** - * Constructor. - * - * @param impl Implementation. - */ - PortableReader(ignite::impl::portable::PortableReaderImpl* impl); - - /** - * Read 8-byte signed integer. Maps to "byte" type in Java. - * - * @param fieldName Field name. - * @param fieldName Field name. - * @return Result. - */ - int8_t ReadInt8(const char* fieldName); - - /** - * Read array of 8-byte signed integers. Maps to "byte[]" 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 ReadInt8Array(const char* fieldName, int8_t* res, int32_t len); - - /** - * Read bool. Maps to "short" type in Java. - * - * @param fieldName Field name. - * @return Result. - */ - bool ReadBool(const char* fieldName); - - /** - * Read array of bools. Maps to "bool[]" 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 ReadBoolArray(const char* fieldName, bool* res, int32_t len); - - /** - * Read 16-byte signed integer. Maps to "short" type in Java. - * - * @param fieldName Field name. - * @return Result. - */ - int16_t ReadInt16(const char* fieldName); - - /** - * Read array of 16-byte signed integers. Maps to "short[]" 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 ReadInt16Array(const char* fieldName, int16_t* res, int32_t len); - - /** - * Read 16-byte unsigned integer. Maps to "char" type in Java. - * - * @param fieldName Field name. - * @return Result. - */ - uint16_t ReadUInt16(const char* fieldName); - - /** - * Read array of 16-byte unsigned integers. Maps to "char[]" 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 ReadUInt16Array(const char* fieldName, uint16_t* res, int32_t len); - - /** - * Read 32-byte signed integer. Maps to "int" type in Java. - * - * @param fieldName Field name. - * @return Result. - */ - int32_t ReadInt32(const char* fieldName); - - /** - * Read array of 32-byte signed integers. Maps to "int[]" 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 ReadInt32Array(const char* fieldName, int32_t* res, int32_t len); - - /** - * Read 64-byte signed integer. Maps to "long" type in Java. - * - * @param fieldName Field name. - * @return Result. - */ - int64_t ReadInt64(const char* fieldName); - - /** - * Read array of 64-byte signed integers. Maps to "long[]" 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 ReadInt64Array(const char* fieldName, int64_t* res, int32_t len); - - /** - * Read float. Maps to "float" type in Java. - * - * @param fieldName Field name. - * @return Result. - */ - float ReadFloat(const char* fieldName); - - /** - * Read array of floats. Maps to "float[]" 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 ReadFloatArray(const char* fieldName, float* res, int32_t len); - - /** - * Read double. Maps to "double" type in Java. - * - * @param fieldName Field name. - * @return Result. - */ - double ReadDouble(const char* fieldName); - - /** - * Read array of doubles. Maps to "double[]" 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 ReadDoubleArray(const char* fieldName, double* res, int32_t len); - - /** - * Read Guid. Maps to "UUID" type in Java. - * - * @param fieldName Field name. - * @return Result. - */ - Guid ReadGuid(const char* fieldName); - - /** - * Read array of Guids. Maps to "UUID[]" 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 ReadGuidArray(const char* fieldName, Guid* res, int32_t len); - - /** - * Read string. - * - * @param fieldName Field name. - * @param res Array to store data to. - * @param len Expected length of string. NULL terminator will be set in case len is - * greater than real string length. - * @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 ReadString(const char* fieldName, char* res, int32_t len); - - /** - * Read string from the stream. - * - * @param fieldName Field name. - * @return String. - */ - std::string ReadString(const char* fieldName) - { - int32_t len = ReadString(fieldName, NULL, 0); - - if (len != -1) - { - ignite::impl::utils::SafeArray<char> arr(len + 1); - - ReadString(fieldName, arr.target, len + 1); - - return std::string(arr.target); - } - else - return std::string(); - } - - /** - * Start string array read. - * - * @param fieldName Field name. - * @return String array reader. - */ - PortableStringArrayReader ReadStringArray(const char* fieldName); - - /** - * Start array read. - * - * @param fieldName Field name. - * @return Array reader. - */ - template<typename T> - PortableArrayReader<T> ReadArray(const char* fieldName) - { - int32_t size; - - int32_t id = impl->ReadArray(fieldName, &size); - - return PortableArrayReader<T>(impl, id, size); - } - - /** - * Start collection read. - * - * @param fieldName Field name. - * @return Collection reader. - */ - template<typename T> - PortableCollectionReader<T> ReadCollection(const char* fieldName) - { - CollectionType typ; - int32_t size; - - int32_t id = impl->ReadCollection(fieldName, &typ, &size); - - return PortableCollectionReader<T>(impl, id, typ, size); - } - - /** - * Read values and insert them to specified position. - * - * @param fieldName Field name. - * @param out Output iterator to the initial position in the destination sequence. - * @return Number of elements that have been read. - */ - template<typename T, typename OutputIterator> - int32_t ReadCollection(const char* fieldName, OutputIterator out) - { - return impl->ReadCollection<T>(fieldName, out); - } - - /** - * Start map read. - * - * @param fieldName Field name. - * @return Map reader. - */ - template<typename K, typename V> - PortableMapReader<K, V> ReadMap(const char* fieldName) - { - MapType typ; - int32_t size; - - int32_t id = impl->ReadMap(fieldName, &typ, &size); - - return PortableMapReader<K, V>(impl, id, typ, size); - } - - /** - * Read type of the collection. - * - * @param fieldName Field name. - * @return Collection type. - */ - CollectionType ReadCollectionType(const char* fieldName); - - /** - * Read type of the collection. - * - * @param fieldName Field name. - * @return Collection size. - */ - int32_t ReadCollectionSize(const char* fieldName); - - /** - * Read object. - * - * @param fieldName Field name. - * @return Object. - */ - template<typename T> - T ReadObject(const char* fieldName) - { - return impl->ReadObject<T>(fieldName); - } - - /** - * Get raw reader for this reader. - * - * @return Raw reader. - */ - PortableRawReader RawReader(); - private: - /** Implementation delegate. */ - ignite::impl::portable::PortableReaderImpl* impl; - }; - } -} - -#endif \ No newline at end of file
http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/portable/portable_type.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_type.h b/modules/platforms/cpp/core/include/ignite/portable/portable_type.h deleted file mode 100644 index fb086ef..0000000 --- a/modules/platforms/cpp/core/include/ignite/portable/portable_type.h +++ /dev/null @@ -1,293 +0,0 @@ -/* - * 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. - */ - -#ifndef _IGNITE_PORTABLE_TYPE -#define _IGNITE_PORTABLE_TYPE - -#include <stdint.h> - -#include <ignite/common/common.h> - -#include "ignite/ignite_error.h" - -/** - * Start portable type definition. - */ -#define IGNITE_PORTABLE_TYPE_START(T) \ -template<> \ -struct PortableType<T> \ -{ - -/** - * End portable type definition. - */ -#define IGNITE_PORTABLE_TYPE_END \ -}; - -/** - * Implementation of GetTypeId() which returns predefined constant. - */ -#define IGNITE_PORTABLE_GET_TYPE_ID_AS_CONST(id) \ -int32_t GetTypeId() \ -{ \ - return id; \ -} - -/** - * Implementation of GetTypeId() which returns hash of passed type name. - */ -#define IGNITE_PORTABLE_GET_TYPE_ID_AS_HASH(typeName) \ -int32_t GetTypeId() \ -{ \ - return GetPortableStringHashCode(#typeName); \ -} - -/** - * Implementation of GetTypeName() which returns type name as is. - */ -#define IGNITE_PORTABLE_GET_TYPE_NAME_AS_IS(typeName) \ -std::string GetTypeName() \ -{ \ - return #typeName; \ -} - -/** - * Default implementation of GetFieldId() function which returns Java-way hash code of the string. - */ -#define IGNITE_PORTABLE_GET_FIELD_ID_AS_HASH \ -int32_t GetFieldId(const char* name) \ -{ \ - return GetPortableStringHashCode(name); \ -} - -/** - * Implementation of GetHashCode() function which always returns 0. - */ -#define IGNITE_PORTABLE_GET_HASH_CODE_ZERO(T) \ -int32_t GetHashCode(const T& obj) \ -{ \ - return 0; \ -} - -/** - * Implementation of IsNull() function which always returns false. - */ -#define IGNITE_PORTABLE_IS_NULL_FALSE(T) \ -bool IsNull(const T& obj) \ -{ \ - return false; \ -} - -/** - * Implementation of IsNull() function which return true if passed object is null pointer. - */ -#define IGNITE_PORTABLE_IS_NULL_IF_NULLPTR(T) \ -bool IsNull(const T& obj) \ -{ \ - return obj; \ -} - -/** - * Implementation of GetNull() function which returns an instance created with defult constructor. - */ -#define IGNITE_PORTABLE_GET_NULL_DEFAULT_CTOR(T) \ -T GetNull() \ -{ \ - return T(); \ -} - -/** - * Implementation of GetNull() function which returns NULL pointer. - */ -#define IGNITE_PORTABLE_GET_NULL_NULLPTR(T) \ -T GetNull() \ -{ \ - return NULL; \ -} - -namespace ignite -{ - namespace portable - { - class PortableWriter; - class PortableReader; - - /** - * Get portable string hash code. - * - * @param val Value. - * @return Hash code. - */ - IGNITE_IMPORT_EXPORT int32_t GetPortableStringHashCode(const char* val); - - /** - * Portable type structure. Defines a set of functions required for type to be serialized and deserialized. - */ - template<typename T> - struct IGNITE_IMPORT_EXPORT PortableType - { - /** - * Get portable object type ID. - * - * @return Type ID. - */ - int32_t GetTypeId() - { - IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "GetTypeId function is not defined for portable type."); - } - - /** - * Get portable object type name. - * - * @return Type name. - */ - std::string GetTypeName() - { - IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "GetTypeName function is not defined for portable type."); - } - - /** - * Get portable object field ID. - * - * @param name Field name. - * @return Field ID. - */ - int32_t GetFieldId(const char* name) - { - return GetPortableStringHashCode(name); - } - - /** - * Get portable object hash code. - * - * @param obj Portable object. - * @return Hash code. - */ - int32_t GetHashCode(const T& obj) - { - return 0; - } - - /** - * Write portable object. - * - * @param writer Writer. - * @param obj Object. - */ - void Write(PortableWriter& writer, const T& obj) - { - IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Write function is not defined for portable type."); - } - - /** - * Read portable object. - * - * @param reader Reader. - * @return Object. - */ - T Read(PortableReader& reader) - { - IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "Read function is not defined for portable type."); - } - - /** - * Check whether passed portable object should be interpreted as NULL. - * - * @param obj Portable object to test. - * @return True if portable object should be interpreted as NULL. - */ - bool IsNull(const T& obj) - { - return false; - } - - /** - * Get NULL value for the given portable type. - * - * @return NULL value. - */ - T GetNull() - { - IGNITE_ERROR_1(IgniteError::IGNITE_ERR_PORTABLE, "GetNull function is not defined for portable type."); - } - }; - - /* - * Templated portable type for pointers. - */ - template <typename T> - struct IGNITE_IMPORT_EXPORT PortableType<T*> - { - /** Actual type. */ - PortableType<T> typ; - - /** - * Constructor. - */ - PortableType() - { - typ = PortableType<T>(); - } - - int32_t GetTypeId() - { - return typ.GetTypeId(); - } - - std::string GetTypeName() - { - return typ.GetTypeName(); - } - - int32_t GetFieldId(const char* name) - { - return typ.GetFieldId(name); - } - - int32_t GetHashCode(T* const& obj) - { - return typ.GetHashCode(*obj); - } - - void Write(PortableWriter& writer, T* const& obj) - { - typ.Write(writer, *obj); - } - - T* Read(PortableReader& reader) - { - T* res = new T(); - - *res = typ.Read(reader); - - return res; - } - - bool IsNull(T* const& obj) - { - return !obj || typ.IsNull(*obj); - } - - T* GetNull() - { - return NULL; - } - }; - } -} - -#endif http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h b/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h deleted file mode 100644 index c225340..0000000 --- a/modules/platforms/cpp/core/include/ignite/portable/portable_writer.h +++ /dev/null @@ -1,362 +0,0 @@ -/* - * 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. - */ - -#ifndef _IGNITE_PORTABLE_WRITER -#define _IGNITE_PORTABLE_WRITER - -#include <string> -#include <stdint.h> - -#include <ignite/common/common.h> - -#include "ignite/portable/portable_raw_writer.h" - -namespace ignite -{ - namespace portable - { - /** - * Portable writer. - */ - class IGNITE_IMPORT_EXPORT PortableWriter - { - public: - /** - * Constructor. - * - * @param impl Implementation. - */ - PortableWriter(ignite::impl::portable::PortableWriterImpl* impl); - - /** - * Write 8-byte signed integer. Maps to "byte" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteInt8(const char* fieldName, int8_t val); - - /** - * Write array of 8-byte signed integers. Maps to "byte[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteInt8Array(const char* fieldName, const int8_t* val, int32_t len); - - /** - * Write bool. Maps to "short" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteBool(const char* fieldName, bool val); - - /** - * Write array of bools. Maps to "bool[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteBoolArray(const char* fieldName, const bool* val, int32_t len); - - /** - * Write 16-byte signed integer. Maps to "short" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteInt16(const char* fieldName, int16_t val); - - /** - * Write array of 16-byte signed integers. Maps to "short[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteInt16Array(const char* fieldName, const int16_t* val, int32_t len); - - /** - * Write 16-byte unsigned integer. Maps to "char" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteUInt16(const char* fieldName, uint16_t val); - - /** - * Write array of 16-byte unsigned integers. Maps to "char[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteUInt16Array(const char* fieldName, const uint16_t* val, int32_t len); - - /** - * Write 32-byte signed integer. Maps to "int" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteInt32(const char* fieldName, int32_t val); - - /** - * Write array of 32-byte signed integers. Maps to "int[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteInt32Array(const char* fieldName, const int32_t* val, int32_t len); - - /** - * Write 64-byte signed integer. Maps to "long" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteInt64(const char* fieldName, int64_t val); - - /** - * Write array of 64-byte signed integers. Maps to "long[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteInt64Array(const char* fieldName, const int64_t* val, int32_t len); - - /** - * Write float. Maps to "float" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteFloat(const char* fieldName, float val); - - /** - * Write array of floats. Maps to "float[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteFloatArray(const char* fieldName, const float* val, int32_t len); - - /** - * Write double. Maps to "double" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteDouble(const char* fieldName, double val); - - /** - * Write array of doubles. Maps to "double[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteDoubleArray(const char* fieldName, const double* val, int32_t len); - - /** - * Write Guid. Maps to "UUID" type in Java. - * - * @param fieldName Field name. - * @param val Value. - */ - void WriteGuid(const char* fieldName, const Guid& val); - - /** - * Write array of Guids. Maps to "UUID[]" type in Java. - * - * @param fieldName Field name. - * @param val Array. - * @param len Array length. - */ - void WriteGuidArray(const char* fieldName, const Guid* val, int32_t len); - - /** - * Write string. - * - * @param fieldName Field name. - * @param val Null-terminated character sequence. - */ - void WriteString(const char* fieldName, const char* val); - - /** - * Write string. - * - * @param fieldName Field name. - * @param val String. - * @param len String length (characters). - */ - void WriteString(const char* fieldName, const char* val, int32_t len); - - /** - * Write string. - * - * @param fieldName Field name. - * @param val String. - */ - void WriteString(const char* fieldName, const std::string& val) - { - WriteString(fieldName, val.c_str()); - } - - /** - * Start string array write. - * - * @param fieldName Field name. - * @return String array writer. - */ - PortableStringArrayWriter WriteStringArray(const char* fieldName); - - /** - * Write NULL value. - * - * @param fieldName Field name. - */ - void WriteNull(const char* fieldName); - - /** - * Start array write. - * - * @param fieldName Field name. - * @return Array writer. - */ - template<typename T> - PortableArrayWriter<T> WriteArray(const char* fieldName) - { - int32_t id = impl->WriteArray(fieldName); - - return PortableArrayWriter<T>(impl, id); - } - - /** - * Start collection write. - * - * @param fieldName Field name. - * @return Collection writer. - */ - template<typename T> - PortableCollectionWriter<T> WriteCollection(const char* fieldName) - { - return WriteCollection<T>(fieldName, IGNITE_COLLECTION_UNDEFINED); - } - - /** - * Start collection write. - * - * @param fieldName Field name. - * @param type Collection type. - * @return Collection writer. - */ - template<typename T> - PortableCollectionWriter<T> WriteCollection(const char* fieldName, ignite::portable::CollectionType typ) - { - int32_t id = impl->WriteCollection(fieldName, typ); - - return PortableCollectionWriter<T>(impl, id); - } - - /** - * Write values in interval [first, last). - * - * @param fieldName Field name. - * @param first Iterator pointing to the beginning of the interval. - * @param last Iterator pointing to the end of the interval. - */ - template<typename InputIterator> - void WriteCollection(const char* fieldName, InputIterator first, InputIterator last) - { - WriteCollection(fieldName, first, last, IGNITE_COLLECTION_UNDEFINED); - } - - /** - * Write values in interval [first, last). - * - * @param fieldName Field name. - * @param first Iterator pointing to the beginning of the interval. - * @param last Iterator pointing to the end of the interval. - * @param typ Collection type. - */ - template<typename InputIterator> - void WriteCollection(const char* fieldName, InputIterator first, InputIterator last, CollectionType typ) - { - impl->WriteCollection(fieldName, first, last, typ); - } - - /** - * Start map write. - * - * @param fieldName Field name. - * @param typ Map type. - * @return Map writer. - */ - template<typename K, typename V> - PortableMapWriter<K, V> WriteMap(const char* fieldName) - { - return WriteMap<K, V>(fieldName, IGNITE_MAP_UNDEFINED); - } - - /** - * Start map write. - * - * @param fieldName Field name. - * @param typ Map type. - * @return Map writer. - */ - template<typename K, typename V> - PortableMapWriter<K, V> WriteMap(const char* fieldName, ignite::portable::MapType typ) - { - int32_t id = impl->WriteMap(fieldName, typ); - - return PortableMapWriter<K, V>(impl, id); - } - - /** - * Write object. - * - * @param fieldName Field name. - * @param val Value. - */ - template<typename T> - void WriteObject(const char* fieldName, T val) - { - impl->WriteObject<T>(fieldName, val); - } - - /** - * Get raw writer for this reader. - * - * @return Raw writer. - */ - PortableRawWriter RawWriter(); - private: - /** Implementation delegate. */ - ignite::impl::portable::PortableWriterImpl* impl; - }; - } -} - -#endif \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/project/vs/core.vcxproj ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/project/vs/core.vcxproj b/modules/platforms/cpp/core/project/vs/core.vcxproj index 93ac836..cb66d28 100644 --- a/modules/platforms/cpp/core/project/vs/core.vcxproj +++ b/modules/platforms/cpp/core/project/vs/core.vcxproj @@ -217,25 +217,25 @@ <ClInclude Include="..\..\include\ignite\impl\interop\interop_output_stream.h" /> <ClInclude Include="..\..\include\ignite\impl\interop\interop_stream_position_guard.h" /> <ClInclude Include="..\..\include\ignite\impl\operations.h" /> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_common.h" /> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_id_resolver.h" /> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_handler.h" /> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_manager.h" /> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_snapshot.h" /> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater.h" /> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater_impl.h" /> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_reader_impl.h" /> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_schema.h" /> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_utils.h" /> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_writer_impl.h" /> - <ClInclude Include="..\..\include\ignite\portable\portable.h" /> - <ClInclude Include="..\..\include\ignite\portable\portable_consts.h" /> - <ClInclude Include="..\..\include\ignite\portable\portable_containers.h" /> - <ClInclude Include="..\..\include\ignite\portable\portable_type.h" /> - <ClInclude Include="..\..\include\ignite\portable\portable_raw_reader.h" /> - <ClInclude Include="..\..\include\ignite\portable\portable_raw_writer.h" /> - <ClInclude Include="..\..\include\ignite\portable\portable_reader.h" /> - <ClInclude Include="..\..\include\ignite\portable\portable_writer.h" /> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_common.h" /> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_id_resolver.h" /> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_handler.h" /> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_manager.h" /> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_snapshot.h" /> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_updater.h" /> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_updater_impl.h" /> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_reader_impl.h" /> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_schema.h" /> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_utils.h" /> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_writer_impl.h" /> + <ClInclude Include="..\..\include\ignite\binary\binary.h" /> + <ClInclude Include="..\..\include\ignite\binary\binary_consts.h" /> + <ClInclude Include="..\..\include\ignite\binary\binary_containers.h" /> + <ClInclude Include="..\..\include\ignite\binary\binary_type.h" /> + <ClInclude Include="..\..\include\ignite\binary\binary_raw_reader.h" /> + <ClInclude Include="..\..\include\ignite\binary\binary_raw_writer.h" /> + <ClInclude Include="..\..\include\ignite\binary\binary_reader.h" /> + <ClInclude Include="..\..\include\ignite\binary\binary_writer.h" /> <ClInclude Include="..\..\os\win\include\ignite\impl\utils.h" /> </ItemGroup> <ItemGroup> @@ -252,21 +252,21 @@ <ClCompile Include="..\..\src\impl\interop\interop_input_stream.cpp" /> <ClCompile Include="..\..\src\impl\interop\interop_memory.cpp" /> <ClCompile Include="..\..\src\impl\interop\interop_output_stream.cpp" /> - <ClCompile Include="..\..\src\impl\portable\portable_metadata_handler.cpp" /> - <ClCompile Include="..\..\src\impl\portable\portable_metadata_manager.cpp" /> - <ClCompile Include="..\..\src\impl\portable\portable_metadata_snapshot.cpp" /> - <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater.cpp" /> - <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater_impl.cpp" /> - <ClCompile Include="..\..\src\impl\portable\portable_reader_impl.cpp" /> - <ClCompile Include="..\..\src\impl\portable\portable_schema.cpp" /> - <ClCompile Include="..\..\src\impl\portable\portable_utils.cpp" /> - <ClCompile Include="..\..\src\impl\portable\portable_writer_impl.cpp" /> - <ClCompile Include="..\..\src\portable\portable_containers.cpp" /> - <ClCompile Include="..\..\src\portable\portable_type.cpp" /> - <ClCompile Include="..\..\src\portable\portable_raw_reader.cpp" /> - <ClCompile Include="..\..\src\portable\portable_raw_writer.cpp" /> - <ClCompile Include="..\..\src\portable\portable_reader.cpp" /> - <ClCompile Include="..\..\src\portable\portable_writer.cpp" /> + <ClCompile Include="..\..\src\impl\binary\binary_type_handler.cpp" /> + <ClCompile Include="..\..\src\impl\binary\binary_type_manager.cpp" /> + <ClCompile Include="..\..\src\impl\binary\binary_type_snapshot.cpp" /> + <ClCompile Include="..\..\src\impl\binary\binary_type_updater.cpp" /> + <ClCompile Include="..\..\src\impl\binary\binary_type_updater_impl.cpp" /> + <ClCompile Include="..\..\src\impl\binary\binary_reader_impl.cpp" /> + <ClCompile Include="..\..\src\impl\binary\binary_schema.cpp" /> + <ClCompile Include="..\..\src\impl\binary\binary_utils.cpp" /> + <ClCompile Include="..\..\src\impl\binary\binary_writer_impl.cpp" /> + <ClCompile Include="..\..\src\binary\binary_containers.cpp" /> + <ClCompile Include="..\..\src\binary\binary_type.cpp" /> + <ClCompile Include="..\..\src\binary\binary_raw_reader.cpp" /> + <ClCompile Include="..\..\src\binary\binary_raw_writer.cpp" /> + <ClCompile Include="..\..\src\binary\binary_reader.cpp" /> + <ClCompile Include="..\..\src\binary\binary_writer.cpp" /> </ItemGroup> <ItemGroup> <ProjectReference Include="..\..\..\common\project\vs\common.vcxproj"> http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/project/vs/core.vcxproj.filters ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/project/vs/core.vcxproj.filters b/modules/platforms/cpp/core/project/vs/core.vcxproj.filters index da00df3..9bdece4 100644 --- a/modules/platforms/cpp/core/project/vs/core.vcxproj.filters +++ b/modules/platforms/cpp/core/project/vs/core.vcxproj.filters @@ -19,30 +19,6 @@ <ClCompile Include="..\..\src\impl\ignite_impl.cpp"> <Filter>Code\impl</Filter> </ClCompile> - <ClCompile Include="..\..\src\portable\portable_containers.cpp"> - <Filter>Code\portable</Filter> - </ClCompile> - <ClCompile Include="..\..\src\portable\portable_raw_reader.cpp"> - <Filter>Code\portable</Filter> - </ClCompile> - <ClCompile Include="..\..\src\portable\portable_raw_writer.cpp"> - <Filter>Code\portable</Filter> - </ClCompile> - <ClCompile Include="..\..\src\portable\portable_reader.cpp"> - <Filter>Code\portable</Filter> - </ClCompile> - <ClCompile Include="..\..\src\portable\portable_writer.cpp"> - <Filter>Code\portable</Filter> - </ClCompile> - <ClCompile Include="..\..\src\impl\portable\portable_reader_impl.cpp"> - <Filter>Code\impl\portable</Filter> - </ClCompile> - <ClCompile Include="..\..\src\impl\portable\portable_utils.cpp"> - <Filter>Code\impl\portable</Filter> - </ClCompile> - <ClCompile Include="..\..\src\impl\portable\portable_writer_impl.cpp"> - <Filter>Code\impl\portable</Filter> - </ClCompile> <ClCompile Include="..\..\os\win\src\impl\utils.cpp"> <Filter>Code\impl</Filter> </ClCompile> @@ -64,26 +40,50 @@ <ClCompile Include="..\..\src\impl\cache\query\query_impl.cpp"> <Filter>Code\impl\cache\query</Filter> </ClCompile> - <ClCompile Include="..\..\src\impl\portable\portable_metadata_snapshot.cpp"> - <Filter>Code\impl\portable</Filter> + <ClCompile Include="..\..\src\impl\binary\binary_utils.cpp"> + <Filter>Code\impl\binary</Filter> + </ClCompile> + <ClCompile Include="..\..\src\impl\binary\binary_writer_impl.cpp"> + <Filter>Code\impl\binary</Filter> + </ClCompile> + <ClCompile Include="..\..\src\impl\binary\binary_schema.cpp"> + <Filter>Code\impl\binary</Filter> + </ClCompile> + <ClCompile Include="..\..\src\impl\binary\binary_reader_impl.cpp"> + <Filter>Code\impl\binary</Filter> + </ClCompile> + <ClCompile Include="..\..\src\binary\binary_containers.cpp"> + <Filter>Code\binary</Filter> + </ClCompile> + <ClCompile Include="..\..\src\binary\binary_raw_reader.cpp"> + <Filter>Code\binary</Filter> + </ClCompile> + <ClCompile Include="..\..\src\binary\binary_raw_writer.cpp"> + <Filter>Code\binary</Filter> + </ClCompile> + <ClCompile Include="..\..\src\binary\binary_reader.cpp"> + <Filter>Code\binary</Filter> </ClCompile> - <ClCompile Include="..\..\src\impl\portable\portable_metadata_handler.cpp"> - <Filter>Code\impl\portable</Filter> + <ClCompile Include="..\..\src\binary\binary_type.cpp"> + <Filter>Code\binary</Filter> </ClCompile> - <ClCompile Include="..\..\src\portable\portable_type.cpp"> - <Filter>Code\portable</Filter> + <ClCompile Include="..\..\src\binary\binary_writer.cpp"> + <Filter>Code\binary</Filter> </ClCompile> - <ClCompile Include="..\..\src\impl\portable\portable_metadata_manager.cpp"> - <Filter>Code\impl\portable</Filter> + <ClCompile Include="..\..\src\impl\binary\binary_type_updater_impl.cpp"> + <Filter>Code\impl\binary</Filter> </ClCompile> - <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater.cpp"> - <Filter>Code\impl\portable</Filter> + <ClCompile Include="..\..\src\impl\binary\binary_type_updater.cpp"> + <Filter>Code\impl\binary</Filter> </ClCompile> - <ClCompile Include="..\..\src\impl\portable\portable_metadata_updater_impl.cpp"> - <Filter>Code\impl\portable</Filter> + <ClCompile Include="..\..\src\impl\binary\binary_type_snapshot.cpp"> + <Filter>Code\impl\binary</Filter> </ClCompile> - <ClCompile Include="..\..\src\impl\portable\portable_schema.cpp"> - <Filter>Code\impl\portable</Filter> + <ClCompile Include="..\..\src\impl\binary\binary_type_manager.cpp"> + <Filter>Code\impl\binary</Filter> + </ClCompile> + <ClCompile Include="..\..\src\impl\binary\binary_type_handler.cpp"> + <Filter>Code\impl\binary</Filter> </ClCompile> </ItemGroup> <ItemGroup> @@ -117,42 +117,6 @@ <ClInclude Include="..\..\include\ignite\impl\operations.h"> <Filter>Code\impl</Filter> </ClInclude> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_common.h"> - <Filter>Code\impl\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\portable\portable_consts.h"> - <Filter>Code\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\portable\portable.h"> - <Filter>Code\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\portable\portable_containers.h"> - <Filter>Code\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_id_resolver.h"> - <Filter>Code\impl\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\portable\portable_raw_reader.h"> - <Filter>Code\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\portable\portable_raw_writer.h"> - <Filter>Code\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\portable\portable_reader.h"> - <Filter>Code\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\portable\portable_writer.h"> - <Filter>Code\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_reader_impl.h"> - <Filter>Code\impl\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_utils.h"> - <Filter>Code\impl\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_writer_impl.h"> - <Filter>Code\impl\portable</Filter> - </ClInclude> <ClInclude Include="..\..\os\win\include\ignite\impl\utils.h"> <Filter>Code\impl</Filter> </ClInclude> @@ -180,24 +144,6 @@ <ClInclude Include="..\..\include\ignite\impl\cache\query\query_impl.h"> <Filter>Code\impl\cache\query</Filter> </ClInclude> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_snapshot.h"> - <Filter>Code\impl\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_handler.h"> - <Filter>Code\impl\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_manager.h"> - <Filter>Code\impl\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\portable\portable_type.h"> - <Filter>Code\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater.h"> - <Filter>Code\impl\portable</Filter> - </ClInclude> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_metadata_updater_impl.h"> - <Filter>Code\impl\portable</Filter> - </ClInclude> <ClInclude Include="..\..\include\ignite\cache\query\query_argument.h"> <Filter>Code\cache\query</Filter> </ClInclude> @@ -231,8 +177,62 @@ <ClInclude Include="..\..\include\ignite\impl\interop\interop_stream_position_guard.h"> <Filter>Code\impl\interop</Filter> </ClInclude> - <ClInclude Include="..\..\include\ignite\impl\portable\portable_schema.h"> - <Filter>Code\impl\portable</Filter> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_common.h"> + <Filter>Code\impl\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_id_resolver.h"> + <Filter>Code\impl\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_utils.h"> + <Filter>Code\impl\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_writer_impl.h"> + <Filter>Code\impl\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_schema.h"> + <Filter>Code\impl\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_reader_impl.h"> + <Filter>Code\impl\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\binary\binary.h"> + <Filter>Code\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\binary\binary_consts.h"> + <Filter>Code\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\binary\binary_containers.h"> + <Filter>Code\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\binary\binary_raw_reader.h"> + <Filter>Code\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\binary\binary_raw_writer.h"> + <Filter>Code\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\binary\binary_reader.h"> + <Filter>Code\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\binary\binary_type.h"> + <Filter>Code\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\binary\binary_writer.h"> + <Filter>Code\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_updater_impl.h"> + <Filter>Code\impl\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_updater.h"> + <Filter>Code\impl\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_snapshot.h"> + <Filter>Code\impl\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_manager.h"> + <Filter>Code\impl\binary</Filter> + </ClInclude> + <ClInclude Include="..\..\include\ignite\impl\binary\binary_type_handler.h"> + <Filter>Code\impl\binary</Filter> </ClInclude> </ItemGroup> <ItemGroup> @@ -245,23 +245,23 @@ <Filter Include="Code\impl\cache"> <UniqueIdentifier>{b013b0f6-c4b8-4b88-89bc-8b394971788e}</UniqueIdentifier> </Filter> - <Filter Include="Code\impl\portable"> - <UniqueIdentifier>{883773bd-085d-4eb5-81ee-f11188134faf}</UniqueIdentifier> - </Filter> <Filter Include="Code\impl\interop"> <UniqueIdentifier>{d4cc8aeb-6e7b-47e6-9b83-cba925844d96}</UniqueIdentifier> </Filter> <Filter Include="Code\cache"> <UniqueIdentifier>{8b7e32c0-e222-4f3a-af31-19df380c369f}</UniqueIdentifier> </Filter> - <Filter Include="Code\portable"> - <UniqueIdentifier>{24b7134c-9335-44e1-9604-4093d0e3bbf5}</UniqueIdentifier> - </Filter> <Filter Include="Code\cache\query"> <UniqueIdentifier>{4658a0ff-0d2d-45a6-b8de-93eeec0cc081}</UniqueIdentifier> </Filter> <Filter Include="Code\impl\cache\query"> <UniqueIdentifier>{b6e57294-120a-46f2-b0ad-c3595e2cf789}</UniqueIdentifier> </Filter> + <Filter Include="Code\binary"> + <UniqueIdentifier>{24b7134c-9335-44e1-9604-4093d0e3bbf5}</UniqueIdentifier> + </Filter> + <Filter Include="Code\impl\binary"> + <UniqueIdentifier>{883773bd-085d-4eb5-81ee-f11188134faf}</UniqueIdentifier> + </Filter> </ItemGroup> </Project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/binary/binary_containers.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/src/binary/binary_containers.cpp b/modules/platforms/cpp/core/src/binary/binary_containers.cpp new file mode 100644 index 0000000..91645cc --- /dev/null +++ b/modules/platforms/cpp/core/src/binary/binary_containers.cpp @@ -0,0 +1,76 @@ +/* + * 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/binary/binary_containers.h" + +using namespace ignite::impl::binary; + +namespace ignite +{ + namespace binary + { + BinaryStringArrayWriter::BinaryStringArrayWriter(BinaryWriterImpl* impl, int32_t id) : + impl(impl), id(id) + { + // No-op. + } + + void BinaryStringArrayWriter::Write(const char* val) + { + if (val) + Write(val, static_cast<int32_t>(strlen(val))); + else + Write(NULL, -1); + } + + void BinaryStringArrayWriter::Write(const char* val, int32_t len) + { + impl->WriteStringElement(id, val, len); + } + + void BinaryStringArrayWriter::Close() + { + impl->CommitContainer(id); + } + + BinaryStringArrayReader::BinaryStringArrayReader(impl::binary::BinaryReaderImpl* impl, + int32_t id, int32_t size) : impl(impl), id(id), size(size) + { + // No-op. + } + + bool BinaryStringArrayReader::HasNext() + { + return impl->HasNextElement(id); + } + + int32_t BinaryStringArrayReader::GetNext(char* res, int32_t len) + { + return impl->ReadStringElement(id, res, len); + } + + int32_t BinaryStringArrayReader::GetSize() const + { + return size; + } + + bool BinaryStringArrayReader::IsNull() const + { + return size == -1; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/binary/binary_raw_reader.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/src/binary/binary_raw_reader.cpp b/modules/platforms/cpp/core/src/binary/binary_raw_reader.cpp new file mode 100644 index 0000000..61105e0 --- /dev/null +++ b/modules/platforms/cpp/core/src/binary/binary_raw_reader.cpp @@ -0,0 +1,145 @@ +/* + * 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/impl/binary/binary_reader_impl.h" +#include "ignite/binary/binary_raw_reader.h" + +using namespace ignite::impl::binary; + +namespace ignite +{ + namespace binary + { + BinaryRawReader::BinaryRawReader(BinaryReaderImpl* impl) : impl(impl) + { + // No-op. + } + + int8_t BinaryRawReader::ReadInt8() + { + return impl->ReadInt8(); + } + + int32_t BinaryRawReader::ReadInt8Array(int8_t* res, const int32_t len) + { + return impl->ReadInt8Array(res, len); + } + + bool BinaryRawReader::ReadBool() + { + return impl->ReadBool(); + } + + int32_t BinaryRawReader::ReadBoolArray(bool* res, const int32_t len) + { + return impl->ReadBoolArray(res, len); + } + + int16_t BinaryRawReader::ReadInt16() + { + return impl->ReadInt16(); + } + + int32_t BinaryRawReader::ReadInt16Array(int16_t* res, const int32_t len) + { + return impl->ReadInt16Array(res, len); + } + + uint16_t BinaryRawReader::ReadUInt16() + { + return impl->ReadUInt16(); + } + + int32_t BinaryRawReader::ReadUInt16Array(uint16_t* res, const int32_t len) + { + return impl->ReadUInt16Array(res, len); + } + + int32_t BinaryRawReader::ReadInt32() + { + return impl->ReadInt32(); + } + + int32_t BinaryRawReader::ReadInt32Array(int32_t* res, const int32_t len) + { + return impl->ReadInt32Array(res, len); + } + + int64_t BinaryRawReader::ReadInt64() + { + return impl->ReadInt64(); + } + + int32_t BinaryRawReader::ReadInt64Array(int64_t* res, const int32_t len) + { + return impl->ReadInt64Array(res, len); + } + + float BinaryRawReader::ReadFloat() + { + return impl->ReadFloat(); + } + + int32_t BinaryRawReader::ReadFloatArray(float* res, const int32_t len) + { + return impl->ReadFloatArray(res, len); + } + + double BinaryRawReader::ReadDouble() + { + return impl->ReadDouble(); + } + + int32_t BinaryRawReader::ReadDoubleArray(double* res, const int32_t len) + { + return impl->ReadDoubleArray(res, len); + } + + Guid BinaryRawReader::ReadGuid() + { + return impl->ReadGuid(); + } + + int32_t BinaryRawReader::ReadGuidArray(Guid* res, const int32_t len) + { + return impl->ReadGuidArray(res, len); + } + + int32_t BinaryRawReader::ReadString(char* res, const int32_t len) + { + return impl->ReadString(res, len); + } + + BinaryStringArrayReader BinaryRawReader::ReadStringArray() + { + int32_t size; + + int32_t id = impl->ReadStringArray(&size); + + return BinaryStringArrayReader(impl, id, size); + } + + CollectionType BinaryRawReader::ReadCollectionType() + { + return impl->ReadCollectionType(); + } + + int32_t BinaryRawReader::ReadCollectionSize() + { + return impl->ReadCollectionSize(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/binary/binary_raw_writer.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/src/binary/binary_raw_writer.cpp b/modules/platforms/cpp/core/src/binary/binary_raw_writer.cpp new file mode 100644 index 0000000..31f29a9 --- /dev/null +++ b/modules/platforms/cpp/core/src/binary/binary_raw_writer.cpp @@ -0,0 +1,147 @@ +/* + * 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/impl/binary/binary_writer_impl.h" +#include "ignite/binary/binary_raw_writer.h" + +using namespace ignite::impl::binary; + +namespace ignite +{ + namespace binary + { + BinaryRawWriter::BinaryRawWriter(BinaryWriterImpl* impl) : impl(impl) + { + // No-op. + } + + void BinaryRawWriter::WriteInt8(int8_t val) + { + impl->WriteInt8(val); + } + + void BinaryRawWriter::WriteInt8Array(const int8_t* val, int32_t len) + { + impl->WriteInt8Array(val, len); + } + + void BinaryRawWriter::WriteBool(bool val) + { + impl->WriteBool(val); + } + + void BinaryRawWriter::WriteBoolArray(const bool* val, int32_t len) + { + impl->WriteBoolArray(val, len); + } + + void BinaryRawWriter::WriteInt16(int16_t val) + { + impl->WriteInt16(val); + } + + void BinaryRawWriter::WriteInt16Array(const int16_t* val, int32_t len) + { + impl->WriteInt16Array(val, len); + } + + void BinaryRawWriter::WriteUInt16(uint16_t val) + { + impl->WriteUInt16(val); + } + + void BinaryRawWriter::WriteUInt16Array(const uint16_t* val, int32_t len) + { + impl->WriteUInt16Array(val, len); + } + + void BinaryRawWriter::WriteInt32(int32_t val) + { + impl->WriteInt32(val); + } + + void BinaryRawWriter::WriteInt32Array(const int32_t* val, int32_t len) + { + impl->WriteInt32Array(val, len); + } + + void BinaryRawWriter::WriteInt64(int64_t val) + { + impl->WriteInt64(val); + } + + void BinaryRawWriter::WriteInt64Array(const int64_t* val, int32_t len) + { + impl->WriteInt64Array(val, len); + } + + void BinaryRawWriter::WriteFloat(float val) + { + impl->WriteFloat(val); + } + + void BinaryRawWriter::WriteFloatArray(const float* val, int32_t len) + { + impl->WriteFloatArray(val, len); + } + + void BinaryRawWriter::WriteDouble(double val) + { + impl->WriteDouble(val); + } + + void BinaryRawWriter::WriteDoubleArray(const double* val, int32_t len) + { + impl->WriteDoubleArray(val, len); + } + + void BinaryRawWriter::WriteGuid(const Guid& val) + { + impl->WriteGuid(val); + } + + void BinaryRawWriter::WriteGuidArray(const Guid* val, int32_t len) + { + impl->WriteGuidArray(val, len); + } + + void BinaryRawWriter::WriteString(const char* val) + { + if (val) + WriteString(val, static_cast<int32_t>(strlen(val))); + else + WriteNull(); + } + + void BinaryRawWriter::WriteString(const char* val, int32_t len) + { + impl->WriteString(val, len); + } + + BinaryStringArrayWriter BinaryRawWriter::WriteStringArray() + { + int32_t id = impl->WriteStringArray(); + + return BinaryStringArrayWriter(impl, id); + } + + void BinaryRawWriter::WriteNull() + { + impl->WriteNull(); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/binary/binary_reader.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/src/binary/binary_reader.cpp b/modules/platforms/cpp/core/src/binary/binary_reader.cpp new file mode 100644 index 0000000..b3fe4ee --- /dev/null +++ b/modules/platforms/cpp/core/src/binary/binary_reader.cpp @@ -0,0 +1,152 @@ +/* + * 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/impl/binary/binary_reader_impl.h" +#include "ignite/binary/binary_reader.h" + +using namespace ignite::impl::binary; + +namespace ignite +{ + namespace binary + { + BinaryReader::BinaryReader(BinaryReaderImpl* impl) : impl(impl) + { + // No-op. + } + + int8_t BinaryReader::ReadInt8(const char* fieldName) + { + return impl->ReadInt8(fieldName); + } + + int32_t BinaryReader::ReadInt8Array(const char* fieldName, int8_t* res, int32_t len) + { + return impl->ReadInt8Array(fieldName, res, len); + } + + bool BinaryReader::ReadBool(const char* fieldName) + { + return impl->ReadBool(fieldName); + } + + int32_t BinaryReader::ReadBoolArray(const char* fieldName, bool* res, int32_t len) + { + return impl->ReadBoolArray(fieldName, res, len); + } + + int16_t BinaryReader::ReadInt16(const char* fieldName) + { + return impl->ReadInt16(fieldName); + } + + int32_t BinaryReader::ReadInt16Array(const char* fieldName, int16_t* res, int32_t len) + { + return impl->ReadInt16Array(fieldName, res, len); + } + + uint16_t BinaryReader::ReadUInt16(const char* fieldName) + { + return impl->ReadUInt16(fieldName); + } + + int32_t BinaryReader::ReadUInt16Array(const char* fieldName, uint16_t* res, int32_t len) + { + return impl->ReadUInt16Array(fieldName, res, len); + } + + int32_t BinaryReader::ReadInt32(const char* fieldName) + { + return impl->ReadInt32(fieldName); + } + + int32_t BinaryReader::ReadInt32Array(const char* fieldName, int32_t* res, int32_t len) + { + return impl->ReadInt32Array(fieldName, res, len); + } + + int64_t BinaryReader::ReadInt64(const char* fieldName) + { + return impl->ReadInt64(fieldName); + } + + int32_t BinaryReader::ReadInt64Array(const char* fieldName, int64_t* res, int32_t len) + { + return impl->ReadInt64Array(fieldName, res, len); + } + + float BinaryReader::ReadFloat(const char* fieldName) + { + return impl->ReadFloat(fieldName); + } + + int32_t BinaryReader::ReadFloatArray(const char* fieldName, float* res, int32_t len) + { + return impl->ReadFloatArray(fieldName, res, len); + } + + double BinaryReader::ReadDouble(const char* fieldName) + { + return impl->ReadDouble(fieldName); + } + + int32_t BinaryReader::ReadDoubleArray(const char* fieldName, double* res, int32_t len) + { + return impl->ReadDoubleArray(fieldName, res, len); + } + + Guid BinaryReader::ReadGuid(const char* fieldName) + { + return impl->ReadGuid(fieldName); + } + + int32_t BinaryReader::ReadGuidArray(const char* fieldName, Guid* res, int32_t len) + { + return impl->ReadGuidArray(fieldName, res, len); + } + + int32_t BinaryReader::ReadString(const char* fieldName, char* res, int32_t len) + { + return impl->ReadString(fieldName, res, len); + } + + BinaryStringArrayReader BinaryReader::ReadStringArray(const char* fieldName) + { + int32_t size; + + int32_t id = impl->ReadStringArray(fieldName, &size); + + return BinaryStringArrayReader(impl, id, size); + } + + CollectionType BinaryReader::ReadCollectionType(const char* fieldName) + { + return impl->ReadCollectionType(fieldName); + } + + int32_t BinaryReader::ReadCollectionSize(const char* fieldName) + { + return impl->ReadCollectionSize(fieldName); + } + + BinaryRawReader BinaryReader::RawReader() + { + impl->SetRawMode(); + + return BinaryRawReader(impl); + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/binary/binary_type.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/src/binary/binary_type.cpp b/modules/platforms/cpp/core/src/binary/binary_type.cpp new file mode 100644 index 0000000..19d906d --- /dev/null +++ b/modules/platforms/cpp/core/src/binary/binary_type.cpp @@ -0,0 +1,51 @@ +/* + * 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/binary/binary_type.h" + +namespace ignite +{ + namespace binary + { + int32_t GetBinaryStringHashCode(const char* val) + { + if (val) + { + int32_t hash = 0; + + int i = 0; + + while (true) + { + char c = *(val + i++); + + if (c == '\0') + break; + + if ('A' <= c && c <= 'Z') + c = c | 0x20; + + hash = 31 * hash + c; + } + + return hash; + } + else + return 0; + } + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ignite/blob/303d79eb/modules/platforms/cpp/core/src/binary/binary_writer.cpp ---------------------------------------------------------------------- diff --git a/modules/platforms/cpp/core/src/binary/binary_writer.cpp b/modules/platforms/cpp/core/src/binary/binary_writer.cpp new file mode 100644 index 0000000..3247e66 --- /dev/null +++ b/modules/platforms/cpp/core/src/binary/binary_writer.cpp @@ -0,0 +1,154 @@ +/* + * 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/impl/binary/binary_writer_impl.h" +#include "ignite/binary/binary_writer.h" + +using namespace ignite::impl::binary; + +namespace ignite +{ + namespace binary + { + BinaryWriter::BinaryWriter(BinaryWriterImpl* impl) : impl(impl) + { + // No-op. + } + + void BinaryWriter::WriteInt8(const char* fieldName, int8_t val) + { + impl->WriteInt8(fieldName, val); + } + + void BinaryWriter::WriteInt8Array(const char* fieldName, const int8_t* val, int32_t len) + { + impl->WriteInt8Array(fieldName, val, len); + } + + void BinaryWriter::WriteBool(const char* fieldName, bool val) + { + impl->WriteBool(fieldName, val); + } + + void BinaryWriter::WriteBoolArray(const char* fieldName, const bool* val, int32_t len) + { + impl->WriteBoolArray(fieldName, val, len); + } + + void BinaryWriter::WriteInt16(const char* fieldName, int16_t val) + { + impl->WriteInt16(fieldName, val); + } + + void BinaryWriter::WriteInt16Array(const char* fieldName, const int16_t* val, int32_t len) + { + impl->WriteInt16Array(fieldName, val, len); + } + + void BinaryWriter::WriteUInt16(const char* fieldName, uint16_t val) + { + impl->WriteUInt16(fieldName, val); + } + + void BinaryWriter::WriteUInt16Array(const char* fieldName, const uint16_t* val, int32_t len) + { + impl->WriteUInt16Array(fieldName, val, len); + } + + void BinaryWriter::WriteInt32(const char* fieldName, int32_t val) + { + impl->WriteInt32(fieldName, val); + } + + void BinaryWriter::WriteInt32Array(const char* fieldName, const int32_t* val, int32_t len) + { + impl->WriteInt32Array(fieldName, val, len); + } + + void BinaryWriter::WriteInt64(const char* fieldName, const int64_t val) + { + impl->WriteInt64(fieldName, val); + } + + void BinaryWriter::WriteInt64Array(const char* fieldName, const int64_t* val, int32_t len) + { + impl->WriteInt64Array(fieldName, val, len); + } + + void BinaryWriter::WriteFloat(const char* fieldName, float val) + { + impl->WriteFloat(fieldName, val); + } + + void BinaryWriter::WriteFloatArray(const char* fieldName, const float* val, int32_t len) + { + impl->WriteFloatArray(fieldName, val, len); + } + + void BinaryWriter::WriteDouble(const char* fieldName, double val) + { + impl->WriteDouble(fieldName, val); + } + + void BinaryWriter::WriteDoubleArray(const char* fieldName, const double* val, int32_t len) + { + impl->WriteDoubleArray(fieldName, val, len); + } + + void BinaryWriter::WriteGuid(const char* fieldName, const Guid& val) + { + impl->WriteGuid(fieldName, val); + } + + void BinaryWriter::WriteGuidArray(const char* fieldName, const Guid* val, const int32_t len) + { + impl->WriteGuidArray(fieldName, val, len); + } + + void BinaryWriter::WriteString(const char* fieldName, const char* val) + { + if (val) + WriteString(fieldName, val, static_cast<int32_t>(strlen(val))); + else + WriteNull(fieldName); + } + + void BinaryWriter::WriteString(const char* fieldName, const char* val, int32_t len) + { + impl->WriteString(fieldName, val, len); + } + + BinaryStringArrayWriter BinaryWriter::WriteStringArray(const char* fieldName) + { + int32_t id = impl->WriteStringArray(fieldName); + + return BinaryStringArrayWriter(impl, id); + } + + void BinaryWriter::WriteNull(const char* fieldName) + { + impl->WriteNull(fieldName); + } + + BinaryRawWriter BinaryWriter::RawWriter() + { + impl->SetRawMode(); + + return BinaryRawWriter(impl); + } + } +} \ No newline at end of file