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


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

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


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

示例1: merge

void Settings::merge(const boost::property_tree::ptree& from,
                     boost::property_tree::ptree& to,
                     bool overwrite)
{
    // Is this a single value or a subtree?
    if (!from.data().empty()) {
        // Single value
        if (overwrite || to.data().empty()) {
            to.put_value(from.data());
        }
        return;
    }

    // Subtree
    for (const auto& fromEntry : from) {
        // Does the key exist in the destination?
        auto toIt = to.find(fromEntry.first);
        if (toIt == to.not_found()) {
            ptree::ptree child;

            // Recurse into the new child
            merge(fromEntry.second, child, overwrite);

            // Create a path object because ptree uses '.' as a path delimiter
            // when strings are used
            ptree::ptree::path_type treePath = createPath(fromEntry.first);
            to.add_child(treePath, child);
        } else {
            // Recurse into the subtrees
            merge(fromEntry.second, toIt->second, overwrite);
        }
    }
}
开发者ID:icyerasor,项目名称:joynr,代码行数:33,代码来源:Settings.cpp

示例2: 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

示例3: updateOnly

void updateOnly(boost::property_tree::ptree &dest, bool ignoreEmptyUpdates, const boost::property_tree::ptree::path_type &childPath, const boost::property_tree::ptree &child) {
    if(ignoreEmptyUpdates && (child.data().empty() || child.data().find_first_not_of(" \n\t\r") == std::string::npos)) return;
    if(!dest.get_optional<std::string>(childPath)) {
        throw PropertyTree::KeyNotFoundException(std::string("Could not find the destination '") + childPath.dump() + "' to update with '" + child.data() + "'.");
    }
    dest.put(childPath, child.data());
}
开发者ID:Yvaine,项目名称:Schweizer-Messer,代码行数:7,代码来源:BoostPropertyTreeImplementation.cpp

示例4: handleConfigItem

int ParallelFilter::handleConfigItem(const std::string& confFile,
				     const boost::property_tree::ptree::const_iterator& it)
{
    BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ":: "<< type() << " " << it->first ;

    cout << "PF::handle "  << it->first << endl;
    if (it->first == "parallelFilter") {
	// recurse
 	return loadConfig(confFile, it->second.begin(), it->second.end());
    } else if (it->first == "thread") {
	cout << "PF::THREAD FOUND!"<< endl;
	Filter* f;
	if ( it->second.size() > 1 
	     ) {
	    // instantiate a filterbank
	    FilterBank* fb = new FilterBank();

	    fb->bank(NULL);
	    fb->loadConfig( it->second );
	    
	    f=fb;
	} else if (it->second.begin()->first == "filterGroup") {
	    // instantiate a filterbank
	    FilterBank* fb = new FilterBank();
	    const boost::property_tree::ptree pt = it->second.begin()->second;

	    cout << "DD " << pt.data() << endl;
	    fb->bank(NULL);
	    fb->loadFileConfig(pt.data());

	    f=fb;
	} else {
	    const boost::property_tree::ptree pt = it->second;
	    f = instantiateFilter(pt.begin() );
	}

	FilterThread* ft = new FilterThread(f);
	lanes.push_back(ft);

	add(f); // book-keeping

    } else if (it->first == "barrier") {
	boost::property_tree::ptree::const_iterator child = it->second.begin();
	cout << "PF::BARRIER FOUND! "<< child->first << endl;

	Filter* f = instantiateFilter( child );
	
	f->loadConfig( it->second );

	this->mux = (Mux*) f;

	add(f); // book-keeping

    } else {
	//return FilterBank::handleConfigItem(confFile, it);
    }
    return 1;
}
开发者ID:voxel-dot-at,项目名称:toffy,代码行数:58,代码来源:parallelFilter.cpp

示例5: print_ptree

void print_ptree(std::ostream& os, const boost::property_tree::ptree& pt, int depth)
{
	typedef bp::ptree::const_iterator c_it;

	if(pt.empty())
		os << "'" << pt.data() << "'\n";
	else
	{
		std::string pad("");
		pad.assign(depth*4,' ');
		++depth;
		std::string pad2 = pad + "    ";

		if(is_list(pt))
		{
			os << "[\n";
			for(c_it it=pt.begin(); it!=pt.end(); ++it)
			{
				os << pad2;
				print_ptree(os, it->second, depth);
			}
			os << pad << "]\n";
		}
		else
		{
			os << "{\n";
			for(c_it it=pt.begin(); it!=pt.end(); ++it)
			{
				os << pad2 << "'" << it->first << "': ";
				print_ptree(os, it->second, depth);
			}
			os << pad << "}\n";
		}
	}
}
开发者ID:nerdvegas,项目名称:certus,代码行数:35,代码来源:ptree_utils.cpp

