CGAL 6.2 - IO Streams
Loading...
Searching...
No Matches
CGAL::IO::Basic_indenting_streambuf< CharT, Traits > Class Template Reference

#include <CGAL/IO/Indenting_ostream.h>

Inherits from

std::basic_streambuf< CharT, std::char_traits< CharT > >, and std::char_traits< CharT >.

Definition

template<typename CharT, typename Traits = std::char_traits<CharT>>
class CGAL::IO::Basic_indenting_streambuf< CharT, Traits >

The class template Basic_indenting_streambuf wraps another basic_streambuf and automatically adds indentation at the beginning of each line.

This is useful for formatting debug output with consistent indentation levels.

Template Parameters
CharTCharacter type (typically char or wchar_t)
TraitsCharacter traits type
See also
Basic_indenting_stream_guard
make_indenting_guards
Examples
Stream_support/indenting_ostream.cpp.

Public Types

using char_type = CharT
 Character type.
 
using traits_type = Traits
 Character traits type.
 
using int_type = typename traits_type::int_type
 Integer type for character representation.
 
using pos_type = typename traits_type::pos_type
 Position type for stream positioning.
 
using off_type = typename traits_type::off_type
 Offset type for stream positioning.
 
using streambuf_type = std::basic_streambuf< char_type, traits_type >
 Type of the wrapped streambuf.
 
using string = std::basic_string< char_type >
 String type matching character type.
 

Public Member Functions

 Basic_indenting_streambuf (streambuf_type &wrapped_buf, const string &indent_string={2, char_type(' ')})
 constructs an indenting streambuf wrapper.
 
const stringindent_string () const
 gets the current indentation string.
 
void set_indent_string (const string &new_indent)
 sets a new indentation string.
 
void set_indent_level (int level, int spaces_per_level=2)
 sets indentation level using repeated spaces.
 
streambuf_typewrapped_streambuf () const
 gets the wrapped streambuf.
 

Constructor & Destructor Documentation

◆ Basic_indenting_streambuf()

template<typename CharT , typename Traits = std::char_traits<CharT>>
CGAL::IO::Basic_indenting_streambuf< CharT, Traits >::Basic_indenting_streambuf ( streambuf_type wrapped_buf,
const string indent_string = {2, char_type(' ')} 
)
explicit

constructs an indenting streambuf wrapper.

Parameters
wrapped_bufThe underlying streambuf to wrap
indent_stringThe string to use for indentation (default: 2 spaces)

Member Function Documentation

◆ set_indent_level()

template<typename CharT , typename Traits = std::char_traits<CharT>>
void CGAL::IO::Basic_indenting_streambuf< CharT, Traits >::set_indent_level ( int  level,
int  spaces_per_level = 2 
)

sets indentation level using repeated spaces.

Parameters
levelNumber of indentation levels
spaces_per_levelNumber of spaces per level (default: 2)

◆ set_indent_string()

template<typename CharT , typename Traits = std::char_traits<CharT>>
void CGAL::IO::Basic_indenting_streambuf< CharT, Traits >::set_indent_string ( const string new_indent)

sets a new indentation string.

Parameters
new_indentThe new indentation string