10#if !defined (HPP_ALIB_STRINGS_LOCALSTRING)
14#if !defined (HPP_ALIB_STRINGS_FORMAT)
18#if !defined (HPP_ALIB_STRINGS_DETAIL_NUMBERCONVERSION)
22#if ALIB_DEBUG && !defined (HPP_ALIB_LANG_DBGTYPEDEMANGLER)
28namespace alib {
namespace strings {
43namespace APPENDABLES {
49template<
typename TChar>
52 target.template _<false>( b ?
"true" :
"false" );
55template<
typename TChar>
64template<
typename TChar>
74template<
typename TChar>
104 template<
typename TChar>
117template<
typename TChar>
120 integer reference= tab.reference;
133 reference= target.Length();
137 integer length= target.Length();
138 integer qtyChars= tab.minPad > 0 ? tab.minPad : 0;
140 if ( tab.tabSize > 1 )
141 qtyChars+= (tab.tabSize - ( (length + qtyChars - reference) % tab.tabSize ) ) % tab.tabSize;
144 target.template InsertChars<false>( tab.tabChar, qtyChars );
151template<
typename TChar>
163 if( !field.theContent.template IsType<void>() && field.theContent.template IsType<TString<TChar>>() )
164 theContent= field.theContent.template Unbox<TString<TChar>>();
168 noneStringArgBuf << field.theContent;
169 theContent= noneStringArgBuf;
173 TString<TChar> theContent= field.theContent;
176 integer padSize= field.fieldWidth
182 target.template _ <false>( theContent );
183 if (padSize > 0 ) target.template InsertChars<false>( field.padChar, padSize );
191 target.template InsertChars<false>( field.padChar, padSize );
192 target.template Append<false>( theContent );
197 integer leftPadding= padSize / 2;
198 if( leftPadding > 0 )
199 target.template InsertChars<false> ( field.padChar, leftPadding );
200 target.template Append<false> ( theContent );
201 if( padSize > leftPadding ) target.template InsertChars<false> ( field.padChar, padSize - leftPadding );
207template<
typename TChar>
208void T_Append<typename TFormat<TChar>::Escape, TChar>::operator()( TAString<TChar>& target,
const typename TFormat<TChar>::Escape& escape)
210 if( target.AdjustRegion(
const_cast<typename TFormat<TChar>::Escape&
>(escape).startIdx,
211 const_cast<typename TFormat<TChar>::Escape&
>(escape).length ) )
214 integer regionEnd= escape.startIdx + escape.length;
221 for(
integer idx= escape.startIdx; idx < regionEnd ; ++idx )
223 TChar c= target.CharAt(idx);
225 TChar resultChar=
'\0';
228 case '\\' : resultChar=
'\\';
break;
229 case '\r' : resultChar=
'r' ;
break;
230 case '\n' : resultChar=
'n' ;
break;
231 case '\t' : resultChar=
't' ;
break;
232 case '\a' : resultChar=
'a' ;
break;
233 case '\b' : resultChar=
'b' ;
break;
234 case '\v' : resultChar=
'v' ;
break;
235 case '\f' : resultChar=
'f' ;
break;
237 case '"' : resultChar=
'"' ;
break;
242 if( resultChar !=
'\0')
244 target.template InsertChars<false>(
'\\', 1, idx);
245 target[++idx]= resultChar;
257 for(
integer idx= escape.startIdx; idx < regionEnd ; ++idx )
259 TChar c= target.CharAt(idx);
263 c= target.CharAt(idx + 1);
265 TChar resultChar=
'\0';
268 case '\\' : resultChar=
'\\';
break;
269 case 'r' : resultChar=
'\r' ;
break;
270 case 'n' : resultChar=
'\n' ;
break;
271 case 't' : resultChar=
'\t' ;
break;
272 case 'a' : resultChar=
'\a' ;
break;
273 case 'b' : resultChar=
'\b' ;
break;
274 case 'v' : resultChar=
'\v' ;
break;
275 case 'f' : resultChar=
'\f' ;
break;
277 case '"' : resultChar=
'"' ;
break;
282 if( resultChar !=
'\0')
284 target.Delete( idx, 1);
285 target[idx]= resultChar;
295template<
typename TChar>
302 target.EnsureRemainingCapacity( fmt.valueType== 3 ? 48
306 integer length= target.Length();
310 fmt.valueType == 2 ?
detail::WriteDecUnsigned(
static_cast<uint64_t
>(fmt.v.value) , target.VBuffer(), length, fmt.width , *nf ) :
313 target.SetLength( length );
318template<
typename TChar>
325 target.EnsureRemainingCapacity( 80 );
327 integer length= target.Length();
329 length=
detail::WriteBin( fmt.theValue, target.VBuffer(), length, fmt.theWidth, *nf );
331 target.SetLength( length );
334template<
typename TChar>
341 target.EnsureRemainingCapacity( 25 );
343 integer length= target.Length();
345 length=
detail::WriteHex( fmt.theValue, target.VBuffer(), length, fmt.theWidth, *nf );
347 target.SetLength( length );
350template<
typename TChar>
351void T_Append<typename TFormat<TChar>::Oct, TChar>::operator()( TAString<TChar>& target,
const typename TFormat<TChar>::Oct& fmt )
353 TNumberFormat<TChar>* nf= fmt.nf;
357 target.EnsureRemainingCapacity( 30 );
359 integer length= target.Length();
361 length=
detail::WriteOct( fmt.theValue, target.VBuffer(), length, fmt.theWidth, *nf );
363 target.SetLength( length );
371#if !defined(ALIB_DOX)
375template void T_Append<TFormat<nchar> ,
nchar>::operator()( TAString<nchar>&,
const TFormat<nchar>& );
376template void T_Append<TFormat<nchar>::Tab ,
nchar>::operator()( TAString<nchar>&,
const TFormat<nchar>::Tab& );
377template void T_Append<TFormat<nchar>::Field ,
nchar>::operator()( TAString<nchar>&,
const TFormat<nchar>::Field& );
378template void T_Append<TFormat<nchar>::Escape,
nchar>::operator()( TAString<nchar>&,
const TFormat<nchar>::Escape& );
379template void T_Append<TFormat<nchar>::Bin ,
nchar>::operator()( TAString<nchar>&,
const TFormat<nchar>::Bin& );
380template void T_Append<TFormat<nchar>::Hex ,
nchar>::operator()( TAString<nchar>&,
const TFormat<nchar>::Hex& );
381template void T_Append<TFormat<nchar>::Oct ,
nchar>::operator()( TAString<nchar>&,
const TFormat<nchar>::Oct& );
387template void T_Append<TFormat<wchar> ,
wchar>::operator()( TAString<wchar>&,
const TFormat<wchar>& );
388template void T_Append<TFormat<wchar>::Tab ,
wchar>::operator()( TAString<wchar>&,
const TFormat<wchar>::Tab& );
389template void T_Append<TFormat<wchar>::Field ,
wchar>::operator()( TAString<wchar>&,
const TFormat<wchar>::Field& );
390template void T_Append<TFormat<wchar>::Escape,
wchar>::operator()( TAString<wchar>&,
const TFormat<wchar>::Escape& );
391template void T_Append<TFormat<wchar>::Bin ,
wchar>::operator()( TAString<wchar>&,
const TFormat<wchar>::Bin& );
392template void T_Append<TFormat<wchar>::Hex ,
wchar>::operator()( TAString<wchar>&,
const TFormat<wchar>::Hex& );
393template void T_Append<TFormat<wchar>::Oct ,
wchar>::operator()( TAString<wchar>&,
const TFormat<wchar>::Oct& );
398template void T_Append<TFormat<xchar> ,
xchar>::operator()( TAString<xchar>&,
const TFormat<xchar>& );
399template void T_Append<TFormat<xchar>::Tab ,
xchar>::operator()( TAString<xchar>&,
const TFormat<xchar>::Tab& );
400template void T_Append<TFormat<xchar>::Field ,
xchar>::operator()( TAString<xchar>&,
const TFormat<xchar>::Field& );
401template void T_Append<TFormat<xchar>::Escape,
xchar>::operator()( TAString<xchar>&,
const TFormat<xchar>::Escape& );
402template void T_Append<TFormat<xchar>::Bin ,
xchar>::operator()( TAString<xchar>&,
const TFormat<xchar>::Bin& );
403template void T_Append<TFormat<xchar>::Hex ,
xchar>::operator()( TAString<xchar>&,
const TFormat<xchar>::Hex& );
404template void T_Append<TFormat<xchar>::Oct ,
xchar>::operator()( TAString<xchar>&,
const TFormat<xchar>::Oct& );
void DbgDisableBufferReplacementWarning()
void EnsureRemainingCapacity(integer spaceNeeded)
void SetLength(integer newLength)
constexpr integer Length() const
integer WStringLength() const
@ On
Switch it on, switched on, etc.
@ Right
Chooses right alignment.
@ Left
Chooses left alignment.
ALIB_API integer WriteFloat(double value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf)
ALIB_API integer WriteDecUnsigned(uint64_t value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf)
ALIB_API integer WriteOct(uint64_t value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf)
ALIB_API integer WriteDecSigned(int64_t value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf)
ALIB_API integer WriteHex(uint64_t value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf)
ALIB_API integer WriteBin(uint64_t value, TChar *buffer, integer idx, int minWidth, const TNumberFormat< TChar > &nf)
characters::wchar wchar
Type alias in namespace alib.
characters::xchar xchar
Type alias in namespace alib.
characters::nchar nchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
void operator()(TAString< TChar > &target, const TAppendable &src)