refactor: session: provide an iterator over consumer data channel keys
[lttng-tools.git] / src / common / ctl / format.hpp
1 /*
2 * Copyright (C) 2024 Jérémie Galarneau <jeremie.galarneau@efficios.com>
3 *
4 * SPDX-License-Identifier: LGPL-2.1-only
5 *
6 */
7
8 #ifndef LTTNG_COMMON_CTL_FORMAT_H
9 #define LTTNG_COMMON_CTL_FORMAT_H
10
11 #include <common/format.hpp>
12
13 #include <lttng/lttng.h>
14
15 /*
16 * Due to a bug in g++ < 7.1, this specialization must be enclosed in the fmt namespace,
17 * see https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56480.
18 */
19 namespace fmt {
20 template <>
21 struct formatter<lttng_buffer_type> : formatter<std::string> {
22 template <typename FormatContextType>
23 typename FormatContextType::iterator format(lttng_buffer_type buffer_type,
24 FormatContextType& ctx)
25 {
26 auto name = "unknown";
27
28 switch (buffer_type) {
29 case LTTNG_BUFFER_PER_PID:
30 name = "per-pid";
31 break;
32 case LTTNG_BUFFER_PER_UID:
33 name = "per-uid";
34 break;
35 case LTTNG_BUFFER_GLOBAL:
36 name = "global";
37 break;
38 }
39
40 return format_to(ctx.out(), name);
41 }
42 };
43 } /* namespace fmt */
44
45 #endif /* LTTNG_COMMON_CTL_FORMAT_H */
This page took 0.02982 seconds and 4 git commands to generate.