34 convertedTextMode(false),
37 parentConnectionReader(nullptr)
43 if (writer !=
nullptr) {
59 this->messageLen = len;
60 this->textMode = textMode;
61 this->bareMode = bareMode;
65 convertedTextMode =
false;
66 pushedIntFlag =
false;
71 this->protocol = protocol;
106 #ifndef YARP_NO_DEPRECATED
112 char* buf =
new char[len];
116 if (r < 0 ||
static_cast<size_t>(r) < b.
length()) {
134 bool success =
false;
135 std::string result = in->
readLine(
'\n', &success);
140 messageLen -= result.length() + 1;
146 if (writer !=
nullptr) {
148 if (str !=
nullptr) {
149 if (protocol !=
nullptr) {
150 protocol->
reply(*writer);
158 writePending =
false;
168 reset(*in, str, route, len, textMode, bareMode);
182 pushedIntFlag =
true;
187 template <
typename T,
typename NetT>
188 inline T StreamConnectionReader::expectType()
195 if (r < 0 ||
static_cast<size_t>(r) < b.length()) {
199 messageLen -= b.length();
201 return static_cast<T
>(x);
209 return expectType<std::int8_t, NetInt8>();
217 return expectType<std::int16_t, NetInt16>();
223 pushedIntFlag =
false;
229 return expectType<std::int32_t, NetInt32>();
237 return expectType<std::int64_t, NetInt64>();
245 return expectType<yarp::conf::float32_t, NetFloat32>();
253 return expectType<yarp::conf::float64_t, NetFloat64>();
268 bool lsuccess =
false;
269 std::string result = in->
readLine(terminatingChar, &lsuccess);
271 messageLen -= result.length() + 1;
289 if (!convertedTextMode) {
297 convertedTextMode =
true;
306 if (str ==
nullptr) {
309 if (writer ==
nullptr) {
315 if (protocol !=
nullptr) {
323 if (str !=
nullptr) {
334 if (str !=
nullptr) {
378 if (protocol !=
nullptr) {
380 return {
const_cast<char*
>(env.c_str()), env.length()};
382 if (parentConnectionReader !=
nullptr) {
395 if (config.
size() == 0) {
396 if (protocol !=
nullptr) {
405 this->parentConnectionReader = parentConnectionReader;
408 bool StreamConnectionReader::isGood()
A simple collection of objects that can be described and transmitted in a portable way.
size_type size() const
Gets the number of elements in the bottle.
bool read(ConnectionReader &reader) override
Set the bottle's value based on input from a network connection.
bool write(ConnectionWriter &writer) const override
Output a representation of the bottle to a network connection.
A simple abstraction for a block of bytes.
An interface for reading from a network connection.
virtual Bytes readEnvelope()
Read a message envelope, if available.
An interface for writing to a network connection.
This is a base class for objects that can be both read from and be written to the YARP network.
Information about a connection between two ports.
const std::string & getToName() const
Get the destination of the route.
const std::string & getCarrierName() const
Get the carrier type of the route.
const std::string & getFromName() const
Get the source of the route.
A base class for nested structures that can be searched.
A stream which can be asked to perform bidirectional communication.
virtual OutputStream & getOutputStream()=0
Get an OutputStream to write to.
virtual const Contact & getLocalAddress() const =0
Get the address of the local side of the stream.
virtual const Contact & getRemoteAddress() const =0
Get the address of the remote side of the stream.
A helper for creating cached object descriptions.
std::string toString() const
bool write(ConnectionWriter &connection) const override
Write this object to a network connection.
void clear() override
Clear all cached data.
Connection choreographer.
std::string getSenderSpecifier() const override
Extract a name for the sender, if the connection type supports that.
const std::string & getEnvelope() const override
Read the envelope associated with the current message.
void reply(SizedWriter &writer) override
Reply to a message we have just read.
void willReply()
Promise that we'll be making a reply.
virtual std::string expectString()
Read a string from the network connection.
std::int64_t expectInt64() override
Read a 64-bit integer from the network connection.
yarp::os::Contact getRemoteContact() const override
Gets information about who is supplying the data being read, if that information is available.
bool convertTextMode() override
Reads in a standard description in text mode, and converts it to a standard description in binary.
void setParentConnectionReader(ConnectionReader *parentConnectionReader) override
Set ConnectionReader to be used for reading the envelope.
bool isActive() const override
yarp::os::ConnectionWriter * getWriter() override
Gets a way to reply to the message, if possible.
bool pushInt(int x) override
Store an integer to return on the next call to expectInt()
void setProtocol(Protocol *protocol)
bool isBareMode() const override
Check if the connection is bare mode.
std::int16_t expectInt16() override
Read a 16-bit integer from the network connection.
yarp::conf::float64_t expectFloat64() override
Read a 64-bit floating point number from the network connection.
yarp::os::Contact getLocalContact() const override
Gets information about who is receiving the data, if that information is available.
const yarp::os::Searchable & getConnectionModifiers() const override
Access modifiers associated with the connection, if any.
virtual std::string expectLine()
size_t getSize() const override
Checks how much data is available.
std::string expectText(const char terminatingChar) override
Read some text from the network connection.
std::int8_t expectInt8() override
Read a 8-bit integer from the network connection.
yarp::conf::float32_t expectFloat32() override
Read a 32-bit floating point number from the network connection.
virtual void flushWriter()
yarp::os::Bytes readEnvelope() override
Read a message envelope, if available.
bool isValid() const override
void reset(yarp::os::InputStream &in, TwoWayStream *str, const Route &route, size_t len, bool textMode, bool bareMode=false)
bool isError() const override
virtual ~StreamConnectionReader()
virtual bool expectBlock(yarp::os::Bytes &b)
bool isTextMode() const override
Check if the connection is text mode.
yarp::os::Portable * getReference() const override
Get a direct pointer to the object being sent, if possible.
virtual void setReference(yarp::os::Portable *obj)
std::int32_t expectInt32() override
Read a 32-bit integer from the network connection.
void requestDrop() override
Tag the connection to be dropped after the current message.
bool setSize(size_t len) override
The components from which ports and connections are built.
An interface to the operating system, including Port based communication.
std::int32_t NetInt32
Definition of the NetInt32 type.