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 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 236 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 () | |
| 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 &&!0, ::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 244 of file stdiostream.mpp.
|
protected |
The type of the base class that stores the allocator.
Definition at line 239 of file stdiostream.mpp.
| using alib::strings::compatibility::std::OStreamWriter< TChar, TAllocator, TSynced, TTargetLF >::CharType = TChar |
Exposes template parameter TChar.
Definition at line 243 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 252 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 263 of file stdiostream.mpp.
|
staticconstexpr |
Exposes template parameter TSynced.
Definition at line 242 of file stdiostream.mpp.
|
staticconstexpr |
Exposes template parameter TAdjustLF.
Definition at line 246 of file stdiostream.mpp.
|
inline |
Constructor accepting the destination stream.
| os | The output-stream to use. |
Definition at line 341 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 348 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 274 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 406 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 368 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 387 of file stdiostream.mpp.
|
inline |
See sibling method Write(const NString&, integer*).
| 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 394 of file stdiostream.mpp.
|
inline |
See sibling method Write(const NString&, integer*).
| 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 401 of file stdiostream.mpp.