parse_size.h 628 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include <util/generic/strbuf.h>
  3. namespace NSize {
  4. ui64 ParseSize(TStringBuf size);
  5. // Convenient disk size representation with string parsing and integer comparison
  6. class TSize {
  7. public:
  8. TSize(ui64 value = 0)
  9. : Value(value)
  10. {
  11. }
  12. ui64 GetValue() const {
  13. return Value;
  14. }
  15. operator ui64() const {
  16. return Value;
  17. }
  18. private:
  19. ui64 Value;
  20. };
  21. TSize FromKiloBytes(ui64 value);
  22. TSize FromMegaBytes(ui64 value);
  23. TSize FromGigaBytes(ui64 value);
  24. TSize FromTeraBytes(ui64 value);
  25. }