19 using namespace ::exception;
21 #if FASTCDR_IS_BIG_ENDIAN_TARGET 25 #endif // if FASTCDR_IS_BIG_ENDIAN_TARGET 31 : m_currentPosition(cdr.m_currentPosition)
32 , m_alignPosition(cdr.m_alignPosition)
33 , m_swapBytes(cdr.m_swapBytes)
34 , m_lastDataSize(cdr.m_lastDataSize)
39 const state& current_state)
66 uint8_t
dummy = 0, encapsulationKind = 0;
67 state state_before_error(*
this);
77 throw BadParamException(
"Unexpected non-zero initial byte received in Cdr::read_encapsulation");
82 (*this) >> encapsulationKind;
99 if (0 != (encapsulationKind & ~allowed_kind_mask))
101 throw BadParamException(
"Unexpected CDR type received in Cdr::read_encapsulation");
115 catch (Exception& ex)
127 uint8_t
dummy = 0, encapsulationKind = 0;
128 state state_before_error(*
this);
142 (*this) << encapsulationKind;
144 catch (Exception& ex)
157 catch (Exception& ex)
202 bool returnedValue =
false;
207 returnedValue =
true;
210 return returnedValue;
229 state& current_state)
248 bool returnedValue =
false;
253 returnedValue =
true;
256 return returnedValue;
285 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
289 const int16_t short_t)
292 size_t sizeAligned =
sizeof(short_t) + align;
304 const char*
dst =
reinterpret_cast<const char*
>(&short_t);
318 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
322 const int16_t short_t,
333 catch (Exception& ex)
343 const int32_t long_t)
346 size_t sizeAligned =
sizeof(long_t) + align;
358 const char*
dst =
reinterpret_cast<const char*
>(&long_t);
374 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
378 const int32_t long_t,
389 catch (Exception& ex)
399 const int64_t longlong_t)
402 size_t sizeAligned =
sizeof(longlong_t) + align;
414 const char*
dst =
reinterpret_cast<const char*
>(&longlong_t);
434 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
438 const int64_t longlong_t,
449 catch (Exception& ex)
462 size_t sizeAligned =
sizeof(float_t) + align;
474 const char*
dst =
reinterpret_cast<const char*
>(&float_t);
490 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
505 catch (Exception& ex)
515 const double double_t)
518 size_t sizeAligned =
sizeof(double_t) + align;
530 const char*
dst =
reinterpret_cast<const char*
>(&double_t);
550 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
554 const double double_t,
565 catch (Exception& ex)
575 const long double ldouble_t)
578 size_t sizeAligned =
sizeof(ldouble_t) + align;
590 #if FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 591 __float128 tmp = ldouble_t;
592 const char*
dst =
reinterpret_cast<const char*
>(&tmp);
594 const char* dst =
reinterpret_cast<const char*
>(&ldouble_t);
595 #endif // FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 596 #if FASTCDR_HAVE_FLOAT128 || FASTCDR_SIZEOF_LONG_DOUBLE == 16 614 #if FASTCDR_SIZEOF_LONG_DOUBLE == 8 633 #error unsupported long double type and no __float128 available 634 #endif // FASTCDR_SIZEOF_LONG_DOUBLE == 8 635 #endif // FASTCDR_HAVE_FLOAT128 || FASTCDR_SIZEOF_LONG_DOUBLE == 16 639 #if FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 640 __float128 tmp = ldouble_t;
644 #if FASTCDR_SIZEOF_LONG_DOUBLE == 8 645 m_currentPosition << static_cast<long double>(0);
647 #endif // FASTCDR_SIZEOF_LONG_DOUBLE == 8 648 #if FASTCDR_SIZEOF_LONG_DOUBLE == 8 || FASTCDR_SIZEOF_LONG_DOUBLE == 16 649 m_currentPosition << ldouble_t;
650 m_currentPosition +=
sizeof(ldouble_t);
652 #error unsupported long double type and no __float128 available 653 #endif // FASTCDR_SIZEOF_LONG_DOUBLE == 8 || FASTCDR_SIZEOF_LONG_DOUBLE == 16 654 #endif // FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 660 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
664 const long double ldouble_t,
675 catch (Exception& ex)
703 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
707 const char* string_t)
711 if (string_t !=
nullptr)
732 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
744 const wchar_t* string_t)
746 uint32_t bytesLength = 0;
749 if (string_t !=
nullptr)
751 wstrlen = wcslen(string_t);
770 #endif // if defined(_WIN32) 775 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
787 const char* string_t,
798 catch (Exception& ex)
808 const wchar_t* string_t,
819 catch (Exception& ex)
832 size_t totalSize =
sizeof(*bool_t) * numElements;
853 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
860 size_t totalSize =
sizeof(*char_t) * numElements;
872 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
876 const int16_t* short_t,
879 if (numElements == 0)
885 size_t totalSize =
sizeof(*short_t) * numElements;
886 size_t sizeAligned = totalSize +
align;
901 const char*
dst =
reinterpret_cast<const char*
>(&short_t);
902 const char* end = dst + totalSize;
904 for (; dst < end; dst +=
sizeof(*short_t))
919 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
923 const int16_t* short_t,
935 catch (Exception& ex)
945 const int32_t* long_t,
948 if (numElements == 0)
954 size_t totalSize =
sizeof(*long_t) * numElements;
955 size_t sizeAligned = totalSize +
align;
970 const char*
dst =
reinterpret_cast<const char*
>(&long_t);
971 const char* end = dst + totalSize;
973 for (; dst < end; dst +=
sizeof(*long_t))
990 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
994 const int32_t* long_t,
1006 catch (Exception& ex)
1016 const wchar_t* wchar,
1019 if (numElements == 0)
1032 const wchar_t* wchar,
1044 catch (Exception& ex)
1054 const int64_t* longlong_t,
1057 if (numElements == 0)
1063 size_t totalSize =
sizeof(*longlong_t) * numElements;
1064 size_t sizeAligned = totalSize +
align;
1079 const char*
dst =
reinterpret_cast<const char*
>(&longlong_t);
1080 const char* end = dst + totalSize;
1082 for (; dst < end; dst +=
sizeof(*longlong_t))
1103 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1107 const int64_t* longlong_t,
1119 catch (Exception& ex)
1129 const float* float_t,
1132 if (numElements == 0)
1138 size_t totalSize =
sizeof(*float_t) * numElements;
1139 size_t sizeAligned = totalSize +
align;
1154 const char*
dst =
reinterpret_cast<const char*
>(&float_t);
1155 const char* end = dst + totalSize;
1157 for (; dst < end; dst +=
sizeof(*float_t))
1174 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1178 const float* float_t,
1190 catch (Exception& ex)
1200 const double* double_t,
1203 if (numElements == 0)
1209 size_t totalSize =
sizeof(*double_t) * numElements;
1210 size_t sizeAligned = totalSize +
align;
1225 const char*
dst =
reinterpret_cast<const char*
>(&double_t);
1226 const char* end = dst + totalSize;
1228 for (; dst < end; dst +=
sizeof(*double_t))
1249 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1253 const double* double_t,
1265 catch (Exception& ex)
1275 const long double* ldouble_t,
1278 if (numElements == 0)
1285 size_t totalSize = 16 * numElements;
1286 size_t sizeAligned = totalSize +
align;
1299 #if FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 1302 for (
size_t i = 0; i < numElements; ++i, ++ldouble_t)
1304 __float128 tmp = *ldouble_t;
1305 const char*
dst =
reinterpret_cast<const char*
>(&tmp);
1326 for (
size_t i = 0; i < numElements; ++i, ++ldouble_t)
1328 __float128 tmp = *ldouble_t;
1334 #if FASTCDR_SIZEOF_LONG_DOUBLE == 8 || FASTCDR_SIZEOF_LONG_DOUBLE == 16 1337 const char*
dst =
reinterpret_cast<const char*
>(&ldouble_t);
1338 const char* end = dst + totalSize;
1340 for (; dst < end; dst +=
sizeof(*ldouble_t))
1342 #if FASTCDR_SIZEOF_LONG_DOUBLE == 16 1360 #endif // FASTCDR_SIZEOF_LONG_DOUBLE == 16 1373 #if FASTCDR_SIZEOF_LONG_DOUBLE == 16 1377 for (
size_t i = 0; i < numElements; ++i)
1379 m_currentPosition << static_cast<long double>(0);
1381 m_currentPosition << ldouble_t[i];
1382 m_currentPosition += 8;
1384 #endif // FASTCDR_SIZEOF_LONG_DOUBLE == 16 1387 #error unsupported long double type and no __float128 available 1388 #endif // FASTCDR_SIZEOF_LONG_DOUBLE == 8 || FASTCDR_SIZEOF_LONG_DOUBLE == 16 1389 #endif // FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 1394 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1398 const long double* ldouble_t,
1410 catch (Exception& ex)
1431 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1438 size_t sizeAligned =
sizeof(short_t) + align;
1450 char*
dst =
reinterpret_cast<char*
>(&short_t);
1464 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1479 catch (Exception& ex)
1492 size_t sizeAligned =
sizeof(long_t) + align;
1504 char*
dst =
reinterpret_cast<char*
>(&long_t);
1520 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1535 catch (Exception& ex)
1545 int64_t& longlong_t)
1548 size_t sizeAligned =
sizeof(longlong_t) + align;
1560 char*
dst =
reinterpret_cast<char*
>(&longlong_t);
1580 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1584 int64_t& longlong_t,
1595 catch (Exception& ex)
1608 size_t sizeAligned =
sizeof(float_t) + align;
1620 char*
dst =
reinterpret_cast<char*
>(&float_t);
1636 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1651 catch (Exception& ex)
1664 size_t sizeAligned =
sizeof(double_t) + align;
1676 char*
dst =
reinterpret_cast<char*
>(&double_t);
1696 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1711 catch (Exception& ex)
1721 long double& ldouble_t)
1724 size_t sizeAligned =
sizeof(ldouble_t) + align;
1736 #if FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 1737 __float128 tmp = ldouble_t;
1738 char*
dst =
reinterpret_cast<char*
>(&tmp);
1740 char* dst =
reinterpret_cast<char*
>(&ldouble_t);
1741 #endif // FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 1742 #if FASTCDR_HAVE_FLOAT128 || FASTCDR_SIZEOF_LONG_DOUBLE == 16 1759 #if FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 1760 ldouble_t =
static_cast<long double>(tmp);
1761 #endif // FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 1763 #if FASTCDR_SIZEOF_LONG_DOUBLE == 8 1774 #error unsupported long double type and no __float128 available 1775 #endif // FASTCDR_SIZEOF_LONG_DOUBLE == 8 1776 #endif // FASTCDR_HAVE_FLOAT128 || FASTCDR_SIZEOF_LONG_DOUBLE == 16 1780 #if FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 1784 ldouble_t =
static_cast<long double>(tmp);
1786 #if FASTCDR_SIZEOF_LONG_DOUBLE == 8 || FASTCDR_SIZEOF_LONG_DOUBLE == 16 1787 #if FASTCDR_SIZEOF_LONG_DOUBLE == 8 1789 #endif // FASTCDR_SIZEOF_LONG_DOUBLE == 8 1792 #endif // FASTCDR_SIZEOF_LONG_DOUBLE == 8 || FASTCDR_SIZEOF_LONG_DOUBLE == 16 1793 #endif // FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 1799 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1803 long double& ldouble_t,
1814 catch (Exception& ex)
1840 else if (value == 0)
1846 throw BadParamException(
"Unexpected byte value in Cdr::deserialize(bool), expected 0 or 1");
1849 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1855 uint32_t length = 0;
1872 reinterpret_cast<char*
>(calloc(length + ((&
m_currentPosition)[length - 1] ==
'\0' ? 0 : 1),
1880 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1886 uint32_t length = 0;
1901 string_t =
reinterpret_cast<wchar_t*
>(calloc(length + 1,
sizeof(
wchar_t)));
1904 for (
size_t idx = 0; idx < length; ++idx)
1908 string_t[idx] =
static_cast<wchar_t>(temp);
1914 #endif // if defined(_WIN32) 1919 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
1934 catch (Exception& ex)
1955 catch (Exception& ex)
1967 const char* returnedValue =
"";
1968 state state_before_error(*
this);
1974 return returnedValue;
1983 if (returnedValue[length - 1] ==
'\0')
1987 return returnedValue;
1998 std::wstring returnedValue = L
"";
1999 state state_(*
this);
2002 uint32_t bytesLength = length * 4;
2004 if (bytesLength == 0)
2006 return returnedValue;
2013 returnedValue.resize(length);
2015 if (returnedValue[length - 1] == L
'\0')
2018 returnedValue.erase(length);
2020 return returnedValue;
2032 size_t totalSize =
sizeof(*bool_t) * numElements;
2046 bool_t[
count] =
true;
2048 else if (value == 0)
2050 bool_t[
count] =
false;
2057 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
2064 size_t totalSize =
sizeof(*char_t) * numElements;
2076 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
2083 if (numElements == 0)
2089 size_t totalSize =
sizeof(*short_t) * numElements;
2090 size_t sizeAligned = totalSize +
align;
2105 char*
dst =
reinterpret_cast<char*
>(short_t);
2106 char* end = dst + totalSize;
2108 for (; dst < end; dst +=
sizeof(*short_t))
2123 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
2139 catch (Exception& ex)
2152 if (numElements == 0)
2158 size_t totalSize =
sizeof(*long_t) * numElements;
2159 size_t sizeAligned = totalSize +
align;
2174 char*
dst =
reinterpret_cast<char*
>(long_t);
2175 char* end = dst + totalSize;
2177 for (; dst < end; dst +=
sizeof(*long_t))
2194 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
2210 catch (Exception& ex)
2223 if (numElements == 0)
2232 wchar[
count] =
static_cast<wchar_t>(value);
2250 catch (Exception& ex)
2260 int64_t* longlong_t,
2263 if (numElements == 0)
2269 size_t totalSize =
sizeof(*longlong_t) * numElements;
2270 size_t sizeAligned = totalSize +
align;
2285 char*
dst =
reinterpret_cast<char*
>(longlong_t);
2286 char* end = dst + totalSize;
2288 for (; dst < end; dst +=
sizeof(*longlong_t))
2309 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
2313 int64_t* longlong_t,
2325 catch (Exception& ex)
2338 if (numElements == 0)
2344 size_t totalSize =
sizeof(*float_t) * numElements;
2345 size_t sizeAligned = totalSize +
align;
2360 char*
dst =
reinterpret_cast<char*
>(float_t);
2361 char* end = dst + totalSize;
2363 for (; dst < end; dst +=
sizeof(*float_t))
2380 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
2396 catch (Exception& ex)
2409 if (numElements == 0)
2415 size_t totalSize =
sizeof(*double_t) * numElements;
2416 size_t sizeAligned = totalSize +
align;
2431 char*
dst =
reinterpret_cast<char*
>(double_t);
2432 char* end = dst + totalSize;
2434 for (; dst < end; dst +=
sizeof(*double_t))
2455 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
2471 catch (Exception& ex)
2481 long double* ldouble_t,
2484 if (numElements == 0)
2491 size_t totalSize = 16 * numElements;
2492 size_t sizeAligned = totalSize +
align;
2505 #if FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 2508 for (
size_t i = 0; i < numElements; ++i)
2511 char*
dst =
reinterpret_cast<char*
>(&tmp);
2528 ldouble_t[i] =
static_cast<long double>(tmp);
2533 for (
size_t i = 0; i < numElements; ++i)
2538 ldouble_t[i] =
static_cast<long double>(tmp);
2542 #if FASTCDR_SIZEOF_LONG_DOUBLE == 8 || FASTCDR_SIZEOF_LONG_DOUBLE == 16 2545 char*
dst =
reinterpret_cast<char*
>(ldouble_t);
2546 char* end = dst + numElements *
sizeof(*ldouble_t);
2548 for (; dst < end; dst +=
sizeof(*ldouble_t))
2550 #if FASTCDR_SIZEOF_LONG_DOUBLE == 16 2561 #endif // FASTCDR_SIZEOF_LONG_DOUBLE == 16 2574 #if FASTCDR_SIZEOF_LONG_DOUBLE == 16 2578 for (
size_t i = 0; i < numElements; ++i)
2584 #endif // FASTCDR_SIZEOF_LONG_DOUBLE == 16 2586 #endif // FASTCDR_SIZEOF_LONG_DOUBLE == 8 || FASTCDR_SIZEOF_LONG_DOUBLE == 16 2587 #endif // FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16 2592 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
2596 long double* ldouble_t,
2608 catch (Exception& ex)
2618 const std::vector<bool>& vector_t)
2620 state state_before_error(*
this);
2622 *this << static_cast<int32_t>(vector_t.size());
2624 size_t totalSize = vector_t.size() *
sizeof(bool);
2634 std::vector<bool>::const_reference ref = vector_t[
count];
2646 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
2653 std::vector<bool>& vector_t)
2655 uint32_t seqLength = 0;
2656 state state_before_error(*
this);
2660 size_t totalSize = seqLength *
sizeof(bool);
2664 vector_t.resize(seqLength);
2675 vector_t[
count] =
true;
2677 else if (value == 0)
2679 vector_t[
count] =
false;
2683 throw BadParamException(
"Unexpected byte value in Cdr::deserializeBoolSequence, expected 0 or 1");
2690 throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
2697 std::string*& sequence_t,
2698 size_t& numElements)
2700 uint32_t seqLength = 0;
2701 state state_before_error(*
this);
2707 sequence_t =
new std::string[seqLength];
2712 delete [] sequence_t;
2718 numElements = seqLength;
2723 std::wstring*& sequence_t,
2724 size_t& numElements)
2726 uint32_t seqLength = 0;
2727 state state_before_error(*
this);
2733 sequence_t =
new std::wstring[seqLength];
2738 delete [] sequence_t;
2744 numElements = seqLength;
virtual Cdr_DllAPI void raise() const =0
This function throws the object as exception.
static size_t alignment(size_t current_alignment, size_t dataSize)
Get the number of bytes needed to align a position to certain data size.
void setState(state &state)
This function sets a previous state of the CDR serialization process;.
void reset()
This function resets the current position in the buffer to the beginning.
bool moveAlignmentForward(size_t numBytes)
This function moves the alignment forward.
FastBuffer::iterator m_lastPosition
The last position in the buffer;.
bool resize(size_t minSizeInc)
This function resizes the internal buffer. It only applies if the FastBuffer object was created with ...
This abstract class is used to create exceptions.
CdrType
This enumeration represents the two kinds of CDR serialization supported by eprosima::fastcdr::CDR.
typename detail::char_t_impl< S >::type char_t
Cdr & serializeBoolSequence(const std::vector< bool > &vector_t)
This class is thrown as an exception when the buffer's internal memory reachs its size limit...
Cdr & read_encapsulation()
This function reads the encapsulation of the CDR stream. If the CDR stream contains an encapsulation...
Cdr & deserializeArray(uint8_t *octet_t, size_t numElements)
This function deserializes an array of octets.
const char * readString(uint32_t &length)
constexpr std::uintptr_t align(std::size_t alignment, std::uintptr_t ptr, std::size_t &space)
Specifies that the content is not a parameter list.
uint8_t m_endianness
The endianness that will be applied over the buffer.
DDSCdrPlFlag getDDSCdrPlFlag() const
This function returns the parameter list flag when the CDR type is eprosima::fastcdr::DDS_CDR.
static Cdr_DllAPI const char *const NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT
Default message used in the library.
uint16_t m_options
This attribute stores the option flags when the CDR type is DDS_CDR;.
Cdr & deserializeWStringSequence(std::wstring *&sequence_t, size_t &numElements)
void changeEndianness(Endianness endianness)
This function sets the current endianness used by the CDR type.
void setDDSCdrOptions(uint16_t options)
This function sets the option flags when the CDR type is eprosima::fastcdr::DDS_CDR.
FastBuffer::iterator m_currentPosition
The current position in the serialization/deserialization process.
const FastBuffer::iterator m_currentPosition
The position in the buffer when the state was created.
uint16_t getDDSCdrOptions() const
This function returns the option flags when the CDR type is eprosima::fastcdr::DDS_CDR.
Endianness endianness() const
This function returns the current endianness used by the CDR type.
iterator begin()
This function returns a iterator that points to the begining of the stream.
FastBuffer::iterator m_alignPosition
The position from where the aligment is calculated.
char * getCurrentPosition()
This function returns the current position in the CDR stream.
uint32_t size_to_uint32(size_t val)
void rmemcopy(void *dst, const size_t size)
This function copies from the raw buffer to a external buffer.
const FastBuffer::iterator m_alignPosition
The position from the aligment is calculated, when the state was created..
static const Endianness DEFAULT_ENDIAN
Default endiness in the system.
This class stores the current state of a CDR serialization.
Cdr & serializeArray(const uint8_t *octet_t, size_t numElements)
This function serializes an array of octets.
Cdr & deserializeStringSequence(std::string *&sequence_t, size_t &numElements)
state(const Cdr &cdr)
Default constructor.
constexpr auto count() -> size_t
Cdr & serialize_encapsulation()
This function writes the encapsulation of the CDR stream. If the CDR stream should contain an encapsu...
char * getBufferPointer()
This function returns the pointer to the current used buffer.
This class offers an interface to serialize/deserialize some basic types using CDR protocol inside an...
bool jump(size_t numBytes)
This function skips a number of bytes in the CDR stream buffer.
bool m_swapBytes
This attribute specified if it is needed to swap the bytes when the state was created..
Cdr & deserializeBoolSequence(std::vector< bool > &vector_t)
DDSCdrPlFlag
This enumeration represents the two posible values of the flag that points if the content is a parame...
Endianness
This enumeration represents endianness types.
This class represents a stream of bytes that contains (or will contain) serialized data...
Cdr(FastBuffer &cdrBuffer, const Endianness endianness=DEFAULT_ENDIAN, const CdrType cdrType=CORBA_CDR)
This constructor creates an eprosima::fastcdr::Cdr object that can serialize/deserialize the assigned...
DDSCdrPlFlag m_plFlag
Using DDS_CDR type, this attribute stores if the stream buffer contains a parameter list or not...
bool resize(size_t minSizeInc)
This function resizes the raw buffer. It will call the user's defined function for this purpose...
void makeAlign(size_t align)
This function jumps the number of bytes of the alignment. These bytes should be calculated with the f...
const std::wstring readWString(uint32_t &length)
void memcopy(const void *src, const size_t size)
This function copies a buffer into the raw buffer.
FastBuffer & m_cdrBuffer
Reference to the buffer that will be serialized/deserialized.
char * getBuffer() const
This function returns the stream that the eprosima::fastcdr::FastBuffers uses to serialize data...
void resetAlignment()
This function resets the alignment to the current position in the buffer.
state getState()
This function returns the current state of the CDR serialization process.
size_t m_lastDataSize
Stores the last datasize serialized/deserialized. It's used to optimize.
iterator end()
This function returns a iterator that points to the end of the stream.
Cdr & serialize(const uint8_t octet_t)
This function serializes an octet.
size_t m_lastDataSize
Stores the last datasize serialized/deserialized when the state was created.
void setDDSCdrPlFlag(DDSCdrPlFlag plFlag)
This function sets the parameter list flag when the CDR type is eprosima::fastcdr::DDS_CDR.
Specifies that the content is a parameter list.
CONSTEXPR size_t ALIGNMENT_LONG_DOUBLE
CdrType m_cdrType
The type of CDR that will be use in serialization/deserialization.
Cdr & deserialize(uint8_t &octet_t)
This function deserializes an octet.
bool m_swapBytes
This attribute specifies if it is needed to swap the bytes.