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


C++ Node::push_back方法代码示例

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


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

示例1: saveFulcrums

void GraphIO::saveFulcrums(YAML::Node& fulcrum, const ConnectionDescription& connection)
{
    fulcrum["from"] = connection.from.getFullName();
    fulcrum["to"] = connection.to.getFullName();

    for (const Fulcrum& f : connection.fulcrums) {
        YAML::Node pt;
        pt.push_back(f.pos().x);
        pt.push_back(f.pos().y);

        fulcrum["pts"].push_back(pt);
    }

    for (const Fulcrum& f : connection.fulcrums) {
        YAML::Node handle;
        handle.push_back(f.handleIn().x);
        handle.push_back(f.handleIn().y);
        handle.push_back(f.handleOut().x);
        handle.push_back(f.handleOut().y);

        fulcrum["handles"].push_back(handle);
    }

    for (const Fulcrum& f : connection.fulcrums) {
        fulcrum["types"].push_back(f.type());
    }
}
开发者ID:cogsys-tuebingen,项目名称:csapex,代码行数:27,代码来源:graphio.cpp

示例2: upgradeYaml

void LootSettings::upgradeYaml(YAML::Node& yaml) {
    // Upgrade YAML settings' keys and values from those used in earlier
    // versions of LOOT.

  if (yaml["Debug Verbosity"] && !yaml["enableDebugLogging"])
    yaml["enableDebugLogging"] = yaml["Debug Verbosity"].as<unsigned int>() > 0;

  if (yaml["Update Masterlist"] && !yaml["updateMasterlist"])
    yaml["updateMasterlist"] = yaml["Update Masterlist"];

  if (yaml["Game"] && !yaml["game"])
    yaml["game"] = yaml["Game"];

  if (yaml["Language"] && !yaml["language"])
    yaml["language"] = yaml["Language"];

  if (yaml["Last Game"] && !yaml["lastGame"])
    yaml["lastGame"] = yaml["Last Game"];

  if (yaml["Games"] && !yaml["games"]) {
    yaml["games"] = yaml["Games"];

    for (auto node : yaml["games"]) {
      if (node["url"]) {
        node["repo"] = node["url"];
        node["branch"] = "master";  // It'll get updated to the correct default
      }
    }
  }

  if (yaml["games"]) {
    // Handle exception if YAML is invalid, eg. if an unrecognised
    // game type is used (which can happen if downgrading from a
    // later version of LOOT that supports more game types).
    // However, can't remove elements from a sequence Node, so have to
    // copy the valid elements into a new node then overwrite the
    // original.
    YAML::Node validGames;
    for (auto node : yaml["games"]) {
      try {
        GameSettings settings(node.as<GameSettings>());

        if (!yaml["Games"]) {
            // Update existing default branch, if the default
            // repositories are used.
          if (settings.RepoURL() == GameSettings(settings.Type()).RepoURL()
              && settings.IsRepoBranchOldDefault()) {
            settings.SetRepoBranch(GameSettings(settings.Type()).RepoBranch());
          }
        }

        validGames.push_back(settings);
      } catch (...) {}
    }
    yaml["games"] = validGames;
  }

  if (yaml["filters"])
    yaml["filters"].remove("contentFilter");
}
开发者ID:silentdark,项目名称:loot,代码行数:60,代码来源:loot_settings.cpp

示例3: P

