当前位置: 首页>>代码示例>>C++>>正文


C++ Bottle::append方法代码示例

本文整理汇总了C++中Bottle::append方法的典型用法代码示例。如果您正苦于以下问题:C++ Bottle::append方法的具体用法?C++ Bottle::append怎么用?C++ Bottle::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Bottle的用法示例。


在下文中一共展示了Bottle::append方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: putBottle

 Bottle& putBottleCompat(const char *key, const Bottle& val) {
     if (val.get(1).asString()=="=") {
         Bottle b;
         b.add(val.get(0));
         b.append(val.tail().tail());
         return putBottle(key,b);
     }
     return putBottle(key,val);
 }
开发者ID:JoErNanO,项目名称:yarp,代码行数:9,代码来源:Property.cpp

示例2: apply

bool NameServer::apply(const Bottle& cmd, Bottle& result,
                       const Contact& remote) {
    Bottle rcmd;
    rcmd.addString("ignored_legacy");
    rcmd.append(cmd);
    ConstString in = rcmd.toString().c_str();
    ConstString out = apply(in,remote).c_str();
    result.fromString(out.c_str());
    return true;
}
开发者ID:apaikan,项目名称:yarp,代码行数:10,代码来源:NameServer.cpp

示例3: respond

bool DeviceResponder::respond(const Bottle& command, Bottle& reply) {
    switch (command.get(0).asVocab()) {
    case VOCAB4('h','e','l','p'):
        if (examples.size()>=1) {
            reply.add(Value::makeVocab("many"));
            if (command.get(1).toString()=="more") {
                reply.append(details);
            } else {
                reply.append(examples);
            }
            return true;
        } else {
            reply.add("no documentation available");
            return false;
        }
        break;
    default:
        reply.add("command not recognized");
        return false;
    }
    return false;
}
开发者ID:JoErNanO,项目名称:yarp,代码行数:22,代码来源:DeviceDriver.cpp

