Geant4  10.02.p03
cheprep::IndentPrintWriter Class Reference

#include <IndentPrintWriter.h>

Collaboration diagram for cheprep::IndentPrintWriter:

Public Member Functions

 IndentPrintWriter (std::ostream *out, int level=0)
 
virtual ~IndentPrintWriter ()
 
void close ()
 
IndentPrintWriteroperator<< (const std::string &s)
 
IndentPrintWriteroperator<< (std::ostream &(*pf)(std::ostream &))
 
void println (const std::string &s)
 
void print (const std::string &s)
 
void println ()
 
void indent ()
 
void outdent ()
 
int getIndent () const
 
void setIndent (const int level)
 
std::string getIndentString () const
 
void setIndentString (const std::string &indentString)
 

Private Member Functions

void doIndent ()
 

Private Attributes

std::ostream * out
 
bool closed
 
int indentLevel
 
bool indented
 
std::string indentString
 

Detailed Description

Definition at line 22 of file IndentPrintWriter.h.

Constructor & Destructor Documentation

◆ IndentPrintWriter()

cheprep::IndentPrintWriter::IndentPrintWriter ( std::ostream *  out,
int  level = 0 
)

Definition at line 15 of file IndentPrintWriter.cc.

16  : out(outstream),
17  closed(false),
18  indentLevel(level),
19  indented(false),
20  indentString(" ") {
21 }

◆ ~IndentPrintWriter()

cheprep::IndentPrintWriter::~IndentPrintWriter ( )
virtual

Definition at line 23 of file IndentPrintWriter.cc.

23  {
24 }

Member Function Documentation

◆ close()

void cheprep::IndentPrintWriter::close ( )

Definition at line 26 of file IndentPrintWriter.cc.

26  {
27  if (!closed) {
28  out->flush();
29  closed = true;
30  }
31 }
Here is the caller graph for this function:

◆ doIndent()

void cheprep::IndentPrintWriter::doIndent ( )
private

Definition at line 58 of file IndentPrintWriter.cc.

58  {
59  for (int i=0; i<indentLevel; i++) {
60  *out << indentString;
61  }
62  indented = true;
63 }
Here is the caller graph for this function:

◆ getIndent()

int cheprep::IndentPrintWriter::getIndent ( ) const

Definition at line 73 of file IndentPrintWriter.cc.

73  {
74  return indentLevel;
75 }
Here is the caller graph for this function:

◆ getIndentString()

string cheprep::IndentPrintWriter::getIndentString ( ) const

Definition at line 81 of file IndentPrintWriter.cc.

81  {
82  return indentString;
83 }
Here is the caller graph for this function:

◆ indent()

void cheprep::IndentPrintWriter::indent ( )

Definition at line 65 of file IndentPrintWriter.cc.

65  {
66  indentLevel++;
67 }
Here is the caller graph for this function:

◆ operator<<() [1/2]

IndentPrintWriter & cheprep::IndentPrintWriter::operator<< ( const std::string &  s)

Definition at line 33 of file IndentPrintWriter.cc.

33  {
34  if (!indented) doIndent();
35  *out << s;
36  return *this;
37 }
static const double s
Definition: G4SIunits.hh:168
Here is the call graph for this function:

◆ operator<<() [2/2]

IndentPrintWriter& cheprep::IndentPrintWriter::operator<< ( std::ostream &(*)(std::ostream &)  pf)

◆ outdent()

void cheprep::IndentPrintWriter::outdent ( )

Definition at line 69 of file IndentPrintWriter.cc.

69  {
70  indentLevel--;
71 }
Here is the caller graph for this function:

◆ print()

void cheprep::IndentPrintWriter::print ( const std::string &  s)

Definition at line 49 of file IndentPrintWriter.cc.

49  {
50  *this << s;
51 }
static const double s
Definition: G4SIunits.hh:168

◆ println() [1/2]

void cheprep::IndentPrintWriter::println ( const std::string &  s)

Definition at line 45 of file IndentPrintWriter.cc.

45  {
46  *this << s << endl;
47 }
static const double s
Definition: G4SIunits.hh:168

◆ println() [2/2]

void cheprep::IndentPrintWriter::println ( )

Definition at line 53 of file IndentPrintWriter.cc.

53  {
54  *out << endl;
55  indented = false;
56 }

◆ setIndent()

void cheprep::IndentPrintWriter::setIndent ( const int  level)

Definition at line 77 of file IndentPrintWriter.cc.

77  {
78  indentLevel = level;
79 }

◆ setIndentString()

void cheprep::IndentPrintWriter::setIndentString ( const std::string &  indentString)

Definition at line 85 of file IndentPrintWriter.cc.

85  {
86  indentString = anIndent;
87 }
Here is the caller graph for this function:

Member Data Documentation

◆ closed

bool cheprep::IndentPrintWriter::closed
private

Definition at line 45 of file IndentPrintWriter.h.

◆ indented

bool cheprep::IndentPrintWriter::indented
private

Definition at line 47 of file IndentPrintWriter.h.

◆ indentLevel

int cheprep::IndentPrintWriter::indentLevel
private

Definition at line 46 of file IndentPrintWriter.h.

◆ indentString

std::string cheprep::IndentPrintWriter::indentString
private

Definition at line 48 of file IndentPrintWriter.h.

◆ out

std::ostream* cheprep::IndentPrintWriter::out
private

Definition at line 44 of file IndentPrintWriter.h.


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