Author: aschnell Date: Tue Feb 3 20:48:11 2009 New Revision: 55220 URL: http://svn.opensuse.org/viewcvs/yast?rev=55220&view=rev Log: - whitespace cleanup Modified: trunk/storage/libstorage/src/HumanString.cc Modified: trunk/storage/libstorage/src/HumanString.cc URL: http://svn.opensuse.org/viewcvs/yast/trunk/storage/libstorage/src/HumanString.cc?rev=55220&r1=55219&r2=55220&view=diff ============================================================================== --- trunk/storage/libstorage/src/HumanString.cc (original) +++ trunk/storage/libstorage/src/HumanString.cc Tue Feb 3 20:48:11 2009 @@ -19,14 +19,14 @@ namespace storage { - + int numSuffixes() { return 6; } - - + + string getSuffix(int i, bool classic, bool sloppy = false) { @@ -38,7 +38,7 @@ else /* Byte abbreviated */ return classic ? "B" : _("B"); - + case 1: if (sloppy) /* Kilo abbreviated */ @@ -46,7 +46,7 @@ else /* KiloByte abbreviated */ return classic ? "kB" : _("kB"); - + case 2: if (sloppy) /* Mega abbreviated */ @@ -54,7 +54,7 @@ else /* MegaByte abbreviated */ return classic ? "MB" : _("MB"); - + case 3: if (sloppy) /* Giga abbreviated */ @@ -62,7 +62,7 @@ else /* GigaByte abbreviated */ return classic ? "GB" : _("GB"); - + case 4: if (sloppy) /* Tera abbreviated */ @@ -70,7 +70,7 @@ else /* TeraByte abbreviated */ return classic ? "TB" : _("TB"); - + case 5: if (sloppy) /* Peta abbreviated */ @@ -79,50 +79,50 @@ /* PetaByte abbreviated */ return classic ? "PB" : _("PB"); } - + return string("error"); } - - + + string byteToHumanString(unsigned long long size, bool classic, int precision, bool omit_zeroes) { const locale loc = classic ? locale::classic() : locale(); - + double f = size; int i = 0; - + while (f >= 1024.0 && i + 1 < numSuffixes()) { f /= 1024.0; i++; } - + if (omit_zeroes && (f == (unsigned long long)(f))) { precision = 0; } - + ostringstream s; s.imbue(loc); s.setf(ios::fixed); s.precision(precision); - + s << f << ' ' << getSuffix(i, classic); - + return s.str(); } - - + + bool humanStringToByte(const string& str, bool classic, unsigned long long& size) { const locale loc = classic ? locale::classic() : locale(); - + const string str_trimmed = boost::trim_copy(str, loc); - + double f = 1.0; - + for (int i = 0; i < numSuffixes(); i++) { for (int j = 0; j < (classic ? 1 : 2); j++) @@ -131,13 +131,13 @@ if (boost::iends_with(str_trimmed, suffix, loc)) { string number = str_trimmed.substr(0, str_trimmed.size() - suffix.size()); - + istringstream s(boost::trim_copy(number, loc)); s.imbue(loc); - + double g; s >> g; - + if (!s.fail() && s.eof() && g >= 0.0) { size = g * f; @@ -145,11 +145,11 @@ } } } - + f *= 1024.0; } - + return false; } - + } -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org