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"
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, const 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());
270  }
271 
277  BinaryStringArrayWriter WriteStringArray();
278 
282  void WriteNull();
283 
289  template<typename T>
291  {
292  int32_t id = impl->WriteArray();
293 
294  return BinaryArrayWriter<T>(impl, id);
295  }
296 
302  template<typename T>
304  {
305  return WriteCollection<T>(CollectionType::UNDEFINED);
306  }
307 
314  template<typename T>
316  {
317  int32_t id = impl->WriteCollection(typ);
318 
319  return BinaryCollectionWriter<T>(impl, id);
320  }
321 
328  template<typename InputIterator>
329  void WriteCollection(InputIterator first, InputIterator last)
330  {
331  impl->WriteCollection(first, last, CollectionType::UNDEFINED);
332  }
333 
341  template<typename InputIterator>
342  void WriteCollection(InputIterator first, InputIterator last, CollectionType::Type typ)
343  {
344  impl->WriteCollection(first, last, typ);
345  }
346 
352  template<typename K, typename V>
354  {
355  return WriteMap<K, V>(MapType::UNDEFINED);
356  }
357 
364  template<typename K, typename V>
366  {
367  int32_t id = impl->WriteMap(typ);
368 
369  return BinaryMapWriter<K, V>(impl, id);
370  }
371 
377  template<typename T>
378  void WriteObject(const T& val)
379  {
380  impl->WriteObject<T>(val);
381  }
382  private:
384  ignite::impl::binary::BinaryWriterImpl* impl;
385  };
386  }
387 }
388 
389 #endif //_IGNITE_BINARY_BINARY_RAW_WRITER
BinaryArrayWriter< T > WriteArray()
Start array write.
Definition: binary_raw_writer.h:290
Timestamp type.
Definition: timestamp.h:37
void WriteCollection(InputIterator first, InputIterator last)
Write values in interval [first, last).
Definition: binary_raw_writer.h:329
Declares specific binary constatants.
Date type.
Definition: date.h:35
Declares binary reader and writer types for the collections.
BinaryMapWriter< K, V > WriteMap(MapType::Type typ)
Start map write.
Definition: binary_raw_writer.h:365
Declares ignite::Guid class.
Declares ignite::Timestamp class.
BinaryCollectionWriter< T > WriteCollection(CollectionType::Type typ)
Start collection write.
Definition: binary_raw_writer.h:315
void WriteCollection(InputIterator first, InputIterator last, CollectionType::Type typ)
Write values in interval [first, last).
Definition: binary_raw_writer.h:342
Binary collection writer.
Definition: binary_containers.h:182
Binary array writer.
Definition: binary_containers.h:121
Type
Definition: binary_consts.h:35
void WriteObject(const T &val)
Write object.
Definition: binary_raw_writer.h:378
Type
Definition: binary_consts.h:69
Time type.
Definition: time.h:35
Binary string array writer.
Definition: binary_containers.h:48
BinaryCollectionWriter< T > WriteCollection()
Start collection write.
Definition: binary_raw_writer.h:303
Binary raw writer.
Definition: binary_raw_writer.h:55
Undefined.
Definition: binary_consts.h:74
Undefined.
Definition: binary_consts.h:40
void WriteString(const std::string &val)
Write string.
Definition: binary_raw_writer.h:267
Global universally unique identifier (GUID).
Definition: guid.h:36
BinaryMapWriter< K, V > WriteMap()
Start map write.
Definition: binary_raw_writer.h:353
Binary map writer.
Definition: binary_containers.h:241
Apache Ignite API.
Definition: cache.h:48
Declares ignite::Date class.