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


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

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


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

示例1: AreDetailsEqual

    bool AreDetailsEqual(const YAML::Node& lhs, const YAML::Node& rhs) {
        //We want to check for plugin order and messages. 
        if (lhs.IsSequence() && rhs.IsSequence()) {
            std::list<std::string> lhs_names, rhs_names;
            std::list<Message> lhs_messages, rhs_messages;
            
            for (YAML::const_iterator it = lhs.begin(); it != lhs.end(); ++it) {
                if ((*it)["name"])
                    lhs_names.push_back((*it)["name"].as<std::string>());
                if ((*it)["messages"]) {
                    std::list<Message> messages = (*it)["messages"].as< std::list<Message> >();
                    lhs_messages.insert(lhs_messages.end(), messages.begin(), messages.end());
                }
            }
            for (YAML::const_iterator it = rhs.begin(); it != rhs.end(); ++it) {
                if ((*it)["name"])
                    rhs_names.push_back((*it)["name"].as<std::string>());
                if ((*it)["messages"]) {
                    std::list<Message> messages = (*it)["messages"].as< std::list<Message> >();
                    rhs_messages.insert(rhs_messages.end(), messages.begin(), messages.end());
                }
            }

            return lhs_names == rhs_names && lhs_messages == rhs_messages;
        }
        else
            return false;
    }
开发者ID:dbb,项目名称:loot,代码行数:28,代码来源:generators.cpp

示例2: defaultString

bool
KnobSerialization::checkForDefaultValueNode(const YAML::Node& node, const std::string& nodeType, bool dataTypeSet)
{
    std::string defaultString("Default");
    std::string defaultTypeName = defaultString + nodeType;
    if (!node[defaultTypeName]) {
        return false;
    }

    // If the _dataType member was set in checkForValueNode, ensure that the data type of the value is the same as
    // the default value.
    if (dataTypeSet) {
        SerializationValueVariantTypeEnum type = dataTypeFromString(nodeType);
        if (type != _dataType) {
            throw std::invalid_argument(_scriptName + ": Default value and value type differ!");
        }
    } else {
        _dataType = dataTypeFromString(nodeType);
    }


    YAML::Node defNode = node[defaultTypeName];
    int nDims = defNode.IsSequence() ? defNode.size() : 1;
    _defaultValues.resize(nDims);
    for (int i = 0; i < nDims; ++i) {
        _defaultValues[i].serializeDefaultValue = true;
        YAML::Node dimNode = defNode.IsSequence() ? defNode[i] : defNode;
        decodeValueFromNode(dimNode, _defaultValues[i].value, _dataType);
    }

    return true;
}
开发者ID:kcotugno,项目名称:Natron,代码行数:32,代码来源:KnobSerialization.cpp

示例3: get

bool YamlPath::get(YAML::Node root, YAML::Node& out) {
    size_t beginToken = 0, endToken = 0, pathSize = codedPath.size();
    auto delimiter = MAP_DELIM; // First token must be a map key.
    while (endToken < pathSize) {
        if (!root.IsDefined()) {
            return false; // A node before the end of the path was mising, quit!
        }
        beginToken = endToken;
        endToken = pathSize;
        endToken = std::min(endToken, codedPath.find(SEQ_DELIM, beginToken));
        endToken = std::min(endToken, codedPath.find(MAP_DELIM, beginToken));
        if (delimiter == SEQ_DELIM) {
            int index = std::stoi(&codedPath[beginToken]);
            if (root.IsSequence()) {
                root.reset(root[index]);
            } else {
                return false;
            }
        } else if (delimiter == MAP_DELIM) {
            auto key = codedPath.substr(beginToken, endToken - beginToken);
            if (root.IsMap()) {
                root.reset(root[key]);
            } else {
                return false;
            }
        } else {
            return false; // Path is malformed, return null node.
        }
        delimiter = codedPath[endToken]; // Get next character as the delimiter.
        ++endToken; // Move past the delimiter.
    }
    // Success! Assign the result.
    out.reset(root);
    return true;
}
开发者ID:karimnaaji,项目名称:tangram-es,代码行数:35,代码来源:yamlPath.cpp

