29 while ((idx=search->IndexOf(
'\n', idx)) != -1 ) {
30 if constexpr (isRN ) {
31 if (idx == 0 || search->CharAt(idx - 1) !=
'\r') {
33 dest.Reset(search->Substring(0, idx))._(
'\r')._<NC>(search->Substring(idx));
37 dest.InsertAt(
"\r", idx);
42 if (idx > 0 && search->CharAt(idx - 1) ==
'\r' ) {
44 dest.Reset(search->Substring(0, idx-1))._(search->Substring(idx));
48 dest.Delete(idx-1, 1);
62 while ((idx=dest.IndexOf(
'\n', idx)) != -1 ) {
64 if (idx == 0 || dest.CharAt(idx - 1) !=
'\r')
65 dest.InsertAt(
"\r", idx);
68 if (!isRN && idx > 0 && dest.CharAt(idx - 1) ==
'\r' )
69 dest.Delete(idx-1, 1);
81 ALIB_WARNING(
"STRINGS",
"StringWriter::WriteAndGetWideLength: No output stream")
88 ostream->write( src.Buffer(), src.Length() );
89 return src.WStringLength();
96 ALIB_WARNING(
"STRINGS",
"StringWriter::WriteAndGetWideLength: No output stream")
109 ALIB_WARNING(
"STRINGS",
"StringWriter::WriteAndGetWideLength: No output stream")
115 ostream->write( src.Buffer(), src.Length() );
121 ALIB_WARNING(
"STRINGS",
"StringWriter::WriteAndGetWideLength: No output stream")
126 while (count >= alc.Length() ) {
127 ostream->write(alc.Buffer(), alc.Length());
128 count-= alc.Length();
132 ostream->write(alc.Buffer(), count);
139 ALIB_WARNING(
"STRINGS",
"StringWriter::WriteAndGetWideLength: No output stream")
153 while( startIdx <
string.
Length() )
173template<
typename TChar>
175 TAString<TChar, alib::lang::HeapAllocator>& target,
176 const compatibility::std::TISReadLine<TChar>& reader )
180 compatibility::std::TISReadLine<TChar>& param=
const_cast<compatibility::std::TISReadLine<TChar>&
>( reader );
187 while( !param.IStream->eof() )
191 alib::integer actReadSize= (std::min)( param.BufferSize, param.MaxLineWidth - ( target.Length() - origLength) + 1 );
192 if ( actReadSize < 2 )
195 target.EnsureRemainingCapacity( actReadSize );
199 int64_t start= target.Length();
200 param.IStream->getline( target.VBuffer() + start, actReadSize );
201 std::streamsize gCount= param.IStream->gcount();
202 std::streamsize count=
static_cast<std::streamsize
>(
characters::Length( target.Buffer() + start ) );
204 bool lineComplete= count + 1 == gCount;
210 if( *(target.Buffer() + start) ==
'\r' )
212 target.template Delete<NC>(
static_cast<alib::integer>(start), 1 );
218 if( *(target.Buffer() + start -1 ) ==
'\r' )
224 if ( param.IStream->eof() )
238 if ( gCount == actReadSize -1)
240 if ( param.IStream->eof() )
246 ALIB_ASSERT( param.IStream->rdstate() == std::iostream::failbit )
247 param.IStream->clear();
252 if ( param.IStream->eof() )
255 if ( param.IStream->rdstate() == std::iostream::failbit )
257 ALIB_ERROR(
"STRINGS",
"Unknown Error Reading File. Maybe method implemented incomplete?" )
267 ALIB_ERROR( "STRINGS", "Unknown Error Reading
File. Probably not a text file." )
276template
void alib::strings::T_Append<
alib::strings::compatibility::std::TISReadLine<
char >,
char ,
alib::lang::
HeapAllocator>::operator()( TAString<
char ,
alib::lang::
HeapAllocator>& target, const compatibility::std::TISReadLine<
char >& reader );
277template
void alib::strings::T_Append<
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
ALIB_API integer WriteAndGetWideLength(const NString &src)
ALIB_API void Write(const NString &src)
ALIB_API void WriteChars(const nchar fillChar, integer count)
NAString converter
The string buffer used for conversion.
#define ALIB_WARNING(...)
#define ALIB_WARNINGS_RESTORE
#define ALIB_WARNINGS_ALLOW_UNSAFE_BUFFER_USAGE
#define ALIB_ASSERT(cond)
integer Length(const TChar *cstring)
@ Clear
Chooses to clear existing data.
std::ostream & operator<<(std::ostream &stream, const alib::NString &string)
files::File File
Type alias in namespace alib.
characters::AlignedCharArray<> AlignedCharArray
strings::TString< nchar > NString
Type alias in namespace alib.
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace alib.
strings::TSubstring< character > Substring
Type alias in namespace alib.
strings::TString< wchar > WString
Type alias in namespace alib.
constexpr CString NEW_LINE
A zero-terminated string containing the new-line character sequence.
lang::HeapAllocator HeapAllocator
Type alias in namespace alib.
characters::nchar nchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.