aboutsummaryrefslogtreecommitdiffstats
path: root/util/generic/flags.cpp
blob: 2ee52188a0d986bb3d2656c35416fa0d59bf6544 (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 << ")";
}