示例4: if

// Incrementally load YAML
static NEVER_INLINE void operator +=(YAML::Node& left, const YAML::Node& node)
{
	if (node && !node.IsNull())
	{
		if (node.IsMap())
		{
			for (const auto& pair : node)
			{
				if (pair.first.IsScalar())
				{
					auto&& lhs = left[pair.first.Scalar()];
					lhs += pair.second;
				}
				else
				{
					// Exotic case (TODO: probably doesn't work)
					auto&& lhs = left[YAML::Clone(pair.first)];
					lhs += pair.second;
				}
			}
		}
		else if (node.IsScalar() || node.IsSequence())
		{
			// Scalars and sequences are replaced completely, but this may change in future.
			// This logic may be overwritten by custom demands of every specific cfg:: node.
			left = node;
		}
	}
}
开发者ID:Zangetsu38,项目名称:rpcs3,代码行数:30,代码来源:SettingsDialog.cpp

示例5: ParseBeaconMapFile

    int GazeboRosPulson::ParseBeaconMapFile(std::string f)
    {
        ROS_INFO("Opening Beacon Map File: %s", f.c_str());

        // open file
        std::fstream fs;
        fs.open(f.c_str());
        if (!fs.is_open())
            return -1;
        YAML::Node map = YAML::LoadFile(f.c_str());
        assert(map.IsSequence());

        num_beacons_ = map.size();

        // read beacon locations
        for (int i = 0; i < num_beacons_; i++)
        {
            Beacon b;
            b.x = (double) map[i]["x"].as<double>();
            b.y = (double) map[i]["y"].as<double>();
            b.z = (double) map[i]["z"].as<double>();
            b.id = (int) map[i]["id"].as<int>();

            ROS_INFO("Beacon %d at : %f %f %f", b.id, b.x, b.y, b.z);

            beacons_.push_back(b);
        }

        // close file
        fs.close();
        return 0;
    }
开发者ID:ashariati,项目名称:gazebo_ros_pulson,代码行数:32,代码来源:gazebo_ros_pulson.cpp

示例6: from_yaml

Vector from_yaml(type_t<Vector>, const YAML::Node& value)
{
    if (!value.IsSequence())
        throw deserialize_error{"type must be a sequence but is " +
                                yaml_type_name(value)};

    Vector ret{};
    vector_reserve(ret, value.size(), has_reserve<Vector>{});

    for (const auto& item : value)
    {
        try
        {
            ret.push_back(yaml::deserialize<typename Vector::value_type>(item));
        }
        catch (deserialize_error& ex)
        {
            std::string msg = "error when deserializing element " +
                              std::to_string(ret.size());
            ex.add(msg.c_str());
            throw;
        }
    }

    return ret;
}
开发者ID:k0zmo,项目名称:kl,代码行数:26,代码来源:yaml.hpp

示例7: if

/*
 * This function checks to see if the current YAML::Node contains only keys
 * that we care about. Unknown keys should cause PLFS to spit out an error
 * rather than being silently ignored.
 * This is a bit nasty as it drills through the entire tree recursively
 * but it will catch any unknowns in one pass
 *
 * Returns true if all keys are valid
 *
 * Returns false if unknown keys are found and sets bad_key to an error
 * message that points out what key is invalid
 */
