10#if !defined (HPP_ALIB_LANG_FORMAT_PARAGRAPHS)
13# if !defined(HPP_ALIB_LANG_FORMAT_EXCEPTIONS)
17#if !defined (HPP_ALIB_STRINGS_UTIL_TOKENIZER)
21#if !defined (HPP_ALIB_CAMP_MESSAGE_EXCEPTION)
41: Buffer(externalBuffer)
48 const String& pIndentOtherLines )
50 String indentOtherLines= pIndentOtherLines.
IsNull() ? indentFirstLine
119 #if defined( _WIN32 )
135 integer exceptStart= errPos - 25;
136 if( exceptStart <= 0 )
138 exceptPos+= exceptStart;
148 actText.
_( markedBuffer, exceptStart, 50 );
149 if( markedBuffer.
Length() > exceptStart + 50 )
167 searchCharBuf[1]=
'\n';
169 String searchChars(searchCharBuf, 2);
190 integer pos= parser.template IndexOfAny<lang::Inclusion::Include, false>( searchChars );
200 if( parser.
CharAt( pos ) ==
'\n' )
202 parser.template ConsumeChars<false, lang::CurrentData::Keep>( pos,
Buffer, 1 );
213 parser.template ConsumeChars<false, lang::CurrentData::Keep>( pos,
Buffer, 1 );
300 const String& pIndentFirstLine,
301 const String& pIndentOtherLines )
305 String indentOtherLines= pIndentOtherLines.
IsNotNull() ? pIndentOtherLines : pIndentFirstLine;
307 bool isFirstLine=
true;
310 bool indentAreJustSpaces=
false;
313 integer maxLineWidthDetectionStartIdx= startIdx;
317 maxLineWidth= (std::max)( maxLineWidth, startIdx - maxLineWidthDetectionStartIdx
319 #if defined( _WIN32 )
328 maxLineWidthDetectionStartIdx= startIdx;
332 int isWinNL=
text[ startIdx ] ==
'\r' ? 1 : 0;
333 if (
text[ startIdx + isWinNL ] ==
'\n' )
340 indent = isFirstLine ? indentFirstLines : indentOtherLines;
341 indentAreJustSpaces= (indent.template IndexOfAny<lang::Inclusion::Exclude>(
A_CHAR(
" " ) ) < 0 );
345 if ( !indentAreJustSpaces )
349 startIdx+= indent.
Length();
353 #if defined( _WIN32 )
356 text.template InsertChars<false>(
'\r', 1, startIdx );
362 text.template Delete<false>(startIdx, 1);
368 startIdx+= 1 + isWinNL;
381 indent = isFirstLine ? indentFirstLines : indentOtherLines;
382 indentAreJustSpaces= (indent.template IndexOfAny<lang::Inclusion::Exclude>(
A_CHAR(
" " ) ) < 0 );
395 bool isLastLine =
true;
396 bool exceeds =
false;
407 exceeds= lineWidth > 0 && idx - startIdx >= lineWidth;
411 if(idx - startIdx <= lineWidth )
412 lastSpaceInLine= idx;
423 #if defined( _WIN32 )
424 if(
text[idx-1] ==
'\n' &&
text[idx-2] !=
'\r' )
426 text.template InsertChars<false>(
'\r', 1, idx-1 );
430 if(
text[idx-1] ==
'\n' &&
text[idx-2] ==
'\r' )
432 text.template Delete<false>((idx-2), 1);
438 if( exceeds && ( lastSpaceInLine || !isLastLine ) )
440 integer wrapPos= lastSpaceInLine > 0 ? lastSpaceInLine : idx;
441 text.template ReplaceSubstring<false>(
NewLine(), wrapPos, 1 );
446 if( justifyChar !=
'\0' )
448 integer qtyInserts= lineWidth - (wrapPos - startIdx );
453 while ( leftInsertBoundary < idx &&
text[leftInsertBoundary] ==
' ' )
454 ++leftInsertBoundary;
456 if( leftInsertBoundary < idx )
458 while( qtyInserts > 0 )
461 bool foundOne=
false;
462 while( qtyInserts > 0 )
465 if( actPos < leftInsertBoundary )
471 while( --actPos > leftInsertBoundary &&
text[actPos] ==
' ' )
TAString & DeleteEnd(integer regionLength)
TAString & InsertChars(TChar c, integer qty)
TAString & _(const TString< TChar > &src, integer regionStart, integer regionLength=MAX_LEN)
ALIB_API void SetBuffer(integer newCapacity)
ALIB_API integer SearchAndReplace(TChar needle, TChar replacement, integer startIdx=0)
TAString & InsertAt(const TString< TChar > &src, integer pos)
constexpr bool IsNull() const
TChar CharAt(integer idx) const
constexpr bool IsNotEmpty() const
constexpr integer Length() const
constexpr bool IsNotNull() const
ALIB_WARNINGS_RESTORE integer LastIndexOf(TChar needle, integer startIndex=MAX_LEN) const
bool EndsWith(const TString &needle) const
TString< TChar > ConsumeToken(TChar separator=',')
bool ConsumeString(const TString< TChar > &consumable)
#define ALIB_CALLER_NULLED
#define ALIB_WARNINGS_RESTORE
#define ALIB_ASSERT_ERROR(cond,...)
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
#define ALIB_CALLER_PRUNED
platform_specific integer
platform_specific uinteger
lang::Exception Exception
Type alias in namespace alib.
constexpr CString NewLine()
constexpr CString EmptyString()
characters::character character
Type alias in namespace alib.