Code cleanup: Merged successive string literals in readout

pull/36/head
Tatsuhiro Tsujikawa 2012-12-08 18:46:19 +09:00
parent bf56f3c299
commit 2364f809c3
1 changed files with 20 additions and 35 deletions

View File

@ -106,14 +106,13 @@ void printProgress
eta = (rg->getTotalLength()-rg->getCompletedLength())/stat.downloadSpeed; eta = (rg->getTotalLength()-rg->getCompletedLength())/stat.downloadSpeed;
} }
o << "[" o << "[#" << rg->getGID() << " ";
<< "#" << rg->getGID() << " ";
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
if(rg->getDownloadContext()->hasAttribute(CTX_ATTR_BT) && if(rg->getDownloadContext()->hasAttribute(CTX_ATTR_BT) &&
!bittorrent::getTorrentAttrs(rg->getDownloadContext())->metadata.empty() && !bittorrent::getTorrentAttrs(rg->getDownloadContext())->metadata.empty() &&
rg->downloadFinished()) { rg->downloadFinished()) {
o << "SEEDING" << "(" << "ratio:"; o << "SEEDING(ratio:";
if(rg->getCompletedLength() > 0) { if(rg->getCompletedLength() > 0) {
std::streamsize oldprec = o.precision(); std::streamsize oldprec = o.precision();
o << std::fixed << std::setprecision(1) o << std::fixed << std::setprecision(1)
@ -129,8 +128,7 @@ void printProgress
{ {
o << "SIZE:" o << "SIZE:"
<< sizeFormatter(rg->getCompletedLength()) << sizeFormatter(rg->getCompletedLength())
<< "B" << "B/"
<< "/"
<< sizeFormatter(rg->getTotalLength()) << sizeFormatter(rg->getTotalLength())
<< "B"; << "B";
if(rg->getTotalLength() > 0) { if(rg->getTotalLength() > 0) {
@ -139,33 +137,29 @@ void printProgress
<< "%)"; << "%)";
} }
} }
o << " " o << " CN:"
<< "CN:"
<< rg->getNumConnection(); << rg->getNumConnection();
#ifdef ENABLE_BITTORRENT #ifdef ENABLE_BITTORRENT
const SharedHandle<BtObject>& btObj = e->getBtRegistry()->get(rg->getGID()); const SharedHandle<BtObject>& btObj = e->getBtRegistry()->get(rg->getGID());
if(btObj) { if(btObj) {
std::vector<SharedHandle<Peer> > peers; std::vector<SharedHandle<Peer> > peers;
btObj->peerStorage->getActivePeers(peers); btObj->peerStorage->getActivePeers(peers);
o << " " << "SEED:" o << " SEED:"
<< countSeeder(peers.begin(), peers.end()); << countSeeder(peers.begin(), peers.end());
} }
#endif // ENABLE_BITTORRENT #endif // ENABLE_BITTORRENT
if(!rg->downloadFinished()) { if(!rg->downloadFinished()) {
o << " " o << " SPD:"
<< "SPD:"
<< sizeFormatter(stat.downloadSpeed) << "Bs"; << sizeFormatter(stat.downloadSpeed) << "Bs";
} }
if(stat.sessionUploadLength > 0) { if(stat.sessionUploadLength > 0) {
o << " " o << " UP:"
<< "UP:"
<< sizeFormatter(stat.uploadSpeed) << "Bs" << sizeFormatter(stat.uploadSpeed) << "Bs"
<< "(" << sizeFormatter(stat.allTimeUploadLength) << "B)"; << "(" << sizeFormatter(stat.allTimeUploadLength) << "B)";
} }
if(eta > 0) { if(eta > 0) {
o << " " o << " ETA:"
<< "ETA:"
<< util::secfmt(eta); << util::secfmt(eta);
} }
o << "]"; o << "]";
@ -192,8 +186,7 @@ public:
printProgress(o, rg, e_, sizeFormatter_); printProgress(o, rg, e_, sizeFormatter_);
const std::vector<SharedHandle<FileEntry> >& fileEntries = const std::vector<SharedHandle<FileEntry> >& fileEntries =
rg->getDownloadContext()->getFileEntries(); rg->getDownloadContext()->getFileEntries();
o << "\n" o << "\nFILE: ";
<< "FILE: ";
writeFilePath(fileEntries.begin(), fileEntries.end(), writeFilePath(fileEntries.begin(), fileEntries.end(),
o, rg->inMemoryDownload()); o, rg->inMemoryDownload());
o << "\n" o << "\n"
@ -227,7 +220,7 @@ void printProgressSummary
o << " as of " << buf; o << " as of " << buf;
} }
} }
o << " *** " << "\n" o << " *** \n"
<< std::setfill(SEP_CHAR) << std::setw(cols) << SEP_CHAR << "\n"; << std::setfill(SEP_CHAR) << std::setw(cols) << SEP_CHAR << "\n";
global::cout()->write(o.str().c_str()); global::cout()->write(o.str().c_str());
std::for_each(groups.begin(), groups.end(), std::for_each(groups.begin(), groups.end(),
@ -312,29 +305,25 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
if(e->getRequestGroupMan()->countRequestGroup() > 1 && if(e->getRequestGroupMan()->countRequestGroup() > 1 &&
!e->getRequestGroupMan()->downloadFinished()) { !e->getRequestGroupMan()->downloadFinished()) {
int spd = e->getRequestGroupMan()->getNetStat().calculateDownloadSpeed(); int spd = e->getRequestGroupMan()->getNetStat().calculateDownloadSpeed();
o << " [TOTAL SPD:" << sizeFormatter(spd) << "Bs" << "]"; o << " [TOTAL SPD:" << sizeFormatter(spd) << "Bs]";
} }
{ {
SharedHandle<FileAllocationEntry> entry = SharedHandle<FileAllocationEntry> entry =
e->getFileAllocationMan()->getPickedEntry(); e->getFileAllocationMan()->getPickedEntry();
if(entry) { if(entry) {
o << " " o << " [FileAlloc:"
<< "[FileAlloc:"
<< "#" << entry->getRequestGroup()->getGID() << " " << "#" << entry->getRequestGroup()->getGID() << " "
<< sizeFormatter(entry->getCurrentLength()) << sizeFormatter(entry->getCurrentLength())
<< "B" << "B/"
<< "/"
<< sizeFormatter(entry->getTotalLength()) << sizeFormatter(entry->getTotalLength())
<< "B" << "B(";
<< "(";
if(entry->getTotalLength() > 0) { if(entry->getTotalLength() > 0) {
o << 100LL*entry->getCurrentLength()/entry->getTotalLength(); o << 100LL*entry->getCurrentLength()/entry->getTotalLength();
} else { } else {
o << "--"; o << "--";
} }
o << "%)" o << "%)]";
<< "]";
if(e->getFileAllocationMan()->hasNext()) { if(e->getFileAllocationMan()->hasNext()) {
o << "(" o << "("
<< e->getFileAllocationMan()->countEntryInQueue() << e->getFileAllocationMan()->countEntryInQueue()
@ -347,22 +336,18 @@ ConsoleStatCalc::calculateStat(const DownloadEngine* e)
SharedHandle<CheckIntegrityEntry> entry = SharedHandle<CheckIntegrityEntry> entry =
e->getCheckIntegrityMan()->getPickedEntry(); e->getCheckIntegrityMan()->getPickedEntry();
if(entry) { if(entry) {
o << " " o << " [Checksum:#"
<< "[Checksum:" << entry->getRequestGroup()->getGID() << " "
<< "#" << entry->getRequestGroup()->getGID() << " "
<< sizeFormatter(entry->getCurrentLength()) << sizeFormatter(entry->getCurrentLength())
<< "B" << "B/"
<< "/"
<< sizeFormatter(entry->getTotalLength()) << sizeFormatter(entry->getTotalLength())
<< "B" << "B(";
<< "(";
if(entry->getTotalLength() > 0) { if(entry->getTotalLength() > 0) {
o << 100LL*entry->getCurrentLength()/entry->getTotalLength(); o << 100LL*entry->getCurrentLength()/entry->getTotalLength();
} else { } else {
o << "--"; o << "--";
} }
o << "%)" o << "%)]";
<< "]";
if(e->getCheckIntegrityMan()->hasNext()) { if(e->getCheckIntegrityMan()->hasNext()) {
o << "(" o << "("
<< e->getCheckIntegrityMan()->countEntryInQueue() << e->getCheckIntegrityMan()->countEntryInQueue()