aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/messagebus/local_flags.cpp
blob: 877e533f763bbe511c81787f30169bac81a70608 (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
#include "local_flags.h"

#include <util/stream/str.h>
#include <util/string/printf.h>

using namespace NBus;
using namespace NBus::NPrivate;

TString NBus::NPrivate::LocalFlagSetToString(ui32 flags0) {
    if (flags0 == 0) {
        return "0";
    }

    ui32 flags = flags0;

    TStringStream ss;
#define P(name, value, ...)          \
    do                               \
        if (flags & value) {         \
            if (!ss.Str().empty()) { \
                ss << "|";           \
            }                        \
            ss << #name;             \
            flags &= ~name;          \
        }                            \
    while (false);
    MESSAGE_LOCAL_FLAGS_MAP(P)
    if (flags != 0) {
        return Sprintf("0x%x", unsigned(flags0));
    }
    return ss.Str();
}