65 mPriv(new
Private(count, time, std::move(frameId)))
67 yCAssert(HEADER, mPriv->frameId.find(
' ') == std::string::npos);
76 mPriv(new
Private(*(rhs.mPriv)))
81 mPriv(std::exchange(rhs.mPriv,
nullptr))
93 *mPriv = *(rhs.mPriv);
101 std::swap(mPriv, rhs.mPriv);
108 return mPriv->sequenceNumber;
113 return mPriv->timeStamp;
118 return mPriv->frameId;
123 return mPriv->sequenceNumber !=
npos;
129 std::string stampStr = connection.
expectText();
134 int ret = std::sscanf(stampStr.c_str(),
"%u %lg %n", &seqNum, &ts, &used);
135 if (
ret != 2 && used > 0) {
139 mPriv->sequenceNumber = seqNum;
140 mPriv->timeStamp = ts;
141 mPriv->frameId = stampStr.substr((
size_t)used, stampStr.find(
' ', used));
152 if (len != 2 && len != 3) {
181 yCAssert(HEADER, mPriv->frameId.find(
' ') == std::string::npos);
183 mPriv->frameId.clear();
200 static constexpr
size_t buf_size = 512;
202 if (!mPriv->frameId.empty()) {
203 std::snprintf(buf, buf_size,
"%d %.*g %s", mPriv->sequenceNumber, DBL_DIG, mPriv->timeStamp, mPriv->frameId.c_str());
205 std::snprintf(buf, buf_size,
"%d %.*g", mPriv->sequenceNumber, DBL_DIG, mPriv->timeStamp);
210 connection.
appendInt32(mPriv->frameId.empty() ? 2 : 3);
212 connection.
appendInt32(
static_cast<std::int32_t
>(mPriv->sequenceNumber));
215 if (!mPriv->frameId.empty()) {
236 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.
virtual void appendString(const char *str, const char terminate='\n') final
Send a character sequence 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.