Go to the documentation of this file.
15 #ifndef _FASTCDR_FASTCDR_H_
16 #define _FASTCDR_FASTCDR_H_
25 #if !__APPLE__ && !__FreeBSD__ && !__VXWORKS__
29 #endif // if !__APPLE__ && !__FreeBSD__ && !__VXWORKS__
68 const state&) =
delete;
107 return current_position_ - cdr_buffer_.begin();
130 const uint8_t octet_t)
166 const uint16_t ushort_t)
178 const int16_t short_t)
190 const uint32_t ulong_t)
202 const int32_t long_t)
226 const uint64_t ulonglong_t)
238 const int64_t longlong_t)
262 const double double_t)
274 const long double ldouble_t)
298 const char* string_t)
310 const wchar_t* string_t)
322 const std::string& string_t)
334 const std::wstring& string_t)
345 template<
class _T,
size_t _Size>
347 const std::array<_T, _Size>& array_t)
349 return serialize<_T, _Size>(array_t);
360 const std::vector<_T>& vector_t)
362 return serialize<_T>(vector_t);
375 type_t.serialize(*
this);
482 uint64_t& ulonglong_t)
530 long double& ldouble_t)
570 std::string& string_t)
582 std::wstring& string_t)
593 template<
class _T,
size_t _Size>
595 std::array<_T, _Size>& array_t)
597 return deserialize<_T, _Size>(array_t);
608 std::vector<_T>& vector_t)
610 return deserialize<_T>(vector_t);
635 const uint8_t octet_t)
637 return serialize(
static_cast<char>(octet_t));
650 if (((last_position_ - current_position_) >=
sizeof(
char_t)) || resize(
sizeof(
char_t)))
652 current_position_++ <<
char_t;
669 return serialize(
static_cast<char>(int8));
680 const uint16_t ushort_t)
682 return serialize(
static_cast<int16_t
>(ushort_t));
693 const int16_t short_t)
695 if (((last_position_ - current_position_) >=
sizeof(short_t)) || resize(
sizeof(short_t)))
697 current_position_ << short_t;
698 current_position_ +=
sizeof(short_t);
714 const uint32_t ulong_t)
716 return serialize(
static_cast<int32_t
>(ulong_t));
727 const int32_t long_t)
729 if (((last_position_ - current_position_) >=
sizeof(long_t)) || resize(
sizeof(long_t)))
731 current_position_ << long_t;
732 current_position_ +=
sizeof(long_t);
750 return serialize(
static_cast<uint32_t
>(wchar));
761 const uint64_t ulonglong_t)
763 return serialize(
static_cast<int64_t
>(ulonglong_t));
774 const int64_t longlong_t)
776 if (((last_position_ - current_position_) >=
sizeof(longlong_t)) || resize(
sizeof(longlong_t)))
778 current_position_ << longlong_t;
779 current_position_ +=
sizeof(longlong_t);
797 if (((last_position_ - current_position_) >=
sizeof(float_t)) || resize(
sizeof(float_t)))
799 current_position_ << float_t;
800 current_position_ +=
sizeof(float_t);
816 const double double_t)
818 if (((last_position_ - current_position_) >=
sizeof(double_t)) || resize(
sizeof(double_t)))
820 current_position_ << double_t;
821 current_position_ +=
sizeof(double_t);
837 const long double ldouble_t)
839 if (((last_position_ - current_position_) >=
sizeof(ldouble_t)) || resize(
sizeof(ldouble_t)))
841 current_position_ << ldouble_t;
843 current_position_ +=
sizeof(ldouble_t);
844 current_position_ << static_cast<long double>(0);
845 #endif // if defined(_WIN32)
846 current_position_ +=
sizeof(ldouble_t);
870 const char* string_t);
879 const wchar_t* string_t);
889 const std::string& string_t)
902 const std::wstring& string_t)
913 template<
class _T,
size_t _Size>
915 const std::array<_T, _Size>& array_t)
917 return serialize_array(array_t.data(), array_t.size());
926 template<
class _T =
bool>
928 const std::vector<bool>& vector_t)
930 return serialize_bool_sequence(vector_t);
941 const std::vector<_T>& vector_t)
943 state state_before_error(*
this);
945 *this << static_cast<int32_t>(vector_t.size());
949 return serialize_array(vector_t.data(), vector_t.size());
953 set_state(state_before_error);
969 const std::vector<bool>& vector_t)
971 return serialize_bool_sequence(vector_t);
974 #endif // ifdef _MSC_VER
999 const uint8_t* octet_t,
1000 size_t num_elements)
1002 return serialize_array(
reinterpret_cast<const char*
>(octet_t), num_elements);
1014 size_t num_elements);
1026 size_t num_elements)
1028 return serialize_array(
reinterpret_cast<const char*
>(int8), num_elements);
1040 const uint16_t* ushort_t,
1041 size_t num_elements)
1043 return serialize_array(
reinterpret_cast<const int16_t*
>(ushort_t), num_elements);
1054 const int16_t* short_t,
1055 size_t num_elements);
1066 const uint32_t* ulong_t,
1067 size_t num_elements)
1069 return serialize_array(
reinterpret_cast<const int32_t*
>(ulong_t), num_elements);
1080 const int32_t* long_t,
1081 size_t num_elements);
1091 const wchar_t* wchar,
1092 size_t num_elements);
1103 const uint64_t* ulonglong_t,
1104 size_t num_elements)
1106 return serialize_array(
reinterpret_cast<const int64_t*
>(ulonglong_t), num_elements);
1117 const int64_t* longlong_t,
1118 size_t num_elements);
1128 const float* float_t,
1129 size_t num_elements);
1139 const double* double_t,
1140 size_t num_elements);
1150 const long double* ldouble_t,
1151 size_t num_elements);
1162 size_t num_elements);
1173 const std::string* string_t,
1174 size_t num_elements)
1192 const std::wstring* string_t,
1193 size_t num_elements)
1211 const std::vector<_T>* vector_t,
1212 size_t num_elements)
1231 size_t num_elements)
1249 const _T* sequence_t,
1250 size_t num_elements)
1252 state state_before_error(*
this);
1254 serialize(
static_cast<int32_t
>(num_elements));
1258 return serialize_array(sequence_t, num_elements);
1262 set_state(state_before_error);
1279 return deserialize(
reinterpret_cast<char&
>(octet_t));
1292 if ((last_position_ - current_position_) >=
sizeof(
char_t))
1294 current_position_++ >>
char_t;
1311 return deserialize(
reinterpret_cast<char&
>(int8));
1324 return deserialize(
reinterpret_cast<int16_t&
>(ushort_t));
1337 if ((last_position_ - current_position_) >=
sizeof(short_t))
1339 current_position_ >> short_t;
1340 current_position_ +=
sizeof(short_t);
1358 return deserialize(
reinterpret_cast<int32_t&
>(ulong_t));
1371 if ((last_position_ - current_position_) >=
sizeof(long_t))
1373 current_position_ >> long_t;
1374 current_position_ +=
sizeof(long_t);
1394 wchar =
static_cast<wchar_t>(
ret);
1406 uint64_t& ulonglong_t)
1408 return deserialize(
reinterpret_cast<int64_t&
>(ulonglong_t));
1419 int64_t& longlong_t)
1421 if ((last_position_ - current_position_) >=
sizeof(longlong_t))
1423 current_position_ >> longlong_t;
1424 current_position_ +=
sizeof(longlong_t);
1442 if ((last_position_ - current_position_) >=
sizeof(float_t))
1444 current_position_ >> float_t;
1445 current_position_ +=
sizeof(float_t);
1463 if ((last_position_ - current_position_) >=
sizeof(double_t))
1465 current_position_ >> double_t;
1466 current_position_ +=
sizeof(double_t);
1482 long double& ldouble_t)
1484 if ((last_position_ - current_position_) >=
sizeof(ldouble_t))
1486 current_position_ >> ldouble_t;
1487 current_position_ +=
sizeof(ldouble_t);
1489 current_position_ +=
sizeof(ldouble_t);
1490 #endif // if defined(_WIN32)
1530 wchar_t*& string_t);
1540 std::string& string_t)
1542 uint32_t length = 0;
1544 string_t = std::string(str, length);
1556 std::wstring& string_t)
1558 uint32_t length = 0;
1559 string_t = read_wstring(length);
1569 template<
class _T,
size_t _Size>
1571 std::array<_T, _Size>& array_t)
1573 return deserialize_array(array_t.data(), array_t.size());
1582 template<
class _T =
bool>
1584 std::vector<bool>& vector_t)
1586 return deserialize_bool_sequence(vector_t);
1597 std::vector<_T>& vector_t)
1599 uint32_t sequence_length = 0;
1600 state state_before_error(*
this);
1602 *
this >> sequence_length;
1606 vector_t.resize(sequence_length);
1607 return deserialize_array(vector_t.data(), vector_t.size());
1611 set_state(state_before_error);
1627 std::vector<bool>& vector_t)
1629 return deserialize_bool_sequence(vector_t);
1632 #endif // ifdef _MSC_VER
1658 size_t num_elements)
1660 return deserialize_array(
reinterpret_cast<char*
>(octet_t), num_elements);
1672 size_t num_elements);
1684 size_t num_elements)
1686 return deserialize_array(
reinterpret_cast<char*
>(int8), num_elements);
1699 size_t num_elements)
1701 return deserialize_array(
reinterpret_cast<int16_t*
>(ushort_t), num_elements);
1713 size_t num_elements);
1725 size_t num_elements)
1727 return deserialize_array(
reinterpret_cast<int32_t*
>(ulong_t), num_elements);
1739 size_t num_elements);
1750 size_t num_elements);
1761 uint64_t* ulonglong_t,
1762 size_t num_elements)
1764 return deserialize_array(
reinterpret_cast<int64_t*
>(ulonglong_t), num_elements);
1775 int64_t* longlong_t,
1776 size_t num_elements);
1787 size_t num_elements);
1798 size_t num_elements);
1808 long double* ldouble_t,
1809 size_t num_elements);
1820 size_t num_elements);
1831 std::string* string_t,
1832 size_t num_elements)
1850 std::wstring* string_t,
1851 size_t num_elements)
1869 std::vector<_T>* vector_t,
1870 size_t num_elements)
1889 size_t num_elements)
1907 template<
class _T = std::
string>
1909 std::string*& sequence_t,
1910 size_t& num_elements)
1912 return deserialize_string_sequence(sequence_t, num_elements);
1924 template<
class _T = std::w
string>
1926 std::wstring*& sequence_t,
1927 size_t& num_elements)
1929 return deserialize_wstring_sequence(sequence_t, num_elements);
1944 size_t& num_elements)
1946 uint32_t sequence_length = 0;
1947 state state_before_error(*
this);
1953 sequence_t =
reinterpret_cast<_T*
>(calloc(sequence_length,
sizeof(_T)));
1954 deserialize_array(sequence_t, sequence_length);
1960 set_state(state_before_error);
1964 num_elements = sequence_length;
1979 FastCdr& deserialize_sequence<std::string>(
1980 std::string*& sequence_t,
1981 size_t& num_elements)
1983 return deserialize_string_sequence(sequence_t, num_elements);
1996 FastCdr& deserialize_sequence<std::wstring>(
1997 std::wstring*& sequence_t,
1998 size_t& num_elements)
2000 return deserialize_wstring_sequence(sequence_t, num_elements);
2003 #endif // ifdef _MSC_VER
2008 const FastCdr&) =
delete;
2010 FastCdr& operator =(
2011 const FastCdr&) =
delete;
2013 FastCdr& serialize_bool_sequence(
2014 const std::vector<bool>& vector_t);
2016 FastCdr& deserialize_bool_sequence(
2017 std::vector<bool>& vector_t);
2019 FastCdr& deserialize_string_sequence(
2020 std::string*& sequence_t,
2021 size_t& num_elements);
2023 FastCdr& deserialize_wstring_sequence(
2024 std::wstring*& sequence_t,
2025 size_t& num_elements);
2034 template<
class _T,
size_t _Size>
2036 const std::array<_T, _Size>* array_t,
2037 size_t num_elements)
2039 return serialize_array(array_t->data(), num_elements * array_t->size());
2049 template<
class _T,
size_t _Size>
2051 std::array<_T, _Size>* array_t,
2052 size_t num_elements)
2054 return deserialize_array(array_t->data(), num_elements * array_t->size());
2058 size_t min_size_inc);
2063 std::wstring read_wstring(
2078 #endif //_FASTCDR_FASTCDR_H_
FastCdr & serialize(const uint8_t octet_t)
This function serializes an octet.
FastCdr & deserialize_array(std::string *string_t, size_t num_elements)
This function deserializes an array of strings.
FastCdr & deserialize(int64_t &longlong_t)
This function deserializes a long long.
FastCdr & deserialize(int8_t &int8)
This function deserializes an int8_t.
FastCdr & serialize_array(const std::vector< _T > *vector_t, size_t num_elements)
This function template serializes an array of sequences.
#define get_current_position()
FastCdr & deserialize(std::vector< bool > &vector_t)
This function template deserializes a sequence of booleans.
FastCdr & deserialize(std::wstring &string_t)
This function deserializes a std::wstring.
FastCdr & deserialize(float &float_t)
This function deserializes a float.
FastBuffer::iterator current_position_
The current position in the serialization/deserialization process.
This class offers an interface to serialize/deserialize some basic types using a modified CDR protoco...
FastCdr & serialize(const long double ldouble_t)
This function serializes a long double.
FastCdr & deserialize_array(uint64_t *ulonglong_t, size_t num_elements)
This function deserializes an array of unsigned long longs.
FastCdr & deserialize(long double &ldouble_t)
This function deserializes a long double.
FastCdr & serialize_array(const uint64_t *ulonglong_t, size_t num_elements)
This function serializes an array of unsigned long longs.
FastCdr & deserialize_array(_T *type_t, size_t num_elements)
This function template deserializes an array of non-basic type objects.
FastCdr & serialize_array(const uint32_t *ulong_t, size_t num_elements)
This function serializes an array of unsigned longs.
FastCdr & serialize(const double double_t)
This function serializes a double.
FastCdr & serialize(const std::string &string_t)
This function serializes a std::string.
FastCdr & serialize(const std::vector< bool > &vector_t)
This function template serializes a sequence of booleans.
This class stores the current state of a CDR serialization.
FastCdr & serialize(const uint64_t ulonglong_t)
This function serializes an unsigned long long.
FastCdr & serialize(const int32_t long_t)
This function serializes a long.
FastCdr & serialize_array(const std::string *string_t, size_t num_elements)
This function serializes an array of strings.
void deserialize(Cdr &, _T &)
static void read_string(LexState *ls, int del, SemInfo *seminfo)
FastCdr & deserialize(std::string &string_t)
This function deserializes a std::string.
FastCdr & deserialize_array(uint8_t *octet_t, size_t num_elements)
This function deserializes an array of octets.
FastCdr & deserialize(double &double_t)
This function deserializes a double.
FastCdr & serialize_array(const uint8_t *octet_t, size_t num_elements)
This function serializes an array of octets.
FastCdr & deserialize_array(uint16_t *ushort_t, size_t num_elements)
This function deserializes an array of unsigned shorts.
FastCdr & deserialize(std::array< _T, _Size > &array_t)
This function template deserializes an array.
FastCdr & serialize(const std::array< _T, _Size > &array_t)
This function template serializes an array.
FastCdr & deserialize_array(int8_t *int8, size_t num_elements)
This function deserializes an array of int8_t.
FastCdr & serialize_array(const std::array< _T, _Size > *array_t, size_t num_elements)
This function template detects the content type of the STD container array and serializes the array.
FastCdr & serialize(const int64_t longlong_t)
This function serializes a long long.
FastCdr & deserialize(uint8_t &octet_t)
This function deserializes an octet.
constexpr auto count() -> size_t
FastCdr & deserialize(uint64_t &ulonglong_t)
This function deserializes an unsigned long long.
FastCdr & serialize_array(const _T *type_t, size_t num_elements)
This function template serializes an array of non-basic type objects.
FastCdr & serialize(const uint16_t ushort_t)
This function serializes an unsigned short.
FastCdr & serialize_sequence(const _T *sequence_t, size_t num_elements)
This function template serializes a raw sequence.
FastCdr & deserialize(std::vector< _T > &vector_t)
This function template deserializes a sequence.
FastCdr & deserialize_sequence(std::wstring *&sequence_t, size_t &num_elements)
This function template deserializes a wide-string sequence. This function allocates memory to store t...
FastCdr & serialize(const std::vector< _T > &vector_t)
This function template serializes a sequence.
FastCdr & serialize_array(const int8_t *int8, size_t num_elements)
This function serializes an array of int8_t.
FastCdr & serialize(const uint32_t ulong_t)
This function serializes an unsigned long.
void serialize(Cdr &, const _T &)
FastCdr & deserialize_array(std::array< _T, _Size > *array_t, size_t num_elements)
This function template detects the content type of the STD container array and deserializes the array...
FastCdr & deserialize_array(uint32_t *ulong_t, size_t num_elements)
This function deserializes an array of unsigned longs.
This abstract class is used to create exceptions.
FastCdr & deserialize(uint32_t &ulong_t)
This function deserializes an unsigned long.
const FastBuffer::iterator current_position_
The position in the buffer when the state was created.
FastCdr & deserialize_sequence(std::string *&sequence_t, size_t &num_elements)
This function template deserializes a string sequence. This function allocates memory to store the se...
FastCdr & serialize(const float float_t)
This function serializes a float.
FastCdr & deserialize_array(std::vector< _T > *vector_t, size_t num_elements)
This function template deserializes an array of sequences.
FastCdr & serialize(const _T &type_t)
This function template serializes a non-basic type.
This class is thrown as an exception when the buffer's internal memory reachs its size limit.
FastBuffer & cdr_buffer_
Reference to the buffer that will be serialized/deserialized.
FastCdr & deserialize_sequence(_T *&sequence_t, size_t &num_elements)
This function template deserializes a raw sequence. This function allocates memory to store the seque...
std::ostream & operator<<(std::ostream &out, const Interval< Scalar, Value > &i)
FastCdr & serialize(const int8_t int8)
This function serializes an int8_t.
FastCdr & deserialize(_T &type_t)
This function template deserializes a non-basic type object.
virtual Cdr_DllAPI void raise() const =0
This function throws the object as exception.
FastCdr & deserialize(int16_t &short_t)
This function deserializes a short.
FastCdr & serialize(const std::wstring &string_t)
This function serializes a std::wstring.
FastCdr & serialize(const int16_t short_t)
This function serializes a short.
FastCdr & deserialize(wchar_t &wchar)
This function deserializes a wide-char.
size_t get_serialized_data_length() const
This function returns the length of the serialized data inside the stream.
FastBuffer::iterator last_position_
The last position in the buffer;.
This class represents a stream of bytes that contains (or will contain) serialized data....
FastCdr & serialize(const wchar_t wchar)
This function serializes a wide-char.
FastCdr & deserialize_array(std::wstring *string_t, size_t num_elements)
This function deserializes an array of wide-strings.
FastCdr & deserialize(int32_t &long_t)
This function deserializes a long.
FastCdr & deserialize(uint16_t &ushort_t)
This function deserializes an unsigned short.
FastCdr & serialize(const char char_t)
This function serializes a character.
typename detail::char_t_impl< S >::type char_t
FastCdr & deserialize(char &char_t)
This function deserializes a character.
FastCdr & serialize_array(const uint16_t *ushort_t, size_t num_elements)
This function serializes an array of unsigned shorts.
FastCdr & serialize_array(const std::wstring *string_t, size_t num_elements)
This function serializes an array of wstrings.
This class implements the iterator used to go through a FastBuffer.
static const Cdr_DllAPI char *const NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT
Default message used in the library.
plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:44