本文整理汇总了C++中FileReader::get_sections方法的典型用法代码示例。如果您正苦于以下问题:C++ FileReader::get_sections方法的具体用法?C++ FileReader::get_sections怎么用?C++ FileReader::get_sections使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReader
的用法示例。
在下文中一共展示了FileReader::get_sections方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: runtime_error
TileFactory::TileFactory(const Pathname& filename) :
tiles(),
packers(),
color_packer(),
descriptions()
{
packers.push_back(new TilePacker(1024, 1024));
packers.push_back(new TilePacker(1024, 1024));
color_packer = 0;
FileReader reader = FileReader::parse(filename);
if(reader.get_name() != "windstille-tiles")
{
std::ostringstream msg;
msg << "'" << filename << "' is not a windstille tiles file";
throw std::runtime_error(msg.str());
}
std::vector<FileReader> sections = reader.get_sections();
for(std::vector<FileReader>::iterator i = sections.begin(); i != sections.end(); ++i)
{
if (i->get_name() == "tiles") {
parse_tiles(*i);
} else if (i->get_name() == "tilegroup") {
// ignore
}
}
}
示例2: runtime_error
void
SpriteData::parse(const Pathname& dir, FileReader& reader)
{
std::vector<FileReader> sections = reader.get_sections();
for(std::vector<FileReader>::iterator i = sections.begin(); i != sections.end(); ++i)
actions.push_back(parse_action(dir, *i));
if(actions.size() == 0)
throw std::runtime_error("Sprite contains no actions");
}
示例3:
std::vector<FileReader> get_sections() const
{
std::vector<FileReader> lst = m_reader.get_sections();
std::vector<FileReader> result;
for(auto it = lst.begin(); it != lst.end(); ++it)
{
result.push_back(OverrideFileReader(*it, m_overrides));
}
return result;
}
示例4: parse
void
ResourceManager::parse_section(const std::string& section, FileReader& reader)
{
std::string name;
reader.read_string("name", name);
std::vector<FileReader> sections = reader.get_sections();
for(std::vector<FileReader>::iterator i = sections.begin(); i != sections.end(); ++i)
{
if (section.empty())
parse(name, *i);
else
parse(section + "/" + name, *i);
}
}
示例5: if
void
WorldObjRenderer::process(const FileReader& reader)
{
// FIXME: does not handle sprite alignment
// FIXME: does not handle remove groundpieces
// FIXME: does not handle liquid
if (reader.get_name() == "surface-background" ||
reader.get_name() == "starfield-background" ||
reader.get_name() == "solidcolor-background" ||
reader.get_name() == "snow-generator" ||
reader.get_name() == "rain-generator")
{
// ignore
}
else if (reader.get_name() == "groundpiece" ||
reader.get_name() == "liquid" ||
reader.get_name() == "exit" ||
reader.get_name() == "hotspot")
{
process_object_with_surface(reader);
}
else if (reader.get_name() == "entrance")
{
Vector3f pos;
reader.read_vector("position", pos);
render_sprite(ResDescriptor("entrances/generic"), pos);
}
else if (reader.get_name() == "spike")
{
Vector3f pos;
reader.read_vector("position", pos);
render_surface(ResDescriptor("traps/spike_editor"), pos);
}
else if (reader.get_name() == "switchdoor-switch")
{
Vector3f pos;
reader.read_vector("position", pos);
render_surface(ResDescriptor("worldobjs/switchdoor_switch"), pos);
}
else if (reader.get_name() == "switchdoor-door")
{
Vector3f pos;
reader.read_vector("position", pos);
render_surface(ResDescriptor("worldobjs/switchdoor_box"), pos);
}
else if (reader.get_name() == "group")
{
FileReader objects = reader.read_section("objects");
process(objects.get_sections());
}
else if (reader.get_name() == "prefab")
{
std::string name;
if (!reader.read_string("name", name))
{
log_error("'name' tag missing for prefab");
}
else
{
PrefabFile prefab = PrefabFile::from_resource(name);
Vector3f position;
reader.read_vector("position", position);
push_translate(static_cast<int>(position.x),
static_cast<int>(position.y));
process(prefab.get_objects());
pop_translate();
}
}
else
{
log_error("unknown object type: %1%", reader.get_name());
}
}
示例6: runtime_error
Controller*
Manager::create_controller(const Pathname& filename)
{
std::unique_ptr<Controller> controller(new Controller(desc));
FileReader reader = FileReader::parse(filename);
if (reader.get_name() != "pingus-controller")
{
throw std::runtime_error("Controller: invalid config file '" + filename.str() + "'");
}
else
{
const std::vector<FileReader>& sections = reader.get_sections();
for (std::vector<FileReader>::const_iterator i = sections.begin();
i != sections.end(); ++i)
{
if (StringUtil::has_suffix(i->get_name(), "pointer"))
{
const std::vector<FileReader>& pointers = i->get_sections();
for(std::vector<FileReader>::const_iterator j = pointers.begin(); j != pointers.end(); ++j)
{
int id = desc.get_definition(i->get_name()).id;
ControllerPointer* ctrl_pointer = controller->get_pointer(id);
Pointer* pointer = create_pointer(*j, ctrl_pointer);
if (pointer)
ctrl_pointer->add_pointer(pointer);
else
std::cout << "Manager: pointer: Couldn't create pointer " << j->get_name() << std::endl;
}
}
else if (StringUtil::has_suffix(i->get_name(), "scroller"))
{
const std::vector<FileReader>& scrollers = i->get_sections();
for(std::vector<FileReader>::const_iterator j = scrollers.begin(); j != scrollers.end(); ++j)
{
int id = desc.get_definition(i->get_name()).id;
ControllerScroller* ctrl_scroller = controller->get_scroller(id);
Scroller* scroller = create_scroller(*j, ctrl_scroller);
if (scroller)
ctrl_scroller->add_scroller(scroller);
else
std::cout << "Manager: scroller: Couldn't create scroller " << j->get_name() << std::endl;
}
}
else if (StringUtil::has_suffix(i->get_name(), "button"))
{
const std::vector<FileReader>& buttons = i->get_sections();
for(std::vector<FileReader>::const_iterator j = buttons.begin(); j != buttons.end(); ++j)
{
int id = desc.get_definition(i->get_name()).id;
ControllerButton* ctrl_button = controller->get_button(id);
Button* button = create_button(*j, ctrl_button);
if (button)
ctrl_button->add_button(button);
else
std::cout << "Manager: button: Couldn't create button " << j->get_name() << std::endl;
}
}
else if (StringUtil::has_suffix(i->get_name(), "axis"))
{
const std::vector<FileReader>& axes = i->get_sections();
for(std::vector<FileReader>::const_iterator j = axes.begin(); j != axes.end(); ++j)
{
int id = desc.get_definition(i->get_name()).id;
ControllerAxis* ctrl_axis = controller->get_axis(id);
Axis* axis = create_axis(*j, ctrl_axis);
if (axis)
ctrl_axis->add_axis(axis);
else
std::cout << "Manager: axis: Couldn't create axis " << j->get_name() << std::endl;
}
}
else if (StringUtil::has_suffix(i->get_name(), "keyboard"))
{
const std::vector<FileReader>& keyboards = i->get_sections();
for(std::vector<FileReader>::const_iterator j = keyboards.begin(); j != keyboards.end(); ++j)
{
int id = desc.get_definition(i->get_name()).id;
ControllerKeyboard* ctrl_keyboard = controller->get_keyboard(id);
Keyboard* keyboard = create_keyboard(*j, ctrl_keyboard);
if (keyboard)
ctrl_keyboard->add_keyboard(keyboard);
else
std::cout << "Manager: keyboard: Couldn't create keyboard " << j->get_name() << std::endl;
}
}
else
{
throw std::runtime_error(std::string("Manager: Unkown Element in Controller Config: ")
+ i->get_name());
}
}
}
Controller* ctrl = controller.release();
controllers.push_back(ctrl);
return ctrl;
//.........这里部分代码省略.........
示例7: 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);
}
}
}
}