Geant4 9.6.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 * @version $Id: IndentPrintWriter.cc,v 1.14 2005-06-02 21:28:45 duns Exp $
12 */
13namespace cheprep {
14
15IndentPrintWriter::IndentPrintWriter(ostream* outstream, int level)
16 : out(outstream),
17 closed(false),
18 indentLevel(level),
19 indented(false),
20 indentString(" ") {
21}
22
24}
25
27 if (!closed) {
28 out->flush();
29 closed = true;
30 }
31}
32
34 if (!indented) doIndent();
35 *out << s;
36 return *this;
37}
38
40 *out << endl;
41 indented = false;
42 return *this;
43}
44
45void IndentPrintWriter::println(const string & s) {
46 *this << s << endl;
47}
48
49void IndentPrintWriter::print(const string & s) {
50 *this << s;
51}
52
54 *out << endl;
55 indented = false;
56}
57
58void IndentPrintWriter::doIndent() {
59 for (int i=0; i<indentLevel; i++) {
60 *out << indentString;
61 }
62 indented = true;
63}
64
66 indentLevel++;
67}
68
70 indentLevel--;
71}
72
74 return indentLevel;
75}
76
77void IndentPrintWriter::setIndent(const int level) {
78 indentLevel = level;
79}
80
82 return indentString;
83}
84
85void IndentPrintWriter::setIndentString(const string & anIndent) {
86 indentString = anIndent;
87}
88
89} // 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)