5 fmtCI.
Format( formatSpec.IsNotEmpty() ? formatSpec
9 :
A_CHAR(
"[@ sf:sl from ''ya'' by ''ta'']")
22 while ( format.IsNotEmpty() ) {
26 while ( format.ConsumeChar(c) )
35 target.InsertChars<NC>(
'\'', pairs );
42 integer end= format.IndexOf(
'\'' );
44 ALIB_WARNING(
"ALIB",
"Format Error: Missing single Quote" )
45 target <<
"Format Error: Missing closing single quote character <'>" ;
49 target._<NC>( format, 0, end );
50 format.ConsumeChars<NC>( end + 1 );
59 if ( format.ConsumeChar(
'f') ) {
60 if(
ci.File ) target._<NC>(
ci.File );
61 else target._<NC>(
"<NULL>" );
64 if ( format.ConsumeChar(
'l') ) {
66 target._<NC>(
ci.Line );
69 if ( format.ConsumeChar(
'm') ) {
71 target._<NC>(
ci.Func );
75 target.InsertChars<NC>( c, n );
79 #if !ALIB_SINGLE_THREADED
87 if ( format.ConsumeChar(
'n') ) {
88 target._<NC>( thread ? thread->GetName()
98 if ( format.ConsumeChar(
'i') ) {
99 if ( thread ) target._<NC>( thread->GetID() );
103 else target._<NC>(
A_CHAR(
"<Null>") );
109 if ( format.ConsumeChar(
'c') ) {
110 if constexpr (
sizeof(std::thread::id) ==
sizeof(uint16_t) ) {
111 uint16_t nativeID= 0;
112 std::memcpy(&nativeID, &
ci.ThreadID, 2);
113 target._<NC>(
"0x")._<NC>(
Hex(nativeID, 4));
115 if constexpr (
sizeof(std::thread::id) ==
sizeof(uint32_t) ) {
116 uint32_t nativeID= 0;
117 std::memcpy(&nativeID, &
ci.ThreadID, 4);
118 target._<NC>(
"0x")._<NC>(
Hex(nativeID, 8));
120 if constexpr (
sizeof(std::thread::id) ==
sizeof(uint64_t) ) {
121 uint64_t nativeID= 0;
122 std::memcpy(&nativeID, &
ci.ThreadID, 8);
123 target._<NC>(
"0x")._<NC>(
Hex(nativeID, 16));
130 if ( format.ConsumeChar(
'a') ) {
131 target._<NC>(
ci.ThreadID );
135 target.InsertChars<NC>( c, n );
145 if ( format.ConsumeChar(
'f') ) {
155 if (!
ci.TypeInfo) target._<NC>(
162 else target << lang::DbgTypeDemangler(*
ci.TypeInfo).Get();
168 if ( format.ConsumeChar(
'n') ) {
195 if ( format.ConsumeChar(
'a') ) {
197 target._<NC>(
ci.Func )._<NC>(
"()");
200 target._<NC>( *
ci.TypeInfo )._<NC>(
"::");
201 target._<NC>(
ci.Func )._<NC>(
"()");
208 target.InsertChars<NC>( c, n );
213 target.InsertChars<NC>( c, n );
227DOX_MARKER([DOX_BOXING_IFORMAT_DATETIME])
229 strings::util::CalendarDateTime tct( box.Unbox<
DateTime>() );
230 tct.Format( formatSpec.IsNotEmpty() ? formatSpec
234 :
A_CHAR(
"yyyy-MM-dd HH:mm:ss" ),
238DOX_MARKER([DOX_BOXING_IFORMAT_DATETIME])
252 double v= double(val);
255 if( unit < ByteSizeUnits::IEC_END) {
257 divisor= double(1024);
259 loopEnd= int(unit - ByteSizeUnits::SI);
260 divisor= double(1000);
263 for (
int i = 0; i < loopEnd; ++i)
271 if( val < byteLimit )
276 if( val < byteLimit * factor)
277 return std::make_pair(
double(val) /
double(factor), unit );
286 target.EnsureRemainingCapacity(128);
288 auto magnitude= (unit == ByteSizeUnits::IEC) ? getMagnitude(val, magnitudeThreshold, 1024ull)
289 : getMagnitude(val, magnitudeThreshold, 1000ull);
291 if( magnitude.second == ByteSizeUnits::IEC )
292 target <<
Dec( val,
nullptr );
295 target.VBuffer(), target.Length(), 0, nf) );
298 target << unitSeparator;
299 target << (magnitude.second + unit);
303 auto result= getMagnitude( Value, MagnitudeThreshold, 1024 );
304 result.second+= ByteSizeUnits::IEC;
309 auto result= getMagnitude( Value, MagnitudeThreshold, 1000 );
310 result.second+= ByteSizeUnits::SI;
315double ByteSizeSI ::ConvertTo(
ByteSizeUnits unit) {
return convertTo(Value, unit); };
318}
namespace alib::strings {
320void AppendableTraits< format::ByteSizeSI, character, lang::HeapAllocator>::operator()( AString& target,
const format::ByteSizeSI src )
322 format::FormatByteSize( target, src.Value, src.MagnitudeThreshold, src.UnitSeparator,
323 format::ByteSizeUnits::SI, * format::BYTESIZE_NUMBER_FORMAT );
325void AppendableTraits< format::ByteSizeIEC, character, lang::HeapAllocator>::operator()( AString& target,
const format::ByteSizeIEC src )
327 format::FormatByteSize( target, src.Value, src.MagnitudeThreshold, src.UnitSeparator,
328 format::ByteSizeUnits::IEC, * format::BYTESIZE_NUMBER_FORMAT );
#define ALIB_WARNING(domain,...)
#define ALIB_POP_ALLOWANCE
#define ALIB_ALLOW_NOTHING_RETURNED
#define ALIB_BOXING_VTABLE_DEFINE(TMapped, Identifier)
const String & GetResource(const NString &name)
TAString & _(const TAppendable &src)
static Thread * Get(std::thread::id nativeID)
void typeName(const detail::VTable *vtable, AString &result)
@ Clear
Chooses to clear existing data.
integer WriteFloat(double value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf)
strings::TNumberFormat< character > NumberFormat
Type alias in namespace #"%alib".
threads::Thread Thread
Type alias in namespace #"%alib".
lang::integer integer
Type alias in namespace #"%alib".
boxing::Box Box
Type alias in namespace #"%alib".
strings::TString< character > String
Type alias in namespace #"%alib".
strings::TDec< character > Dec
Type alias in namespace #"%alib".
strings::TSubstring< character > Substring
Type alias in namespace #"%alib".
NLocalString< 2048 > NString2K
Type alias name for #"TLocalString;TLocalString<nchar,2048>".
camp::Basecamp BASECAMP
The singleton instance of ALib Camp class #"Basecamp".
lang::CallerInfo CallerInfo
Type alias in namespace #"%alib".
strings::THex< character > Hex
Type alias in namespace #"%alib".
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace #"%alib".
characters::character character
Type alias in namespace #"%alib".
lang::uinteger uinteger
Type alias in namespace #"%alib".
time::DateTime DateTime
Type alias in namespace #"%alib".