Skip to content

Commit

Permalink
get() goes const, add clear()
Browse files Browse the repository at this point in the history
  • Loading branch information
jg1uaa committed Mar 7, 2020
1 parent b7f5fdd commit abf17e1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
7 changes: 6 additions & 1 deletion UserDBentry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,16 @@ void CUserDBentry::set(const std::string key, const std::string value)
m_db[key] = value;
}

std::string CUserDBentry::get(const std::string key)
const std::string CUserDBentry::get(const std::string key) const
{
try {
return m_db.at(key);
} catch (...) {
return "";
}
}

void CUserDBentry::clear(void)
{
m_db.clear();
}
3 changes: 2 additions & 1 deletion UserDBentry.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ class CUserDBentry {
static bool isValidKey(const std::string key);

void set(const std::string key, const std::string value);
std::string get(const std::string key);
const std::string get(const std::string key) const;
void clear(void);

private:
std::unordered_map<std::string, std::string> m_db;
Expand Down

0 comments on commit abf17e1

Please sign in to comment.