66 mPriv(new
Private(count, time,
std::move(frameId)))
68 yCAssert(HEADER, mPriv->frameId.find(
' ') == std::string::npos);
77 mPriv(new
Private(*(rhs.mPriv)))
82 mPriv(std::exchange(rhs.mPriv,
nullptr))
94 *mPriv = *(rhs.mPriv);
102 std::swap(mPriv, rhs.mPriv);
109 return mPriv->sequenceNumber;
114 return mPriv->timeStamp;
119 return mPriv->frameId;
124 return mPriv->sequenceNumber !=
npos;
130 std::string stampStr = connection.
expectText();
135 int ret = std::sscanf(stampStr.c_str(),
"%u %lg %n", &seqNum, &ts, &used);
136 if (
ret != 2 && used > 0) {
140 mPriv->sequenceNumber = seqNum;
141 mPriv->timeStamp = ts;
142 mPriv->frameId = stampStr.substr((
size_t)used, stampStr.find(
' ', used));
153 if (len != 2 && len != 3) {
182 yCAssert(HEADER, mPriv->frameId.find(
' ') == std::string::npos);
184 mPriv->frameId.clear();
201 static constexpr size_t buf_size = 512;
203 if (!mPriv->frameId.empty()) {
204 std::snprintf(buf, buf_size,
"%d %.*g %s", mPriv->sequenceNumber, DBL_DIG, mPriv->timeStamp, mPriv->frameId.c_str());
206 std::snprintf(buf, buf_size,
"%d %.*g", mPriv->sequenceNumber, DBL_DIG, mPriv->timeStamp);
211 connection.
appendInt32(mPriv->frameId.empty() ? 2 : 3);
213 connection.
appendInt32(
static_cast<std::int32_t
>(mPriv->sequenceNumber));
216 if (!mPriv->frameId.empty()) {
237 mPriv->frameId = std::move(
frameId);
#define BOTTLE_TAG_FLOAT64
#define BOTTLE_TAG_STRING
An interface for reading from a network connection.
virtual std::string expectString()
Read a string from the network connection.
virtual bool isTextMode() const =0
Check if the connection is text mode.
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
virtual std::string expectText(const char terminatingChar='\n')=0
Read some text from the network connection.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
virtual bool isError() const =0
virtual yarp::conf::float64_t expectFloat64()=0
Read a 64-bit floating point number from the network connection.
An interface for writing to a network connection.
virtual bool isError() const =0
virtual bool isTextMode() const =0
Check if the connection is text mode.
virtual void appendText(const std::string &str, const char terminate='\n')=0
Send a terminated string to the network connection.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
virtual void appendFloat64(yarp::conf::float64_t data)=0
Send a representation of a 64-bit floating point number to the network connection.
void appendString(const std::string &str)
Send a string to the network connection.
#define yCAssert(component, x)
#define YARP_OS_LOG_COMPONENT(name, name_string)
yarp::rosmsg::std_msgs::Header Header
double now()
Return the current time in seconds, relative to an arbitrary starting point.