Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
IndentPrintWriter.h
Go to the documentation of this file.
1 // Copyright FreeHEP, 2005.
2 #ifndef CHEPREP_INDENTPRINTWRITER_H
3 #define CHEPREP_INDENTPRINTWRITER_H 1
4 
5 #include "cheprep/config.h"
6 
7 #include <iostream>
8 #include <string>
9 
10 /**
11  * A PrintWriter that keeps track of an indentation level
12  * and indents the output appropriately.
13  *
14  * <b>Warning:</b> Only print and println methods taking strings have been overriden,
15  * print, println methods taking other arguments may not be indented properly.
16  *
17  * @author Mark Donszelmann
18  * @version $Id: IndentPrintWriter.h 66373 2012-12-18 09:41:34Z gcosmo $
19  */
20 namespace cheprep {
21 
23 
24  public:
25  IndentPrintWriter(std::ostream* out, int level = 0);
26  virtual ~IndentPrintWriter();
27 
28  void close();
29  IndentPrintWriter& operator<< (const std::string & s);
30  IndentPrintWriter& operator<< (std::ostream& (*pf)(std::ostream&));
31  void println(const std::string & s);
32  void print(const std::string & s);
33  void println();
34  void indent();
35  void outdent();
36  int getIndent() const;
37  void setIndent(const int level);
38  std::string getIndentString() const;
39  void setIndentString(const std::string & indentString);
40 
41  private:
42  void doIndent();
43 
44  std::ostream* out;
45  bool closed;
46  int indentLevel;
47  bool indented;
48  std::string indentString;
49 };
50 
51 } // cheprep
52 
53 
54 #endif
55 
const XML_Char * s
std::string getIndentString() const
IndentPrintWriter(std::ostream *out, int level=0)
void setIndentString(const std::string &indentString)
void setIndent(const int level)
IndentPrintWriter & operator<<(const std::string &s)
void print(const std::string &s)