add FileSize::operator std::string() const
This commit is contained in:
parent
feac7be191
commit
79e47c3cda
6
Log.cpp
6
Log.cpp
|
@ -297,6 +297,12 @@ std::ostream& operator<<(std::ostream& str, const PrintErrno&) {
|
||||||
return str << strerror(errno) << " (" << errno << ')';
|
return str << strerror(errno) << " (" << errno << ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FileSize::operator std::string() const {
|
||||||
|
std::ostringstream str;
|
||||||
|
str << *this;
|
||||||
|
return str.str();
|
||||||
|
}
|
||||||
|
|
||||||
std::ostream& operator<<(std::ostream& str, const FileSize& fs) {
|
std::ostream& operator<<(std::ostream& str, const FileSize& fs) {
|
||||||
static const char PREFIX[] {' ', 'K', 'M', 'G', 'T', 'P', 'E'};
|
static const char PREFIX[] {' ', 'K', 'M', 'G', 'T', 'P', 'E'};
|
||||||
static const uint_fast8_t PREFIXCOUNT = 7;
|
static const uint_fast8_t PREFIXCOUNT = 7;
|
||||||
|
|
1
Log.h
1
Log.h
|
@ -122,6 +122,7 @@ public:
|
||||||
explicit FileSize(uint64_t fs) : fs(fs) {}
|
explicit FileSize(uint64_t fs) : fs(fs) {}
|
||||||
FileSize(const FileSize&) = delete;
|
FileSize(const FileSize&) = delete;
|
||||||
FileSize& operator=(const FileSize&) = delete;
|
FileSize& operator=(const FileSize&) = delete;
|
||||||
|
operator std::string() const;
|
||||||
private:
|
private:
|
||||||
uint64_t fs;
|
uint64_t fs;
|
||||||
friend std::ostream& operator<<(std::ostream& str, const FileSize& fs);
|
friend std::ostream& operator<<(std::ostream& str, const FileSize& fs);
|
||||||
|
|
Loading…
Reference in New Issue