rti::topic::to_string not found in 5.3.0

5 posts / 0 new
Last post
jferguson75's picture
Offline
Last seen: 4 years 7 months ago
Joined: 01/28/2020
Posts: 4
rti::topic::to_string not found in 5.3.0

I'm very new to RTI and DDS but I've been mucking through learning the library the best I can to accomplish what I need.

I'm trying to make a library using .NET Core 3.1 so that all of our outher .NET Core projects can reference it.  To do that I'm creating a .NET C++ Core 3.1 project that references the DDS and RTI lib files directly instead of using the Framework libraries.  

My goal is to make a library that can take in Json and created DynamicData Structs and then to convert the DynamicData back into Json.  I've created the method (I hope) that walks through the Json using the new System.Text.Json library available in 3.1.  Now I'm trying to serialize the DynamicData back into Json.  

While looking for something else, I found in the community that in 5.3.0 there is now a way to serialize the DynamicData back into Json within the library using rti::topic::to_string.  I've got RTI 5.3.0 installed and I'm referencing the x64Win64VS2015 lib files but it can't find the to_string function.  It doesn't show up in the code complete in Visual Studio and it won't compile.

So my question are these:

1.  What am I missing to be able to serialize my DynamicData into Json usint rti::topic::to_string

2.  Is there an automatic way to deserialize a Json string into DynamicData without having to walk through it like I currently am?

Any help I can get would be very appreciated.

Offline
Last seen: 1 week 2 days ago
Joined: 04/02/2013
Posts: 196

Hi,

The function rti::topic::to_string is part of the Modern C++ API. I suspect you're using the Traditional C++ API. In that case, the function is DDS_DynamicData::to_string.

Let us know how that goes, we've also been interested in testing C++/CLI in .NET Core.

jferguson75's picture
Offline
Last seen: 4 years 7 months ago
Joined: 01/28/2020
Posts: 4

I hadn't considered that, Alejandro.  I was using the DynamicData Use Cases in the Programming How-Tos as my guide for creating the DynamicData but I don't think I considered whether I was using the Modern C++ or Traditional.  (I'm normally a C# developer so getting back to C++ has been painful after so many years.)  Because I've been creating DynamicData instead of DD_DynamicData, the traditional C++ method wasn't working for me either.  I guess I need to confirm which one I started out using and straighten out my code.

UPDATE:

I'm definitely using the Modern C++ code.  I used the code generator in RTI Connext Launcher 5.3.0 to create a new test project using Modern C++ (C++11) for the language and x64Win64VS2015 for the platform.  I went into the main function of the generated code and tried to write the line rti::topic::to_string() and it gave a syntax error saying it can't find to_string() in rti::topic.  Am I referencing the wrong libraries?

jferguson75's picture
Offline
Last seen: 4 years 7 months ago
Joined: 01/28/2020
Posts: 4

OK.  I feel dumb.  It's just rusty C++ experience.

I was missing the #include <rti/topic/to_string.hpp> line in my .h file.

I just thought I'd wrap this up in case someone else read this thread.  Thanks, Alejandro for responding.

Offline
Last seen: 1 week 2 days ago
Joined: 04/02/2013
Posts: 196

Thanks for the update. If you want to include all the API at once, consider including <rti/rti.hpp>. However, including specific headers as you did can speed up the compilation time.

Alex