Yarp: String nightmare in ConnectionReader/Writer

Created on 21 Jan 2019  路  2Comments  路  Source: robotology/yarp

The following methods are problematic:

  • yarp::os::ConnectionReader::expectText(const char terminatingChar = '\n')
  • yarp::os::ConnectionWriter::appendString(const char* str,const char terminatingChar = '\n' )
  • yarp::os::ConnectionWriter::appendRawString(const std::string& s)

Currently, the only proved way to receive a string is as: size+blob of bytes, e.g.

    int string_size = connection.expectInt32();
    this->map_id.resize(string_size);
    connection.expectBlock(const_cast<char*>(this->map_id.data()), string_size);
YARP v3.1.0 Library - YARP_os YARP v3.2.0 API Bug Fixed Deprecation

Most helpful comment

After some investigation, I agree that this part is a nightmare. I'm planning to:

  • Replace ConnectionWriter::appendString with appendText (appendString will be deprecated)
  • Replace ConnectionWriter::appendRawString with appendString (different signature) (appendRawString deprecated)
  • Add ConnectionReader::expectString
  • Cleanup string serialization all around in YARP code. (This includes changing code generated by thift, but since I have a huge refactor on the way, I'm going to change this later).

The goal is to have either appendText -> expectText or appendString -> expectString

Since there are pure interfaces involved, this is going to be a breaking change, but I searched these methods using github search, and they seem to be used only inside YARP.

All 2 comments

After some investigation, I agree that this part is a nightmare. I'm planning to:

  • Replace ConnectionWriter::appendString with appendText (appendString will be deprecated)
  • Replace ConnectionWriter::appendRawString with appendString (different signature) (appendRawString deprecated)
  • Add ConnectionReader::expectString
  • Cleanup string serialization all around in YARP code. (This includes changing code generated by thift, but since I have a huge refactor on the way, I'm going to change this later).

The goal is to have either appendText -> expectText or appendString -> expectString

Since there are pure interfaces involved, this is going to be a breaking change, but I searched these methods using github search, and they seem to be used only inside YARP.

Fixed by #1972

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Nicogene picture Nicogene  路  3Comments

xEnVrE picture xEnVrE  路  3Comments

diegoferigo picture diegoferigo  路  3Comments

drdanz picture drdanz  路  3Comments

traversaro picture traversaro  路  4Comments