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

[19089] Fix HelloWorld DataSharing example idl (backport #3714) #3884

Merged
merged 2 commits into from
Oct 24, 2023
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
16 changes: 10 additions & 6 deletions examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorld.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ using namespace eprosima::fastcdr::exception;

#include <utility>

#define HelloWorld_max_cdr_typesize 264ULL;
#define HelloWorld_max_cdr_typesize 29ULL;
#define HelloWorld_max_key_cdr_typesize 0ULL;

HelloWorld::HelloWorld()
Expand Down Expand Up @@ -137,7 +137,11 @@ void HelloWorld::deserialize(
{

dcdr >> m_index;
dcdr >> m_message;
{
std::string aux;
dcdr >> aux;
m_message = aux.c_str();
}
}

/*!
Expand Down Expand Up @@ -173,7 +177,7 @@ uint32_t& HelloWorld::index()
* @param _message New value to be copied in member message
*/
void HelloWorld::message(
const std::string& _message)
const eprosima::fastrtps::fixed_string<20>& _message)
{
m_message = _message;
}
Expand All @@ -183,7 +187,7 @@ void HelloWorld::message(
* @param _message New value to be moved in member message
*/
void HelloWorld::message(
std::string&& _message)
eprosima::fastrtps::fixed_string<20>&& _message)
{
m_message = std::move(_message);
}
Expand All @@ -192,7 +196,7 @@ void HelloWorld::message(
* @brief This function returns a constant reference to member message
* @return Constant reference to member message
*/
const std::string& HelloWorld::message() const
const eprosima::fastrtps::fixed_string<20>& HelloWorld::message() const
{
return m_message;
}
Expand All @@ -201,7 +205,7 @@ const std::string& HelloWorld::message() const
* @brief This function returns a reference to member message
* @return Reference to member message
*/
std::string& HelloWorld::message()
eprosima::fastrtps::fixed_string<20>& HelloWorld::message()
{
return m_message;
}
Expand Down
20 changes: 10 additions & 10 deletions examples/cpp/dds/HelloWorldExampleDataSharing/HelloWorld.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,33 +147,33 @@ class HelloWorld
* @param _message New value to be copied in member message
*/
eProsima_user_DllExport void message(
const std::string& _message);
const eprosima::fastrtps::fixed_string<20>& _message);

/*!
* @brief This function moves the value in member message
* @param _message New value to be moved in member message
*/
eProsima_user_DllExport void message(
std::string&& _message);
eprosima::fastrtps::fixed_string<20>&& _message);

/*!
* @brief This function returns a constant reference to member message
* @return Constant reference to member message
*/
eProsima_user_DllExport const std::string& message() const;
eProsima_user_DllExport const eprosima::fastrtps::fixed_string<20>& message() const;

/*!
* @brief This function returns a reference to member message
* @return Reference to member message
*/
eProsima_user_DllExport std::string& message();
eProsima_user_DllExport eprosima::fastrtps::fixed_string<20>& message();

/*!
* @brief This function returns the maximum serialized size of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
* @brief This function returns the maximum serialized size of an object
* depending on the buffer alignment.
* @param current_alignment Buffer alignment.
* @return Maximum serialized size.
*/
eProsima_user_DllExport static size_t getMaxCdrSerializedSize(
size_t current_alignment = 0);

Expand Down Expand Up @@ -228,7 +228,7 @@ class HelloWorld
private:

uint32_t m_index;
std::string m_message;
eprosima::fastrtps::fixed_string<20> m_message;

};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
struct HelloWorld
{
unsigned long index;
string message;
string<20> message;
};
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class HelloWorldPubSubType : public eprosima::fastdds::dds::TopicDataType
#ifdef TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED
eProsima_user_DllExport inline bool is_bounded() const override
{
return false;
return true;
}

#endif // TOPIC_DATA_TYPE_API_HAS_IS_BOUNDED
Expand Down
Loading