bool
is_valid_node(const YAML::Node node, string** bad_key) {
    set<string> key_list(Valid_Keys, 
                         Valid_Keys + 
                         (sizeof(Valid_Keys) / sizeof(Valid_Keys[0]))
                        );
    string key;
    string err = "\nBad key or value in plfsrc: ";
    if(node.IsMap()) {
        for(YAML::const_iterator it=node.begin();it!=node.end();it++) {
            if(!it->first.IsNull()) {
                key = it->first.as<string>();
                if(!is_valid_node(node[key],bad_key)) // recurse
                    return false;
                if(key_list.find(key) == key_list.end()) {
                    err.append(key);
                    *bad_key = new string (err);
                    return false; // this is an unknown key
                }
            }
        }
    }
    else if (node.IsSequence()) {
        for(unsigned int i = 0; i < node.size(); i++)
            if(!is_valid_node(node[i],bad_key)) // recurse
                return false;
    }
    else if (node.IsScalar() && node.as<string>().find(" ") != string::npos) {
        err.append(node.as<string>());
        *bad_key = new string (err);
        return false; // no spaces in values allowed
    }
    return true; // all keys are valid
}
开发者ID:zhang-jingwang,项目名称:plfs-core,代码行数:46,代码来源:parse_conf.cpp

示例8: load_from_file

bool ParamManager::load_from_file(std::string filename)
{
  try
  {
    YAML::Node root = YAML::LoadFile(filename);
    assert(root.IsSequence());

    for (int i = 0; i < root.size(); i++)
    {
      if (root[i].IsMap() && root[i]["name"] && root[i]["type"] && root[i]["value"])
      {
        if (is_param_id(root[i]["name"].as<std::string>()))
        {
          Param param = params_.find(root[i]["name"].as<std::string>())->second;
          if ((MAV_PARAM_TYPE) root[i]["type"].as<int>() == param.getType())
          {
            set_param_value(root[i]["name"].as<std::string>(), root[i]["value"].as<double>());
          }
        }
      }
    }

    return true;
  }
  catch (...)
  {
    return false;
  }
}
开发者ID:byu-magicc,项目名称:fcu_io,代码行数:29,代码来源:param_manager.cpp

示例9:

std::tuple<Ts...> from_yaml(type_t<std::tuple<Ts...>>, const YAML::Node& value)
{
    if (!value.IsSequence())
        throw deserialize_error{"type must be a sequence but is " +
                                yaml_type_name(value)};

    return tuple_from_yaml<std::tuple<Ts...>>(
        value, make_index_sequence<sizeof...(Ts)>{});
}
开发者ID:k0zmo,项目名称:kl,代码行数:9,代码来源:yaml.hpp

示例10: InvalidNode

void
NonKeyParamsSerialization::decode(const YAML::Node& node)
{
    if (!node.IsSequence() || node.size() != 3) {
        throw YAML::InvalidNode();
    }
    dataTypeSize = node[0].as<std::size_t>();
    nComps = node[1].as<int>();
    bounds.decode(node[2]);
}
开发者ID:azerupi,项目名称:Natron,代码行数:10,代码来源:NonKeyParamsSerialization.cpp

示例11: main

int main(int argc, char **argv) {
  ros::init(argc, argv, "apriltag_ros");
  ros::NodeHandle nh("~");
  image_transport::ImageTransport it(nh);
  image_transport::CameraSubscriber camera_sub =
      it.subscribeCamera("image_raw", 1, cam_callback);
  pose_pub = nh.advertise<geometry_msgs::PoseStamped>("pose_cam", 1);

  //  load YAML file with tag positions
  std::string yamlPath;
  if (!nh.hasParam("map_file")) {
    ROS_ERROR("Error: You must specify the map_file parameter.");
    return -1;
  }
  nh.getParam("map_file", yamlPath);

  try {
    YAML::Node mapNode = YAML::LoadFile(yamlPath);

    if (!mapNode.IsSequence()) {
      throw std::runtime_error("YAML file should be a sequence of tags");
    }

    for (size_t i=0; i < mapNode.size(); i++) {
      apriltag_ros::Tag tag = mapNode[i].as<apriltag_ros::Tag>();
      tagsWorld[tag.id] = tag;  //  add to map
    }

    if (tagsWorld.empty()) {
      throw std::runtime_error("No tags were loaded");
    } else {
      ROS_INFO("Loaded %lu tags from the map file", tagsWorld.size());
    }
  }
  catch(std::exception& e) {
    ROS_ERROR("Error: Failed to load map file: %s", yamlPath.c_str());
    ROS_ERROR("Reason: %s", e.what());
    return -1;
  }

  image_pub = nh.advertise<sensor_msgs::Image>("image", 1);
  tag_pub   = nh.advertise<apriltag_ros::tags>("tags", 1);

  ros::Rate r(10.0);
  while(nh.ok())
  {
    r.sleep();
    ros::spinOnce();
  }

  return 0;
}
开发者ID:mwatterson,项目名称:apriltag,代码行数:52,代码来源:apriltag_ros_node.cpp

