31 convertedTextMode(
false),
34 parentConnectionReader(nullptr)
40 if (writer !=
nullptr) {
56 this->messageLen = len;
57 this->textMode = textMode;
58 this->bareMode = bareMode;
62 convertedTextMode =
false;
63 pushedIntFlag =
false;
68 this->protocol = protocol;
103#ifndef YARP_NO_DEPRECATED
109 char* buf =
new char[len];
113 if (r < 0 ||
static_cast<size_t>(r) < b.
length()) {
131 bool success =
false;
132 std::string result = in->
readLine(
'\n', &success);
137 messageLen -= result.length() + 1;
143 if (writer !=
nullptr) {
145 if (str !=
nullptr) {
146 if (protocol !=
nullptr) {
147 protocol->
reply(*writer);
155 writePending =
false;
165 reset(*in, str, route, len, textMode, bareMode);
179 pushedIntFlag =
true;
184template <
typename T,
typename NetT>
185inline T StreamConnectionReader::expectType()
192 if (r < 0 ||
static_cast<size_t>(r) < b.length()) {
196 messageLen -= b.length();
198 return static_cast<T
>(x);
220 pushedIntFlag =
false;
268 messageLen -= result.length() + 1;
286 if (!convertedTextMode) {
294 convertedTextMode =
true;
303 if (str ==
nullptr) {
306 if (writer ==
nullptr) {
312 if (protocol !=
nullptr) {
320 if (str !=
nullptr) {
331 if (str !=
nullptr) {
375 if (protocol !=
nullptr) {
377 return {
const_cast<char*
>(
env.c_str()),
env.length()};
379 if (parentConnectionReader !=
nullptr) {
392 if (config.
size() == 0) {
393 if (protocol !=
nullptr) {
402 this->parentConnectionReader = parentConnectionReader;
405bool 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 mini-server for performing network communication in the background.
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 const Contact & getRemoteAddress() const =0
Get the address of the remote side of the stream.
virtual const Contact & getLocalAddress() const =0
Get the address of the local side of the stream.
virtual OutputStream & getOutputStream()=0
Get an OutputStream to write to.
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.
void flushWriter() override
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.