Skip to content

Commit abf17e1

Browse files
committed
get() goes const, add clear()
1 parent b7f5fdd commit abf17e1

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

UserDBentry.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,16 @@ void CUserDBentry::set(const std::string key, const std::string value)
4444
m_db[key] = value;
4545
}
4646

47-
std::string CUserDBentry::get(const std::string key)
47+
const std::string CUserDBentry::get(const std::string key) const
4848
{
4949
try {
5050
return m_db.at(key);
5151
} catch (...) {
5252
return "";
5353
}
5454
}
55+
56+
void CUserDBentry::clear(void)
57+
{
58+
m_db.clear();
59+
}

UserDBentry.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ class CUserDBentry {
4040
static bool isValidKey(const std::string key);
4141

4242
void set(const std::string key, const std::string value);
43-
std::string get(const std::string key);
43+
const std::string get(const std::string key) const;
44+
void clear(void);
4445

4546
private:
4647
std::unordered_map<std::string, std::string> m_db;

0 commit comments

Comments
 (0)