12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939 |
- // 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_CDR_H_
- #define _FASTCDR_CDR_H_
- #include "fastcdr_dll.h"
- #include "FastBuffer.h"
- #include "exceptions/NotEnoughMemoryException.h"
- #include <stdint.h>
- #include <string>
- #include <vector>
- #include <map>
- #include <iostream>
- #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 CDR protocol inside an eprosima::fastcdr::FastBuffer.
- * @ingroup FASTCDRAPIREFERENCE
- */
- class Cdr_DllAPI Cdr
- {
- public:
- //! @brief This enumeration represents the two kinds of CDR serialization supported by eprosima::fastcdr::CDR.
- typedef enum
- {
- //! @brief Common CORBA CDR serialization.
- CORBA_CDR,
- //! @brief DDS CDR serialization.
- DDS_CDR
- } CdrType;
- //! @brief This enumeration represents the two posible values of the flag that points if the content is a parameter list (only in DDS CDR).
- typedef enum
- #ifdef HAVE_CXX0X
- : uint8_t
- #endif
- {
- //! @brief Specifies that the content is not a parameter list.
- DDS_CDR_WITHOUT_PL = 0x0,
- //! @brief Specifies that the content is a parameter list.
- DDS_CDR_WITH_PL = 0x2
- } DDSCdrPlFlag;
- /*!
- * @brief This enumeration represents endianness types.
- */
- typedef enum
- #ifdef HAVE_CXX0X
- : uint8_t
- #endif
- {
- //! @brief Big endianness.
- BIG_ENDIANNESS = 0x0,
- //! @brief Little endianness.
- LITTLE_ENDIANNESS = 0x1
- } Endianness;
- //! @brief Default endiness in the system.
- static const Endianness DEFAULT_ENDIAN;
- /*!
- * @brief This class stores the current state of a CDR serialization.
- */
- class Cdr_DllAPI state
- {
- friend class Cdr;
- public:
- /*!
- * @brief Default constructor.
- */
- state(const Cdr &cdr);
- /*!
- * @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 The position from the aligment is calculated, when the state was created..
- const FastBuffer::iterator m_alignPosition;
- //! @brief This attribute specified if it is needed to swap the bytes when the state was created..
- bool m_swapBytes;
- //! @brief Stores the last datasize serialized/deserialized when the state was created.
- size_t m_lastDataSize;
- };
- /*!
- * @brief This constructor creates an eprosima::fastcdr::Cdr object that can serialize/deserialize
- * the assigned buffer.
- *
- * @param cdrBuffer A reference to the buffer that contains (or will contain) the CDR representation.
- * @param endianness The initial endianness that will be used. The default value is the endianness of the system.
- * @param cdrType Represents the type of CDR that will be used in serialization/deserialization. The default value is CORBA CDR.
- */
- Cdr(FastBuffer &cdrBuffer, const Endianness endianness = DEFAULT_ENDIAN, const CdrType cdrType = CORBA_CDR);
- /*!
- * @brief This function reads the encapsulation of the CDR stream.
- * If the CDR stream contains an encapsulation, then this function should be called before starting to deserialize.
- * @return Reference to the eprosima::fastcdr::Cdr 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.
- */
- Cdr& read_encapsulation();
- /*!
- * @brief This function writes the encapsulation of the CDR stream.
- * If the CDR stream should contain an encapsulation, then this function should be called before starting to serialize.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize_encapsulation();
- /*!
- * @brief This function returns the parameter list flag when the CDR type is eprosima::fastcdr::DDS_CDR.
- * @return The flag that specifies if the content is a parameter list.
- */
- DDSCdrPlFlag getDDSCdrPlFlag() const;
- /*!
- * @brief This function sets the parameter list flag when the CDR type is eprosima::fastcdr::DDS_CDR.
- * @param plFlag New value for the flag that specifies if the content is a parameter list.
- */
- void setDDSCdrPlFlag(DDSCdrPlFlag plFlag);
- /*!
- * @brief This function returns the option flags when the CDR type is eprosima::fastcdr::DDS_CDR.
- * @return The option flags.
- */
- uint16_t getDDSCdrOptions() const;
- /*!
- * @brief This function sets the option flags when the CDR type is eprosima::fastcdr::DDS_CDR.
- * @param options New value for the option flags.
- */
- void setDDSCdrOptions(uint16_t options);
- /*!
- * @brief This function sets the current endianness used by the CDR type.
- * @param endianness The new endianness value.
- */
- void changeEndianness(Endianness endianness);
- /*!
- * @brief This function returns the current endianness used by the CDR type.
- * @return The endianness.
- */
- Endianness endianness() const { return static_cast<Endianness>(m_endianness); }
- /*!
- * @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 it works successfully. Otherwise, false is returned.
- */
- bool jump(size_t numBytes);
- /*!
- * @brief This function resets the current position in the buffer to the beginning.
- */
- void reset();
- /*!
- * @brief This function returns the pointer to the current used buffer.
- * @return Pointer to the starting position of the buffer.
- */
- char* getBufferPointer();
- /*!
- * @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 Get the number of bytes needed to align a position to certain data size.
- * @param current_alignment Position to be aligned.
- * @param dataSize Size of next data to process (should be power of two).
- * @return Number of required alignment bytes.
- */
- inline static size_t alignment(size_t current_alignment, size_t dataSize) { return (dataSize - (current_alignment % dataSize)) & (dataSize-1);}
- /*!
- * @brief This function returns the current state of the CDR serialization process.
- * @return The current state of the CDR serialization process.
- */
- state getState();
- /*!
- * @brief This function sets a previous state of the CDR serialization process;
- * @param state Previous state that will be set.
- */
- void setState(state &state);
- /*!
- * @brief This function moves the alignment forward.
- * @param numBytes The number of bytes the alignment should advance.
- * @return True If alignment was moved successfully.
- */
- bool moveAlignmentForward(size_t numBytes);
- /*!
- * @brief This function resets the alignment to the current position in the buffer.
- */
- inline void resetAlignment(){m_alignPosition = m_currentPosition;}
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& operator<<(const uint32_t ulong_t){return serialize(ulong_t);}
- /*!
- * @brief This operator serializes a long.
- * @param ulong_t The value of the long that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& operator<<(const float float_t){return serialize(float_t);}
- /*!
- * @brief This operator serializes a double.
- * @param double_t The value of the double that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& operator<<(const bool bool_t){return serialize(bool_t);}
- /*!
- * @brief This operator serializes a null-terminated c-string.
- * @param string_t Pointer to the begining of the string that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& operator<<(const char *string_t){return serialize(string_t);}
- /*!
- * @brief This operator serializes a null-terminated c-string.
- * @param string_t Pointer to the begining of the string that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& operator<<(char *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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T>
- inline Cdr& operator<<(const std::vector<_T> &vector_t){return serialize<_T>(vector_t);}
- /*!
- * @brief This operator template is used to serialize maps.
- * @param map_t The map that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _K, class _T>
- inline Cdr& operator<<(const std::map<_K, _T> &map_t){return serialize<_K, _T>(map_t);}
- /*!
- * @brief This operator template is used to serialize any other non-basic type.
- * @param type_t A reference to the object that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T>
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& operator>>(char &char_t){return deserialize(char_t);}
- /*!
- * @brief This operator deserializes a int8_t.
- * @param int8 The variable that will store the int8_t read from the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& operator>>(int32_t &long_t){return deserialize(long_t);}
- // TODO in FastCdr
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& operator>>(wchar_t &wchar){return deserialize(wchar);}
- /*!
- * @brief This operator deserializes a 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr 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 Cdr& 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::Cdr 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 Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& operator>>(std::string &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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T>
- inline Cdr& operator>>(std::vector<_T> &vector_t){return deserialize<_T>(vector_t);}
- /*!
- * @brief This operator template is used to deserialize maps.
- * @param map_t The variable that will store the map read from the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _K, class _T>
- inline Cdr& operator>>(std::map<_K, _T> &map_t){return deserialize<_K, _T>(map_t);}
- /*!
- * @brief This operator template is used to deserialize any other non-basic type.
- * @param type_t The variable that will store the object read from the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T>
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const uint8_t octet_t)
- {
- return serialize(static_cast<char>(octet_t));
- }
- /*!
- * @brief This function serializes an octet with a different endianness.
- * @param octet_t The value of the octet that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const uint8_t octet_t, Endianness endianness)
- {
- return serialize(static_cast<char>(octet_t), endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const char char_t);
- /*!
- * @brief This function serializes a character with a different endianness.
- * @param char_t The value of the character that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const char char_t, Endianness /*endianness*/)
- {
- return serialize(char_t);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const int8_t int8)
- {
- return serialize(static_cast<char>(int8));
- }
- /*!
- * @brief This function serializes an int8_t with a different endianness.
- * @param octet_t The value of the int8_t that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const int8_t int8, Endianness endianness)
- {
- return serialize(static_cast<char>(int8), endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const uint16_t ushort_t)
- {
- return serialize(static_cast<int16_t>(ushort_t));
- }
- /*!
- * @brief This function serializes an unsigned short with a different endianness.
- * @param ushort_t The value of the unsigned short that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const uint16_t ushort_t, Endianness endianness)
- {
- return serialize(static_cast<int16_t>(ushort_t), endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const int16_t short_t);
- /*!
- * @brief This function serializes a short with a different endianness.
- * @param short_t The value of the short that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const int16_t short_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const uint32_t ulong_t)
- {
- return serialize(static_cast<int32_t>(ulong_t));
- }
- /*!
- * @brief This function serializes an unsigned long with a different endianness.
- * @param ulong_t The value of the unsigned long that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const uint32_t ulong_t, Endianness endianness)
- {
- return serialize(static_cast<int32_t>(ulong_t), endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const int32_t long_t);
- /*!
- * @brief This function serializes a long with a different endianness.
- * @param long_t The value of the long that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const int32_t long_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const wchar_t wchar)
- {
- return serialize(static_cast<uint32_t>(wchar));
- }
- /*!
- * @brief This function serializes a wide-char with a different endianness.
- * @param wchar The value of the wide-char that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const wchar_t wchar, Endianness endianness)
- {
- return serialize(static_cast<uint32_t>(wchar), endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const uint64_t ulonglong_t)
- {
- return serialize(static_cast<int64_t>(ulonglong_t));
- }
- /*!
- * @brief This function serializes an unsigned long long with a different endianness.
- * @param ulonglong_t The value of the unsigned long long that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const uint64_t ulonglong_t, Endianness endianness)
- {
- return serialize(static_cast<int64_t>(ulonglong_t), endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const int64_t longlong_t);
- /*!
- * @brief This function serializes a long long with a different endianness.
- * @param longlong_t The value of the long long that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const int64_t longlong_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const float float_t);
- /*!
- * @brief This function serializes a float with a different endianness.
- * @param float_t The value of the float that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const float float_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const double double_t);
- /*!
- * @brief This function serializes a double with a different endianness.
- * @param double_t The value of the double that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const double double_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- * @note Due to internal representation differences, WIN32 and *NIX like systems are not compatible.
- */
- Cdr& serialize(const long double ldouble_t);
- /*!
- * @brief This function serializes a long double with a different endianness.
- * @param ldouble_t The value of the long double that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- * @note Due to internal representation differences, WIN32 and *NIX like systems are not compatible.
- */
- Cdr& serialize(const long double ldouble_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const bool bool_t);
- /*!
- * @brief This function serializes a boolean with a different endianness.
- * @param bool_t The value of the boolean that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const bool bool_t, Endianness /*endianness*/)
- {
- return serialize(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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline Cdr& serialize(char *string_t) { return serialize(static_cast<const char*>(string_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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const wchar_t *string_t);
- /*!
- * @brief This function serializes a string with a different endianness.
- * @param string_t The pointer to the string that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const char *string_t, Endianness endianness);
- /*!
- * @brief This function serializes a wstring with a different endianness.
- * @param string_t The pointer to the wstring that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serialize(const wchar_t *string_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const std::wstring &string_t) {return serialize(string_t.c_str());}
- /*!
- * @brief This function serializes a std::string with a different endianness.
- * @param string_t The string that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serialize(const std::string &string_t, Endianness endianness) {return serialize(string_t.c_str(), endianness);}
- #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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- inline Cdr& serialize(const std::array<_T, _Size> &array_t)
- { return serializeArray(array_t.data(), array_t.size());}
- /*!
- * @brief This function template serializes an array with a different endianness.
- * @param array_t The array that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- inline Cdr& serialize(const std::array<_T, _Size> &array_t, Endianness endianness)
- { return serializeArray(array_t.data(), array_t.size(), endianness);}
- #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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T = bool>
- Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& 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;
- }
- /*!
- * @brief This function template serializes a map.
- * @param map_t The map that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _K, class _T>
- Cdr& serialize(const std::map<_K, _T> &map_t)
- {
- state state_(*this);
- *this << static_cast<int32_t>(map_t.size());
- try
- {
- for (auto it_pair = map_t.begin(); it_pair != map_t.end(); ++it_pair)
- {
- *this << it_pair->first;
- *this << it_pair->second;
- }
- //return serializeArray(map_t.data(), map_t.size());
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- setState(state_);
- 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<>
- Cdr& serialize<bool>(const std::vector<bool> &vector_t)
- {
- return serializeBoolSequence(vector_t);
- }
- #endif
- /*!
- * @brief This function template serializes a sequence with a different endianness.
- * @param vector_t The sequence that will be serialized in the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& serialize(const std::vector<_T> &vector_t, Endianness endianness)
- {
- bool auxSwap = m_swapBytes;
- m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
- try
- {
- serialize(vector_t);
- m_swapBytes = auxSwap;
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- m_swapBytes = auxSwap;
- ex.raise();
- }
- return *this;
- }
- /*!
- * @brief This function template serializes a non-basic object.
- * @param type_t The object that will be serialized in the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T>
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& 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 octets with a different endianness.
- * @param octet_t The array of octets that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serializeArray(const uint8_t *octet_t, size_t numElements, Endianness /*endianness*/)
- {
- 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const char *char_t, size_t numElements);
- /*!
- * @brief This function serializes an array of characters with a different endianness.
- * @param char_t The array of characters that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serializeArray(const char *char_t, size_t numElements, Endianness /*endianness*/)
- {
- return serializeArray(char_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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serializeArray(const int8_t *int8, size_t numElements)
- {
- return serializeArray(reinterpret_cast<const char*>(int8), numElements);
- }
- /*!
- * @brief This function serializes an array of int8_t with a different endianness.
- * @param int8 The array of int8_t that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serializeArray(const int8_t *int8, size_t numElements, Endianness /*endianness*/)
- {
- 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& 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 unsigned shorts with a different endianness.
- * @param ushort_t The array of unsigned shorts that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serializeArray(const uint16_t *ushort_t, size_t numElements, Endianness endianness)
- {
- return serializeArray(reinterpret_cast<const int16_t*>(ushort_t), numElements, endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const int16_t *short_t, size_t numElements);
- /*!
- * @brief This function serializes an array of shorts with a different endianness.
- * @param short_t The array of shorts that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const int16_t *short_t, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& 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 unsigned longs with a different endianness.
- * @param ulong_t The array of unsigned longs that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serializeArray(const uint32_t *ulong_t, size_t numElements, Endianness endianness)
- {
- return serializeArray(reinterpret_cast<const int32_t*>(ulong_t), numElements, endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const int32_t *long_t, size_t numElements);
- /*!
- * @brief This function serializes an array of longs with a different endianness.
- * @param long_t The array of longs that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const int32_t *long_t, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const wchar_t *wchar, size_t numElements);
- /*!
- * @brief This function serializes an array of wide-chars with a different endianness.
- * @param wchar The array of longs that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const wchar_t *wchar, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& 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 unsigned long longs with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serializeArray(const uint64_t *ulonglong_t, size_t numElements, Endianness endianness)
- {
- return serializeArray(reinterpret_cast<const int64_t*>(ulonglong_t), numElements, endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const int64_t *longlong_t, size_t numElements);
- /*!
- * @brief This function serializes an array of long longs with a different endianness.
- * @param longlong_t The array of long longs that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const int64_t *longlong_t, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const float *float_t, size_t numElements);
- /*!
- * @brief This function serializes an array of floats with a different endianness.
- * @param float_t The array of floats that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const float *float_t, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const double *double_t, size_t numElements);
- /*!
- * @brief This function serializes an array of doubles with a different endianness.
- * @param double_t The array of doubles that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const double *double_t, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const long double *ldouble_t, size_t numElements);
- /*!
- * @brief This function serializes an array of long doubles with a different endianness.
- * @param ldouble_t The array of long doubles that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const long double *ldouble_t, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- Cdr& serializeArray(const bool *bool_t, size_t numElements);
- /*!
- * @brief This function serializes an array of booleans with a different endianness.
- * @param bool_t The array of booleans that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serializeArray(const bool *bool_t, size_t numElements, Endianness /*endianness*/)
- {
- return serializeArray(bool_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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& 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 wide-strings.
- * @param string_t The array of wide-strings that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& 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 serializes an array of strings with a different endianness.
- * @param string_t The array of strings that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serializeArray(const std::string *string_t, size_t numElements, Endianness endianness)
- {
- bool auxSwap = m_swapBytes;
- m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
- try
- {
- serializeArray(string_t, numElements);
- m_swapBytes = auxSwap;
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- m_swapBytes = auxSwap;
- ex.raise();
- }
- return *this;
- }
- /*!
- * @brief This function serializes an array of wide-strings with a different endianness.
- * @param string_t The array of wide-strings that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& serializeArray(const std::wstring *string_t, size_t numElements, Endianness endianness)
- {
- bool auxSwap = m_swapBytes;
- m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
- try
- {
- serializeArray(string_t, numElements);
- m_swapBytes = auxSwap;
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- m_swapBytes = auxSwap;
- ex.raise();
- }
- return *this;
- }
- /*!
- * @brief This function template serializes an array of sequences of objects.
- * @param vector_t The array of sequences of objects that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& 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 objects.
- * @param type_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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& 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 an array of non-basic objects with a different endianness.
- * @param type_t The array of objects that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& serializeArray(const _T *type_t, size_t numElements, Endianness endianness)
- {
- bool auxSwap = m_swapBytes;
- m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
- try
- {
- serializeArray(type_t, numElements);
- m_swapBytes = auxSwap;
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- m_swapBytes = auxSwap;
- ex.raise();
- }
- 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& 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 template serializes a raw sequence with a different endianness.
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& serializeSequence(const _T *sequence_t, size_t numElements, Endianness endianness)
- {
- bool auxSwap = m_swapBytes;
- m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
- try
- {
- serializeSequence(sequence_t, numElements);
- m_swapBytes = auxSwap;
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- m_swapBytes = auxSwap;
- 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(uint8_t &octet_t)
- {
- return deserialize(reinterpret_cast<char&>(octet_t));
- }
- /*!
- * @brief This function deserializes an octet with a different endianness.
- * @param octet_t The variable that will store the octet read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(uint8_t &octet_t, Endianness endianness)
- {
- return deserialize(reinterpret_cast<char&>(octet_t), endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(char &char_t);
- /*!
- * @brief This function deserializes a character with a different endianness.
- * @param char_t The variable that will store the character read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(char &char_t, Endianness /*endianness*/)
- {
- return deserialize(char_t);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(int8_t &int8)
- {
- return deserialize(reinterpret_cast<char&>(int8));
- }
- /*!
- * @brief This function deserializes an int8_t with a different endianness.
- * @param int8 The variable that will store the int8_t read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(int8_t &int8, Endianness endianness)
- {
- return deserialize(reinterpret_cast<char&>(int8), endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(uint16_t &ushort_t)
- {
- return deserialize(reinterpret_cast<int16_t&>(ushort_t));
- }
- /*!
- * @brief This function deserializes an unsigned short with a different endianness.
- * @param ushort_t The variable that will store the unsigned short read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(uint16_t &ushort_t, Endianness endianness)
- {
- return deserialize(reinterpret_cast<int16_t&>(ushort_t), endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(int16_t &short_t);
- /*!
- * @brief This function deserializes a short with a different endianness.
- * @param short_t The variable that will store the short read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(int16_t &short_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(uint32_t &ulong_t)
- {
- return deserialize(reinterpret_cast<int32_t&>(ulong_t));
- }
- /*!
- * @brief This function deserializes an unsigned long with a different endianness.
- * @param ulong_t The variable that will store the unsigned long read from the buffer..
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(uint32_t &ulong_t, Endianness endianness)
- {
- return deserialize(reinterpret_cast<int32_t&>(ulong_t), endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(int32_t &long_t);
- /*!
- * @brief This function deserializes a long with a different endianness.
- * @param long_t The variable that will store the long read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(int32_t &long_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(wchar_t &wchar)
- {
- uint32_t ret;
- deserialize(ret);
- wchar = static_cast<wchar_t>(ret);
- return *this;
- }
- /*!
- * @brief This function deserializes a wide-char with a different endianness.
- * @param wchar The variable that will store the wide-char read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(wchar_t &wchar, Endianness endianness)
- {
- uint32_t ret;
- deserialize(ret, endianness);
- 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(uint64_t &ulonglong_t)
- {
- return deserialize(reinterpret_cast<int64_t&>(ulonglong_t));
- }
- /*!
- * @brief This function deserializes an unsigned long long with a different endianness.
- * @param ulonglong_t The variable that will store the unsigned long long read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(uint64_t &ulonglong_t, Endianness endianness)
- {
- return deserialize(reinterpret_cast<int64_t&>(ulonglong_t), endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(int64_t &longlong_t);
- /*!
- * @brief This function deserializes a long long with a different endianness.
- * @param longlong_t The variable that will store the long long read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(int64_t &longlong_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(float &float_t);
- /*!
- * @brief This function deserializes a float with a different endianness.
- * @param float_t The variable that will store the float read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(float &float_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(double &double_t);
- /*!
- * @brief This function deserializes a double with a different endianness.
- * @param double_t The variable that will store the double read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(double &double_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- * @note Due to internal representation differences, WIN32 and *NIX like systems are not compatible.
- */
- Cdr& deserialize(long double &ldouble_t);
- /*!
- * @brief This function deserializes a long double with a different endianness.
- * @param ldouble_t The variable that will store the long double read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- * @note Due to internal representation differences, WIN32 and *NIX like systems are not compatible.
- */
- Cdr& deserialize(long double &ldouble_t, Endianness endianness);
- /*!
- * @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::Cdr 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.
- */
- Cdr& deserialize(bool &bool_t);
- /*!
- * @brief This function deserializes a boolean with a different endianness.
- * @param bool_t The variable that will store the boolean read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr 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
- Cdr& deserialize(bool &bool_t, Endianness /*endianness*/)
- {
- return deserialize(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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(wchar_t *&string_t);
- /*!
- * @brief This function deserializes a string with a different endianness.
- * 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(char *&string_t, Endianness endianness);
- /*!
- * @brief This function deserializes a wide string with a different endianness.
- * 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserialize(wchar_t *&string_t, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& 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::string.
- * @param string_t The variable that will store the string read from the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(std::wstring &string_t)
- {
- uint32_t length = 0;
- string_t = readWString(length);
- return *this;
- }
- /*!
- * @brief This function deserializes a string with a different endianness.
- * @param string_t The variable that will store the string read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(std::string &string_t, Endianness endianness)
- {
- bool auxSwap = m_swapBytes;
- m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
- try
- {
- deserialize(string_t);
- m_swapBytes = auxSwap;
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- m_swapBytes = auxSwap;
- ex.raise();
- }
- return *this;
- }
- /*!
- * @brief This function deserializes a string with a different endianness.
- * @param string_t The variable that will store the string read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserialize(std::wstring &string_t, Endianness endianness)
- {
- bool auxSwap = m_swapBytes;
- m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
- try
- {
- deserialize(string_t);
- m_swapBytes = auxSwap;
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- m_swapBytes = auxSwap;
- ex.raise();
- }
- 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- inline Cdr& deserialize(std::array<_T, _Size> &array_t)
- { return deserializeArray(array_t.data(), array_t.size());}
- /*!
- * @brief This function template deserializes an array with a different endianness.
- * @param array_t The variable that will store the array read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- inline Cdr& deserialize(std::array<_T, _Size> &array_t, Endianness endianness)
- { return deserializeArray(array_t.data(), array_t.size(), endianness);}
- #endif
- #if !defined(_MSC_VER) && HAVE_CXX0X
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T = bool>
- Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& 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;
- }
- /*!
- * @brief This function template deserializes a map.
- * @param map_t The variable that will store the map read from the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _K, class _T>
- Cdr& deserialize(std::map<_K, _T> &map_t)
- {
- uint32_t seqLength = 0;
- state state_(*this);
- *this >> seqLength;
- try
- {
- for (uint32_t i = 0; i < seqLength; ++i)
- {
- _K key;
- _T value;
- *this >> key;
- *this >> value;
- map_t.emplace(std::pair<_K, _T>(std::move(key), std::move(value)));
- }
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- setState(state_);
- ex.raise();
- }
- return *this;
- }
- #ifdef _MSC_VER
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<>
- Cdr& deserialize<bool>(std::vector<bool> &vector_t)
- {
- return deserializeBoolSequence(vector_t);
- }
- #endif
- /*!
- * @brief This function template deserializes a sequence with a different endianness.
- * @param vector_t The variable that will store the sequence read from the buffer.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& deserialize(std::vector<_T> &vector_t, Endianness endianness)
- {
- bool auxSwap = m_swapBytes;
- m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
- try
- {
- deserialize(vector_t);
- m_swapBytes = auxSwap;
- }
- catch(exception::Exception &ex)
- {
- m_swapBytes = auxSwap;
- ex.raise();
- }
- return *this;
- }
- /*!
- * @brief This function template deserializes a non-basic object.
- * @param type_t The variable that will store the object read from the buffer.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T>
- inline Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(uint8_t *octet_t, size_t numElements)
- {
- return deserializeArray(reinterpret_cast<char*>(octet_t), numElements);
- }
- /*!
- * @brief This function deserializes an array of octets with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(uint8_t *octet_t, size_t numElements, Endianness endianness)
- {
- return deserializeArray(reinterpret_cast<char*>(octet_t), numElements, endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(char *char_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of characters with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(char *char_t, size_t numElements, Endianness /*endianness*/)
- {
- return deserializeArray(char_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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(int8_t *int8, size_t numElements)
- {
- return deserializeArray(reinterpret_cast<char*>(int8), numElements);
- }
- /*!
- * @brief This function deserializes an array of int8_t with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(int8_t *int8, size_t numElements, Endianness endianness)
- {
- return deserializeArray(reinterpret_cast<char*>(int8), numElements, endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(uint16_t *ushort_t, size_t numElements)
- {
- return deserializeArray(reinterpret_cast<int16_t*>(ushort_t), numElements);
- }
- /*!
- * @brief This function deserializes an array of unsigned shorts with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(uint16_t *ushort_t, size_t numElements, Endianness endianness)
- {
- return deserializeArray(reinterpret_cast<int16_t*>(ushort_t), numElements, endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(int16_t *short_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of shorts with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(int16_t *short_t, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(uint32_t *ulong_t, size_t numElements)
- {
- return deserializeArray(reinterpret_cast<int32_t*>(ulong_t), numElements);
- }
- /*!
- * @brief This function deserializes an array of unsigned longs with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(uint32_t *ulong_t, size_t numElements, Endianness endianness)
- {
- return deserializeArray(reinterpret_cast<int32_t*>(ulong_t), numElements, endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(int32_t *long_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of longs with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(int32_t *long_t, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(wchar_t *wchar, size_t numElements);
- /*!
- * @brief This function deserializes an array of wide-chars with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(wchar_t *wchar, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(uint64_t *ulonglong_t, size_t numElements)
- {
- return deserializeArray(reinterpret_cast<int64_t*>(ulonglong_t), numElements);
- }
- /*!
- * @brief This function deserializes an array of unsigned long longs with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(uint64_t *ulonglong_t, size_t numElements, Endianness endianness)
- {
- return deserializeArray(reinterpret_cast<int64_t*>(ulonglong_t), numElements, endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(int64_t *longlong_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of long longs with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(int64_t *longlong_t, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(float *float_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of floats with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(float *float_t, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(double *double_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of doubles with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(double *double_t, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(long double *ldouble_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of long doubles with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(long double *ldouble_t, size_t numElements, Endianness endianness);
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- Cdr& deserializeArray(bool *bool_t, size_t numElements);
- /*!
- * @brief This function deserializes an array of booleans with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(bool *bool_t, size_t numElements, Endianness /*endianness*/)
- {
- return deserializeArray(bool_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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& 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 wide-strings read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& 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 deserializes an array of strings with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(std::string *string_t, size_t numElements, Endianness endianness)
- {
- bool auxSwap = m_swapBytes;
- m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
- try
- {
- deserializeArray(string_t, numElements);
- m_swapBytes = auxSwap;
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- m_swapBytes = auxSwap;
- ex.raise();
- }
- return *this;
- }
- /*!
- * @brief This function deserializes an array of wide-strings with a different endianness.
- * @param string_t The variable that will store the array of wide-strings read from the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- inline
- Cdr& deserializeArray(std::wstring *string_t, size_t numElements, Endianness endianness)
- {
- bool auxSwap = m_swapBytes;
- m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
- try
- {
- deserializeArray(string_t, numElements);
- m_swapBytes = auxSwap;
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- m_swapBytes = auxSwap;
- ex.raise();
- }
- return *this;
- }
- /*!
- * @brief This function deserializes an array of sequences of objects.
- * @param string_t The variable that will store the array of sequences of objects read from the buffer.
- * @param numElements Number of the elements in the array.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& 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 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& deserializeArray(_T *type_t, size_t numElements)
- {
- for(size_t count = 0; count < numElements; ++count)
- type_t[count].deserialize(*this);
- return *this;
- }
- /*!
- * @brief This function template deserializes an array of non-basic objects with a different endianness.
- * @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.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& deserializeArray(_T *type_t, size_t numElements, Endianness endianness)
- {
- bool auxSwap = m_swapBytes;
- m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
- try
- {
- deserializeArray(type_t, numElements);
- m_swapBytes = auxSwap;
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- m_swapBytes = auxSwap;
- ex.raise();
- }
- 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T = std::string>
- Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T = std::wstring>
- Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<>
- Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<>
- Cdr& deserializeSequence<std::wstring>(std::wstring *&sequence_t, size_t &numElements)
- {
- return deserializeWStringSequence(sequence_t, numElements);
- }
- #endif
- /*!
- * @brief This function template deserializes a raw sequence with a different endianness.
- * 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T>
- Cdr& deserializeSequence(_T *&sequence_t, size_t &numElements, Endianness endianness)
- {
- bool auxSwap = m_swapBytes;
- m_swapBytes = (m_swapBytes && (m_endianness == endianness)) || (!m_swapBytes && (m_endianness != endianness));
- try
- {
- deserializeSequence(sequence_t, numElements);
- m_swapBytes = auxSwap;
- }
- catch(eprosima::fastcdr::exception::Exception &ex)
- {
- m_swapBytes = auxSwap;
- ex.raise();
- }
- return *this;
- }
- private:
- Cdr(const Cdr&) = delete;
- Cdr& operator=(const Cdr&) = delete;
- Cdr& serializeBoolSequence(const std::vector<bool> &vector_t);
- Cdr& deserializeBoolSequence(std::vector<bool> &vector_t);
- Cdr& deserializeStringSequence(std::string *&sequence_t, size_t &numElements);
- Cdr& 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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- Cdr& 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 serializes the array with a different endianness.
- * @param array_t The array that will be serialized in the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- Cdr& serializeArray(const std::array<_T, _Size> *array_t, size_t numElements, Endianness endianness)
- {
- return serializeArray(array_t->data(), numElements * array_t->size(), endianness);
- }
- /*!
- * @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::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- Cdr& deserializeArray(std::array<_T, _Size> *array_t, size_t numElements)
- {
- return deserializeArray(array_t->data(), numElements * array_t->size());
- }
- /*!
- * @brief This function template detects the content type of STD container array and deserializes the array with a different endianness.
- * @param array_t The variable that will store the array read from the buffer.
- * @param numElements Number of the elements in the array.
- * @param endianness Endianness that will be used in the serialization of this value.
- * @return Reference to the eprosima::fastcdr::Cdr object.
- * @exception exception::NotEnoughMemoryException This exception is thrown when trying to deserialize a position that exceeds the internal memory size.
- */
- template<class _T, size_t _Size>
- Cdr& deserializeArray(std::array<_T, _Size> *array_t, size_t numElements, Endianness endianness)
- {
- return deserializeArray(array_t->data(), numElements * array_t->size(), endianness);
- }
- #endif
- /*!
- * @brief This function returns the extra bytes regarding the allignment.
- * @param dataSize The size of the data that will be serialized.
- * @return The size needed for the aligment.
- */
- inline size_t alignment(size_t dataSize) const {return dataSize > m_lastDataSize ? (dataSize - ((m_currentPosition - m_alignPosition) % dataSize)) & (dataSize-1) : 0;}
- /*!
- * @brief This function jumps the number of bytes of the alignment. These bytes should be calculated with the function eprosima::fastcdr::Cdr::alignment.
- * @param align The number of bytes to be skipped.
- */
- inline void makeAlign(size_t align){m_currentPosition += align;}
- /*!
- * @brief This function resizes the internal buffer. It only applies if the FastBuffer object was created with the default constructor.
- * @param minSizeInc Minimun size increase for the internal buffer
- * @return True if the resize was succesful, false if it was not
- */
- bool resize(size_t minSizeInc);
- //TODO
- const char* readString(uint32_t &length);
- const std::wstring readWString(uint32_t &length);
- //! @brief Reference to the buffer that will be serialized/deserialized.
- FastBuffer &m_cdrBuffer;
- //! @brief The type of CDR that will be use in serialization/deserialization.
- CdrType m_cdrType;
- //! @brief Using DDS_CDR type, this attribute stores if the stream buffer contains a parameter list or not.
- DDSCdrPlFlag m_plFlag;
- //! @brief This attribute stores the option flags when the CDR type is DDS_CDR;
- uint16_t m_options;
- //! @brief The endianness that will be applied over the buffer.
- uint8_t m_endianness;
- //! @brief This attribute specifies if it is needed to swap the bytes.
- bool m_swapBytes;
- //! @brief Stores the last datasize serialized/deserialized. It's used to optimize.
- size_t m_lastDataSize;
- //! @brief The current position in the serialization/deserialization process.
- FastBuffer::iterator m_currentPosition;
- //! @brief The position from where the aligment is calculated.
- FastBuffer::iterator m_alignPosition;
- //! @brief The last position in the buffer;
- FastBuffer::iterator m_lastPosition;
- };
- } //namespace fastcdr
- } //namespace eprosima
- #endif // _CDR_CDR_H_
|