示例4: respond

	bool respond(const Bottle &command, Bottle &reply)
	{
		reply.clear();

		if (command.get(0).asString() == "checkGraspSucceeded")
		{
			if (graspSucceeded)		reply.append("true");
			else					reply.append("false");

			//graspSucceeded = false;
		}
		else if (command.get(0).asString() == "grasp")
		{
			Bottle answer;

			if(command.size() == 4)
			{
				if(command.get(1).asString() != "safe")
				{
					reply.addInt(-2);
					reply.addString("Error: wrong keyword");
					return false;
				}

				graspSucceeded = false;
				activeHand = command.get(3).asString().c_str();
				answer = grasp->Grasp(primitives,command.get(2).asString().c_str(),activeHand, true);
				if (answer.get(0).asInt() == 0)		isGrasping.signal();

			}
			else if (command.size() == 3)
			{
				activeHand = command.get(2).asString().c_str();
				answer = grasp->Grasp(primitives,command.get(1).asString().c_str(),activeHand, false);
			}
			else
			{
				reply.addInt(-2);
				reply.addString("Error: wrong syntax");
				return false;
			}
			
			// check if grasp returned an error
			cout << answer.toString() << endl;
			reply.append(answer);
		}

		else if (command.get(0).asString() == "release")
		{
			if(command.size() != 2)
			{
				reply.addInt(-2);
				reply.addString("Error: wrong syntax");
				return false;
			}

			activeHand = command.get(1).asString().c_str();
			Bottle answer = grasp->Release(primitives,activeHand);
			reply.append(answer);
		}

		else if (command.get(0).asString() == "tighten")
		{	
			if(command.size() == 1)
				reply = grasp->Tighten(activeHand);
			
			else if(command.size() == 2)
			{
				activeHand = command.get(1).asString().c_str();
				Bottle answer = grasp->Tighten(activeHand);
				reply.append(answer);
			}
			else
			{
				reply.addInt(-2);
				reply.addString("Error: wrong syntax");
				return false;
			}				
		}

		else if (command.get(0).asString() == "offset")
		{
			if (command.size() == 2 && command.get(1).asString() == "get")
				reply = grasp->getOffset();

			else if (command.size() == 3 && command.get(1).asString() == "set")
			{			
				Bottle * list = command.get(2).asList();
				if(list->size() != 9)
				{
					reply.addInt(-2);
					reply.addString("Error: wrong argument number");
					return false;
				}
				grasp->setOffset(*list);
				reply.addInt(0);
			}
			else
			{
				reply.addInt(-2);
//.........这里部分代码省略.........
开发者ID:xufango,项目名称:contrib_bk,代码行数:101,代码来源:main.cpp

示例5: getVTGSparam

Bottle PMPthread::getVTGSparam(Bottle cmdBot, string side)
{
	VirtualTrajectoryGenerator * VTGS;

	if (side == "right")	VTGS = VTGS_r;
	if (side == "left")		VTGS = VTGS_l;

	VTGSparam cmd;
	Bottle reply;

	if(!identifyCmd(cmdBot, cmd))
	{
		reply.addString("Unknown command\n");
	}
	else
	{
		switch(cmd)
		{
			// VTGS parameters
			case target:
				reply.append(Matrix2Bottle(VTGS->getTarget()));
				break;
	
			case weights:
				reply.append(Matrix2Bottle(VTGS->getWeights()));
				break;
	
			// tbg1 parameters
			case T_init1:
				reply.addDouble(VTGS->tbg1.getT_init());
				break;
	
			case T_dur1:
				reply.addDouble(VTGS->tbg1.getT_dur());
				break;
	
			case SlopeRamp1:
				reply.addDouble(VTGS->tbg1.getSlopeRamp());
				break;
	
			case alpha1:
				reply.addDouble(VTGS->tbg1.getAlpha());
				break;

			// tbg2 parameters
			case T_init2:
				reply.addDouble(VTGS->tbg2.getT_init());
				break;
	
			case T_dur2:
				reply.addDouble(VTGS->tbg2.getT_dur());
				break;

			case SlopeRamp2:
				reply.addDouble(VTGS->tbg2.getSlopeRamp());
				break;
	
			case alpha2:
				reply.addDouble(VTGS->tbg2.getAlpha());
				break;
		}
	}
	return reply;
}
开发者ID:xufango,项目名称:contrib_bk,代码行数:64,代码来源:PMPthread.cpp

示例6: getPMPparam

Bottle PMPthread::getPMPparam(Bottle cmdBot)
{
	PMPparam cmd;
	Bottle reply;

	if(!identifyCmd(cmdBot, cmd))
	{
		reply.addString("Unknown command\n");
	}
	else
	{
		switch(cmd)
		{
			// PMP parameters
			case xr_target:			
				reply.append(Vector2Bottle(PMP->x_tgR));
				break;
	
			case xl_target:
				reply.append(Vector2Bottle(PMP->x_tgL));
				break;

			case q_rightArm:
				reply.append(Vector2Bottle(PMP->get_q_rightArm()));
				break;

			case q_leftArm:
				reply.append(Vector2Bottle(PMP->get_q_rightArm()));
				break;

			case qr_initial:
				reply.append(Vector2Bottle(PMP->q_0R));
				break;

			case ql_initial:
				reply.append(Vector2Bottle(PMP->q_0L));
				break;

			case Kr_virt:
				reply.append(Matrix2Bottle(PMP->get_K_right()));
				break;

			case Kl_virt:
				reply.append(Matrix2Bottle(PMP->get_K_left()));
				break;

			case A_rightArm:
				reply.append(Matrix2Bottle(PMP->get_A_rightArm()));
				break;

			case A_leftArm:
				reply.append(Matrix2Bottle(PMP->get_A_rightArm()));
				break;

			case Kr_int:
				reply.append(Matrix2Bottle(PMP->get_Kint_right()));
				break;

			case Kl_int:
				reply.append(Matrix2Bottle(PMP->get_Kint_left()));
				break;

			case K_virt_bimanual:
				reply.append(Matrix2Bottle(PMP->get_K_biman()));
				break;

			case A_bimanual:
				reply.append(Matrix2Bottle(PMP->get_A_biman()));
				break;

			case wrist:

				if(cmdBot.size() != 2)
				{
					reply.append("Error: parameter value size mismatch");
					break;
				}

				cout << cmdBot.toString() << endl;
				if (cmdBot.get(1).asString() == "right")
				{
					reply.addDouble(PMP->q_ref_right(7)*CTRL_RAD2DEG);
					break;
				}
				else if (cmdBot.get(1).asString() == "left")
				{
					reply.addDouble(PMP->q_ref_left(7)*CTRL_RAD2DEG);
					break;
				}
				else if (cmdBot.get(1).asString() == "bimanual")
				{
					reply.addDouble(PMP->q_ref_right(7)*CTRL_RAD2DEG);
					reply.addDouble(PMP->q_ref_left(7)*CTRL_RAD2DEG);
					break;
				}
				else
				{
					printf("Error: unknown chain parameter value\n");
					reply.append("error");
					break;
//.........这里部分代码省略.........
开发者ID:xufango,项目名称:contrib_bk,代码行数:101,代码来源:PMPthread.cpp

示例7: respond


//.........这里部分代码省略.........
                        reply.addString("ERROR: pose was not set");
                    }
                }
                return true;
            }
		case get_position:
            {
                if(!(params.size()>0 && params.get(0).isInt())){
                    reply.addString(("ERROR: SkinPart is not specified. Params read are: "+string(params.toString().c_str())).c_str());
                    return true;
                }
                SkinPart sp = (SkinPart) params.get(0).asInt();
                if(params.size()>1 && params.get(1).isInt()){
                    unsigned int taxelId = params.get(1).asInt();
                    Vector res = myThread->getTaxelPosition(sp, taxelId);
                    if(res.size()>0)
                        addToBottle(reply, res);
                    else
                        reply.addString("No position for the specified skin part");
                }
                else{
                    vector<Vector> res = myThread->getTaxelPositions(sp);
                    if(res.empty())
                        reply.addString("Specified skin part has not been found.");
                    else
                        addToBottle(reply, res);
                }
                return true;
            }
		case set_position:
			{
                if(!(params.size()>3 && params.get(0).isInt() )){
                    reply.addString(("ERROR: SkinPart is not specified. Params read are: "+string(params.toString().c_str())).c_str());
                    return true;
                }
                SkinPart sp = (SkinPart) params.get(0).asInt();
                if(params.get(1).isInt()){
                    unsigned int taxelId = params.get(1).asInt();
                    Vector pose;
                    if(!bottleToVector(params.tail().tail(), pose)){
                        reply.addString("ERROR while reading the taxel position");
                        return true;
                    }
                    if(myThread->setTaxelPosition(sp, taxelId, pose))
                        reply.addInt(skin_manager_ok);
                    else{
                        reply.addInt(skin_manager_error);
                        reply.addString("ERROR: position was not set");
                    }
                }
                else{
                    Vector poses;
                    if(!bottleToVector(params.tail(), poses)){
                        reply.addString("ERROR while reading the taxel positions");
                        return true;
                    }
                    if(myThread->setTaxelPositions(sp, poses))
                        reply.addInt(skin_manager_ok);
                    else{
                        reply.addInt(skin_manager_error);
                        reply.addString("ERROR: position was not set");
                    }
                }
                return true;
            }
		case get_confidence:
			{
				if(!(params.size()>0 && params.get(0).isInt())){
                    reply.addString(("ERROR: SkinPart is not specified. Params read are: "+string(params.toString().c_str())).c_str());
                    return true;
                }
                SkinPart sp = (SkinPart) params.get(0).asInt();
                if(params.size()>1 && params.get(1).isInt()){
                    unsigned int taxelId = params.get(1).asInt();
                    double res = myThread->getPoseConfidence(sp, taxelId);
					reply.addDouble(res);
                }
                else{
                    Vector res = myThread->getPoseConfidences(sp);
                    if(res.size()==0)
                        reply.addString("Specified skin part has not been found");
                    else
                        addToBottle(reply, res);
                }
                return true;

			}
        case get_info:
            reply.append(myThread->getInfo());
            return true;

		default:
			reply.addString("ERROR: This command is known but it is not managed in the code.");
			return true;
	}

	reply.addString( (SkinManagerCommandList[com]+" command received.").c_str());

	return true;	
}
开发者ID:apaikan,项目名称:icub-main,代码行数:101,代码来源:skinManager.cpp

示例8: respond

bool RGBDSensorParser::respond(const Bottle& cmd, Bottle& response)
{
    bool ret = false;
    int interfaceType = cmd.get(0).asVocab();

    response.clear();
    switch(interfaceType)
    {
        case VOCAB_RGB_VISUAL_PARAMS:
        {
            // forwarding to the proper parser.
            ret = rgbParser.respond(cmd, response);
        }
        break;

        case VOCAB_DEPTH_VISUAL_PARAMS:
        {
            // forwarding to the proper parser.
            ret = depthParser.respond(cmd, response);
        }
        break;

        case VOCAB_RGBD_SENSOR:
        {
            switch (cmd.get(1).asVocab())
            {
                case VOCAB_GET:
                {
                    switch(cmd.get(2).asVocab())
                    {
                        case VOCAB_EXTRINSIC_PARAM:
                        {
                            yarp::sig::Matrix params;
                            ret = iRGBDSensor->getExtrinsicParam(params);
                            if(ret)
                            {
                                yarp::os::Bottle params_b;
                                response.addVocab(VOCAB_RGBD_SENSOR);
                                response.addVocab(VOCAB_EXTRINSIC_PARAM);
                                response.addVocab(VOCAB_IS);
                                ret &= Property::copyPortable(params, params_b);  // will it really work??
                                response.append(params_b);
                            }
                            else
                                response.addVocab(VOCAB_FAILED);
                        }
                        break;

                        case VOCAB_ERROR_MSG:
                        {
                            response.addVocab(VOCAB_RGBD_SENSOR);
                            response.addVocab(VOCAB_ERROR_MSG);
                            response.addVocab(VOCAB_IS);
                            response.addString(iRGBDSensor->getLastErrorMsg());
                            ret = true;
                        }
                        break;

                        case VOCAB_RGBD_PROTOCOL_VERSION:
                        {
                            response.addVocab(VOCAB_RGBD_SENSOR);
                            response.addVocab(VOCAB_RGBD_PROTOCOL_VERSION);
                            response.addVocab(VOCAB_IS);
                            response.addInt(RGBD_INTERFACE_PROTOCOL_VERSION_MAJOR);
                            response.addInt(RGBD_INTERFACE_PROTOCOL_VERSION_MINOR);
                        }
                        break;

                        case VOCAB_STATUS:
                        {
                            response.addVocab(VOCAB_RGBD_SENSOR);
                            response.addVocab(VOCAB_STATUS);
                            response.addVocab(VOCAB_IS);
                            response.addInt(iRGBDSensor->getSensorStatus());
                        }
                        break;

                        default:
                        {
                            yError() << "RGBDSensor interface parser received an unknown GET command. Command is " << cmd.toString();
                            response.addVocab(VOCAB_FAILED);
                        }
                        break;
                    }
                }
                break;

                case VOCAB_SET:
                {
                    yError() << "RGBDSensor interface parser received an unknown SET command. Command is " << cmd.toString();
                    response.addVocab(VOCAB_FAILED);
                }
                break;
            }
        }
        break;

        default:
        {
            yError() << "RGBD sensor wrapper received a command for a wrong interface " << yarp::os::Vocab::decode(interfaceType);
//.........这里部分代码省略.........
开发者ID:apaikan,项目名称:yarp,代码行数:101,代码来源:RGBDSensorWrapper.cpp

示例9: registerName

Contact NameClient::registerName(const String& name, const Contact& suggest) {
    String np = getNamePart(name);
    Bottle cmd;
    cmd.addString("register");
    if (np!="") {
        cmd.addString(np.c_str());
    } else {
        cmd.addString("...");
    }
    ConstString prefix = NetworkBase::getEnvironment("YARP_IP");
    NestedContact nc = suggest.getNested();
    ConstString typ = nc.getTypeNameStar();
    if (suggest.isValid()||prefix!=""||typ!="*") {
        if (suggest.getCarrier()!="") {
            cmd.addString(suggest.getCarrier().c_str());
        } else {
            cmd.addString("...");
        }
        if (suggest.getHost()!="") {
            cmd.addString(suggest.getHost().c_str());
        } else {
            if (prefix!="") {
                Bottle ips = NameConfig::getIpsAsBottle();
                for (int i=0; i<ips.size(); i++) {
                    String ip = ips.get(i).asString().c_str();
                    if (ip.find(prefix)==0) {
                        prefix = ip.c_str();
                        break;
                    }
                }
            }
            cmd.addString((prefix!="")?prefix:"...");
        }
        if (suggest.getPort()!=0) {
            cmd.addInt(suggest.getPort());
        } else {
            cmd.addString("...");
        }
        if (typ!="*") {
            cmd.addString(typ);
        }
    }
    Bottle reply;
    send(cmd,reply);

    Contact address = extractAddress(reply);
    if (address.isValid()) {
        String reg = address.getRegName();

        /*

          // this never really got used

        cmd.fromString("set /port offers tcp text text_ack udp mcast shmem name_ser");
        cmd.get(1) = Value(reg.c_str());
        send(cmd,reply);

        // accept the same set of carriers
        cmd.get(2) = Value("accepts");
        send(cmd,reply);
        */

        cmd.clear();
        cmd.addString("set");
        cmd.addString(reg.c_str());
        cmd.addString("ips");
        cmd.append(NameConfig::getIpsAsBottle());
        send(cmd,reply);

        cmd.clear();
        cmd.addString("set");
        cmd.addString(reg.c_str());
        cmd.addString("process");
        cmd.addInt(ACE_OS::getpid());
        send(cmd,reply);
    }
    return address;
}
开发者ID:AbuMussabRaja,项目名称:yarp,代码行数:78,代码来源:NameClient.cpp

示例10: fromConfig


//.........这里部分代码省略.........
                                                init.addString(key.c_str());
                                                init.addString(subName.c_str());
                                                putBottleCompat(key.c_str(),
                                                                init);
                                            } else {
                                                target->addString(subName.c_str());
                                            }
                                        } else {
                                            YARP_ERROR(Logger::get(),
                                                       String("bad include"));
                                            return;
                                        }


                                        Property p;
                                        if (getBottle(subName)!=NULL) {
                                            p.fromString(getBottle(subName)->tail().toString());
                                            //printf(">>> prior p %s\n",
                                            //     p.toString().c_str());
                                        }
                                        p.fromConfigFile(fname.c_str(),
                                                         env, false);
                                        accum.fromString(p.toString());
                                        tag = subName.c_str();
                                        //printf(">>> tag %s accum %s\n",
                                        //     tag.c_str(),
                                        //     accum.toString().c_str());
                                        if (tag!="") {
                                            if (accum.size()>=1) {
                                                Bottle b;
                                                b.addString(tag.c_str());
                                                //Bottle& subList = b.addList();
                                                //subList.copy(accum);
                                                b.append(accum);
                                                putBottleCompat(tag.c_str(),
                                                                b);
                                            }
                                            tag = "";
                                        }
                                    } else {
                                        tag = "";
                                        ConstString fname =
                                            bot.get(1).toString();
                                        //printf("Including %s\n", fname.c_str());
                                        fromConfigFile(fname.c_str(),
                                                       env, false);
                                    }
                                }
                            }
                            if (bot.size()==2 && !including) {
                                buf = bot.get(1).toString().c_str();
                                String key = bot.get(0).toString().c_str();
                                Bottle *target = getBottle(key.c_str());
                                if (target==NULL) {
                                    Bottle init;
                                    init.addString(key.c_str());
                                    init.addString(buf.c_str());
                                    putBottleCompat(key.c_str(),init);
                                } else {
                                    target->addString(buf.c_str());
                                }
                            }
                        }
                        if (!including) {
                            isTag = true;
                        }
开发者ID:JoErNanO,项目名称:yarp,代码行数:67,代码来源:Property.cpp


注:本文中的Bottle::append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。