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 WriteString(const char* val);
238 
245  void WriteString(const char* val, int32_t len);
246 
252  void WriteString(const std::string& val)
253  {
254  WriteString(val.c_str());
255  }
256 
262  BinaryStringArrayWriter WriteStringArray();
263 
267  void WriteNull();
268 
274  template<typename T>
276  {
277  int32_t id = impl->WriteArray();
278 
279  return BinaryArrayWriter<T>(impl, id);
280  }
281 
287  template<typename T>
289  {
290  return WriteCollection<T>(IGNITE_COLLECTION_UNDEFINED);
291  }
292 
299  template<typename T>
301  {
302  int32_t id = impl->WriteCollection(typ);
303 
304  return BinaryCollectionWriter<T>(impl, id);
305  }
306 
314  template<typename InputIterator>
315  void WriteCollection(InputIterator first, InputIterator last)
316  {
317  impl->WriteCollection(first, last, IGNITE_COLLECTION_UNDEFINED);
318  }
319 
327  template<typename InputIterator>
328  void WriteCollection(InputIterator first, InputIterator last, CollectionType typ)
329  {
330  impl->WriteCollection(first, last, typ);
331  }
332 
339  template<typename K, typename V>
341  {
342  return WriteMap<K, V>(IGNITE_MAP_UNDEFINED);
343  }
344 
351  template<typename K, typename V>
353  {
354  int32_t id = impl->WriteMap(typ);
355 
356  return BinaryMapWriter<K, V>(impl, id);
357  }
358 
364  template<typename T>
365  void WriteObject(T val)
366  {
367  impl->WriteObject<T>(val);
368  }
369  private:
371  ignite::impl::binary::BinaryWriterImpl* impl;
372  };
373  }
374 }
375 
376 #endif //_IGNITE_BINARY_BINARY_RAW_WRITER
BinaryArrayWriter< T > WriteArray()
Start array write.
Definition: binary_raw_writer.h:275
Undefined.
Definition: binary_consts.h:40
Timestamp type.
Definition: timestamp.h:37
void WriteCollection(InputIterator first, InputIterator last)
Write values in interval [first, last).
Definition: binary_raw_writer.h:315
Declares specific binary constatants.
Date type.
Definition: date.h:35
Declares binary reader and writer types for the collections.
Declares ignite::Guid class.
Declares ignite::Timestamp class.
void WriteCollection(InputIterator first, InputIterator last, CollectionType typ)
Write values in interval [first, last).
Definition: binary_raw_writer.h:328
CollectionType
Binary collection types.
Definition: binary_consts.h:35
BinaryCollectionWriter< T > WriteCollection(CollectionType typ)
Start collection write.
Definition: binary_raw_writer.h:300
Undefined.
Definition: binary_consts.h:71
Binary collection writer.
Definition: binary_containers.h:182
Binary array writer.
Definition: binary_containers.h:121
Binary string array writer.
Definition: binary_containers.h:48
BinaryCollectionWriter< T > WriteCollection()
Start collection write.
Definition: binary_raw_writer.h:288
Binary raw writer.
Definition: binary_raw_writer.h:55
void WriteString(const std::string &val)
Write string.
Definition: binary_raw_writer.h:252
Global universally unique identifier (GUID).
Definition: guid.h:36
BinaryMapWriter< K, V > WriteMap()
Start map write.
Definition: binary_raw_writer.h:340
void WriteObject(T val)
Write object.
Definition: binary_raw_writer.h:365
Binary map writer.
Definition: binary_containers.h:241
BinaryMapWriter< K, V > WriteMap(MapType typ)
Start map write.
Definition: binary_raw_writer.h:352
Apache Ignite API.
Definition: cache.h:43
Declares ignite::Date class.
MapType
Binary map types.
Definition: binary_consts.h:66