diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-07-09 15:40:49 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-07-09 15:40:49 +0200 |
commit | 713fa43b98b5f4de918253f6fc735cd8542e25e3 (patch) | |
tree | 7a3c39f63c84a31d84c7f5f88c01a5acbf2a04fd | |
parent | da877e4750333f02c48a667241a41412c38bfd16 (diff) |
core_whowas Return a WhoWas::Manager::Stats struct from GetStats() instead of a string
-rw-r--r-- | include/commands/cmd_whowas.h | 11 | ||||
-rw-r--r-- | src/coremods/core_whowas.cpp | 9 |
2 files changed, 15 insertions, 5 deletions
diff --git a/include/commands/cmd_whowas.h b/include/commands/cmd_whowas.h index f9b232281..a17785c22 100644 --- a/include/commands/cmd_whowas.h +++ b/include/commands/cmd_whowas.h @@ -60,15 +60,22 @@ namespace WhoWas class Manager { public: + struct Stats + { + /** Number of currently existing WhoWasGroup objects + */ + size_t entrycount; + }; + /** Add a user to the whowas database. Called when a user quits. * @param user The user to add to the database */ void Add(User* user); /** Retrieves statistics about the whowas database - * @return Whowas statistics + * @return Whowas statistics as a WhoWas::Manager::Stats struct */ - std::string GetStats() const; + Stats GetStats() const; /** Expires old entries */ diff --git a/src/coremods/core_whowas.cpp b/src/coremods/core_whowas.cpp index fee40377a..18c419c75 100644 --- a/src/coremods/core_whowas.cpp +++ b/src/coremods/core_whowas.cpp @@ -88,7 +88,7 @@ const WhoWas::Nick* WhoWas::Manager::FindNick(const std::string& nickname) const return nick; } -std::string WhoWas::Manager::GetStats() const +WhoWas::Manager::Stats WhoWas::Manager::GetStats() const { size_t entrycount = 0; for (whowas_users::const_iterator i = whowas.begin(); i != whowas.end(); ++i) @@ -96,7 +96,10 @@ std::string WhoWas::Manager::GetStats() const WhoWas::Nick::List& list = i->second->entries; entrycount += list.size(); } - return "Whowas entries: " + ConvToStr(entrycount); + + Stats stats; + stats.entrycount = entrycount; + return stats; } void WhoWas::Manager::Add(User* user) @@ -259,7 +262,7 @@ class ModuleWhoWas : public Module ModResult OnStats(char symbol, User* user, string_list &results) { if (symbol == 'z') - results.push_back("249 "+user->nick+" :"+cmd.manager.GetStats()); + results.push_back("249 "+user->nick+" :Whowas entries: "+ConvToStr(cmd.manager.GetStats().entrycount)); return MOD_RES_PASSTHRU; } |