GridGain C++ Client Library
portable_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_WRITER
16 #define _GRIDGAIN_PORTABLE_WRITER
17 
18 #include <string>
19 #include <stdint.h>
20 
21 #include <ignite/common/common.h>
22 
24 
25 namespace gridgain
26 {
27  namespace portable
28  {
32  class IGNITE_IMPORT_EXPORT PortableWriter
33  {
34  public:
40  PortableWriter(gridgain::impl::portable::PortableWriterImpl* impl);
41 
48  void WriteInt8(const char* fieldName, int8_t val);
49 
57  void WriteInt8Array(const char* fieldName, const int8_t* val, int32_t len);
58 
65  void WriteBool(const char* fieldName, bool val);
66 
74  void WriteBoolArray(const char* fieldName, const bool* val, int32_t len);
75 
82  void WriteInt16(const char* fieldName, int16_t val);
83 
91  void WriteInt16Array(const char* fieldName, const int16_t* val, int32_t len);
92 
99  void WriteUInt16(const char* fieldName, uint16_t val);
100 
108  void WriteUInt16Array(const char* fieldName, const uint16_t* val, int32_t len);
109 
116  void WriteInt32(const char* fieldName, int32_t val);
117 
125  void WriteInt32Array(const char* fieldName, const int32_t* val, int32_t len);
126 
133  void WriteInt64(const char* fieldName, int64_t val);
134 
142  void WriteInt64Array(const char* fieldName, const int64_t* val, int32_t len);
143 
150  void WriteFloat(const char* fieldName, float val);
151 
159  void WriteFloatArray(const char* fieldName, const float* val, int32_t len);
160 
167  void WriteDouble(const char* fieldName, double val);
168 
176  void WriteDoubleArray(const char* fieldName, const double* val, int32_t len);
177 
184  void WriteGuid(const char* fieldName, const Guid& val);
185 
193  void WriteGuidArray(const char* fieldName, const Guid* val, int32_t len);
194 
201  void WriteString(const char* fieldName, const char* val);
202 
210  void WriteString(const char* fieldName, const char* val, int32_t len);
211 
218  void WriteString(const char* fieldName, const std::string& val)
219  {
220  WriteString(fieldName, val.c_str());
221  }
222 
229  PortableStringArrayWriter WriteStringArray(const char* fieldName);
230 
236  void WriteNull(const char* fieldName);
237 
244  template<typename T>
245  PortableArrayWriter<T> WriteArray(const char* fieldName)
246  {
247  int32_t id = impl->WriteArray(fieldName);
248 
249  return PortableArrayWriter<T>(impl, id);
250  }
251 
258  template<typename T>
260  {
261  return WriteCollection<T>(fieldName, GG_COLLECTION_UNDEFINED);
262  }
263 
271  template<typename T>
273  {
274  int32_t id = impl->WriteCollection(fieldName, typ);
275 
276  return PortableCollectionWriter<T>(impl, id);
277  }
278 
286  template<typename InputIterator>
287  void WriteCollection(const char* fieldName, InputIterator first, InputIterator last)
288  {
289  WriteCollection(fieldName, first, last, GG_COLLECTION_UNDEFINED);
290  }
291 
300  template<typename InputIterator>
301  void WriteCollection(const char* fieldName, InputIterator first, InputIterator last, CollectionType typ)
302  {
303  impl->WriteCollection(fieldName, first, last, typ);
304  }
305 
313  template<typename K, typename V>
314  PortableMapWriter<K, V> WriteMap(const char* fieldName)
315  {
316  return WriteMap<K, V>(fieldName, GG_MAP_UNDEFINED);
317  }
318 
326  template<typename K, typename V>
327  PortableMapWriter<K, V> WriteMap(const char* fieldName, MapType typ)
328  {
329  int32_t id = impl->WriteMap(fieldName, typ);
330 
331  return PortableMapWriter<K, V>(impl, id);
332  }
333 
340  template<typename T>
341  void WriteObject(const char* fieldName, T val)
342  {
343  impl->WriteObject<T>(fieldName, val);
344  }
345 
351  PortableRawWriter RawWriter();
352  private:
354  gridgain::impl::portable::PortableWriterImpl* impl;
355  };
356  }
357 }
358 
359 #endif
Portable collection writer.
Definition: portable_containers.h:127
Portable collection writer.
Definition: portable_containers.h:84
void WriteCollection(const char *fieldName, InputIterator first, InputIterator last, CollectionType typ)
Write values in interval [first, last).
Definition: portable_writer.h:301
Portable writer.
Definition: portable_writer.h:32
Global universally unique identifier (GUID).
Definition: guid.h:27
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
PortableMapWriter< K, V > WriteMap(const char *fieldName, MapType typ)
Start map write.
Definition: portable_writer.h:327
Undefined.
Definition: portable_consts.h:32
void WriteString(const char *fieldName, const std::string &val)
Write string.
Definition: portable_writer.h:218
PortableCollectionWriter< T > WriteCollection(const char *fieldName, CollectionType typ)
Start collection write.
Definition: portable_writer.h:272
void WriteObject(const char *fieldName, T val)
Write object.
Definition: portable_writer.h:341
PortableCollectionWriter< T > WriteCollection(const char *fieldName)
Start collection write.
Definition: portable_writer.h:259
PortableMapWriter< K, V > WriteMap(const char *fieldName)
Start map write.
Definition: portable_writer.h:314
PortableArrayWriter< T > WriteArray(const char *fieldName)
Start array write.
Definition: portable_writer.h:245
Declares gridgain::portable::PortableRawWriter class.
Portable raw writer.
Definition: portable_raw_writer.h:34
void WriteCollection(const char *fieldName, InputIterator first, InputIterator last)
Write values in interval [first, last).
Definition: portable_writer.h:287
GridGain API.
Definition: cache.h:35
MapType
Portable map types.
Definition: portable_consts.h:68