Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
Stroika::Foundation::Characters::FormatString< CHAR_T > Struct Template Reference

Stroika's format string: it always formats WIDE - each argument as std::formatter<T, wchar_t> formats it - into a String; written narrow ("..."_f) only as a terser spelling, so then it must be ASCII. More...

#include <Format.h>

Public Member Functions

constexpr wstring_view get () const
 
constexpr qStroika_Foundation_Characters_FMT_PREFIX_::wstring_view getx_ () const
 the format string as the formatting library's own wstring_view (std's, or fmtlib's) - only for calling Common::StdCompat::vformat directly
 
template<IFormattable... ARGS>
String operator() (ARGS &&... args) const
 format args - checked against the format string at run time: a mismatch throws format_error (a FormatLiteral, "..."_f, checks at compile time)
 
template<IFormattable... ARGS>
String operator() (const locale &loc, ARGS &&... args) const
 As above, with a locale.
 

Detailed Description

template<typename CHAR_T>
struct Stroika::Foundation::Characters::FormatString< CHAR_T >

Stroika's format string: it always formats WIDE - each argument as std::formatter<T, wchar_t> formats it - into a String; written narrow ("..."_f) only as a terser spelling, so then it must be ASCII.

A narrow format string (FormatString<char>) must be ASCII - so what it means cannot depend on the compiler's narrow character set. A wide one may be any UNICODE, and so may what is formatted into either - a String, say.

But EITHER way it produces a fully UNICODE String, and all the conversions - {} - are UNICODE.

For narrow output instead - a std::string, in the program's narrow character set - use std::format with a narrow format string. Stroika's own types format there too (a String as AsNarrowSDKString (eIgnoreErrors) gives it), but not what only _f adds: the types std::format cannot format, formatted through their Characters::ToString (

See also
IFormattable).
Note
A FormatString<wchar_t> views its text, so that text must last as long as the program (
See also
String::FromStringConstant)
  • Debug builds check it. A FormatString<char> keeps its own, widened, copy; "..."_f's is static (
FormatLiteral).
Note
What it formats:
See also
IFormattable.
Example Usage
String a = FormatString<char>{"Internet Media Type {} not supported"sv}(mediaType); // checked at run time
String sameAsA = "Internet Media Type {} not supported"_f (mediaType); // checked at compile time
DbgTrace ("prettyVersionString={}"_f, ppv);
DbgTrace ("currentException={}"_f, current_exception ());
DbgTrace ("seq={}"_f, Sequence<IO::Networking::URI>{...});
#define DbgTrace
Definition Trace.h:327
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Definition String.h:201
Stroika's format string: it always formats WIDE - each argument as std::formatter<T,...

Definition at line 103 of file Characters/Format.h.

Member Function Documentation

◆ get()

template<typename CHAR_T >
constexpr wstring_view Stroika::Foundation::Characters::FormatString< CHAR_T >::get ( ) const
constexpr

This retrieves the underlying string data - for the format string itself (regardless of how created, as a wstring_view).

Definition at line 107 of file Characters/Format.inl.


The documentation for this struct was generated from the following files: