dataSizeToString can print the exact size additionally
This commit is contained in:
parent
72b7afb17e
commit
8c6f7a9785
|
@ -25,7 +25,7 @@ void truncateString(string &str, char terminationChar)
|
|||
*
|
||||
* The unit with appropriate binary prefix will be appended.
|
||||
*/
|
||||
string dataSizeToString(uint64 sizeInByte)
|
||||
string dataSizeToString(uint64 sizeInByte, bool includeByte)
|
||||
{
|
||||
stringstream res(stringstream::in | stringstream::out);
|
||||
res.setf(ios::fixed, ios::floatfield);
|
||||
|
@ -41,6 +41,9 @@ string dataSizeToString(uint64 sizeInByte)
|
|||
} else {
|
||||
res << (static_cast<double>(sizeInByte) / 1099511627776.0) << " TiB";
|
||||
}
|
||||
if(includeByte && sizeInByte > 1024LL) {
|
||||
res << ' ' << '(' << sizeInByte << " byte)";
|
||||
}
|
||||
return res.str();
|
||||
}
|
||||
|
||||
|
|
|
@ -194,7 +194,7 @@ template <typename T> LIB_EXPORT std::string interpretIntegerAsString(T integer,
|
|||
return std::string(buffer + startOffset, sizeof(T) - startOffset);
|
||||
}
|
||||
|
||||
LIB_EXPORT std::string dataSizeToString(uint64 sizeInByte);
|
||||
LIB_EXPORT std::string dataSizeToString(uint64 sizeInByte, bool includeByte = false);
|
||||
LIB_EXPORT std::string bitrateToString(double speedInKbitsPerSecond, bool useByteInsteadOfBits = false);
|
||||
LIB_EXPORT std::string encodeBase64(const std::vector<char> &bytes);
|
||||
LIB_EXPORT std::vector<char> decodeBase64(const std::string &encoded);
|
||||
|
|
Loading…
Reference in New Issue