本文整理汇总了C++中FileReader::get_section_names方法的典型用法代码示例。如果您正苦于以下问题:C++ FileReader::get_section_names方法的具体用法?C++ FileReader::get_section_names怎么用?C++ FileReader::get_section_names使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReader
的用法示例。
在下文中一共展示了FileReader::get_section_names方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
std::vector<std::string> get_section_names() const
{
return m_reader.get_section_names();
}
示例2: pout
void
PingusLevel::load(const std::string& resname,
const Pathname& pathname)
{
impl->resname = resname;
FileReader reader = FileReader::parse(pathname);
if (reader.get_name() != "pingus-level")
{
PingusError::raise("Error: " + pathname.str() + ": not a 'pingus-level' file");
}
else
{
int version;
if (reader.read_int("version", version))
pout(PINGUS_DEBUG_LOADING) << "Levelfile Version: " << version << std::endl;
else
pout(PINGUS_DEBUG_LOADING) << "Unknown Levelfile Version: " << version << std::endl;
FileReader head;
if (!reader.read_section("head", head))
{
PingusError::raise("Error: (head) section not found in '" + pathname.str() + "'");
}
else
{
pout(PINGUS_DEBUG_LOADING) << "Reading head" << std::endl;
head.read_string("levelname", impl->levelname);
head.read_string("description", impl->description);
head.read_size ("levelsize", impl->size);
head.read_string("music", impl->music);
head.read_int ("time", impl->time);
head.read_int ("difficulty", impl->difficulty);
head.read_int ("number-of-pingus", impl->number_of_pingus);
head.read_int ("number-to-save", impl->number_to_save);
head.read_color ("ambient-light", impl->ambient_light);
head.read_string("author", impl->author);
pout(PINGUS_DEBUG_LOADING) << "Size: " << impl->size.width << " " << impl->size.height << std::endl;
FileReader actions;
if (head.read_section("actions", actions))
{
std::vector<std::string> lst = actions.get_section_names();
for(std::vector<std::string>::iterator i = lst.begin(); i != lst.end(); ++i)
{
int count = 0;
pout(PINGUS_DEBUG_LOADING) << "Actions: " << i->c_str() << std::endl;
if (actions.read_int(i->c_str(), count))
impl->actions[*i] = count;
}
}
else
{
PingusError::raise("Error: (pingus-level head actions) not found in '" + pathname.str() + "'");
}
}
FileReader objects;
if (reader.read_section("objects", objects))
{
std::vector<FileReader> object_lst = objects.get_sections();
for(std::vector<FileReader>::iterator i = object_lst.begin(); i != object_lst.end(); ++i)
{
impl->objects.push_back(*i);
}
}
}
}