From eb7873a10d1827df6317065be71d18de69047fdd Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Tue, 5 Nov 2013 19:04:47 +0000 Subject: Support the 'infoname' key in zone ini files. --- src/core/parser.cc | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) (limited to 'src/core') diff --git a/src/core/parser.cc b/src/core/parser.cc index ab280e4..a260c19 100644 --- a/src/core/parser.cc +++ b/src/core/parser.cc @@ -13,7 +13,25 @@ namespace core { -bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity) +Info *get_entity_info(Entity *entity) +{ + Info *info = Info::find(entity->info()); + + if (!info) { + std::string labelstr; + if (entity->zone()) { + labelstr.append(entity->zone()->label()); + labelstr += ':'; + } + labelstr.append(entity->label()); + info = new Info(Entity::infotype(), labelstr.c_str()); + entity->set_info(info); + } + + return info; +} + +bool Parser::got_entity_key(filesystem::IniFile &inifile, Entity *entity) { if (!entity) return false; @@ -50,20 +68,14 @@ bool Parser::got_entity_key(filesystem::IniFile &inifile, core::Entity *entity) } else if (inifile.got_key_string("info", strval)) { - Info *info = Info::find(entity->info()); - if (!info) { - std::string labelstr; - if (entity->zone()) { - labelstr.append(entity->zone()->label()); - labelstr += ':'; - } - labelstr.append(entity->label()); - info = new Info(Entity::infotype(), labelstr.c_str()); - entity->set_info(info); - } - + Info *info = get_entity_info(entity); info->add_text(strval); + return true; + + } else if (inifile.got_key_string("infoname", strval)) { + Info *info = get_entity_info(entity); + info->set_name(strval); return true; } else if (inifile.got_key_label("label", strval)) { -- cgit v1.2.3