本文整理汇总了C++中Bottle::toString方法的典型用法代码示例。如果您正苦于以下问题:C++ Bottle::toString方法的具体用法?C++ Bottle::toString怎么用?C++ Bottle::toString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bottle
的用法示例。
在下文中一共展示了Bottle::toString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: insertFeedback
/*
* create the vAugmentedTime for the current used Instance : sql to obtain the foreign key for the feedback table
*
*/
bool abmInteraction::insertFeedback(int feedback, int feedbackInstance)
{
Bottle bResult;
ostringstream osRequest;
//take info from visualdata to put in feedback. In particular the time of original memories is the smallest one from augmented
osRequest << "SELECT DISTINCT instance, augmented_time, img_provider_port, min(\"time\") FROM visualdata WHERE instance = " << rememberedInstance << " AND augmented IS NOT NULL AND augmented_time = '" << *it_augmentedTime << "' AND img_provider_port = '" << img_provider_port << "' GROUP BY instance, augmented_time, img_provider_port;";
bResult = iCub->getABMClient()->requestFromString(osRequest.str());
yInfo() << bResult.toString();
if (bResult.toString() != "NULL") {
//we should only have one line, because instance,augmented_time,img_provider_port is primary key
Bottle bResInsert;
ostringstream osInsertFeedback;
osInsertFeedback << "INSERT INTO feedback VALUES (" << feedbackInstance << ", '" << bResult.get(0).asList()->get(1).toString() << "', '" << bResult.get(0).asList()->get(2).toString() << "', '" << bResult.get(0).asList()->get(3).toString() << "', '" << agentName << "', " << feedback << ", 'none');";
bResInsert = iCub->getABMClient()->requestFromString(osInsertFeedback.str().c_str());
yInfo() << " Request sent : " << osInsertFeedback.str();
}
else {
yError() << "Request to obtain augmented from instance " << rememberedInstance << " with augmented_time = " << *it_augmentedTime << " is NULL";
return false;
}
return true;
}
示例2: run
void RosNameSpace::run() {
int pct = 0;
do {
mutex.wait();
pct = pending.size();
mutex.post();
if (pct>0) {
mutex.wait();
Bottle *bot = pending.get(0).asList();
Bottle curr = *bot;
mutex.post();
dbg_printf("ROS connection begins: %s\n", curr.toString().c_str());
ContactStyle style;
style.admin = true;
style.carrier = "tcp";
Bottle cmd = curr.tail();
Contact contact = Contact::fromString(curr.get(0).asString());
contact.setName("");
Bottle reply;
NetworkBase::write(contact, cmd, reply, style);
dbg_printf("ROS connection ends: %s\n", curr.toString().c_str());
mutex.wait();
pending = pending.tail();
pct = pending.size();
mutex.post();
}
} while (pct>0);
}
示例3: handleSearch
bool TouchingOrder::handleSearch(string type, string target)
{
// look if the object (from human order) exist and if not, trigger proactivetagging
iCub->opc->checkout();
yInfo() << " [handleSearch] : opc checkout";
Object *o = dynamic_cast<Object*>(iCub->opc->getEntity(target));
if(o!=NULL) {
yInfo() << "I found the entity in the opc: " << target << " and thus I'll leave handleSearch";
return true;
}
yInfo() << "I need to call proactiveTagging!";// << endl;
//If there is an unknown object (to see with agents and rtobjects), add it to the rpc_command bottle, and return true
Bottle cmd;
Bottle rply;
cmd.addString("searchingEntity");
cmd.addString(type);
cmd.addString(target);
yDebug() << "Send to proactiveTagging: " << cmd.toString();
rpc_out_port.write(cmd,rply);
yDebug() << rply.toString(); //<< endl;
return true;
}
示例4: checkAccept
void checkAccept() {
report(0, "checking direct object accept...");
PortReaderBuffer<Bottle> buffer;
Bottle dummy;
Bottle data("hello");
Bottle data2("there");
buffer.acceptObject(&data, &dummy);
Bottle *bot = buffer.read();
checkTrue(bot!=NULL,"Inserted message received");
if (bot!=NULL) {
checkEqual(bot->toString().c_str(),"hello","value ok");
}
buffer.acceptObject(&data2, NULL);
bot = buffer.read();
checkTrue(bot!=NULL,"Inserted message received");
if (bot!=NULL) {
checkEqual(bot->toString().c_str(),"there","value ok");
}
buffer.read(false);
}
示例5: main
int main(int argc, char *argv[]) {
if (argc<3) {
fprintf(stderr, "Please supply (1) a port name for the client\n");
fprintf(stderr, " (2) a port name for the server\n");
return 1;
}
Network yarp;
const char *client_name = argv[1];
const char *server_name = argv[2];
RpcClient port;
port.open(client_name);
int ct = 0;
while (true) {
if (port.getOutputCount()==0) {
printf("Trying to connect to %s\n", server_name);
yarp.connect(client_name,server_name);
} else {
Bottle cmd;
cmd.addString("COUNT");
cmd.addInt32(ct);
ct++;
printf("Sending message... %s\n", cmd.toString().c_str());
Bottle response;
port.write(cmd,response);
printf("Got response: %s\n", response.toString().c_str());
}
Time::delay(1);
}
}
示例6: RateThread
//*************************************************************************************************************************
MotorFrictionExcitationThread::MotorFrictionExcitationThread(string _name, string _robotName, int _period, ParamHelperServer *_ph,
wholeBodyInterface *_wbi, ResourceFinder &rf, ParamHelperClient *_identificationModule)
: RateThread(_period), name(_name), robotName(_robotName), paramHelper(_ph), robot(_wbi), identificationModule(_identificationModule)
{
status = EXCITATION_OFF;
sendCmdToMotors = SEND_COMMANDS_TO_MOTORS;
printCountdown = 0;
freeExcCounter = 0;
contactExcCounter = 0;
fricStdDevThrMonitor = 0.0;
ktStdDevThrMonitor = 0.0;
_n = robot->getDoFs();
isFrictionStdDevBelowThreshold = false;
Bottle reply;
if(!contactExc.readFromConfigFile(rf, reply))
printf("Error while reading contact excitation from config file: \n%s\n", reply.toString().c_str());
printf("Results of contact excitation reading: %s\n", reply.toString().c_str());
printf("Contact excitation value read:\n%s\n", contactExc.toString().c_str());
reply.clear();
if(!freeMotionExc.readFromConfigFile(rf, reply))
printf("Error while reading free motion excitation from config file: \n%s\n", reply.toString().c_str());
printf("Results of free motion excitation reading: %s\n", reply.toString().c_str());
printf("Free motion excitation value read:\n%s\n", freeMotionExc.toString().c_str());
}
示例7: testSequence
void testSequence(char *seq,
size_t len,
const char *fmt,
Bottle ref,
bool testWrite = true)
{
char err[1024];
printf("\n");
printf("================================================\n");
printf(" READ %s\n", fmt);
Bytes b1(seq, len);
WireTwiddler tt;
tt.configure(fmt, fmt);
printf(">>> %s\n", tt.toString().c_str());
Bottle bot;
checkTrue(tt.read(bot, b1), "Read failed");
snprintf(err, 1024, "%s: read %s, expected %s", fmt, bot.toString().c_str(), ref.toString().c_str());
checkTrue(bot == ref, err);
printf("[1] %s: read %s as expected\n", fmt, bot.toString().c_str());
StringInputStream sis;
sis.add(b1);
sis.add(b1);
WireTwiddlerReader twiddled_input(sis, tt);
Route route;
bot.clear();
twiddled_input.reset();
ConnectionReader::readFromStream(bot, twiddled_input);
snprintf(err, 1024, "%s: read %s, expected %s", fmt, bot.toString().c_str(), ref.toString().c_str());
checkTrue(bot == ref, err);
printf("[2] %s: read %s as expected\n", fmt, bot.toString().c_str());
bot.clear();
twiddled_input.reset();
ConnectionReader::readFromStream(bot, twiddled_input);
snprintf(err, 1024, "%s: read %s, expected %s", fmt, bot.toString().c_str(), ref.toString().c_str());
checkTrue(bot == ref, err);
printf("[3] %s: read %s as expected\n", fmt, bot.toString().c_str());
if (testWrite) {
printf("\n");
printf("================================================\n");
printf(" WRITE %s\n", fmt);
ManagedBytes output;
checkTrue(tt.write(ref, output), "WRITE FAILED");
snprintf(err, 1024, "WRITE MISMATCH, length %zd, expected %zd", output.length(), len);
checkTrue(output.length() == len, err);
for (size_t i = 0; i < output.length(); i++) {
snprintf(err, 1024, "WRITE MISMATCH, at %zd, have [%d:%c] expected [%d:%c]\n", i, output.get()[i], output.get()[i], seq[i], seq[i]);
checkTrue(output.get()[i] == seq[i], err);
}
printf("[4] %s: wrote %s as expected\n", fmt, bot.toString().c_str());
}
}
示例8: respond
bool MotorFrictionIdentificationModule::respond(const Bottle& cmd, Bottle& reply)
{
paramHelper->lock();
if(!paramHelper->processRpcCommand(cmd, reply))
reply.addString( (string("Command ")+cmd.toString().c_str()+" not recognized.").c_str());
paramHelper->unlock();
// if reply is empty put something into it, otherwise the rpc communication gets stuck
if(reply.size()==0)
reply.addString( (string("Command ")+cmd.toString().c_str()+" received.").c_str());
return true;
}
示例9: step
bool MainWindow::step()
{
Bottle reply;
emit internalStep(&reply);
if (reply.toString() == "error"){
return false;
}
if (reply.toString() == "ok"){
return true;
}
return false;
}
示例10: createAugmentedTimeVector
/*
* create the vAugmentedTime for the current used Instance : sql to obtain the foreign key for the feedback table
*
*/
bool abmInteraction::createAugmentedTimeVector(pair<string,int> & bestTimeAndRank)
{
Bottle bResult;
ostringstream osRequest;
//only augmented_time is needed but better clarity for the print
osRequest << "SELECT DISTINCT instance, augmented_time, img_provider_port FROM visualdata WHERE instance = " << rememberedInstance << " AND augmented IS NOT NULL AND img_provider_port = '" << img_provider_port << "' " ;
if(resume == "agent"){
// not proposing instance with feedback from the agent already.
osRequest << "AND augmented_time NOT IN (SELECT DISTINCT augmented_time FROM feedback WHERE instance = '" << rememberedInstance << "' AND agent = '" << agentName << "') " ;
createBestAugmentedTime(bestTimeAndRank) ;
} else if (resume == "yes") {
osRequest << "AND augmented_time NOT IN (SELECT DISTINCT augmented_time FROM feedback WHERE instance = '" << rememberedInstance << "') " ;
createBestAugmentedTime(bestTimeAndRank);
} else if (resume == "no") {
//come back to default value for best rank/time
bestTimeAndRank.first = "";
bestTimeAndRank.second = 0;
}
osRequest << " ORDER BY augmented_time ASC ;";
osRequest << " ;";
bResult = iCub->getABMClient()->requestFromString(osRequest.str());
yInfo() << "[createAugmentedTimeVector] SQL request bReply : " << bResult.toString();
vAugmentedTime.clear();
if (bResult.toString() != "NULL") {
for (int i = 0; i < bResult.size(); i++){
//get(1) because augmented is in second column of the result
vAugmentedTime.push_back(bResult.get(i).asList()->get(1).toString());
}
}
else {
yError() << "Request to obtain augmented from instance " << rememberedInstance << " is NULL : are you sure there are some augmented images?";
bestTimeAndRank.first = "";
bestTimeAndRank.second = -1;
return false;
}
ostringstream osAugmentedTime;
const char* const delim = ", ";
copy(vAugmentedTime.begin(), vAugmentedTime.end(), std::ostream_iterator<std::string>(osAugmentedTime, delim));
yInfo() << " vAugmentedTime = " << osAugmentedTime.str();
it_augmentedTime = vAugmentedTime.begin();
return true;
}
示例11: run
virtual void run() {
printf("Listening to terminal (type \"quit\" to stop module)\n");
bool isEof = false;
while (!(isEof||isStopping()||owner.isStopping())) {
ConstString str = NetworkBase::readString(&isEof);
if (!isEof) {
Bottle cmd(str.c_str());
Bottle reply;
bool ok = owner.safeRespond(cmd,reply);
if (ok) {
//printf("ALL: %s\n", reply.toString().c_str());
//printf("ITEM 1: %s\n", reply.get(0).toString().c_str());
if (reply.get(0).toString()=="help") {
for (int i=0; i<reply.size(); i++) {
ACE_OS::printf("%s\n",
reply.get(i).toString().c_str());
}
} else {
ACE_OS::printf("%s\n", reply.toString().c_str());
}
} else {
ACE_OS::printf("Command not understood -- %s\n", str.c_str());
}
}
}
//printf("terminal shutting down\n");
//owner.interruptModule();
}
示例12: respond
/*
* Message handler. Just echo all received messages.
*/
bool respond(const Bottle& command, Bottle& reply)
{
cout<<"Got "<<command.toString().c_str()<<endl;
if(command.size() < 3) {
reply.addString("Command error! example: 'sum 3 4'");
return true;
}
int a = command.get(1).asInt();
int b = command.get(2).asInt();
if( command.get(0).asString() == "sum") {
int c = sum(a, b);
reply.addInt(c);
return true;
}
if( command.get(0).asString() == "sub") {
int c = sub(a, b);
reply.addInt(c);
return true;
}
reply.addString("Unknown command");
reply.addString(command.get(0).asString().c_str());
return true;
}
示例13: testStringWithNull
void testStringWithNull() {
report(0,"test string with null");
char buf1[] = "hello world";
char buf2[] = "hello world";
buf2[5] = '\0';
ConstString str1(buf1,12);
ConstString str2(buf2,12);
checkEqual(str1.length(),12,"unmodified string length ok");
checkEqual(str2.length(),12,"modified string length ok");
ConstString str3(str2);
checkEqual(str3.length(),12,"copied string length ok");
Bottle bot;
bot.addString(str2);
checkEqual(bot.get(0).asString().length(),12,"bottled string asString() length ok");
checkEqual(bot.get(0).toString().length(),12,"bottled string toString() length ok");
Bottle bot2 = bot;
checkEqual(bot2.get(0).asString().length(),12,"bottled, copied string length ok");
Bottle bot3;
bot.write(bot3);
checkEqual(bot3.get(0).asString().length(),12,"bottled, serialized string length ok");
Bottle bot4;
bot4.fromString(bot.toString());
checkEqual(bot4.get(0).asString().length(),12,"bottled, text-serialized string length ok");
}
示例14: getOutput
bool SpringyFingersModel::getOutput(Value &out) const
{
if (configured)
{
Value val[5];
fingers[0].getOutput(val[0]);
fingers[1].getOutput(val[1]);
fingers[2].getOutput(val[2]);
fingers[3].getOutput(val[3]);
fingers[4].getOutput(val[4]);
Bottle bOut; Bottle &ins=bOut.addList();
ins.addDouble(val[0].asDouble());
ins.addDouble(val[1].asDouble());
ins.addDouble(val[2].asDouble());
ins.addDouble(val[3].asDouble());
ins.addDouble(val[4].asDouble());
out.fromString(bOut.toString().c_str());
return true;
}
else
return false;
}
示例15: test_surface_mesh
bool test_surface_mesh() {
printf("\n*** test_surface_mesh()\n");
SurfaceMesh mesh;
Box3D bb;
mesh.meshName = "testing";
bb.corners.push_back(PointXYZ(1,2,3));
SurfaceMeshWithBoundingBox obj(mesh,bb);
Bottle bot;
bot.read(obj);
SurfaceMeshWithBoundingBox obj2;
bot.write(obj2);
Bottle bot2;
bot2.read(obj2);
printf("mesh copy: %s -> %s\n", bot.toString().c_str(),
bot2.toString().c_str());
if (obj2.mesh.meshName!=obj.mesh.meshName) {
printf("mesh name not copied correctly\n");
return false;
}
if (obj2.boundingBox.corners.size()!=obj.boundingBox.corners.size()) {
printf("corners not copied correctly\n");
return false;
}
if (bot!=bot2) {
printf("not copied correctly\n");
return false;
}
return true;
}