1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756 |
- // Copyright 2016 Proyectos y Sistemas de Mantenimiento SL (eProsima).
- //
- // Licensed under the Apache License, Version 2.0 (the "License");
- // you may not use this file except in compliance with the License.
- // You may obtain a copy of the License at
- //
- // http://www.apache.org/licenses/LICENSE-2.0
- //
- // Unless required by applicable law or agreed to in writing, software
- // distributed under the License is distributed on an "AS IS" BASIS,
- // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- // See the License for the specific language governing permissions and
- // limitations under the License.
- #ifndef _FASTCDR_FASTCDR_H_
- #define _FASTCDR_FASTCDR_H_
- #include "fastcdr_dll.h"
- #include "FastBuffer.h"
- #include "exceptions/NotEnoughMemoryException.h"
- #include <stdint.h>
- #include <string>
- #include <vector>
- #if !__APPLE__ && !__FreeBSD__ && !__VXWORKS__
- #include <malloc.h>
- #else
- #include <stdlib.h>
- #endif
- #if HAVE_CXX0X
- #include <array>
- #endif
- namespace eprosima
- {
- namespace fastcdr
- {
- /*!
- * @brief This class offers an interface to serialize/deserialize some basic types using a modified CDR protocol inside a eprosima::FastBuffer.
- * This modified CDR protocol provides a serialization mechanism much faster than common CDR protocol, because it doesn't use alignment.
- * @ingroup FASTCDRAPIREFERENCE
- */
- class Cdr_DllAPI FastCdr
- {
- public:
- /*!
- * @brief This class stores the current state of a CDR serialization.
- */
- class Cdr_DllAPI state
- {
- friend class FastCdr;
- public:
- /*!
- * @brief Default constructor.
- */
- state(const FastCdr &fastcdr);
- /*!
- * @brief Copy constructor.
- */
- state(const state&);
- private:
- state& operator=(const state&) = delete;
- //! @brief The position in the buffer when the state was created.
- const FastBuffer::iterator m_currentPosition;
- };
- /*!
- * @brief This constructor creates a eprosima::fastcdr::FastCdr object that can serialize/deserialize
- * the assigned buffer.
- *
- * @param cdrBuffer A reference to the buffer that contains (or will contain) the CDR representation.
- */
- FastCdr(FastBuffer &cdrBuffer);
- /*!
- * @brief This function skips a number of bytes in the CDR stream buffer.
- * @param numBytes The number of bytes that will be jumped.
- * @return True is returned when the jump operation works successfully. Otherwise, false is returned.
- */
- bool jump(size_t numBytes);
- /*!
- * @brief This function resets the current position in the buffer to the begining.
- */
- void reset();
- /*!
- * @brief This function returns the current position in the CDR stream.
- * @return Pointer to the current position in the buffer.
- */
- char* getCurrentPosition();
- /*!
- * @brief This function returns the length of the serialized data inside the stream.
- * @return The length of the serialized data.
- */
- inline size_t getSerializedDataLength() const { return m_currentPosition - m_cdrBuffer.begin();}
- /*!
- * @brief This function returns the current state of the CDR stream.
- * @return The current state of the buffer.
- */
- FastCdr::state getState();
- /*!
- * @brief This function sets a previous state of the CDR stream;
- * @param state Previous state that will be set again.
- */
- void setState(FastCdr::state &state);
- /*!
- * @brief This operator serializes an octet.
- * @param octet_t The value of the octet that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const uint8_t octet_t){return serialize(octet_t);}
- /*!
- * @brief This operator serializes a character.
- * @param char_t The value of the character that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const char char_t){return serialize(char_t);}
- /*!
- * @brief This operator serializes a int8_t.
- * @param int8 The value of the int8_t that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const int8_t int8){return serialize(int8);}
- /*!
- * @brief This operator serializes an unsigned short.
- * @param ushort_t The value of the unsigned short that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const uint16_t ushort_t){return serialize(ushort_t);}
- /*!
- * @brief This operator serializes a short.
- * @param short_t The value of the short that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const int16_t short_t){return serialize(short_t);}
- /*!
- * @brief This operator serializes an unsigned long.
- * @param ulong_t The value of the unsigned long that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const uint32_t ulong_t){return serialize(ulong_t);}
- /*!
- * @brief This operator serializes a long.
- * @param long_t The value of the long that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const int32_t long_t){return serialize(long_t);}
- /*!
- * @brief This operator serializes a wide-char.
- * @param wchar The value of the wide-char that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const wchar_t wchar){return serialize(wchar);}
- /*!
- * @brief This operator serializes an unsigned long long.
- * @param ulonglong_t The value of the unsigned long long that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const uint64_t ulonglong_t){return serialize(ulonglong_t);}
- /*!
- * @brief This operator serializes a long long.
- * @param longlong_t The value of the long long that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const int64_t longlong_t){return serialize(longlong_t);}
- /*!
- * @brief This operator serializes a float.
- * @param float_t The value of the float that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const float float_t){return serialize(float_t);}
- /*!
- * @brief This operator serializes a ldouble.
- * @param double_t The value of the double that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const double double_t){return serialize(double_t);}
- /*!
- * @brief This operator serializes a long double.
- * @param ldouble_t The value of the long double that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const long double ldouble_t){return serialize(ldouble_t);}
- /*!
- * @brief This operator serializes a boolean.
- * @param bool_t The value of the boolean that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const bool bool_t){return serialize(bool_t);}
- /*!
- * @brief This operator serializes a null-terminated string.
- * @param string_t The value of the string that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const char *string_t){return serialize(string_t);}
- /*!
- * @brief This operator serializes a null-terminated wide-string.
- * @param string_t The value of the wide-string that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const wchar_t *string_t){return serialize(string_t);}
- /*!
- * @brief This operator serializes a string.
- * @param string_t The string that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const std::string &string_t){return serialize(string_t);}
- /*!
- * @brief This operator serializes a wstring.
- * @param string_t The wstring that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator<<(const std::wstring &string_t){return serialize(string_t);}
- #if HAVE_CXX0X
- /*!
- * @brief This operator template is used to serialize arrays.
- * @param array_t The array that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- inline FastCdr& operator<<(const std::array<_T, _Size> &array_t){return serialize<_T, _Size>(array_t);}
- #endif
- /*!
- * @brief This operator template is used to serialize sequences.
- * @param vector_t The sequence that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- inline FastCdr& operator<<(const std::vector<_T> &vector_t){return serialize<_T>(vector_t);}
- /*!
- * @brief This operator template is used to serialize non-basic types.
- * @param type_t The object that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- inline FastCdr& operator<<(const _T &type_t)
- {
- type_t.serialize(*this);
- return *this;
- }
- /*!
- * @brief This operator deserializes an octet.
- * @param octet_t The variable that will store the octet read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(uint8_t &octet_t){return deserialize(octet_t);}
- /*!
- * @brief This operator deserializes a character.
- * @param char_t The variable that will store the character read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(char &char_t){return deserialize(char_t);}
- /*!
- * @brief This operator deserializes an int8_t.
- * @param int8 The variable that will store the int8_t read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(int8_t &int8){return deserialize(int8);}
- /*!
- * @brief This operator deserializes an unsigned short.
- * @param ushort_t The variable that will store the unsigned short read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(uint16_t &ushort_t){return deserialize(ushort_t);}
- /*!
- * @brief This operator deserializes a short.
- * @param short_t The variable that will store the short read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(int16_t &short_t){return deserialize(short_t);}
- /*!
- * @brief This operator deserializes an unsigned long.
- * @param ulong_t The variable that will store the unsigned long read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(uint32_t &ulong_t){return deserialize(ulong_t);}
- /*!
- * @brief This operator deserializes a long.
- * @param long_t The variable that will store the long read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(int32_t &long_t){return deserialize(long_t);}
- /*!
- * @brief This operator deserializes a wide-char.
- * @param wchar The variable that will store the wide-char read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(wchar_t &wchar){return deserialize(wchar);}
- /*!
- * @brief This operator deserializes an unsigned long long.
- * @param ulonglong_t The variable that will store the unsigned long long read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(uint64_t &ulonglong_t){return deserialize(ulonglong_t);}
- /*!
- * @brief This operator deserializes a long long.
- * @param longlong_t The variable that will store the long long read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(int64_t &longlong_t){return deserialize(longlong_t);}
- /*!
- * @brief This operator deserializes a float.
- * @param float_t The variable that will store the float read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(float &float_t){return deserialize(float_t);}
- /*!
- * @brief This operator deserializes a double.
- * @param double_t The variable that will store the double read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(double &double_t){return deserialize(double_t);}
- /*!
- * @brief This operator deserializes a long double.
- * @param ldouble_t The variable that will store the long double read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(long double &ldouble_t){return deserialize(ldouble_t);}
- /*!
- * @brief This operator deserializes a boolean.
- * @param bool_t The variable that will store the boolean read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- * @exception exception::BadParamException This exception is thrown when trying to deserialize in an invalid value.
- */
- inline FastCdr& operator>>(bool &bool_t){return deserialize(bool_t);}
- /*!
- * @brief This operator deserializes a null-terminated c-string.
- * @param string_t The variable that will store the c-string read from the buffer.
- * Please note that a newly allocated string will be returned.
- * The caller should free the returned pointer when appropiate.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- * @exception exception::BadParamException This exception is thrown when trying to deserialize an invalid value.
- */
- inline FastCdr& operator>>(char *&string_t){return deserialize(string_t);}
- /*!
- * @brief This operator deserializes a string.
- * @param string_t The variable that will store the string read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(std::string &string_t){return deserialize(string_t);}
- /*!
- * @brief This operator deserializes a wstring.
- * @param string_t The variable that will store the wstring read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline FastCdr& operator>>(std::wstring &string_t){return deserialize(string_t);}
- #if HAVE_CXX0X
- /*!
- * @brief This operator template is used to deserialize arrays.
- * @param array_t The variable that will store the array read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- inline FastCdr& operator>>(std::array<_T, _Size> &array_t){return deserialize<_T, _Size>(array_t);}
- #endif
- /*!
- * @brief This operator template is used to deserialize sequences.
- * @param vector_t The variable that will store the sequence read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- inline FastCdr& operator>>(std::vector<_T> &vector_t){return deserialize<_T>(vector_t);}
- /*!
- * @brief This operator template is used to deserialize non-basic types.
- * @param type_t The variable that will store the object read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- inline FastCdr& operator>>(_T &type_t)
- {
- type_t.deserialize(*this);
- return *this;
- }
- /*!
- * @brief This function serializes an octet.
- * @param octet_t The value of the octet that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const uint8_t octet_t)
- {
- return serialize(static_cast<char>(octet_t));
- }
- /*!
- * @brief This function serializes a character.
- * @param char_t The value of the character that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const char char_t)
- {
- if(((m_lastPosition - m_currentPosition) >= sizeof(char_t)) || resize(sizeof(char_t)))
- {
- m_currentPosition++ << char_t;
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function serializes an int8_t.
- * @param int8 The value of the int8_t that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const int8_t int8)
- {
- return serialize(static_cast<char>(int8));
- }
- /*!
- * @brief This function serializes an unsigned short.
- * @param ushort_t The value of the unsigned short that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const uint16_t ushort_t)
- {
- return serialize(static_cast<int16_t>(ushort_t));
- }
- /*!
- * @brief This function serializes a short.
- * @param short_t The value of the short that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const int16_t short_t)
- {
- if(((m_lastPosition - m_currentPosition) >= sizeof(short_t)) || resize(sizeof(short_t)))
- {
- m_currentPosition << short_t;
- m_currentPosition += sizeof(short_t);
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function serializes an unsigned long.
- * @param ulong_t The value of the unsigned long that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const uint32_t ulong_t)
- {
- return serialize(static_cast<int32_t>(ulong_t));
- }
- /*!
- * @brief This function serializes a long.
- * @param long_t The value of the long that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const int32_t long_t)
- {
- if(((m_lastPosition - m_currentPosition) >= sizeof(long_t)) || resize(sizeof(long_t)))
- {
- m_currentPosition << long_t;
- m_currentPosition += sizeof(long_t);
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function serializes a wide-char.
- * @param wchar The value of the wide-char that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const wchar_t wchar)
- {
- return serialize(static_cast<uint32_t>(wchar));
- }
- /*!
- * @brief This function serializes an unsigned long long.
- * @param ulonglong_t The value of the unsigned long long that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const uint64_t ulonglong_t)
- {
- return serialize(static_cast<int64_t>(ulonglong_t));
- }
- /*!
- * @brief This function serializes a long long.
- * @param longlong_t The value of the long long that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const int64_t longlong_t)
- {
- if(((m_lastPosition - m_currentPosition) >= sizeof(longlong_t)) || resize(sizeof(longlong_t)))
- {
- m_currentPosition << longlong_t;
- m_currentPosition += sizeof(longlong_t);
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function serializes a float.
- * @param float_t The value of the float that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const float float_t)
- {
- if(((m_lastPosition - m_currentPosition) >= sizeof(float_t)) || resize(sizeof(float_t)))
- {
- m_currentPosition << float_t;
- m_currentPosition += sizeof(float_t);
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function serializes a double.
- * @param double_t The value of the double that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const double double_t)
- {
- if(((m_lastPosition - m_currentPosition) >= sizeof(double_t)) || resize(sizeof(double_t)))
- {
- m_currentPosition << double_t;
- m_currentPosition += sizeof(double_t);
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function serializes a long double.
- * @param ldouble_t The value of the long double that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const long double ldouble_t)
- {
- if(((m_lastPosition - m_currentPosition) >= sizeof(ldouble_t)) || resize(sizeof(ldouble_t)))
- {
- m_currentPosition << ldouble_t;
- #if defined(_WIN32)
- m_currentPosition += sizeof(ldouble_t);
- m_currentPosition << static_cast<long double>(0);
- #endif
- m_currentPosition += sizeof(ldouble_t);
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function serializes a boolean.
- * @param bool_t The value of the boolean that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- FastCdr& serialize(const bool bool_t);
- /*!
- * @brief This function serializes a string.
- * @param string_t The pointer to the string that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- FastCdr& serialize(const char *string_t);
- /*!
- * @brief This function serializes a wstring.
- * @param string_t The pointer to the wstring that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- FastCdr& serialize(const wchar_t *string_t);
- /*!
- * @brief This function serializes a std::string.
- * @param string_t The string that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const std::string &string_t) {return serialize(string_t.c_str());}
- /*!
- * @brief This function serializes a std::wstring.
- * @param string_t The wstring that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serialize(const std::wstring &string_t) {return serialize(string_t.c_str());}
- #if HAVE_CXX0X
- /*!
- * @brief This function template serializes an array.
- * @param array_t The array that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- inline FastCdr& serialize(const std::array<_T, _Size> &array_t)
- { return serializeArray(array_t.data(), array_t.size());}
- #endif
- #if !defined(_MSC_VER) && HAVE_CXX0X
- /*!
- * @brief This function template serializes a sequence of booleans.
- * @param vector_t The sequence that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- template<class _T = bool>
- FastCdr& serialize(const std::vector<bool> &vector_t)
- {
- return serializeBoolSequence(vector_t);
- }
- #endif
- /*!
- * @brief This function template serializes a sequence.
- * @param vector_t The sequence that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- FastCdr& serialize(const std::vector<_T> &vector_t)
- {
- state state_before_error(*this);
- *this << static_cast<int32_t>(vector_t.size());
- try
- {
- return serializeArray(vector_t.data(), vector_t.size());
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- setState(state_before_error);
- ex.raise();
- }
- return *this;
- }
- #ifdef _MSC_VER
- /*!
- * @brief This function template serializes a sequence of booleans.
- * @param vector_t The sequence that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- template<>
- FastCdr& serialize<bool>(const std::vector<bool> &vector_t)
- {
- return serializeBoolSequence(vector_t);
- }
- #endif
- /*!
- * @brief This function template serializes a non-basic type.
- * @param type_t The object that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- inline FastCdr& serialize(const _T &type_t)
- {
- type_t.serialize(*this);
- return *this;
- }
- /*!
- * @brief This function serializes an array of octets.
- * @param octet_t The sequence of octets that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serializeArray(const uint8_t *octet_t, size_t numElements)
- {
- return serializeArray(reinterpret_cast<const char*>(octet_t), numElements);
- }
- /*!
- * @brief This function serializes an array of characters.
- * @param char_t The array of characters that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- FastCdr& serializeArray(const char *char_t, size_t numElements);
- /*!
- * @brief This function serializes an array of int8_t.
- * @param int8 The sequence of int8_t that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serializeArray(const int8_t *int8, size_t numElements)
- {
- return serializeArray(reinterpret_cast<const char*>(int8), numElements);
- }
- /*!
- * @brief This function serializes an array of unsigned shorts.
- * @param ushort_t The array of unsigned shorts that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serializeArray(const uint16_t *ushort_t, size_t numElements)
- {
- return serializeArray(reinterpret_cast<const int16_t*>(ushort_t), numElements);
- }
- /*!
- * @brief This function serializes an array of shorts.
- * @param short_t The array of shorts that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- FastCdr& serializeArray(const int16_t *short_t, size_t numElements);
- /*!
- * @brief This function serializes an array of unsigned longs.
- * @param ulong_t The array of unsigned longs that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serializeArray(const uint32_t *ulong_t, size_t numElements)
- {
- return serializeArray(reinterpret_cast<const int32_t*>(ulong_t), numElements);
- }
- /*!
- * @brief This function serializes an array of longs.
- * @param long_t The array of longs that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- FastCdr& serializeArray(const int32_t *long_t, size_t numElements);
- /*!
- * @brief This function serializes an array of wide-chars.
- * @param wchar The array of wide-chars that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- FastCdr& serializeArray(const wchar_t *wchar, size_t numElements);
- /*!
- * @brief This function serializes an array of unsigned long longs.
- * @param ulonglong_t The array of unsigned long longs that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serializeArray(const uint64_t *ulonglong_t, size_t numElements)
- {
- return serializeArray(reinterpret_cast<const int64_t*>(ulonglong_t), numElements);
- }
- /*!
- * @brief This function serializes an array of long longs.
- * @param longlong_t The array of long longs that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- FastCdr& serializeArray(const int64_t *longlong_t, size_t numElements);
- /*!
- * @brief This function serializes an array of floats.
- * @param float_t The array of floats that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- FastCdr& serializeArray(const float *float_t, size_t numElements);
- /*!
- * @brief This function serializes an array of doubles.
- * @param double_t The array of doubles that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- FastCdr& serializeArray(const double *double_t, size_t numElements);
- /*!
- * @brief This function serializes an array of long doubles.
- * @param ldouble_t The array of long doubles that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- FastCdr& serializeArray(const long double *ldouble_t, size_t numElements);
- /*!
- * @brief This function serializes an array of booleans.
- * @param bool_t The array of booleans that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- FastCdr& serializeArray(const bool *bool_t, size_t numElements);
- /*!
- * @brief This function serializes an array of strings.
- * @param string_t The array of strings that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serializeArray(const std::string *string_t, size_t numElements)
- {
- for(size_t count = 0; count < numElements; ++count)
- serialize(string_t[count].c_str());
- return *this;
- }
- /*!
- * @brief This function serializes an array of wstrings.
- * @param string_t The array of wstrings that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& serializeArray(const std::wstring *string_t, size_t numElements)
- {
- for(size_t count = 0; count < numElements; ++count)
- serialize(string_t[count].c_str());
- return *this;
- }
- /*!
- * @brief This function template serializes an array of sequences.
- * @param vector_t The array of sequences that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- FastCdr& serializeArray(const std::vector<_T> *vector_t, size_t numElements)
- {
- for(size_t count = 0; count < numElements; ++count)
- serialize(vector_t[count]);
- return *this;
- }
- /*!
- * @brief This function template serializes an array of non-basic type objects.
- * @param string_t The array of objects that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- FastCdr& serializeArray(const _T *type_t, size_t numElements)
- {
- for(size_t count = 0; count < numElements; ++count)
- type_t[count].serialize(*this);
- return *this;
- }
- /*!
- * @brief This function template serializes a raw sequence.
- * @param sequence_t Pointer to the sequence that will be serialized in the buffer.
- * @param numElements The number of elements contained in the sequence.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- FastCdr& serializeSequence(const _T *sequence_t, size_t numElements)
- {
- state state_before_error(*this);
- serialize(static_cast<int32_t>(numElements));
- try
- {
- return serializeArray(sequence_t, numElements);
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- setState(state_before_error);
- ex.raise();
- }
- return *this;
- }
- /*!
- * @brief This function deserializes an octet.
- * @param octet_t The variable that will store the octet read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(uint8_t &octet_t)
- {
- return deserialize(reinterpret_cast<char&>(octet_t));
- }
- /*!
- * @brief This function deserializes a character.
- * @param char_t The variable that will store the character read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(char &char_t)
- {
- if((m_lastPosition - m_currentPosition) >= sizeof(char_t))
- {
- m_currentPosition++ >> char_t;
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function deserializes an int8_t.
- * @param int8 The variable that will store the int8_t read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(int8_t &int8)
- {
- return deserialize(reinterpret_cast<char&>(int8));
- }
- /*!
- * @brief This function deserializes an unsigned short.
- * @param ushort_t The variable that will store the unsigned short read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(uint16_t &ushort_t)
- {
- return deserialize(reinterpret_cast<int16_t&>(ushort_t));
- }
- /*!
- * @brief This function deserializes a short.
- * @param short_t The variable that will store the short read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(int16_t &short_t)
- {
- if((m_lastPosition - m_currentPosition) >= sizeof(short_t))
- {
- m_currentPosition >> short_t;
- m_currentPosition += sizeof(short_t);
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function deserializes an unsigned long.
- * @param ulong_t The variable that will store the unsigned long read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(uint32_t &ulong_t)
- {
- return deserialize(reinterpret_cast<int32_t&>(ulong_t));
- }
- /*!
- * @brief This function deserializes a long.
- * @param long_t The variable that will store the long read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(int32_t &long_t)
- {
- if((m_lastPosition - m_currentPosition) >= sizeof(long_t))
- {
- m_currentPosition >> long_t;
- m_currentPosition += sizeof(long_t);
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function deserializes a wide-char.
- * @param wchar The variable that will store the wide-char read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(wchar_t &wchar)
- {
- uint32_t ret;
- deserialize(ret);
- wchar = static_cast<wchar_t>(ret);
- return *this;
- }
- /*!
- * @brief This function deserializes an unsigned long long.
- * @param ulonglong_t The variable that will store the unsigned long long read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(uint64_t &ulonglong_t)
- {
- return deserialize(reinterpret_cast<int64_t&>(ulonglong_t));
- }
- /*!
- * @brief This function deserializes a long long.
- * @param longlong_t The variable that will store the long long read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(int64_t &longlong_t)
- {
- if((m_lastPosition - m_currentPosition) >= sizeof(longlong_t))
- {
- m_currentPosition >> longlong_t;
- m_currentPosition += sizeof(longlong_t);
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function deserializes a float.
- * @param float_t The variable that will store the float read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(float &float_t)
- {
- if((m_lastPosition - m_currentPosition) >= sizeof(float_t))
- {
- m_currentPosition >> float_t;
- m_currentPosition += sizeof(float_t);
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function deserializes a double.
- * @param double_t The variable that will store the double read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(double &double_t)
- {
- if((m_lastPosition - m_currentPosition) >= sizeof(double_t))
- {
- m_currentPosition >> double_t;
- m_currentPosition += sizeof(double_t);
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function deserializes a long double.
- * @param ldouble_t The variable that will store the long double read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(long double &ldouble_t)
- {
- if((m_lastPosition - m_currentPosition) >= sizeof(ldouble_t))
- {
- m_currentPosition >> ldouble_t;
- m_currentPosition += sizeof(ldouble_t);
- #if defined(_WIN32)
- m_currentPosition += sizeof(ldouble_t);
- #endif
- return *this;
- }
- throw exception::NotEnoughMemoryException(exception::NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT);
- }
- /*!
- * @brief This function deserializes a boolean.
- * @param bool_t The variable that will store the boolean read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- * @exception exception::BadParamException This exception is thrown when trying to deserialize in an invalid value.
- */
- FastCdr& deserialize(bool &bool_t);
- /*!
- * @brief This function deserializes a string.
- * This function allocates memory to store the string. The user pointer will be set to point this allocated memory.
- * The user will have to free this allocated memory using free()
- * @param string_t The pointer that will point to the string read from the buffer.
- * The user will have to free the allocated memory using free()
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- FastCdr& deserialize(char *&string_t);
- /*!
- * @brief This function deserializes a wide string.
- * This function allocates memory to store the wide string. The user pointer will be set to point this allocated memory.
- * The user will have to free this allocated memory using free()
- * @param string_t The pointer that will point to the wide string read from the buffer.
- * The user will have to free the allocated memory using free()
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- FastCdr& deserialize(wchar_t *&string_t);
- /*!
- * @brief This function deserializes a std::string.
- * @param string_t The variable that will store the string read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(std::string &string_t)
- {
- uint32_t length = 0;
- const char *str = readString(length);
- string_t = std::string(str, length);
- return *this;
- }
- /*!
- * @brief This function deserializes a std::wstring.
- * @param string_t The variable that will store the wstring read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserialize(std::wstring &string_t)
- {
- uint32_t length = 0;
- string_t = readWString(length);
- return *this;
- }
- #if HAVE_CXX0X
- /*!
- * @brief This function template deserializes an array.
- * @param array_t The variable that will store the array read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- inline FastCdr& deserialize(std::array<_T, _Size> &array_t)
- { return deserializeArray(array_t.data(), array_t.size());}
- #endif
- #if !defined(_MSC_VER) && HAVE_CXX0X
- /*!
- * @brief This function template deserializes a sequence of booleans.
- * @param vector_t The variable that will store the sequence read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T = bool>
- FastCdr& deserialize(std::vector<bool> &vector_t)
- {
- return deserializeBoolSequence(vector_t);
- }
- #endif
- /*!
- * @brief This function template deserializes a sequence.
- * @param vector_t The variable that will store the sequence read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- FastCdr& deserialize(std::vector<_T> &vector_t)
- {
- uint32_t seqLength = 0;
- state state_before_error(*this);
- *this >> seqLength;
- try
- {
- vector_t.resize(seqLength);
- return deserializeArray(vector_t.data(), vector_t.size());
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- setState(state_before_error);
- ex.raise();
- }
- return *this;
- }
- #ifdef _MSC_VER
- /*!
- * @brief This function template deserializes a sequence of booleans.
- * @param vector_t The variable that will store the sequence read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<>
- FastCdr& deserialize<bool>(std::vector<bool> &vector_t)
- {
- return deserializeBoolSequence(vector_t);
- }
- #endif
- /*!
- * @brief This function template deserializes a non-basic type object.
- * @param type_t The variable that will store the object read from the buffer.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- inline FastCdr& deserialize(_T &type_t)
- {
- type_t.deserialize(*this);
- return *this;
- }
- /*!
- * @brief This function deserializes an array of octets.
- * @param octet_t The variable that will store the array of octets read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserializeArray(uint8_t *octet_t, size_t numElements)
- {
- return deserializeArray(reinterpret_cast<char*>(octet_t), numElements);
- }
- /*!
- * @brief This function deserializes an array of characters.
- * @param char_t The variable that will store the array of characters read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- FastCdr& deserializeArray(char *char_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of int8_t.
- * @param int8 The variable that will store the array of int8_t read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserializeArray(int8_t *int8, size_t numElements)
- {
- return deserializeArray(reinterpret_cast<char*>(int8), numElements);
- }
- /*!
- * @brief This function deserializes an array of unsigned shorts.
- * @param ushort_t The variable that will store the array of unsigned shorts read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserializeArray(uint16_t *ushort_t, size_t numElements)
- {
- return deserializeArray(reinterpret_cast<int16_t*>(ushort_t), numElements);
- }
- /*!
- * @brief This function deserializes an array of shorts.
- * @param short_t The variable that will store the array of shorts read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- FastCdr& deserializeArray(int16_t *short_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of unsigned longs.
- * @param ulong_t The variable that will store the array of unsigned longs read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserializeArray(uint32_t *ulong_t, size_t numElements)
- {
- return deserializeArray(reinterpret_cast<int32_t*>(ulong_t), numElements);
- }
- /*!
- * @brief This function deserializes an array of longs.
- * @param long_t The variable that will store the array of longs read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- FastCdr& deserializeArray(int32_t *long_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of wide-chars.
- * @param wchar The variable that will store the array of wide-chars read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- FastCdr& deserializeArray(wchar_t *wchar, size_t numElements);
- /*!
- * @brief This function deserializes an array of unsigned long longs.
- * @param ulonglong_t The variable that will store the array of unsigned long longs read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserializeArray(uint64_t *ulonglong_t, size_t numElements)
- {
- return deserializeArray(reinterpret_cast<int64_t*>(ulonglong_t), numElements);
- }
- /*!
- * @brief This function deserializes an array of long longs.
- * @param longlong_t The variable that will store the array of long longs read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- FastCdr& deserializeArray(int64_t *longlong_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of floats.
- * @param float_t The variable that will store the array of floats read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- FastCdr& deserializeArray(float *float_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of doubles.
- * @param double_t The variable that will store the array of doubles read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- FastCdr& deserializeArray(double *double_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of long doubles.
- * @param ldouble_t The variable that will store the array of long doubles read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- FastCdr& deserializeArray(long double *ldouble_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of booleans.
- * @param bool_t The variable that will store the array of booleans read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- FastCdr& deserializeArray(bool *bool_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of strings.
- * @param string_t The variable that will store the array of strings read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserializeArray(std::string *string_t, size_t numElements)
- {
- for(size_t count = 0; count < numElements; ++count)
- deserialize(string_t[count]);
- return *this;
- }
- /*!
- * @brief This function deserializes an array of wide-strings.
- * @param string_t The variable that will store the array of strings read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- inline
- FastCdr& deserializeArray(std::wstring *string_t, size_t numElements)
- {
- for(size_t count = 0; count < numElements; ++count)
- deserialize(string_t[count]);
- return *this;
- }
- /*!
- * @brief This function template deserializes an array of sequences.
- * @param vector_t The variable that will store the array of sequences read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- FastCdr& deserializeArray(std::vector<_T> *vector_t, size_t numElements)
- {
- for(size_t count = 0; count < numElements; ++count)
- deserialize(vector_t[count]);
- return *this;
- }
- /*!
- * @brief This function template deserializes an array of non-basic type objects.
- * @param type_t The variable that will store the array of objects read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- FastCdr& deserializeArray(_T *type_t, size_t numElements)
- {
- for(size_t count = 0; count < numElements; ++count)
- type_t[count].deserialize(*this);
- return *this;
- }
- #if !defined(_MSC_VER) && HAVE_CXX0X
- /*!
- * @brief This function template deserializes a string sequence.
- * This function allocates memory to store the sequence. The user pointer will be set to point this allocated memory.
- * The user will have to free this allocated memory using free()
- * @param sequence_t The pointer that will store the sequence read from the buffer.
- * @param numElements This variable return the number of elements of the sequence.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T = std::string>
- FastCdr& deserializeSequence(std::string *&sequence_t, size_t &numElements)
- {
- return deserializeStringSequence(sequence_t, numElements);
- }
- /*!
- * @brief This function template deserializes a wide-string sequence.
- * This function allocates memory to store the sequence. The user pointer will be set to point this allocated memory.
- * The user will have to free this allocated memory using free()
- * @param sequence_t The pointer that will store the sequence read from the buffer.
- * @param numElements This variable return the number of elements of the sequence.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T = std::wstring>
- FastCdr& deserializeSequence(std::wstring *&sequence_t, size_t &numElements)
- {
- return deserializeWStringSequence(sequence_t, numElements);
- }
- #endif
- /*!
- * @brief This function template deserializes a raw sequence.
- * This function allocates memory to store the sequence. The user pointer will be set to point this allocated memory.
- * The user will have to free this allocated memory using free()
- * @param sequence_t The pointer that will store the sequence read from the buffer.
- * @param numElements This variable return the number of elements of the sequence.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T>
- FastCdr& deserializeSequence(_T *&sequence_t, size_t &numElements)
- {
- uint32_t seqLength = 0;
- state state_before_error(*this);
- deserialize(seqLength);
- try
- {
- sequence_t = reinterpret_cast<_T*>(calloc(seqLength, sizeof(_T)));
- deserializeArray(sequence_t, seqLength);
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- free(sequence_t);
- sequence_t = NULL;
- setState(state_before_error);
- ex.raise();
- }
- numElements = seqLength;
- return *this;
- }
- #ifdef _MSC_VER
- /*!
- * @brief This function template deserializes a string sequence.
- * This function allocates memory to store the sequence. The user pointer will be set to point this allocated memory.
- * The user will have to free this allocated memory using free()
- * @param sequence_t The pointer that will store the sequence read from the buffer.
- * @param numElements This variable return the number of elements of the sequence.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<>
- FastCdr& deserializeSequence<std::string>(std::string *&sequence_t, size_t &numElements)
- {
- return deserializeStringSequence(sequence_t, numElements);
- }
- /*!
- * @brief This function template deserializes a wide-string sequence.
- * This function allocates memory to store the sequence. The user pointer will be set to point this allocated memory.
- * The user will have to free this allocated memory using free()
- * @param sequence_t The pointer that will store the sequence read from the buffer.
- * @param numElements This variable return the number of elements of the sequence.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<>
- FastCdr& deserializeSequence<std::wstring>(std::wstring *&sequence_t, size_t &numElements)
- {
- return deserializeWStringSequence(sequence_t, numElements);
- }
- #endif
- private:
- FastCdr(const FastCdr&) = delete;
- FastCdr& operator=(const FastCdr&) = delete;
- FastCdr& serializeBoolSequence(const std::vector<bool> &vector_t);
- FastCdr& deserializeBoolSequence(std::vector<bool> &vector_t);
- FastCdr& deserializeStringSequence(std::string *&sequence_t, size_t &numElements);
- FastCdr& deserializeWStringSequence(std::wstring *&sequence_t, size_t &numElements);
- #if HAVE_CXX0X
- /*!
- * @brief This function template detects the content type of the STD container array and serializes the array.
- * @param array_t The array that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize in a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- FastCdr& serializeArray(const std::array<_T, _Size> *array_t, size_t numElements)
- {
- return serializeArray(array_t->data(), numElements * array_t->size());
- }
- /*!
- * @brief This function template detects the content type of the STD container array and deserializes the array.
- * @param array_t The variable that will store the array read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::FastCdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize in a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- FastCdr& deserializeArray(std::array<_T, _Size> *array_t, size_t numElements)
- {
- return deserializeArray(array_t->data(), numElements * array_t->size());
- }
- #endif
- bool resize(size_t minSizeInc);
- const char* readString(uint32_t &length);
- std::wstring readWString(uint32_t &length);
- //! @brief Reference to the buffer that will be serialized/deserialized.
- FastBuffer &m_cdrBuffer;
- //! @brief The current position in the serialization/deserialization process.
- FastBuffer::iterator m_currentPosition;
- //! @brief The last position in the buffer;
- FastBuffer::iterator m_lastPosition;
- };
- } //namespace fastcdr
- } //namespace eprosima
- #endif //_FASTCDR_FASTCDR_H_
|