Sierra Toolkit Version of the Day
stk::basic_indent_streambuf< Ch, Tr > Class Template Reference

Class basic_indent_streambuf implements a output streambuf that performs indentation, blank line removal and outline bracing, sending the result character stream to another output stream buffer. More...

#include <IndentStreambuf.hpp>

List of all members.

Public Types

enum  { MAX_INDENT_LEVEL = 50 }
enum  Flags {
  NO_BRACES = 0x00,
  NO_BLANK_LINES = 0x00,
  BRACES = 0x01,
  BLANK_LINES = 0x02
}
 Class Flags ... More...

Public Member Functions

 basic_indent_streambuf (std::basic_streambuf< Ch, Tr > *stream_buffer, size_t indent_size=2, unsigned flags=BRACES)
virtual ~basic_indent_streambuf ()
void redirect (std::basic_streambuf< Ch, Tr > *stream_buffer)
 Member function redirect sets the destination output stream buffer.
std::streambuf * get_stream_buffer ()
 Member function get_stream_buffer returns the current destination output stream buffer.
void set_indent_size (size_t indent_size)
 Member function set_indent_size set the number of spaces to write for each indentation level.
void set_flags (unsigned flags)
 Member function set_flags enables or disables the BLANK_LINES and BRACES written to the destination stream.
virtual std::basic_streambuf
< Ch, Tr >::int_type 
overflow (typename std::basic_streambuf< Ch, Tr >::int_type c)
 Member function overflow interprets a meta-character or writes the specified character to the destination output stream buffer. If the character is a meta-character, the aproprate action is performed.
virtual std::streamsize xsputn (const Ch *p, std::streamsize n)
 Member function xsputn interprets the meta-characters or writes the specified characters to the destination output stream buffer. If a character is a meta-character, the aproprate action is performed.
virtual int sync ()
 Member function sync syncs the destination output stream buffer.

Detailed Description

template<class Ch, class Tr = std::char_traits<Ch>>
class stk::basic_indent_streambuf< Ch, Tr >

Class basic_indent_streambuf implements a output streambuf that performs indentation, blank line removal and outline bracing, sending the result character stream to another output stream buffer.

When, the meta-characters PUSH, POP, and LEFT are inserted into the stream buffer, the characters is discarded and the appropriate operation occurs. In the case of PUSH, the next line will indented by an additional m_indentSize spaces and the currently line will end with an open brace ({) is BRACES are enabled. In the case of POP, the next line will be indented by m_indentSize spaces, it may be preceeded by a line containing a properly indented close brace (}). In the case of LEFT, the next line (current line if at the start), will not be indented.

The stream bufer can be created with BRACES and BLANK_LINES enabled or disabled. When BRACE is enabled, then indentation will be produces braces which allows editors to traverse blocks. Blank lines are normally eliminated, but may be allowed if BLANK_LINES is specified.

Definition at line 40 of file IndentStreambuf.hpp.


Member Enumeration Documentation

template<class Ch , class Tr = std::char_traits<Ch>>
anonymous enum
Enumerator:
MAX_INDENT_LEVEL 

Maximum indentation level.

Definition at line 43 of file IndentStreambuf.hpp.

template<class Ch , class Tr = std::char_traits<Ch>>
enum stk::basic_indent_streambuf::Flags

Class Flags ...

Enumerator:
NO_BRACES 

No braces on indentation shift.

NO_BLANK_LINES 

No blank line are written.

BRACES 

Braces on indentation shift.

BLANK_LINES 

Blank line are written.

Definition at line 51 of file IndentStreambuf.hpp.


Constructor & Destructor Documentation

template<class Ch , class Tr = std::char_traits<Ch>>
stk::basic_indent_streambuf< Ch, Tr >::basic_indent_streambuf ( std::basic_streambuf< Ch, Tr > *  stream_buffer,
size_t  indent_size = 2,
unsigned  flags = BRACES 
) [inline, explicit]

Creates a new basic_indent_streambuf instance.

Parameters:
indent_sizea size_t value of the number of spaces for each indentation level.
flagsan unsigned int value of Flags to enable or disable BLANK_LINES and BRACES.

Definition at line 68 of file IndentStreambuf.hpp.

template<class Ch , class Tr = std::char_traits<Ch>>
virtual stk::basic_indent_streambuf< Ch, Tr >::~basic_indent_streambuf ( ) [inline, virtual]

Destroys a basic_indent_streambuf instance.

Definition at line 85 of file IndentStreambuf.hpp.


Member Function Documentation

template<class Ch , class Tr = std::char_traits<Ch>>
std::streambuf* stk::basic_indent_streambuf< Ch, Tr >::get_stream_buffer ( ) [inline]

Member function get_stream_buffer returns the current destination output stream buffer.

Returns:
a std::streambuf pointer to the current destination output stream buffer.

Definition at line 104 of file IndentStreambuf.hpp.

template<class Ch , class Tr = std::char_traits<Ch>>
void stk::basic_indent_streambuf< Ch, Tr >::set_indent_size ( size_t  indent_size) [inline]

Member function set_indent_size set the number of spaces to write for each indentation level.

Parameters:
indent_sizea size_t value of the number of spaces for each indentation level.

Definition at line 116 of file IndentStreambuf.hpp.

template<class Ch , class Tr = std::char_traits<Ch>>
void stk::basic_indent_streambuf< Ch, Tr >::set_flags ( unsigned  flags) [inline]

Member function set_flags enables or disables the BLANK_LINES and BRACES written to the destination stream.

Parameters:
flagsan unsigned int value of the Flags to enable/disable.

Definition at line 131 of file IndentStreambuf.hpp.

template<class Ch , class Tr = std::char_traits<Ch>>
virtual std::basic_streambuf<Ch, Tr>::int_type stk::basic_indent_streambuf< Ch, Tr >::overflow ( typename std::basic_streambuf< Ch, Tr >::int_type  c) [inline, virtual]

Member function overflow interprets a meta-character or writes the specified character to the destination output stream buffer. If the character is a meta-character, the aproprate action is performed.

Parameters:
can int value of the character to write.
Returns:
an int value of the character written.

Definition at line 197 of file IndentStreambuf.hpp.

template<class Ch , class Tr = std::char_traits<Ch>>
virtual std::streamsize stk::basic_indent_streambuf< Ch, Tr >::xsputn ( const Ch *  p,
std::streamsize  n 
) [inline, virtual]

Member function xsputn interprets the meta-characters or writes the specified characters to the destination output stream buffer. If a character is a meta-character, the aproprate action is performed.

Parameters:
pa Ch const pointer to the character string to write.
na std::streamsize value of the number of characters in the string.
Returns:
a std::streamsize value of the number of characters os the string which were interpreted or written.

Definition at line 235 of file IndentStreambuf.hpp.

template<class Ch , class Tr = std::char_traits<Ch>>
virtual int stk::basic_indent_streambuf< Ch, Tr >::sync ( ) [inline, virtual]

Member function sync syncs the destination output stream buffer.

Returns:
an int value result of the pub sync operation.

Definition at line 309 of file IndentStreambuf.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends