From ae920520a9d7c7c3facba2445045d8a2d0b268ba Mon Sep 17 00:00:00 2001 From: Felix F Xu <84662027+felixf4xu@users.noreply.github.com> Date: Mon, 11 Nov 2024 22:17:48 +0800 Subject: [PATCH] Fix: function definition is marked dllimport (#210) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix: function definition is marked dllimport * Update src/cpp/Cdr.cpp Co-authored-by: Jesús Poderoso <120394830+JesusPoderoso@users.noreply.github.com> * Update src/cpp/Cdr.cpp Co-authored-by: Jesús Poderoso <120394830+JesusPoderoso@users.noreply.github.com> --------- Co-authored-by: Jesús Poderoso <120394830+JesusPoderoso@users.noreply.github.com> --- include/fastcdr/Cdr.h | 61 +++++++---------------------------- src/cpp/Cdr.cpp | 74 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+), 50 deletions(-) diff --git a/include/fastcdr/Cdr.h b/include/fastcdr/Cdr.h index ce2e4f51..0f836ee1 100644 --- a/include/fastcdr/Cdr.h +++ b/include/fastcdr/Cdr.h @@ -531,10 +531,7 @@ class Cdr * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size. */ Cdr_DllAPI Cdr& serialize( - const uint8_t& octet_t) - { - return serialize(static_cast(octet_t)); - } + const uint8_t& octet_t); /*! * @brief This function serializes a character. @@ -552,10 +549,7 @@ class Cdr * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size. */ Cdr_DllAPI Cdr& serialize( - const int8_t int8) - { - return serialize(static_cast(int8)); - } + const int8_t int8); /*! * @brief This function serializes an unsigned short. @@ -564,10 +558,7 @@ class Cdr * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size. */ Cdr_DllAPI Cdr& serialize( - const uint16_t ushort_t) - { - return serialize(static_cast(ushort_t)); - } + const uint16_t ushort_t); /*! * @brief This function serializes a short. @@ -585,10 +576,7 @@ class Cdr * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size. */ Cdr_DllAPI Cdr& serialize( - const uint32_t ulong_t) - { - return serialize(static_cast(ulong_t)); - } + const uint32_t ulong_t); /*! * @brief This function serializes a long. @@ -606,10 +594,7 @@ class Cdr * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size. */ Cdr_DllAPI Cdr& serialize( - const wchar_t wchar) - { - return serialize(static_cast(wchar)); - } + const wchar_t wchar); /*! * @brief This function serializes an unsigned long long. @@ -618,10 +603,7 @@ class Cdr * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size. */ Cdr_DllAPI Cdr& serialize( - const uint64_t ulonglong_t) - { - return serialize(static_cast(ulonglong_t)); - } + const uint64_t ulonglong_t); /*! * @brief This function serializes a long long. @@ -676,10 +658,7 @@ class Cdr * @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size. */ Cdr_DllAPI Cdr& serialize( - char* string_t) - { - return serialize(static_cast(string_t)); - } + char* string_t); /*! * @brief This function serializes a string. @@ -2781,10 +2760,7 @@ class Cdr */ Cdr_DllAPI Cdr& begin_serialize_type( Cdr::state& current_state, - EncodingAlgorithmFlag type_encoding) - { - return (this->*begin_serialize_type_)(current_state, type_encoding); - } + EncodingAlgorithmFlag type_encoding); /*! * @brief Tells to the encoder the encoding of the type finishes. @@ -2794,10 +2770,7 @@ class Cdr * position that exceeds the internal memory size. */ Cdr_DllAPI Cdr& end_serialize_type( - Cdr::state& current_state) - { - return (this->*end_serialize_type_)(current_state); - } + Cdr::state& current_state); /*! * @brief Tells to the encoder a new type and its members starts to be decoded. @@ -2809,10 +2782,7 @@ class Cdr */ Cdr_DllAPI Cdr& deserialize_type( EncodingAlgorithmFlag type_encoding, - std::function functor) - { - return (this->*deserialize_type_)(type_encoding, functor); - } + std::function functor); /*! * @brief Encodes an optional in the buffer. @@ -2866,16 +2836,7 @@ class Cdr * encoded. */ Cdr_DllAPI Cdr& operator <<( - const MemberId& member_id) - { - if (next_member_id_ != MEMBER_ID_INVALID) - { - throw exception::BadParamException("Member id already set and not encoded"); - } - - next_member_id_ = member_id; - return *this; - } + const MemberId& member_id); /*! * @brief Decodes an optional from the buffer. diff --git a/src/cpp/Cdr.cpp b/src/cpp/Cdr.cpp index 6d684999..5f80c157 100644 --- a/src/cpp/Cdr.cpp +++ b/src/cpp/Cdr.cpp @@ -504,6 +504,12 @@ bool Cdr::resize( return false; } +Cdr& Cdr::serialize( + const uint8_t& octet_t) +{ + return serialize(static_cast(octet_t)); +} + Cdr& Cdr::serialize( const char char_t) { @@ -519,6 +525,18 @@ Cdr& Cdr::serialize( throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT); } +Cdr& Cdr::serialize( + const int8_t int8) +{ + return serialize(static_cast(int8)); +} + +Cdr& Cdr::serialize( + const uint16_t ushort_t) +{ + return serialize(static_cast(ushort_t)); +} + Cdr& Cdr::serialize( const int16_t short_t) { @@ -552,6 +570,12 @@ Cdr& Cdr::serialize( throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT); } +Cdr& Cdr::serialize( + const uint32_t ulong_t) +{ + return serialize(static_cast(ulong_t)); +} + Cdr& Cdr::serialize( const int32_t long_t) { @@ -587,6 +611,18 @@ Cdr& Cdr::serialize( throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT); } +Cdr& Cdr::serialize( + const wchar_t wchar) +{ + return serialize(static_cast(wchar)); +} + +Cdr& Cdr::serialize( + const uint64_t ulonglong_t) +{ + return serialize(static_cast(ulonglong_t)); +} + Cdr& Cdr::serialize( const int64_t longlong_t) { @@ -812,6 +848,12 @@ Cdr& Cdr::serialize( throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT); } +Cdr& Cdr::serialize( + char* string_t) +{ + return serialize(static_cast(string_t)); +} + Cdr& Cdr::serialize( const char* string_t) { @@ -2189,6 +2231,38 @@ Cdr& Cdr::deserialize_array( throw NotEnoughMemoryException(NotEnoughMemoryException::NOT_ENOUGH_MEMORY_MESSAGE_DEFAULT); } +Cdr& Cdr::begin_serialize_type( + Cdr::state& current_state, + EncodingAlgorithmFlag type_encoding) +{ + return (this->*begin_serialize_type_)(current_state, type_encoding); +} + +Cdr& Cdr::end_serialize_type( + Cdr::state& current_state) +{ + return (this->*end_serialize_type_)(current_state); +} + +Cdr& Cdr::deserialize_type( + EncodingAlgorithmFlag type_encoding, + std::function functor) +{ + return (this->*deserialize_type_)(type_encoding, functor); +} + +Cdr& Cdr::operator <<( + const MemberId& member_id) +{ + if (next_member_id_ != MEMBER_ID_INVALID) + { + throw exception::BadParamException("Member id already set and not encoded"); + } + + next_member_id_ = member_id; + return *this; +} + Cdr& Cdr::serialize_bool_array( const std::vector& vector_t) {