8#if !defined(ALIB_C20_MODULES) || ((ALIB_C20_MODULES != 0) && (ALIB_C20_MODULES != 1))
9# error "Symbol ALIB_C20_MODULES has to be given to the compiler as either 0 or 1"
48 fmtCI.
Format( formatSpec.IsNotEmpty() ? formatSpec
52 :
A_CHAR(
"[@ sf:sl from ''ya'' by ''ta'']")
65 while ( format.IsNotEmpty() )
70 while ( format.ConsumeChar(c) )
81 target.InsertChars<NC>(
'\'', pairs );
89 integer end= format.IndexOf(
'\'' );
92 ALIB_WARNING(
"ALIB",
"Format Error: Missing single Quote" )
93 target <<
"Format Error: Missing closing single quote character <'>" ;
97 target._<NC>( format, 0, end );
98 format.ConsumeChars<NC>( end + 1 );
108 if ( format.ConsumeChar(
'f') )
110 if(
ci.File ) target._<NC>(
ci.File );
111 else target._<NC>(
"<NULL>" );
114 if ( format.ConsumeChar(
'l') )
117 target._<NC>(
ci.Line );
120 if ( format.ConsumeChar(
'm') )
123 target._<NC>(
ci.Func );
128 target.InsertChars<NC>( c, n );
132 #if !ALIB_SINGLE_THREADED
141 if ( format.ConsumeChar(
'n') )
143 target._<NC>( thread ? thread->GetName()
153 if ( format.ConsumeChar(
'i') )
155 if ( thread ) target._<NC>( thread->GetID() );
159 else target._<NC>(
A_CHAR(
"<Null>") );
165 if ( format.ConsumeChar(
'c') )
167 if constexpr (
sizeof(std::thread::id) ==
sizeof(uint16_t) )
169 uint16_t nativeID= 0;
170 memcpy(&nativeID, &
ci.ThreadID, 2);
171 target._<NC>(
"0x")._<NC>(
Hex(nativeID, 4));
173 if constexpr (
sizeof(std::thread::id) ==
sizeof(uint32_t) )
175 uint32_t nativeID= 0;
176 memcpy(&nativeID, &
ci.ThreadID, 4);
177 target._<NC>(
"0x")._<NC>(
Hex(nativeID, 8));
179 if constexpr (
sizeof(std::thread::id) ==
sizeof(uint64_t) )
181 uint64_t nativeID= 0;
182 memcpy(&nativeID, &
ci.ThreadID, 8);
183 target._<NC>(
"0x")._<NC>(
Hex(nativeID, 16));
190 if ( format.ConsumeChar(
'a') )
192 target._<NC>(
ci.ThreadID );
197 target.InsertChars<NC>( c, n );
208 if ( format.ConsumeChar(
'f') )
213 if (!
ci.TypeInfo) target._<NC>(
220 else target << lang::DbgTypeDemangler(*
ci.TypeInfo).Get();
226 if ( format.ConsumeChar(
'n') )
249 if ( format.ConsumeChar(
'a') )
252 target._<NC>(
ci.Func )._<NC>(
"()");
255 target._<NC>( *
ci.TypeInfo )._<NC>(
"::");
256 target._<NC>(
ci.Func )._<NC>(
"()");
263 target.InsertChars<NC>( c, n );
268 target.InsertChars<NC>( c, n );
282DOX_MARKER([DOX_BOXING_IFORMAT_DATETIME])
285 strings::util::CalendarDateTime tct( box.Unbox<
DateTime>() );
286 tct.Format( formatSpec.IsNotEmpty() ? formatSpec
290 :
A_CHAR(
"yyyy-MM-dd HH:mm:ss" ),
294DOX_MARKER([DOX_BOXING_IFORMAT_DATETIME])
309 double v= double(val);
312 if( unit < ByteSizeUnits::IEC_END)
315 divisor= double(1024);
319 loopEnd= int(unit - ByteSizeUnits::SI);
320 divisor= double(1000);
323 for (
int i = 0; i < loopEnd; ++i)
332 if( val < byteLimit )
338 if( val < byteLimit * factor)
339 return std::make_pair(
double(val) /
double(factor), unit );
350 target.EnsureRemainingCapacity(128);
352 auto magnitude= (unit == ByteSizeUnits::IEC) ? getMagnitude(val, magnitudeThreshold, 1024ull)
353 : getMagnitude(val, magnitudeThreshold, 1000ull);
355 if( magnitude.second == ByteSizeUnits::IEC )
356 target <<
Dec( val,
nullptr );
359 target.VBuffer(), target.Length(), 0, nf) );
362 target << unitSeparator;
363 target << (magnitude.second + unit);
368 auto result= getMagnitude( Value, MagnitudeThreshold, 1024 );
369 result.second+= ByteSizeUnits::IEC;
375 auto result= getMagnitude( Value, MagnitudeThreshold, 1000 );
376 result.second+= ByteSizeUnits::SI;
381double ByteSizeSI ::ConvertTo(
ByteSizeUnits unit) {
return convertTo(Value, unit); };
384}
namespace alib::strings {
386void AppendableTraits< format::ByteSizeSI, character, lang::HeapAllocator>::operator()( AString& target,
const format::ByteSizeSI src )
388 format::FormatByteSize( target, src.Value, src.MagnitudeThreshold, src.UnitSeparator,
389 format::ByteSizeUnits::SI, * format::BYTESIZE_NUMBER_FORMAT );
391void AppendableTraits< format::ByteSizeIEC, character, lang::HeapAllocator>::operator()( AString& target,
const format::ByteSizeIEC src )
393 format::FormatByteSize( target, src.Value, src.MagnitudeThreshold, src.UnitSeparator,
394 format::ByteSizeUnits::IEC, * format::BYTESIZE_NUMBER_FORMAT );
const String & GetResource(const NString &name)
TAString & _(const TAppendable &src)
static ALIB_DLL Thread * Get(std::thread::id nativeID)
#define ALIB_BOXING_VTABLE_DEFINE(TMapped, Identifier)
#define ALIB_WARNINGS_RESTORE
#define ALIB_WARNING(domain,...)
#define ALIB_WARNINGS_IGNORE_NOTHING_RETURNED
void typeName(const detail::VTable *vtable, AString &result)
@ Clear
Chooses to clear existing data.
ALIB_DLL integer WriteFloat(double value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf)
strings::TDec< character > Dec
Type alias in namespace alib.
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
camp::Basecamp BASECAMP
The singleton instance of ALib Camp class Basecamp.
NLocalString< 2048 > NString2K
Type alias name for TLocalString<nchar,2048>.
time::DateTime DateTime
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
strings::TNumberFormat< character > NumberFormat
Type alias in namespace alib.
threads::Thread Thread
Type alias in namespace alib.
strings::THex< character > Hex
Type alias in namespace alib.
boxing::Box Box
Type alias in namespace alib.
lang::CallerInfo CallerInfo
Type alias in namespace alib.
strings::TString< character > String
Type alias in namespace alib.
characters::character character
Type alias in namespace alib.
lang::uinteger uinteger
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.