本文整理汇总了C++中ConnectionReader::isError方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionReader::isError方法的具体用法?C++ ConnectionReader::isError怎么用?C++ ConnectionReader::isError使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionReader
的用法示例。
在下文中一共展示了ConnectionReader::isError方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: read
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bool dynContact::read(ConnectionReader& connection){
// auto-convert text mode interaction
connection.convertTextMode();
// represent a dynContact as a list of 4 elements that are:
// - a list of 3 int, i.e. contactId, bodyPart, linkNumber
// - a list of 3 double, i.e. the CoP
// - a list of 3 double, i.e. the force
// - a list of 3 double, i.e. the moment
if(connection.expectInt()!= BOTTLE_TAG_LIST || connection.expectInt()!=4)
return false;
// - a list of 3 int, i.e. contactId, bodyPart, linkNumber
if(connection.expectInt()!=BOTTLE_TAG_LIST+BOTTLE_TAG_INT || connection.expectInt()!=3)
return false;
contactId = connection.expectInt();
bodyPart = (BodyPart)connection.expectInt();
linkNumber = connection.expectInt();
// - a list of 3 double, i.e. the CoP
if(connection.expectInt()!=BOTTLE_TAG_LIST+BOTTLE_TAG_DOUBLE || connection.expectInt()!=3)
return false;
for(int i=0;i<3;i++) CoP[i] = connection.expectDouble();
// - a list of 3 double, i.e. the force
if(connection.expectInt()!=BOTTLE_TAG_LIST+BOTTLE_TAG_DOUBLE || connection.expectInt()!=3)
return false;
for(int i=0;i<3;i++) F[i] = connection.expectDouble();
setForce(F);
// - a list of 3 double, i.e. the moment
if(connection.expectInt()!=BOTTLE_TAG_LIST+BOTTLE_TAG_DOUBLE || connection.expectInt()!=3)
return false;
for(int i=0;i<3;i++) Mu[i] = connection.expectDouble();
return !connection.isError();
}
示例3: 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;
}
示例4: read
bool Stamp::read(ConnectionReader& connection) {
connection.convertTextMode();
int header = connection.expectInt();
if (header!=BOTTLE_TAG_LIST) { return false; }
int len = connection.expectInt();
if (len!=2) { return false; }
int code;
code = connection.expectInt();
if (code!=BOTTLE_TAG_INT) { return false; }
sequenceNumber = connection.expectInt();
code = connection.expectInt();
if (code!=BOTTLE_TAG_DOUBLE) { return false; }
timeStamp = connection.expectDouble();
if (connection.isError()) {
sequenceNumber = -1;
timeStamp = 0;
return false;
}
return true;
}
示例5: 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);
}
示例6: 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);
}
示例7: read
bool BottleImpl::read(ConnectionReader& reader) {
bool result = false;
if (reader.isTextMode()) {
String str = reader.expectText().c_str();
if (reader.isError()) return false;
bool done = (str.length()<=0);
while (!done) {
if (str[str.length()-1]=='\\') {
str = str.substr(0,str.length()-1);
str += reader.expectText().c_str();
if (reader.isError()) return false;
} else {
if (isComplete(str.c_str())) {
done = true;
} else {
str += "\n";
str += reader.expectText().c_str();
if (reader.isError()) return false;
}
}
}
fromString(str);
result = true;
} else {
#if USE_YARP1_PREFIX
if (!nested) {
int len = reader.expectInt();
if (reader.isError()) return false;
//String name = reader.expectString(len);
String buf(YARP_STRINIT(len));
reader.expectBlock((const char *)buf.c_str(),len);
if (reader.isError()) return false;
String name = buf.c_str();
}
#endif
if (!nested) {
// no byte length any more to facilitate nesting
//reader.expectInt(); // the bottle byte ct; ignored
clear();
specialize(0);
int code = reader.expectInt();
if (reader.isError()) return false;
YMSG(("READ got top level code %d\n", code));
code = code & UNIT_MASK;
if (code!=0) {
specialize(code);
}
}
result = true;
clear();
dirty = true; // for clarity
int len = 0;
int i = 0;
len = reader.expectInt();
if (reader.isError()) return false;
YMSG(("READ got length %d\n", len));
for (i=0; i<len; i++) {
bool ok = fromBytes(reader);
if (!ok) return false;
}
}
return result;
}