Fast CDR  Version 1.1.1
Fast CDR
FastCdr.h
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"
20 #include "exceptions/NotEnoughMemoryException.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 {
40 class Cdr_DllAPI FastCdr
41 {
42 public:
43 
47  class Cdr_DllAPI state
48  {
49  friend class FastCdr;
50 
51  public:
52 
57  const FastCdr& fastcdr);
58 
63  const state&);
64 
65  private:
66 
67  state& operator =(
68  const state&) = delete;
69 
71  const FastBuffer::iterator m_currentPosition;
72  };
80  FastBuffer& cdrBuffer);
81 
87  bool jump(
88  size_t numBytes);
89 
93  void reset();
94 
100 
105  inline size_t getSerializedDataLength() const
106  {
107  return m_currentPosition - m_cdrBuffer.begin();
108  }
109 
115 
120  void setState(
122 
129  inline FastCdr& operator <<(
130  const uint8_t octet_t)
131  {
132  return serialize(octet_t);
133  }
134 
141  inline FastCdr& operator <<(
142  const char char_t)
143  {
144  return serialize(char_t);
145  }
146 
153  inline FastCdr& operator <<(
154  const int8_t int8)
155  {
156  return serialize(int8);
157  }
158 
165  inline FastCdr& operator <<(
166  const uint16_t ushort_t)
167  {
168  return serialize(ushort_t);
169  }
170 
177  inline FastCdr& operator <<(
178  const int16_t short_t)
179  {
180  return serialize(short_t);
181  }
182 
189  inline FastCdr& operator <<(
190  const uint32_t ulong_t)
191  {
192  return serialize(ulong_t);
193  }
194 
201  inline FastCdr& operator <<(
202  const int32_t long_t)
203  {
204  return serialize(long_t);
205  }
206 
213  inline FastCdr& operator <<(
214  const wchar_t wchar)
215  {
216  return serialize(wchar);
217  }
218 
225  inline FastCdr& operator <<(
226  const uint64_t ulonglong_t)
227  {
228  return serialize(ulonglong_t);
229  }
230 
237  inline FastCdr& operator <<(
238  const int64_t longlong_t)
239  {
240  return serialize(longlong_t);
241  }
242 
249  inline FastCdr& operator <<(
250  const float float_t)
251  {
252  return serialize(float_t);
253  }
254 
261  inline FastCdr& operator <<(
262  const double double_t)
263  {
264  return serialize(double_t);
265  }
266 
273  inline FastCdr& operator <<(
274  const long double ldouble_t)
275  {
276  return serialize(ldouble_t);
277  }
278 
285  inline FastCdr& operator <<(
286  const bool bool_t)
287  {
288  return serialize(bool_t);
289  }
290 
297  inline FastCdr& operator <<(
298  const char* string_t)
299  {
300  return serialize(string_t);
301  }
302 
309  inline FastCdr& operator <<(
310  const wchar_t* string_t)
311  {
312  return serialize(string_t);
313  }
314 
321  inline FastCdr& operator <<(
322  const std::string& string_t)
323  {
324  return serialize(string_t);
325  }
326 
333  inline FastCdr& operator <<(
334  const std::wstring& string_t)
335  {
336  return serialize(string_t);
337  }
338 
345  template<class _T, size_t _Size>
346  inline FastCdr& operator <<(
347  const std::array<_T, _Size>& array_t)
348  {
349  return serialize<_T, _Size>(array_t);
350  }
351 
358  template<class _T>
359  inline FastCdr& operator <<(
360  const std::vector<_T>& vector_t)
361  {
362  return serialize<_T>(vector_t);
363  }
364 
371  template<class _T>
372  inline FastCdr& operator <<(
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 (((m_lastPosition - m_currentPosition) >= sizeof(char_t)) || resize(sizeof(char_t)))
651  {
652  m_currentPosition++ << 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 (((m_lastPosition - m_currentPosition) >= sizeof(short_t)) || resize(sizeof(short_t)))
696  {
697  m_currentPosition << short_t;
698  m_currentPosition += 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 (((m_lastPosition - m_currentPosition) >= sizeof(long_t)) || resize(sizeof(long_t)))
730  {
731  m_currentPosition << long_t;
732  m_currentPosition += 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 (((m_lastPosition - m_currentPosition) >= sizeof(longlong_t)) || resize(sizeof(longlong_t)))
777  {
778  m_currentPosition << longlong_t;
779  m_currentPosition += sizeof(longlong_t);
780 
781  return *this;
782  }
783 
785  }
786 
793  inline
795  const float float_t)
796  {
797  if (((m_lastPosition - m_currentPosition) >= sizeof(float_t)) || resize(sizeof(float_t)))
798  {
799  m_currentPosition << float_t;
800  m_currentPosition += sizeof(float_t);
801 
802  return *this;
803  }
804 
806  }
807 
814  inline
816  const double double_t)
817  {
818  if (((m_lastPosition - m_currentPosition) >= sizeof(double_t)) || resize(sizeof(double_t)))
819  {
820  m_currentPosition << double_t;
821  m_currentPosition += sizeof(double_t);
822 
823  return *this;
824  }
825 
827  }
828 
835  inline
837  const long double ldouble_t)
838  {
839  if (((m_lastPosition - m_currentPosition) >= sizeof(ldouble_t)) || resize(sizeof(ldouble_t)))
840  {
841  m_currentPosition << ldouble_t;
842 #if defined(_WIN32)
843  m_currentPosition += sizeof(ldouble_t);
844  m_currentPosition << static_cast<long double>(0);
845 #endif // if defined(_WIN32)
846  m_currentPosition += 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 serializeArray(array_t.data(), array_t.size());
918  }
919 
926  template<class _T = bool>
928  const std::vector<bool>& vector_t)
929  {
930  return serializeBoolSequence(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 serializeArray(vector_t.data(), vector_t.size());
950  }
952  {
953  setState(state_before_error);
954  ex.raise();
955  }
956 
957  return *this;
958  }
959 
960 #ifdef _MSC_VER
967  template<>
968  FastCdr& serialize<bool>(
969  const std::vector<bool>& vector_t)
970  {
971  return serializeBoolSequence(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 numElements)
1001  {
1002  return serializeArray(reinterpret_cast<const char*>(octet_t), numElements);
1003  }
1004 
1013  const char* char_t,
1014  size_t numElements);
1015 
1023  inline
1025  const int8_t* int8,
1026  size_t numElements)
1027  {
1028  return serializeArray(reinterpret_cast<const char*>(int8), numElements);
1029  }
1030 
1038  inline
1040  const uint16_t* ushort_t,
1041  size_t numElements)
1042  {
1043  return serializeArray(reinterpret_cast<const int16_t*>(ushort_t), numElements);
1044  }
1045 
1054  const int16_t* short_t,
1055  size_t numElements);
1056 
1064  inline
1066  const uint32_t* ulong_t,
1067  size_t numElements)
1068  {
1069  return serializeArray(reinterpret_cast<const int32_t*>(ulong_t), numElements);
1070  }
1071 
1080  const int32_t* long_t,
1081  size_t numElements);
1082 
1091  const wchar_t* wchar,
1092  size_t numElements);
1093 
1101  inline
1103  const uint64_t* ulonglong_t,
1104  size_t numElements)
1105  {
1106  return serializeArray(reinterpret_cast<const int64_t*>(ulonglong_t), numElements);
1107  }
1108 
1117  const int64_t* longlong_t,
1118  size_t numElements);
1119 
1128  const float* float_t,
1129  size_t numElements);
1130 
1139  const double* double_t,
1140  size_t numElements);
1141 
1150  const long double* ldouble_t,
1151  size_t numElements);
1152 
1161  const bool* bool_t,
1162  size_t numElements);
1163 
1171  inline
1173  const std::string* string_t,
1174  size_t numElements)
1175  {
1176  for (size_t count = 0; count < numElements; ++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 numElements)
1194  {
1195  for (size_t count = 0; count < numElements; ++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 numElements)
1213  {
1214  for (size_t count = 0; count < numElements; ++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 numElements)
1232  {
1233  for (size_t count = 0; count < numElements; ++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 numElements)
1251  {
1252  state state_before_error(*this);
1253 
1254  serialize(static_cast<int32_t>(numElements));
1255 
1256  try
1257  {
1258  return serializeArray(sequence_t, numElements);
1259  }
1261  {
1262  setState(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 ((m_lastPosition - m_currentPosition) >= sizeof(char_t))
1293  {
1294  m_currentPosition++ >> 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 ((m_lastPosition - m_currentPosition) >= sizeof(short_t))
1338  {
1339  m_currentPosition >> short_t;
1340  m_currentPosition += 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 ((m_lastPosition - m_currentPosition) >= sizeof(long_t))
1372  {
1373  m_currentPosition >> long_t;
1374  m_currentPosition += 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 ((m_lastPosition - m_currentPosition) >= sizeof(longlong_t))
1422  {
1423  m_currentPosition >> longlong_t;
1424  m_currentPosition += sizeof(longlong_t);
1425 
1426  return *this;
1427  }
1428 
1430  }
1431 
1438  inline
1440  float& float_t)
1441  {
1442  if ((m_lastPosition - m_currentPosition) >= sizeof(float_t))
1443  {
1444  m_currentPosition >> float_t;
1445  m_currentPosition += sizeof(float_t);
1446 
1447  return *this;
1448  }
1449 
1451  }
1452 
1459  inline
1461  double& double_t)
1462  {
1463  if ((m_lastPosition - m_currentPosition) >= sizeof(double_t))
1464  {
1465  m_currentPosition >> double_t;
1466  m_currentPosition += sizeof(double_t);
1467 
1468  return *this;
1469  }
1470 
1472  }
1473 
1480  inline
1482  long double& ldouble_t)
1483  {
1484  if ((m_lastPosition - m_currentPosition) >= sizeof(ldouble_t))
1485  {
1486  m_currentPosition >> ldouble_t;
1487  m_currentPosition += sizeof(ldouble_t);
1488 #if defined(_WIN32)
1489  m_currentPosition += 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 = readString(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 = readWString(length);
1560  return *this;
1561  }
1562 
1569  template<class _T, size_t _Size>
1571  std::array<_T, _Size>& array_t)
1572  {
1573  return deserializeArray(array_t.data(), array_t.size());
1574  }
1575 
1582  template<class _T = bool>
1584  std::vector<bool>& vector_t)
1585  {
1586  return deserializeBoolSequence(vector_t);
1587  }
1588 
1595  template<class _T>
1597  std::vector<_T>& vector_t)
1598  {
1599  uint32_t seqLength = 0;
1600  state state_before_error(*this);
1601 
1602  *this >> seqLength;
1603 
1604  try
1605  {
1606  vector_t.resize(seqLength);
1607  return deserializeArray(vector_t.data(), vector_t.size());
1608  }
1610  {
1611  setState(state_before_error);
1612  ex.raise();
1613  }
1614 
1615  return *this;
1616  }
1617 
1618 #ifdef _MSC_VER
1625  template<>
1626  FastCdr& deserialize<bool>(
1627  std::vector<bool>& vector_t)
1628  {
1629  return deserializeBoolSequence(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 numElements)
1659  {
1660  return deserializeArray(reinterpret_cast<char*>(octet_t), numElements);
1661  }
1662 
1671  char* char_t,
1672  size_t numElements);
1673 
1681  inline
1683  int8_t* int8,
1684  size_t numElements)
1685  {
1686  return deserializeArray(reinterpret_cast<char*>(int8), numElements);
1687  }
1688 
1696  inline
1698  uint16_t* ushort_t,
1699  size_t numElements)
1700  {
1701  return deserializeArray(reinterpret_cast<int16_t*>(ushort_t), numElements);
1702  }
1703 
1712  int16_t* short_t,
1713  size_t numElements);
1714 
1722  inline
1724  uint32_t* ulong_t,
1725  size_t numElements)
1726  {
1727  return deserializeArray(reinterpret_cast<int32_t*>(ulong_t), numElements);
1728  }
1729 
1738  int32_t* long_t,
1739  size_t numElements);
1740 
1749  wchar_t* wchar,
1750  size_t numElements);
1751 
1759  inline
1761  uint64_t* ulonglong_t,
1762  size_t numElements)
1763  {
1764  return deserializeArray(reinterpret_cast<int64_t*>(ulonglong_t), numElements);
1765  }
1766 
1775  int64_t* longlong_t,
1776  size_t numElements);
1777 
1786  float* float_t,
1787  size_t numElements);
1788 
1797  double* double_t,
1798  size_t numElements);
1799 
1808  long double* ldouble_t,
1809  size_t numElements);
1810 
1819  bool* bool_t,
1820  size_t numElements);
1821 
1829  inline
1831  std::string* string_t,
1832  size_t numElements)
1833  {
1834  for (size_t count = 0; count < numElements; ++count)
1835  {
1836  deserialize(string_t[count]);
1837  }
1838  return *this;
1839  }
1840 
1848  inline
1850  std::wstring* string_t,
1851  size_t numElements)
1852  {
1853  for (size_t count = 0; count < numElements; ++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 numElements)
1871  {
1872  for (size_t count = 0; count < numElements; ++count)
1873  {
1874  deserialize(vector_t[count]);
1875  }
1876  return *this;
1877  }
1878 
1886  template<class _T>
1888  _T* type_t,
1889  size_t numElements)
1890  {
1891  for (size_t count = 0; count < numElements; ++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& numElements)
1911  {
1912  return deserializeStringSequence(sequence_t, numElements);
1913  }
1914 
1924  template<class _T = std::wstring>
1926  std::wstring*& sequence_t,
1927  size_t& numElements)
1928  {
1929  return deserializeWStringSequence(sequence_t, numElements);
1930  }
1931 
1941  template<class _T>
1943  _T*& sequence_t,
1944  size_t& numElements)
1945  {
1946  uint32_t seqLength = 0;
1947  state state_before_error(*this);
1948 
1949  deserialize(seqLength);
1950 
1951  try
1952  {
1953  sequence_t = reinterpret_cast<_T*>(calloc(seqLength, sizeof(_T)));
1954  deserializeArray(sequence_t, seqLength);
1955  }
1957  {
1958  free(sequence_t);
1959  sequence_t = NULL;
1960  setState(state_before_error);
1961  ex.raise();
1962  }
1963 
1964  numElements = seqLength;
1965  return *this;
1966  }
1967 
1968 #ifdef _MSC_VER
1978  template<>
1979  FastCdr& deserializeSequence<std::string>(
1980  std::string*& sequence_t,
1981  size_t& numElements)
1982  {
1983  return deserializeStringSequence(sequence_t, numElements);
1984  }
1985 
1995  template<>
1996  FastCdr& deserializeSequence<std::wstring>(
1997  std::wstring*& sequence_t,
1998  size_t& numElements)
1999  {
2000  return deserializeWStringSequence(sequence_t, numElements);
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& serializeBoolSequence(
2014  const std::vector<bool>& vector_t);
2015 
2016  FastCdr& deserializeBoolSequence(
2017  std::vector<bool>& vector_t);
2018 
2019  FastCdr& deserializeStringSequence(
2020  std::string*& sequence_t,
2021  size_t& numElements);
2022 
2023  FastCdr& deserializeWStringSequence(
2024  std::wstring*& sequence_t,
2025  size_t& numElements);
2026 
2034  template<class _T, size_t _Size>
2035  FastCdr& serializeArray(
2036  const std::array<_T, _Size>* array_t,
2037  size_t numElements)
2038  {
2039  return serializeArray(array_t->data(), numElements * array_t->size());
2040  }
2041 
2049  template<class _T, size_t _Size>
2050  FastCdr& deserializeArray(
2051  std::array<_T, _Size>* array_t,
2052  size_t numElements)
2053  {
2054  return deserializeArray(array_t->data(), numElements * array_t->size());
2055  }
2056 
2057  bool resize(
2058  size_t minSizeInc);
2059 
2060  const char* readString(
2061  uint32_t& length);
2062 
2063  std::wstring readWString(
2064  uint32_t& length);
2065 
2067  FastBuffer& m_cdrBuffer;
2068 
2070  FastBuffer::iterator m_currentPosition;
2071 
2073  FastBuffer::iterator m_lastPosition;
2074 };
2075 } //namespace fastcdr
2076 } //namespace eprosima
2077 
2078 #endif //_FASTCDR_FASTCDR_H_
This class implements the iterator used to go through a FastBuffer.
Definition: FastBuffer.h:43
This class represents a stream of bytes that contains (or will contain) serialized data.
Definition: FastBuffer.h:229
_FastBuffer_iterator iterator
Definition: FastBuffer.h:232
This class stores the current state of a CDR serialization.
Definition: FastCdr.h:48
state(const FastCdr &fastcdr)
Default constructor.
state(const state &)
Copy constructor.
This class offers an interface to serialize/deserialize some basic types using a modified CDR protoco...
Definition: FastCdr.h:41
FastCdr::state getState()
This function returns the current state of the CDR stream.
FastCdr & serializeArray(const double *double_t, size_t numElements)
This function serializes an array of doubles.
FastCdr & serializeSequence(const _T *sequence_t, size_t numElements)
This function template serializes a raw sequence.
Definition: FastCdr.h:1248
FastCdr & deserializeArray(int32_t *long_t, size_t numElements)
This function deserializes an array of longs.
FastCdr & serializeArray(const uint8_t *octet_t, size_t numElements)
This function serializes an array of octets.
Definition: FastCdr.h:998
FastCdr & deserialize(int32_t &long_t)
This function deserializes a long.
Definition: FastCdr.h:1368
FastCdr & serializeArray(const std::vector< _T > *vector_t, size_t numElements)
This function template serializes an array of sequences.
Definition: FastCdr.h:1210
FastCdr & serialize(const int16_t short_t)
This function serializes a short.
Definition: FastCdr.h:692
FastCdr & deserialize(uint8_t &octet_t)
This function deserializes an octet.
Definition: FastCdr.h:1276
FastCdr & deserialize(std::wstring &string_t)
This function deserializes a std::wstring.
Definition: FastCdr.h:1555
FastCdr & deserialize(int16_t &short_t)
This function deserializes a short.
Definition: FastCdr.h:1334
FastCdr & deserializeArray(uint8_t *octet_t, size_t numElements)
This function deserializes an array of octets.
Definition: FastCdr.h:1656
FastCdr & deserialize(wchar_t *&string_t)
This function deserializes a wide string.
FastCdr & serialize(const uint8_t octet_t)
This function serializes an octet.
Definition: FastCdr.h:634
FastCdr & serialize(const std::array< _T, _Size > &array_t)
This function template serializes an array.
Definition: FastCdr.h:914
FastCdr & serialize(const float float_t)
This function serializes a float.
Definition: FastCdr.h:794
FastCdr & serializeArray(const std::wstring *string_t, size_t numElements)
This function serializes an array of wstrings.
Definition: FastCdr.h:1191
FastCdr & deserialize(char *&string_t)
This function deserializes a string.
FastCdr & serialize(const uint64_t ulonglong_t)
This function serializes an unsigned long long.
Definition: FastCdr.h:760
FastCdr(FastBuffer &cdrBuffer)
This constructor creates a eprosima::fastcdr::FastCdr object that can serialize/deserialize the assig...
FastCdr & deserializeArray(std::string *string_t, size_t numElements)
This function deserializes an array of strings.
Definition: FastCdr.h:1830
FastCdr & serialize(const _T &type_t)
This function template serializes a non-basic type.
Definition: FastCdr.h:983
FastCdr & deserialize(std::string &string_t)
This function deserializes a std::string.
Definition: FastCdr.h:1539
FastCdr & deserialize(long double &ldouble_t)
This function deserializes a long double.
Definition: FastCdr.h:1481
size_t getSerializedDataLength() const
This function returns the length of the serialized data inside the stream.
Definition: FastCdr.h:105
FastCdr & deserialize(double &double_t)
This function deserializes a double.
Definition: FastCdr.h:1460
FastCdr & deserialize(char &char_t)
This function deserializes a character.
Definition: FastCdr.h:1289
FastCdr & serialize(const bool bool_t)
This function serializes a boolean.
FastCdr & deserializeArray(int64_t *longlong_t, size_t numElements)
This function deserializes an array of long longs.
FastCdr & serializeArray(const bool *bool_t, size_t numElements)
This function serializes an array of booleans.
FastCdr & deserialize(std::vector< bool > &vector_t)
This function template deserializes a sequence of booleans.
Definition: FastCdr.h:1583
FastCdr & serializeArray(const char *char_t, size_t numElements)
This function serializes an array of characters.
FastCdr & serializeArray(const float *float_t, size_t numElements)
This function serializes an array of floats.
FastCdr & deserializeArray(int8_t *int8, size_t numElements)
This function deserializes an array of int8_t.
Definition: FastCdr.h:1682
FastCdr & deserializeArray(std::vector< _T > *vector_t, size_t numElements)
This function template deserializes an array of sequences.
Definition: FastCdr.h:1868
FastCdr & deserialize(wchar_t &wchar)
This function deserializes a wide-char.
Definition: FastCdr.h:1389
FastCdr & deserializeArray(float *float_t, size_t numElements)
This function deserializes an array of floats.
FastCdr & serializeArray(const int32_t *long_t, size_t numElements)
This function serializes an array of longs.
FastCdr & deserializeArray(_T *type_t, size_t numElements)
This function template deserializes an array of non-basic type objects.
Definition: FastCdr.h:1887
FastCdr & deserializeArray(char *char_t, size_t numElements)
This function deserializes an array of characters.
FastCdr & serializeArray(const _T *type_t, size_t numElements)
This function template serializes an array of non-basic type objects.
Definition: FastCdr.h:1229
FastCdr & serializeArray(const wchar_t *wchar, size_t numElements)
This function serializes an array of wide-chars.
FastCdr & serialize(const long double ldouble_t)
This function serializes a long double.
Definition: FastCdr.h:836
FastCdr & deserializeSequence(std::wstring *&sequence_t, size_t &numElements)
This function template deserializes a wide-string sequence.
Definition: FastCdr.h:1925
FastCdr & deserialize(float &float_t)
This function deserializes a float.
Definition: FastCdr.h:1439
FastCdr & deserializeSequence(_T *&sequence_t, size_t &numElements)
This function template deserializes a raw sequence.
Definition: FastCdr.h:1942
FastCdr & serialize(const std::vector< _T > &vector_t)
This function template serializes a sequence.
Definition: FastCdr.h:940
FastCdr & serialize(const int8_t int8)
This function serializes an int8_t.
Definition: FastCdr.h:666
FastCdr & serializeArray(const int64_t *longlong_t, size_t numElements)
This function serializes an array of long longs.
FastCdr & deserializeArray(int16_t *short_t, size_t numElements)
This function deserializes an array of shorts.
FastCdr & serializeArray(const uint16_t *ushort_t, size_t numElements)
This function serializes an array of unsigned shorts.
Definition: FastCdr.h:1039
FastCdr & deserialize(bool &bool_t)
This function deserializes a boolean.
FastCdr & deserialize(std::vector< _T > &vector_t)
This function template deserializes a sequence.
Definition: FastCdr.h:1596
FastCdr & serialize(const wchar_t wchar)
This function serializes a wide-char.
Definition: FastCdr.h:747
FastCdr & deserialize(uint32_t &ulong_t)
This function deserializes an unsigned long.
Definition: FastCdr.h:1355
FastCdr & serialize(const uint16_t ushort_t)
This function serializes an unsigned short.
Definition: FastCdr.h:679
FastCdr & serializeArray(const long double *ldouble_t, size_t numElements)
This function serializes an array of long doubles.
FastCdr & deserialize(_T &type_t)
This function template deserializes a non-basic type object.
Definition: FastCdr.h:1641
FastCdr & serialize(const wchar_t *string_t)
This function serializes a wstring.
void setState(FastCdr::state &state)
This function sets a previous state of the CDR stream;.
FastCdr & serializeArray(const std::string *string_t, size_t numElements)
This function serializes an array of strings.
Definition: FastCdr.h:1172
FastCdr & deserializeArray(bool *bool_t, size_t numElements)
This function deserializes an array of booleans.
FastCdr & deserializeArray(double *double_t, size_t numElements)
This function deserializes an array of doubles.
FastCdr & deserialize(int64_t &longlong_t)
This function deserializes a long long.
Definition: FastCdr.h:1418
FastCdr & serialize(const uint32_t ulong_t)
This function serializes an unsigned long.
Definition: FastCdr.h:713
FastCdr & deserializeArray(uint16_t *ushort_t, size_t numElements)
This function deserializes an array of unsigned shorts.
Definition: FastCdr.h:1697
FastCdr & serialize(const std::vector< bool > &vector_t)
This function template serializes a sequence of booleans.
Definition: FastCdr.h:927
FastCdr & serialize(const int64_t longlong_t)
This function serializes a long long.
Definition: FastCdr.h:773
FastCdr & deserializeArray(wchar_t *wchar, size_t numElements)
This function deserializes an array of wide-chars.
FastCdr & serialize(const char *string_t)
This function serializes a string.
FastCdr & deserializeArray(std::wstring *string_t, size_t numElements)
This function deserializes an array of wide-strings.
Definition: FastCdr.h:1849
void reset()
This function resets the current position in the buffer to the begining.
FastCdr & serialize(const std::wstring &string_t)
This function serializes a std::wstring.
Definition: FastCdr.h:901
bool jump(size_t numBytes)
This function skips a number of bytes in the CDR stream buffer.
char * getCurrentPosition()
This function returns the current position in the CDR stream.
FastCdr & serializeArray(const uint64_t *ulonglong_t, size_t numElements)
This function serializes an array of unsigned long longs.
Definition: FastCdr.h:1102
FastCdr & serializeArray(const int8_t *int8, size_t numElements)
This function serializes an array of int8_t.
Definition: FastCdr.h:1024
FastCdr & deserialize(int8_t &int8)
This function deserializes an int8_t.
Definition: FastCdr.h:1308
FastCdr & deserialize(uint16_t &ushort_t)
This function deserializes an unsigned short.
Definition: FastCdr.h:1321
FastCdr & deserializeArray(long double *ldouble_t, size_t numElements)
This function deserializes an array of long doubles.
FastCdr & serialize(const int32_t long_t)
This function serializes a long.
Definition: FastCdr.h:726
FastCdr & deserializeArray(uint32_t *ulong_t, size_t numElements)
This function deserializes an array of unsigned longs.
Definition: FastCdr.h:1723
FastCdr & deserializeSequence(std::string *&sequence_t, size_t &numElements)
This function template deserializes a string sequence.
Definition: FastCdr.h:1908
FastCdr & serialize(const double double_t)
This function serializes a double.
Definition: FastCdr.h:815
FastCdr & serializeArray(const uint32_t *ulong_t, size_t numElements)
This function serializes an array of unsigned longs.
Definition: FastCdr.h:1065
FastCdr & serializeArray(const int16_t *short_t, size_t numElements)
This function serializes an array of shorts.
FastCdr & serialize(const std::string &string_t)
This function serializes a std::string.
Definition: FastCdr.h:888
FastCdr & deserialize(std::array< _T, _Size > &array_t)
This function template deserializes an array.
Definition: FastCdr.h:1570
FastCdr & deserializeArray(uint64_t *ulonglong_t, size_t numElements)
This function deserializes an array of unsigned long longs.
Definition: FastCdr.h:1760
FastCdr & deserialize(uint64_t &ulonglong_t)
This function deserializes an unsigned long long.
Definition: FastCdr.h:1405
FastCdr & serialize(const char char_t)
This function serializes a character.
Definition: FastCdr.h:647
This abstract class is used to create exceptions.
Definition: Exception.h:30
virtual Cdr_DllAPI void raise() const =0
This function throws the object as exception.
This class is thrown as an exception when the buffer's internal memory reachs its size limit.
Definition: NotEnoughMemoryException.h:28
static Cdr_DllAPI const char *const NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT
Default message used in the library.
Definition: NotEnoughMemoryException.h:78
Definition: Cdr.h:35