Skip to content

Commit

Permalink
Fix: function definition is marked dllimport (#210)
Browse files Browse the repository at this point in the history
* 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>
  • Loading branch information
felixf4xu and JesusPoderoso authored Nov 11, 2024
1 parent 5cc8c55 commit ae92052
Show file tree
Hide file tree
Showing 2 changed files with 85 additions and 50 deletions.
61 changes: 11 additions & 50 deletions include/fastcdr/Cdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<char>(octet_t));
}
const uint8_t& octet_t);

/*!
* @brief This function serializes a character.
Expand All @@ -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<char>(int8));
}
const int8_t int8);

/*!
* @brief This function serializes an unsigned short.
Expand All @@ -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<int16_t>(ushort_t));
}
const uint16_t ushort_t);

/*!
* @brief This function serializes a short.
Expand All @@ -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<int32_t>(ulong_t));
}
const uint32_t ulong_t);

/*!
* @brief This function serializes a long.
Expand All @@ -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<uint16_t>(wchar));
}
const wchar_t wchar);

/*!
* @brief This function serializes an unsigned long long.
Expand All @@ -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<int64_t>(ulonglong_t));
}
const uint64_t ulonglong_t);

/*!
* @brief This function serializes a long long.
Expand Down Expand Up @@ -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<const char*>(string_t));
}
char* string_t);

/*!
* @brief This function serializes a string.
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand All @@ -2809,10 +2782,7 @@ class Cdr
*/
Cdr_DllAPI Cdr& deserialize_type(
EncodingAlgorithmFlag type_encoding,
std::function<bool (Cdr&, const MemberId&)> functor)
{
return (this->*deserialize_type_)(type_encoding, functor);
}
std::function<bool (Cdr&, const MemberId&)> functor);

/*!
* @brief Encodes an optional in the buffer.
Expand Down Expand Up @@ -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.
Expand Down
74 changes: 74 additions & 0 deletions src/cpp/Cdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,12 @@ bool Cdr::resize(
return false;
}

Cdr& Cdr::serialize(
const uint8_t& octet_t)
{
return serialize(static_cast<char>(octet_t));
}

Cdr& Cdr::serialize(
const char char_t)
{
Expand All @@ -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<char>(int8));
}

Cdr& Cdr::serialize(
const uint16_t ushort_t)
{
return serialize(static_cast<int16_t>(ushort_t));
}

Cdr& Cdr::serialize(
const int16_t short_t)
{
Expand Down Expand Up @@ -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<int32_t>(ulong_t));
}

Cdr& Cdr::serialize(
const int32_t long_t)
{
Expand Down Expand Up @@ -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<uint16_t>(wchar));
}

Cdr& Cdr::serialize(
const uint64_t ulonglong_t)
{
return serialize(static_cast<int64_t>(ulonglong_t));
}

Cdr& Cdr::serialize(
const int64_t longlong_t)
{
Expand Down Expand Up @@ -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<const char*>(string_t));
}

Cdr& Cdr::serialize(
const char* string_t)
{
Expand Down Expand Up @@ -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<bool (Cdr&, const MemberId&)> 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<bool>& vector_t)
{
Expand Down

0 comments on commit ae92052

Please sign in to comment.