Skip to content

Commit

Permalink
Refs #21362. Leave implementation in header.
Browse files Browse the repository at this point in the history
Signed-off-by: Miguel Company <[email protected]>
  • Loading branch information
MiguelCompany committed Nov 6, 2024
1 parent 3debdec commit b857329
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 23 deletions.
21 changes: 19 additions & 2 deletions include/fastcdr/Cdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -705,9 +705,26 @@ class Cdr
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
* @exception exception::BadParamException This exception is thrown when trying to serialize a string with null characters.
*/
TEMPLATE_SPEC Cdr_DllAPI
TEMPLATE_SPEC
Cdr& serialize(
const std::string& string_t);
const std::string& string_t)
{
// An empty string is serialized as a 0 length string.
if (string_t.empty())
{
return serialize(static_cast<uint32_t>(0));
}

// Check there are no null characters in the string.
const char* c_str = string_t.c_str();
const auto str_len = strlen(c_str);
if (string_t.size() > str_len)
{
throw BadParamException("The string contains null characters");
}

return serialize_sequence(c_str, str_len + 1);
}

/*!
* @brief This function serializes a std::wstring.
Expand Down
21 changes: 0 additions & 21 deletions src/cpp/Cdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,27 +887,6 @@ Cdr& Cdr::serialize(
return *this;
}

TEMPLATE_SPEC
Cdr& Cdr::serialize(
const std::string& string_t)
{
// An empty string is serialized as a 0 length string.
if (string_t.empty())
{
return serialize(static_cast<uint32_t>(0));
}

// Check there are no null characters in the string.
const char* c_str = string_t.c_str();
const auto str_len = strlen(c_str);
if (string_t.size() > str_len)
{
throw BadParamException("The string contains null characters");
}

return serialize_sequence(c_str, str_len + 1);
}

Cdr& Cdr::serialize_array(
const bool* bool_t,
size_t num_elements)
Expand Down

0 comments on commit b857329

Please sign in to comment.