fmt formatter function for json class able to handle 2 types of formats : {} : in this case the type entry of json is used to deduce what to print, looking into the registry {:name|fmt} : in this case, the entry 'name' of the json will be printed in given format.
More...
|
| template<typename ParseContext > |
| constexpr auto | parse (ParseContext &ctx) |
| |
| template<typename FormatContext > |
| auto | format (const json_fmt_arg &json_arg, FormatContext &ctx) const |
| |
fmt formatter function for json class able to handle 2 types of formats : {} : in this case the type entry of json is used to deduce what to print, looking into the registry {:name|fmt} : in this case, the entry 'name' of the json will be printed in given format.
See comment on registry for more details
Definition at line 102 of file MessageSvcSink.cpp.
◆ format()
template<typename FormatContext >
| auto fmt::formatter< json_fmt_arg >::format |
( |
const json_fmt_arg & |
json_arg, |
|
|
FormatContext & |
ctx |
|
) |
| const |
|
inline |
Definition at line 120 of file MessageSvcSink.cpp.
121 const auto&
j = json_arg.payload;
124 const auto type =
j.at(
"type" ).get<std::string>();
126 std::string_view type_key{
type };
128 auto entry =
registry.find( type_key );
130 auto sep = type_key.rfind(
':' );
131 while ( sep != type_key.npos && entry ==
registry.end() ) {
133 type_key.remove_suffix( type_key.size() - sep );
135 sep = type_key.rfind(
':' );
144 return fmt::format_to(
ctx.out(), fmt::runtime( entry->second ), json_arg );
150 return fmt::format_to(
ctx.out(), fmt::runtime( actualFormat ),
153 return fmt::format_to(
ctx.out(), fmt::runtime( actualFormat ),
j.at(
currentName ).template get<double>() );
155 actualFormat[actualFormat.size() - 2] =
'g';
156 return fmt::format_to(
ctx.out(), fmt::runtime( actualFormat ),
159 return fmt::format_to(
ctx.out(),
"Unknown counter format : {}",
currentFormat );
◆ parse()
template<typename ParseContext >
| constexpr auto fmt::formatter< json_fmt_arg >::parse |
( |
ParseContext & |
ctx | ) |
|
|
inlineconstexpr |
Definition at line 105 of file MessageSvcSink.cpp.
106 auto fmt_begin =
ctx.begin();
107 auto fmt_end = std::find( fmt_begin,
ctx.end(),
'}' );
108 if ( fmt_begin == fmt_end ) {
113 auto fmt_colon = std::find( fmt_begin, fmt_end,
'|' );
114 currentName = std::string( fmt_begin, fmt_colon - fmt_begin );
115 currentFormat = std::string( fmt_colon + 1, fmt_end - fmt_colon - 1 );
◆ currentFormat
| std::string fmt::formatter< json_fmt_arg >::currentFormat |
|
private |
◆ currentName
| std::string fmt::formatter< json_fmt_arg >::currentName |
|
private |
The documentation for this class was generated from the following file: