15.12.2011 - version 0.1.1

This commit is contained in:
peri4
2011-12-15 22:39:40 +03:00
parent 74b4173c4c
commit f141bab1c8
18 changed files with 361 additions and 111 deletions

View File

@@ -215,6 +215,7 @@ PIString & PIString::replace(const PIString & what, const PIString & with, bool
PIString & PIString::replaceAll(const PIString & what, const PIString & with) {
if (what.isEmpty()) return *this;
bool ok = true;
while (ok) replace(what, with, &ok);
return *this;
@@ -357,6 +358,29 @@ llong PIString::toLLong() const {
}
PIString & PIString::setReadableSize(long bytes) {
clear();
if (bytes < 1024) {*this += (PIString::fromNumber(bytes) + " B"); return *this;}
double fres = bytes / 1024.;
long res = bytes / 1024;
fres -= res;
if (res < 1024) {*this += (PIString::fromNumber(res) + "." + PIString::fromNumber(int(fres * 10)).left(1) + " kB"); return *this;}
fres = res / 1024.;
res /= 1024;
fres -= res;
if (res < 1024) {*this += (PIString::fromNumber(res) + "." + PIString::fromNumber(int(fres * 10)).left(1) + " MB"); return *this;}
fres = res / 1024.;
res /= 1024;
fres -= res;
if (res < 1024) {*this += (PIString::fromNumber(res) + "." + PIString::fromNumber(int(fres * 10)).left(1) + " GB"); return *this;}
fres = res / 1024.;
res /= 1024;
fres -= res;
*this += (PIString::fromNumber(res) + "." + PIString::fromNumber(int(fres * 10)).left(1) + " PB");
return *this;
}
char chrUpr(char c) {
if (c >= 'a' && c <= 'z') return c + 'A' - 'a';
//if (c >= 'а' && c <= 'я') return c + 'А' - 'а';