本文整理汇总了C++中StringOutputStream::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ StringOutputStream::toString方法的具体用法?C++ StringOutputStream::toString怎么用?C++ StringOutputStream::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringOutputStream
的用法示例。
在下文中一共展示了StringOutputStream::toString方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: testWriteHelp
void CommandLineTestBase::testWriteHelp(ICommandLineModule *module)
{
StringOutputStream stream;
CommandLineHelpContext context(&stream, eHelpOutputFormat_Console, nullptr, "test");
context.setModuleDisplayName(formatString("%s %s", "test", module->name()));
module->writeHelp(context);
TestReferenceChecker checker(rootChecker());
checker.checkTextBlock(stream.toString(), "HelpOutput");
}
示例2: testWrite
void testWrite() {
report(0,"testing writing...");
StringOutputStream sos;
char txt[] = "Hello my friend";
Bytes b(txt,ACE_OS::strlen(txt));
sos.write(b);
checkEqual(txt,sos.toString(),"single write");
StringOutputStream sos2;
sos2.write('y');
sos2.write('o');
checkEqual("yo",sos2.toString(),"multiple writes");
}
示例3: Selection_SnapToGrid
void Selection_SnapToGrid (void)
{
StringOutputStream command;
command << "snapSelected -grid " << GlobalGrid().getGridSize();
UndoableCommand undo(command.toString());
if (GlobalSelectionSystem().Mode() == SelectionSystem::eComponent) {
GlobalSceneGraph().traverse(ComponentSnappableSnapToGridSelected(GlobalGrid().getGridSize()));
} else {
GlobalSceneGraph().traverse(SnappableSnapToGridSelected(GlobalGrid().getGridSize()));
}
}
示例4: getBlock
std::string MaterialSystem::getBlock (const std::string& texture)
{
if (texture.empty())
return "";
const std::string textureDir = GlobalTexturePrefix_get();
std::string skippedTextureDirectory = texture.substr(textureDir.length());
if (skippedTextureDirectory.empty())
return "";
MaterialBlockMap::iterator i = _blocks.find(skippedTextureDirectory);
if (i != _blocks.end())
return i->second;
if (!_materialLoaded)
loadMaterials();
if (!_materialLoaded)
return "";
StringOutputStream outputStream;
StringInputStream inputStream(_material);
AutoPtr<Tokeniser> tokeniser(GlobalScriptLibrary().createSimpleTokeniser(inputStream));
int depth = 0;
bool found = false;
std::string token = tokeniser->getToken();
while (token.length()) {
if (token == "{") {
depth++;
} else if (token == "}") {
depth--;
}
if (depth >= 1) {
if (depth == 1 && token == "material") {
token = tokeniser->getToken();
if (token == skippedTextureDirectory) {
found = true;
outputStream << "{ material ";
}
}
if (found)
outputStream << token << " ";
} else if (found) {
outputStream << "}";
break;
}
token = tokeniser->getToken();
}
return outputStream.toString();
}
示例5: endMove
// End the move, this freezes the current transforms
void RadiantSelectionSystem::endMove() {
freezeTransforms();
// greebo: Deselect all faces if we are in brush and drag mode
if (Mode() == ePrimitive) {
if (ManipulatorMode() == eDrag) {
GlobalSceneGraph().traverse(SelectAllComponentWalker(false, SelectionSystem::eFace));
//Scene_SelectAll_Component(false, SelectionSystem::eFace);
}
}
// Remove all degenerated brushes from the scene graph (should emit a warning)
GlobalSceneGraph().traverse(RemoveDegenerateBrushWalker());
_pivotMoving = false;
pivotChanged();
// Update the views
SceneChangeNotify();
// If we started an undoable operation, end it now and tell the console what happened
if (_undoBegun) {
StringOutputStream command;
if (ManipulatorMode() == eTranslate) {
command << "translateTool";
outputTranslation(command);
}
else if (ManipulatorMode() == eRotate) {
command << "rotateTool";
outputRotation(command);
}
else if (ManipulatorMode() == eScale) {
command << "scaleTool";
outputScale(command);
}
else if (ManipulatorMode() == eDrag) {
command << "dragTool";
}
// Finish the undo move
GlobalUndoSystem().finish(command.toString());
}
}
示例6: write
bool WireTwiddler::write(yarp::os::Bottle& bot,
yarp::os::ManagedBytes& data) {
StringOutputStream sos;
if (!writer) {
writer = ConnectionWriter::createBufferedConnectionWriter();
}
if (!writer) {
return false;
}
SizedWriter *buf = writer->getBuffer();
if (!buf) {
return false;
}
buf->clear();
bot.write(*writer);
WireTwiddlerWriter twiddled_output(*buf,*this);
twiddled_output.write(sos);
std::string result = sos.toString();
data = ManagedBytes(Bytes((char*)result.c_str(),result.length()),false);
data.copy();
return true;
}
示例7: write
bool XmlRpcCarrier::write(Protocol& proto, SizedWriter& writer) {
//XmlRpc::setVerbosity(10);
StringOutputStream sos;
StringInputStream sis;
writer.write(sos);
sis.reset(sos.toString());
String header;
if (sender) {
header = NetType::readLine(sis);
}
String body = NetType::readLine(sis);
//printf("Asked to write: hdr %s body %s\n",
// header.c_str(), body.c_str());
Value v;
//printf("HEADER %s\n", header.c_str());
if (header[0]=='q') {
body = "yarp.quit";
// XMLRPC does not need a quit message, this should get stripped
return false;
}
Bottle *bot = v.asList();
//Bottle aux;
bot->fromString(body.c_str());
ConstString methodName;
if (sender) {
methodName = bot->get(0).toString();
*bot = bot->tail();
}
XmlRpcValue args;
if (bot->size()==1) {
toXmlRpcValue(bot->get(0),args);
} else {
toXmlRpcValue(v,args);
}
//printf("xmlrpc block to write is %s\n", args.toXml().c_str());
std::string req;
if (sender) {
const Address& addr = host.isValid()?host:proto.getStreams().getRemoteAddress();
XmlRpcClient c(addr.getName().c_str(),(addr.getPort()>0)?addr.getPort():80);
c.generateRequest(methodName.c_str(),args);
req = c.getRequest();
} else {
XmlRpcServerConnection c(0,NULL);
c.generateResponse(args.toXml());
req = c.getResponse();
}
int start = 0;
//printf("converts to %s\n", req.c_str());
if (sender) {
if (req.length()<8) {
fprintf(stderr, "XmlRpcCarrier fail, %s:%d\n", __FILE__, __LINE__);
return false;
}
for (int i=0; i<(int)req.length(); i++) {
if (req[i] == '\n') {
start++;
break;
}
start++;
}
if (!firstRound) {
Bytes b((char*)http.c_str(),http.length());
proto.os().write(b);
}
firstRound = false;
}
Bytes b((char*)req.c_str()+start,req.length()-start);
//printf("WRITING [%s]\n", req.c_str()+start);
proto.os().write(b);
return proto.os().isOk();
}
示例8: write
bool XmlRpcCarrier::write(ConnectionState& proto, SizedWriter& writer) {
StringOutputStream sos;
StringInputStream sis;
writer.write(sos);
sis.reset(sos.toString());
ConstString header;
if (sender) {
header = sis.readLine();
}
ConstString body = sis.readLine();
Value v;
if (header.length()>0 && header[0]=='q') {
body = "yarp.quit";
// XMLRPC does not need a quit message, this should get stripped
return false;
}
Bottle *bot = v.asList();
bot->fromString(body.c_str());
ConstString methodName;
if (sender) {
methodName = bot->get(0).toString();
*bot = bot->tail();
}
XmlRpcValue args;
if (bot->size()==1) {
toXmlRpcValue(bot->get(0),args);
} else {
toXmlRpcValue(v,args);
}
std::string req;
if (sender) {
const Contact& addr = host.isValid()?host:proto.getStreams().getRemoteAddress();
XmlRpcClient c(addr.getHost().c_str(),(addr.getPort()>0)?addr.getPort():80);
c.generateRequest(methodName.c_str(),args);
req = c.getRequest();
} else {
XmlRpcServerConnection c(0,NULL);
c.generateResponse(args.toXml());
req = c.getResponse();
}
int start = 0;
if (sender) {
if (req.length()<8) {
fprintf(stderr, "XmlRpcCarrier fail, %s:%d\n", __FILE__, __LINE__);
return false;
}
for (int i=0; i<(int)req.length(); i++) {
if (req[i] == '\n') {
start++;
break;
}
start++;
}
if (!firstRound) {
Bytes b((char*)http.c_str(),http.length());
proto.os().write(b);
}
firstRound = false;
}
Bytes b((char*)req.c_str()+start,req.length()-start);
proto.os().write(b);
return proto.os().isOk();
}