本文整理汇总了C++中ConnectionReader类的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionReader类的具体用法?C++ ConnectionReader怎么用?C++ ConnectionReader使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConnectionReader类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readRaw
bool StoreBlob::readRaw(ConnectionReader& reader) {
int len = reader.expectInt();
String buf(YARP_STRINIT(len));
reader.expectBlock((const char *)buf.c_str(),len);
x = buf;
return true;
}
示例2: readRaw
bool StoreBlob::readRaw(ConnectionReader& reader)
{
std::int32_t len = reader.expectInt32();
x.resize(len);
reader.expectBlock(const_cast<char*>(x.data()), len);
return true;
}
示例3: read
bool DeviceResponder::read(ConnectionReader& connection) {
Bottle cmd, response;
if (!cmd.read(connection)) { return false; }
//printf("command received: %s\n", cmd.toString().c_str());
respond(cmd,response);
if (response.size()>=1) {
ConnectionWriter *writer = connection.getWriter();
if (writer!=NULL) {
if (response.get(0).toString()=="many"&&writer->isTextMode()) {
for (int i=1; i<response.size(); i++) {
Value& v = response.get(i);
if (v.isList()) {
v.asList()->write(*writer);
} else {
Bottle b;
b.add(v);
b.write(*writer);
}
}
} else {
response.write(*writer);
}
//printf("response sent: %s\n", response.toString().c_str());
}
} else {
ConnectionWriter *writer = connection.getWriter();
if (writer!=NULL) {
response.clear();
response.addVocab(Vocab::encode("nak"));
response.write(*writer);
}
}
return true;
}
示例4: read
virtual bool read(ConnectionReader& connection)
{
unsigned int incoming;
bool ok = connection.expectBlock((char*)&datum, sizeof(double));
ok=ok&&connection.expectBlock((char*)&incoming, sizeof(int));
//this resize only if needed
resize(incoming);
if (payloadSize>0)
ok=ok&&connection.expectBlock((char *)payload, payloadSize);
return ok;
}
示例5: getBusStats
bool yarp::os::Node::Helper::read(ConnectionReader& reader)
{
if (!reader.isValid()) {
return false;
}
NodeArgs na;
na.request.read(reader);
//printf("NODE API for %s received %s\n",
//name.c_str(),
//na.request.toString().c_str());
std::string key = na.request.get(0).asString();
na.args = na.request.tail().tail();
if (key=="getBusStats") {
getBusStats(na);
} else if (key=="getBusInfo") {
getBusInfo(na);
} else if (key=="getMasterUri") {
getMasterUri(na);
} else if (key=="shutdown") {
shutdown(na);
} else if (key=="getPid") {
getPid(na);
} else if (key=="getSubscriptions") {
getSubscriptions(na);
} else if (key=="getPublications") {
getPublications(na);
} else if (key=="paramUpdate") {
paramUpdate(na);
} else if (key=="publisherUpdate") {
publisherUpdate(na);
} else if (key=="requestTopic") {
requestTopic(na);
} else {
na.error("I have no idea what you are talking about");
}
if (na.should_drop) {
reader.requestDrop(); // ROS likes to close down.
}
if (reader.getWriter()) {
Bottle full;
full.addInt32(na.code);
full.addString(na.msg);
full.add(na.reply);
//printf("NODE %s <<< %s\n",
//name.c_str(),
//full.toString().c_str());
full.write(*reader.getWriter());
}
return true;
}
示例6: read
bool RFModuleHelper::read(ConnectionReader& connection) {
Bottle cmd, response;
if (!cmd.read(connection)) { return false; }
printf("command received: %s\n", cmd.toString().c_str());
bool result = owner.safeRespond(cmd,response);
if (response.size()>=1) {
ConnectionWriter *writer = connection.getWriter();
if (writer!=0) {
if (response.get(0).toString()=="many" && writer->isTextMode()) {
for (int i=1; i<response.size(); i++) {
Value& v = response.get(i);
if (v.isList()) {
v.asList()->write(*writer);
} else {
Bottle b;
b.add(v);
b.write(*writer);
}
}
} else {
response.write(*writer);
}
//printf("response sent: %s\n", response.toString().c_str());
}
}
return result;
}
示例7: read
virtual bool read(ConnectionReader& connection) {
Bottle cmd, response;
cmd.read(connection);
printf("command received: %s\n", cmd.toString().c_str());
int code = cmd.get(0).asVocab();
switch (code) {
case VOCAB3('s','e','t'):
printf("set command received\n");
prop.put(cmd.get(1).asString().c_str(),cmd.get(2));
break;
case VOCAB3('g','e','t'):
printf("get command received\n");
response.addVocab(VOCAB2('i','s'));
response.add(cmd.get(1));
response.add(prop.find(cmd.get(1).asString().c_str()));
break;
}
if (response.size()>=1) {
ConnectionWriter *writer = connection.getWriter();
if (writer!=NULL) {
response.write(*writer);
printf("response sent: %s\n", response.toString().c_str());
}
}
}
示例8: read
bool Storable::read(ConnectionReader& connection)
{
std::int32_t x = connection.expectInt32();
if (x != getCode()) {
return false;
}
return readRaw(connection);
}
示例9: reader
WireReader::WireReader(ConnectionReader& reader) : reader(reader)
{
reader.convertTextMode();
state = &baseState;
flush_if_needed = false;
get_mode = false;
support_get_mode = false;
expecting = false;
}
示例10: read
virtual bool read(ConnectionReader& connection) {
Bottle receive;
receive.read(connection);
receive.addInt(5);
ConnectionWriter *writer = connection.getWriter();
if (writer!=NULL) {
receive.write(*writer);
}
return true;
}
示例11: fromBytes
bool BottleImpl::fromBytes(ConnectionReader& reader) {
if (reader.isError()) return false;
int id = speciality;
YMSG(("READING, nest flag is %d\n", nested));
if (id==0) {
id = reader.expectInt();
YMSG(("READ subcode %d\n", id));
} else {
YMSG(("READ skipped subcode %d\n", speciality));
}
Storable *storable = Storable::createByCode(id);
if (storable==NULL) {
YARP_SPRINTF1(Logger::get(),error,"BottleImpl reader failed, unrecognized object code %d",id);
return false;
}
storable->readRaw(reader);
add(storable);
return true;
}
示例12: readFromConnection
/**
* This helper function groups code to avoid duplication. It is not a member function of Image because
* there are problems with ImageNetworkHeader, anyhow the function is state-less and uses only parameters.
*/
inline bool readFromConnection(Image &dest, ImageNetworkHeader &header, ConnectionReader& connection)
{
dest.resize(header.width, header.height);
unsigned char *mem = dest.getRawImage();
int allocatedBytes = dest.getRawImageSize();
yAssert(mem != NULL);
//this check is redundant with assertion, I would remove it
if (dest.getRawImageSize() != header.imgSize) {
printf("There is a problem reading an image\n");
printf("incoming: width %d, height %d, code %d, quantum %d, size %d\n",
(int)header.width, (int)header.height,
(int)header.id,
(int)header.quantum, (int)header.imgSize);
printf("my space: width %d, height %d, code %d, quantum %d, size %d\n",
dest.width(), dest.height(), dest.getPixelCode(), dest.getQuantum(), allocatedBytes);
}
yAssert(allocatedBytes == header.imgSize);
bool ok = connection.expectBlock((char *)mem, allocatedBytes);
return (!connection.isError() && ok);
}
示例13: read
virtual bool read(ConnectionReader& connection) {
Bottle b,r;
bool ok = b.read(connection);
if (!ok) return false;
stackWrap->onTick();
r.addString("tack");
ConnectionWriter *returnToSender = connection.getWriter();
if (returnToSender != NULL)
r.write(*returnToSender);
return true;
}
示例14: read
bool PortCommand::read(ConnectionReader& reader) {
//ACE_DEBUG((LM_DEBUG,"PortCommand::readBlock"));
ch = '\0';
str = "";
if (!reader.isTextMode()) {
bool ok = reader.expectBlock(header.get(),header.length());
if (!ok) return false;
char *base = header.get();
if (base[4] == '~') {
ch = base[5];
if (ch=='\0') {
//str = reader.expectString(reader.getSize());
str = reader.expectText('\0').c_str();
if (reader.isError()) return false;
if (str.length()>0) {
ch = str[0];
}
}
} else {
return false;
}
} else {
str = reader.expectText().c_str();
if (reader.isError()) return false;
if (str.length()>0) {
ch = str[0];
}
}
return true;
}
示例15: read
bool Value::read(ConnectionReader& connection) {
if (proxy) {
delete proxy;
proxy = 0;
}
int x = connection.expectInt();
if ((x&0xffff) != x) return false;
if (!(x&BOTTLE_TAG_LIST)) return false;
int len = connection.expectInt();
if (len==0) return true;
if (len!=1) return false;
if (x==BOTTLE_TAG_LIST) {
x = connection.expectInt();
} else {
x &= ~BOTTLE_TAG_LIST;
}
if (connection.isError()) return false;
Storable *s = Storable::createByCode(x);
setProxy(s);
if (!proxy) return false;
return s->readRaw(connection);
}