aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/yson_pull/detail/number.h
blob: b620082d9d443b01f80d358a153f6379999db454 (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
34
35
36
37
#pragma once

#include <util/system/types.h>

namespace NYsonPull { 
    namespace NDetail { 
        enum class number_type { 
            float64, 
            uint64, 
            int64 
        }; 

        struct number { 
            number_type type; 
            union { 
                double as_float64; 
                ui64 as_uint64; 
                i64 as_int64; 
            } value; 

            number(double v) { 
                type = number_type::float64; 
                value.as_float64 = v; 
            } 

            number(i64 v) { 
                type = number_type::int64; 
                value.as_int64 = v; 
            } 

            number(ui64 v) { 
                type = number_type::uint64; 
                value.as_uint64 = v; 
            } 
        }; 
    }
}