YAML::Node& Generator::on_generate_votes ( const YAML::Node & msg, YAML::Node & ret )
{
	ret["type"] = "votes_generated";
	uint V = msg["data"][0].as<uint>();
	uint O = msg["data"][1].as<uint>();
	Integer p = msg["data"][2].as<Integer>();
	Integer g = msg["data"][3].as<Integer>();
	Integer k = Integer::Random ( p / 2, p );
	ret["data"][0][0] = k;
	std::set<Integer> T;
	while ( T.size() < V )
	{
		T.insert ( Integer::Random ( p / 2, p ) );
	}
	for ( Integer t: T )
	{
		YAML::Node card;
		Integer y;
		do
		{
			y = Integer::Random ( p / 2, p - Integer ( 1 ) );
		}
		while ( Integer::Call ( mpz_gcd, y, p - Integer ( 1 ) ) != 1 ) ;
		Integer gt = Integer::Call ( mpz_powm, g, t, p );
		Integer gy = Integer::Call ( mpz_powm, g, y, p );
		Integer P ( 1 );
		for ( uint i = 0; i < O; ++i )
		{
			YAML::Node option;
			P = Integer::NextPrime ( P );
			Integer o = ( P * Integer::Call ( mpz_powm, g, k * t, p ) ) % p;
			Integer s = ( ( o - t * gy ) * Integer::Call ( mpz_powm, y, Integer ( -1 ), p - Integer ( 1 ) ) ) % ( p - Integer ( 1 ) );
			option[0] = gt;
			option[1] = o;
			option[2] = gy;
			option[3] = s;
			card.push_back ( option );
		}
		ret["data"][0][1].push_back ( gt );
		ret["data"][1].push_back ( card );
	}
	return ret;
}
开发者ID:evote,项目名称:generator,代码行数:43,代码来源:generator.cpp

示例4: if

    static inline YAML::Node extract(const std::string& start_link, const std::string& end_link, const KDL::Chain& chain)
    {
        std::string var_suffix = "_var";
        std::string frame_suffix = "_frame";
        std::string expression_name = "fk";

        std::vector<YAML::Node> input_vars;
        std::vector<YAML::Node> joint_frames;
        YAML::Node frame_mul;
        YAML::Node axis_angle_null;
        axis_angle_null["axis-angle"].push_back(get_vector3(1, 0, 0));
        axis_angle_null["axis-angle"].push_back(0);

        int input_var_index = 0;
        for (std::vector<KDL::Segment>::const_iterator it = chain.segments.begin(); it != chain.segments.end(); ++it)
        {
            KDL::Joint joint = it->getJoint();

            std::string var_name = joint.getName() + var_suffix;
            std::string frame_name = joint.getName() + frame_suffix;

            YAML::Node joint_frame;
            if (joint.getType() != KDL::Joint::None)
            {
                // Set input variable definition
                YAML::Node input_var;
                input_var[joint.getName() + var_suffix]["input-var"] = input_var_index;
                input_var_index++;
                input_vars.push_back(input_var);

                // Set joint transform
                YAML::Node translation;
                YAML::Node rotation;

                // Set joint axis
                YAML::Node joint_axis = get_vector3(joint.JointAxis());
                if (joint.getType() == KDL::Joint::TransAxis)
                {
                    YAML::Node scale_vec;
                    scale_vec["scale-vector"].push_back(var_name);
                    scale_vec["scale-vector"].push_back(joint_axis);
                    translation["vector-add"].push_back(scale_vec);
                    translation["vector-add"].push_back(get_vector3(joint.JointOrigin()));
                    rotation = axis_angle_null;
                }
                else if (joint.getType() == KDL::Joint::RotAxis)
                {
                    translation = get_vector3(joint.JointOrigin());
                    rotation["axis-angle"].push_back(joint_axis);
                    rotation["axis-angle"].push_back(var_name);
                }

                // Create frame and add to list
                YAML::Node joint_transform;
                joint_transform["frame"].push_back(rotation);
                joint_transform["frame"].push_back(translation);
                joint_frame[frame_name]["frame-mul"].push_back(joint_transform);
            }

            std::vector<YAML::Node> f_tip_nodes = get_frame_tip_nodes(*it);
            for (std::vector<YAML::Node>::iterator f_tip_it = f_tip_nodes.begin(); f_tip_it != f_tip_nodes.end(); ++f_tip_it)
            {
                joint_frame[frame_name]["frame-mul"].push_back(*f_tip_it);
            }

            if (joint_frame.size() > 0)
            {
                joint_frames.push_back(joint_frame);
                frame_mul.push_back(frame_name);
            }
        }

        // Merge nodes
        YAML::Node node;
        for (std::vector<YAML::Node>::iterator it = input_vars.begin(); it != input_vars.end(); ++it)
        {
            node.push_back(*it);
        }
        for (std::vector<YAML::Node>::iterator it = joint_frames.begin(); it != joint_frames.end(); ++it)
        {
            node.push_back(*it);
        }
        YAML::Node fk_def;
        fk_def[expression_name]["frame-mul"] = frame_mul;
        node.push_back(fk_def);

        return node;
    }
