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"
19 module ALib.Strings.StdIOStream;
40 while( startIdx <
string.
Length() ) {
42 conv.
Reset(
string.Substring<alib::NC>(startIdx, length) );
59template<
typename TChar>
63 TAString<TChar, HeapAllocator>& target,
64 const compatibility::std::TIStreamLine<TChar>& constIsLine ) {
67 compatibility::std::TIStreamLine<TChar>& isLine=
68 const_cast<compatibility::std::TIStreamLine<TChar>&
>( constIsLine );
70 if ( isLine.TargetData == lang::CurrentData::Clear )
75 while( !isLine.IStream->eof() ) {
78 integer actReadSize= (std::min)( isLine.BufferSize,
79 isLine.MaxLineWidth - (target.Length() - origLength) + 1 );
80 if ( actReadSize < 2 )
83 target.EnsureRemainingCapacity( actReadSize );
87 isLine.IStream->getline( target.VBuffer() + start, actReadSize );
88 std::streamsize gCount= isLine.IStream->gcount();
89 std::streamsize count=
static_cast<std::streamsize
>( characters::Length( target.Buffer() + start ) );
91 bool lineComplete= count + 1 == gCount;
96 if( *(target.Buffer() + start) ==
'\r' ) {
97 target.template Delete<NC>(
static_cast<alib::integer>(start), 1 );
103 if( *(target.Buffer() + start -1 ) ==
'\r' )
109 if ( isLine.IStream->eof() ) {
119 if ( gCount == actReadSize -1) {
120 if ( isLine.IStream->eof() )
125 ALIB_ASSERT( isLine.IStream->rdstate() == std::iostream::failbit,
"STRINGS" )
126 isLine.IStream->clear();
131 if ( isLine.IStream->eof() )
134 if ( isLine.IStream->rdstate() == std::iostream::failbit ) {
135 ALIB_ERROR(
"STRINGS",
"Unknown Error Reading File. Maybe method implemented incomplete?")
145 ALIB_ERROR(
"STRINGS",
"Unknown Error Reading File. Probably not a text file." )
153template
void alib::strings::AppendableTraits<
alib::strings::compatibility::std::TIStreamLine<
char >,
char ,
alib::lang::HeapAllocator>::operator()( TAString<
char ,
alib::lang::HeapAllocator>& target, const compatibility::std::TIStreamLine<
char >& reader );
154template
void alib::strings::AppendableTraits<
alib::strings::compatibility::std::TIStreamLine<
wchar_t>,
wchar_t,
alib::lang::HeapAllocator>::operator()( TAString<
wchar_t,
alib::lang::HeapAllocator>& target, const compatibility::std::TIStreamLine<
wchar_t>& reader );
void DbgDisableBufferReplacementWarning()
constexpr integer Length() const
constexpr const TChar * Buffer() const
#define ALIB_ASSERT(cond, domain)
#define ALIB_ERROR(domain,...)
integer Length(const TChar *cstring)
ALIB_EXPORT constexpr TEnum operator<<(TEnum lhs, typename std::underlying_type< TEnum >::type rhs) noexcept
platform_specific integer
lang::integer integer
Type alias in namespace alib.
strings::TString< nchar > NString
Type alias in namespace alib.
strings::TString< wchar > WString
Type alias in namespace alib.
NLocalString< 4096 > NString4K
Type alias name for TLocalString<nchar,8192>.