GridGain C++ Client Library
portable_raw_writer.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) GridGain Systems. All Rights Reserved.
3  * _________ _____ __________________ _____
4  * __ ____/___________(_)______ /__ ____/______ ____(_)_______
5  * _ / __ __ ___/__ / _ __ / _ / __ _ __ `/__ / __ __ \
6  * / /_/ / _ / _ / / /_/ / / /_/ / / /_/ / _ / _ / / /
7  * \____/ /_/ /_/ \_,__/ \____/ \__,_/ /_/ /_/ /_/
8  */
9 
15 #ifndef _GRIDGAIN_PORTABLE_RAW_WRITER
16 #define _GRIDGAIN_PORTABLE_RAW_WRITER
17 
18 #include <stdint.h>
19 
20 #include <ignite/common/common.h>
21 
22 #include "gridgain/impl/portable/portable_writer_impl.h"
25 #include "gridgain/guid.h"
26 
27 namespace gridgain
28 {
29  namespace portable
30  {
34  class IGNITE_IMPORT_EXPORT PortableRawWriter
35  {
36  public:
42  PortableRawWriter(gridgain::impl::portable::PortableWriterImpl* impl);
43 
49  void WriteInt8(int8_t val);
50 
57  void WriteInt8Array(const int8_t* val, int32_t len);
58 
64  void WriteBool(bool val);
65 
72  void WriteBoolArray(const bool* val, int32_t len);
73 
79  void WriteInt16(int16_t val);
80 
87  void WriteInt16Array(const int16_t* val, int32_t len);
88 
94  void WriteUInt16(uint16_t val);
95 
102  void WriteUInt16Array(const uint16_t* val, int32_t len);
103 
109  void WriteInt32(int32_t val);
110 
117  void WriteInt32Array(const int32_t* val, int32_t len);
118 
124  void WriteInt64(int64_t val);
125 
132  void WriteInt64Array(const int64_t* val, int32_t len);
133 
139  void WriteFloat(float val);
140 
147  void WriteFloatArray(const float* val, int32_t len);
148 
154  void WriteDouble(double val);
155 
162  void WriteDoubleArray(const double* val, int32_t len);
163 
169  void WriteGuid(const Guid& val);
170 
177  void WriteGuidArray(const Guid* val, int32_t len);
178 
184  void WriteString(const char* val);
185 
192  void WriteString(const char* val, int32_t len);
193 
199  void WriteString(const std::string& val)
200  {
201  WriteString(val.c_str());
202  }
203 
209  PortableStringArrayWriter WriteStringArray();
210 
214  void WriteNull();
215 
221  template<typename T>
223  {
224  int32_t id = impl->WriteArray();
225 
226  return PortableArrayWriter<T>(impl, id);
227  }
228 
234  template<typename T>
236  {
237  return WriteCollection<T>(GG_COLLECTION_UNDEFINED);
238  }
239 
246  template<typename T>
248  {
249  int32_t id = impl->WriteCollection(typ);
250 
251  return PortableCollectionWriter<T>(impl, id);
252  }
253 
261  template<typename InputIterator>
262  void WriteCollection(InputIterator first, InputIterator last)
263  {
264  impl->WriteCollection(first, last, GG_COLLECTION_UNDEFINED);
265  }
266 
274  template<typename InputIterator>
275  void WriteCollection(InputIterator first, InputIterator last, CollectionType typ)
276  {
277  impl->WriteCollection(first, last, typ);
278  }
279 
286  template<typename K, typename V>
288  {
289  return WriteMap<K, V>(GG_MAP_UNDEFINED);
290  }
291 
298  template<typename K, typename V>
300  {
301  int32_t id = impl->WriteMap(typ);
302 
303  return PortableMapWriter<K, V>(impl, id);
304  }
305 
311  template<typename T>
312  void WriteObject(T val)
313  {
314  impl->WriteObject<T>(val);
315  }
316  private:
318  gridgain::impl::portable::PortableWriterImpl* impl;
319  };
320  }
321 }
322 
323 #endif
Portable collection writer.
Definition: portable_containers.h:127
Portable collection writer.
Definition: portable_containers.h:84
Global universally unique identifier (GUID).
Definition: guid.h:27
Declares portable reader and writer types for the collections.
Declares gridgain::Guid class.
CollectionType
Portable collection types.
Definition: portable_consts.h:27
Portable string array writer.
Definition: portable_containers.h:32
Undefined.
Definition: portable_consts.h:73
Portable map writer.
Definition: portable_containers.h:170
Undefined.
Definition: portable_consts.h:32
Declares specific portable constants.
void WriteObject(T val)
Write object.
Definition: portable_raw_writer.h:312
PortableCollectionWriter< T > WriteCollection(CollectionType typ)
Start collection write.
Definition: portable_raw_writer.h:247
PortableArrayWriter< T > WriteArray()
Start array write.
Definition: portable_raw_writer.h:222
PortableMapWriter< K, V > WriteMap(MapType typ)
Start map write.
Definition: portable_raw_writer.h:299
PortableMapWriter< K, V > WriteMap()
Start map write.
Definition: portable_raw_writer.h:287
Portable raw writer.
Definition: portable_raw_writer.h:34
void WriteCollection(InputIterator first, InputIterator last, CollectionType typ)
Write values in interval [first, last).
Definition: portable_raw_writer.h:275
void WriteString(const std::string &val)
Write string.
Definition: portable_raw_writer.h:199
void WriteCollection(InputIterator first, InputIterator last)
Write values in interval [first, last).
Definition: portable_raw_writer.h:262
GridGain API.
Definition: cache.h:35
MapType
Portable map types.
Definition: portable_consts.h:68
PortableCollectionWriter< T > WriteCollection()
Start collection write.
Definition: portable_raw_writer.h:235