本文整理汇总了C++中ConnectionReader::isTextMode方法的典型用法代码示例。如果您正苦于以下问题:C++ ConnectionReader::isTextMode方法的具体用法?C++ ConnectionReader::isTextMode怎么用?C++ ConnectionReader::isTextMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConnectionReader
的用法示例。
在下文中一共展示了ConnectionReader::isTextMode方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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 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;
}
示例3: read
virtual bool read(ConnectionReader& reader) {
YTRACE("NameServer::read start");
ConstString ref = "NAME_SERVER ";
bool ok = true;
ConstString msg = "?";
bool haveMessage = false;
if (ok) {
if (reader.isTextMode()) {
msg = reader.expectText().c_str();
} else {
// migrate to binary mode support, eventually optimize
Bottle b;
b.read(reader);
msg = b.toString().c_str();
}
haveMessage = (msg!="");
msg = ref + msg;
}
if (reader.isActive()&&haveMessage) {
YARP_DEBUG(Logger::get(),ConstString("name server got message ") + msg);
size_t index = msg.find("NAME_SERVER");
if (index==0) {
Contact remote = reader.getRemoteContact();
YARP_DEBUG(Logger::get(),
ConstString("name server receiving from ") +
remote.toURI());
YARP_DEBUG(Logger::get(),
ConstString("name server request is ") + msg);
ConstString result = server->apply(msg,remote);
ConnectionWriter *os = reader.getWriter();
if (os!=YARP_NULLPTR) {
if (result=="") {
result = ns_terminate(ConstString("unknown command ") +
msg + "\n");
}
// This change is just to make Microsoft Telnet happy
ConstString tmp;
for (unsigned int i=0; i<result.length(); i++) {
if (result[i]=='\n') {
tmp += '\r';
}
tmp += result[i];
}
tmp += '\r';
os->appendString(tmp.c_str(),'\n');
YARP_DEBUG(Logger::get(),
ConstString("name server reply is ") + result);
ConstString resultSparse = result;
size_t end = resultSparse.find("\n*** end of message");
if (end!=ConstString::npos) {
resultSparse[end] = '\0';
}
YARP_INFO(Logger::get(),resultSparse);
}
} else {
YARP_INFO(Logger::get(),
ConstString("Name server ignoring unknown command: ")+msg);
ConnectionWriter *os = reader.getWriter();
if (os!=YARP_NULLPTR) {
// this result is necessary for YARP1 support
os->appendString("???????????????????????????????????????",'\n');
//os->flush();
//os->close();
}
}
}
YTRACE("NameServer::read stop");
return true;
}