FastCdr.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_FASTCDR_H_
16 #define _FASTCDR_FASTCDR_H_
17 
18 #include "fastcdr_dll.h"
19 #include "FastBuffer.h"
21 #include <stdint.h>
22 #include <string>
23 #include <vector>
24 
25 #if !__APPLE__ && !__FreeBSD__ && !__VXWORKS__
26 #include <malloc.h>
27 #else
28 #include <stdlib.h>
29 #endif // if !__APPLE__ && !__FreeBSD__ && !__VXWORKS__
30 
31 #include <array>
32 
33 namespace eprosima {
34 namespace fastcdr {
41 {
42 public:
43 
48  {
49  friend class FastCdr;
50 
51  public:
52 
56  state(
57  const FastCdr& fastcdr);
58 
62  state(
63  const state&);
64 
65  private:
66 
67  state& operator =(
68  const state&) = delete;
69 
72  };
79  FastCdr(
80  FastBuffer& cdr_buffer);
81 
87  bool jump(
88  size_t num_bytes);
89 
93  void reset();
94 
99  char* get_current_position();
100 
105  inline size_t get_serialized_data_length() const
106  {
107  return current_position_ - cdr_buffer_.begin();
108  }
109 
114  FastCdr::state get_state();
115 
120  void set_state(
122 
130  const uint8_t octet_t)
131  {
132  return serialize(octet_t);
133  }
134 
142  const char char_t)
143  {
144  return serialize(char_t);
145  }
146 
154  const int8_t int8)
155  {
156  return serialize(int8);
157  }
158 
166  const uint16_t ushort_t)
167  {
168  return serialize(ushort_t);
169  }
170 
178  const int16_t short_t)
179  {
180  return serialize(short_t);
181  }
182 
190  const uint32_t ulong_t)
191  {
192  return serialize(ulong_t);
193  }
194 
202  const int32_t long_t)
203  {
204  return serialize(long_t);
205  }
206 
214  const wchar_t wchar)
215  {
216  return serialize(wchar);
217  }
218 
226  const uint64_t ulonglong_t)
227  {
228  return serialize(ulonglong_t);
229  }
230 
238  const int64_t longlong_t)
239  {
240  return serialize(longlong_t);
241  }
242 
250  const float float_t)
251  {
252  return serialize(float_t);
253  }
254 
262  const double double_t)
263  {
264  return serialize(double_t);
265  }
266 
274  const long double ldouble_t)
275  {
276  return serialize(ldouble_t);
277  }
278 
286  const bool bool_t)
287  {
288  return serialize(bool_t);
289  }
290 
298  const char* string_t)
299  {
300  return serialize(string_t);
301  }
302 
310  const wchar_t* string_t)
311  {
312  return serialize(string_t);
313  }
314 
322  const std::string& string_t)
323  {
324  return serialize(string_t);
325  }
326 
334  const std::wstring& string_t)
335  {
336  return serialize(string_t);
337  }
338 
345  template<class _T, size_t _Size>
347  const std::array<_T, _Size>& array_t)
348  {
349  return serialize<_T, _Size>(array_t);
350  }
351 
358  template<class _T>
360  const std::vector<_T>& vector_t)
361  {
362  return serialize<_T>(vector_t);
363  }
364 
371  template<class _T>
373  const _T& type_t)
374  {
375  type_t.serialize(*this);
376  return *this;
377  }
378 
385  inline FastCdr& operator >>(
386  uint8_t& octet_t)
387  {
388  return deserialize(octet_t);
389  }
390 
397  inline FastCdr& operator >>(
398  char& char_t)
399  {
400  return deserialize(char_t);
401  }
402 
409  inline FastCdr& operator >>(
410  int8_t& int8)
411  {
412  return deserialize(int8);
413  }
414 
421  inline FastCdr& operator >>(
422  uint16_t& ushort_t)
423  {
424  return deserialize(ushort_t);
425  }
426 
433  inline FastCdr& operator >>(
434  int16_t& short_t)
435  {
436  return deserialize(short_t);
437  }
438 
445  inline FastCdr& operator >>(
446  uint32_t& ulong_t)
447  {
448  return deserialize(ulong_t);
449  }
450 
457  inline FastCdr& operator >>(
458  int32_t& long_t)
459  {
460  return deserialize(long_t);
461  }
462 
469  inline FastCdr& operator >>(
470  wchar_t& wchar)
471  {
472  return deserialize(wchar);
473  }
474 
481  inline FastCdr& operator >>(
482  uint64_t& ulonglong_t)
483  {
484  return deserialize(ulonglong_t);
485  }
486 
493  inline FastCdr& operator >>(
494  int64_t& longlong_t)
495  {
496  return deserialize(longlong_t);
497  }
498 
505  inline FastCdr& operator >>(
506  float& float_t)
507  {
508  return deserialize(float_t);
509  }
510 
517  inline FastCdr& operator >>(
518  double& double_t)
519  {
520  return deserialize(double_t);
521  }
522 
529  inline FastCdr& operator >>(
530  long double& ldouble_t)
531  {
532  return deserialize(ldouble_t);
533  }
534 
542  inline FastCdr& operator >>(
543  bool& bool_t)
544  {
545  return deserialize(bool_t);
546  }
547 
557  inline FastCdr& operator >>(
558  char*& string_t)
559  {
560  return deserialize(string_t);
561  }
562 
569  inline FastCdr& operator >>(
570  std::string& string_t)
571  {
572  return deserialize(string_t);
573  }
574 
581  inline FastCdr& operator >>(
582  std::wstring& string_t)
583  {
584  return deserialize(string_t);
585  }
586 
593  template<class _T, size_t _Size>
594  inline FastCdr& operator >>(
595  std::array<_T, _Size>& array_t)
596  {
597  return deserialize<_T, _Size>(array_t);
598  }
599 
606  template<class _T>
607  inline FastCdr& operator >>(
608  std::vector<_T>& vector_t)
609  {
610  return deserialize<_T>(vector_t);
611  }
612 
619  template<class _T>
620  inline FastCdr& operator >>(
621  _T& type_t)
622  {
623  type_t.deserialize(*this);
624  return *this;
625  }
626 
633  inline
635  const uint8_t octet_t)
636  {
637  return serialize(static_cast<char>(octet_t));
638  }
639 
646  inline
648  const char char_t)
649  {
650  if (((last_position_ - current_position_) >= sizeof(char_t)) || resize(sizeof(char_t)))
651  {
652  current_position_++ << char_t;
653  return *this;
654  }
655 
657  }
658 
665  inline
667  const int8_t int8)
668  {
669  return serialize(static_cast<char>(int8));
670  }
671 
678  inline
680  const uint16_t ushort_t)
681  {
682  return serialize(static_cast<int16_t>(ushort_t));
683  }
684 
691  inline
693  const int16_t short_t)
694  {
695  if (((last_position_ - current_position_) >= sizeof(short_t)) || resize(sizeof(short_t)))
696  {
697  current_position_ << short_t;
698  current_position_ += sizeof(short_t);
699 
700  return *this;
701  }
702 
704  }
705 
712  inline
714  const uint32_t ulong_t)
715  {
716  return serialize(static_cast<int32_t>(ulong_t));
717  }
718 
725  inline
727  const int32_t long_t)
728  {
729  if (((last_position_ - current_position_) >= sizeof(long_t)) || resize(sizeof(long_t)))
730  {
731  current_position_ << long_t;
732  current_position_ += sizeof(long_t);
733 
734  return *this;
735  }
736 
738  }
739 
746  inline
748  const wchar_t wchar)
749  {
750  return serialize(static_cast<uint32_t>(wchar));
751  }
752 
759  inline
761  const uint64_t ulonglong_t)
762  {
763  return serialize(static_cast<int64_t>(ulonglong_t));
764  }
765 
772  inline
774  const int64_t longlong_t)
775  {
776  if (((last_position_ - current_position_) >= sizeof(longlong_t)) || resize(sizeof(longlong_t)))
777  {
778  current_position_ << longlong_t;
779  current_position_ += sizeof(longlong_t);
780 
781  return *this;
782  }
783 
785  }
786 
793  inline
795  const float float_t)
796  {
797  if (((last_position_ - current_position_) >= sizeof(float_t)) || resize(sizeof(float_t)))
798  {
799  current_position_ << float_t;
800  current_position_ += sizeof(float_t);
801 
802  return *this;
803  }
804 
806  }
807 
814  inline
816  const double double_t)
817  {
818  if (((last_position_ - current_position_) >= sizeof(double_t)) || resize(sizeof(double_t)))
819  {
820  current_position_ << double_t;
821  current_position_ += sizeof(double_t);
822 
823  return *this;
824  }
825 
827  }
828 
835  inline
837  const long double ldouble_t)
838  {
839  if (((last_position_ - current_position_) >= sizeof(ldouble_t)) || resize(sizeof(ldouble_t)))
840  {
841  current_position_ << ldouble_t;
842 #if defined(_WIN32)
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);
847 
848  return *this;
849  }
850 
852  }
853 
861  const bool bool_t);
862 
870  const char* string_t);
871 
879  const wchar_t* string_t);
880 
887  inline
889  const std::string& string_t)
890  {
891  return serialize(string_t.c_str());
892  }
893 
900  inline
902  const std::wstring& string_t)
903  {
904  return serialize(string_t.c_str());
905  }
906 
913  template<class _T, size_t _Size>
915  const std::array<_T, _Size>& array_t)
916  {
917  return serialize_array(array_t.data(), array_t.size());
918  }
919 
926  template<class _T = bool>
928  const std::vector<bool>& vector_t)
929  {
930  return serialize_bool_sequence(vector_t);
931  }
932 
939  template<class _T>
941  const std::vector<_T>& vector_t)
942  {
943  state state_before_error(*this);
944 
945  *this << static_cast<int32_t>(vector_t.size());
946 
947  try
948  {
949  return serialize_array(vector_t.data(), vector_t.size());
950  }
952  {
953  set_state(state_before_error);
954  ex.raise();
955  }
956 
957  return *this;
958  }
959 
960 #ifdef _MSC_VER
961 
967  template<>
968  FastCdr& serialize<bool>(
969  const std::vector<bool>& vector_t)
970  {
971  return serialize_bool_sequence(vector_t);
972  }
973 
974 #endif // ifdef _MSC_VER
975 
982  template<class _T>
984  const _T& type_t)
985  {
986  type_t.serialize(*this);
987  return *this;
988  }
989 
997  inline
999  const uint8_t* octet_t,
1000  size_t num_elements)
1001  {
1002  return serialize_array(reinterpret_cast<const char*>(octet_t), num_elements);
1003  }
1004 
1012  FastCdr& serialize_array(
1013  const char* char_t,
1014  size_t num_elements);
1015 
1023  inline
1025  const int8_t* int8,
1026  size_t num_elements)
1027  {
1028  return serialize_array(reinterpret_cast<const char*>(int8), num_elements);
1029  }
1030 
1038  inline
1040  const uint16_t* ushort_t,
1041  size_t num_elements)
1042  {
1043  return serialize_array(reinterpret_cast<const int16_t*>(ushort_t), num_elements);
1044  }
1045 
1053  FastCdr& serialize_array(
1054  const int16_t* short_t,
1055  size_t num_elements);
1056 
1064  inline
1066  const uint32_t* ulong_t,
1067  size_t num_elements)
1068  {
1069  return serialize_array(reinterpret_cast<const int32_t*>(ulong_t), num_elements);
1070  }
1071 
1079  FastCdr& serialize_array(
1080  const int32_t* long_t,
1081  size_t num_elements);
1082 
1090  FastCdr& serialize_array(
1091  const wchar_t* wchar,
1092  size_t num_elements);
1093 
1101  inline
1103  const uint64_t* ulonglong_t,
1104  size_t num_elements)
1105  {
1106  return serialize_array(reinterpret_cast<const int64_t*>(ulonglong_t), num_elements);
1107  }
1108 
1116  FastCdr& serialize_array(
1117  const int64_t* longlong_t,
1118  size_t num_elements);
1119 
1127  FastCdr& serialize_array(
1128  const float* float_t,
1129  size_t num_elements);
1130 
1138  FastCdr& serialize_array(
1139  const double* double_t,
1140  size_t num_elements);
1141 
1149  FastCdr& serialize_array(
1150  const long double* ldouble_t,
1151  size_t num_elements);
1152 
1160  FastCdr& serialize_array(
1161  const bool* bool_t,
1162  size_t num_elements);
1163 
1171  inline
1173  const std::string* string_t,
1174  size_t num_elements)
1175  {
1176  for (size_t count = 0; count < num_elements; ++count)
1177  {
1178  serialize(string_t[count].c_str());
1179  }
1180  return *this;
1181  }
1182 
1190  inline
1192  const std::wstring* string_t,
1193  size_t num_elements)
1194  {
1195  for (size_t count = 0; count < num_elements; ++count)
1196  {
1197  serialize(string_t[count].c_str());
1198  }
1199  return *this;
1200  }
1201 
1209  template<class _T>
1211  const std::vector<_T>* vector_t,
1212  size_t num_elements)
1213  {
1214  for (size_t count = 0; count < num_elements; ++count)
1215  {
1216  serialize(vector_t[count]);
1217  }
1218  return *this;
1219  }
1220 
1228  template<class _T>
1230  const _T* type_t,
1231  size_t num_elements)
1232  {
1233  for (size_t count = 0; count < num_elements; ++count)
1234  {
1235  type_t[count].serialize(*this);
1236  }
1237  return *this;
1238  }
1239 
1247  template<class _T>
1249  const _T* sequence_t,
1250  size_t num_elements)
1251  {
1252  state state_before_error(*this);
1253 
1254  serialize(static_cast<int32_t>(num_elements));
1255 
1256  try
1257  {
1258  return serialize_array(sequence_t, num_elements);
1259  }
1261  {
1262  set_state(state_before_error);
1263  ex.raise();
1264  }
1265 
1266  return *this;
1267  }
1268 
1275  inline
1277  uint8_t& octet_t)
1278  {
1279  return deserialize(reinterpret_cast<char&>(octet_t));
1280  }
1281 
1288  inline
1290  char& char_t)
1291  {
1292  if ((last_position_ - current_position_) >= sizeof(char_t))
1293  {
1294  current_position_++ >> char_t;
1295  return *this;
1296  }
1297 
1299  }
1300 
1307  inline
1309  int8_t& int8)
1310  {
1311  return deserialize(reinterpret_cast<char&>(int8));
1312  }
1313 
1320  inline
1322  uint16_t& ushort_t)
1323  {
1324  return deserialize(reinterpret_cast<int16_t&>(ushort_t));
1325  }
1326 
1333  inline
1335  int16_t& short_t)
1336  {
1337  if ((last_position_ - current_position_) >= sizeof(short_t))
1338  {
1339  current_position_ >> short_t;
1340  current_position_ += sizeof(short_t);
1341 
1342  return *this;
1343  }
1344 
1346  }
1347 
1354  inline
1356  uint32_t& ulong_t)
1357  {
1358  return deserialize(reinterpret_cast<int32_t&>(ulong_t));
1359  }
1360 
1367  inline
1369  int32_t& long_t)
1370  {
1371  if ((last_position_ - current_position_) >= sizeof(long_t))
1372  {
1373  current_position_ >> long_t;
1374  current_position_ += sizeof(long_t);
1375 
1376  return *this;
1377  }
1378 
1380  }
1381 
1388  inline
1390  wchar_t& wchar)
1391  {
1392  uint32_t ret;
1393  deserialize(ret);
1394  wchar = static_cast<wchar_t>(ret);
1395  return *this;
1396  }
1397 
1404  inline
1406  uint64_t& ulonglong_t)
1407  {
1408  return deserialize(reinterpret_cast<int64_t&>(ulonglong_t));
1409  }
1410 
1417  inline
1419  int64_t& longlong_t)
1420  {
1421  if ((last_position_ - current_position_) >= sizeof(longlong_t))
1422  {
1423  current_position_ >> longlong_t;
1424  current_position_ += sizeof(longlong_t);
1425 
1426  return *this;
1427  }
1428 
1430  }
1431 
1438  inline
1440  float& float_t)
1441  {
1442  if ((last_position_ - current_position_) >= sizeof(float_t))
1443  {
1444  current_position_ >> float_t;
1445  current_position_ += sizeof(float_t);
1446 
1447  return *this;
1448  }
1449 
1451  }
1452 
1459  inline
1461  double& double_t)
1462  {
1463  if ((last_position_ - current_position_) >= sizeof(double_t))
1464  {
1465  current_position_ >> double_t;
1466  current_position_ += sizeof(double_t);
1467 
1468  return *this;
1469  }
1470 
1472  }
1473 
1480  inline
1482  long double& ldouble_t)
1483  {
1484  if ((last_position_ - current_position_) >= sizeof(ldouble_t))
1485  {
1486  current_position_ >> ldouble_t;
1487  current_position_ += sizeof(ldouble_t);
1488 #if defined(_WIN32)
1489  current_position_ += sizeof(ldouble_t);
1490 #endif // if defined(_WIN32)
1491 
1492  return *this;
1493  }
1494 
1496  }
1497 
1506  bool& bool_t);
1507 
1518  char*& string_t);
1519 
1530  wchar_t*& string_t);
1531 
1538  inline
1540  std::string& string_t)
1541  {
1542  uint32_t length = 0;
1543  const char* str = read_string(length);
1544  string_t = std::string(str, length);
1545  return *this;
1546  }
1547 
1554  inline
1556  std::wstring& string_t)
1557  {
1558  uint32_t length = 0;
1559  string_t = read_wstring(length);
1560  return *this;
1561  }
1562 
1569  template<class _T, size_t _Size>
1571  std::array<_T, _Size>& array_t)
1572  {
1573  return deserialize_array(array_t.data(), array_t.size());
1574  }
1575 
1582  template<class _T = bool>
1584  std::vector<bool>& vector_t)
1585  {
1586  return deserialize_bool_sequence(vector_t);
1587  }
1588 
1595  template<class _T>
1597  std::vector<_T>& vector_t)
1598  {
1599  uint32_t sequence_length = 0;
1600  state state_before_error(*this);
1601 
1602  *this >> sequence_length;
1603 
1604  try
1605  {
1606  vector_t.resize(sequence_length);
1607  return deserialize_array(vector_t.data(), vector_t.size());
1608  }
1610  {
1611  set_state(state_before_error);
1612  ex.raise();
1613  }
1614 
1615  return *this;
1616  }
1617 
1618 #ifdef _MSC_VER
1619 
1625  template<>
1626  FastCdr& deserialize<bool>(
1627  std::vector<bool>& vector_t)
1628  {
1629  return deserialize_bool_sequence(vector_t);
1630  }
1631 
1632 #endif // ifdef _MSC_VER
1633 
1640  template<class _T>
1642  _T& type_t)
1643  {
1644  type_t.deserialize(*this);
1645  return *this;
1646  }
1647 
1655  inline
1657  uint8_t* octet_t,
1658  size_t num_elements)
1659  {
1660  return deserialize_array(reinterpret_cast<char*>(octet_t), num_elements);
1661  }
1662 
1670  FastCdr& deserialize_array(
1671  char* char_t,
1672  size_t num_elements);
1673 
1681  inline
1683  int8_t* int8,
1684  size_t num_elements)
1685  {
1686  return deserialize_array(reinterpret_cast<char*>(int8), num_elements);
1687  }
1688 
1696  inline
1698  uint16_t* ushort_t,
1699  size_t num_elements)
1700  {
1701  return deserialize_array(reinterpret_cast<int16_t*>(ushort_t), num_elements);
1702  }
1703 
1711  FastCdr& deserialize_array(
1712  int16_t* short_t,
1713  size_t num_elements);
1714 
1722  inline
1724  uint32_t* ulong_t,
1725  size_t num_elements)
1726  {
1727  return deserialize_array(reinterpret_cast<int32_t*>(ulong_t), num_elements);
1728  }
1729 
1737  FastCdr& deserialize_array(
1738  int32_t* long_t,
1739  size_t num_elements);
1740 
1748  FastCdr& deserialize_array(
1749  wchar_t* wchar,
1750  size_t num_elements);
1751 
1759  inline
1761  uint64_t* ulonglong_t,
1762  size_t num_elements)
1763  {
1764  return deserialize_array(reinterpret_cast<int64_t*>(ulonglong_t), num_elements);
1765  }
1766 
1774  FastCdr& deserialize_array(
1775  int64_t* longlong_t,
1776  size_t num_elements);
1777 
1785  FastCdr& deserialize_array(
1786  float* float_t,
1787  size_t num_elements);
1788 
1796  FastCdr& deserialize_array(
1797  double* double_t,
1798  size_t num_elements);
1799 
1807  FastCdr& deserialize_array(
1808  long double* ldouble_t,
1809  size_t num_elements);
1810 
1818  FastCdr& deserialize_array(
1819  bool* bool_t,
1820  size_t num_elements);
1821 
1829  inline
1831  std::string* string_t,
1832  size_t num_elements)
1833  {
1834  for (size_t count = 0; count < num_elements; ++count)
1835  {
1836  deserialize(string_t[count]);
1837  }
1838  return *this;
1839  }
1840 
1848  inline
1850  std::wstring* string_t,
1851  size_t num_elements)
1852  {
1853  for (size_t count = 0; count < num_elements; ++count)
1854  {
1855  deserialize(string_t[count]);
1856  }
1857  return *this;
1858  }
1859 
1867  template<class _T>
1869  std::vector<_T>* vector_t,
1870  size_t num_elements)
1871  {
1872  for (size_t count = 0; count < num_elements; ++count)
1873  {
1874  deserialize(vector_t[count]);
1875  }
1876  return *this;
1877  }
1878 
1886  template<class _T>
1888  _T* type_t,
1889  size_t num_elements)
1890  {
1891  for (size_t count = 0; count < num_elements; ++count)
1892  {
1893  type_t[count].deserialize(*this);
1894  }
1895  return *this;
1896  }
1897 
1907  template<class _T = std::string>
1909  std::string*& sequence_t,
1910  size_t& num_elements)
1911  {
1912  return deserialize_string_sequence(sequence_t, num_elements);
1913  }
1914 
1924  template<class _T = std::wstring>
1926  std::wstring*& sequence_t,
1927  size_t& num_elements)
1928  {
1929  return deserialize_wstring_sequence(sequence_t, num_elements);
1930  }
1931 
1941  template<class _T>
1943  _T*& sequence_t,
1944  size_t& num_elements)
1945  {
1946  uint32_t sequence_length = 0;
1947  state state_before_error(*this);
1948 
1949  deserialize(sequence_length);
1950 
1951  try
1952  {
1953  sequence_t = reinterpret_cast<_T*>(calloc(sequence_length, sizeof(_T)));
1954  deserialize_array(sequence_t, sequence_length);
1955  }
1957  {
1958  free(sequence_t);
1959  sequence_t = NULL;
1960  set_state(state_before_error);
1961  ex.raise();
1962  }
1963 
1964  num_elements = sequence_length;
1965  return *this;
1966  }
1967 
1968 #ifdef _MSC_VER
1969 
1978  template<>
1979  FastCdr& deserialize_sequence<std::string>(
1980  std::string*& sequence_t,
1981  size_t& num_elements)
1982  {
1983  return deserialize_string_sequence(sequence_t, num_elements);
1984  }
1985 
1995  template<>
1996  FastCdr& deserialize_sequence<std::wstring>(
1997  std::wstring*& sequence_t,
1998  size_t& num_elements)
1999  {
2000  return deserialize_wstring_sequence(sequence_t, num_elements);
2001  }
2002 
2003 #endif // ifdef _MSC_VER
2004 
2005 private:
2006 
2007  FastCdr(
2008  const FastCdr&) = delete;
2009 
2010  FastCdr& operator =(
2011  const FastCdr&) = delete;
2012 
2013  FastCdr& serialize_bool_sequence(
2014  const std::vector<bool>& vector_t);
2015 
2016  FastCdr& deserialize_bool_sequence(
2017  std::vector<bool>& vector_t);
2018 
2019  FastCdr& deserialize_string_sequence(
2020  std::string*& sequence_t,
2021  size_t& num_elements);
2022 
2023  FastCdr& deserialize_wstring_sequence(
2024  std::wstring*& sequence_t,
2025  size_t& num_elements);
2026 
2034  template<class _T, size_t _Size>
2036  const std::array<_T, _Size>* array_t,
2037  size_t num_elements)
2038  {
2039  return serialize_array(array_t->data(), num_elements * array_t->size());
2040  }
2041 
2049  template<class _T, size_t _Size>
2051  std::array<_T, _Size>* array_t,
2052  size_t num_elements)
2053  {
2054  return deserialize_array(array_t->data(), num_elements * array_t->size());
2055  }
2056 
2057  bool resize(
2058  size_t min_size_inc);
2059 
2060  const char* read_string(
2061  uint32_t& length);
2062 
2063  std::wstring read_wstring(
2064  uint32_t& length);
2065 
2068 
2071 
2074 };
2075 } //namespace fastcdr
2076 } //namespace eprosima
2077 
2078 #endif //_FASTCDR_FASTCDR_H_
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const uint8_t octet_t)
This function serializes an octet.
Definition: FastCdr.h:634
eprosima::fastcdr::FastCdr::deserialize_array
FastCdr & deserialize_array(std::string *string_t, size_t num_elements)
This function deserializes an array of strings.
Definition: FastCdr.h:1830
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(int64_t &longlong_t)
This function deserializes a long long.
Definition: FastCdr.h:1418
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(int8_t &int8)
This function deserializes an int8_t.
Definition: FastCdr.h:1308
eprosima::fastcdr::FastCdr::serialize_array
FastCdr & serialize_array(const std::vector< _T > *vector_t, size_t num_elements)
This function template serializes an array of sequences.
Definition: FastCdr.h:1210
NotEnoughMemoryException.h
get_current_position
#define get_current_position()
Definition: deserializer.cpp:7
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(std::vector< bool > &vector_t)
This function template deserializes a sequence of booleans.
Definition: FastCdr.h:1583
detail::state
state
Definition: core.h:2305
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(std::wstring &string_t)
This function deserializes a std::wstring.
Definition: FastCdr.h:1555
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(float &float_t)
This function deserializes a float.
Definition: FastCdr.h:1439
eprosima::fastcdr::FastCdr::current_position_
FastBuffer::iterator current_position_
The current position in the serialization/deserialization process.
Definition: FastCdr.h:2070
eprosima::fastcdr::FastCdr
This class offers an interface to serialize/deserialize some basic types using a modified CDR protoco...
Definition: FastCdr.h:40
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const long double ldouble_t)
This function serializes a long double.
Definition: FastCdr.h:836
FastBuffer.h
eprosima::fastcdr::FastCdr::deserialize_array
FastCdr & deserialize_array(uint64_t *ulonglong_t, size_t num_elements)
This function deserializes an array of unsigned long longs.
Definition: FastCdr.h:1760
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(long double &ldouble_t)
This function deserializes a long double.
Definition: FastCdr.h:1481
eprosima::fastcdr::FastCdr::serialize_array
FastCdr & serialize_array(const uint64_t *ulonglong_t, size_t num_elements)
This function serializes an array of unsigned long longs.
Definition: FastCdr.h:1102
eprosima::fastcdr::FastCdr::deserialize_array
FastCdr & deserialize_array(_T *type_t, size_t num_elements)
This function template deserializes an array of non-basic type objects.
Definition: FastCdr.h:1887
eprosima::fastcdr::FastCdr::serialize_array
FastCdr & serialize_array(const uint32_t *ulong_t, size_t num_elements)
This function serializes an array of unsigned longs.
Definition: FastCdr.h:1065
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const double double_t)
This function serializes a double.
Definition: FastCdr.h:815
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const std::string &string_t)
This function serializes a std::string.
Definition: FastCdr.h:888
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const std::vector< bool > &vector_t)
This function template serializes a sequence of booleans.
Definition: FastCdr.h:927
eprosima::fastcdr::FastCdr::state
This class stores the current state of a CDR serialization.
Definition: FastCdr.h:47
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const uint64_t ulonglong_t)
This function serializes an unsigned long long.
Definition: FastCdr.h:760
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const int32_t long_t)
This function serializes a long.
Definition: FastCdr.h:726
eprosima::fastcdr::FastCdr::serialize_array
FastCdr & serialize_array(const std::string *string_t, size_t num_elements)
This function serializes an array of strings.
Definition: FastCdr.h:1172
eprosima::fastcdr::deserialize
void deserialize(Cdr &, _T &)
read_string
static void read_string(LexState *ls, int del, SemInfo *seminfo)
Definition: llex.c:382
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(std::string &string_t)
This function deserializes a std::string.
Definition: FastCdr.h:1539
eprosima::fastcdr::FastCdr::deserialize_array
FastCdr & deserialize_array(uint8_t *octet_t, size_t num_elements)
This function deserializes an array of octets.
Definition: FastCdr.h:1656
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(double &double_t)
This function deserializes a double.
Definition: FastCdr.h:1460
eprosima::fastcdr::FastCdr::serialize_array
FastCdr & serialize_array(const uint8_t *octet_t, size_t num_elements)
This function serializes an array of octets.
Definition: FastCdr.h:998
eprosima::fastcdr::FastCdr::deserialize_array
FastCdr & deserialize_array(uint16_t *ushort_t, size_t num_elements)
This function deserializes an array of unsigned shorts.
Definition: FastCdr.h:1697
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(std::array< _T, _Size > &array_t)
This function template deserializes an array.
Definition: FastCdr.h:1570
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const std::array< _T, _Size > &array_t)
This function template serializes an array.
Definition: FastCdr.h:914
eprosima::fastcdr::FastCdr::deserialize_array
FastCdr & deserialize_array(int8_t *int8, size_t num_elements)
This function deserializes an array of int8_t.
Definition: FastCdr.h:1682
eprosima::fastcdr::FastCdr::serialize_array
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.
Definition: FastCdr.h:2035
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const int64_t longlong_t)
This function serializes a long long.
Definition: FastCdr.h:773
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(uint8_t &octet_t)
This function deserializes an octet.
Definition: FastCdr.h:1276
detail::count
constexpr auto count() -> size_t
Definition: core.h:1222
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(uint64_t &ulonglong_t)
This function deserializes an unsigned long long.
Definition: FastCdr.h:1405
eprosima::fastcdr::FastCdr::serialize_array
FastCdr & serialize_array(const _T *type_t, size_t num_elements)
This function template serializes an array of non-basic type objects.
Definition: FastCdr.h:1229
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const uint16_t ushort_t)
This function serializes an unsigned short.
Definition: FastCdr.h:679
eprosima::fastcdr::FastCdr::serialize_sequence
FastCdr & serialize_sequence(const _T *sequence_t, size_t num_elements)
This function template serializes a raw sequence.
Definition: FastCdr.h:1248
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(std::vector< _T > &vector_t)
This function template deserializes a sequence.
Definition: FastCdr.h:1596
eprosima::fastcdr::FastCdr::deserialize_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...
Definition: FastCdr.h:1925
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const std::vector< _T > &vector_t)
This function template serializes a sequence.
Definition: FastCdr.h:940
eprosima::fastcdr::FastCdr::serialize_array
FastCdr & serialize_array(const int8_t *int8, size_t num_elements)
This function serializes an array of int8_t.
Definition: FastCdr.h:1024
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const uint32_t ulong_t)
This function serializes an unsigned long.
Definition: FastCdr.h:713
eprosima::fastcdr::serialize
void serialize(Cdr &, const _T &)
eprosima::fastcdr::FastCdr::deserialize_array
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...
Definition: FastCdr.h:2050
eprosima::fastcdr::FastCdr::deserialize_array
FastCdr & deserialize_array(uint32_t *ulong_t, size_t num_elements)
This function deserializes an array of unsigned longs.
Definition: FastCdr.h:1723
eprosima::fastcdr::exception::Exception
This abstract class is used to create exceptions.
Definition: Exception.h:29
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(uint32_t &ulong_t)
This function deserializes an unsigned long.
Definition: FastCdr.h:1355
eprosima::fastcdr::FastCdr::state::current_position_
const FastBuffer::iterator current_position_
The position in the buffer when the state was created.
Definition: FastCdr.h:71
backward::Color::reset
@ reset
Definition: backward.hpp:3678
eprosima::fastcdr::FastCdr::deserialize_sequence
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...
Definition: FastCdr.h:1908
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const float float_t)
This function serializes a float.
Definition: FastCdr.h:794
Cdr_DllAPI
#define Cdr_DllAPI
Definition: fastcdr_dll.h:51
eprosima::fastcdr::FastCdr::deserialize_array
FastCdr & deserialize_array(std::vector< _T > *vector_t, size_t num_elements)
This function template deserializes an array of sequences.
Definition: FastCdr.h:1868
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const _T &type_t)
This function template serializes a non-basic type.
Definition: FastCdr.h:983
fastcdr_dll.h
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::FastCdr::cdr_buffer_
FastBuffer & cdr_buffer_
Reference to the buffer that will be serialized/deserialized.
Definition: FastCdr.h:2067
eprosima::fastcdr::FastCdr::deserialize_sequence
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...
Definition: FastCdr.h:1942
mcap::internal::operator<<
std::ostream & operator<<(std::ostream &out, const Interval< Scalar, Value > &i)
Definition: intervaltree.hpp:37
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const int8_t int8)
This function serializes an int8_t.
Definition: FastCdr.h:666
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(_T &type_t)
This function template deserializes a non-basic type object.
Definition: FastCdr.h:1641
eprosima::fastcdr::exception::Exception::raise
virtual Cdr_DllAPI void raise() const =0
This function throws the object as exception.
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(int16_t &short_t)
This function deserializes a short.
Definition: FastCdr.h:1334
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const std::wstring &string_t)
This function serializes a std::wstring.
Definition: FastCdr.h:901
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const int16_t short_t)
This function serializes a short.
Definition: FastCdr.h:692
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(wchar_t &wchar)
This function deserializes a wide-char.
Definition: FastCdr.h:1389
eprosima::fastcdr::FastCdr::get_serialized_data_length
size_t get_serialized_data_length() const
This function returns the length of the serialized data inside the stream.
Definition: FastCdr.h:105
eprosima::fastcdr::FastCdr::last_position_
FastBuffer::iterator last_position_
The last position in the buffer;.
Definition: FastCdr.h:2073
eprosima::fastcdr::FastBuffer
This class represents a stream of bytes that contains (or will contain) serialized data....
Definition: FastBuffer.h:243
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const wchar_t wchar)
This function serializes a wide-char.
Definition: FastCdr.h:747
eprosima::fastcdr::FastCdr::deserialize_array
FastCdr & deserialize_array(std::wstring *string_t, size_t num_elements)
This function deserializes an array of wide-strings.
Definition: FastCdr.h:1849
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(int32_t &long_t)
This function deserializes a long.
Definition: FastCdr.h:1368
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(uint16_t &ushort_t)
This function deserializes an unsigned short.
Definition: FastCdr.h:1321
eprosima
Definition: fixed_size_string.hpp:32
eprosima::fastcdr::FastCdr::serialize
FastCdr & serialize(const char char_t)
This function serializes a character.
Definition: FastCdr.h:647
char_t
typename detail::char_t_impl< S >::type char_t
Definition: core.h:664
eprosima::fastcdr::FastCdr::deserialize
FastCdr & deserialize(char &char_t)
This function deserializes a character.
Definition: FastCdr.h:1289
mqtt_test.ret
ret
Definition: mqtt_test.py:30
eprosima::fastcdr::FastCdr::serialize_array
FastCdr & serialize_array(const uint16_t *ushort_t, size_t num_elements)
This function serializes an array of unsigned shorts.
Definition: FastCdr.h:1039
eprosima::fastcdr::FastCdr::serialize_array
FastCdr & serialize_array(const std::wstring *string_t, size_t num_elements)
This function serializes an array of wstrings.
Definition: FastCdr.h:1191
eprosima::fastcdr::_FastBuffer_iterator
This class implements the iterator used to go through a FastBuffer.
Definition: FastBuffer.h:42
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


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