10#ifndef HPP_ALIB_COMPATIBILITY_STD_STRINGS_IOSTREAM
11#define HPP_ALIB_COMPATIBILITY_STD_STRINGS_IOSTREAM 1
19#include "alib/compatibility/std_strings.hpp"
25namespace alib {
namespace strings {
namespace compatibility {
namespace std {
48#define ALIB_STRINGS_SUPPRESS_STD_OSTREAM_OPERATOR(TYPE) \
49 namespace alib::strings::compatibility::std { \
50 template<> struct T_SuppressStdOstreamOperator<TYPE> : ::std::true_type {}; }
79template<
typename TChar>
126 namespace APPENDABLES {
154namespace compatibility {
namespace std {
194 : ostream( &::std::cout )
285 : readOp( &::std::cin )
319 target.
Reset( readOp );
331 converter.
Reset( readOp );
358 namespace strings {
namespace compatibility {
namespace std {
373 if (
string.IsNotEmpty() )
374 stream.write(
string.Buffer(),
string.Length() );
388 stream->write(
string.Buffer(),
string.Length() );
461 if (
string.IsNotEmpty() )
463 #if ALIB_CHARACTERS_NATIVE_WCHAR
464 stream.write(
string.Buffer(),
string.Length() );
499 string << alib::strings::compatibility::std::TISReadLine<alib::nchar>( &stream,
517 if (stream !=
nullptr)
518 string << alib::strings::compatibility::std::TISReadLine<alib::nchar>( stream,
541inline std::basic_istream<wchar_t>&
operator>>( std::basic_istream<wchar_t>& stream,
544 #if ALIB_CHARACTERS_NATIVE_WCHAR
545 string << alib::strings::compatibility::std::TISReadLine<wchar_t>( &stream,
550 converter << alib::strings::compatibility::std::TISReadLine<wchar_t>( &stream,
552 string.Reset( converter );
570inline std::basic_istream<wchar_t>*
operator>>( std::basic_istream<wchar_t>* stream,
575 if (stream !=
nullptr)
592template<
typename TAppendable,
593 typename TEnableIf=
typename std::enable_if<
597std::ostream&
operator<<( std::ostream& stream,
const TAppendable& appendable )
618template<
typename TAppendable,
619 typename TEnableIf=
typename std::enable_if<
624std::ostream*
operator<<( std::ostream* stream,
const TAppendable& appendable )
626 if (stream !=
nullptr)
642template<
typename TAppendable,
643 typename TEnableIf=
typename std::enable_if<
648std::wostream&
operator<<( std::wostream& stream,
const TAppendable& appendable )
650 #if ALIB_CHARACTERS_NATIVE_WCHAR
674template<
typename TAppendable,
typename TAllocator,
675 typename TEnableIf=
typename std::enable_if< alib::strings::TT_IsAppendable<TAppendable,alib::wchar,TAllocator>::value
678std::wostream*
operator<<( std::wostream* stream,
const TAppendable& appendable )
680 if (stream !=
nullptr)
688 }}
namespace APPENDABLES {
690 namespace alib {
namespace strings {
TAString & _(const TString< TChar > &src, integer regionStart, integer regionLength=MAX_LEN)
void DbgDisableBufferReplacementWarning()
constexpr bool IsNotEmpty() const
constexpr integer Length() const
constexpr const TChar * Buffer() const
void Read(NAString &target)
void SetStream(::std::istream *is)
::std::istream * GetStream()
void Read(WAString &target)
NAString converter
The string buffer used for conversion.
StringReader()
Constructor.Invokes SetStream passing std::cin.
compatibility::std::TISReadLine< nchar > readOp
::std::ostream * GetStream()
ALIB_API void Write(const WString &src)
ALIB_API integer WriteAndGetWideLength(const NString &src)
ALIB_API integer WriteAndGetWideLength(const WString &src)
ALIB_API void Write(const NString &src)
ALIB_API void WriteChars(const nchar fillChar, integer count)
void SetStream(::std::ostream *os)
NAString converter
The string buffer used for conversion.
#define ALIB_ASSERT_MODULE(modulename)
#define ALIB_STRINGS_SUPPRESS_STD_OSTREAM_OPERATOR(TYPE)
#define ALIB_ASSERT_WARNING(cond,...)
@ Keep
Chooses not no clear existing data.
@ Clear
Chooses to clear existing data.
std::ostream & operator<<(std::ostream &stream, const alib::NString &string)
std::istream & operator>>(std::istream &stream, alib::NAString &string)
characters::nchar nchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
void operator()(TAString< TChar, lang::HeapAllocator > &target, const compatibility::std::TISReadLine< TChar > &reader)
TISReadLine(::std::basic_istream< TChar > *istream, lang::CurrentData targetData=lang::CurrentData::Clear, integer bufferSize=256, integer maxLineWidth=4096)
integer BufferSize
The amount of characters that the buffer is increased while reading parts of the line.
::std::basic_istream< TChar > * IStream
The input stream to read from.
integer MaxLineWidth
The maximum length of a single line to be read. Longer lines get truncated.
lang::CurrentData TargetData
If CurrentData::KEEP, the target AString is not cleared before the read operation.