VMware Tanzu GemFire Native C++ Reference  10.1.5
DataOutput.hpp
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 
18 #pragma once
19 
20 #ifndef GEODE_DATAOUTPUT_H_
21 #define GEODE_DATAOUTPUT_H_
22 
23 #include <algorithm>
24 #include <cstdlib>
25 #include <cstring>
26 #include <string>
27 
28 #include "CacheableString.hpp"
29 #include "ExceptionTypes.hpp"
30 #include "Serializable.hpp"
31 #include "internal/geode_globals.hpp"
32 
33 namespace apache {
34 namespace geode {
35 namespace client {
36 
37 class SerializationRegistry;
38 class DataOutputInternal;
39 class CacheImpl;
40 class Pool;
41 class TcrMessage;
42 
48 class APACHE_GEODE_EXPORT DataOutput {
49  public:
55  inline void write(uint8_t value) {
56  ensureCapacity(1);
57  writeNoCheck(value);
58  }
59 
65  inline void write(int8_t value) { write(static_cast<uint8_t>(value)); }
66 
72  inline void writeBoolean(bool value) { write(static_cast<uint8_t>(value)); }
73 
80  inline void writeBytes(const uint8_t* bytes, int32_t len) {
81  if (len >= 0) {
82  ensureCapacity(len + 5);
83  writeArrayLen(bytes == nullptr ? 0 : len); // length of bytes...
84  if (len > 0 && bytes != nullptr) {
85  std::memcpy(m_buf, bytes, len);
86  m_buf += len;
87  }
88  } else {
89  write(static_cast<int8_t>(-1));
90  }
91  }
92 
99  inline void writeBytes(const int8_t* bytes, int32_t len) {
100  writeBytes(reinterpret_cast<const uint8_t*>(bytes), len);
101  }
102 
114  inline void writeBytesOnly(const uint8_t* bytes, size_t len) {
115  ensureCapacity(len);
116  std::memcpy(m_buf, bytes, len);
117  m_buf += len;
118  }
119 
131  inline void writeBytesOnly(const int8_t* bytes, size_t len) {
132  writeBytesOnly(reinterpret_cast<const uint8_t*>(bytes), len);
133  }
134 
140  inline void writeInt(uint16_t value) {
141  ensureCapacity(2);
142  *(m_buf++) = static_cast<uint8_t>(value >> 8);
143  *(m_buf++) = static_cast<uint8_t>(value);
144  }
145 
151  inline void writeChar(uint16_t value) {
152  ensureCapacity(2);
153  *(m_buf++) = static_cast<uint8_t>(value >> 8);
154  *(m_buf++) = static_cast<uint8_t>(value);
155  }
156 
162  inline void writeInt(uint32_t value) {
163  ensureCapacity(4);
164  *(m_buf++) = static_cast<uint8_t>(value >> 24);
165  *(m_buf++) = static_cast<uint8_t>(value >> 16);
166  *(m_buf++) = static_cast<uint8_t>(value >> 8);
167  *(m_buf++) = static_cast<uint8_t>(value);
168  }
169 
175  inline void writeInt(uint64_t value) {
176  ensureCapacity(8);
177  *(m_buf++) = static_cast<uint8_t>(value >> 56);
178  *(m_buf++) = static_cast<uint8_t>(value >> 48);
179  *(m_buf++) = static_cast<uint8_t>(value >> 40);
180  *(m_buf++) = static_cast<uint8_t>(value >> 32);
181  *(m_buf++) = static_cast<uint8_t>(value >> 24);
182  *(m_buf++) = static_cast<uint8_t>(value >> 16);
183  *(m_buf++) = static_cast<uint8_t>(value >> 8);
184  *(m_buf++) = static_cast<uint8_t>(value);
185  }
186 
192  inline void writeInt(int16_t value) {
193  writeInt(static_cast<uint16_t>(value));
194  }
195 
201  inline void writeInt(int32_t value) {
202  writeInt(static_cast<uint32_t>(value));
203  }
204 
210  inline void writeInt(int64_t value) {
211  writeInt(static_cast<uint64_t>(value));
212  }
213 
221  inline void writeArrayLen(int32_t len) {
222  if (len == -1) {
223  write(static_cast<int8_t>(-1));
224  } else if (len <= 252) { // 252 is java's ((byte)-4 && 0xFF)
225  write(static_cast<uint8_t>(len));
226  } else if (len <= 0xFFFF) {
227  write(static_cast<int8_t>(-2));
228  writeInt(static_cast<uint16_t>(len));
229  } else {
230  write(static_cast<int8_t>(-3));
231  writeInt(len);
232  }
233  }
234 
240  inline void writeFloat(float value) {
241  union float_uint32_t {
242  float f;
243  uint32_t u;
244  } v;
245  v.f = value;
246  writeInt(v.u);
247  }
248 
254  inline void writeDouble(double value) {
255  union double_uint64_t {
256  double d;
257  uint64_t ll;
258  } v;
259  v.d = value;
260  writeInt(v.ll);
261  }
262 
263  template <class _CharT>
264  inline void writeString(const _CharT* value) {
265  // TODO string should we convert to empty string?
266  if (nullptr == value) {
267  write(static_cast<uint8_t>(DSCode::CacheableNullString));
268  } else {
269  writeString(std::basic_string<_CharT>(value));
270  }
271  }
272 
273  template <class _CharT, class... _Tail>
274  inline void writeString(const std::basic_string<_CharT, _Tail...>& value) {
275  // without scanning string, making worst case choices.
276  // TODO constexp for each string type to jmutf8 length conversion
277  if (value.length() * 3 <= std::numeric_limits<uint16_t>::max()) {
278  write(static_cast<uint8_t>(DSCode::CacheableString));
279  writeJavaModifiedUtf8(value);
280  } else {
281  write(static_cast<uint8_t>(DSCode::CacheableStringHuge));
282  writeUtf16Huge(value);
283  }
284  }
285 
286  template <class _CharT>
287  inline void writeUTF(const _CharT* value) {
288  if (nullptr == value) {
289  throw NullPointerException("Parameter value must not be null.");
290  }
291  writeUTF(std::basic_string<_CharT>(value));
292  }
293 
294  template <class _CharT, class... Tail>
295  inline void writeUTF(const std::basic_string<_CharT, Tail...>& value) {
296  writeJavaModifiedUtf8(value);
297  }
298 
308  template <class _CharT, class... _Tail>
309  inline void writeChars(const std::basic_string<_CharT, _Tail...>& value) {
310  writeUtf16(value);
311  }
312 
325  template <class _CharT>
326  inline void writeChars(const _CharT* value) {
327  writeChars(std::basic_string<_CharT>(value));
328  }
329 
336  template <class PTR>
337  void writeObject(const std::shared_ptr<PTR>& objptr, bool isDelta = false) {
338  writeObjectInternal(objptr, isDelta);
339  }
340 
345  const uint8_t* getCursor() { return m_buf; }
346 
352  void advanceCursor(size_t offset) {
353  ensureCapacity(offset);
354  m_buf += offset;
355  }
356 
362  void rewindCursor(size_t offset) { m_buf -= offset; }
363 
364  void updateValueAtPos(size_t offset, uint8_t value) {
365  m_bytes.get()[offset] = value;
366  }
367 
368  uint8_t getValueAtPos(size_t offset) { return m_bytes.get()[offset]; }
369 
373  inline const uint8_t* getBuffer() const {
374  // GF_R_ASSERT(!((uint32_t)(m_bytes) % 4));
375  return m_bytes.get();
376  }
377 
381  inline size_t getRemainingBufferLength() const {
382  // GF_R_ASSERT(!((uint32_t)(m_bytes) % 4));
383  return m_size - getBufferLength();
384  }
385 
392  inline const uint8_t* getBuffer(size_t* rsize) const {
393  *rsize = m_buf - m_bytes.get();
394  // GF_R_ASSERT(!((uint32_t)(m_bytes) % 4));
395  return m_bytes.get();
396  }
397 
398  inline uint8_t* getBufferCopy() {
399  size_t size = m_buf - m_bytes.get();
400  auto result = static_cast<uint8_t*>(std::malloc(size * sizeof(uint8_t)));
401  if (result == nullptr) {
402  throw OutOfMemoryException("Out of Memory while resizing buffer");
403  }
404  std::memcpy(result, m_bytes.get(), size);
405  return result;
406  }
407 
412  inline size_t getBufferLength() const { return m_buf - m_bytes.get(); }
413 
417  inline void reset() {
418  if (m_haveBigBuffer) {
419  // create smaller buffer
420  m_bytes.reset(
421  static_cast<uint8_t*>(std::malloc(m_lowWaterMark * sizeof(uint8_t))));
422  if (m_bytes == nullptr) {
423  throw OutOfMemoryException("Out of Memory while resizing buffer");
424  }
425  m_size = m_lowWaterMark;
426  // reset the flag
427  m_haveBigBuffer = false;
428  // release the lock
429  releaseLock();
430  }
431  m_buf = m_bytes.get();
432  }
433 
434  // make sure there is room left for the requested size item.
435  inline void ensureCapacity(size_t size) {
436  size_t offset = m_buf - m_bytes.get();
437  if ((m_size - offset) < size) {
438  size_t newSize = m_size * 2 + (8192 * (size / 8192));
439  if (newSize >= m_highWaterMark && !m_haveBigBuffer) {
440  // acquire the lock
441  acquireLock();
442  // set flag
443  m_haveBigBuffer = true;
444  }
445  m_size = newSize;
446 
447  auto bytes = m_bytes.release();
448  auto tmp =
449  static_cast<uint8_t*>(std::realloc(bytes, m_size * sizeof(uint8_t)));
450  if (tmp == nullptr) {
451  throw OutOfMemoryException("Out of Memory while resizing buffer");
452  }
453  m_bytes.reset(tmp);
454  m_buf = m_bytes.get() + offset;
455  }
456  }
457 
458  uint8_t* getBufferCopyFrom(const uint8_t* from, size_t length) {
459  uint8_t* result;
460  _GEODE_NEW(result, uint8_t[length]);
461  std::memcpy(result, from, length);
462 
463  return result;
464  }
465 
466  static void safeDelete(uint8_t* src) { _GEODE_SAFE_DELETE(src); }
467 
468  virtual Cache* getCache() const;
469 
470  DataOutput() = delete;
471 
473  virtual ~DataOutput() noexcept {
474  reset();
475  if (m_bytes) {
476  DataOutput::checkinBuffer(m_bytes.release(), m_size);
477  }
478  }
479 
480  DataOutput(const DataOutput&) = delete;
481  DataOutput& operator=(const DataOutput&) = delete;
482  DataOutput(DataOutput&&) = default;
483  DataOutput& operator=(DataOutput&&) = default;
484 
485  protected:
489  DataOutput(const CacheImpl* cache, Pool* pool);
490 
491  virtual const SerializationRegistry& getSerializationRegistry() const;
492 
493  private:
494  void writeObjectInternal(const std::shared_ptr<Serializable>& ptr,
495  bool isDelta = false);
496 
497  static void acquireLock();
498  static void releaseLock();
499 
500  struct FreeDeleter {
501  void operator()(uint8_t* p) { free(p); }
502  };
503 
504  // memory m_buffer to encode to.
505  std::unique_ptr<uint8_t, FreeDeleter> m_bytes;
506  // cursor.
507  uint8_t* m_buf;
508  // size of m_bytes.
509  size_t m_size;
510  // high and low water marks for buffer size
511  static size_t m_lowWaterMark;
512  static size_t m_highWaterMark;
513  // flag to indicate we have a big buffer
514  volatile bool m_haveBigBuffer;
515  const CacheImpl* m_cache;
516  Pool* m_pool;
517 
518  inline void writeAscii(const std::string& value) {
519  uint16_t len = static_cast<uint16_t>(
520  std::min<size_t>(value.length(), std::numeric_limits<uint16_t>::max()));
521  writeInt(len);
522  for (size_t i = 0; i < len; i++) {
523  // blindly assumes ascii so mask off only 7 bits
524  write(static_cast<int8_t>(value.data()[i] & 0x7F));
525  }
526  }
527 
528  inline void writeAsciiHuge(const std::string& value) {
529  uint32_t len = static_cast<uint32_t>(
530  std::min<size_t>(value.length(), std::numeric_limits<uint32_t>::max()));
531  writeInt(static_cast<uint32_t>(len));
532  for (size_t i = 0; i < len; i++) {
533  // blindly assumes ascii so mask off only 7 bits
534  write(static_cast<int8_t>(value.data()[i] & 0x7F));
535  }
536  }
537 
538  template <class _CharT, class _Traits, class _Allocator>
539  void writeJavaModifiedUtf8(
540  const std::basic_string<_CharT, _Traits, _Allocator>& value) {
541  writeJavaModifiedUtf8(value.data(), value.length());
542  }
543 
544  template <class _Traits, class _Allocator>
545  void writeJavaModifiedUtf8(
546  const std::basic_string<char, _Traits, _Allocator>& value);
547 
548  template <class _Traits, class _Allocator>
549  void writeJavaModifiedUtf8(
550  const std::basic_string<char32_t, _Traits, _Allocator>& value);
551 
552  template <class _Traits, class _Allocator>
553  inline void writeJavaModifiedUtf8(
554  const std::basic_string<wchar_t, _Traits, _Allocator>& value) {
555  typedef std::conditional<
556  sizeof(wchar_t) == sizeof(char16_t), char16_t,
557  std::conditional<sizeof(wchar_t) == sizeof(char32_t), char32_t,
558  char>::type>::type _Convert;
559  writeJavaModifiedUtf8(reinterpret_cast<const _Convert*>(value.data()),
560  value.length());
561  }
562 
563  inline void writeJavaModifiedUtf8(const char16_t* data, size_t len) {
564  if (0 == len) {
565  writeInt(static_cast<uint16_t>(0));
566  } else {
567  auto encodedLen = static_cast<uint16_t>(
568  std::min<size_t>(getJavaModifiedUtf8EncodedLength(data, len),
569  std::numeric_limits<uint16_t>::max()));
570  writeInt(encodedLen);
571  ensureCapacity(encodedLen);
572  const auto end = m_buf + encodedLen;
573  while (m_buf < end) {
574  encodeJavaModifiedUtf8(*data++);
575  }
576  if (m_buf > end) m_buf = end;
577  }
578  }
579 
580  void writeJavaModifiedUtf8(const char32_t* data, size_t len);
581 
582  template <class _CharT, class _Traits, class _Allocator>
583  inline void writeUtf16Huge(
584  const std::basic_string<_CharT, _Traits, _Allocator>& value) {
585  writeUtf16Huge(value.data(), value.length());
586  }
587 
588  template <class _Traits, class _Allocator>
589  void writeUtf16Huge(
590  const std::basic_string<char, _Traits, _Allocator>& value);
591 
592  template <class _Traits, class _Allocator>
593  void writeUtf16Huge(
594  const std::basic_string<char32_t, _Traits, _Allocator>& value);
595 
596  template <class _Traits, class _Allocator>
597  inline void writeUtf16Huge(
598  const std::basic_string<wchar_t, _Traits, _Allocator>& value) {
599  typedef std::conditional<
600  sizeof(wchar_t) == sizeof(char16_t), char16_t,
601  std::conditional<sizeof(wchar_t) == sizeof(char32_t), char32_t,
602  char>::type>::type _Convert;
603  writeUtf16Huge(reinterpret_cast<const _Convert*>(value.data()),
604  value.length());
605  }
606 
607  inline void writeUtf16Huge(const char16_t* data, size_t length) {
608  uint32_t len = static_cast<uint32_t>(
609  std::min<size_t>(length, std::numeric_limits<uint32_t>::max()));
610  writeInt(len);
611  writeUtf16(data, length);
612  }
613 
614  void writeUtf16Huge(const char32_t* data, size_t len);
615 
616  template <class _CharT, class _Traits, class _Allocator>
617  inline void writeUtf16(
618  const std::basic_string<_CharT, _Traits, _Allocator>& value) {
619  writeUtf16(value.data(), value.length());
620  }
621 
622  template <class _Traits, class _Allocator>
623  void writeUtf16(const std::basic_string<char, _Traits, _Allocator>& value);
624 
625  template <class _Traits, class _Allocator>
626  void writeUtf16(
627  const std::basic_string<char32_t, _Traits, _Allocator>& value);
628 
629  template <class _Traits, class _Allocator>
630  inline void writeUtf16(
631  const std::basic_string<wchar_t, _Traits, _Allocator>& value) {
632  typedef std::conditional<
633  sizeof(wchar_t) == sizeof(char16_t), char16_t,
634  std::conditional<sizeof(wchar_t) == sizeof(char32_t), char32_t,
635  char>::type>::type _Convert;
636  writeUtf16(reinterpret_cast<const _Convert*>(value.data()), value.length());
637  }
638 
639  inline void writeUtf16(const char16_t* data, size_t length) {
640  ensureCapacity(length * 2);
641  for (; length > 0; length--, data++) {
642  writeNoCheck(static_cast<uint8_t>(*data >> 8));
643  writeNoCheck(static_cast<uint8_t>(*data));
644  }
645  }
646 
647  void writeUtf16(const char32_t* data, size_t len);
648 
649  static size_t getJavaModifiedUtf8EncodedLength(const char16_t* data,
650  size_t length);
651 
652  inline static void getEncodedLength(const char val, int32_t& encodedLen) {
653  if ((val == 0) || (val & 0x80)) {
654  // two byte.
655  encodedLen += 2;
656  } else {
657  // one byte.
658  encodedLen++;
659  }
660  }
661 
662  inline static void getEncodedLength(const wchar_t val, int32_t& encodedLen) {
663  if (val == 0) {
664  encodedLen += 2;
665  } else if (val < 0x80) // ASCII character
666  {
667  encodedLen++;
668  } else if (val < 0x800) {
669  encodedLen += 2;
670  } else {
671  encodedLen += 3;
672  }
673  }
674 
675  inline void encodeChar(const char value) {
676  uint8_t tmp = static_cast<uint8_t>(value);
677  if ((tmp == 0) || (tmp & 0x80)) {
678  // two byte.
679  *(m_buf++) = static_cast<uint8_t>(0xc0 | ((tmp & 0xc0) >> 6));
680  *(m_buf++) = static_cast<uint8_t>(0x80 | (tmp & 0x3f));
681  } else {
682  // one byte.
683  *(m_buf++) = tmp;
684  }
685  }
686 
687  // this will lose the character set encoding.
688  inline void encodeChar(const wchar_t value) {
689  uint16_t c = static_cast<uint16_t>(value);
690  if (c == 0) {
691  *(m_buf++) = 0xc0;
692  *(m_buf++) = 0x80;
693  } else if (c < 0x80) { // ASCII character
694  *(m_buf++) = static_cast<uint8_t>(c);
695  } else if (c < 0x800) {
696  *(m_buf++) = static_cast<uint8_t>(0xC0 | c >> 6);
697  *(m_buf++) = static_cast<uint8_t>(0x80 | (c & 0x3F));
698  } else {
699  *(m_buf++) = static_cast<uint8_t>(0xE0 | c >> 12);
700  *(m_buf++) = static_cast<uint8_t>(0x80 | ((c >> 6) & 0x3F));
701  *(m_buf++) = static_cast<uint8_t>(0x80 | (c & 0x3F));
702  }
703  }
704 
705  inline void encodeJavaModifiedUtf8(const char16_t c) {
706  if (c == 0) {
707  // NUL
708  *(m_buf++) = 0xc0;
709  *(m_buf++) = 0x80;
710  } else if (c < 0x80) {
711  // ASCII character
712  *(m_buf++) = static_cast<uint8_t>(c);
713  } else if (c < 0x800) {
714  *(m_buf++) = static_cast<uint8_t>(0xC0 | c >> 6);
715  *(m_buf++) = static_cast<uint8_t>(0x80 | (c & 0x3F));
716  } else {
717  *(m_buf++) = static_cast<uint8_t>(0xE0 | c >> 12);
718  *(m_buf++) = static_cast<uint8_t>(0x80 | ((c >> 6) & 0x3F));
719  *(m_buf++) = static_cast<uint8_t>(0x80 | (c & 0x3F));
720  }
721  }
722 
723  inline void writeNoCheck(uint8_t value) { *(m_buf++) = value; }
724 
725  inline void writeNoCheck(int8_t value) {
726  writeNoCheck(static_cast<uint8_t>(value));
727  }
728 
729  Pool* getPool() const { return m_pool; }
730 
731  static uint8_t* checkoutBuffer(size_t* size);
732  static void checkinBuffer(uint8_t* buffer, size_t size);
733 
734  friend Cache;
735  friend CacheImpl;
736  friend DataOutputInternal;
737  friend CacheableString;
738  friend TcrMessage;
739 };
740 
741 template void DataOutput::writeJavaModifiedUtf8(const std::u16string&);
742 // template void DataOutput::writeJavaModifiedUtf8(const std::u32string&);
743 template void DataOutput::writeJavaModifiedUtf8(const std::wstring&);
744 
745 } // namespace client
746 } // namespace geode
747 } // namespace apache
748 
749 #endif // GEODE_DATAOUTPUT_H_
apache::geode::client::DataOutput::writeFloat
void writeFloat(float value)
Write a float value to the DataOutput.
Definition: DataOutput.hpp:240
CacheableString.hpp
apache::geode::client::DataOutput::writeDouble
void writeDouble(double value)
Write a double precision real number to the DataOutput.
Definition: DataOutput.hpp:254
apache::geode::client::DataOutput::writeBytesOnly
void writeBytesOnly(const uint8_t *bytes, size_t len)
Write an array of unsigned bytes without its length to the DataOutput.
Definition: DataOutput.hpp:114
apache::geode::client::DataOutput::writeBytes
void writeBytes(const uint8_t *bytes, int32_t len)
Write an array of unsigned bytes to the DataOutput.
Definition: DataOutput.hpp:80
apache::geode::client::DataOutput::DataOutput
DataOutput(const CacheImpl *cache, Pool *pool)
Construct a new DataOutput.
apache::geode::client::DataOutput::rewindCursor
void rewindCursor(size_t offset)
Rewind the buffer cursor by the given offset.
Definition: DataOutput.hpp:362
apache::geode::client::DataOutput::writeInt
void writeInt(uint16_t value)
Write a 16-bit unsigned integer value to the DataOutput.
Definition: DataOutput.hpp:140
apache::geode::client::Pool
A pool of connections to connect from a client to a set of Geode Cache Servers.
Definition: Pool.hpp:63
apache::geode::client::DataOutput::writeChar
void writeChar(uint16_t value)
Write a 16-bit Char (wchar_t) value to the DataOutput.
Definition: DataOutput.hpp:151
apache::geode::client::DataOutput::reset
void reset()
Reset the internal cursor to the start of the buffer.
Definition: DataOutput.hpp:417
apache::geode::client::DataOutput::writeInt
void writeInt(uint32_t value)
Write a 32-bit unsigned integer value to the DataOutput.
Definition: DataOutput.hpp:162
apache::geode::client::DataOutput::write
void write(int8_t value)
Write a signed byte to the DataOutput.
Definition: DataOutput.hpp:65
apache::geode::client::OutOfMemoryException
Thrown when the system cannot allocate any more memory.
Definition: ExceptionTypes.hpp:392
apache::geode::client::DataOutput::writeBytesOnly
void writeBytesOnly(const int8_t *bytes, size_t len)
Write an array of signed bytes without its length to the DataOutput.
Definition: DataOutput.hpp:131
apache::geode::client::DataOutput::write
void write(uint8_t value)
Write an unsigned byte to the DataOutput.
Definition: DataOutput.hpp:55
apache::geode::client::DataOutput::writeObject
void writeObject(const std::shared_ptr< PTR > &objptr, bool isDelta=false)
Write a Serializable object to the DataOutput.
Definition: DataOutput.hpp:337
apache::geode::client::DataOutput::advanceCursor
void advanceCursor(size_t offset)
Advance the buffer cursor by the given offset.
Definition: DataOutput.hpp:352
apache::geode::client::DataOutput::getRemainingBufferLength
size_t getRemainingBufferLength() const
Get a pointer to the internal buffer of DataOutput.
Definition: DataOutput.hpp:381
apache::geode::client::DataOutput
Provide operations for writing primitive data values, byte arrays, strings, Serializable objects to a...
Definition: DataOutput.hpp:48
apache::geode::client::DataOutput::writeInt
void writeInt(int32_t value)
Write a 32-bit signed integer value to the DataOutput.
Definition: DataOutput.hpp:201
apache::geode::client::DataOutput::writeInt
void writeInt(int16_t value)
Write a 16-bit signed integer value to the DataOutput.
Definition: DataOutput.hpp:192
apache::geode::client::DataOutput::writeInt
void writeInt(int64_t value)
Write a 64-bit signed integer value to the DataOutput.
Definition: DataOutput.hpp:210
apache::geode::client::DataOutput::getBuffer
const uint8_t * getBuffer() const
Get a pointer to the internal buffer of DataOutput.
Definition: DataOutput.hpp:373
apache::geode::client::DataOutput::writeInt
void writeInt(uint64_t value)
Write a 64-bit unsigned integer value to the DataOutput.
Definition: DataOutput.hpp:175
apache::geode::client::DataOutput::writeBytes
void writeBytes(const int8_t *bytes, int32_t len)
Write an array of signed bytes to the DataOutput.
Definition: DataOutput.hpp:99
apache::geode::client::DataOutput::~DataOutput
virtual ~DataOutput() noexcept
Destruct a DataOutput, including releasing the created buffer.
Definition: DataOutput.hpp:473
apache::geode::client::DataOutput::getCursor
const uint8_t * getCursor()
Get an internal pointer to the current location in the DataOutput byte array.
Definition: DataOutput.hpp:345
apache::geode::client::DataOutput::writeChars
void writeChars(const _CharT *value)
Writes a sequence of UTF-16 code units representing the given string value.
Definition: DataOutput.hpp:326
apache::geode::client::DataOutput::getBufferLength
size_t getBufferLength() const
Get the length of current data in the internal buffer of DataOutput.
Definition: DataOutput.hpp:412
apache::geode::client::DataOutput::getBuffer
const uint8_t * getBuffer(size_t *rsize) const
Get a pointer to the internal buffer of DataOutput.
Definition: DataOutput.hpp:392
apache::geode::client::DataOutput::writeChars
void writeChars(const std::basic_string< _CharT, _Tail... > &value)
Writes a sequence of UTF-16 code units representing the given string value.
Definition: DataOutput.hpp:309
apache::geode::client::DataOutput::writeBoolean
void writeBoolean(bool value)
Write a boolean value to the DataOutput.
Definition: DataOutput.hpp:72
apache::geode::client::DataOutput::writeArrayLen
void writeArrayLen(int32_t len)
Write a 32-bit signed integer array length value to the DataOutput in a manner compatible with java s...
Definition: DataOutput.hpp:221

Apache Geode C++ Cache API Documentation