diff options
| author | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-08-07 00:10:53 +0900 |
|---|---|---|
| committer | Tatsuhiro Tsujikawa <tatsuhiro.t@gmail.com> | 2011-08-07 00:10:53 +0900 |
| commit | 190d1700762e68ae4204b67b07cdf31c550482e4 (patch) | |
| tree | a3599c43dfabbf7f0c6155219573af5caac83aff /src/ServerStat.cc | |
| parent | 7f3d027b83761eacb581624c4ca9d48b668c3a6c (diff) | |
Rewritten ServerStatMan using BufferedFile.
Diffstat (limited to 'src/ServerStat.cc')
| -rw-r--r-- | src/ServerStat.cc | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/src/ServerStat.cc b/src/ServerStat.cc index c841059a..395dc16e 100644 --- a/src/ServerStat.cc +++ b/src/ServerStat.cc @@ -41,6 +41,8 @@ #include "Logger.h" #include "LogFactory.h" #include "fmt.h" +#include "a2functional.h" +#include "util.h" namespace aria2 { @@ -204,17 +206,20 @@ bool ServerStat::operator==(const ServerStat& serverStat) const return hostname_ == serverStat.hostname_ && protocol_ == serverStat.protocol_; } -std::ostream& operator<<(std::ostream& o, const ServerStat& serverStat) -{ - o << "host=" << serverStat.getHostname() << ", " - << "protocol=" << serverStat.getProtocol() << ", " - << "dl_speed=" << serverStat.getDownloadSpeed() << ", " - << "sc_avg_speed=" << serverStat.getSingleConnectionAvgSpeed() << ", " - << "mc_avg_speed=" << serverStat.getMultiConnectionAvgSpeed() << ", " - << "last_updated=" << serverStat.getLastUpdated().getTime() << ", " - << "counter=" << serverStat.getCounter() << ", " - << "status=" << ServerStat::STATUS_STRING[serverStat.getStatus()]; - return o; +std::string ServerStat::toString() const +{ + std::string res; + strappend(res, "host=", getHostname(), ", "); + strappend(res, "protocol=", getProtocol(), ", "); + strappend(res, "dl_speed=", util::uitos(getDownloadSpeed()), ", "); + strappend(res, "sc_avg_speed=", util::uitos(getSingleConnectionAvgSpeed()), + ", "); + strappend(res, "mc_avg_speed=", util::uitos(getMultiConnectionAvgSpeed()), + ", "); + strappend(res, "last_updated=", util::itos(getLastUpdated().getTime()), ", "); + strappend(res, "counter=", util::uitos(getCounter()), ", "); + strappend(res, "status=", ServerStat::STATUS_STRING[getStatus()]); + return res; } } // namespace aria2 |
