4#ifndef _Stroika_Foundation_Characters_Format_h_
5#define _Stroika_Foundation_Characters_Format_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
13#include "Stroika/Foundation/Common/Common.h"
14#include "Stroika/Foundation/Common/Concepts.h"
41 template <
typename RESULT,
typename F,
typename... ARGS>
42 RESULT WithFormatArgs_ (F&& f,
const ARGS&... args);
44#if qStroika_Foundation_Debug_AssertionsChecked
49 bool LastsAppLifetime_ (wstring_view s);
55 template <
typename CHAR_T,
size_t N>
57 using CharType = CHAR_T;
58 static constexpr size_t kChars = N - 1;
66 template <FixedString_ LITERAL>
67 consteval array<wchar_t,
decltype (LITERAL)::kChars + 1> Widen_ ();
70 template <FixedString_ LITERAL>
71 consteval bool IsASCII_ ();
102 template <
typename CHAR_T>
113 constexpr FormatString (
const basic_string_view<CHAR_T>& s);
119 constexpr wstring_view
get ()
const;
126 constexpr qStroika_Foundation_Characters_FMT_PREFIX_::wstring_view
getx_ ()
const;
136 [[nodiscard]]
inline String operator() (
const locale& loc, ARGS&&... args)
const;
142 struct Unchecked_ {};
143 constexpr FormatString (
const basic_string_view<CHAR_T>& s, Unchecked_);
148 template <
typename CHAR_T>
150 template <
typename CHAR_T>
160 vector<wchar_t> fStringData_;
165#if !qCompilerAndStdLib_vector_constexpr_Buggy
169#if !qCompilerAndStdLib_vector_constexpr_Buggy
174#if !qCompilerAndStdLib_vector_constexpr_Buggy
179 constexpr wstring_view
get ()
const;
180 constexpr qStroika_Foundation_Characters_FMT_PREFIX_::wstring_view
getx_ ()
const;
181 template <Stroika_Foundation_Common_formattable_FilterOnStringLitOp_BWA (
IFormattable)... ARGS>
183 template <Stroika_Foundation_Common_formattable_FilterOnStringLitOp_BWA (
IFormattable)... ARGS>
184 [[nodiscard]]
inline String operator() (
const locale& loc, ARGS&&... args)
const;
204 template <Private_::FixedString_ LITERAL>
206 static_assert (
Common::IAnyOf<
typename decltype (LITERAL)::CharType,
char,
wchar_t>);
207 static_assert (Private_::IsASCII_<LITERAL> (),
"a narrow \"...\"_f must be ASCII");
218 template <Stroika_Foundation_Common_formattable_FilterOnStringLitOp_BWA (
IFormattable)... ARGS>
220 template <Stroika_Foundation_Common_formattable_FilterOnStringLitOp_BWA (
IFormattable)... ARGS>
227 template <
typename... ARGS>
235 requires (same_as<
typename decltype (LITERAL)::CharType,
char>);
239 using FormatLiteralTag_ = void;
243 static constexpr array<wchar_t,
decltype (LITERAL)::kChars + 1> kWide_ = Private_::Widen_<LITERAL> ();
252 template <
typename T>
253 concept IFormatLiteral =
requires {
typename remove_cvref_t<T>::FormatLiteralTag_; };
267 inline namespace Literals {
268 template <Private_::FixedString_ LITERAL>
277 template <
typename CHAR_T>
279 template <
typename CHAR_T>
289 [[deprecated (
"Since Stroika v3.0d6 - use _f format strings - not old style c format strings - use CString::Format for old style C "
290 "format strings")]]
String
291 Format (
const wchar_t* format, ...);
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Check if legal to call Characters::ToString(T)...
Concept: trivial shorthand for variadic same_as A or same_as B, or ...
String FormatV(const wchar_t *format, va_list argsList)
printf-style formatting of a va_list, into a String - with one difference from vswprintf: s takes a c...
String VFormat(const FormatString< CHAR_T > &f, const Common::StdCompat::wformat_args &args)
same as std::vformat, except that it always uses wformat_args, and produces a Stroika String