ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
std_strings_iostream.hpp
Go to the documentation of this file.
1//==================================================================================================
2/// \file
3/// This header file is part of the \aliblong.<br>
4/// With the inclusion of this header compatibility features between \alib and the C++ standard
5/// library are provided.
6///
7/// \emoji :copyright: 2013-2024 A-Worx GmbH, Germany.
8/// Published under \ref mainpage_license "Boost Software License".
9//==================================================================================================
10#ifndef HPP_ALIB_COMPATIBILITY_STD_STRINGS_IOSTREAM
11#define HPP_ALIB_COMPATIBILITY_STD_STRINGS_IOSTREAM 1
12#pragma once
13#if !defined(DOXYGEN)
14# include "alib/alib.hpp"
15#endif
16
17ALIB_ASSERT_MODULE(STRINGS)
18
19#include "alib/compatibility/std_strings.hpp"
20#include <iostream>
22
24
25namespace alib { namespace strings { namespace compatibility { namespace std {
26
27//==================================================================================================
28/// This template type may be specialized to suppress ambiguities for types \p{T} which
29/// - have <c>std::operator<<(ostream, const T&)</c> defined, \b and
30/// - are \ref alib_strings_assembly_ttostring "appendable" to \alib strings.
31///
32/// \note
33/// The ambiguity occurs due to the definition of <c>std::operator<<</c> for all appendable
34/// types.
35///
36/// If a specialization of this template struct exists that inherits <c>std::true_type</c>,
37/// the compiler will not choose the \alib implementation of the operator, which resolves the
38/// ambiguity.
39///
40/// \see
41/// Specialization might be done with macro
42/// \ref ALIB_STRINGS_SUPPRESS_STD_OSTREAM_OPERATOR.
43///
44/// @tparam T The appendable type to suppress
45//==================================================================================================
46template<typename T> struct T_SuppressStdOstreamOperator : ::std::false_type {};
47
48#define ALIB_STRINGS_SUPPRESS_STD_OSTREAM_OPERATOR(TYPE) \
49 namespace alib::strings::compatibility::std { \
50 template<> struct T_SuppressStdOstreamOperator<TYPE> : ::std::true_type {}; }
51
52
53//==================================================================================================
54/// Parameter class used to append to objects of type \alib{strings;TAString;AString}, which
55/// invokes the method of the according specialization of template struct
56/// <b>T_Append<ISReadLine,TChar,HeapAllocator></b>.<br>
57/// This then reads a line of text from the encapsulated \b std::istream and appends that line to the
58/// target \b %AString.
59///
60/// While, of course, this class can be created 'inline' (for example, similar objects of parameter
61/// classes found in \alib{strings;TFormat;Format}), in the usual case that a series of lines are to
62/// be read from a \b std::istream, a local object of this type might be created. In case of a
63/// reading loop, rather outside such loop.
64///
65/// Field #IsEOF can be used to detect the end of the input stream.
66///
67/// \see
68/// - \alib{strings;compatibility::std::operator>>(std::istream&;NAString& string)} and
69/// \alib{strings;compatibility::std::operator<<(std::ostream&;const NString&)}.
70/// - For a sample, refer to source code of \alib class \b %IniFile, method
71/// \alib{config;IniFile::Read}.
72///
73///
74/// @tparam TChar The character type of the input stream as well as the receiving string.<br>
75/// Specializations for character types \alib{characters;nchar},
76/// \alib{characters;wchar} exist. Those have corresponding alias type definition
77/// shortcuts \alib{ISReadLineN} and \alib{ISReadLineW} in namespace #alib.
78//==================================================================================================
79template<typename TChar>
81{
82 /// The input stream to read from.
83 ::std::basic_istream<TChar>* IStream;
84
85 /// If \c CurrentData::KEEP, the target \c %AString is not cleared before the read operation.
87
88 /// The amount of characters that the buffer is increased while reading parts of the line.
90
91 /// The maximum length of a single line to be read. Longer lines get truncated.
93
94 /// Indicates if the end of the input stream was detected with the last read operation.
95 /// If so, a next read operation will not change the string (or clear it, if #TargetData is
96 /// \c false
97 bool IsEOF = false;
98
99 //==============================================================================================
100 /// Constructor.
101 ///
102 /// @param istream The input stream to read from.
103 /// @param targetData If \c CurrentData::Keep, the target \c %AString is not cleared
104 /// before the read operation is performed.
105 /// Defaults to \c CurrentData::Clear.
106 /// @param bufferSize The amount of characters that the buffer is increased while reading
107 /// parts of the line. Defaults to 256 characters.
108 /// @param maxLineWidth The maximum length of a single line to be read. Longer lines
109 /// get truncated. Defaults to 4096 characters.
110 //==============================================================================================
111 TISReadLine( ::std::basic_istream<TChar>* istream,
113 integer bufferSize = 256,
114 integer maxLineWidth = 4096 )
115 : IStream (istream),
116 TargetData (targetData),
117 BufferSize (bufferSize),
118 MaxLineWidth(maxLineWidth)
119 {}
120};
121
122
123}} // namespace alib::strings[::compatibility::std]
124
125#if DOXYGEN
126 namespace APPENDABLES {
127#endif
128
129/// Specialization of type-traits struct \alib{strings;T_Append} for type
130/// \alib{strings::compatibility::std;TISReadLine}.
131/// @tparam TChar The <b>AString</b>'s \ref alib_characters_chars "character type".
132template<typename TChar> struct T_Append<compatibility::std::TISReadLine<TChar>, TChar, lang::HeapAllocator>
133{
134 //==============================================================================================
135 /// Reads a line from a text file and appends the contents to \p{target}.
136 /// If the end of the input stream was reached, field
137 /// \alib{strings::compatibility::std::TISReadLine;IsEOF} of parameter \p{reader} will be set
138 /// to \c true, what indicates that a next read operation would fail if it was performed.
139 ///
140 /// \note
141 /// For setting field <em>IsEOF</em> the object will be cast to a non-constant reference.
142 /// See functor \alib{strings;T_Append} for an explanation why it is OK to do so.
143 ///
144 /// @param target The AString object to read into.
145 /// @param reader The object holding the \b std::istream and some parameters.
146 //==============================================================================================
149};
150
151#if DOXYGEN
152} namespace alib::strings[::APPENDABLES]
153#endif
154namespace compatibility { namespace std {
155
156//==================================================================================================
157/// This class is a simple helper-class that converts strings of the
158/// \alib{characters;character;default character type} to narrow strings as expected by
159/// \c std::ostream objects.
160///
161/// The basic goal of this class is to avoid preprocessor directives for code selection when
162/// the default string-type of \alib uses wide characters.
163///
164/// For example, to write string data into a file, the following approach is advised:
165///
166/// 1. Create an output stream of (derived) type \c std::ostream.
167/// 2. Create an object of this class and pass the output stream via #SetStream.
168/// 3. Write string data stored in objects of platform-dependent type alias \ref alib::AString
169/// by passing those to method #Write.
170///
171/// Within step 3, the compiler chooses the right overloaded version of the method #Write.
172/// Hence, the potentially necessary conversion of the string data is done transparently and only
173/// if needed.
174///
175/// \see Class \alib{strings::compatibility::std;StringReader}.
176//==================================================================================================
178{
179 protected:
180 /// The string buffer used for conversion.
182
183 public:
184 /// The output stream as provided with #SetStream. Will be set to the \c std::cout,
185 /// respectively \c std::wcout in the constructor.
186 ::std::ostream* ostream;
187
188 public:
189 //==========================================================================================
190 /// Constructor.
191 /// Invokes #SetStream passing \c std::cout.
192 //==========================================================================================
194 : ostream( &::std::cout )
195 {}
196
197
198 //==========================================================================================
199 /// Sets the output stream.
200 ///
201 /// @param os Pointer to the output stream to write to.
202 //==========================================================================================
203 void SetStream( ::std::ostream * os) { ostream= os; }
204
205 //==========================================================================================
206 /// Returns the output stream previously set with #SetStream.
207 ///
208 /// @return The output stream set with #SetStream.
209 //==========================================================================================
210 ::std::ostream* GetStream() { return ostream; }
211
212 //==========================================================================================
213 /// Write the given narrow string to the stream and return the length of the string given
214 /// if it was converted to wide characters.
215 ///
216 /// \note
217 /// The return value is the length of the given string if it was converted to wide string,
218 /// even though in this overloaded version it is unnecessary to be converted.
219 /// This is useful to determine the "real" output width when an output text is formatted.
220 /// Of course, in many locales, this is still not the real output width because even
221 /// uni-code characters are not guaranteed to represent exactly one printable character.
222 /// But still, this value is already a much better approximation than the length of the
223 /// given narrow string.
224 ///
225 /// @param src The string to write.
226 /// @return Returns the length of the given string as wide string.
227 //==========================================================================================
230
231 //==========================================================================================
232 /// Write the given wide string to the stream and returns the length of the string given
233 /// @param src The string to write.
234 /// @return Returns the length of the given wide string.
235 //==========================================================================================
238
239 //==========================================================================================
240 /// Write the given narrow string to the stream.
241 /// @param src The string to write.
242 //==========================================================================================
244 void Write( const NString& src );
245
246 //==========================================================================================
247 /// Write the given narrow character repeatedly to the stream.
248 /// @param fillChar The character to write.
249 /// @param count The number of characters to write.
250 //==========================================================================================
252 void WriteChars( const nchar fillChar, integer count );
253
254 //==========================================================================================
255 /// Write the given wide string to the stream.
256 /// @param src The string to write.
257 //==========================================================================================
259 void Write( const WString& src );
260};
261
262//==================================================================================================
263/// This class is a helper-class that converts narrow string data read from an object of
264/// type \c std::istream to the \alib{characters;character;default character type}.
265///
266/// \see Further explanations are given with sibling class
267/// \alib{strings::compatibility::std;StringWriter}.
268//==================================================================================================
270{
271 protected:
272 /// The string buffer used for conversion.
274
275 /// The input stream as provided with #SetStream. Will be set to the \c std::cin,
276 /// respectively \c std::win in the constructor.
278
279
280 public:
281 //==========================================================================================
282 /// Constructor.Invokes #SetStream passing \c std::cin.
283 //==========================================================================================
285 : readOp( &::std::cin )
286 {}
287
288
289 //==========================================================================================
290 /// Sets the input stream.
291 ///
292 /// @param is Pointer to the input stream to read from to.
293 //==========================================================================================
294 void SetStream( ::std::istream* is ) { readOp.IStream= is;}
295
296 //==========================================================================================
297 /// Returns the input stream previously set with #SetStream.
298 ///
299 /// @return The input stream set with #SetStream.
300 //==========================================================================================
301 ::std::istream* GetStream() { return readOp.IStream; }
302
303 //==========================================================================================
304 /// Returns \c true if the input stream signaled its end, \c false otherwise.
305 ///
306 /// @return \c true if the input stream is known to be at its end, \c false otherwise.
307 //==========================================================================================
308 bool IsEOF() { return readOp.IsEOF; }
309
310
311 //==========================================================================================
312 /// Reads one line of text from the input stream into a narrow string.
313 ///
314 /// @param target The storage buffer for the string to read. This string will be cleared
315 /// independent of the availability of input data.
316 //==========================================================================================
317 void Read( NAString& target )
318 {
319 target.Reset( readOp );
320 }
321
322 //==========================================================================================
323 /// Reads one line of text from the internal input stream into a wide string.
324 ///
325 /// @param target The storage buffer for the string to read. This string will be cleared
326 /// independent of the availability of input data.
327 //==========================================================================================
328 void Read( WAString& target )
329 {
330 target.Reset();
331 converter.Reset( readOp );
332 target << converter;
333 }
334};
335
336}}} // namespace alib[::strings::compatibility::std]
337
338/// Type alias in namespace \b alib.
340
341/// Type alias in namespace \b alib.
343
344/// Type alias in namespace \b alib.
346
347/// Type alias in namespace \b alib.
349
350/// Type alias in namespace \b alib.
352
353
354// #################################################################################################
355// #################### std::ostream& operator<< ###############################
356// #################################################################################################
357#if DOXYGEN
358 namespace strings { namespace compatibility { namespace std {
359#else
360} // namespace [alib]
361#endif
362
363//==================================================================================================
364/// Copies the contents of the given \b %NString to into the \c std::ostream given as reference.
365///
366/// \note Unlike this documentation indicates, the operator is defined in the global namespace.
367/// @param stream The ostream object to write the given String into.
368/// @param string The String to write into the given ostream.
369/// @returns The ostream to allow concatenated operations.
370//==================================================================================================
371inline std::ostream& operator<<( std::ostream& stream, const alib::NString& string )
372{
373 if ( string.IsNotEmpty() )
374 stream.write( string.Buffer(), string.Length() );
375 return stream;
376}
377
378//==================================================================================================
379/// Copies the contents of the given \b %NString to into the \c std::ostream given as pointer.
380///
381/// \note Unlike this documentation indicates, the operator is defined in the global namespace.
382/// @param stream The ostream object to write the given String into.
383/// @param string The String to write into the given ostream.
384/// @returns The ostream to allow concatenated operations.
385//==================================================================================================
386inline std::ostream* operator<<( std::ostream* stream, const alib::NString& string )
387{
388 stream->write( string.Buffer(), string.Length() );
389 return stream;
390}
391
392//==================================================================================================
393/// Copies the contents of the given \b %WString to into the \c std::ostream given as reference.
394///
395/// \note Unlike this documentation indicates, the operator is defined in the global namespace.
396/// @param stream The ostream object to write the given String into.
397/// @param string The String to write into the given ostream.
398/// @returns The ostream to allow concatenated operations.
399//==================================================================================================
400ALIB_API std::ostream& operator<<( std::ostream& stream, const alib::WString& string );
401
402//==================================================================================================
403/// Copies the contents of the given \b %WString to into the \c std::ostream given as pointer.
404///
405/// \note Unlike this documentation indicates, the operator is defined in the global namespace.
406/// @param stream The ostream object to write the given String into.
407/// @param string The String to write into the given ostream.
408/// @returns The ostream to allow concatenated operations.
409//==================================================================================================
410inline std::ostream* operator<<( std::ostream* stream, const alib::WString& string )
411{
412 (*stream) << string;
413 return stream;
414}
415
416//==================================================================================================
417/// Copies the contents of the given \b %NString to into the \c std::wostream given as reference.
418///
419/// \note
420/// This operator uses a local string buffer of 256 bytes size to convert the given narrow string
421/// to an string of \c wchar_t characters that the output stream accepts. In case that
422/// the given \p{string} is larger, a dynamic memory allocation has to be made.<br>
423/// In performance-critical code that writes larger string data, a custom conversion method,
424/// that for example reuses a buffer, may be appropriate.
425///
426/// <p>
427/// \note Unlike this documentation indicates, the operator is defined in the global namespace.
428/// @param stream The ostream object to write the given String into.
429/// @param string The String to write into the given ostream.
430/// @returns The ostream to allow concatenated operations.
431//==================================================================================================
432ALIB_API std::wostream& operator<<( std::wostream& stream, const alib::NString& string );
433
434//==================================================================================================
435/// Copies the contents of the given \b %NString to into the \c std::wostream given as pointer.
436///
437/// \note Unlike this documentation indicates, the operator is defined in the global namespace.
438/// \see The notes on memory efficiency, documented with operator
439/// \alib{strings::compatibility::std;operator<<(std::wostream&,const NString&)}
440/// which this operator uses inline.
441/// @param stream The ostream object to write the given String into.
442/// @param string The String to write into the given ostream.
443/// @returns The ostream to allow concatenated operations.
444//==================================================================================================
445inline std::wostream* operator<<( std::wostream* stream, const alib::NString& string )
446{
447 (*stream) << string;
448 return stream;
449}
450
451//==================================================================================================
452/// Copies the contents of the given \b %WString to into the \c std::wostream given as reference.
453///
454/// \note Unlike this documentation indicates, the operator is defined in the global namespace.
455/// @param stream The ostream object to write the given String into.
456/// @param string The String to write into the given ostream.
457/// @returns The ostream to allow concatenated operations.
458//==================================================================================================
459inline std::wostream& operator<<( std::wostream& stream, const alib::WString& string )
460{
461 if ( string.IsNotEmpty() )
462 {
463 #if ALIB_CHARACTERS_NATIVE_WCHAR
464 stream.write( string.Buffer(), string.Length() );
465 #else
466 alib::XLocalString<1024> converter( string );
468 stream.write( converter.Buffer(), converter.Length() );
469 #endif
470 }
471 return stream;
472}
473
474//==================================================================================================
475/// Copies the contents of the given \b %WString to into the \c std::wostream given as pointer.
476///
477/// \note Unlike this documentation indicates, the operator is defined in the global namespace.
478/// @param stream The ostream object to write the given String into.
479/// @param string The String to write into the given ostream.
480/// @returns The ostream to allow concatenated operations.
481//==================================================================================================
482inline std::wostream* operator<<( std::wostream* stream, const alib::WString& string )
483{
484 (*stream) << string;
485 return stream;
486}
487
488//==================================================================================================
489/// Clears the given \b %NAString and extracts data from the std::istream into it. The extractions
490/// ends with either the end of the std::istream or when reading a newline character.
491///
492/// \note Unlike this documentation indicates, the operator is defined in the global namespace.
493/// @param stream The istream object to extract data from.
494/// @param string The AString to receive data.
495/// @returns The ostream to allow concatenated operations.
496//==================================================================================================
497inline std::istream& operator>>( std::istream& stream, alib::NAString& string )
498{
499 string << alib::strings::compatibility::std::TISReadLine<alib::nchar>( &stream,
501 return stream;
502}
503
504//==================================================================================================
505/// Clears the given \b %NAString and extracts data from the std::istream into it. The extractions
506/// ends with either the end of the std::istream or when reading a newline character.
507///
508/// \note Unlike this documentation indicates, the operator is defined in the global namespace.
509/// @param stream The istream object to extract data from.
510/// @param string The AString to receive data.
511/// @returns The ostream to allow concatenated operations.
512//==================================================================================================
513inline std::istream* operator>>( std::istream* stream, alib::NAString& string )
514{
515 ALIB_ASSERT_WARNING( stream != nullptr, "STRINGS", "Given std::IStream is nullptr" )
516
517 if (stream != nullptr)
518 string << alib::strings::compatibility::std::TISReadLine<alib::nchar>( stream,
520 return stream;
521}
522
523//==================================================================================================
524/// Clears the given \b %WAString and extracts data from the std::istream into it. The extractions
525/// ends with either the end of the std::istream or when reading a newline character.
526///
527/// \note
528/// If code selection symbol \ref ALIB_CHARACTERS_NATIVE_WCHAR evaluates to false, a local buffer
529/// is used to convert the string of \c wchar_t characters that the input stream provides.
530/// In case that the string read from the stream is larger, a dynamic memory allocation has to
531/// be made.<br>
532/// In performance-critical code that receives larger string data, a custom conversion method
533/// that, for example, reuses a buffer may be appropriate.
534///
535/// <p>
536/// \note Unlike this documentation indicates, the operator is defined in the global namespace.
537/// @param stream The istream object to extract data from.
538/// @param string The AString to receive data.
539/// @returns The ostream to allow concatenated operations.
540//==================================================================================================
541inline std::basic_istream<wchar_t>& operator>>( std::basic_istream<wchar_t>& stream,
542 alib::WAString& string )
543{
544 #if ALIB_CHARACTERS_NATIVE_WCHAR
545 string << alib::strings::compatibility::std::TISReadLine<wchar_t>( &stream,
547 #else
548 alib::XLocalString<1024> converter;
550 converter << alib::strings::compatibility::std::TISReadLine<wchar_t>( &stream,
552 string.Reset( converter );
553 #endif
554 return stream;
555}
556
557//==================================================================================================
558/// Clears the given \b %WAString and extracts data from the std::istream into it. The extractions
559/// ends with either the end of the std::istream or when reading a newline character.
560///
561/// \note Unlike this documentation indicates, the operator is defined in the global namespace.
562///
563/// \see The notes on memory efficiency, documented with operator
564/// \alib{strings::compatibility::std;operator>>(std::basic_istream<wchar_t>&, WAString& )}
565/// which this operator uses inline.
566/// @param stream The istream object to extract data from.
567/// @param string The AString to receive data.
568/// @returns The ostream to allow concatenated operations.
569//==================================================================================================
570inline std::basic_istream<wchar_t>* operator>>( std::basic_istream<wchar_t>* stream,
571 alib::WAString& string )
572{
573 ALIB_ASSERT_WARNING ( stream != nullptr, "STRINGS", "Given std::istream is nullptr" )
574
575 if (stream != nullptr)
576 (*stream) >> string;
577 return stream;
578}
579
580
581//==================================================================================================
582/// Copies the contents of the given \ref alib_strings_assembly_ttostring "appendable type"
583/// the \c std::ostream given as reference.
584///
585/// \note Unlike this documentation indicates, this operator is defined in the global namespace.
586///
587/// @tparam TAppendable The appendable type.
588/// @param stream The \c std::ostream object to write the given String into.
589/// @param appendable The object whose contents is to be written into the given \p{stream}.
590/// @returns The ostream to allow concatenated operations.
591//==================================================================================================
592template<typename TAppendable,
593 typename TEnableIf= typename std::enable_if<
596 >::type>
597std::ostream& operator<<( std::ostream& stream, const TAppendable& appendable )
598{
601
602 if ( buf._(appendable).IsNotEmpty() )
603 stream.write( buf.Buffer(), buf.Length() );
604 return stream;
605}
606
607//==================================================================================================
608/// Copies the contents of the given \alib{strings;T_Append;appendable type} the \c std::ostream
609/// given as pointer.
610///
611/// \note Unlike this documentation indicates, this operator is defined in the global namespace.
612///
613/// @tparam TAppendable The appendable type.
614/// @param stream The \c std::ostream object to write the given String into.
615/// @param appendable The object whose contents is to be written into the given \p{stream}.
616/// @returns The ostream to allow concatenated operations.
617//==================================================================================================
618template<typename TAppendable,
619 typename TEnableIf= typename std::enable_if<
622 >::type>
623
624std::ostream* operator<<( std::ostream* stream, const TAppendable& appendable )
625{
626 if (stream != nullptr)
627 operator<<( * stream, appendable );
628 return stream;
629}
630
631//==================================================================================================
632/// Copies the contents of the given \alib{strings;T_Append;appendable type} the \c std::ostream
633/// given as reference.
634///
635/// \note Unlike this documentation indicates, this operator is defined in the global namespace.
636///
637/// @tparam TAppendable The appendable type.
638/// @param stream The \c std::ostream object to write the given String into.
639/// @param appendable The object whose contents is to be written into the given \p{stream}.
640/// @returns The ostream to allow concatenated operations.
641//==================================================================================================
642template<typename TAppendable,
643 typename TEnableIf= typename std::enable_if<
646 >::type>
647
648std::wostream& operator<<( std::wostream& stream, const TAppendable& appendable )
649{
650 #if ALIB_CHARACTERS_NATIVE_WCHAR
652 #else
654 #endif
656
657 if ( buf._(appendable).IsNotEmpty() )
658 stream.write( buf.Buffer(), buf.Length() );
659 return stream;
660}
661
662//==================================================================================================
663/// Copies the contents of the given \alib{strings;T_Append;appendable type} the \c std::ostream
664/// given as pointer.
665///
666/// \note Unlike this documentation indicates, this operator is defined in the global namespace.
667///
668/// @tparam TAppendable The appendable type.
669/// @tparam TAllocator The allocator type, as prototyped with \alib{lang;Allocator}.
670/// @param stream The \c std::ostream object to write the given String into.
671/// @param appendable The object whose contents is to be written into the given \p{stream}.
672/// @returns The ostream to allow concatenated operations.
673//==================================================================================================
674template<typename TAppendable, typename TAllocator,
675 typename TEnableIf= typename std::enable_if< alib::strings::TT_IsAppendable<TAppendable,alib::wchar,TAllocator>::value
677 >::type>
678std::wostream* operator<<( std::wostream* stream, const TAppendable& appendable )
679{
680 if (stream != nullptr)
681 operator<<( * stream, appendable );
682 return stream;
683}
684
685
686
687#if DOXYGEN
688 }} namespace APPENDABLES {
689#else
690 namespace alib { namespace strings { // the real namespace
691#endif
692
693
695 ::operator()( TAString<char , lang::HeapAllocator>& target, const strings::compatibility::std::TISReadLine<char >& reader );
696
698 ::operator()( TAString<wchar_t, lang::HeapAllocator>& target, const strings::compatibility::std::TISReadLine<wchar_t>& reader );
699
700#if DOXYGEN
701 }} // namespace alib[::strings::APPENDABLES]
702#else
703 } // namespace alib[::strings]
704#endif
705
706} // namespace [alib]
707
709
714
719
720#endif // HPP_ALIB_COMPATIBILITY_STD_STRINGS_IOSTREAM
721
TAString & _(const TString< TChar > &src, integer regionStart, integer regionLength=MAX_LEN)
void DbgDisableBufferReplacementWarning()
Definition tastring.inl:363
constexpr bool IsNotEmpty() const
Definition string.hpp:389
constexpr integer Length() const
Definition string.hpp:326
constexpr const TChar * Buffer() const
Definition string.hpp:319
NAString converter
The string buffer used for conversion.
StringReader()
Constructor.Invokes SetStream passing std::cin.
compatibility::std::TISReadLine< nchar > readOp
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)
NAString converter
The string buffer used for conversion.
#define ALIB_ASSERT_MODULE(modulename)
Definition alib.hpp:223
#define ALIB_API
Definition alib.hpp:639
#define ALIB_STRINGS_SUPPRESS_STD_OSTREAM_OPERATOR(TYPE)
#define ALIB_ASSERT_WARNING(cond,...)
Definition alib.hpp:1272
@ 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)
Definition alib.cpp:69
characters::nchar nchar
Type alias in namespace alib.
lang::integer integer
Type alias in namespace alib.
Definition integers.hpp:273
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.