示例12: decodeBezierCPCurve

static void decodeBezierCPCurve(const YAML::Node& node, double* x, CurveSerialization* curve)
{
    try {
        if (node.IsSequence()) {
            curve->decode(node);
            if (!curve->keys.empty()) {
                *x = curve->keys.front().value;
            }
        } else {
            *x = node.as<double>();
        }
    } catch (const YAML::BadConversion& /*e*/) {
        assert(false);
    }
}
开发者ID:ebrayton,项目名称:Natron,代码行数:15,代码来源:BezierCPSerialization.cpp

示例13: InvalidNode

void
BezierCPSerialization::decode(const YAML::Node& node)
{
    if (!node.IsSequence() || node.size() != 6) {
        throw YAML::InvalidNode();
    }

    decodeBezierCPCurve(node[0], &x, &xCurve);
    decodeBezierCPCurve(node[1], &y, &yCurve);
    decodeBezierCPCurve(node[2], &leftX, &leftCurveX);
    decodeBezierCPCurve(node[3], &leftY, &leftCurveY);
    decodeBezierCPCurve(node[4], &rightX, &rightCurveX);
    decodeBezierCPCurve(node[5], &rightY, &rightCurveY);

}
开发者ID:ebrayton,项目名称:Natron,代码行数:15,代码来源:BezierCPSerialization.cpp

示例14: decodeMat

static bool decodeMat(const YAML::Node &node, kr::Mat<Scalar, Rows, Cols> &M) {
  static_assert(Rows != Eigen::Dynamic && Cols != Eigen::Dynamic,
                "Static matrices only");

  if (!node.IsSequence() || node.size() != Rows*Cols) {
    return false;
  }

  for (int i = 0; i < Rows; i++) {
    for (int j = 0; j < Cols; j++) {
      M(i, j) = static_cast<Scalar>(node[i * Cols + j].as<double>());
    }
  }
  return true;
}
开发者ID:kartikmohta,项目名称:test-circle-ci-ros,代码行数:15,代码来源:yaml.hpp

示例15: parseYAML

void GameConfiguration::parseYAML(const string archivoAParsear){
	//VERIFICA SI ARCHIVO ESTA CORRUPTO O TIENE FORMATO VALIDO DE YAML, EN ESE CASO PARSEA DIRECTAMENTE EL ARCHIVO POR DEFECTO
	this->loadFile(archivoAParsear);

	this->pantalla = PantallaConfig(this->nodoRaiz["pantalla"]);
	this->configuracion = ConfiguracionConfig(this->nodoRaiz["configuracion"]);
	YAML::Node nodoTipos = this->nodoRaiz["tipos"];
	this->escenario = EscenarioConfig(this->nodoRaiz["escenario"]);


	if(!nodoTipos.IsSequence()){
		Log().Get(TAG,logERROR) << "Nodo tipos tiene que ser una secuencia";
	} else {
		for (std::size_t i=0;i < nodoTipos.size();i++) {
		  TipoConfig* newNodo = new TipoConfig(nodoTipos[i]);
		  tipos.push_back(*newNodo);
		}
	}
}
开发者ID:kaoruheanna,项目名称:AgeOfFiuba,代码行数:19,代码来源:GameConfiguration.cpp


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