Last change
on this file since 1139 was
834,
checked in by garnier, 16 years ago
|
import all except CVS
|
-
Property svn:executable set to
*
|
File size:
1.4 KB
|
Rev | Line | |
---|
[834] | 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,v 1.3 2005/06/02 21:28:45 duns Exp $ |
---|
| 19 | */ |
---|
| 20 | namespace cheprep { |
---|
| 21 | |
---|
| 22 | class IndentPrintWriter { |
---|
| 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 | |
---|
Note: See
TracBrowser
for help on using the repository browser.