Browse Source

dataSizeToString can print the exact size additionally

experiment/meta_header
Martchus 7 years ago
parent
commit
8c6f7a9785
  1. 5
      conversion/stringconversion.cpp
  2. 2
      conversion/stringconversion.h

5
conversion/stringconversion.cpp

@ -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();
}

2
conversion/stringconversion.h

@ -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…
Cancel
Save