aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/flags.cpp
blob: f16a6435624ff02f697af9d2ee7dd8236dd39f63 (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
#include "flags.h"

#include <util/stream/format.h>
#include <util/system/yassert.h>

void ::NPrivate::PrintFlags(IOutputStream& stream, ui64 value, size_t size) { 
    /* Note that this function is in cpp because we need to break circular
     * dependency between TFlags and ENumberFormat. */
    stream << "TFlags(";

    switch (size) {
        case 1: 
            stream << Bin(static_cast<ui8>(value), HF_FULL); 
            break; 
        case 2: 
            stream << Bin(static_cast<ui16>(value), HF_FULL); 
            break; 
        case 4: 
            stream << Bin(static_cast<ui32>(value), HF_FULL); 
            break; 
        case 8: 
            stream << Bin(static_cast<ui64>(value), HF_FULL); 
            break; 
        default: 
            Y_VERIFY(false); 
    }

    stream << ")";
}