本文整理汇总了C++中DummyConnector::setTextMode方法的典型用法代码示例。如果您正苦于以下问题:C++ DummyConnector::setTextMode方法的具体用法?C++ DummyConnector::setTextMode怎么用?C++ DummyConnector::setTextMode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DummyConnector
的用法示例。
在下文中一共展示了DummyConnector::setTextMode方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: write
bool Bottle::write(PortReader& reader, bool textMode)
{
DummyConnector con;
con.setTextMode(textMode);
write(con.getWriter());
return reader.read(con.getReader());
}
示例2: testEmptyList
void testEmptyList() {
// based on a case submitted by Stephane Lallee; doesn't appear to
// fail here as he sees going from TCL to C++
report(0,"test empty list");
Bottle b;
b.fromString("appp plan-clean (\"<Plan>\" \"<Names>\" cover \"</Names>\" \"<isAtomic>\" 1 \"</isAtomic>\" \"<motorCommand>\" () \"</motorCommand>\" \"<Primitive>\" (cover 28988.470168 \"<args>\" \"7106\" \"7103\" \"</args>\" \"<argsRole>\" object1 arg2 object2 arg1 subject \"7107\" \"</argsRole>\" \"<preReqRelations>\" \"</preReqRelations>\" \"<preForRelations>\" \"</preForRelations>\" \"<postAddRelations>\" \"</postAddRelations>\" \"<postRemRelations>\" \"</postRemRelations>\" \"<addRelations>\" \"</addRelations>\" \"<remRelations>\" visible null arg2 \"</remRelations>\") \"</Primitive>\" \"<SubPlans>\" \"</SubPlans>\" \"</Plan>\")");
Bottle b2 = b;
checkEqual(b2.size(),3,"copy ok level 1");
Bottle *sub = b2.get(2).asList();
checkTrue(sub!=NULL,"list where list expected");
if (sub!=NULL) {
checkEqual(sub->size(),16,"copy ok level 2");
}
DummyConnector con;
con.setTextMode(false);
b.write(con.getWriter());
Bottle b3;
b3.read(con.getReader());
checkEqual(b3.size(),b.size(),"binary read/write ok");
sub = b3.get(2).asList();
checkTrue(sub!=NULL,"list where list expected");
if (sub!=NULL) {
checkEqual(sub->size(),16,"copy ok level 2");
}
}
示例3: write
bool BufferedConnectionWriter::write(PortReader& obj)
{
DummyConnector con;
con.setTextMode(isTextMode());
if (!write(con.getWriter()))
return false;
return obj.read(con.getReader());
}
示例4: read
bool Bottle::read(const PortWriter& writer, bool textMode)
{
implementation->edit();
DummyConnector con;
con.setTextMode(textMode);
writer.write(con.getWriter());
return read(con.getReader());
}
示例5:
bool yarp::os::impl::HttpCarrier::write(Protocol& proto, SizedWriter& writer) {
DummyConnector con;
con.setTextMode(true);
for (size_t i=writer.headerLength(); i<writer.length(); i++) {
con.getWriter().appendBlock(writer.data(i),writer.length(i));
}
Bottle b;
b.read(con.getReader());
ConstString body = b.find("web").toString();
if (body.length()!=0) {
ConstString header;
header += NetType::toHexString(body.length()).c_str();
header += "\r\n";
Bytes b2((char*)header.c_str(),header.length());
proto.os().write(b2);
Bytes b3((char*)body.c_str(),body.length());
proto.os().write(b3);
proto.os().write('\r');
proto.os().write('\n');
} else {
ConstString txt = b.toString() + "\r\n";
ConstString header;
header += NetType::toHexString(txt.length()).c_str();
header += "\r\n";
Bytes b2((char*)header.c_str(),header.length());
proto.os().write(b2);
Bytes b3((char*)txt.c_str(),txt.length());
proto.os().write(b3);
proto.os().write('\r');
proto.os().write('\n');
}
proto.os().flush();
return proto.os().isOk();
}
示例6: header
bool yarp::os::impl::HttpCarrier::reply(Protocol& proto, SizedWriter& writer) {
DummyConnector con;
con.setTextMode(true);
for (size_t i=writer.headerLength(); i<writer.length(); i++) {
con.getWriter().appendBlock(writer.data(i),writer.length(i));
}
Bottle b;
b.read(con.getReader());
ConstString mime = b.check("mime",Value("text/html")).asString();
ConstString body;
bool using_json = false;
if (stream!=NULL) {
if (stream->useJson()) {
mime = "text/json";
asJson(body,&b,stream->typeHint());
using_json = true;
}
}
if (b.check("web")&&!using_json) {
body = b.find("web").toString();
}
if (b.check("stream")&&!using_json) {
String header("HTTP/1.1 200 OK\r\nContent-Type: ");
header += mime;
header += "\r\n";
header += "Transfer-Encoding: chunked\r\n";
header += "\r\n";
int N = 2*1024;
header += NetType::toHexString(body.length()+N);
header += "\r\n";
Bytes b2((char*)header.c_str(),header.length());
proto.os().write(b2);
// chrome etc won't render until enough chars are received.
for (int i=0; i<N; i++) {
proto.os().write(' ');
}
Bytes b3((char*)body.c_str(),body.length());
proto.os().write(b3);
proto.os().write('\r');
proto.os().write('\n');
if (stream!=NULL) {
stream->flip();
}
return true;
}
if (stream!=NULL) {
stream->finish();
}
// Could check response codes, mime types here.
if (body.length()!=0 || using_json) {
ConstString mime = b.check("mime",Value("text/html")).asString();
String header("HTTP/1.1 200 OK\nContent-Type: ");
header += mime;
header += "\n";
header += "Access-Control-Allow-Origin: *\n";
header += "\n";
Bytes b2((char*)header.c_str(),header.length());
proto.os().write(b2);
//body = b.toString();
Bytes b3((char*)body.c_str(),body.length());
proto.os().write(b3);
} else {
writer.write(proto.os());
}
proto.os().flush();
return proto.os().isOk();
}