开发者ID:jannikb,项目名称:giskard,代码行数:88,代码来源:expression_extraction.hpp

示例5: getAddr

	YAML::Node getAddr () {
		YAML::Node me;
		me.push_back(ip);
		me.push_back(port);
		return me;
	}
开发者ID:DaMSL,项目名称:K3-Benchstack,代码行数:6,代码来源:k3run.cpp

示例6: main

int main(int argc, const char* argv[])
{
    try
    {
        std::string qdataxmlfilen;
        if(argc < 2)
        {
            if(getenv("QDATA_XML_FILE") == NULL)
            {
                std::cout << "Please set the QDATA_XML_FILE variable or supply an argument." << std::endl;
                exit(0);
            }
            else
            {
                qdataxmlfilen = getenv("QDATA_XML_FILE");
            }
        }
        else
        {
            qdataxmlfilen = argv[1];
        }

        std::auto_ptr<qdata_t> doc(qdata(qdataxmlfilen));
        YAML::Node outdoc;

        if(std::string(doc->type()) == "ELEMENT")
        {
            if(!doc->header().present())
            {
                std::cout << "Document declared ELEMENT type, yet missing <header> element." << std::endl;
                exit(-1);
            }
            YAML::Node odoc;
            outdoc["header"].push_back(odoc);
            header_t h = doc->header().get();
            odoc["name"] = std::string(h.name());
            odoc["author"] = std::string(h.author());
            odoc["description"] = std::string(h.description());
            odoc["extra"] = std::string(h.extra());
            odoc["maxquestions"] = int(h.maxquestions());
            if(h.skipoverride().present())
                odoc["skipoverride"] = bool(h.skipoverride().get());
            if(h.answernumberinput().present())
                odoc["answernumberinput"] = bool(h.answernumberinput().get());
            if(h.skipisincorrect().present())
                odoc["skipisincorrect"] = bool(h.skipisincorrect().get());
            if(h.quizmode().present())
                odoc["quizmode"] = bool(h.quizmode().get());

            if(!doc->questions().present())
            {
                std::cout << "Document declared ELEMENT type, yet missing <questions> element." << std::endl;
                exit(-1);
            }
            YAML::Node qdoc;
            outdoc["questions"].push_back(qdoc);
            questions_t q = doc->questions().get();
            questions_t::problem_sequence& qseq = q.problem();
            int index = 1;
            for(questions_t::problem_iterator iter = qseq.begin();
                    iter != qseq.end();
                    iter++)
            {
                question_t ques(*iter);
                YAML::Node cques;
                qdoc["q" + toString(index)].push_back(cques);
                cques["question"] = std::string(ques.question());
                answers_t answers = ques.answers();
                YAML::Node answersnode;
                cques["answers"] = answersnode;
                answers_t::answer_sequence& aseq = answers.answer();
                for(answers_t::answer_iterator iter2 = aseq.begin();
                        iter2 != aseq.end();
                        iter2++)
                {
                    answersnode.push_back(std::string(*iter2));
                }
                cques["correctanswer"] = int(ques.correctanswer());
                index++;
            }
        }
        else if (std::string(doc->type()) == "ATTRIBUTE")
        {
            if(!doc->headera().present())
            {
                std::cout << "Document declared ATTRIBUTE type, yet missing <headera> element." << std::endl;
                exit(-1);
            }
            YAML::Node odoc;
            outdoc["header"] = odoc;
            headera_t h = doc->headera().get();
            odoc["name"] = std::string(h.name());
            odoc["author"] = std::string(h.author());
            odoc["description"] = std::string(h.description());
            odoc["extra"] = std::string(h.extra());
            odoc["maxquestions"] = int(h.maxquestions());
            if(h.skipoverride().present())
                odoc["skipoverride"] = bool(h.skipoverride().get());
            if(h.answernumberinput().present())
                odoc["answernumberinput"] = bool(h.answernumberinput().get());
//.........这里部分代码省略.........
开发者ID:Bobhostern,项目名称:CreateLSRQDataFromXML,代码行数:101,代码来源:main.cpp

示例7: launchTask

  virtual void launchTask(ExecutorDriver* driver, const TaskInfo& task)    {
	localPeerCount++;

    TaskStatus status;
    status.mutable_task_id()->MergeFrom(task.task_id());
    status.set_state(TASK_RUNNING);
    driver->sendStatusUpdate(status);

    //-------------  START TASK OPERATIONS ----------
	cout << "Running K3 Program: " << task.name() << endl;
	string k3_cmd;

	using namespace YAML;

	Node hostParams = Load(task.data());
	Node peerParams;
	Node peers;
//	vector<Node> peers;

	cout << "WHAT I RECEIVED\n----------------------\n";
	cout << Dump(hostParams);
	cout << "\n---------------------------------\n";

	k3_cmd = "cd $MESOS_SANDBOX && bash -c 'ulimit -c unlimited && ./" + hostParams["binary"].as<string>();
	if (hostParams["logging"]) {
		k3_cmd += " -l INFO ";
	}
        if (hostParams["resultVar"]) {
          k3_cmd += " --result_path $MESOS_SANDBOX --result_var " + hostParams["resultVar"].as<string>();
        }


	string datavar, datapath;
	string datapolicy = "default";
	int peerStart = 0;
	int peerEnd = 0;

	for (const_iterator param=hostParams.begin(); param!=hostParams.end(); param++)  {
		string key = param->first.as<string>();
//		cout << " PROCESSING: " << key << endl;
		if (key == "logging" || key == "binary" ||
			key == "server" || key == "server_group") {
			continue;
		}
		if (key == "roles") {
		  continue;
		}

		else if (key == "peers") {
			peerParams["peers"] = hostParams["peers"];
		}
		else if (key == "me") {
			Node meList = param->second;
			YAML::Emitter emit;
			emit << YAML::Flow << meList;
			for (std::size_t i=0; i<meList.size(); i++)  {
				peers.push_back(meList[i]);
			}
		}
		else if (key == "data") {
		        // TODO: Datafiles per group. This is a hack
		        // that only includes the data files from the first peer group
		        // and assigns them to any peer
		        Node dataFilesNode = param->second[0];
			for(YAML::const_iterator it=dataFilesNode.begin();it!=dataFilesNode.end();++it) {
                          DataFile f;
                          auto d = *it;
			  f.path = d["path"].as<string>();
			  f.varName = d["var"].as<string>();
			  f.policy = d["policy"].as<string>();
			  dataFiles.push_back(f);
			}

		}

		//else if (key == "datavar") {
		//	datavar = param->second.as<string>();
		//}
		//else if (key == "datapath") {
		//	datapath = "{path: " + param->second.as<string>() + "}";
		//}
		//else if (key == "datapolicy") {
		//	datapolicy = param->second.as<string>();
		//}
		else if (key == "totalPeers")  {
			totalPeerCount = param->second.as<int>();
		}
		else if (key == "peerStart") {
			peerStart = param->second.as<int>();
		}
		else if (key == "peerEnd") {
			peerEnd = param->second.as<int>();
		}
		else if (key == "globals") {
		  // handled per peer

		}
		else {
//			string value = i->second.as<string>();
			//peerParams[key] = param->second;
//.........这里部分代码省略.........
开发者ID:DaMSL,项目名称:K3,代码行数:101,代码来源:k3_executor.cpp


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