Skip to content

Commit b857329

Browse files
committed
Refs #21362. Leave implementation in header.
Signed-off-by: Miguel Company <[email protected]>
1 parent 3debdec commit b857329

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

include/fastcdr/Cdr.h

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,9 +705,26 @@ class Cdr
705705
* @exception exception::NotEnoughMemoryException This exception is thrown when trying to serialize a position that exceeds the internal memory size.
706706
* @exception exception::BadParamException This exception is thrown when trying to serialize a string with null characters.
707707
*/
708-
TEMPLATE_SPEC Cdr_DllAPI
708+
TEMPLATE_SPEC
709709
Cdr& serialize(
710-
const std::string& string_t);
710+
const std::string& string_t)
711+
{
712+
// An empty string is serialized as a 0 length string.
713+
if (string_t.empty())
714+
{
715+
return serialize(static_cast<uint32_t>(0));
716+
}
717+
718+
// Check there are no null characters in the string.
719+
const char* c_str = string_t.c_str();
720+
const auto str_len = strlen(c_str);
721+
if (string_t.size() > str_len)
722+
{
723+
throw BadParamException("The string contains null characters");
724+
}
725+
726+
return serialize_sequence(c_str, str_len + 1);
727+
}
711728

712729
/*!
713730
* @brief This function serializes a std::wstring.

src/cpp/Cdr.cpp

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -887,27 +887,6 @@ Cdr& Cdr::serialize(
887887
return *this;
888888
}
889889

890-
TEMPLATE_SPEC
891-
Cdr& Cdr::serialize(
892-
const std::string& string_t)
893-
{
894-
// An empty string is serialized as a 0 length string.
895-
if (string_t.empty())
896-
{
897-
return serialize(static_cast<uint32_t>(0));
898-
}
899-
900-
// Check there are no null characters in the string.
901-
const char* c_str = string_t.c_str();
902-
const auto str_len = strlen(c_str);
903-
if (string_t.size() > str_len)
904-
{
905-
throw BadParamException("The string contains null characters");
906-
}
907-
908-
return serialize_sequence(c_str, str_len + 1);
909-
}
910-
911890
Cdr& Cdr::serialize_array(
912891
const bool* bool_t,
913892
size_t num_elements)

0 commit comments

Comments
 (0)