GridGain C++ Client Library
portable_raw_reader.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_READER
16 #define _GRIDGAIN_PORTABLE_RAW_READER
17 
18 #include <stdint.h>
19 #include <string>
20 
21 #include <ignite/common/common.h>
22 
23 #include "gridgain/impl/portable/portable_reader_impl.h"
26 #include "gridgain/guid.h"
27 
28 namespace gridgain
29 {
30  namespace portable
31  {
35  class IGNITE_IMPORT_EXPORT PortableRawReader
36  {
37  public:
43  PortableRawReader(gridgain::impl::portable::PortableReaderImpl* impl);
44 
50  int8_t ReadInt8();
51 
62  int32_t ReadInt8Array(int8_t* res, const int32_t len);
63 
69  bool ReadBool();
70 
81  int32_t ReadBoolArray(bool* res, const int32_t len);
82 
88  int16_t ReadInt16();
89 
100  int32_t ReadInt16Array(int16_t* res, const int32_t len);
101 
107  uint16_t ReadUInt16();
108 
119  int32_t ReadUInt16Array(uint16_t* res, const int32_t len);
120 
126  int32_t ReadInt32();
127 
138  int32_t ReadInt32Array(int32_t* res, const int32_t len);
139 
145  int64_t ReadInt64();
146 
157  int32_t ReadInt64Array(int64_t* res, const int32_t len);
158 
164  float ReadFloat();
165 
176  int32_t ReadFloatArray(float* res, const int32_t len);
177 
183  double ReadDouble();
184 
195  int32_t ReadDoubleArray(double* res, const int32_t len);
196 
202  Guid ReadGuid();
203 
214  int32_t ReadGuidArray(Guid* res, const int32_t len);
215 
227  int32_t ReadString(char* res, const int32_t len);
228 
234  std::string ReadString()
235  {
236  int32_t len = ReadString(NULL, 0);
237 
238  if (len != -1)
239  {
240  gridgain::impl::utils::SafeArray<char> arr(len + 1);
241 
242  ReadString(arr.target, len + 1);
243 
244  return std::string(arr.target);
245  }
246  else
247  return std::string();
248  }
249 
255  PortableStringArrayReader ReadStringArray();
256 
262  template<typename T>
264  {
265  int32_t size;
266 
267  int32_t id = impl->ReadArray(&size);
268 
269  return PortableArrayReader<T>(impl, id, size);
270  }
271 
277  template<typename T>
279  {
280  CollectionType typ;
281  int32_t size;
282 
283  int32_t id = impl->ReadCollection(&typ, &size);
284 
285  return PortableCollectionReader<T>(impl, id, typ, size);
286  }
287 
294  template<typename T, typename OutputIterator>
295  int32_t ReadCollection(OutputIterator out)
296  {
297  return impl->ReadCollection<T>(out);
298  }
299 
305  template<typename K, typename V>
307  {
308  MapType typ;
309  int32_t size;
310 
311  int32_t id = impl->ReadMap(&typ, &size);
312 
313  return PortableMapReader<K, V>(impl, id, typ, size);
314  }
315 
321  CollectionType ReadCollectionType();
322 
328  int32_t ReadCollectionSize();
329 
335  template<typename T>
337  {
338  return impl->ReadObject<T>();
339  }
340  private:
342  gridgain::impl::portable::PortableReaderImpl* impl;
343  };
344  }
345 }
346 
347 #endif
T ReadObject()
Read object.
Definition: portable_raw_reader.h:336
Portable raw reader.
Definition: portable_raw_reader.h:35
Global universally unique identifier (GUID).
Definition: guid.h:27
Declares portable reader and writer types for the collections.
Declares gridgain::Guid class.
Portable array reader.
Definition: portable_containers.h:291
Portable string array reader.
Definition: portable_containers.h:212
CollectionType
Portable collection types.
Definition: portable_consts.h:27
int32_t ReadCollection(OutputIterator out)
Read values and insert them to specified position.
Definition: portable_raw_reader.h:295
Portable collection reader.
Definition: portable_containers.h:359
Portable map reader.
Definition: portable_containers.h:441
std::string ReadString()
Read string from the stream.
Definition: portable_raw_reader.h:234
Declares specific portable constants.
PortableArrayReader< T > ReadArray()
Start array read.
Definition: portable_raw_reader.h:263
PortableMapReader< K, V > ReadMap()
Start map read.
Definition: portable_raw_reader.h:306
GridGain API.
Definition: cache.h:35
PortableCollectionReader< T > ReadCollection()
Start collection read.
Definition: portable_raw_reader.h:278
MapType
Portable map types.
Definition: portable_consts.h:68