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"
76 const String& pIndentOtherLines )
78 String indentOtherLines= pIndentOtherLines.
IsNull() ? indentFirstLine
103 "Paragraphs: PopIndent without prior push." )
108 "Paragraphs: PopIndent without prior push." )
142 #if defined( _WIN32 )
157 integer exceptStart= errPos - 25;
158 if( exceptStart <= 0 )
160 exceptPos+= exceptStart;
170 actText.
_( markedBuffer, exceptStart, 50 );
171 if( markedBuffer.
Length() > exceptStart + 50 )
187 searchCharBuf[1]=
'\n';
188 String searchChars(searchCharBuf, 2);
197 integer pos= parser.template IndexOfAny<lang::Inclusion::Include, NC>( searchChars );
207 if( parser.
CharAt( pos ) ==
'\n' )
209 parser.template ConsumeChars<NC, lang::CurrentData::Keep>( pos,
Buffer, 1 );
210 if (
Buffer.CharAtEnd<NC>() ==
'\r')
217 lastTextStart=
Buffer.Length();
221 parser.template ConsumeChars<NC, lang::CurrentData::Keep>( pos,
Buffer, 1 );
289 if( lastTextStart <
Buffer.Length() )
309 const String& pIndentFirstLine,
310 const String& pIndentOtherLines )
314 String indentOtherLines= pIndentOtherLines.
IsNotNull() ? pIndentOtherLines : pIndentFirstLine;
316 bool isFirstLine=
true;
319 bool indentAreJustSpaces=
false;
322 integer maxLineWidthDetectionStartIdx= startIdx;
326 maxLineWidth= (std::max)( maxLineWidth, startIdx - maxLineWidthDetectionStartIdx
328 #
if defined( _WIN32 )
335 if ( startIdx ==
text.Length() )
337 maxLineWidthDetectionStartIdx= startIdx;
341 int isWinNL=
text[ startIdx ] ==
'\r' ? 1 : 0;
342 if (
text[ startIdx + isWinNL ] ==
'\n' )
349 indent = isFirstLine ? indentFirstLines : indentOtherLines;
350 indentAreJustSpaces= (indent.template IndexOfAny<lang::Inclusion::Exclude>(
A_CHAR(
" " ) ) < 0 );
354 if ( !indentAreJustSpaces )
356 text.InsertAt( indent, startIdx );
357 startIdx+= indent.
Length();
360 #if defined( _WIN32 )
363 text.template InsertChars<NC>(
'\r', 1, startIdx );
369 text.template Delete<NC>(startIdx, 1);
375 startIdx+= 1 + isWinNL;
388 indent = isFirstLine ? indentFirstLines : indentOtherLines;
389 indentAreJustSpaces= (indent.template IndexOfAny<lang::Inclusion::Exclude>(
A_CHAR(
" " ) ) < 0 );
391 text.InsertAt( indent, startIdx );
403 bool isLastLine =
true;
404 bool exceeds =
false;
405 while (++idx <
text.Length() )
414 exceeds= lineWidth > 0 && idx - startIdx >= lineWidth;
418 if(idx - startIdx <= lineWidth )
419 lastSpaceInLine= idx;
430 #if defined( _WIN32 )
431 if(
text[idx-1] ==
'\n' &&
text[idx-2] !=
'\r' )
433 text.template InsertChars<NC>(
'\r', 1, idx-1 );
437 if(
text[idx-1] ==
'\n' &&
text[idx-2] ==
'\r' )
439 text.template Delete<NC>((idx-2), 1);
445 if( exceeds && ( lastSpaceInLine || !isLastLine ) )
447 integer wrapPos= lastSpaceInLine > 0 ? lastSpaceInLine : idx;
448 text.template ReplaceSubstring<NC>(
NEW_LINE, wrapPos, 1 );
453 if( justifyChar !=
'\0' )
455 integer qtyInserts= lineWidth - (wrapPos - startIdx );
460 while ( leftInsertBoundary < idx &&
text[leftInsertBoundary] ==
' ' )
461 ++leftInsertBoundary;
463 if( leftInsertBoundary < idx )
465 while( qtyInserts > 0 )
468 bool foundOne=
false;
469 while( qtyInserts > 0 )
471 actPos=
text.LastIndexOf(
' ', actPos );
472 if( actPos < leftInsertBoundary )
475 text.InsertChars( justifyChar, 1, actPos );
478 while( --actPos > leftInsertBoundary &&
text[actPos] ==
' ' )
TAString & DeleteEnd(integer regionLength)
ALIB_DLL integer SearchAndReplace(TChar needle, TChar replacement, integer startIdx=0, integer endIdx=strings::MAX_LEN)
TAString & _(const TAppendable &src)
constexpr integer Length() const
bool EndsWith(const TString &needle) const
constexpr bool IsNotNull() const
TChar CharAt(integer idx) const
constexpr bool IsNotEmpty() const
constexpr bool IsNull() const
bool ConsumeString(const TString< TChar > &consumable)
TString< TChar > ConsumeToken(TChar separator=',', lang::Inclusion includeSeparator=lang::Inclusion::Include)
#define ALIB_CALLER_NULLED
#define ALIB_ASSERT_ERROR(cond, domain,...)
strings::TAString< character, lang::HeapAllocator > AString
Type alias in namespace alib.
LocalString< 64 > String64
Type alias name for TLocalString<character,64>.
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
constexpr const String EMPTY_STRING
An empty string of the default character type.
lang::integer integer
Type alias in namespace alib.
std::deque< T, SCAMono< T > > StdDequeMono
Type alias in namespace alib.
exceptions::Exception Exception
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.