diff --git a/libs/libnamemanager/src/base/module_name_map.cpp b/libs/libnamemanager/src/base/module_name_map.cpp index bcb1c23c2..7cceb6506 100644 --- a/libs/libnamemanager/src/base/module_name_map.cpp +++ b/libs/libnamemanager/src/base/module_name_map.cpp @@ -26,6 +26,14 @@ std::string ModuleNameMap::name(const std::string& tag) const { return result->second; } +std::vector ModuleNameMap::tags() const { + std::vector keys; + for (auto const& element : tag2names_) { + keys.push_back(element.first); + } + return keys; +} + int ModuleNameMap::set_tag_to_name_pair(const std::string& tag, const std::string& name) { /* tagA <--x--> nameA * | @@ -45,6 +53,7 @@ int ModuleNameMap::set_tag_to_name_pair(const std::string& tag, const std::strin tag2names_[tag] = name; /* Clean up */ name2tags_.erase(name); + return CMD_EXEC_SUCCESS; } } /* end namespace openfpga */ diff --git a/libs/libnamemanager/src/base/module_name_map.h b/libs/libnamemanager/src/base/module_name_map.h index d2c921b81..c9bcf1c81 100644 --- a/libs/libnamemanager/src/base/module_name_map.h +++ b/libs/libnamemanager/src/base/module_name_map.h @@ -5,6 +5,7 @@ * Include header files required by the data structure definition *******************************************************************/ #include +#include #include /* Begin namespace openfpga */ @@ -17,6 +18,8 @@ class ModuleNameMap { public: /* Public accessors */ /** @brief Get customized name with a given tag */ std::string name(const std::string& tag) const; + /** @brief return a list of all the current keys */ + std::vector tags() const; public: /* Public mutators */ /** @brief Create the one-on-one mapping between an built-in name and a customized name. Return 0 for success, return 1 for fail */ diff --git a/libs/libnamemanager/src/io/read_xml_module_name_map.cpp b/libs/libnamemanager/src/io/read_xml_module_name_map.cpp index 3b93a543e..3b1f76ed2 100644 --- a/libs/libnamemanager/src/io/read_xml_module_name_map.cpp +++ b/libs/libnamemanager/src/io/read_xml_module_name_map.cpp @@ -30,10 +30,10 @@ static int read_xml_module_name_binding(pugi::xml_node& xml_binding, const pugiutil::loc_data& loc_data, ModuleNameMap& module_name_map) { std::string default_name = - get_attribute(xml_port, XML_MODULE_NAME_ATTRIBUTE_DEFAULT, loc_data) + get_attribute(xml_binding, XML_MODULE_NAME_ATTRIBUTE_DEFAULT, loc_data) .as_string(); std::string given_name = - get_attribute(xml_port, XML_MODULE_NAME_ATTRIBUTE_GIVEN, loc_data) + get_attribute(xml_binding, XML_MODULE_NAME_ATTRIBUTE_GIVEN, loc_data) .as_string(); return module_name_map.set_tag_to_name_pair(default_name, given_name);