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


C++ ptree::size方法代码示例

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


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

示例1: PropertyTreeValue

    /**
     * @brief  Construct a PropertyTreeValue from a tree object
     *
     * This function will determine whether the tree object represents an array
     * or an object by scanning the key names for any non-empty strings. In the
     * case of an empty tree object, it is not possible to determine whether it
     * is an array or an object, so it will be treated as an array by default.
     * Empty arrays are considered equal to empty objects when compared using
     * non-strict type comparison. Empty strings will also be stored as empty
     * arrays.
     *
     * @param  tree  Tree object to be wrapped
     */
    PropertyTreeValue(const boost::property_tree::ptree &tree)
    {
        if (tree.data().empty()) {    // No string content
            if (tree.size() == 0) {   // No children
                array = tree;         // Treat as empty array
            } else {
                bool isArray = true;
                boost::property_tree::ptree::const_iterator itr;
                for (itr = tree.begin(); itr != tree.end(); itr++) {
                    if (!itr->first.empty()) {
                        isArray = false;
                        break;
                    }
                }

                if (isArray) {
                    array = tree;
                } else {
                    object = tree;
                }
            }
        } else {
            value = tree.data();
        }
    }
开发者ID:hotwatermorning,项目名称:valijson,代码行数:38,代码来源:property_tree_adapter.hpp

示例2: getVectorFromJsonArray

core::vector3df getVectorFromJsonArray(const boost::property_tree::ptree& tree) {
	//if position array has correct size, fetch the three elements via incrementing iterator to first element two times
	if(tree.size() == 3) {
		auto begin = tree.begin();
		float x = (begin++)->second.get_value<float>();
		float y = (begin++)->second.get_value<float>();
		float z = begin->second.get_value<float>();
		return core::vector3df(x,y,z);
	} else {
		return core::vector3df();
	}
}
开发者ID:Xerox16,项目名称:Liero3D,代码行数:12,代码来源:parts.cpp

示例3: if

void
mergePropertyTrees (boost::property_tree::ptree &ptMerged,
                    const boost::property_tree::ptree &ptSecond, int level )
{
  // Value or object or array
  if (level > 0 && ptSecond.empty() ) {
    // Copy value
    ptMerged = ptSecond;
  } else if (level > 0 && ptSecond.count (std::string() ) == ptSecond.size() ) {
    // Copy array
    ptMerged = ptSecond;
  } else {
    auto it = ptSecond.begin();

    for (; it != ptSecond.end(); ++it) {
      boost::property_tree::ptree child = ptMerged.get_child (it->first.data(),
                                          boost::property_tree::ptree() );
      mergePropertyTrees (child, it->second, level + 1);

      ptMerged.erase (it->first.data() );
      ptMerged.add_child (it->first.data(), child);
    }
  }
}
开发者ID:startgeek,项目名称:kurento-media-server,代码行数:24,代码来源:loadConfig.cpp


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