20using namespace ::exception;
24 : current_position_(fastcdr.current_position_)
29 const state& current_state)
45 bool ret_value =
false;
110 const char* string_t)
114 if (string_t !=
nullptr)
144 const wchar_t* string_t)
146 uint32_t bytes_length = 0;
149 if (string_t !=
nullptr)
151 wstrlen = wcslen(string_t);
155 if (bytes_length > 0)
187 size_t total_size =
sizeof(*bool_t) * num_elements;
191 for (
size_t count = 0; count < num_elements; ++count)
212 size_t total_size =
sizeof(*char_t) * num_elements;
225 const int16_t* short_t,
228 size_t total_size =
sizeof(*short_t) * num_elements;
242 const int32_t* long_t,
245 size_t total_size =
sizeof(*long_t) * num_elements;
259 const wchar_t* wchar,
262 for (
size_t count = 0; count < num_elements; ++count)
270 const int64_t* longlong_t,
273 size_t total_size =
sizeof(*longlong_t) * num_elements;
287 const float* float_t,
290 size_t total_size =
sizeof(*float_t) * num_elements;
304 const double* double_t,
307 size_t total_size =
sizeof(*double_t) * num_elements;
321 const long double* ldouble_t,
324 size_t total_size = 16 * num_elements;
328#if FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16
329 for (
size_t idx = 0; idx < num_elements; ++idx)
331 __float128 tmp = ldouble_t[idx];
336#if FASTCDR_SIZEOF_LONG_DOUBLE == 16
340#if FASTCDR_SIZEOF_LONG_DOUBLE == 8
341 for (
size_t idx = 0; idx < num_elements; ++idx)
343 current_position_ << static_cast<long double>(0);
349#error unsupported long double type and no __float128 available
380 throw BadParamException(
"Got unexpected byte value in deserialize for bool (expected 0 or 1)");
403 reinterpret_cast<char*
>(calloc(length + ((&
current_position_)[length - 1] ==
'\0' ? 0 : 1),
430 string_t =
reinterpret_cast<wchar_t*
>(calloc(length + 1,
sizeof(
wchar_t)));
433 for (
size_t idx = 0; idx < length; ++idx)
437 string_t[idx] =
static_cast<wchar_t>(temp);
455 const char* ret_value =
"";
456 state state_before_error(*
this);
468 if (ret_value[length - 1] ==
'\0')
487 uint32_t bytes_length = length * 4;
489 if (bytes_length == 0)
498 if (ret_value[length - 1] == L
'\0')
501 ret_value.
erase(length);
515 size_t total_size =
sizeof(*bool_t) * num_elements;
519 for (
size_t count = 0; count < num_elements; ++count)
526 bool_t[count] =
true;
530 bool_t[count] =
false;
544 size_t total_size =
sizeof(*char_t) * num_elements;
560 size_t total_size =
sizeof(*short_t) * num_elements;
577 size_t total_size =
sizeof(*long_t) * num_elements;
595 for (
size_t count = 0; count < num_elements; ++count)
598 wchar[count] =
static_cast<wchar_t>(value);
607 size_t total_size =
sizeof(*longlong_t) * num_elements;
624 size_t total_size =
sizeof(*float_t) * num_elements;
641 size_t total_size =
sizeof(*double_t) * num_elements;
655 long double* ldouble_t,
658 size_t total_size = 16 * num_elements;
662#if FASTCDR_HAVE_FLOAT128 && FASTCDR_SIZEOF_LONG_DOUBLE < 16
663 for (
size_t idx = 0; idx < num_elements; ++idx)
668 ldouble_t[idx] =
static_cast<long double>(tmp);
671#if FASTCDR_SIZEOF_LONG_DOUBLE == 16
675#if FASTCDR_SIZEOF_LONG_DOUBLE == 8
676 for (
size_t idx = 0; idx < num_elements; ++idx)
683#error unsupported long double type and no __float128 available
697 state state_before_error(*
this);
699 *this << static_cast<int32_t>(vector_t.
size());
701 size_t total_size = vector_t.
size() *
sizeof(bool);
705 for (
size_t count = 0; count < vector_t.
size(); ++count)
729 uint32_t sequence_length = 0;
730 state state_before_error(*
this);
732 *
this >> sequence_length;
734 size_t total_size = sequence_length *
sizeof(bool);
738 vector_t.
resize(sequence_length);
739 for (uint32_t count = 0; count < sequence_length; ++count)
746 vector_t[count] =
true;
750 vector_t[count] =
false;
765 size_t& num_elements)
767 uint32_t sequence_length = 0;
768 state state_before_error(*
this);
779 delete [] sequence_t;
785 num_elements = sequence_length;
791 size_t& num_elements)
793 uint32_t sequence_length = 0;
794 state state_before_error(*
this);
805 delete [] sequence_t;
811 num_elements = sequence_length;
uint32_t size_to_uint32(size_t val)
This class represents a stream of bytes that contains (or will contain) serialized data....
bool resize(size_t min_size_inc)
This function resizes the raw buffer. It will call the user's defined function for this purpose.
iterator begin()
This function returns a iterator that points to the begining of the stream.
iterator end()
This function returns a iterator that points to the end of the stream.
This class stores the current state of a CDR serialization.
state(const FastCdr &fastcdr)
Default constructor.
const FastBuffer::iterator current_position_
The position in the buffer when the state was created.
This class offers an interface to serialize/deserialize some basic types using a modified CDR protoco...
void set_state(FastCdr::state &state)
This function sets a previous state of the CDR stream;.
FastBuffer::iterator current_position_
The current position in the serialization/deserialization process.
bool resize(size_t min_size_inc)
FastCdr & serialize_array(const uint8_t *octet_t, size_t num_elements)
This function serializes an array of octets.
void reset()
This function resets the current position in the buffer to the begining.
std::wstring read_wstring(uint32_t &length)
FastCdr & deserialize_bool_sequence(std::vector< bool > &vector_t)
FastCdr & serialize(const uint8_t octet_t)
This function serializes an octet.
FastBuffer::iterator last_position_
The last position in the buffer;.
FastBuffer & cdr_buffer_
Reference to the buffer that will be serialized/deserialized.
char * get_current_position()
This function returns the current position in the CDR stream.
FastCdr & deserialize_wstring_sequence(std::wstring *&sequence_t, size_t &num_elements)
FastCdr & serialize_bool_sequence(const std::vector< bool > &vector_t)
const char * read_string(uint32_t &length)
FastCdr & deserialize(uint8_t &octet_t)
This function deserializes an octet.
FastCdr & deserialize_array(uint8_t *octet_t, size_t num_elements)
This function deserializes an array of octets.
bool jump(size_t num_bytes)
This function skips a number of bytes in the CDR stream buffer.
FastCdr(FastBuffer &cdr_buffer)
This constructor creates a eprosima::fastcdr::FastCdr object that can serialize/deserialize the assig...
FastCdr & deserialize_string_sequence(std::string *&sequence_t, size_t &num_elements)
FastCdr::state get_state()
This function returns the current state of the CDR stream.
void memcopy(const void *src, const size_t size)
This function copies a buffer into the raw buffer.
void rmemcopy(void *dst, const size_t size)
This function copies from the raw buffer to a external buffer.
This class is thrown as an exception when an invalid parameter is being serialized.
This abstract class is used to create exceptions.
virtual Cdr_DllAPI void raise() const =0
This function throws the object as exception.
This class is thrown as an exception when the buffer's internal memory reachs its size limit.
static Cdr_DllAPI const char *const NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT
Default message used in the library.