Add a name_mapper mapping the HumanReadable name to the id.

This commit is contained in:
Matthieu Gautier
2019-08-10 17:06:17 +02:00
parent abb5db0193
commit d90f8b0f05
3 changed files with 77 additions and 0 deletions

View File

@ -21,10 +21,13 @@
#define KIWIX_NAMEMAPPER_H
#include <string>
#include <map>
namespace kiwix
{
class Library;
class NameMapper {
public:
virtual ~NameMapper() = default;
@ -39,6 +42,20 @@ class IdNameMapper : public NameMapper {
virtual std::string getIdForName(const std::string& name) { return name; };
};
class HumanReadableNameMapper : public NameMapper {
private:
std::map<std::string, std::string> m_idToName;
std::map<std::string, std::string> m_nameToId;
public:
HumanReadableNameMapper(kiwix::Library& library, bool withAlias);
virtual ~HumanReadableNameMapper() = default;
virtual std::string getNameForId(const std::string& id);
virtual std::string getIdForName(const std::string& name);
};
}
#endif