58template<
typename TChar>
101 namespace APPENDABLES {
107template<
typename TChar>
191template<
typename TChar =
nchar,
193 bool TSynced =
false,
195requires (::std::is_same_v<TChar, char> || ::std::is_same_v<TChar, wchar_t>)
215 #if defined(__cpp_lib_syncbuf) || DOXYGEN
220 ::std::basic_osyncstream< TChar,
221 ::std::char_traits<TChar>,
225 ::std::basic_ostream<TChar>&
ostream;
233 template<
typename TSrc>
241 #if !ALIB_SINGLE_THREADED && (defined(__cpp_lib_syncbuf) || DOXYGEN )
245 if constexpr (TSynced)
247 && (
ostream.get_wrapped() == ::std::cout.rdbuf()
248 ||
ostream.get_wrapped() == ::std::cerr.rdbuf() ) )
254 lineEnd= src.
IndexOf(
'\n', lineStart);
263 if (src.
CharAt(writeEnd - 1) ==
'\r' )
265 if (writeEnd > lineStart) {
266 if constexpr (::std::is_same_v<TChar, TSrc>) {
269 ostream.write( src.
Buffer() + lineStart, writeEnd - lineStart );
277 if ( printedWidth ) {
278 if constexpr (::std::is_same_v<TChar, wchar>)
279 *printedWidth= converter.
Length();
281 *printedWidth= line.
Length();
289 if constexpr ( ::std::is_same_v<TChar, nchar> )
ostream.write(
"\n", 1 );
290 else ostream.write( L
"\n", 1 );
292 if constexpr ( ::std::is_same_v<TChar, nchar> )
ostream.write(
"\r\n", 2 );
293 else ostream.write( L
"\r\n", 2 );
295 lineStart= lineEnd + 1;
304 #if !defined(__cpp_lib_syncbuf) || ALIB_SINGLE_THREADED || DOXYGEN
312 OStreamWriter(::std::basic_ostream<TChar>& os, TAllocator& alloc)
317 OStreamWriter(::std::basic_ostream<TChar>& os, TAllocator& alloc)
320 , ostream { os.rdbuf() ,
lang::StdAllocator<TChar, TAllocator>(alloc) } {}
368 while (count >= alc.Length() ) {
369 ostream.write(alc.Buffer(), alc.Length());
370 count-= alc.Length();
374 ostream.write(alc.Buffer(), count);
381template<
typename TChar =
nchar,
383 bool TSynced =
false,
391template<
typename TChar =
nchar,
393 bool TSynced =
false,
421 :
readOp( &::
std::cin,
lang::CurrentData::Clear, bufferSize, maxLineWidth ) {}
463template<
typename TChar =
nchar,
465 bool TSynced =
false,
477 namespace strings {
namespace compatibility {
namespace std {
492 if (
string.IsNotEmpty() )
493 stream.write(
string.Buffer(),
string.Length() );
508 stream->write(
string.Buffer(),
string.Length() );
585 if (
string.IsNotEmpty() ) {
586 #if ALIB_CHARACTERS_NATIVE_WCHAR
587 stream.write(
string.Buffer(),
string.Length() );
623 string << alib::strings::compatibility::std::TIStreamLine<alib::nchar>( &stream,
642 if (stream !=
nullptr)
643 string << alib::strings::compatibility::std::TIStreamLine<alib::nchar>( stream,
667inline std::basic_istream<wchar_t>&
operator>>( std::basic_istream<wchar_t>& stream,
669 #if ALIB_CHARACTERS_NATIVE_WCHAR
670 string << alib::strings::compatibility::std::TIStreamLine<wchar_t>( &stream,
675 converter << alib::strings::compatibility::std::TIStreamLine<wchar_t>( &stream,
677 string.Reset( converter );
696inline std::basic_istream<wchar_t>*
operator>>( std::basic_istream<wchar_t>* stream,
700 if (stream !=
nullptr)
720template<
typename TAppendable>
723std::ostream&
operator<<( std::ostream& stream,
const TAppendable& appendable ) {
744template<
typename TAppendable>
747std::ostream*
operator<<( std::ostream* stream,
const TAppendable& appendable ) {
748 if (stream !=
nullptr)
765template<
typename TAppendable>
768std::wostream&
operator<<( std::wostream& stream,
const TAppendable& appendable ) {
769 #if ALIB_CHARACTERS_NATIVE_WCHAR
794template<
typename TAppendable,
typename TAllocator>
797std::wostream*
operator<<( std::wostream* stream,
const TAppendable& appendable ) {
798 if (stream !=
nullptr)
806 }}
namespace APPENDABLES {
#define ALIB_COMMA_CALLER_PRUNED
#define ALIB_SINGLE_THREADED
#define ALIB_ASSERT_WARNING(cond, domain,...)
void Set(OwnablePointer ownable)
TAString & _(const TAppendable &src)
void DbgDisableBufferReplacementWarning()
constexpr integer Length() const
integer IndexOf(TChar needle, integer startIdx=0) const
TChar CharAt(integer idx) const
constexpr bool IsNotEmpty() const
constexpr const TChar * Buffer() const
integer WStringLength() const
IStreamReader(integer bufferSize=4096, integer maxLineWidth=4096)
void Read(NAString &target)
compatibility::std::TIStreamLine< nchar > readOp
void Read(WAString &target)
void SetStream(::std::istream *is)
::std::istream * GetStream()
NAString converter
The string buffer used for conversion.
::std::conditional_t< TSynced &&!0, ::std::basic_osyncstream< TChar, ::std::char_traits< TChar >, lang::StdAllocator< TChar, TAllocator > >, ::std::basic_ostream< TChar > & > ostream
void Write(const NString &src, integer *printedWidth=nullptr)
void Write(const XString &src, integer *printedWidth=nullptr)
::std::ostream & GetStream()
OStreamWriter(::std::basic_ostream< TChar > &os)
lang::AllocatorMember< TAllocator > allocBase
The type of the base class that stores the allocator.
void Write(const WString &src, integer *printedWidth=nullptr)
static constexpr lang::LineFeeds TargetLF
OStreamWriter(::std::basic_ostream< TChar > &os, TAllocator &alloc)
void doWrite(const TString< TSrc > &src, integer *printedWidth)
TChar CharType
Exposes template parameter TChar.
void Fill(const TChar fillChar, integer count)
static constexpr bool Synced
TAllocator AllocatorType
Exposes template parameter TAllocator.
LineFeeds
Denotes line-feed encoding sequences "\n" and "\r\n".
@ WindowsOS
WindowsOS style line-feeds "\r\n".
@ Platform
Platform specific. Equals to either 'Unix' or 'WindowsOS'.
@ Unix
Unix-style line-feeds "\n".
@ Keep
Chooses not no clear existing data.
@ Clear
Chooses to clear existing data.
ALIB_EXPORT std::istream & operator>>(std::istream &stream, alib::NAString &string)
ALIB_EXPORT std::ostream & operator<<(std::ostream &stream, const alib::NString &string)
strings::TString< nchar > NString
Type alias in namespace #"%alib".
strings::compatibility::std::IStreamReader IStreamReader
Type alias in namespace #"%alib".
strings::TString< wchar > WString
Type alias in namespace #"%alib".
strings::compatibility::std::TIStreamLine< alib::wchar > IStreamLineW
Type alias in namespace #"%alib".
strings::TLocalString< wchar, TCapacity, lang::HeapAllocator > WLocalString
Type alias in namespace #"%alib".
strings::TString< xchar > XString
Type alias in namespace #"%alib".
strings::TAString< nchar, lang::HeapAllocator > NAString
Type alias in namespace #"%alib".
lang::integer integer
Type alias in namespace #"%alib".
strings::compatibility::std::TIStreamLine< alib::character > IStreamLine
Type alias in namespace #"%alib".
strings::TLocalString< xchar, TCapacity, lang::HeapAllocator > XLocalString
Type alias in namespace #"%alib".
characters::nchar nchar
Type alias in namespace #"%alib".
strings::compatibility::std::TIStreamLine< alib::nchar > IStreamLineN
Type alias in namespace #"%alib".
NLocalString< 256 > NString256
Type alias name for #"TLocalString;TLocalString<nchar,256>".
strings::TAString< wchar, lang::HeapAllocator > WAString
Type alias in namespace #"%alib".
strings::compatibility::std::OStreamWriter< TChar, TAllocator, TSynced, TTargetLF > OStreamWriter
Type alias in namespace #"%alib".
#define ALIB_STRINGS_SUPPRESS_STD_OSTREAM_OPERATOR(TYPE)
TAllocator & GetAllocator() const noexcept
void operator()(TAString< TChar, lang::HeapAllocator > &target, const compatibility::std::TIStreamLine< TChar > &reader)
::std::basic_istream< alib::character > * IStream
TIStreamLine(::std::basic_istream< TChar > *istream, lang::CurrentData targetData=lang::CurrentData::Clear, integer bufferSize=4096, integer maxLineWidth=4096)
lang::CurrentData TargetData