4#include "Stroika/Foundation/StroikaPreComp.h"
13#include "Stroika/Foundation/Containers/Common.h"
16#include "Stroika/Foundation/Math/Common.h"
23using namespace Stroika::Foundation::Memory;
31String Characters::FormatV (const
wchar_t* format, va_list argsList)
35 const wchar_t* useFormat = format;
36 wchar_t newFormat[5 * 1024];
38 size_t origFormatLen = wcslen (format);
39 Require (origFormatLen < NEltsOf (newFormat) / 2);
41 bool lookingAtFmtCvt =
false;
42 size_t newFormatIdx = 0;
43 for (
size_t i = 0; i < origFormatLen; ++i) {
44 if (lookingAtFmtCvt) {
47 lookingAtFmtCvt =
false;
50 newFormat[newFormatIdx] =
'l';
52 lookingAtFmtCvt =
false;
58 if (isdigit (format[i])) {
62 lookingAtFmtCvt =
false;
68 if (format[i] ==
'%') {
69 lookingAtFmtCvt =
true;
72 newFormat[newFormatIdx] = format[i];
75 Assert (newFormatIdx >= origFormatLen);
76 if (newFormatIdx > origFormatLen) {
77 newFormat[newFormatIdx] =
'\0';
78 useFormat = newFormat;
86 va_copy (argListCopy, argsList);
89 while (::vswprintf (msgBuf.data (), msgBuf.GetSize (), useFormat, argListCopy) < 0) {
90 msgBuf.GrowToSize_uninitialized (msgBuf.GetSize () * 2);
92 va_copy (argListCopy, argsList);
95 Assert (::wcslen (msgBuf.data ()) < msgBuf.GetSize ());
96 return String{msgBuf.data ()};
98DISABLE_COMPILER_MSC_WARNING_END (6262)
105String Characters::Format (const
wchar_t* format, ...)
108 va_start (argsList, format);
109 String tmp = FormatV (format, argsList);
#define RequireNotNull(p)
String is like std::u32string, except it is much easier to use, often much more space efficient,...
Logically halfway between std::array and std::vector; Smart 'direct memory array' - which when needed...
DISABLE_COMPILER_MSC_WARNING_START(4996)