aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/parse_size/parse_size.h
blob: ad235ef02f0e6baa3303d0ac87a48ff2e4a7399a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#pragma once

#include <util/generic/strbuf.h>

namespace NSize {
    ui64 ParseSize(TStringBuf size);

    // Convenient disk size representation with string parsing and integer comparison
    class TSize {
    public:
        TSize(ui64 value = 0)
            : Value(value)
        {
        }

        ui64 GetValue() const {
            return Value;
        }

        operator ui64() const {
            return Value;
        }

    private:
        ui64 Value;
    };

    TSize FromKiloBytes(ui64 value);
    TSize FromMegaBytes(ui64 value);
    TSize FromGigaBytes(ui64 value);
    TSize FromTeraBytes(ui64 value);

}