Geant4 10.7.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
IndentPrintWriter.cc
Go to the documentation of this file.
1// Copyright FreeHEP, 2005.
2
3#include <fstream>
4
6
7using namespace std;
8
9/**
10 * @author Mark Donszelmann
11 */
12namespace cheprep {
13
14IndentPrintWriter::IndentPrintWriter(ostream* outstream, int level)
15 : out(outstream),
16 closed(false),
17 indentLevel(level),
18 indented(false),
19 indentString(" ") {
20}
21
23}
24
26 if (!closed) {
27 out->flush();
28 closed = true;
29 }
30}
31
33 if (!indented) doIndent();
34 *out << s;
35 return *this;
36}
37
39 *out << endl;
40 indented = false;
41 return *this;
42}
43
44void IndentPrintWriter::println(const string & s) {
45 *this << s << endl;
46}
47
48void IndentPrintWriter::print(const string & s) {
49 *this << s;
50}
51
53 *out << endl;
54 indented = false;
55}
56
57void IndentPrintWriter::doIndent() {
58 for (int i=0; i<indentLevel; i++) {
59 *out << indentString;
60 }
61 indented = true;
62}
63
65 indentLevel++;
66}
67
69 indentLevel--;
70}
71
73 return indentLevel;
74}
75
76void IndentPrintWriter::setIndent(const int level) {
77 indentLevel = level;
78}
79
81 return indentString;
82}
83
84void IndentPrintWriter::setIndentString(const string & anIndent) {
85 indentString = anIndent;
86}
87
88} // cheprep
void setIndent(const int level)
IndentPrintWriter & operator<<(const std::string &s)
void print(const std::string &s)
std::string getIndentString() const
IndentPrintWriter(std::ostream *out, int level=0)
void setIndentString(const std::string &indentString)