Cdr.h
Go to the documentation of this file.
1 // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef _FASTCDR_CDR_H_
16 #define _FASTCDR_CDR_H_
17 
18 #include <array>
19 #include <bitset>
20 #include <cassert>
21 #include <cstdint>
22 #include <functional>
23 #include <map>
24 #include <string>
25 #include <type_traits>
26 #include <utility>
27 #include <vector>
28 
29 #include "fastcdr_dll.h"
30 
31 #include "CdrEncoding.hpp"
35 #include "exceptions/Exception.h"
37 #include "FastBuffer.h"
38 #include "xcdr/external.hpp"
39 #include "xcdr/MemberId.hpp"
40 #include "xcdr/optional.hpp"
41 
42 #if !__APPLE__ && !__FreeBSD__ && !__VXWORKS__
43 #include <malloc.h>
44 #else
45 #include <stdlib.h>
46 #endif // if !__APPLE__ && !__FreeBSD__ && !__VXWORKS__
47 
48 namespace eprosima {
49 namespace fastcdr {
50 
51 class Cdr;
52 
53 template<class _T>
54 extern void serialize(
55  Cdr&,
56  const _T&);
57 
58 template<class _T>
59 extern void deserialize(
60  Cdr&,
61  _T&);
62 
67 class Cdr
68 {
69 public:
70 
74  typedef enum : uint8_t
75  {
80  } Endianness;
81 
84 
89  typedef enum
90  {
100 
104  class state
105  {
106  friend class Cdr;
107 
108  public:
109 
112  const Cdr& cdr);
113 
116  const state& state);
117 
118 
120  Cdr_DllAPI bool operator ==(
121  const state& other_state) const;
122 
123  private:
124 
125  state& operator =(
126  const state& state) = delete;
127 
130 
133 
135  bool swap_bytes_ {false};
136 
138  size_t last_data_size_ {0};
139 
142 
144  uint32_t member_size_ {0};
145 
147  XCdrHeaderSelection header_selection_ {XCdrHeaderSelection::AUTO_WITH_SHORT_HEADER_BY_DEFAULT};
148 
150  XCdrHeaderSelection header_serialized_ {XCdrHeaderSelection::SHORT_HEADER};
151 
154  };
155 
164  Cdr_DllAPI Cdr(
165  FastBuffer& cdr_buffer,
167  const CdrVersion cdr_version = XCDRv2);
168 
179 
187 
193 
200 
209  EncodingAlgorithmFlag encoding_flag);
210 
215  Cdr_DllAPI std::array<uint8_t, 2> get_dds_cdr_options() const;
216 
222  const std::array<uint8_t, 2>& options);
223 
230 
236 
242  Cdr_DllAPI bool jump(
243  size_t num_bytes);
244 
248  Cdr_DllAPI void reset();
249 
255 
261 
266  Cdr_DllAPI size_t get_serialized_data_length() const;
267 
274  inline static size_t alignment(
275  size_t current_alignment,
276  size_t data_size)
277  {
278  return (data_size - (current_alignment % data_size)) & (data_size - 1);
279  }
280 
285  Cdr_DllAPI state get_state() const;
286 
291  Cdr_DllAPI void set_state(
292  const state& state);
293 
300  size_t num_bytes);
301 
305  inline void reset_alignment()
306  {
307  origin_ = offset_;
308  last_data_size_ = 0;
309  }
310 
324  template<class _T>
325  inline Cdr& operator <<(
326  const _T& value)
327  {
329  {
330  serialize(value);
331  }
332  else
333  {
335 
336  }
337 
338  return *this;
339  }
340 
354  template<class _T>
355  inline Cdr& operator >>(
356  _T& value)
357  {
359  {
360  deserialize(value);
361  }
362  else
363  {
364  deserialize_member(value);
365  }
366  return *this;
367  }
368 
379  template<class _T, typename std::enable_if<!std::is_enum<_T>::value>::type* = nullptr, typename = void>
381  const _T& value)
382  {
383  eprosima::fastcdr::serialize(*this, value);
384  return *this;
385  }
386 
395  template<class _T>
397  const _T& value,
399  {
400  bool aux_swap = swap_bytes_;
401  swap_bytes_ = (swap_bytes_ && (static_cast<Endianness>(endianness_) == endianness)) ||
402  (!swap_bytes_ && (static_cast<Endianness>(endianness_) != endianness));
403 
404  try
405  {
406  serialize(value);
407  swap_bytes_ = aux_swap;
408  }
409  catch (exception::Exception& ex)
410  {
411  swap_bytes_ = aux_swap;
412  ex.raise();
413  }
414 
415  return *this;
416  }
417 
426  template<class _T,
427  typename std::enable_if<std::is_enum<_T>::value>::type* = nullptr,
429  int32_t>::value>::type* = nullptr>
431  const _T& value)
432  {
433  return serialize(static_cast<int32_t>(value));
434  }
435 
444  template<class _T,
445  typename std::enable_if<std::is_enum<_T>::value>::type* = nullptr,
447  uint32_t>::value>::type* = nullptr>
449  const _T& value)
450  {
451  return serialize(static_cast<uint32_t>(value));
452  }
453 
462  template<class _T,
463  typename std::enable_if<std::is_enum<_T>::value>::type* = nullptr,
465  int16_t>::value>::type* = nullptr>
467  const _T& value)
468  {
469  return serialize(static_cast<int16_t>(value));
470  }
471 
480  template<class _T,
481  typename std::enable_if<std::is_enum<_T>::value>::type* = nullptr,
483  uint16_t>::value>::type* = nullptr>
485  const _T& value)
486  {
487  return serialize(static_cast<uint16_t>(value));
488  }
489 
498  template<class _T,
499  typename std::enable_if<std::is_enum<_T>::value>::type* = nullptr,
501  int8_t>::value>::type* = nullptr>
503  const _T& value)
504  {
505  return serialize(static_cast<int8_t>(value));
506  }
507 
516  template<class _T,
517  typename std::enable_if<std::is_enum<_T>::value>::type* = nullptr,
519  uint8_t>::value>::type* = nullptr>
521  const _T& value)
522  {
523  return serialize(static_cast<uint8_t>(value));
524  }
525 
533  const uint8_t& octet_t)
534  {
535  return serialize(static_cast<char>(octet_t));
536  }
537 
545  const char char_t);
546 
554  const int8_t int8)
555  {
556  return serialize(static_cast<char>(int8));
557  }
558 
566  const uint16_t ushort_t)
567  {
568  return serialize(static_cast<int16_t>(ushort_t));
569  }
570 
578  const int16_t short_t);
579 
587  const uint32_t ulong_t)
588  {
589  return serialize(static_cast<int32_t>(ulong_t));
590  }
591 
599  const int32_t long_t);
600 
608  const wchar_t wchar)
609  {
610  return serialize(static_cast<uint16_t>(wchar));
611  }
612 
620  const uint64_t ulonglong_t)
621  {
622  return serialize(static_cast<int64_t>(ulonglong_t));
623  }
624 
632  const int64_t longlong_t);
633 
641  const float float_t);
642 
650  const double double_t);
651 
660  const long double ldouble_t);
661 
669  const bool bool_t);
670 
678  char* string_t)
679  {
680  return serialize(static_cast<const char*>(string_t));
681  }
682 
690  const char* string_t);
691 
699  const wchar_t* string_t);
700 
707  TEMPLATE_SPEC
709  const std::string& string_t)
710  {
711  return serialize(string_t.c_str());
712  }
713 
720  TEMPLATE_SPEC
722  const std::wstring& string_t)
723  {
724  return serialize(string_t.c_str());
725  }
726 
734  template <size_t MAX_CHARS>
736  const fixed_string<MAX_CHARS>& value)
737  {
738  return serialize(value.c_str());
739  }
740 
747  template<class _T, size_t _Size>
749  const std::array<_T, _Size>& array_t)
750  {
751  if (!is_multi_array_primitive(&array_t))
752  {
753  Cdr::state dheader_state {allocate_xcdrv2_dheader()};
754 
755  serialize_array(array_t.data(), array_t.size());
756 
757  set_xcdrv2_dheader(dheader_state);
758  }
759  else
760  {
761  serialize_array(array_t.data(), array_t.size());
762  }
763 
764  return *this;
765  }
766 
773  template<class _T, typename std::enable_if<!std::is_enum<_T>::value &&
774  !std::is_arithmetic<_T>::value>::type* = nullptr>
776  const std::vector<_T>& vector_t)
777  {
778  Cdr::state dheader_state {allocate_xcdrv2_dheader()};
779 
780  serialize(static_cast<int32_t>(vector_t.size()));
781 
782  try
783  {
784  serialize_array(vector_t.data(), vector_t.size());
785  }
786  catch (exception::Exception& ex)
787  {
788  set_state(dheader_state);
789  ex.raise();
790  }
791 
792  set_xcdrv2_dheader(dheader_state);
793 
794  return *this;
795  }
796 
803  template<class _T, typename std::enable_if<std::is_enum<_T>::value ||
804  std::is_arithmetic<_T>::value>::type* = nullptr>
806  const std::vector<_T>& vector_t)
807  {
808  state state_before_error(*this);
809 
810  serialize(static_cast<int32_t>(vector_t.size()));
811 
812  try
813  {
814  serialize_array(vector_t.data(), vector_t.size());
815  }
816  catch (exception::Exception& ex)
817  {
818  set_state(state_before_error);
819  ex.raise();
820  }
821 
823  {
824  serialized_member_size_ = get_serialized_member_size<_T>();
825  }
826 
827  return *this;
828  }
829 
836  TEMPLATE_SPEC
838  const std::vector<bool>& vector_t)
839  {
840  return serialize_bool_sequence(vector_t);
841  }
842 
849  template<class _K, class _T, typename std::enable_if<!std::is_enum<_T>::value &&
850  !std::is_arithmetic<_T>::value>::type* = nullptr>
852  const std::map<_K, _T>& map_t)
853  {
854  Cdr::state dheader_state {allocate_xcdrv2_dheader()};
855 
856  serialize(static_cast<int32_t>(map_t.size()));
857 
858  try
859  {
860  for (auto it_pair = map_t.begin(); it_pair != map_t.end(); ++it_pair)
861  {
862  serialize(it_pair->first);
863  serialize(it_pair->second);
864  }
865  }
866  catch (exception::Exception& ex)
867  {
868  set_state(dheader_state);
869  ex.raise();
870  }
871 
872  set_xcdrv2_dheader(dheader_state);
873 
874  return *this;
875  }
876 
883  template<class _K, class _T, typename std::enable_if<std::is_enum<_T>::value ||
884  std::is_arithmetic<_T>::value>::type* = nullptr>
886  const std::map<_K, _T>& map_t)
887  {
888  state state_(*this);
889 
890  serialize(static_cast<int32_t>(map_t.size()));
891 
892  try
893  {
894  for (auto it_pair = map_t.begin(); it_pair != map_t.end(); ++it_pair)
895  {
896  serialize(it_pair->first);
897  serialize(it_pair->second);
898  }
899  }
900  catch (exception::Exception& ex)
901  {
902  set_state(state_);
903  ex.raise();
904  }
905 
906  return *this;
907  }
908 
917  template<size_t N, typename std::enable_if < (N < 9) > ::type* = nullptr>
918  Cdr& serialize(
919  const std::bitset<N>& value)
920  {
921  return serialize(static_cast<uint8_t>(value.to_ulong()));
922  }
923 
924  template<size_t N, typename std::enable_if < (8 < N && N < 17) > ::type* = nullptr>
925  Cdr& serialize(
926  const std::bitset<N>& value)
927  {
928  return serialize(static_cast<uint16_t>(value.to_ulong()));
929  }
930 
931  template<size_t N, typename std::enable_if < (16 < N && N < 33) > ::type* = nullptr>
932  Cdr& serialize(
933  const std::bitset<N>& value)
934  {
935  return serialize(static_cast<uint32_t>(value.to_ulong()));
936  }
937 
938  template<size_t N, typename std::enable_if < (32 < N && N < 65) > ::type* = nullptr>
939  Cdr& serialize(
940  const std::bitset<N>& value)
941  {
942  return serialize(static_cast<uint64_t>(value.to_ullong()));
943  }
944 
956  template<class _T>
958  const _T* value,
959  size_t num_elements)
960  {
961  for (size_t count = 0; count < num_elements; ++count)
962  {
963  serialize(value[count]);
964  }
965  return *this;
966  }
967 
976  template<class _T>
978  const _T* type_t,
979  size_t num_elements,
981  {
982  bool aux_swap = swap_bytes_;
983  swap_bytes_ = (swap_bytes_ && (static_cast<Endianness>(endianness_) == endianness)) ||
984  (!swap_bytes_ && (static_cast<Endianness>(endianness_) != endianness));
985 
986  try
987  {
988  serialize_array(type_t, num_elements);
989  swap_bytes_ = aux_swap;
990  }
991  catch (exception::Exception& ex)
992  {
993  swap_bytes_ = aux_swap;
994  ex.raise();
995  }
996 
997  return *this;
998  }
999 
1007  TEMPLATE_SPEC
1009  const uint8_t* octet_t,
1010  size_t num_elements)
1011  {
1012  return serialize_array(reinterpret_cast<const char*>(octet_t), num_elements);
1013  }
1014 
1023  const char* char_t,
1024  size_t num_elements);
1025 
1033  TEMPLATE_SPEC
1035  const int8_t* int8,
1036  size_t num_elements)
1037  {
1038  return serialize_array(reinterpret_cast<const char*>(int8), num_elements);
1039  }
1040 
1048  TEMPLATE_SPEC
1050  const uint16_t* ushort_t,
1051  size_t num_elements)
1052  {
1053  return serialize_array(reinterpret_cast<const int16_t*>(ushort_t), num_elements);
1054  }
1055 
1064  const int16_t* short_t,
1065  size_t num_elements);
1066 
1074  TEMPLATE_SPEC
1076  const uint32_t* ulong_t,
1077  size_t num_elements)
1078  {
1079  return serialize_array(reinterpret_cast<const int32_t*>(ulong_t), num_elements);
1080  }
1081 
1090  const int32_t* long_t,
1091  size_t num_elements);
1092 
1101  const wchar_t* wchar,
1102  size_t num_elements);
1103 
1111  TEMPLATE_SPEC
1113  const uint64_t* ulonglong_t,
1114  size_t num_elements)
1115  {
1116  return serialize_array(reinterpret_cast<const int64_t*>(ulonglong_t), num_elements);
1117  }
1118 
1127  const int64_t* longlong_t,
1128  size_t num_elements);
1129 
1138  const float* float_t,
1139  size_t num_elements);
1140 
1149  const double* double_t,
1150  size_t num_elements);
1151 
1161  const long double* ldouble_t,
1162  size_t num_elements);
1163 
1172  const bool* bool_t,
1173  size_t num_elements);
1174 
1182  TEMPLATE_SPEC
1184  const std::string* string_t,
1185  size_t num_elements)
1186  {
1187  for (size_t count = 0; count < num_elements; ++count)
1188  {
1189  serialize(string_t[count].c_str());
1190  }
1191  return *this;
1192  }
1193 
1201  TEMPLATE_SPEC
1203  const std::wstring* string_t,
1204  size_t num_elements)
1205  {
1206  for (size_t count = 0; count < num_elements; ++count)
1207  {
1208  serialize(string_t[count].c_str());
1209  }
1210  return *this;
1211  }
1212 
1221  template<size_t MAX_CHARS>
1223  const fixed_string<MAX_CHARS>* value,
1224  size_t num_elements)
1225  {
1226  for (size_t count = 0; count < num_elements; ++count)
1227  {
1228  serialize(value[count].c_str());
1229  }
1230  return *this;
1231  }
1232 
1240  template<class _T, typename std::enable_if<std::is_enum<_T>::value ||
1241  std::is_arithmetic<_T>::value>::type* = nullptr>
1243  const std::vector<_T>& value)
1244  {
1245  serialize_array(value.data(), value.size());
1246 
1247  return *this;
1248  }
1249 
1257  template<class _T, typename std::enable_if<!std::is_enum<_T>::value &&
1258  !std::is_arithmetic<_T>::value>::type* = nullptr>
1260  const std::vector<_T>& value)
1261  {
1262  Cdr::state dheader_state {allocate_xcdrv2_dheader()};
1263 
1264  serialize_array(value.data(), value.size());
1265 
1266  set_xcdrv2_dheader(dheader_state);
1267 
1268  return *this;
1269  }
1270 
1279  template<class _T>
1281  const std::vector<_T>& value,
1283  {
1284  bool aux_swap = swap_bytes_;
1285  swap_bytes_ = (swap_bytes_ && (static_cast<Endianness>(endianness_) == endianness)) ||
1286  (!swap_bytes_ && (static_cast<Endianness>(endianness_) != endianness));
1287 
1288  try
1289  {
1290  serialize_array(value);
1291  swap_bytes_ = aux_swap;
1292  }
1293  catch (exception::Exception& ex)
1294  {
1295  swap_bytes_ = aux_swap;
1296  ex.raise();
1297  }
1298 
1299  return *this;
1300  }
1301 
1309  TEMPLATE_SPEC
1311  const std::vector<bool>& value)
1312  {
1313  serialize_bool_array(value);
1314 
1315  return *this;
1316  }
1317 
1325  template<class _T, typename std::enable_if<!std::is_enum<_T>::value &&
1326  !std::is_arithmetic<_T>::value>::type* = nullptr>
1328  const _T* sequence_t,
1329  size_t num_elements)
1330  {
1331  Cdr::state dheader_state {allocate_xcdrv2_dheader()};
1332 
1333  serialize(static_cast<int32_t>(num_elements));
1334 
1335  try
1336  {
1337  serialize_array(sequence_t, num_elements);
1338  }
1339  catch (exception::Exception& ex)
1340  {
1341  set_state(dheader_state);
1342  ex.raise();
1343  }
1344 
1345  set_xcdrv2_dheader(dheader_state);
1346 
1347  return *this;
1348  }
1349 
1357  template<class _T, typename std::enable_if<std::is_enum<_T>::value ||
1358  std::is_arithmetic<_T>::value>::type* = nullptr>
1360  const _T* sequence_t,
1361  size_t num_elements)
1362  {
1363  state state_before_error(*this);
1364 
1365  serialize(static_cast<int32_t>(num_elements));
1366 
1367  try
1368  {
1369  serialize_array(sequence_t, num_elements);
1370  }
1371  catch (exception::Exception& ex)
1372  {
1373  set_state(state_before_error);
1374  ex.raise();
1375  }
1376 
1378  {
1379  serialized_member_size_ = get_serialized_member_size<_T>();
1380  }
1381 
1382  return *this;
1383  }
1384 
1393  template<class _T>
1395  const _T* sequence_t,
1396  size_t num_elements,
1398  {
1399  bool aux_swap = swap_bytes_;
1400  swap_bytes_ = (swap_bytes_ && (static_cast<Endianness>(endianness_) == endianness)) ||
1401  (!swap_bytes_ && (static_cast<Endianness>(endianness_) != endianness));
1402 
1403  try
1404  {
1405  serialize_sequence(sequence_t, num_elements);
1406  swap_bytes_ = aux_swap;
1407  }
1408  catch (exception::Exception& ex)
1409  {
1410  swap_bytes_ = aux_swap;
1411  ex.raise();
1412  }
1413 
1414  return *this;
1415  }
1416 
1427  template<class _T, typename std::enable_if<!std::is_enum<_T>::value>::type* = nullptr, typename = void>
1429  _T& value)
1430  {
1431  eprosima::fastcdr::deserialize(*this, value);
1432  return *this;
1433  }
1434 
1443  template<class _T>
1445  _T& value,
1447  {
1448  bool aux_swap = swap_bytes_;
1449  swap_bytes_ = (swap_bytes_ && (static_cast<Endianness>(endianness_) == endianness)) ||
1450  (!swap_bytes_ && (static_cast<Endianness>(endianness_) != endianness));
1451 
1452  try
1453  {
1454  deserialize(value);
1455  swap_bytes_ = aux_swap;
1456  }
1457  catch (exception::Exception& ex)
1458  {
1459  swap_bytes_ = aux_swap;
1460  ex.raise();
1461  }
1462 
1463  return *this;
1464  }
1465 
1473  template<class _T,
1474  typename std::enable_if<std::is_enum<_T>::value>::type* = nullptr,
1476  int32_t>::value>::type* = nullptr>
1478  _T& value)
1479  {
1480  int32_t decode_value {0};
1481  deserialize(decode_value);
1482  value = static_cast<_T>(decode_value);
1483  return *this;
1484  }
1485 
1493  template<class _T,
1494  typename std::enable_if<std::is_enum<_T>::value>::type* = nullptr,
1496  uint32_t>::value>::type* = nullptr>
1498  _T& value)
1499  {
1500  uint32_t decode_value {0};
1501  deserialize(decode_value);
1502  value = static_cast<_T>(decode_value);
1503  return *this;
1504  }
1505 
1513  template<class _T,
1514  typename std::enable_if<std::is_enum<_T>::value>::type* = nullptr,
1516  int16_t>::value>::type* = nullptr>
1518  _T& value)
1519  {
1520  int16_t decode_value {0};
1521  deserialize(decode_value);
1522  value = static_cast<_T>(decode_value);
1523  return *this;
1524  }
1525 
1533  template<class _T,
1534  typename std::enable_if<std::is_enum<_T>::value>::type* = nullptr,
1536  uint16_t>::value>::type* = nullptr>
1538  _T& value)
1539  {
1540  uint16_t decode_value {0};
1541  deserialize(decode_value);
1542  value = static_cast<_T>(decode_value);
1543  return *this;
1544  }
1545 
1553  template<class _T,
1554  typename std::enable_if<std::is_enum<_T>::value>::type* = nullptr,
1556  int8_t>::value>::type* = nullptr>
1558  _T& value)
1559  {
1560  int8_t decode_value {0};
1561  deserialize(decode_value);
1562  value = static_cast<_T>(decode_value);
1563  return *this;
1564  }
1565 
1573  template<class _T,
1574  typename std::enable_if<std::is_enum<_T>::value>::type* = nullptr,
1576  uint8_t>::value>::type* = nullptr>
1578  _T& value)
1579  {
1580  uint8_t decode_value {0};
1581  deserialize(decode_value);
1582  value = static_cast<_T>(decode_value);
1583  return *this;
1584  }
1585 
1592  TEMPLATE_SPEC
1594  uint8_t& octet_t)
1595  {
1596  return deserialize(reinterpret_cast<char&>(octet_t));
1597  }
1598 
1606  char& char_t);
1607 
1614  TEMPLATE_SPEC
1616  int8_t& int8)
1617  {
1618  return deserialize(reinterpret_cast<char&>(int8));
1619  }
1620 
1627  TEMPLATE_SPEC
1629  uint16_t& ushort_t)
1630  {
1631  return deserialize(reinterpret_cast<int16_t&>(ushort_t));
1632  }
1633 
1641  int16_t& short_t);
1642 
1649  TEMPLATE_SPEC
1651  uint32_t& ulong_t)
1652  {
1653  return deserialize(reinterpret_cast<int32_t&>(ulong_t));
1654  }
1655 
1663  int32_t& long_t);
1664 
1671  TEMPLATE_SPEC
1673  wchar_t& wchar)
1674  {
1675  uint16_t ret;
1676  deserialize(ret);
1677  wchar = static_cast<wchar_t>(ret);
1678  return *this;
1679  }
1680 
1687  TEMPLATE_SPEC
1689  uint64_t& ulonglong_t)
1690  {
1691  return deserialize(reinterpret_cast<int64_t&>(ulonglong_t));
1692  }
1693 
1701  int64_t& longlong_t);
1702 
1710  float& float_t);
1711 
1719  double& double_t);
1720 
1729  long double& ldouble_t);
1730 
1739  bool& bool_t);
1740 
1750  char*& string_t);
1751 
1761  wchar_t*& string_t);
1762 
1769  TEMPLATE_SPEC
1771  std::string& string_t)
1772  {
1773  uint32_t length = 0;
1774  const char* str = read_string(length);
1775  string_t.assign(str, length);
1776  return *this;
1777  }
1778 
1785  TEMPLATE_SPEC
1787  std::wstring& string_t)
1788  {
1789  uint32_t length = 0;
1790  string_t = read_wstring(length);
1791  return *this;
1792  }
1793 
1801  template <size_t MAX_CHARS>
1803  fixed_string<MAX_CHARS>& value)
1804  {
1805  uint32_t length = 0;
1806  const char* str = read_string(length);
1807  value = std::string(str, length);
1808  return *this;
1809  }
1810 
1817  template<class _T, size_t _Size>
1819  std::array<_T, _Size>& array_t)
1820  {
1822  {
1823  uint32_t dheader {0};
1824  deserialize(dheader);
1825 
1826  uint32_t count {0};
1827  auto offset = offset_;
1828  while (offset_ - offset < dheader && count < _Size)
1829  {
1830  deserialize_array(&array_t.data()[count], 1);
1831  ++count;
1832  }
1833 
1834  if (offset_ - offset != dheader)
1835  {
1836  throw exception::BadParamException("Member size greater than size specified by DHEADER");
1837  }
1838  }
1839  else
1840  {
1841  return deserialize_array(array_t.data(), array_t.size());
1842  }
1843 
1844  return *this;
1845  }
1846 
1853  template<class _T, typename std::enable_if<!std::is_enum<_T>::value &&
1854  !std::is_arithmetic<_T>::value>::type* = nullptr>
1856  std::vector<_T>& vector_t)
1857  {
1858  uint32_t sequence_length {0};
1859 
1861  {
1862  uint32_t dheader {0};
1863  deserialize(dheader);
1864 
1865  auto offset = offset_;
1866 
1867  deserialize(sequence_length);
1868 
1869  if (0 == sequence_length)
1870  {
1871  vector_t.clear();
1872  return *this;
1873  }
1874  else
1875  {
1876  vector_t.resize(sequence_length);
1877  }
1878 
1879  uint32_t count {0};
1880  while (offset_ - offset < dheader && count < sequence_length)
1881  {
1882  deserialize(vector_t.data()[count]);
1883  ++count;
1884  }
1885 
1886  if (offset_ - offset != dheader)
1887  {
1888  throw exception::BadParamException("Member size differs from the size specified by DHEADER");
1889  }
1890  }
1891  else
1892  {
1893  state state_before_error(*this);
1894 
1895  deserialize(sequence_length);
1896 
1897  if (sequence_length == 0)
1898  {
1899  vector_t.clear();
1900  return *this;
1901  }
1902 
1903  if ((end_ - offset_) < sequence_length)
1904  {
1905  set_state(state_before_error);
1908  }
1909 
1910  try
1911  {
1912  vector_t.resize(sequence_length);
1913  return deserialize_array(vector_t.data(), vector_t.size());
1914  }
1915  catch (exception::Exception& ex)
1916  {
1917  set_state(state_before_error);
1918  ex.raise();
1919  }
1920  }
1921 
1922  return *this;
1923  }
1924 
1931  template<class _T, typename std::enable_if<std::is_enum<_T>::value ||
1932  std::is_arithmetic<_T>::value>::type* = nullptr>
1934  std::vector<_T>& vector_t)
1935  {
1936  uint32_t sequence_length = 0;
1937  state state_before_error(*this);
1938 
1939  deserialize(sequence_length);
1940 
1941  if (sequence_length == 0)
1942  {
1943  vector_t.clear();
1944  return *this;
1945  }
1946 
1947  if ((end_ - offset_) < sequence_length)
1948  {
1949  set_state(state_before_error);
1952  }
1953 
1954  try
1955  {
1956  vector_t.resize(sequence_length);
1957  return deserialize_array(vector_t.data(), vector_t.size());
1958  }
1959  catch (exception::Exception& ex)
1960  {
1961  set_state(state_before_error);
1962  ex.raise();
1963  }
1964 
1965  return *this;
1966  }
1967 
1974  TEMPLATE_SPEC
1976  std::vector<bool>& vector_t)
1977  {
1978  return deserialize_bool_sequence(vector_t);
1979  }
1980 
1987  template<class _K, class _T, typename std::enable_if<!std::is_enum<_T>::value &&
1988  !std::is_arithmetic<_T>::value>::type* = nullptr>
1990  std::map<_K, _T>& map_t)
1991  {
1993  {
1994  uint32_t dheader {0};
1995  deserialize(dheader);
1996 
1997  auto offset = offset_;
1998 
1999  uint32_t map_length {0};
2000  deserialize(map_length);
2001 
2002  map_t.clear();
2003 
2004  uint32_t count {0};
2005  while (offset_ - offset < dheader && count < map_length)
2006  {
2007  _K key;
2008  _T val;
2009  deserialize(key);
2010  deserialize(val);
2011  map_t.emplace(std::pair<_K, _T>(std::move(key), std::move(val)));
2012  ++count;
2013  }
2014 
2015  if (offset_ - offset != dheader)
2016  {
2017  throw exception::BadParamException("Member size greater than size specified by DHEADER");
2018  }
2019  }
2020  else
2021  {
2022  uint32_t sequence_length = 0;
2023  state state_(*this);
2024 
2025  deserialize(sequence_length);
2026 
2027  try
2028  {
2029  for (uint32_t i = 0; i < sequence_length; ++i)
2030  {
2031  _K key;
2032  _T value;
2033  deserialize(key);
2034  deserialize(value);
2035  map_t.emplace(std::pair<_K, _T>(std::move(key), std::move(value)));
2036  }
2037  }
2038  catch (exception::Exception& ex)
2039  {
2040  set_state(state_);
2041  ex.raise();
2042  }
2043  }
2044 
2045  return *this;
2046  }
2047 
2054  template<class _K, class _T, typename std::enable_if<std::is_enum<_T>::value ||
2055  std::is_arithmetic<_T>::value>::type* = nullptr>
2057  std::map<_K, _T>& map_t)
2058  {
2059  uint32_t sequence_length = 0;
2060  state state_(*this);
2061 
2062  deserialize(sequence_length);
2063 
2064  try
2065  {
2066  for (uint32_t i = 0; i < sequence_length; ++i)
2067  {
2068  _K key;
2069  _T value;
2070  deserialize(key);
2071  deserialize(value);
2072  map_t.emplace(std::pair<_K, _T>(std::move(key), std::move(value)));
2073  }
2074  }
2075  catch (exception::Exception& ex)
2076  {
2077  set_state(state_);
2078  ex.raise();
2079  }
2080 
2081  return *this;
2082  }
2083 
2091  template<size_t N, typename std::enable_if < (N < 9) > ::type* = nullptr>
2092  Cdr& deserialize(
2093  std::bitset<N>& value)
2094  {
2095  uint8_t decode_value {0};
2096  deserialize(decode_value);
2097  value = decode_value;
2098  return *this;
2099  }
2100 
2101  template<size_t N, typename std::enable_if < (8 < N && N < 17) > ::type* = nullptr>
2102  Cdr& deserialize(
2103  std::bitset<N>& value)
2104  {
2105  uint16_t decode_value {0};
2106  deserialize(decode_value);
2107  value = decode_value;
2108  return *this;
2109  }
2110 
2111  template<size_t N, typename std::enable_if < (16 < N && N < 33) > ::type* = nullptr>
2112  Cdr& deserialize(
2113  std::bitset<N>& value)
2114  {
2115  uint32_t decode_value {0};
2116  deserialize(decode_value);
2117  value = decode_value;
2118  return *this;
2119  }
2120 
2121  template<size_t N, typename std::enable_if < (32 < N && N < 65) > ::type* = nullptr>
2122  Cdr& deserialize(
2123  std::bitset<N>& value)
2124  {
2125  uint64_t decode_value {0};
2126  deserialize(decode_value);
2127  value = decode_value;
2128  return *this;
2129  }
2130 
2142  template<class _T>
2144  _T* value,
2145  size_t num_elements)
2146  {
2147  for (size_t count = 0; count < num_elements; ++count)
2148  {
2149  deserialize(value[count]);
2150  }
2151  return *this;
2152  }
2153 
2162  template<class _T>
2164  _T* type_t,
2165  size_t num_elements,
2167  {
2168  bool aux_swap = swap_bytes_;
2169  swap_bytes_ = (swap_bytes_ && (static_cast<Endianness>(endianness_) == endianness)) ||
2170  (!swap_bytes_ && (static_cast<Endianness>(endianness_) != endianness));
2171 
2172  try
2173  {
2174  deserialize_array(type_t, num_elements);
2175  swap_bytes_ = aux_swap;
2176  }
2177  catch (exception::Exception& ex)
2178  {
2179  swap_bytes_ = aux_swap;
2180  ex.raise();
2181  }
2182 
2183  return *this;
2184  }
2185 
2193  TEMPLATE_SPEC
2195  uint8_t* octet_t,
2196  size_t num_elements)
2197  {
2198  return deserialize_array(reinterpret_cast<char*>(octet_t), num_elements);
2199  }
2200 
2209  char* char_t,
2210  size_t num_elements);
2211 
2219  TEMPLATE_SPEC
2221  int8_t* int8,
2222  size_t num_elements)
2223  {
2224  return deserialize_array(reinterpret_cast<char*>(int8), num_elements);
2225  }
2226 
2234  TEMPLATE_SPEC
2236  uint16_t* ushort_t,
2237  size_t num_elements)
2238  {
2239  return deserialize_array(reinterpret_cast<int16_t*>(ushort_t), num_elements);
2240  }
2241 
2250  int16_t* short_t,
2251  size_t num_elements);
2252 
2260  TEMPLATE_SPEC
2262  uint32_t* ulong_t,
2263  size_t num_elements)
2264  {
2265  return deserialize_array(reinterpret_cast<int32_t*>(ulong_t), num_elements);
2266  }
2267 
2276  int32_t* long_t,
2277  size_t num_elements);
2278 
2287  wchar_t* wchar,
2288  size_t num_elements);
2289 
2297  TEMPLATE_SPEC
2299  uint64_t* ulonglong_t,
2300  size_t num_elements)
2301  {
2302  return deserialize_array(reinterpret_cast<int64_t*>(ulonglong_t), num_elements);
2303  }
2304 
2313  int64_t* longlong_t,
2314  size_t num_elements);
2315 
2324  float* float_t,
2325  size_t num_elements);
2326 
2335  double* double_t,
2336  size_t num_elements);
2337 
2347  long double* ldouble_t,
2348  size_t num_elements);
2349 
2358  bool* bool_t,
2359  size_t num_elements);
2360 
2371  template<class _T, typename std::enable_if<std::is_enum<_T>::value ||
2372  std::is_arithmetic<_T>::value>::type* = nullptr>
2374  std::vector<_T>& value)
2375  {
2376  deserialize_array(value.data(), value.size());
2377 
2378  return *this;
2379  }
2380 
2391  template<class _T, typename std::enable_if<!std::is_enum<_T>::value &&
2392  !std::is_arithmetic<_T>::value>::type* = nullptr>
2394  std::vector<_T>& value)
2395  {
2397  {
2398  uint32_t dheader {0};
2399  deserialize(dheader);
2400 
2401  uint32_t count {0};
2402  auto offset = offset_;
2403  while (offset_ - offset < dheader && count < value.size())
2404  {
2405  deserialize_array(&value.data()[count], 1);
2406  ++count;
2407  }
2408 
2409  if (offset_ - offset != dheader)
2410  {
2411  throw exception::BadParamException("Member size greater than size specified by DHEADER");
2412  }
2413  }
2414  else
2415  {
2416  return deserialize_array(value.data(), value.size());
2417  }
2418 
2419  return *this;
2420  }
2421 
2433  template<class _T>
2435  std::vector<_T>& value,
2437  {
2438  bool aux_swap = swap_bytes_;
2439  swap_bytes_ = (swap_bytes_ && (static_cast<Endianness>(endianness_) == endianness)) ||
2440  (!swap_bytes_ && (static_cast<Endianness>(endianness_) != endianness));
2441 
2442  try
2443  {
2444  deserialize_array(value);
2445  swap_bytes_ = aux_swap;
2446  }
2447  catch (exception::Exception& ex)
2448  {
2449  swap_bytes_ = aux_swap;
2450  ex.raise();
2451  }
2452 
2453  return *this;
2454  }
2455 
2466  TEMPLATE_SPEC
2468  std::vector<bool>& value)
2469  {
2470  deserialize_bool_array(value);
2471 
2472  return *this;
2473  }
2474 
2484  template<class _T, typename std::enable_if<!std::is_enum<_T>::value &&
2485  !std::is_arithmetic<_T>::value>::type* = nullptr>
2487  _T*& sequence_t,
2488  size_t& num_elements)
2489  {
2490  uint32_t sequence_length {0};
2491 
2493  {
2494  uint32_t dheader {0};
2495  deserialize(dheader);
2496 
2497  auto offset = offset_;
2498 
2499  deserialize(sequence_length);
2500 
2501  try
2502  {
2503  sequence_t = reinterpret_cast<_T*>(calloc(sequence_length, sizeof(_T)));
2504 
2505  uint32_t count {0};
2506  while (offset_ - offset < dheader && count < sequence_length)
2507  {
2508  deserialize(sequence_t[count]);
2509  ++count;
2510  }
2511 
2512  if (offset_ - offset != dheader)
2513  {
2514  throw exception::BadParamException("Member size greater than size specified by DHEADER");
2515  }
2516  }
2517  catch (exception::Exception& ex)
2518  {
2519  free(sequence_t);
2520  sequence_t = NULL;
2521  ex.raise();
2522  }
2523  }
2524  else
2525  {
2526  state state_before_error(*this);
2527 
2528  deserialize(sequence_length);
2529 
2530  if ((end_ - offset_) < sequence_length)
2531  {
2532  set_state(state_before_error);
2535  }
2536 
2537  try
2538  {
2539  sequence_t = reinterpret_cast<_T*>(calloc(sequence_length, sizeof(_T)));
2540  deserialize_array(sequence_t, sequence_length);
2541  }
2542  catch (exception::Exception& ex)
2543  {
2544  free(sequence_t);
2545  sequence_t = NULL;
2546  set_state(state_before_error);
2547  ex.raise();
2548  }
2549  }
2550 
2551  num_elements = sequence_length;
2552  return *this;
2553  }
2554 
2564  template<class _T, typename std::enable_if<std::is_enum<_T>::value ||
2565  std::is_arithmetic<_T>::value>::type* = nullptr>
2567  _T*& sequence_t,
2568  size_t& num_elements)
2569  {
2570  uint32_t sequence_length = 0;
2571  state state_before_error(*this);
2572 
2573  deserialize(sequence_length);
2574 
2575  try
2576  {
2577  sequence_t = reinterpret_cast<_T*>(calloc(sequence_length, sizeof(_T)));
2578  deserialize_array(sequence_t, sequence_length);
2579  }
2580  catch (exception::Exception& ex)
2581  {
2582  free(sequence_t);
2583  sequence_t = NULL;
2584  set_state(state_before_error);
2585  ex.raise();
2586  }
2587 
2588  num_elements = sequence_length;
2589  return *this;
2590  }
2591 
2602  template<class _T>
2604  _T*& sequence_t,
2605  size_t& num_elements,
2607  {
2608  bool aux_swap = swap_bytes_;
2609  swap_bytes_ = (swap_bytes_ && (static_cast<Endianness>(endianness_) == endianness)) ||
2610  (!swap_bytes_ && (static_cast<Endianness>(endianness_) != endianness));
2611 
2612  try
2613  {
2614  deserialize_sequence(sequence_t, num_elements);
2615  swap_bytes_ = aux_swap;
2616  }
2617  catch (exception::Exception& ex)
2618  {
2619  swap_bytes_ = aux_swap;
2620  ex.raise();
2621  }
2622 
2623  return *this;
2624  }
2625 
2635  TEMPLATE_SPEC
2637  std::string*& sequence_t,
2638  size_t& num_elements)
2639  {
2640  return deserialize_string_sequence(sequence_t, num_elements);
2641  }
2642 
2652  TEMPLATE_SPEC
2654  std::wstring*& sequence_t,
2655  size_t& num_elements)
2656  {
2657  return deserialize_wstring_sequence(sequence_t, num_elements);
2658  }
2659 
2663 
2674  template<class _T>
2676  const MemberId& member_id,
2677  const _T& member_value,
2678  XCdrHeaderSelection header_selection = XCdrHeaderSelection::AUTO_WITH_SHORT_HEADER_BY_DEFAULT)
2679  {
2680  Cdr::state current_state(*this);
2681  (this->*begin_serialize_member_)(member_id, true, current_state, header_selection);
2682  serialize(member_value);
2683  return (this->*end_serialize_member_)(current_state);
2684  }
2685 
2696  template<class _T>
2698  const MemberId& member_id,
2699  const optional<_T>& member_value,
2700  XCdrHeaderSelection header_selection = XCdrHeaderSelection::AUTO_WITH_SHORT_HEADER_BY_DEFAULT)
2701  {
2702  Cdr::state current_state(*this);
2703  (this->*begin_serialize_opt_member_)(member_id, member_value.has_value(), current_state, header_selection);
2704  serialize(member_value);
2705  return (this->*end_serialize_opt_member_)(current_state);
2706  }
2707 
2715  template<class _T>
2717  _T& member_value)
2718  {
2719  return deserialize(member_value);
2720  }
2721 
2729  template<class _T>
2731  optional<_T>& member_value)
2732  {
2734  {
2735  Cdr::state current_state(*this);
2736  MemberId member_id;
2737  xcdr1_deserialize_member_header(member_id, current_state);
2738  auto prev_offset = offset_;
2739  if (0 < current_state.member_size_)
2740  {
2741  deserialize(member_value);
2742  }
2743  if (current_state.member_size_ != offset_ - prev_offset)
2744  {
2746  "Member size provided by member header is not equal to the real decoded member size");
2747  }
2748  }
2749  else
2750  {
2751  deserialize(member_value);
2752  }
2753  return *this;
2754  }
2755 
2765  Cdr::state& current_state,
2766  EncodingAlgorithmFlag type_encoding)
2767  {
2768  return (this->*begin_serialize_type_)(current_state, type_encoding);
2769  }
2770 
2779  Cdr::state& current_state)
2780  {
2781  return (this->*end_serialize_type_)(current_state);
2782  }
2783 
2793  EncodingAlgorithmFlag type_encoding,
2794  std::function<bool (Cdr&, const MemberId&)> functor)
2795  {
2796  return (this->*deserialize_type_)(type_encoding, functor);
2797  }
2798 
2806  template<class _T>
2808  const optional<_T>& value)
2809  {
2811  {
2812  serialize(value.has_value());
2813  }
2814 
2815  if (value.has_value())
2816  {
2817  serialize(*value);
2818  }
2819  return *this;
2820  }
2821 
2830  template<class _T>
2832  const external<_T>& value)
2833  {
2834  if (!value)
2835  {
2836  throw exception::BadParamException("External member is null");
2837  }
2838 
2839  serialize(*value);
2840  return *this;
2841  }
2842 
2851  const MemberId& member_id)
2852  {
2854  {
2855  throw exception::BadParamException("Member id already set and not encoded");
2856  }
2857 
2858  next_member_id_ = member_id;
2859  return *this;
2860  }
2861 
2869  template<class _T>
2871  optional<_T>& value)
2872  {
2873  bool is_present = true;
2875  {
2876  deserialize(is_present);
2877  }
2878  value.reset(is_present);
2879  if (is_present)
2880  {
2881  deserialize(*value);
2882  }
2883  return *this;
2884  }
2885 
2894  template<class _T>
2896  external<_T>& value)
2897  {
2898  if (value.is_locked())
2899  {
2900  throw exception::BadParamException("External member is locked");
2901  }
2902 
2903  if (!value)
2904  {
2905  value = external<_T>{new typename external<_T>::type()};
2906  }
2907 
2908  deserialize(*value);
2909  return *this;
2910  }
2911 
2920  template<class _T>
2922  optional<external<_T>>& value)
2923  {
2924  if (value.has_value() && value.value().is_locked())
2925  {
2926  throw exception::BadParamException("External member is locked");
2927  }
2928 
2929  bool is_present = true;
2931  {
2932  deserialize(is_present);
2933  }
2934  value.reset(is_present);
2935  if (is_present)
2936  {
2937  deserialize(*value);
2938  }
2939  return *this;
2940  }
2941 
2948 
2956  const state& state);
2957 
2958 private:
2959 
2960  Cdr(
2961  const Cdr&) = delete;
2962 
2963  Cdr& operator =(
2964  const Cdr&) = delete;
2965 
2967  const std::vector<bool>& vector_t);
2968 
2970  const std::vector<bool>& vector_t);
2971 
2973  std::vector<bool>& vector_t);
2974 
2976  std::vector<bool>& vector_t);
2977 
2979  std::string*& sequence_t,
2980  size_t& num_elements);
2981 
2983  std::wstring*& sequence_t,
2984  size_t& num_elements);
2985 
2993  template<class _T, size_t _Size>
2995  const std::array<_T, _Size>* array_t,
2996  size_t num_elements)
2997  {
2998  return serialize_array(array_t->data(), num_elements * array_t->size());
2999  }
3000 
3008  template<class _T, size_t _Size>
3010  std::array<_T, _Size>* array_t,
3011  size_t num_elements)
3012  {
3013  return deserialize_array(array_t->data(), num_elements * array_t->size());
3014  }
3015 
3024  template<class _T, size_t _Size>
3026  std::array<_T, _Size>* array_t,
3027  size_t num_elements,
3029  {
3030  return deserialize_array(array_t->data(), num_elements * array_t->size(), endianness);
3031  }
3032 
3039  inline size_t alignment(
3040  size_t data_size) const
3041  {
3042  return data_size > last_data_size_ ? (data_size - ((offset_ - origin_) % data_size)) & (data_size - 1) : 0;
3043  }
3044 
3049  inline void make_alignment(
3050  size_t align)
3051  {
3052  offset_ += align;
3053  last_data_size_ = 0;
3054  }
3055 
3061  bool resize(
3062  size_t min_size_inc);
3063 
3064  Cdr_DllAPI const char* read_string(
3065  uint32_t& length);
3066  Cdr_DllAPI const std::wstring read_wstring(
3067  uint32_t& length);
3068 
3072 
3080  const MemberId& member_id);
3081 
3092  const MemberId& member_id,
3093  size_t member_serialized_size);
3094 
3102  const MemberId& member_id);
3103 
3112  const MemberId& member_id,
3113  size_t member_serialized_size);
3114 
3125  const MemberId& member_id,
3126  size_t member_serialized_size);
3127 
3136  const MemberId& member_id,
3137  size_t member_serialized_size);
3138 
3148  MemberId& member_id,
3149  Cdr::state& current_state);
3150 
3159  const MemberId& member_id);
3160 
3171  const MemberId& member_id,
3172  size_t member_serialized_size);
3173 
3182  const MemberId& member_id);
3183 
3193  const MemberId& member_id,
3194  size_t member_serialized_size);
3195 
3206  const MemberId& member_id,
3207  size_t member_serialized_size);
3208 
3218  const MemberId& member_id,
3219  size_t member_serialized_size);
3220 
3230  const MemberId& member_id,
3231  const FastBuffer::iterator& offset);
3232 
3242  MemberId& member_id,
3243  Cdr::state& current_state);
3244 
3262  const MemberId& member_id,
3263  bool is_present,
3264  Cdr::state& current_state,
3265  XCdrHeaderSelection header_selection);
3266 
3278  const Cdr::state& current_state);
3279 
3296  const MemberId& member_id,
3297  bool is_present,
3298  Cdr::state& current_state,
3299  XCdrHeaderSelection header_selection);
3300 
3312  const Cdr::state& current_state);
3313 
3331  const MemberId& member_id,
3332  bool is_present,
3333  Cdr::state& current_state,
3334  XCdrHeaderSelection header_selection);
3335 
3347  const Cdr::state& current_state);
3348 
3359  Cdr::state& current_state,
3360  EncodingAlgorithmFlag type_encoding) noexcept;
3361 
3371  const Cdr::state& current_state);
3372 
3387  Cdr::state& current_state,
3388  EncodingAlgorithmFlag type_encoding);
3389 
3400  const Cdr::state& current_state);
3401 
3415  EncodingAlgorithmFlag type_encoding,
3416  std::function<bool (Cdr&, const MemberId&)> functor);
3417 
3432  EncodingAlgorithmFlag type_encoding,
3433  std::function<bool (Cdr&, const MemberId&)> functor);
3434 
3436  const MemberId& member_id,
3437  bool is_present,
3438  Cdr::state& current_state,
3439  XCdrHeaderSelection header_selection);
3440 
3442  const Cdr::state& current_state);
3443 
3445  Cdr::state& current_state,
3446  EncodingAlgorithmFlag type_encoding);
3447 
3449  const Cdr::state& current_state);
3450 
3452  EncodingAlgorithmFlag type_encoding,
3453  std::function<bool (Cdr&, const MemberId&)> functor);
3454 
3458  void reset_callbacks();
3459 
3460  using begin_serialize_member_functor = Cdr& (Cdr::*)(
3461  const MemberId&,
3462  bool,
3463  Cdr::state&,
3466 
3467  using end_serialize_member_functor = Cdr& (Cdr::*)(
3468  const Cdr::state&);
3470 
3472  const MemberId&,
3473  bool,
3474  Cdr::state&,
3477 
3479  const Cdr::state&);
3481 
3482  using begin_serialize_type_functor = Cdr& (Cdr::*)(
3483  Cdr::state&,
3486 
3487  using end_serialize_type_functor = Cdr& (Cdr::*)(
3488  const Cdr::state&);
3490 
3491  using deserialize_type_functor = Cdr& (Cdr::*)(
3493  std::function<bool (Cdr&, const MemberId&)>);
3495 
3498 
3501 
3504 
3507 
3509  std::array<uint8_t, 2> options_{{0}};
3510 
3512  uint8_t endianness_ {Endianness::LITTLE_ENDIANNESS};
3513 
3515  bool swap_bytes_ {false};
3516 
3518  size_t last_data_size_ {0};
3519 
3522 
3525 
3528 
3531 
3533  size_t align64_ {4};
3534 
3540  {
3545  }
3547  serialized_member_size_ {NO_SERIALIZED_MEMBER_SIZE};
3548 
3549 
3550  uint32_t get_long_lc(
3551  SerializedMemberSizeForNextInt serialized_member_size);
3552 
3553  uint32_t get_short_lc(
3554  size_t member_serialized_size);
3555 
3556  template<class _T, typename std::enable_if<std::is_enum<_T>::value ||
3557  std::is_arithmetic<_T>::value>::type* = nullptr>
3559  {
3560  return (1 == sizeof(_T) ? SERIALIZED_MEMBER_SIZE :
3561  (4 == sizeof(_T) ? SERIALIZED_MEMBER_SIZE_4 :
3562  (8 == sizeof(_T) ? SERIALIZED_MEMBER_SIZE_8 : NO_SERIALIZED_MEMBER_SIZE)));
3563  }
3564 
3565 };
3566 
3567 } //namespace fastcdr
3568 } //namespace eprosima
3569 
3570 #endif // _CDR_CDR_H_
eprosima::fastcdr::Cdr::state::previous_encoding_
EncodingAlgorithmFlag previous_encoding_
Not related with the state. Used by encoding algorithms to store the previous encoding algorithm.
Definition: Cdr.h:153
eprosima::fastcdr::Cdr::serialize
Cdr_DllAPI Cdr & serialize(const wchar_t wchar)
This function serializes a wide-char.
Definition: Cdr.h:607
eprosima::fastcdr::Cdr::xcdr1_end_serialize_member
Cdr & xcdr1_end_serialize_member(const Cdr::state &current_state)
Tells to the encoder to finish the encoding of the member.
Definition: Cdr.cpp:2735
eprosima::fastcdr::Cdr::set_dds_cdr_options
Cdr_DllAPI void set_dds_cdr_options(const std::array< uint8_t, 2 > &options)
This function sets the option flags when the CDR type is eprosima::fastcdr::DDS_CDR.
Definition: Cdr.cpp:361
BadParamException.h
eprosima::fastcdr::Cdr::change_endianness
Cdr_DllAPI void change_endianness(Endianness endianness)
This function sets the current endianness used by the CDR type.
Definition: Cdr.cpp:367
eprosima::fastcdr::Cdr::begin_serialize_type_functor
Cdr &(Cdr::*)(Cdr::state &, EncodingAlgorithmFlag) begin_serialize_type_functor
Definition: Cdr.h:3484
eprosima::fastcdr::Cdr::state::next_member_id_
MemberId next_member_id_
Not related with the state. Next member id which will be encoded.
Definition: Cdr.h:141
eprosima::fastcdr::Cdr::endianness_
uint8_t endianness_
The endianness that will be applied over the buffer.
Definition: Cdr.h:3512
eprosima::fastcdr::exception::BadParamException
This class is thrown as an exception when an invalid parameter is being serialized.
Definition: BadParamException.h:27
NotEnoughMemoryException.h
eprosima::fastcdr::Cdr::serialize
Cdr & serialize(const external< _T > &value)
Encodes an external in the buffer.
Definition: Cdr.h:2831
eprosima::fastcdr::optional::has_value
bool has_value() const
Checks whether the optional contains a value.
Definition: optional.hpp:196
eprosima::fastcdr::Cdr::serialize_array
Cdr & 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.
Definition: Cdr.h:2994
eprosima::fastcdr::Cdr::deserialize_string_sequence
Cdr_DllAPI Cdr & deserialize_string_sequence(std::string *&sequence_t, size_t &num_elements)
Definition: Cdr.cpp:2316
eprosima::fastcdr::Cdr::origin_
FastBuffer::iterator origin_
The position from where the alignment is calculated.
Definition: Cdr.h:3524
detail::state
state
Definition: core.h:2305
align
Definition: core.h:2016
eprosima::fastcdr::Cdr::xcdr2_change_to_short_member_header
void xcdr2_change_to_short_member_header(const MemberId &member_id, size_t member_serialized_size)
Changes the previous encoded long header to a short header according to XCDRv2.
Definition: Cdr.cpp:2634
eprosima::fastcdr::Cdr::set_encoding_flag
Cdr_DllAPI bool set_encoding_flag(EncodingAlgorithmFlag encoding_flag)
Sets the EncodingAlgorithmFlag for the encapsulation when the CDR type is CdrVersion::DDS_CDR,...
Definition: Cdr.cpp:339
eprosima::fastcdr::Cdr::deserialize
TEMPLATE_SPEC Cdr & deserialize(int8_t &int8)
This function deserializes an int8_t.
Definition: Cdr.h:1615
eprosima::fastcdr::Cdr::serialize
Cdr_DllAPI Cdr & serialize(const uint32_t ulong_t)
This function serializes an unsigned long.
Definition: Cdr.h:586
fixed_size_string.hpp
eprosima::fastcdr::Cdr::get_serialized_member_size
constexpr SerializedMemberSizeForNextInt get_serialized_member_size() const
Definition: Cdr.h:3558
eprosima::fastcdr::Cdr::begin_serialize_opt_member_
begin_serialize_opt_member_functor begin_serialize_opt_member_
Definition: Cdr.h:3476
eprosima::fastcdr::Cdr::state::state
Cdr_DllAPI state(const Cdr &cdr)
Default constructor.
Definition: Cdr.cpp:95
eprosima::fastcdr::Cdr::get_long_lc
uint32_t get_long_lc(SerializedMemberSizeForNextInt serialized_member_size)
Definition: Cdr.cpp:50
eprosima::fastcdr::Cdr::SERIALIZED_MEMBER_SIZE_4
@ SERIALIZED_MEMBER_SIZE_4
Serialized member size in a DHEADER.
Definition: Cdr.h:3543
eprosima::fastcdr::Cdr::begin_serialize_member_functor
Cdr &(Cdr::*)(const MemberId &, bool, Cdr::state &, XCdrHeaderSelection) begin_serialize_member_functor
Definition: Cdr.h:3464
eprosima::fastcdr::Cdr::SHORT_HEADER
@ SHORT_HEADER
Initially a short member header is allocated and cannot be changed. This option may cause an exceptio...
Definition: Cdr.h:92
FastBuffer.h
eprosima::fastcdr::Cdr::xcdr2_end_long_member_header
void xcdr2_end_long_member_header(const MemberId &member_id, size_t member_serialized_size)
Finish the encoding of a long member header of a member according to XCDRv2.
Definition: Cdr.cpp:2618
eprosima::fastcdr::Cdr::begin_serialize_opt_member_functor
Cdr &(Cdr::*)(const MemberId &, bool, Cdr::state &, XCdrHeaderSelection) begin_serialize_opt_member_functor
Definition: Cdr.h:3475
eprosima::fastcdr::Cdr::deserialize_type
Cdr_DllAPI Cdr & deserialize_type(EncodingAlgorithmFlag type_encoding, std::function< bool(Cdr &, const MemberId &)> functor)
Tells to the encoder a new type and its members starts to be decoded.
Definition: Cdr.h:2792
eprosima::fastcdr::Cdr::state::operator==
Cdr_DllAPI bool operator==(const state &other_state) const
Compares two states.
Definition: Cdr.cpp:117
backward::ColorMode::type
type
Definition: backward.hpp:3600
eprosima::fastcdr::Cdr::serialize
Cdr & serialize(const std::array< _T, _Size > &array_t)
This function template serializes an array.
Definition: Cdr.h:748
eprosima::fastcdr::Cdr::end_serialize_type_
end_serialize_type_functor end_serialize_type_
Definition: Cdr.h:3489
eprosima::fastcdr::Cdr::get_dds_cdr_options
Cdr_DllAPI std::array< uint8_t, 2 > get_dds_cdr_options() const
This function returns the option flags when the CDR type is eprosima::fastcdr::DDS_CDR.
Definition: Cdr.cpp:356
eprosima::fastcdr::Cdr::state::operator=
state & operator=(const state &state)=delete
eprosima::fastcdr::Cdr::deserialize
TEMPLATE_SPEC Cdr & deserialize(uint16_t &ushort_t)
This function deserializes an unsigned short.
Definition: Cdr.h:1628
eprosima::fastcdr::Cdr::serialize
TEMPLATE_SPEC Cdr & serialize(const std::vector< bool > &vector_t)
This function template serializes a sequence of booleans.
Definition: Cdr.h:837
eprosima::fastcdr::Cdr::deserialize
TEMPLATE_SPEC Cdr & deserialize(uint8_t &octet_t)
This function deserializes an octet.
Definition: Cdr.h:1593
eprosima::fastcdr::Cdr::xcdr1_end_serialize_opt_member
Cdr & xcdr1_end_serialize_opt_member(const Cdr::state &current_state)
Tells to the encoder to finish the encoding of the member.
Definition: Cdr.cpp:2859
eprosima::fastcdr::Cdr::serialize
Cdr_DllAPI Cdr & serialize(const uint8_t &octet_t)
This function serializes an octet.
Definition: Cdr.h:532
eprosima::fastcdr::Cdr::xcdr1_begin_serialize_opt_member
Cdr & xcdr1_begin_serialize_opt_member(const MemberId &member_id, bool is_present, Cdr::state &current_state, XCdrHeaderSelection header_selection)
Tells to the encoder a member starts to be encoded according to XCDRv1.
Definition: Cdr.cpp:2805
eprosima::fastcdr::Cdr::serialize
Cdr & serialize(const _T &value, Endianness endianness)
Encodes the value of a type with a different endianness.
Definition: Cdr.h:396
eprosima::fastcdr::Cdr::serialize_array
TEMPLATE_SPEC Cdr & serialize_array(const std::wstring *string_t, size_t num_elements)
This function serializes an array of wide-strings.
Definition: Cdr.h:1202
eprosima::fastcdr::Cdr::deserialize_array
TEMPLATE_SPEC Cdr & deserialize_array(uint32_t *ulong_t, size_t num_elements)
This function deserializes an array of unsigned longs.
Definition: Cdr.h:2261
eprosima::fastcdr::Cdr::state::header_selection_
XCdrHeaderSelection header_selection_
Not related with the state. Used by encoding algorithms to store the selected member header version.
Definition: Cdr.h:147
eprosima::fastcdr::Cdr::serialize_array
TEMPLATE_SPEC Cdr & serialize_array(const int8_t *int8, size_t num_elements)
This function serializes an array of int8_t.
Definition: Cdr.h:1034
eprosima::fastcdr::Cdr::serialize
Cdr & serialize(const std::map< _K, _T > &map_t)
This function template serializes a map of non-primitive.
Definition: Cdr.h:851
eprosima::fastcdr::Cdr::AUTO_WITH_LONG_HEADER_BY_DEFAULT
@ AUTO_WITH_LONG_HEADER_BY_DEFAULT
Initially a long member header is allocated but can be changed to the shorter version.
Definition: Cdr.h:98
eprosima::fastcdr::Cdr::xcdr2_serialize_short_member_header
void xcdr2_serialize_short_member_header(const MemberId &member_id)
Encodes a short member header of a member according to XCDRv2.
Definition: Cdr.cpp:2586
eprosima::fastcdr::Cdr::cdr_end_serialize_member
Cdr & cdr_end_serialize_member(const Cdr::state &current_state)
Definition: Cdr.cpp:3336
eprosima::fastcdr::Cdr::deserialize_array
Cdr & deserialize_array(_T *value, size_t num_elements)
Decodes an array of a type not managed by this encoder from the buffer.
Definition: Cdr.h:2143
eprosima::fastcdr::Cdr::Endianness
Endianness
This enumeration represents endianness types.
Definition: Cdr.h:74
eprosima::fastcdr::Cdr::deserialize
Cdr & deserialize(std::map< _K, _T > &map_t)
This function template deserializes a map of non-primitive.
Definition: Cdr.h:1989
eprosima::fastcdr::Cdr::reset_alignment
void reset_alignment()
This function resets the alignment to the current position in the buffer.
Definition: Cdr.h:305
eprosima::fastcdr::Cdr::deserialize
Cdr & deserialize(std::array< _T, _Size > &array_t)
This function template deserializes an array.
Definition: Cdr.h:1818
eprosima::fastcdr::deserialize
void deserialize(Cdr &, _T &)
eprosima::fastcdr::Cdr::BIG_ENDIANNESS
@ BIG_ENDIANNESS
Big endianness.
Definition: Cdr.h:77
eprosima::fastcdr::Cdr::serialize
TEMPLATE_SPEC Cdr & serialize(const std::string &string_t)
This function serializes a std::string.
Definition: Cdr.h:708
eprosima::fastcdr::Cdr::xcdr2_begin_serialize_type
Cdr & xcdr2_begin_serialize_type(Cdr::state &current_state, EncodingAlgorithmFlag type_encoding)
Tells to the encoder a new type and its members start to be encoded according to XCDRv2.
Definition: Cdr.cpp:3151
eprosima::fastcdr::Cdr::operator<<
Cdr & operator<<(const _T &value)
Encodes the value into the buffer.
Definition: Cdr.h:325
eprosima::fastcdr::Cdr::begin_serialize_type
Cdr_DllAPI Cdr & begin_serialize_type(Cdr::state &current_state, EncodingAlgorithmFlag type_encoding)
Tells to the encoder a new type and its members starts to be encoded.
Definition: Cdr.h:2764
eprosima::fastcdr::Cdr::operator=
Cdr & operator=(const Cdr &)=delete
eprosima::fastcdr::Cdr::deserialize_array
TEMPLATE_SPEC Cdr & deserialize_array(uint8_t *octet_t, size_t num_elements)
This function deserializes an array of octets.
Definition: Cdr.h:2194
eprosima::fastcdr::Cdr::xcdr1_deserialize_type
Cdr & xcdr1_deserialize_type(EncodingAlgorithmFlag type_encoding, std::function< bool(Cdr &, const MemberId &)> functor)
Tells to the encoder a new type and its members start to be decoded according to XCDRv1.
Definition: Cdr.cpp:3192
eprosima::fastcdr::Cdr::jump
Cdr_DllAPI bool jump(size_t num_bytes)
This function skips a number of bytes in the CDR stream buffer.
Definition: Cdr.cpp:382
eprosima::fastcdr::Cdr::xcdr1_deserialize_member_header
Cdr_DllAPI bool xcdr1_deserialize_member_header(MemberId &member_id, Cdr::state &current_state)
Decodes a member header according to XCDRv1.
Definition: Cdr.cpp:2535
eprosima::fastcdr::Cdr::get_serialized_data_length
Cdr_DllAPI size_t get_serialized_data_length() const
This function returns the length of the serialized data inside the stream.
Definition: Cdr.cpp:407
eprosima::fastcdr::Cdr::cdr_begin_serialize_type
Cdr & cdr_begin_serialize_type(Cdr::state &current_state, EncodingAlgorithmFlag type_encoding)
Definition: Cdr.cpp:3343
eprosima::fastcdr::Cdr::deserialize_array
Cdr & deserialize_array(_T *type_t, size_t num_elements, Endianness endianness)
This function template deserializes an array of non-basic objects with a different endianness.
Definition: Cdr.h:2163
eprosima::fastcdr::CdrVersion
CdrVersion
This enumeration represents the kinds of CDR serialization supported by eprosima::fastcdr::CDR.
Definition: CdrEncoding.hpp:24
eprosima::fastcdr::Cdr::deserialize
Cdr & deserialize(optional< _T > &value)
Decodes an optional from the buffer.
Definition: Cdr.h:2870
eprosima::fastcdr::Cdr::deserialize_array
TEMPLATE_SPEC Cdr & deserialize_array(uint16_t *ushort_t, size_t num_elements)
This function deserializes an array of unsigned shorts.
Definition: Cdr.h:2235
eprosima::fastcdr::Cdr::deserialize
Cdr & deserialize(optional< external< _T >> &value)
Decodes an optional of an external from the buffer.
Definition: Cdr.h:2921
eprosima::fastcdr::Cdr::encoding_flag_
EncodingAlgorithmFlag encoding_flag_
Stores the main encoding algorithm.
Definition: Cdr.h:3503
eprosima::fastcdr::Cdr::move_alignment_forward
Cdr_DllAPI bool move_alignment_forward(size_t num_bytes)
This function moves the alignment forward.
Definition: Cdr.cpp:440
eprosima::fastcdr::Cdr
This class offers an interface to serialize/deserialize some basic types using CDR protocol inside an...
Definition: Cdr.h:67
eprosima::fastcdr::Cdr::xcdr2_end_serialize_member
Cdr & xcdr2_end_serialize_member(const Cdr::state &current_state)
Tells to the encoder to finish the encoding of the member.
Definition: Cdr.cpp:2972
eprosima::fastcdr::Cdr::begin_serialize_type_
begin_serialize_type_functor begin_serialize_type_
Definition: Cdr.h:3485
eprosima::fastcdr::Cdr::next_member_id_
MemberId next_member_id_
Next member identifier to be processed.
Definition: Cdr.h:3530
eprosima::fastcdr::Cdr::serialize_array
Cdr & serialize_array(const _T *value, size_t num_elements)
Encodes an array of a type not managed by this encoder into the buffer.
Definition: Cdr.h:957
MemberId.hpp
eprosima::fastcdr::Cdr::Cdr
Cdr_DllAPI Cdr(FastBuffer &cdr_buffer, const Endianness endianness=DEFAULT_ENDIAN, const CdrVersion cdr_version=XCDRv2)
This constructor creates an eprosima::fastcdr::Cdr object that can serialize/deserialize the assigned...
Definition: Cdr.cpp:130
eprosima::fastcdr::PLAIN_CDR
@ PLAIN_CDR
Specifies that the content is PLAIN_CDR.
Definition: CdrEncoding.hpp:40
eprosima::fastcdr::Cdr::xcdr2_begin_serialize_member
Cdr & xcdr2_begin_serialize_member(const MemberId &member_id, bool is_present, Cdr::state &current_state, XCdrHeaderSelection header_selection)
Tells to the encoder a member starts to be encoded according to XCDRv2.
Definition: Cdr.cpp:2929
eprosima::fastcdr::Cdr::xcdr2_deserialize_type
Cdr & xcdr2_deserialize_type(EncodingAlgorithmFlag type_encoding, std::function< bool(Cdr &, const MemberId &)> functor)
Tells to the encoder a new type and its members start to be decoded according to XCDRv2.
Definition: Cdr.cpp:3241
eprosima::fastcdr::Cdr::serialize_array
TEMPLATE_SPEC Cdr & serialize_array(const uint32_t *ulong_t, size_t num_elements)
This function serializes an array of unsigned longs.
Definition: Cdr.h:1075
detail::count
constexpr auto count() -> size_t
Definition: core.h:1222
container_recursive_inspector.hpp
Exception.h
eprosima::fastcdr::Cdr::xcdr2_end_short_member_header
void xcdr2_end_short_member_header(const MemberId &member_id, size_t member_serialized_size)
Finish the encoding of a short member header of a member according to XCDRv2.
Definition: Cdr.cpp:2595
eprosima::fastcdr::Cdr::deserialize_bool_sequence
Cdr_DllAPI Cdr & deserialize_bool_sequence(std::vector< bool > &vector_t)
Definition: Cdr.cpp:2272
eprosima::fastcdr::Cdr::serialize_array
Cdr & serialize_array(const std::vector< _T > &value)
Encodes an std::vector of primitives as an array.
Definition: Cdr.h:1242
eprosima::fastcdr::Cdr::begin_serialize_member_
begin_serialize_member_functor begin_serialize_member_
Definition: Cdr.h:3465
eprosima::fastcdr::PLAIN_CDR2
@ PLAIN_CDR2
Specifies that the content is PLAIN_CDR2.
Definition: CdrEncoding.hpp:44
eprosima::fastcdr::XCDRv2
@ XCDRv2
XCDRv2 encoding defined by standard DDS X-Types 1.3.
Definition: CdrEncoding.hpp:33
eprosima::fastcdr::Cdr::deserialize
Cdr & deserialize(std::vector< _T > &vector_t)
This function template deserializes a sequence of non-primitive.
Definition: Cdr.h:1855
eprosima::fastcdr::Cdr::serialize_encapsulation
Cdr_DllAPI Cdr & serialize_encapsulation()
This function writes the encapsulation of the CDR stream. If the CDR stream should contain an encapsu...
Definition: Cdr.cpp:284
eprosima::fastcdr::Cdr::state::origin_
const FastBuffer::iterator origin_
The position from the alignment is calculated, when the state was created.
Definition: Cdr.h:132
eprosima::fastcdr::Cdr::serialize_sequence
Cdr & serialize_sequence(const _T *sequence_t, size_t num_elements)
This function template serializes a raw sequence of non-primitives.
Definition: Cdr.h:1327
eprosima::fastcdr::Cdr::xcdr1_begin_serialize_member
Cdr & xcdr1_begin_serialize_member(const MemberId &member_id, bool is_present, Cdr::state &current_state, XCdrHeaderSelection header_selection)
Tells to the encoder a member starts to be encoded according to XCDRv1.
Definition: Cdr.cpp:2680
eprosima::fastcdr::Cdr::serialize
TEMPLATE_SPEC Cdr & serialize(const std::wstring &string_t)
This function serializes a std::wstring.
Definition: Cdr.h:721
eprosima::fastcdr::Cdr::xcdr2_deserialize_member_header
void xcdr2_deserialize_member_header(MemberId &member_id, Cdr::state &current_state)
Decodes a member header according to XCDRv2.
Definition: Cdr.cpp:3069
eprosima::fastcdr::Cdr::endianness
Cdr_DllAPI Endianness endianness() const
This function returns the current endianness used by the CDR type.
Definition: Cdr.cpp:377
eprosima::fastcdr::MemberId
Definition: MemberId.hpp:27
eprosima::fastcdr::Cdr::read_wstring
const Cdr_DllAPI std::wstring read_wstring(uint32_t &length)
Definition: Cdr.cpp:1686
eprosima::fastcdr::Cdr::deserialize
Cdr & deserialize(_T &value, Endianness endianness)
Decodes the value of a type with a different endianness.
Definition: Cdr.h:1444
eprosima::fastcdr::external
This class template manages an external member, a member declared to be external to the storage of a ...
Definition: external.hpp:29
eprosima::fastcdr::Cdr::xcdr2_shrink_to_long_member_header
void xcdr2_shrink_to_long_member_header(const MemberId &member_id, const FastBuffer::iterator &offset)
Join the previous encoded long header with the next DHEADER which was serialized after.
Definition: Cdr.cpp:2668
eprosima::fastcdr::Cdr::allocate_xcdrv2_dheader
Cdr_DllAPI state allocate_xcdrv2_dheader()
Encodes an empty DHEADER if the encoding version is XCDRv2. After serializing the members's type,...
Definition: Cdr.cpp:3380
backward::details::move
const T & move(const T &v)
Definition: backward.hpp:394
eprosima::fastcdr::Cdr::deserialize_bool_array
Cdr_DllAPI Cdr & deserialize_bool_array(std::vector< bool > &vector_t)
Definition: Cdr.cpp:2232
eprosima::fastcdr::Cdr::SERIALIZED_MEMBER_SIZE_8
@ SERIALIZED_MEMBER_SIZE_8
Serialized member size (which is a multiple of 4) in a DHEADER.
Definition: Cdr.h:3544
eprosima::fastcdr::Cdr::serialize_sequence
Cdr & serialize_sequence(const _T *sequence_t, size_t num_elements, Endianness endianness)
This function template serializes a raw sequence with a different endianness.
Definition: Cdr.h:1394
eprosima::fastcdr::external::type
T type
Definition: external.hpp:33
eprosima::fastcdr::Cdr::serialize
Cdr & serialize(const std::vector< _T > &vector_t)
This function template serializes a sequence of non-primitive.
Definition: Cdr.h:775
eprosima::fastcdr::Cdr::deserialize
TEMPLATE_SPEC Cdr & deserialize(uint64_t &ulonglong_t)
This function deserializes an unsigned long long.
Definition: Cdr.h:1688
eprosima::fastcdr::Cdr::get_current_position
Cdr_DllAPI char * get_current_position()
This function returns the current position in the CDR stream.
Definition: Cdr.cpp:402
eprosima::fastcdr::Cdr::serialize_array
TEMPLATE_SPEC Cdr & serialize_array(const uint16_t *ushort_t, size_t num_elements)
This function serializes an array of unsigned shorts.
Definition: Cdr.h:1049
eprosima::fastcdr::Cdr::deserialize_wstring_sequence
Cdr_DllAPI Cdr & deserialize_wstring_sequence(std::wstring *&sequence_t, size_t &num_elements)
Definition: Cdr.cpp:2378
eprosima::fastcdr::Cdr::align64_
size_t align64_
Align for types equal or greater than 64bits.
Definition: Cdr.h:3533
eprosima::fastcdr::Cdr::get_buffer_pointer
Cdr_DllAPI char * get_buffer_pointer()
This function returns the pointer to the current used buffer.
Definition: Cdr.cpp:397
eprosima::fastcdr::Cdr::LONG_HEADER
@ LONG_HEADER
Initially a long member header is allocated and cannot be changed.
Definition: Cdr.h:94
eprosima::fastcdr::Cdr::LITTLE_ENDIANNESS
@ LITTLE_ENDIANNESS
Little endianness.
Definition: Cdr.h:79
eprosima::fastcdr::optional
This class template manages an optional contained value, i.e. a value that may or may not be present.
Definition: optional.hpp:46
eprosima::fastcdr::Cdr::state::last_data_size_
size_t last_data_size_
Stores the last datasize serialized/deserialized when the state was created.
Definition: Cdr.h:138
eprosima::fastcdr::is_multi_array_primitive
constexpr bool is_multi_array_primitive(...)
Basis.
Definition: container_recursive_inspector.hpp:27
eprosima::fastcdr::MEMBER_ID_INVALID
static const MemberId MEMBER_ID_INVALID
Definition: MemberId.hpp:67
eprosima::fastcdr::Cdr::serialize_array
Cdr & serialize_array(const fixed_string< MAX_CHARS > *value, size_t num_elements)
Encodes an array of fixed strings.
Definition: Cdr.h:1222
eprosima::fastcdr::serialize
void serialize(Cdr &, const _T &)
eprosima::fastcdr::Cdr::last_data_size_
size_t last_data_size_
Stores the last datasize serialized/deserialized. It's used to optimize.
Definition: Cdr.h:3518
eprosima::fastcdr::Cdr::serialize
Cdr_DllAPI Cdr & serialize(const uint64_t ulonglong_t)
This function serializes an unsigned long long.
Definition: Cdr.h:619
eprosima::fastcdr::Cdr::end_serialize_type_functor
Cdr &(Cdr::*)(const Cdr::state &) end_serialize_type_functor
Definition: Cdr.h:3488
eprosima::fastcdr::Cdr::serialize_array
TEMPLATE_SPEC Cdr & serialize_array(const uint8_t *octet_t, size_t num_elements)
This function serializes an array of octets.
Definition: Cdr.h:1008
eprosima::fastcdr::Cdr::reset
Cdr_DllAPI void reset()
This function resets the current position in the buffer to the beginning.
Definition: Cdr.cpp:427
eprosima::fastcdr::Cdr::xcdr2_end_serialize_type
Cdr & xcdr2_end_serialize_type(const Cdr::state &current_state)
Tells to the encoder to finish the encoding of the type.
Definition: Cdr.cpp:3173
eprosima::fastcdr::Cdr::serialize_array
Cdr & serialize_array(const std::vector< _T > &value, Endianness endianness)
Encodes an std::vector as an array with a different endianness.
Definition: Cdr.h:1280
external.hpp
eprosima::fastcdr::Cdr::NO_SERIALIZED_MEMBER_SIZE
enum eprosima::fastcdr::Cdr::SerializedMemberSizeForNextInt NO_SERIALIZED_MEMBER_SIZE
Specifies if a DHEADER was serialized. Used to optimize XCDRv2 member headers.
eprosima::fastcdr::Cdr::NO_SERIALIZED_MEMBER_SIZE
@ NO_SERIALIZED_MEMBER_SIZE
Definition: Cdr.h:3541
eprosima::fastcdr::Cdr::alignment
size_t alignment(size_t data_size) const
Returns the number of bytes needed to align the current position (having as reference the origin) to ...
Definition: Cdr.h:3039
eprosima::fastcdr::Cdr::serialize_array
TEMPLATE_SPEC Cdr & serialize_array(const std::vector< bool > &value)
Encodes an std::vector of booleans as an array.
Definition: Cdr.h:1310
eprosima::fastcdr::Cdr::deserialize_array
Cdr & deserialize_array(std::vector< _T > &value)
Decodes an array of primitives on a std::vector.
Definition: Cdr.h:2373
eprosima::fastcdr::Cdr::xcdr1_serialize_short_member_header
void xcdr1_serialize_short_member_header(const MemberId &member_id)
XCDR extensions.
Definition: Cdr.cpp:2443
eprosima::fastcdr::Cdr::deserialize_array
Cdr & 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...
Definition: Cdr.h:3009
eprosima::fastcdr::exception::Exception
This abstract class is used to create exceptions.
Definition: Exception.h:29
eprosima::fastcdr::Cdr::cdr_version_
CdrVersion cdr_version_
The type of CDR that will be use in serialization/deserialization.
Definition: Cdr.h:3500
eprosima::fastcdr::Cdr::deserialize
Cdr & deserialize(fixed_string< MAX_CHARS > &value)
Decodes a fixed string.
Definition: Cdr.h:1802
eprosima::fastcdr::Cdr::serialize_array
Cdr & serialize_array(const _T *type_t, size_t num_elements, Endianness endianness)
This function template serializes an array of non-basic objects with a different endianness.
Definition: Cdr.h:977
eprosima::fastcdr::Cdr::cdr_begin_serialize_member
Cdr & cdr_begin_serialize_member(const MemberId &member_id, bool is_present, Cdr::state &current_state, XCdrHeaderSelection header_selection)
Definition: Cdr.cpp:3326
eprosima::fastcdr::Cdr::get_state
Cdr_DllAPI state get_state() const
Returns the current state of the CDR serialization process.
Definition: Cdr.cpp:412
eprosima::fastcdr::Cdr::serialize_array
TEMPLATE_SPEC Cdr & serialize_array(const uint64_t *ulonglong_t, size_t num_elements)
This function serializes an array of unsigned long longs.
Definition: Cdr.h:1112
eprosima::fastcdr::Cdr::deserialize_sequence
Cdr & deserialize_sequence(_T *&sequence_t, size_t &num_elements, Endianness endianness)
This function template deserializes a raw sequence with a different endianness. This function allocat...
Definition: Cdr.h:2603
eprosima::fastcdr::Cdr::end_serialize_type
Cdr_DllAPI Cdr & end_serialize_type(Cdr::state &current_state)
Tells to the encoder the encoding of the type finishes.
Definition: Cdr.h:2778
eprosima::fastcdr::Cdr::end_serialize_member_
end_serialize_member_functor end_serialize_member_
Definition: Cdr.h:3469
eprosima::fastcdr::Cdr::deserialize_array
TEMPLATE_SPEC Cdr & deserialize_array(int8_t *int8, size_t num_elements)
This function deserializes an array of int8_t.
Definition: Cdr.h:2220
eprosima::fastcdr::Cdr::deserialize
TEMPLATE_SPEC Cdr & deserialize(std::vector< bool > &vector_t)
This function template deserializes a sequence.
Definition: Cdr.h:1975
eprosima::fastcdr::Cdr::deserialize_sequence
TEMPLATE_SPEC Cdr & 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...
Definition: Cdr.h:2636
eprosima::fastcdr::Cdr::deserialize_type_
deserialize_type_functor deserialize_type_
Definition: Cdr.h:3494
eprosima::fastcdr::Cdr::read_encapsulation
Cdr_DllAPI Cdr & read_encapsulation()
This function reads the encapsulation of the CDR stream. If the CDR stream contains an encapsulation,...
Definition: Cdr.cpp:194
sol::detail::align
constexpr std::uintptr_t align(std::size_t alignment, std::uintptr_t ptr, std::size_t &space)
Definition: sol.hpp:10963
eprosima::fastcdr::Cdr::reset_callbacks
void reset_callbacks()
Resets the internal callbacks depending on the current selected Cdr version.
Definition: Cdr.cpp:160
Cdr_DllAPI
#define Cdr_DllAPI
Definition: fastcdr_dll.h:51
eprosima::fastcdr::Cdr::swap_bytes_
bool swap_bytes_
This attribute specifies if it is needed to swap the bytes.
Definition: Cdr.h:3515
eprosima::fastcdr::Cdr::state::header_serialized_
XCdrHeaderSelection header_serialized_
Not related with the state. Used by encoding algorithms to store the allocated member header version.
Definition: Cdr.h:150
eprosima::fastcdr::Cdr::serialize_member
Cdr & serialize_member(const MemberId &member_id, const optional< _T > &member_value, XCdrHeaderSelection header_selection=XCdrHeaderSelection::AUTO_WITH_SHORT_HEADER_BY_DEFAULT)
Encodes an optional member of a type according to the encoding algorithm used.
Definition: Cdr.h:2697
fastcdr_dll.h
eprosima::fastcdr::Cdr::current_encoding_
EncodingAlgorithmFlag current_encoding_
Stores the current encoding algorithm.
Definition: Cdr.h:3506
eprosima::fastcdr::Cdr::get_encoding_flag
Cdr_DllAPI EncodingAlgorithmFlag get_encoding_flag() const
Returns the EncodingAlgorithmFlag set in the encapsulation when the CDR type is CdrVersion::DDS_CDR,...
Definition: Cdr.cpp:334
eprosima::fastcdr::Cdr::DEFAULT_ENDIAN
static const Cdr_DllAPI Endianness DEFAULT_ENDIAN
Default endianess in the system.
Definition: Cdr.h:83
eprosima::fastcdr::Cdr::AUTO_WITH_SHORT_HEADER_BY_DEFAULT
@ AUTO_WITH_SHORT_HEADER_BY_DEFAULT
Initially a short member header is allocated but can be changed to the longer version.
Definition: Cdr.h:96
eprosima::fastcdr::Cdr::deserialize_member
Cdr & deserialize_member(optional< _T > &member_value)
Decodes an optional member of a type according to the encoding algorithm used.
Definition: Cdr.h:2730
eprosima::fastcdr::Cdr::operator>>
Cdr & operator>>(_T &value)
Decodes the value from the buffer.
Definition: Cdr.h:355
eprosima::fastcdr::Cdr::end_
FastBuffer::iterator end_
The last position in the buffer;.
Definition: Cdr.h:3527
eprosima::fastcdr::exception::NotEnoughMemoryException
This class is thrown as an exception when the buffer's internal memory reachs its size limit.
Definition: NotEnoughMemoryException.h:27
eprosima::fastcdr::Cdr::cdr_end_serialize_type
Cdr & cdr_end_serialize_type(const Cdr::state &current_state)
Definition: Cdr.cpp:3354
eprosima::fastcdr::Cdr::resize
bool resize(size_t min_size_inc)
This function resizes the internal buffer. It only applies if the FastBuffer object was created with ...
Definition: Cdr.cpp:455
eprosima::fastcdr::Cdr::deserialize
Cdr & deserialize(external< _T > &value)
Decodes an external from the buffer.
Definition: Cdr.h:2895
eprosima::fastcdr::Cdr::SERIALIZED_MEMBER_SIZE
@ SERIALIZED_MEMBER_SIZE
Default. No serialized member size in a DHEADER.
Definition: Cdr.h:3542
eprosima::fastcdr::Cdr::deserialize_array
Cdr & deserialize_array(std::array< _T, _Size > *array_t, size_t num_elements, Endianness endianness)
This function template detects the content type of STD container array and deserializes the array wit...
Definition: Cdr.h:3025
eprosima::fastcdr::Cdr::set_state
Cdr_DllAPI void set_state(const state &state)
Sets a previous state of the CDR serialization process;.
Definition: Cdr.cpp:417
eprosima::fastcdr::Cdr::serialize_array
TEMPLATE_SPEC Cdr & serialize_array(const std::string *string_t, size_t num_elements)
This function serializes an array of strings.
Definition: Cdr.h:1183
eprosima::fastcdr::Cdr::options_
std::array< uint8_t, 2 > options_
This attribute stores the option flags when the CDR type is DDS_CDR;.
Definition: Cdr.h:3509
eprosima::fastcdr::Cdr::serialize_member
Cdr & serialize_member(const MemberId &member_id, const _T &member_value, XCdrHeaderSelection header_selection=XCdrHeaderSelection::AUTO_WITH_SHORT_HEADER_BY_DEFAULT)
XCDR extensions.
Definition: Cdr.h:2675
eprosima::fastcdr::Cdr::end_serialize_opt_member_
end_serialize_member_functor end_serialize_opt_member_
Definition: Cdr.h:3480
eprosima::fastcdr::Cdr::read_string
const Cdr_DllAPI char * read_string(uint32_t &length)
Definition: Cdr.cpp:1655
eprosima::fastcdr::fixed_string
Template class for non-alloc strings.
Definition: fixed_size_string.hpp:44
eprosima::fastcdr::exception::Exception::raise
virtual Cdr_DllAPI void raise() const =0
This function throws the object as exception.
eprosima::fastcdr::Cdr::serialize_bool_sequence
Cdr_DllAPI Cdr & serialize_bool_sequence(const std::vector< bool > &vector_t)
Definition: Cdr.cpp:2192
eprosima::fastcdr::Cdr::end_serialize_memberopt__functor
Cdr &(Cdr::*)(const Cdr::state &) end_serialize_memberopt__functor
Definition: Cdr.h:3479
eprosima::fastcdr::Cdr::SerializedMemberSizeForNextInt
SerializedMemberSizeForNextInt
Definition: Cdr.h:3539
eprosima::fastcdr::Cdr::deserialize
TEMPLATE_SPEC Cdr & deserialize(std::string &string_t)
This function deserializes a std::string.
Definition: Cdr.h:1770
eprosima::fastcdr::Cdr::serialize_bool_array
Cdr_DllAPI Cdr & serialize_bool_array(const std::vector< bool > &vector_t)
Definition: Cdr.cpp:2154
CdrEncoding.hpp
eprosima::fastcdr::Cdr::xcdr1_change_to_short_member_header
void xcdr1_change_to_short_member_header(const MemberId &member_id, size_t member_serialized_size)
Changes the previous encoded long header to a short header according to XCDRv1.
Definition: Cdr.cpp:2497
eprosima::fastcdr::Cdr::serialize
Cdr & serialize(const _T &value)
Encodes the value of a type into the buffer.
Definition: Cdr.h:380
eprosima::fastcdr::Cdr::serialize
Cdr_DllAPI Cdr & serialize(const int8_t int8)
This function serializes an int8_t.
Definition: Cdr.h:553
eprosima::fastcdr::Cdr::deserialize
TEMPLATE_SPEC Cdr & deserialize(uint32_t &ulong_t)
This function deserializes an unsigned long.
Definition: Cdr.h:1650
eprosima::fastcdr::Cdr::xcdr1_begin_serialize_type
Cdr & xcdr1_begin_serialize_type(Cdr::state &current_state, EncodingAlgorithmFlag type_encoding) noexcept
Tells to the encoder a new type and its members start to be encoded according to XCDRv1.
Definition: Cdr.cpp:3119
eprosima::fastcdr::Cdr::deserialize
Cdr & deserialize(_T &value)
Decodes the value of a type from the buffer.
Definition: Cdr.h:1428
eprosima::fastcdr::Cdr::deserialize_array
TEMPLATE_SPEC Cdr & deserialize_array(std::vector< bool > &value)
Decodes an array of booleans on a std::vector.
Definition: Cdr.h:2467
eprosima::fastcdr::Cdr::XCdrHeaderSelection
XCdrHeaderSelection
Definition: Cdr.h:89
eprosima::fastcdr::FastBuffer
This class represents a stream of bytes that contains (or will contain) serialized data....
Definition: FastBuffer.h:243
eprosima::fastcdr::Cdr::cdr_deserialize_type
Cdr & cdr_deserialize_type(EncodingAlgorithmFlag type_encoding, std::function< bool(Cdr &, const MemberId &)> functor)
Definition: Cdr.cpp:3361
eprosima::fastcdr::Cdr::deserialize
TEMPLATE_SPEC Cdr & deserialize(wchar_t &wchar)
This function deserializes a wide-char.
Definition: Cdr.h:1672
eprosima::fastcdr::Cdr::cdr_buffer_
FastBuffer & cdr_buffer_
Reference to the buffer that will be serialized/deserialized.
Definition: Cdr.h:3497
eprosima::fastcdr::Cdr::state::member_size_
uint32_t member_size_
Not related with the state. Used by encoding algorithms to set the encoded member size.
Definition: Cdr.h:144
eprosima::fastcdr::PL_CDR2
@ PL_CDR2
Specifies that the content is PL_CDR2.
Definition: CdrEncoding.hpp:48
eprosima::fastcdr::Cdr::state::swap_bytes_
bool swap_bytes_
This attribute specifies if it is needed to swap the bytes when the state is created.
Definition: Cdr.h:135
eprosima::fastcdr::Cdr::deserialize_type_functor
Cdr &(Cdr::*)(EncodingAlgorithmFlag, std::function< bool(Cdr &, const MemberId &)>) deserialize_type_functor
Definition: Cdr.h:3493
eprosima::fastcdr::Cdr::serialize
Cdr_DllAPI Cdr & serialize(char *string_t)
This function serializes a string.
Definition: Cdr.h:677
eprosima::fastcdr::Cdr::make_alignment
void make_alignment(size_t align)
This function jumps the number of bytes of the alignment. These bytes should be calculated with the f...
Definition: Cdr.h:3049
eprosima::fastcdr::Cdr::serialize
Cdr & serialize(const fixed_string< MAX_CHARS > &value)
Encodes a eprosima::fastcdr::fixed_string in the buffer.
Definition: Cdr.h:735
eprosima::fastcdr::EncodingAlgorithmFlag
EncodingAlgorithmFlag
This enumeration represents the supported XCDR encoding algorithms.
Definition: CdrEncoding.hpp:37
eprosima
Definition: fixed_size_string.hpp:32
eprosima::fastcdr::Cdr::set_xcdrv2_dheader
Cdr_DllAPI void set_xcdrv2_dheader(const state &state)
Uses the state to calculate the member's type size and serialize the value in the previous allocated ...
Definition: Cdr.cpp:3394
eprosima::fastcdr::Cdr::deserialize_member
Cdr & deserialize_member(_T &member_value)
Decodes a member of a type according to the encoding algorithm used.
Definition: Cdr.h:2716
eprosima::fastcdr::Cdr::xcdr2_serialize_long_member_header
void xcdr2_serialize_long_member_header(const MemberId &member_id)
Encodes a long member header of a member according to XCDRv2.
Definition: Cdr.cpp:2607
eprosima::fastcdr::Cdr::xcdr1_end_short_member_header
void xcdr1_end_short_member_header(const MemberId &member_id, size_t member_serialized_size)
Finish the encoding of a short member header of a member according to XCDRv1.
Definition: Cdr.cpp:2458
eprosima::fastcdr::Cdr::end_serialize_member_functor
Cdr &(Cdr::*)(const Cdr::state &) end_serialize_member_functor
Definition: Cdr.h:3468
eprosima::fastcdr::Cdr::get_short_lc
uint32_t get_short_lc(size_t member_serialized_size)
Definition: Cdr.cpp:73
eprosima::fastcdr::Cdr::serialize
Cdr & serialize(const optional< _T > &value)
Encodes an optional in the buffer.
Definition: Cdr.h:2807
char_t
typename detail::char_t_impl< S >::type char_t
Definition: core.h:664
eprosima::fastcdr::Cdr::xcdr2_change_to_long_member_header
void xcdr2_change_to_long_member_header(const MemberId &member_id, size_t member_serialized_size)
Changes the previous encoded long header to a short header according to XCDRv2.
Definition: Cdr.cpp:2647
eprosima::fastcdr::Cdr::state
This class stores the current state of a CDR serialization.
Definition: Cdr.h:104
eprosima::fastcdr::Cdr::get_cdr_version
Cdr_DllAPI CdrVersion get_cdr_version() const
Retrieves the CdrVersion used by the instance.
Definition: Cdr.cpp:329
eprosima::fastcdr::Cdr::xcdr1_serialize_long_member_header
void xcdr1_serialize_long_member_header(const MemberId &member_id)
Encodes a long member header of a member according to XCDRv1.
Definition: Cdr.cpp:2471
eprosima::fastcdr::Cdr::xcdr1_change_to_long_member_header
void xcdr1_change_to_long_member_header(const MemberId &member_id, size_t member_serialized_size)
Changes the previous encoded short header to a long header according to XCDRv1.
Definition: Cdr.cpp:2512
mqtt_test.ret
ret
Definition: mqtt_test.py:30
eprosima::fastcdr::Cdr::offset_
FastBuffer::iterator offset_
The current position in the serialization/deserialization process.
Definition: Cdr.h:3521
eprosima::fastcdr::Cdr::deserialize_array
TEMPLATE_SPEC Cdr & deserialize_array(uint64_t *ulonglong_t, size_t num_elements)
This function deserializes an array of unsigned long longs.
Definition: Cdr.h:2298
eprosima::fastcdr::Cdr::xcdr1_end_long_member_header
void xcdr1_end_long_member_header(const MemberId &member_id, size_t member_serialized_size)
Finish the encoding of a long member header of a member according to XCDRv1.
Definition: Cdr.cpp:2488
eprosima::fastcdr::Cdr::alignment
static size_t alignment(size_t current_alignment, size_t data_size)
Returns the number of bytes needed to align a position to certain data size.
Definition: Cdr.h:274
eprosima::fastcdr::Cdr::deserialize_sequence
TEMPLATE_SPEC Cdr & 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...
Definition: Cdr.h:2653
eprosima::fastcdr::Cdr::deserialize_array
Cdr & deserialize_array(std::vector< _T > &value, Endianness endianness)
Decodes an array of non-primitives on a std::vector with a different endianness.
Definition: Cdr.h:2434
eprosima::fastcdr::Cdr::xcdr1_end_serialize_type
Cdr & xcdr1_end_serialize_type(const Cdr::state &current_state)
Tells to the encoder to finish the encoding of the type.
Definition: Cdr.cpp:3133
eprosima::fastcdr::_FastBuffer_iterator
This class implements the iterator used to go through a FastBuffer.
Definition: FastBuffer.h:42
eprosima::fastcdr::Cdr::deserialize_sequence
Cdr & deserialize_sequence(_T *&sequence_t, size_t &num_elements)
This function template deserializes a raw sequence of non-primitives. This function allocates memory ...
Definition: Cdr.h:2486
eprosima::fastcdr::exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT
static const Cdr_DllAPI char *const NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT
Default message used in the library.
Definition: NotEnoughMemoryException.h:78
eprosima::fastcdr::Cdr::state::offset_
const FastBuffer::iterator offset_
The position in the buffer when the state was created.
Definition: Cdr.h:129
eprosima::fastcdr::Cdr::serialize
Cdr_DllAPI Cdr & serialize(const uint16_t ushort_t)
This function serializes an unsigned short.
Definition: Cdr.h:565
optional.hpp
eprosima::fastcdr::Cdr::deserialize
TEMPLATE_SPEC Cdr & deserialize(std::wstring &string_t)
This function deserializes a std::wstring.
Definition: Cdr.h:1786


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:43