Apache Ignite C++
binary_raw_reader.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_READER
24 #define _IGNITE_BINARY_BINARY_RAW_READER
25 
26 #include <stdint.h>
27 #include <string>
28 
29 #include <ignite/common/common.h>
30 
31 #include "ignite/impl/binary/binary_reader_impl.h"
34 #include "ignite/guid.h"
35 #include "ignite/date.h"
36 #include "ignite/timestamp.h"
37 
38 namespace ignite
39 {
40  namespace binary
41  {
56  class IGNITE_IMPORT_EXPORT BinaryRawReader
57  {
58  public:
66  BinaryRawReader(ignite::impl::binary::BinaryReaderImpl* impl);
67 
73  int8_t ReadInt8();
74 
85  int32_t ReadInt8Array(int8_t* res, int32_t len);
86 
92  bool ReadBool();
93 
104  int32_t ReadBoolArray(bool* res, int32_t len);
105 
111  int16_t ReadInt16();
112 
123  int32_t ReadInt16Array(int16_t* res, int32_t len);
124 
130  uint16_t ReadUInt16();
131 
142  int32_t ReadUInt16Array(uint16_t* res, int32_t len);
143 
149  int32_t ReadInt32();
150 
161  int32_t ReadInt32Array(int32_t* res, int32_t len);
162 
168  int64_t ReadInt64();
169 
180  int32_t ReadInt64Array(int64_t* res, int32_t len);
181 
187  float ReadFloat();
188 
199  int32_t ReadFloatArray(float* res, int32_t len);
200 
206  double ReadDouble();
207 
218  int32_t ReadDoubleArray(double* res, int32_t len);
219 
225  Guid ReadGuid();
226 
237  int32_t ReadGuidArray(Guid* res, int32_t len);
238 
244  Date ReadDate();
245 
256  int32_t ReadDateArray(Date* res, int32_t len);
257 
263  Timestamp ReadTimestamp();
264 
275  int32_t ReadTimestampArray(Timestamp* res, int32_t len);
276 
288  int32_t ReadString(char* res, int32_t len);
289 
295  std::string ReadString()
296  {
297  int32_t len = ReadString(NULL, 0);
298 
299  if (len != -1)
300  {
301  ignite::common::FixedSizeArray<char> arr(len + 1);
302 
303  ReadString(arr.GetData(), static_cast<int32_t>(arr.GetSize()));
304 
305  return std::string(arr.GetData());
306  }
307  else
308  return std::string();
309  }
310 
316  BinaryStringArrayReader ReadStringArray();
317 
323  template<typename T>
325  {
326  int32_t size;
327 
328  int32_t id = impl->ReadArray(&size);
329 
330  return BinaryArrayReader<T>(impl, id, size);
331  }
332 
338  template<typename T>
340  {
341  CollectionType typ;
342  int32_t size;
343 
344  int32_t id = impl->ReadCollection(&typ, &size);
345 
346  return BinaryCollectionReader<T>(impl, id, typ, size);
347  }
348 
355  template<typename T, typename OutputIterator>
356  int32_t ReadCollection(OutputIterator out)
357  {
358  return impl->ReadCollection<T>(out);
359  }
360 
366  template<typename K, typename V>
368  {
369  MapType typ;
370  int32_t size;
371 
372  int32_t id = impl->ReadMap(&typ, &size);
373 
374  return BinaryMapReader<K, V>(impl, id, typ, size);
375  }
376 
382  CollectionType ReadCollectionType();
383 
389  int32_t ReadCollectionSize();
390 
396  template<typename T>
398  {
399  return impl->ReadObject<T>();
400  }
401  private:
403  ignite::impl::binary::BinaryReaderImpl* impl;
404  };
405  }
406 }
407 
408 #endif //_IGNITE_BINARY_BINARY_RAW_READER
Timestamp type.
Definition: timestamp.h:37
Declares specific binary constatants.
Date type.
Definition: date.h:35
Declares binary reader and writer types for the collections.
Binary string array reader.
Definition: binary_containers.h:297
Binary map reader.
Definition: binary_containers.h:561
BinaryCollectionReader< T > ReadCollection()
Start collection read.
Definition: binary_raw_reader.h:339
Binary collection reader.
Definition: binary_containers.h:468
Declares ignite::Guid class.
Declares ignite::Timestamp class.
BinaryMapReader< K, V > ReadMap()
Start map read.
Definition: binary_raw_reader.h:367
int32_t ReadCollection(OutputIterator out)
Read values and insert them to specified position.
Definition: binary_raw_reader.h:356
CollectionType
Binary collection types.
Definition: binary_consts.h:35
BinaryArrayReader< T > ReadArray()
Start array read.
Definition: binary_raw_reader.h:324
Binary array reader.
Definition: binary_containers.h:389
T ReadObject()
Read object.
Definition: binary_raw_reader.h:397
std::string ReadString()
Read string from the stream.
Definition: binary_raw_reader.h:295
Global universally unique identifier (GUID).
Definition: guid.h:36
Apache Ignite API.
Definition: cache.h:43
Declares ignite::Date class.
MapType
Binary map types.
Definition: binary_consts.h:66
Binary raw reader.
Definition: binary_raw_reader.h:56