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"
42 while ((idx=search->IndexOf(
'\n', idx)) != -1 ) {
43 if constexpr (isRN ) {
44 if (idx == 0 || search->CharAt(idx - 1) !=
'\r') {
46 dest.Reset(search->Substring(0, idx))._(
'\r')._<NC>(search->Substring(idx));
50 dest.InsertAt(
"\r", idx);
55 if (idx > 0 && search->CharAt(idx - 1) ==
'\r' ) {
57 dest.Reset(search->Substring(0, idx-1))._(search->Substring(idx));
61 dest.Delete(idx-1, 1);
75 while ((idx=dest.IndexOf(
'\n', idx)) != -1 ) {
77 if (idx == 0 || dest.CharAt(idx - 1) !=
'\r')
78 dest.InsertAt(
"\r", idx);
81 if (!isRN && idx > 0 && dest.CharAt(idx - 1) ==
'\r' )
82 dest.Delete(idx-1, 1);
94 ALIB_WARNING(
"STRINGS",
"StringWriter::WriteAndGetWideLength: No output stream" )
101 ostream->write( src.Buffer(), src.Length() );
102 return src.WStringLength();
109 ALIB_WARNING(
"STRINGS",
"StringWriter::WriteAndGetWideLength: No output stream" )
122 ALIB_WARNING(
"STRINGS",
"StringWriter::WriteAndGetWideLength: No output stream" )
128 ostream->write( src.Buffer(), src.Length() );
134 ALIB_WARNING(
"STRINGS",
"StringWriter::WriteAndGetWideLength: No output stream" )
139 while (count >= alc.Length() ) {
140 ostream->write(alc.Buffer(), alc.Length());
141 count-= alc.Length();
145 ostream->write(alc.Buffer(), count);
152 ALIB_WARNING(
"STRINGS",
"StringWriter::WriteAndGetWideLength: No output stream" )
166 while( startIdx <
string.
Length() )
179 alib::strings::TLocalString<wchar_t, 256> conv;
186template<
typename TChar>
187void alib::strings::AppendableTraits<alib::strings::compatibility::std::TISReadLine<TChar>, TChar, alib::lang::HeapAllocator>::operator()(
188 TAString<TChar, alib::lang::HeapAllocator>& target,
189 const compatibility::std::TISReadLine<TChar>& reader )
193 compatibility::std::TISReadLine<TChar>& param=
const_cast<compatibility::std::TISReadLine<TChar>&
>( reader );
200 while( !param.IStream->eof() )
204 alib::integer actReadSize= (std::min)( param.BufferSize, param.MaxLineWidth - ( target.Length() - origLength) + 1 );
205 if ( actReadSize < 2 )
208 target.EnsureRemainingCapacity( actReadSize );
211 int64_t start= target.Length();
212 param.IStream->getline( target.VBuffer() + start, actReadSize );
213 std::streamsize gCount= param.IStream->gcount();
214 std::streamsize count=
static_cast<std::streamsize
>(
characters::Length( target.Buffer() + start ) );
216 bool lineComplete= count + 1 == gCount;
222 if( *(target.Buffer() + start) ==
'\r' )
224 target.template Delete<NC>(
static_cast<alib::integer>(start), 1 );
230 if( *(target.Buffer() + start -1 ) ==
'\r' )
236 if ( param.IStream->eof() )
248 if ( gCount == actReadSize -1)
250 if ( param.IStream->eof() )
256 ALIB_ASSERT( param.IStream->rdstate() == std::iostream::failbit,
"STRINGS" )
257 param.IStream->clear();
262 if ( param.IStream->eof() )
265 if ( param.IStream->rdstate() == std::iostream::failbit )
267 ALIB_ERROR(
"STRINGS",
"Unknown Error Reading File. Maybe method implemented incomplete?")
277 ALIB_ERROR(
"STRINGS",
"Unknown Error Reading File. Probably not a text file." )
286template
void alib::strings::AppendableTraits<alib::strings::compatibility::std::TISReadLine<
char >,
char , alib::lang::
HeapAllocator>::operator()( TAString<
char , alib::lang::
HeapAllocator>& target, const compatibility::std::TISReadLine<
char >& reader );
287template
void alib::strings::AppendableTraits<alib::strings::compatibility::std::TISReadLine<
wchar_t>,
wchar_t, alib::lang::
HeapAllocator>::operator()( TAString<
wchar_t, alib::lang::
HeapAllocator>& target, const compatibility::std::TISReadLine<
wchar_t>& reader );
void DbgDisableBufferReplacementWarning()
constexpr integer Length() const
constexpr const TChar * Buffer() const
NAString converter
The string buffer used for conversion.
ALIB_DLL integer WriteAndGetWideLength(const NString &src)
ALIB_DLL void WriteChars(const nchar fillChar, integer count)
ALIB_DLL void Write(const NString &src)
#define ALIB_ASSERT(cond, domain)
#define ALIB_WARNING(domain,...)
#define ALIB_ERROR(domain,...)
integer Length(const TChar *cstring)
@ Clear
Chooses to clear existing data.
ALIB_EXPORT std::ostream & operator<<(std::ostream &stream, const alib::NString &string)
characters::AlignedCharArray<> AlignedCharArray
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
lang::integer integer
Type alias in namespace alib.
strings::TString< nchar > NString
Type alias in namespace alib.
NLocalString< 1024 > NString1K
Type alias name for TLocalString<nchar,1024>.
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace alib.
strings::TString< wchar > WString
Type alias in namespace alib.
characters::nchar nchar
Type alias in namespace alib.
lang::HeapAllocator HeapAllocator
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.