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_RAW_WRITER
24 #define _IGNITE_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 
35 namespace ignite
36 {
37  namespace binary
38  {
42  class IGNITE_IMPORT_EXPORT BinaryRawWriter
43  {
44  public:
50  BinaryRawWriter(ignite::impl::binary::BinaryWriterImpl* impl);
51 
57  void WriteInt8(int8_t val);
58 
65  void WriteInt8Array(const int8_t* val, int32_t len);
66 
72  void WriteBool(bool val);
73 
80  void WriteBoolArray(const bool* val, int32_t len);
81 
87  void WriteInt16(int16_t val);
88 
95  void WriteInt16Array(const int16_t* val, int32_t len);
96 
102  void WriteUInt16(uint16_t val);
103 
110  void WriteUInt16Array(const uint16_t* val, int32_t len);
111 
117  void WriteInt32(int32_t val);
118 
125  void WriteInt32Array(const int32_t* val, int32_t len);
126 
132  void WriteInt64(int64_t val);
133 
140  void WriteInt64Array(const int64_t* val, int32_t len);
141 
147  void WriteFloat(float val);
148 
155  void WriteFloatArray(const float* val, int32_t len);
156 
162  void WriteDouble(double val);
163 
170  void WriteDoubleArray(const double* val, int32_t len);
171 
177  void WriteGuid(const Guid& val);
178 
185  void WriteGuidArray(const Guid* val, int32_t len);
186 
192  void WriteString(const char* val);
193 
200  void WriteString(const char* val, int32_t len);
201 
207  void WriteString(const std::string& val)
208  {
209  WriteString(val.c_str());
210  }
211 
217  BinaryStringArrayWriter WriteStringArray();
218 
222  void WriteNull();
223 
229  template<typename T>
231  {
232  int32_t id = impl->WriteArray();
233 
234  return BinaryArrayWriter<T>(impl, id);
235  }
236 
242  template<typename T>
244  {
245  return WriteCollection<T>(IGNITE_COLLECTION_UNDEFINED);
246  }
247 
254  template<typename T>
256  {
257  int32_t id = impl->WriteCollection(typ);
258 
259  return BinaryCollectionWriter<T>(impl, id);
260  }
261 
269  template<typename InputIterator>
270  void WriteCollection(InputIterator first, InputIterator last)
271  {
272  impl->WriteCollection(first, last, IGNITE_COLLECTION_UNDEFINED);
273  }
274 
282  template<typename InputIterator>
283  void WriteCollection(InputIterator first, InputIterator last, CollectionType typ)
284  {
285  impl->WriteCollection(first, last, typ);
286  }
287 
294  template<typename K, typename V>
296  {
297  return WriteMap<K, V>(IGNITE_MAP_UNDEFINED);
298  }
299 
306  template<typename K, typename V>
308  {
309  int32_t id = impl->WriteMap(typ);
310 
311  return BinaryMapWriter<K, V>(impl, id);
312  }
313 
319  template<typename T>
320  void WriteObject(T val)
321  {
322  impl->WriteObject<T>(val);
323  }
324  private:
326  ignite::impl::binary::BinaryWriterImpl* impl;
327  };
328  }
329 }
330 
331 #endif
BinaryArrayWriter< T > WriteArray()
Start array write.
Definition: binary_raw_writer.h:230
Undefined.
Definition: binary_consts.h:40
void WriteCollection(InputIterator first, InputIterator last)
Write values in interval [first, last).
Definition: binary_raw_writer.h:270
Declares specific binary constatants.
Declares binary reader and writer types for the collections.
Declares ignite::Guid class.
void WriteCollection(InputIterator first, InputIterator last, CollectionType typ)
Write values in interval [first, last).
Definition: binary_raw_writer.h:283
CollectionType
Binary collection types.
Definition: binary_consts.h:35
BinaryCollectionWriter< T > WriteCollection(CollectionType typ)
Start collection write.
Definition: binary_raw_writer.h:255
Undefined.
Definition: binary_consts.h:71
Binary collection writer.
Definition: binary_containers.h:135
Binary collection writer.
Definition: binary_containers.h:92
Binary string array writer.
Definition: binary_containers.h:40
BinaryCollectionWriter< T > WriteCollection()
Start collection write.
Definition: binary_raw_writer.h:243
Binary raw writer.
Definition: binary_raw_writer.h:42
void WriteString(const std::string &val)
Write string.
Definition: binary_raw_writer.h:207
Global universally unique identifier (GUID).
Definition: guid.h:35
BinaryMapWriter< K, V > WriteMap()
Start map write.
Definition: binary_raw_writer.h:295
void WriteObject(T val)
Write object.
Definition: binary_raw_writer.h:320
Binary map writer.
Definition: binary_containers.h:178
BinaryMapWriter< K, V > WriteMap(MapType typ)
Start map write.
Definition: binary_raw_writer.h:307
Apache Ignite API.
Definition: binary_consts.h:28
MapType
Binary map types.
Definition: binary_consts.h:66