示例6: genOSXPlistPrefValue

void genOSXPlistPrefValue(const pt::ptree& tree,
                          const Row& base,
                          unsigned int level,
                          QueryData& results) {
  if (tree.empty()) {
    Row r = base;
    r["value"] = tree.data();
    results.push_back(std::move(r));
    // No more levels to parse.
    return;
  }

  for (const auto& item : tree) {
    Row r = base;
    if (r["subkey"].size() > 0) {
      r["subkey"] += '/';
      if (item.first.size() == 0) {
        r["subkey"] += std::to_string(level++);
      }
    }

    r["subkey"] += item.first;
    genOSXPlistPrefValue(item.second, r, level, results);
  }
}
开发者ID:theopolis,项目名称:osquery,代码行数:25,代码来源:preferences.cpp

示例7: convert

void convert(const boost::property_tree::wptree & in, boost::property_tree::ptree & out)
{
    out.data() = utf8(in.data());
    for(boost::property_tree::wptree::const_iterator i = in.begin(), end = in.end(); i != end; ++i)
    {
        out.push_back(boost::property_tree::ptree::value_type(utf8(i->first), boost::property_tree::ptree()));
        convert(i->second, out.back().second);
    }
}
开发者ID:spolitov,项目名称:lib,代码行数:9,代码来源:xml.cpp

示例8: printPTree

void printPTree(const boost::property_tree::ptree &pt, const std::string prefix)
{
	std::cout << prefix << "data = \"" << pt.data() << '"' << std::endl;
	using boost::property_tree::ptree;
	for (ptree::const_iterator it = pt.begin(); it != pt.end(); ++it)
	{
		std::cout << prefix << "child = \""  << it->first << '"' << std::endl;
		printPTree(it->second, prefix + "\t");
	}
}
开发者ID:anehrkor,项目名称:KappaTools,代码行数:10,代码来源:IOHelper.cpp

示例9: is_list

bool is_list(const boost::property_tree::ptree& pt)
{
	if(!pt.data().empty())
		return false;

	for(bp::ptree::const_iterator it=pt.begin(); it!=pt.end(); ++it)
	{
		if(!it->first.empty())
			return false;
	}
	return true;
}
开发者ID:nerdvegas,项目名称:certus,代码行数:12,代码来源:ptree_utils.cpp

示例10: get_value

T get_value(const boost::property_tree::ptree & node, const std::string & name)
{
    try
    {
        return node.get_value<T>();
    }
    catch (...)
    {
        throw config_error(std::string("Failed to parse ") +
                           name + ". Expected " + name_trait<T>::name() +
                           " but got '" + node.data() + "'");
    }
}
开发者ID:ninowalker,项目名称:mapnik-trunk,代码行数:13,代码来源:ptree_helpers.hpp

示例11: printTree

void printTree (boost::property_tree::ptree &pt, int level) {
  if (pt.empty()) {
    std::cout << "\""<< pt.data()<< "\"";
  } else {
    if (level) std::cout << std::endl; 
    std::cout << indent(level) << "{" << std::endl;     
    for (boost::property_tree::ptree::iterator pos = pt.begin(); pos != pt.end();) {
      std::cout << indent(level+1) << "\"" << pos->first << "\": "; 
      printTree(pos->second, level + 1); 
      ++pos; 
      if (pos != pt.end()) {
        std::cout << ","; 
      }
      std::cout << std::endl;
    } 
    std::cout << indent(level) << " }";     
  } 
  return; 
}
开发者ID:Flos,项目名称:ladybug_windows,代码行数:19,代码来源:configuration_helper.cpp

示例12: merge

void merge(boost::property_tree::ptree &dest, bool ignoreEmptyUpdates, const boost::property_tree::ptree::path_type &childPath, const boost::property_tree::ptree &child) {
    if(ignoreEmptyUpdates && (child.data().empty() || child.data().find_first_not_of(" \n\t\r") == std::string::npos)) return;
    dest.put(childPath, child.data());
}
开发者ID:Yvaine,项目名称:Schweizer-Messer,代码行数:4,代码来源:BoostPropertyTreeImplementation.cpp


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