示例#1
0
vconfig::child_list vconfig::get_children(const std::string& key) const
{
	vconfig::child_list res;

	BOOST_FOREACH(const config::any_child &child, cfg_->all_children_range())
	{
		if (child.key == key) {
			res.push_back(vconfig(child.cfg, cache_));
		} else if (child.key == "insert_tag") {
			vconfig insert_cfg(child.cfg);
			if(insert_cfg["name"] == key) {
				variable_info vinfo(insert_cfg["variable"], false, variable_info::TYPE_CONTAINER);
				if(!vinfo.is_valid) {
					//push back an empty tag
					res.push_back(empty_vconfig());
				} else if(vinfo.explicit_index) {
					res.push_back(vconfig(vinfo.as_container(), true));
				} else {
					variable_info::array_range range = vinfo.as_array();
					if(range.first == range.second) {
						//push back an empty tag
						res.push_back(empty_vconfig());
					}
					while(range.first != range.second) {
						res.push_back(vconfig(*range.first++, true));
					}
				}
			}
		}
	}
	return res;
}
示例#2
0
static inline void info(const char *fmt, ...)
{
	va_list va;
	va_start(va, fmt);
	vinfo(fmt, va);
	va_end(va);
}
示例#3
0
void info(const char *format, ...)
{
	va_list ap;

	va_start(ap, format);

	vinfo(format, ap);

	va_end(ap);
}
示例#4
0
static inline void verbose(const char *fmt, ...)
{
	va_list va;

	if (!v_option)
		return;

	va_start(va, fmt);
	vinfo(fmt, va);
	va_end(va);
}
示例#5
0
static inline void verbose(const struct eject_control *ctl, const char *fmt, ...)
{
	va_list va;

	if (!ctl->v_option)
		return;

	va_start(va, fmt);
	vinfo(fmt, va);
	va_end(va);
}
示例#6
0
void start_logging(const char *ident, const char *message, ...)
{
	va_list ap;

	openlog(ident, LOG_PID | LOG_NDELAY | LOG_PERROR, LOG_DAEMON);

	va_start(ap, message);

	vinfo(message, ap);

	va_end(ap);
}
示例#7
0
config vconfig::get_parsed_config() const
{
	// Keeps track of insert_tag variables.
	static std::set<std::string> vconfig_recursion;

	config res;

	BOOST_FOREACH(const config::attribute &i, cfg_->attribute_range()) {
		res[i.first] = expand(i.first);
	}

	BOOST_FOREACH(const config::any_child &child, cfg_->all_children_range())
	{
		if (child.key == "insert_tag") {
			vconfig insert_cfg(child.cfg);
			const t_string& name = insert_cfg["name"];
			const t_string& vname = insert_cfg["variable"];
			if(!vconfig_recursion.insert(vname).second) {
				throw recursion_error("vconfig::get_parsed_config() infinite recursion detected, aborting");
			}
			try {
				variable_info vinfo(vname, false, variable_info::TYPE_CONTAINER);
				if(!vinfo.is_valid) {
					res.add_child(name); //add empty tag
				} else if(vinfo.explicit_index) {
					res.add_child(name, vconfig(vinfo.as_container()).get_parsed_config());
				} else {
					variable_info::array_range range = vinfo.as_array();
					if(range.first == range.second) {
						res.add_child(name); //add empty tag
					}
					while(range.first != range.second) {
						res.add_child(name, vconfig(*range.first++).get_parsed_config());
					}
				}
				vconfig_recursion.erase(vname);
			} catch(recursion_error &err) {
				vconfig_recursion.erase(vname);
				WRN_NG << err.message << std::endl;
				if(vconfig_recursion.empty()) {
					res.add_child("insert_tag", insert_cfg.get_config());
				} else {
					// throw to the top [insert_tag] which started the recursion
					throw;
				}
			}
		} else {
			res.add_child(child.key, vconfig(child.cfg).get_parsed_config());
		}
	}
	return res;
}
示例#8
0
vconfig vconfig::all_children_iterator::get_child() const
{
	if (inner_index_ >= 0 && i_->key == "insert_tag")
	{
		variable_info vinfo(vconfig(i_->cfg)["variable"], false, variable_info::TYPE_CONTAINER);
		if(!vinfo.is_valid) {
			return empty_vconfig();
		} else if(inner_index_ == 0) {
			return vconfig(vinfo.as_container(), true);
		}
		variable_info::array_range r = vinfo.as_array();
		std::advance(r.first, inner_index_);
		return vconfig(*r.first, true);
	}
	return vconfig(i_->cfg, cache_);
}
示例#9
0
vconfig::all_children_iterator& vconfig::all_children_iterator::operator++()
{
	if (inner_index_ >= 0 && i_->key == "insert_tag")
	{
		variable_info vinfo(vconfig(i_->cfg)["variable"], false, variable_info::TYPE_CONTAINER);
		if(vinfo.is_valid && !vinfo.explicit_index) {
			variable_info::array_range range = vinfo.as_array();
			if (++inner_index_ < std::distance(range.first, range.second)) {
				return *this;
			}
			inner_index_ = 0;
		}
	}
	++i_;
	return *this;
}
示例#10
0
/**
 * Returns a child of *this whose key is @a key.
 * If no such child exists, returns an unconstructed vconfig (use null() to test
 * for this).
 */
vconfig vconfig::child(const std::string& key) const
{
	if (const config &natural = cfg_->child(key)) {
		return vconfig(natural, cache_);
	}
	BOOST_FOREACH(const config &ins, cfg_->child_range("insert_tag"))
	{
		vconfig insert_cfg(ins);
		if(insert_cfg["name"] == key) {
			variable_info vinfo(insert_cfg["variable"], false, variable_info::TYPE_CONTAINER);
			if(!vinfo.is_valid) {
				return empty_vconfig();
			}
			return vconfig(vinfo.as_container(), true);
		}
	}
	return unconstructed_vconfig();
}
示例#11
0
void MvcBook::UpdateTitle()
{
	MvcView* pView=m_pBook->m_pActiveView;
	if(!pView) return;


	ViewInfo& vinfo(m_aOpenedViews[pView]);

	String title = pView->GetTitle();
	if (vinfo.title != title)
	{
		vinfo.title = title;
		vinfo.index = -1;
	}

	vinfo.dirty=pView->Target.TestId(CmdProc::CP_DIRTY);

	
	class MyViewInfoLess
	{
	public:
		bool operator()(ViewInfo* lhs, ViewInfo* rhs)
		{
			if (lhs->index < rhs->index) return true;
			if (lhs->index > rhs->index) return false;
			return lhs->timestamp < rhs->timestamp;
		}
	};

	bst_map<String, bst_set<ViewInfo*, MyViewInfoLess> > ainfo;
	for (auto it = m_aOpenedViews.begin(); it != m_aOpenedViews.end(); ++it)
	{
		ainfo[(*it).second.title].insert(&(*it).second);
	}
	for (auto it = ainfo.begin(); it != ainfo.end(); it++)
	{
		bst_set<ViewInfo*, MyViewInfoLess>& ainfo((*it).second);
		if (ainfo.size() == 1)
		{
			(*ainfo.begin())->index = -1;
			continue;
		}

		int n = (*ainfo.rbegin())->index;
		for (auto it = ainfo.begin(); it != ainfo.end() && (*it)->index < 0; ++it)
		{
			(*it)->index = ++n;
		}

	}


	for (view_map::iterator it = m_aOpenedViews.begin(); it != m_aOpenedViews.end(); ++it)
	{
		ViewInfo& vinfo((*it).second);
		String title;
		if (vinfo.dirty) title << "* ";
		else  title << "  ";

		title << vinfo.title;
		if (vinfo.index >= 0)
		{
			title << ":" << vinfo.index;
		}
		if (title == vinfo.title_n) continue;
		vinfo.title_n = title;

		wxWindow* pCanvas = (*it).first->GetCanvas();
		int id = m_pBook->GetPageIndex(pCanvas);
		if (id >= 0)
		{
			m_pBook->SetPageText(id, str2wx(title));
		}
		else
		{
			System::LogTrace("canvas not found");
		}
	}

}