aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/string_utils/parse_size/parse_size.h
blob: c9fa92980b39b2d0beff7a7643f1ef695ad8ebdc (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); 

}