PandA-2024.02
indented_output_stream.hpp
Go to the documentation of this file.
1 /*
2  *
3  * _/_/_/ _/_/ _/ _/ _/_/_/ _/_/
4  * _/ _/ _/ _/ _/_/ _/ _/ _/ _/ _/
5  * _/_/_/ _/_/_/_/ _/ _/_/ _/ _/ _/_/_/_/
6  * _/ _/ _/ _/ _/ _/ _/ _/ _/
7  * _/ _/ _/ _/ _/ _/_/_/ _/ _/
8  *
9  * ***********************************************
10  * PandA Project
11  * URL: http://panda.dei.polimi.it
12  * Politecnico di Milano - DEIB
13  * System Architectures Group
14  * ***********************************************
15  * Copyright (C) 2004-2024 Politecnico di Milano
16  *
17  * This file is part of the PandA framework.
18  *
19  * The PandA framework is free software; you can redistribute it and/or modify
20  * it under the terms of the GNU General Public License as published by
21  * the Free Software Foundation; either version 3 of the License, or
22  * (at your option) any later version.
23  *
24  * This program is distributed in the hope that it will be useful,
25  * but WITHOUT ANY WARRANTY; without even the implied warranty of
26  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
27  * GNU General Public License for more details.
28  *
29  * You should have received a copy of the GNU General Public License
30  * along with this program. If not, see <http://www.gnu.org/licenses/>.
31  *
32  */
43 #ifndef INDENTED_OUTPUT_STREAM_HPP
44 #define INDENTED_OUTPUT_STREAM_HPP
45 
47 #include <sstream>
48 #include <string>
49 
51 #include "refcount.hpp"
52 
55 #define STD_OPENING_CHAR (static_cast<char>(1))
56 #define STD_CLOSING_CHAR (static_cast<char>(2))
59 
64 {
65  private:
67  std::ostringstream output_stream;
68 
70  unsigned int indent_spaces;
71 
74 
77 
79  unsigned int delta;
80 
82 
86  void AppendIndent();
87 
91  void AppendChar(const char& c);
92 
93  public:
100  IndentedOutputStream(char o = '{', char c = '}', unsigned int d = 3);
101 
106 
111  void Append(const std::string& str);
112 
117  void AppendIndented(const std::string& str);
118 
122  void Indent();
123 
127  void Deindent();
128 
132  const std::string WriteString();
133 
138  void WriteFile(const std::string& file_name);
139 };
141 #endif
void WriteFile(const std::string &file_name)
Write the indented output on a file.
void AppendIndent()
Append the indent spaces.
unsigned int delta
delta indent space
IndentedOutputStream(char o='{', char c='}', unsigned int d=3)
constructor
void AppendIndented(const std::string &str)
Append a pre-indented string to the output.
void Indent()
Manually increase the indenting of the code.
char closing_char
char that increments the indent space by a delta
const std::string WriteString()
Write the indented output on a string.
void Append(const std::string &str)
Append a string to the output.
char opening_char
char that increments the indent space by a delta
unsigned int indent_spaces
number of spaces used to indent after a new line print
std::ostringstream output_stream
The actual stream.
Template definition of refcount.
char str[25]
Definition: fixedptc.c:8
void AppendChar(const char &c)
Append the current char.
void Deindent()
Manually reduce the indenting of the code.
Class to print indented code.

Generated on Mon Feb 12 2024 13:02:56 for PandA-2024.02 by doxygen 1.8.13