Ookii.CommandLine for C++  1.0.0
Public Types | Public Member Functions | Static Public Member Functions | List of all members
ookii::basic_line_wrapping_ostream< CharType, Traits > Class Template Reference

Output stream that wraps lines on white-space characters at the specified line length, and with support for indentation. More...

#include <ookii/line_wrapping_stream.h>

Inheritance diagram for ookii::basic_line_wrapping_ostream< CharType, Traits >:
Inheritance graph
[legend]
Collaboration diagram for ookii::basic_line_wrapping_ostream< CharType, Traits >:
Collaboration graph
[legend]

Public Types

using base_type = std::basic_ostream< CharType, Traits >
 The concrete type that this class derives from.
 
using streambuf_type = std::basic_streambuf< CharType, Traits >
 The concrete base stream buffer type used by this stream.
 

Public Member Functions

 basic_line_wrapping_ostream (base_type &base_stream, size_t max_line_length)
 Initializes a new instance of the basic_line_wrapping_ostream class with the specified underlying stream and maximum line length. More...
 
 basic_line_wrapping_ostream (basic_line_wrapping_ostream &&other) noexcept
 Move constructor. More...
 
basic_line_wrapping_ostreamoperator= (basic_line_wrapping_ostream &&other) noexcept
 Move assignment operator. More...
 
void swap (basic_line_wrapping_ostream &other) noexcept
 Swaps this basic_line_wrapping_ostream instance with another. More...
 

Static Public Member Functions

static basic_line_wrapping_ostream for_cerr (short default_width=80)
 Creates a basic_line_wrapping_ostream that writes to the standard error stream, using the console width as the line width. More...
 
static basic_line_wrapping_ostream for_cout (short default_width=80)
 Creates a basic_line_wrapping_ostream that writes to the standard output stream, using the console width as the line width. More...
 

Detailed Description

template<typename CharType, typename Traits = std::char_traits<CharType>>
class ookii::basic_line_wrapping_ostream< CharType, Traits >

Output stream that wraps lines on white-space characters at the specified line length, and with support for indentation.

This stream writes its output to the stream buffer of another stream, which could be any stream (like a file stream, or string stream).

Warning
This class assumes that the target stream is at the start of a line when writing starts, and that no other users are writing to the same stream. Otherwise, output will not be correctly wrapped or indented.

Several typedefs for common character types are provided:

Type Definition
ookii::line_wrapping_ostream ookii::basic_line_wrapping_ostream<char>
ookii::wline_wrapping_ostream ookii::basic_line_wrapping_ostream<wchar_t>
Template Parameters
CharTypeThe type of characters used by the target stream.
TraitsThe character traits used by the target stream.

Constructor & Destructor Documentation

◆ basic_line_wrapping_ostream() [1/2]

template<typename CharType , typename Traits = std::char_traits<CharType>>
ookii::basic_line_wrapping_ostream< CharType, Traits >::basic_line_wrapping_ostream ( base_type base_stream,
size_t  max_line_length 
)
inline

Initializes a new instance of the basic_line_wrapping_ostream class with the specified underlying stream and maximum line length.

Parameters
base_streamThe stream whose stream buffer to write output to.
max_line_lengthThe maximum line length, or a value of 0 or larger than 65536 to specify no limit. Use the use_console_width constant to use the console width as the maximum.

◆ basic_line_wrapping_ostream() [2/2]

template<typename CharType , typename Traits = std::char_traits<CharType>>
ookii::basic_line_wrapping_ostream< CharType, Traits >::basic_line_wrapping_ostream ( basic_line_wrapping_ostream< CharType, Traits > &&  other)
inlinenoexcept

Move constructor.

Parameters
otherThe basic_line_wrapping_ostream to move from.

Member Function Documentation

◆ for_cerr()

template<typename CharType , typename Traits = std::char_traits<CharType>>
static basic_line_wrapping_ostream ookii::basic_line_wrapping_ostream< CharType, Traits >::for_cerr ( short  default_width = 80)
inlinestatic

Creates a basic_line_wrapping_ostream that writes to the standard error stream, using the console width as the line width.

Parameters
default_widthThe maximum line length to use if the console width cannot be determined.

◆ for_cout()

template<typename CharType , typename Traits = std::char_traits<CharType>>
static basic_line_wrapping_ostream ookii::basic_line_wrapping_ostream< CharType, Traits >::for_cout ( short  default_width = 80)
inlinestatic

Creates a basic_line_wrapping_ostream that writes to the standard output stream, using the console width as the line width.

Parameters
default_widthThe maximum line length to use if the console width cannot be determined.

◆ operator=()

template<typename CharType , typename Traits = std::char_traits<CharType>>
basic_line_wrapping_ostream& ookii::basic_line_wrapping_ostream< CharType, Traits >::operator= ( basic_line_wrapping_ostream< CharType, Traits > &&  other)
inlinenoexcept

Move assignment operator.

Parameters
otherThe basic_line_wrapping_ostream to move from.

◆ swap()

template<typename CharType , typename Traits = std::char_traits<CharType>>
void ookii::basic_line_wrapping_ostream< CharType, Traits >::swap ( basic_line_wrapping_ostream< CharType, Traits > &  other)
inlinenoexcept

Swaps this basic_line_wrapping_ostream instance with another.

Parameters
otherThe instance to swap with.

The documentation for this class was generated from the following file: