8#include <fmt/ostream.h>
12#ifndef ARP_USE_ARP_SYSTEM_CORE
18#ifndef ARP_INSIDE_ARP_H
19 #error Never include 'BasicFormatter.hxx' directly, just include 'Arp.h'
26template<
typename C,
typename A>
class BasicString;
33template<
typename C,
typename A = std::allocator<C>>
38 using StringType = BasicString<C, A>;
39 using ExceptionHandler = std::function<void(
const char*,
const char*)>;
43 template<
typename... Args>
44 static StringType FormatCommon(ExceptionHandler exceptionHandler,
const StringType& format,
const Args& ... args);
47 template<
typename... Args>
48 static StringType FormatCommon(ExceptionHandler exceptionHandler,
const CharType* format,
const Args& ... args);
51 template<
typename... Args>
52 static StringType FormatPrintf(ExceptionHandler exceptionHandler,
const StringType& format,
const Args& ... args);
55 template<
typename... Args>
56 static StringType FormatPrintf(ExceptionHandler exceptionHandler,
const CharType* format,
const Args& ... args);
61template<
typename C,
typename A>
62template<
typename... Args>
63inline typename BasicFormatter<C, A>::StringType BasicFormatter<C, A>::FormatCommon(ExceptionHandler exceptionHandler,
const StringType& format,
const Args& ... args)
65 return BasicFormatter::FormatCommon(exceptionHandler, format.CStr(), args...);
68template<
typename C,
typename A>
69template<
typename... Args>
70inline typename BasicFormatter<C, A>::StringType BasicFormatter<C, A>::FormatCommon(ExceptionHandler exceptionHandler,
const CharType* format,
const Args& ... args)
74 return fmt::format(fmt::runtime(format), args...);
76 catch (std::exception& e)
78 exceptionHandler(format, e.what());
83template<
typename C,
typename A>
84template<
typename... Args>
85inline typename BasicFormatter<C, A>::StringType BasicFormatter<C, A>::FormatPrintf(ExceptionHandler exceptionHandler,
const StringType& format,
const Args& ... args)
87 return BasicFormatter<C, A>::FormatPrintf(exceptionHandler, format.CStr(), args...);
90template<
typename C,
typename A>
91template<
typename... Args>
92inline typename BasicFormatter<C, A>::StringType BasicFormatter<C, A>::FormatPrintf(ExceptionHandler exceptionHandler,
const CharType* format,
const Args& ... args)
96 return fmt::sprintf(format, args...);
98 catch (std::exception& e)
100 exceptionHandler(format, e.what());
Root namespace for the PLCnext API