Beispiel #1
0
tbuilder_listbox::tbuilder_listbox(const config& cfg)
	: tbuilder_control(cfg)
	, vertical_scrollbar_mode(
			  get_scrollbar_mode(cfg["vertical_scrollbar_mode"]))
	, horizontal_scrollbar_mode(
			  get_scrollbar_mode(cfg["horizontal_scrollbar_mode"]))
	, header(nullptr)
	, footer(nullptr)
	, list_builder(nullptr)
	, list_data()
	, has_minimum_(cfg["has_minimum"].to_bool(true))
	, has_maximum_(cfg["has_maximum"].to_bool(true))
{
	if(const config& h = cfg.child("header")) {
		header = std::make_shared<tbuilder_grid>(h);
	}

	if(const config& f = cfg.child("footer")) {
		footer = std::make_shared<tbuilder_grid>(f);
	}

	const config& l = cfg.child("list_definition");

	VALIDATE(l, _("No list defined."));
	list_builder = std::make_shared<tbuilder_grid>(l);
	assert(list_builder);
	VALIDATE(list_builder->rows == 1,
			 _("A 'list_definition' should contain one row."));

	const config& data = cfg.child("list_data");
	if(!data) {
		return;
	}

	for(const auto & row : data.child_range("row"))
	{
		unsigned col = 0;

		for(const auto & c : row.child_range("column"))
		{
			list_data.push_back(string_map());
			for(const auto & i : c.attribute_range())
			{
				list_data.back()[i.first] = i.second;
			}
			++col;
		}

		VALIDATE(col == list_builder->cols,
				 _("'list_data' must have the same number of "
				   "columns as the 'list_definition'."));
	}
}
Beispiel #2
0
tbuilder_horizontal_listbox::tbuilder_horizontal_listbox(const config& cfg)
	: tbuilder_control(cfg)
	, vertical_scrollbar_mode(
			  get_scrollbar_mode(cfg["vertical_scrollbar_mode"]))
	, horizontal_scrollbar_mode(
			  get_scrollbar_mode(cfg["horizontal_scrollbar_mode"]))
	, list_builder(nullptr)
	, list_data()
{
	const config& l = cfg.child("list_definition");

	VALIDATE(l, _("No list defined."));
	list_builder = new tbuilder_grid(l);
	assert(list_builder);
	VALIDATE(list_builder->rows == 1,
			 _("A 'list_definition' should contain one row."));

	const config& data = cfg.child("list_data");
	if(!data)
		return;

	for(const auto & row : data.child_range("row"))
	{
		unsigned col = 0;

		for(const auto & c : row.child_range("column"))
		{
			list_data.push_back(string_map());
			for(const auto & i : c.attribute_range())
			{
				list_data.back()[i.first] = i.second;
			}
			++col;
		}

		VALIDATE(col == list_builder->cols,
				 _("'list_data' must have "
				   "the same number of columns as the 'list_definition'."));
	}
}
void ParserGroup::Parse(filesystem::FB_FILE *fp)
{
	sub_groups = string_map();
	
	while(!feof(fp))
	{
		std::string string = ReadLine(fp);

		int position = IsProperty(string);
		if(position != -1)
		{
			std::string property = GetProperty(string, position, true);
			std::string value = GetProperty(string, position, false);

			properties[ property ] = value;
		}
		else
		{
			// Branches ?
			for(int i = 0; i < (int)string.size(); ++i)
			{
				if(string[i] == '{')
				{
					ParseSubGroups(fp);
					break;
				}

				if(string[i] == '}')
				{
					// End of this group
					return;
				}
			}
		}
	}
}