std::string in cmessage

45 views
Skip to first unread message

astriffe

unread,
Apr 22, 2013, 11:44:21 AM4/22/13
to omn...@googlegroups.com
Hello

I wanted to replace an opp_string in my .msg-file with a std::string in order to avoid pointers (serialization). However, opp_msgc creates a compilation error in the .cc-file (method getFieldAsString).

Does anyone know how to fix this or how to include std::strings correctly? You can see the code of my .msg-file below.

What seems strange to me is that getContentName() returns a std::string&...

Any hints are very much appreciated!
TIA!

- Alex


-- DataPkt.msg

cplusplus {{
#include "Signature.h"
#include "SignedInfo.h"
#include "Content.h"
#include <string>
}}

class noncobject Signature;
class noncobject SignedInfo;
class noncobject Content;
class noncobject std::string;


packet DataPkt {
    std::string contentName;
    Signature sig;            // class Signature tbd, string digestAlgorithm, witness, string signature etc.
    SignedInfo siginfo;        // class SignedInfo tbd, string PublisherID, keyLocator, int stale_time etc.
    Content data;            // class Content tbd, int chunk index (version, etc.), char data [], ...
}

Alex Berger

unread,
Apr 26, 2013, 5:23:06 AM4/26/13
to omn...@googlegroups.com
I think only opp_strings, i.e., cstrings, are supported right now by opp_msgc but the omnetpp developers should be able to give you more information. Maybe there is an easy way to make it work.

ruchi shrivastava

unread,
Feb 17, 2017, 4:22:43 AM2/17/17
to OMNeT++ Users
Hi ...You can try changing opp_string to std_string in your .cc file as:
opp_string s;
std :: string p;
p = s.c_str();

i see its been long time since this thread was started. You would have worked it out already :)
Reply all
Reply to author
Forward
0 new messages