| Apache Ignite C++

binary_raw_writer.h
Go to the documentation of this file.
1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
23 #ifndef _IGNITE_BINARY_BINARY_RAW_WRITER
24 #define _IGNITE_BINARY_BINARY_RAW_WRITER
25
26 #include <stdint.h>
27
28 #include <ignite/common/common.h>
29
30 #include "ignite/impl/binary/binary_writer_impl.h"
31 #include "ignite/binary/binary_consts.h"
32 #include "ignite/binary/binary_containers.h"
33 #include "ignite/guid.h"
34 #include "ignite/date.h"
35 #include "ignite/timestamp.h"
36
37 namespace ignite
38 {
39 namespace binary
40 {
55 class IGNITE_IMPORT_EXPORT BinaryRawWriter
56 {
57 public:
65 BinaryRawWriter(ignite::impl::binary::BinaryWriterImpl* impl);
66
72 void WriteInt8(int8_t val);
73
80 void WriteInt8Array(const int8_t* val, int32_t len);
81
87 void WriteBool(bool val);
88
95 void WriteBoolArray(const bool* val, int32_t len);
96
102 void WriteInt16(int16_t val);
103
110 void WriteInt16Array(const int16_t* val, int32_t len);
111
117 void WriteUInt16(uint16_t val);
118
125 void WriteUInt16Array(const uint16_t* val, int32_t len);
126
132 void WriteInt32(int32_t val);
133
140 void WriteInt32Array(const int32_t* val, int32_t len);
141
147 void WriteInt64(int64_t val);
148
155 void WriteInt64Array(const int64_t* val, int32_t len);
156
162 void WriteFloat(float val);
163
170 void WriteFloatArray(const float* val, int32_t len);
171
177 void WriteDouble(double val);
178
185 void WriteDoubleArray(const double* val, int32_t len);
186
192 void WriteGuid(const Guid& val);
193
200 void WriteGuidArray(const Guid* val, int32_t len);
201
207 void WriteDate(const Date& val);
208
215 void WriteDateArray(const Date* val, int32_t len);
216
222 void WriteTimestamp(const Timestamp& val);
223
230 void WriteTimestampArray(const Timestamp* val, int32_t len);
231
237 void WriteTime(const Time& val);
238
245 void WriteTimeArray(const Time* val, int32_t len);
246
252 void WriteString(const char* val);
253
260 void WriteString(const char* val, int32_t len);
261
267 void WriteString(const std::string& val)
268 {
269 WriteString(val.c_str(), static_cast<int32_t>(val.size()));
270 }
271
283 BinaryStringArrayWriter WriteStringArray();
284
290 void WriteBinaryEnum(BinaryEnumEntry entry);
291
295 void WriteNull();
296
308 template<typename T>
309 BinaryArrayWriter<T> WriteArray()
310 {
311 int32_t id = impl->WriteArray();
312
313 return BinaryArrayWriter<T>(impl, id);
314 }
315
327 template<typename T>
328 BinaryCollectionWriter<T> WriteCollection()
329 {
330 return WriteCollection<T>(CollectionType::UNDEFINED);
331 }
332
345 template<typename T>
346 BinaryCollectionWriter<T> WriteCollection(CollectionType::Type typ)
347 {
348 int32_t id = impl->WriteCollection(typ);
349
350 return BinaryCollectionWriter<T>(impl, id);
351 }
352
359 template<typename InputIterator>
360 void WriteCollection(InputIterator first, InputIterator last)
361 {
362 impl->WriteCollection(first, last, CollectionType::UNDEFINED);
363 }
364
372 template<typename InputIterator>
373 void WriteCollection(InputIterator first, InputIterator last, CollectionType::Type typ)
374 {
375 impl->WriteCollection(first, last, typ);
376 }
377
389 template<typename K, typename V>
390 BinaryMapWriter<K, V> WriteMap()
391 {
392 return WriteMap<K, V>(MapType::UNDEFINED);
393 }
394
407 template<typename K, typename V>
408 BinaryMapWriter<K, V> WriteMap(MapType::Type typ)
409 {
410 int32_t id = impl->WriteMap(typ);
411
412 return BinaryMapWriter<K, V>(impl, id);
413 }
414
420 template<typename T>
421 void WriteObject(const T& val)
422 {
423 impl->WriteObject<T>(val);
424 }
425
433 template<typename T>
434 void WriteEnum(T val)
435 {
436 impl->WriteEnum(val);
437 }
438
439 private:
441 ignite::impl::binary::BinaryWriterImpl* impl;
442 };
443 }
444 }
445
446 #endif //_IGNITE_BINARY_BINARY_RAW_WRITER
ignite
Apache Ignite API.
Definition: cache.h:48
ignite::binary::BinaryRawWriter::WriteCollection
void WriteCollection(InputIterator first, InputIterator last)
Write values in interval [first, last).
Definition: binary_raw_writer.h:360
ignite::binary::BinaryStringArrayWriter
Binary string array writer.
Definition: binary_containers.h:48
ignite::binary::MapType::Type
Type
Definition: binary_consts.h:69
ignite::Time
Time type.
Definition: time.h:35
ignite::binary::BinaryRawWriter::WriteEnum
void WriteEnum(T val)
Write binary enum entry.
Definition: binary_raw_writer.h:434
ignite::Guid
Global universally unique identifier (GUID).
Definition: guid.h:36
ignite::binary::BinaryRawWriter::WriteMap
BinaryMapWriter< K, V > WriteMap(MapType::Type typ)
Start map write.
Definition: binary_raw_writer.h:408
ignite::binary::MapType::UNDEFINED
@ UNDEFINED
Undefined.
Definition: binary_consts.h:74
binary_consts.h
ignite::binary::CollectionType::UNDEFINED
@ UNDEFINED
Undefined.
Definition: binary_consts.h:40
ignite::binary::BinaryRawWriter::WriteCollection
void WriteCollection(InputIterator first, InputIterator last, CollectionType::Type typ)
Write values in interval [first, last).
Definition: binary_raw_writer.h:373
ignite::binary::BinaryArrayWriter
Binary array writer.
Definition: binary_containers.h:121
ignite::binary::BinaryCollectionWriter
Binary collection writer.
Definition: binary_containers.h:182
ignite::binary::BinaryRawWriter::WriteCollection
BinaryCollectionWriter< T > WriteCollection(CollectionType::Type typ)
Start collection write.
Definition: binary_raw_writer.h:346
date.h
ignite::binary::BinaryRawWriter
Binary raw writer.
Definition: binary_raw_writer.h:55
ignite::binary::BinaryRawWriter::WriteMap
BinaryMapWriter< K, V > WriteMap()
Start map write.
Definition: binary_raw_writer.h:390
ignite::binary::BinaryEnumEntry
Binary enum entry.
Definition: binary_enum_entry.h:39
ignite::Timestamp
Timestamp type.
Definition: timestamp.h:37
ignite::Date
Date type.
Definition: date.h:35
ignite::binary::BinaryRawWriter::WriteCollection
BinaryCollectionWriter< T > WriteCollection()
Start collection write.
Definition: binary_raw_writer.h:328
ignite::binary::BinaryMapWriter
Binary map writer.
Definition: binary_containers.h:241
ignite::binary::CollectionType::Type
Type
Definition: binary_consts.h:35
ignite::binary::BinaryRawWriter::WriteObject
void WriteObject(const T &val)
Write object.
Definition: binary_raw_writer.h:421
ignite::binary::BinaryRawWriter::WriteString
void WriteString(const std::string &val)
Write string.
Definition: binary_raw_writer.h:267
guid.h
binary_containers.h
timestamp.h
ignite::binary::BinaryRawWriter::WriteArray
BinaryArrayWriter< T > WriteArray()
Start array write.
Definition: binary_raw_writer.h:309