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


C++ wptree::get_child方法代码示例

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


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

示例1: readProperties

void HttpPostCommand::readProperties(boost::property_tree::wptree& pt)
{
    AbstractCommand::readProperties(pt);

    setUrl(QString::fromStdWString(pt.get(L"url", Http::DEFAULT_URL.toStdWString())));
    setTriggerOnNext(pt.get(L"triggeronnext", Http::DEFAULT_TRIGGER_ON_NEXT));

    if (pt.count(L"httpdata") > 0)
    {
        BOOST_FOREACH(const boost::property_tree::wptree::value_type& value, pt.get_child(L"httpdata"))
        {
            this->models.push_back(KeyValueModel(QString::fromStdWString(value.second.get<std::wstring>(L"key")),
                                                 QString::fromStdWString(value.second.get<std::wstring>(L"value"))));
        }
    }
开发者ID:CasparCG,项目名称:Client,代码行数:15,代码来源:HttpPostCommand.cpp

示例2: configure

void configure(const std::wstring& filename)
{
	try
	{
		auto separator = boost::filesystem::path::preferred_separator;
		auto initialPath = fs::initial_path<fs::path>().wstring();
		std::wstring path_(initialPath + boost::lexical_cast<std::wstring>(separator) + filename);
		const wchar_t *pstr = path_.c_str();

		std::wifstream file(reinterpret_cast<const char *>(pstr));

		CASPAR_LOG(info) << L"before read_xml ..." << initialPath << " " << filename << " " << pstr;

		boost::property_tree::read_xml("/etc/casparcg.config", pt, boost::property_tree::xml_parser::trim_whitespace | boost::property_tree::xml_parser::no_comments);

		CASPAR_LOG(info) << L"read_xml done...";

		auto paths = pt.get_child(L"configuration.paths");
		media = widen(paths.get(L"media-path", initialPath + L"/media/"));
		log = widen(paths.get(L"log-path", initialPath + L"/log/"));
		ftemplate = fs::complete(fs::path(widen(paths.get(L"template-path", initialPath + L"/template/")))).wstring();		
		data = widen(paths.get(L"data-path", initialPath + L"/data/"));
		thumbnails = widen(paths.get(L"thumbnails-path", initialPath + L"/thumbnails/"));

		//Make sure that all paths have a trailing backslash
		if(media.at(media.length()-1) != L'/')
			media.append(L"/");
		if(log.at(log.length()-1) != L'/')
			log.append(L"/");
		if(ftemplate.at(ftemplate.length()-1) != L'/')
			ftemplate.append(L"/");
		if(data.at(data.length()-1) != L'/')
			data.append(L"/");
		if(thumbnails.at(thumbnails.length()-1) != L'/')
			thumbnails.append(L"/");

		try
		{
			for(auto it = fs::directory_iterator(initialPath); it != fs::directory_iterator(); ++it)
			{
				if(it->path().filename().wstring().find(L".fth") != std::wstring::npos)			
				{
					auto from_path = *it;
					auto to_path = fs::path(ftemplate + L'/' + it->path().filename().wstring());
				
					if(fs::exists(to_path))
						fs::remove(to_path);

					fs::copy_file(from_path, to_path);
				}	
			}
		}
		catch(...)
		{
			CASPAR_LOG_CURRENT_EXCEPTION();
			CASPAR_LOG(error) << L"Failed to copy template-hosts from initial-path to template-path.";
		}
	}
	catch(...)
	{
		std::wcout << L" ### Invalid configuration file. ###";
		throw;
	}

	try
	{
		auto media_path = fs::path(media);
		if(!fs::exists(media_path))
			fs::create_directory(media_path);
		
		auto log_path = fs::path(log);
		if(!fs::exists(log_path))
			fs::create_directory(log_path);
		
		auto template_path = fs::path(ftemplate);
		if(!fs::exists(template_path))
			fs::create_directory(template_path);
		
		auto data_path = fs::path(data);
		if(!fs::exists(data_path))
			fs::create_directory(data_path);
		
		auto thumbnails_path = fs::path(thumbnails);
		if(!fs::exists(thumbnails_path))
			fs::create_directory(thumbnails_path);
	}
	catch(...)
	{
		CASPAR_LOG_CURRENT_EXCEPTION();
		CASPAR_LOG(error) << L"Failed to create configured directories.";
	}
}
开发者ID:zhouqilin,项目名称:casparLinux,代码行数:92,代码来源:env.cpp


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