This class writes ALib Strings into instances of std::basic_ostream<TChar>. The features of this type are:
std::ostream and std::wostream). The character width is controlled with the template parameter TChar."\r\n", on GNU/Linux platforms, just "\n" may be written. This feature is controlled by the template parameter TTargetLF.It is recommended that only short-living, local instances of this class are created. This is especially important in the case that parameter TSynced is true. In this mode, this type follows the RAII idiom just as its then available member
std::osyncstream does.
std::osyncstream only if the compiler flag -fexperimental-library is provided.| TChar | The character type of the target std::basic_ostream. Defaults to nchar (which effectively is C++ char). |
| TAllocator | The allocator type to use with std::osyncstream (if TSynced is true), and with temporary character conversion buffers in case those need to exceed 4kB.Defaults to lang::HeapAllocator. |
| TSynced | Determines if the encapsulated std::ostream should be synchronized on writing. If so, the C++ 20 mechanism provided with std::osyncstream std::cout and std::cerr. |
| TTargetLF | Determines whether non-conform line-feeds are adjusted. The default value is Platform, which converts all line-feeds to the platforms' standard. Values Unix and WindowsOS can be used to force conversion to a different standard. Finally, Ignore disables the detection and conversion of line-feed codes. |
Definition at line 235 of file stdiostream.mpp.
Public Type Index: | |
| using | AllocatorType = TAllocator |
| Exposes template parameter TAllocator. | |
| using | CharType = TChar |
| Exposes template parameter TChar. | |
Public Type Index: inherited from alib::lang::AllocatorMember< lang::HeapAllocator > | |
| using | AllocatorType |
| Exposes the allocator type. | |
Public Static Field Index: | |
| static constexpr bool | Synced = TSynced |
| Exposes template parameter TSynced. | |
| static constexpr lang::LineFeeds | TargetLF = TTargetLF |
| Exposes template parameter TAdjustLF. | |
Public Field Index: | |
| bool | DisableSync =false |
Public Method Index: | |
| OStreamWriter (::std::basic_ostream< TChar > &os) | |
| OStreamWriter (::std::basic_ostream< TChar > &os, TAllocator &alloc) | |
| void | Fill (const TChar fillChar, integer count) |
| ::std::ostream & | GetStream () |
| void | Write (const NString &src, integer *printedWidth=nullptr) |
| void | Write (const WString &src, integer *printedWidth=nullptr) |
| void | Write (const XString &src, integer *printedWidth=nullptr) |
Public Method Index: inherited from alib::lang::AllocatorMember< lang::HeapAllocator > | |
| AllocatorMember () | |
| AllocatorMember (lang::HeapAllocator &pAllocator) noexcept | |
| AllocatorInterface< lang::HeapAllocator > | AI () const noexcept |
| lang::HeapAllocator & | GetAllocator () const noexcept |
Protected Type Index: | |
| using | allocBase = lang::AllocatorMember<TAllocator> |
| The type of the base class that stores the allocator. | |
Protected Field Index: | |
| ::std::conditional_t< TSynced &&!ALIB_SINGLE_THREADED, ::std::basic_osyncstream< TChar, ::std::char_traits< TChar >, lang::StdAllocator< TChar, TAllocator > >, ::std::basic_ostream< TChar > & > | ostream |
Protected Field Index: inherited from alib::lang::AllocatorMember< lang::HeapAllocator > | |
| lang::HeapAllocator * | allocator |
| The allocator stored. | |
Protected Method Index: | |
| template<typename TSrc> | |
| void | doWrite (const TString< TSrc > &src, integer *printedWidth) |
| using alib::strings::compatibility::std::OStreamWriter< TChar, TAllocator, TSynced, TTargetLF >::AllocatorType = TAllocator |
Exposes template parameter TAllocator.
Definition at line 243 of file stdiostream.mpp.
|
protected |
The type of the base class that stores the allocator.
Definition at line 238 of file stdiostream.mpp.
| using alib::strings::compatibility::std::OStreamWriter< TChar, TAllocator, TSynced, TTargetLF >::CharType = TChar |
Exposes template parameter TChar.
Definition at line 242 of file stdiostream.mpp.
| bool alib::strings::compatibility::std::OStreamWriter< TChar, TAllocator, TSynced, TTargetLF >::DisableSync =false |
This flag may be set after construction to disable the syncing mechanics, even if the template parameter TSynced is set. This is useful, for example, if a using code detects recursion, which is not allowed with std::osyncstream and STD_IOSTREAMS_LOCK.
Definition at line 251 of file stdiostream.mpp.
|
protected |
If unsynced, this member holds the output stream as provided with construction. In the synced case, this stores a std::basic_osyncstream which wraps the given output stream.
Definition at line 262 of file stdiostream.mpp.
|
staticconstexpr |
Exposes template parameter TSynced.
Definition at line 241 of file stdiostream.mpp.
|
staticconstexpr |
Exposes template parameter TAdjustLF.
Definition at line 245 of file stdiostream.mpp.
|
inline |
Constructor accepting the destination stream.
| os | The output-stream to use. |
Definition at line 340 of file stdiostream.mpp.
|
inline |
Constructor accepting the destination stream, as well as an allocator to use.
| os | The output-stream to use. |
| alloc | The allocator to use for the internal buffers. |
Definition at line 347 of file stdiostream.mpp.
|
inlineprotected |
Implementation of overloaded methods Write.
| src | The string to write. | |
| [out] | printedWidth | If given, the output width of src when it was printed is returned. (See the class description for further information.) |
| TSrc | The character type of the source string. |
Definition at line 273 of file stdiostream.mpp.
|
inline |
Write the given character repeatedly to the stream.
| fillChar | The character to write. |
| count | The number of characters to write. |
Definition at line 405 of file stdiostream.mpp.
|
inline |
Returns the output stream given with construction, or, if template parameter TSynced is true, that output stream wrapped in a std::basic_osyncstream. In the latter case, the sync-stream is destructed - and data is written - only with the destruction of this instance.
Definition at line 367 of file stdiostream.mpp.
|
inline |
Writes the given narrow string to the stream.
| src | The string to write. | |
| [out] | printedWidth | If given, the width if src was printed is returned. See the note above. If not given, the method might execute slightly faster. |
Definition at line 386 of file stdiostream.mpp.
|
inline |
See sibling method Write( const NString& src, integer* printedWidth ).
| src | The wide string to write. | |
| [out] | printedWidth | If given, the width if src was printed is returned. See the note above. If not given, the method might execute slightly faster. |
Definition at line 393 of file stdiostream.mpp.
|
inline |
See sibling method Write( const NString& src, integer* printedWidth ).
| src | The strange string to write. | |
| [out] | printedWidth | If given, the width if src was printed is returned. See the note above. If not given, the method might execute slightly faster. |
Definition at line 400 of file stdiostream.mpp.