Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: function definition is marked dllimport #210

Merged
merged 3 commits into from
Nov 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 11 additions & 50 deletions include/fastcdr/Cdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -530,10 +530,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 @@ -551,10 +548,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 @@ -563,10 +557,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 @@ -584,10 +575,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 @@ -605,10 +593,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 @@ -617,10 +602,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 @@ -675,10 +657,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 @@ -2765,10 +2744,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 @@ -2778,10 +2754,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 @@ -2793,10 +2766,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 @@ -2850,16 +2820,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 @@ -466,6 +466,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 @@ -481,6 +487,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 @@ -514,6 +532,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 @@ -549,6 +573,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 @@ -774,6 +810,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 @@ -2151,6 +2193,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);
}

felixf4xu marked this conversation as resolved.
Show resolved Hide resolved
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
Loading