IDS peak genericC++ v1.17.0
Loading...
Searching...
No Matches
peak_utils.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
9#include <type_traits>
10#include <iostream>
11
12#if defined(PEAK_ENABLE_FORMAT_SUPPORT) && defined(__has_include)
13# if __has_include(<format>)
14# include <format>
15# include <string_view>
16# endif
17#endif
18
19namespace peak
20{
21namespace core
22{
23template <typename T>
24auto operator<<(std::ostream& os, T entry) ->
25 typename std::enable_if<std::is_enum<T>::value, decltype(os << ToString(entry))>::type
26{
27 return os << ToString(entry);
28}
29
30namespace nodes
31{
32template <typename T>
33auto operator<<(std::ostream& os, T entry) ->
34 typename std::enable_if<std::is_enum<T>::value, decltype(os << ToString(entry))>::type
35{
36 return os << ToString(entry);
37}
38} /* namespace nodes */
39} /* namespace core */
40} /* namespace peak */
41
42#if defined(PEAK_ENABLE_FORMAT_SUPPORT) && defined(__cpp_lib_format)
43
44template <typename T>
45requires std::is_enum_v<T>&& requires(T e)
46{
47 ToString(e);
48}
49struct std::formatter<T> : std::formatter<std::string_view>
50{
51 auto format(T e, std::format_context& ctx) const
52 {
53 return std::formatter<std::string_view>::format(ToString(e), ctx);
54 }
55};
56
57#endif
The "nodes" namespace contains all GenAPI node types.
Definition peak_utils.hpp:31
auto operator<<(std::ostream &os, T entry) -> typename std::enable_if< std::is_enum< T >::value, decltype(os<< ToString(entry))>::type
Definition peak_utils.hpp:33
PEAK_COMMON_NO_DISCARD std::string ToString(NodeCacheUsePolicy entry)
Definition peak_common_node_enums.hpp:69
The "core" namespace contains the direct GenAPI and GenTL wrapper.
Definition peak_buffer.hpp:32
auto operator<<(std::ostream &os, T entry) -> typename std::enable_if< std::is_enum< T >::value, decltype(os<< ToString(entry))>::type
Definition peak_utils.hpp:24
std::string ToString(BufferPayloadType entry)
Definition peak_buffer.hpp:635
The "peak" namespace directly contains convenience functionality like the DeviceManager as well as th...
Definition peak_buffer.hpp:29