PandA-2024.02
|
Class to print indented code. More...
#include <indented_output_stream.hpp>
Public Member Functions | |
IndentedOutputStream (char o='{', char c='}', unsigned int d=3) | |
constructor More... | |
~IndentedOutputStream () | |
destructor More... | |
void | Append (const std::string &str) |
Append a string to the output. More... | |
void | AppendIndented (const std::string &str) |
Append a pre-indented string to the output. More... | |
void | Indent () |
Manually increase the indenting of the code. More... | |
void | Deindent () |
Manually reduce the indenting of the code. More... | |
const std::string | WriteString () |
Write the indented output on a string. More... | |
void | WriteFile (const std::string &file_name) |
Write the indented output on a file. More... | |
Private Member Functions | |
void | AppendIndent () |
Append the indent spaces. More... | |
void | AppendChar (const char &c) |
Append the current char. More... | |
Private Attributes | |
std::ostringstream | output_stream |
The actual stream. More... | |
unsigned int | indent_spaces |
number of spaces used to indent after a new line print More... | |
char | opening_char |
char that increments the indent space by a delta More... | |
char | closing_char |
char that increments the indent space by a delta More... | |
unsigned int | delta |
delta indent space More... | |
bool | is_line_start |
Class to print indented code.
Definition at line 63 of file indented_output_stream.hpp.
IndentedOutputStream::IndentedOutputStream | ( | char | o = '{' , |
char | c = '}' , |
||
unsigned int | d = 3 |
||
) |
constructor
o | is the opening character used by simple_indent. |
c | is the closing character used by simple_indent. |
d | is the number of characters used to indent the code. |
Definition at line 54 of file indented_output_stream.cpp.
IndentedOutputStream::~IndentedOutputStream | ( | ) |
destructor
This corresponds to a THROW_ASSERT, however it is against C++ rules throw an error inside a destructor
Definition at line 59 of file indented_output_stream.cpp.
References indent_spaces, and indentation.
void IndentedOutputStream::Append | ( | const std::string & | str | ) |
Append a string to the output.
str | is the string to be printed |
Specified whether the first character of the string we are going to write must be indented or not
Definition at line 70 of file indented_output_stream.cpp.
References AppendChar(), AppendIndent(), closing_char, Deindent(), delta, indent_spaces, is_line_start, opening_char, output_stream, STD_CLOSING_CHAR, STD_OPENING_CHAR, THROW_UNREACHABLE, and WriteFile().
Referenced by CWriter::compute_phi_nodes(), CreateAddressTranslation::ComputeAddress(), HLSInstructionWriter::declareFunction(), InstructionWriter::declareFunction(), DiscrepancyAnalysisCWriter::DeclareLocalVariables(), CWriter::DeclareType(), CWriter::DeclareVariable(), CWriter::EndFunctionBody(), CreateAddressTranslation::Exec(), CBackend::Exec(), MemoryInitializationCWriter::FinalizeFileInit(), BasicBlocksProfilingCWriter::print_edge(), MemoryInitializationCWriter::Process(), CWriter::StartFunctionBody(), InstructionWriter::write(), language_writer::write(), verilog_writer::write_assign(), verilog_writer::write_comment(), VHDL_writer::write_comment(), VHDL_writer::write_component_declaration(), verilog_writer::write_header(), VHDL_writer::write_header(), VHDL_writer::write_io_signal_post_fix(), verilog_writer::write_io_signal_post_fix(), VHDL_writer::write_io_signal_post_fix_vector(), verilog_writer::write_io_signal_post_fix_vector(), VHDL_writer::write_library_declaration(), verilog_writer::write_library_declaration(), VHDL_writer::write_module_declaration(), verilog_writer::write_module_declaration(), VHDL_writer::write_module_definition_begin(), verilog_writer::write_module_definition_begin(), VHDL_writer::write_module_definition_end(), verilog_writer::write_module_definition_end(), VHDL_writer::write_module_instance_begin(), verilog_writer::write_module_instance_begin(), VHDL_writer::write_module_instance_end(), verilog_writer::write_module_instance_end(), VHDL_writer::write_module_internal_declaration(), VHDL_writer::write_module_parametrization(), verilog_writer::write_module_parametrization(), VHDL_writer::write_module_parametrization_decl(), verilog_writer::write_module_parametrization_decl(), system_verilog_writer::write_NP_functionalities(), VHDL_writer::write_NP_functionalities(), verilog_writer::write_NP_functionalities(), VHDL_writer::write_port_binding(), verilog_writer::write_port_binding(), VHDL_writer::write_port_decl_header(), VHDL_writer::write_port_decl_tail(), VHDL_writer::write_port_declaration(), verilog_writer::write_port_declaration(), VHDL_writer::write_present_state_update(), verilog_writer::write_present_state_update(), VHDL_writer::write_signal_declaration(), verilog_writer::write_signal_declaration(), VHDL_writer::write_state_declaration(), verilog_writer::write_state_declaration(), VHDL_writer::write_transition_output_functions(), verilog_writer::write_transition_output_functions(), VHDL_writer::write_vector_port_binding(), verilog_writer::write_vector_port_binding(), DiscrepancyAnalysisCWriter::WriteBBHeader(), VHDL_writer::WriteBuiltin(), verilog_writer::WriteBuiltin(), CWriter::WriteBuiltinWaitCall(), InstructionWriter::WriteComment(), DiscrepancyAnalysisCWriter::WriteExtraCodeBeforeEveryMainCall(), DiscrepancyAnalysisCWriter::WriteExtraInitCode(), CWriter::WriteFunctionDeclaration(), DiscrepancyAnalysisCWriter::WriteGlobalDeclarations(), BasicBlocksProfilingCWriter::WriteGlobalDeclarations(), CBackend::WriteGlobalDeclarations(), CWriter::WriteGlobalDeclarations(), CWriter::WriteHashTableImplementation(), HLSCWriter::WriteHeader(), EdgeCWriter::WriteHeader(), CWriter::WriteHeader(), CWriter::writeInclude(), HLSCWriter::WriteMainTestbench(), DiscrepancyAnalysisCWriter::WriteMainTestbench(), HLSCWriter::WriteParamDecl(), HLSCWriter::WriteParamInitialization(), DiscrepancyAnalysisCWriter::writePostInstructionInfo(), DiscrepancyAnalysisCWriter::writePreInstructionInfo(), EdgeCWriter::writeRoutineInstructions(), CWriter::writeRoutineInstructions(), EdgeCWriter::writeRoutineInstructions_rec(), CWriter::writeRoutineInstructions_rec(), HLSCWriter::WriteSimulatorInitMemory(), HLSCWriter::WriteTestbenchFunctionCall(), and DiscrepancyAnalysisCWriter::WriteTestbenchHelperFunctions().
|
private |
Append the current char.
Definition at line 160 of file indented_output_stream.cpp.
References output_stream.
Referenced by Append().
|
private |
Append the indent spaces.
Definition at line 152 of file indented_output_stream.cpp.
References indent_spaces, and output_stream.
Referenced by Append().
void IndentedOutputStream::AppendIndented | ( | const std::string & | str | ) |
Append a pre-indented string to the output.
str | is the string to be printed |
Definition at line 147 of file indented_output_stream.cpp.
References output_stream, and str.
Referenced by HLSCWriter::WriteMainTestbench().
void IndentedOutputStream::Deindent | ( | ) |
Manually reduce the indenting of the code.
Definition at line 170 of file indented_output_stream.cpp.
References delta, indent_spaces, and THROW_ASSERT.
Referenced by Append(), VHDL_writer::write_component_declaration(), verilog_writer::write_module_declaration(), VHDL_writer::write_module_definition_begin(), VHDL_writer::write_module_definition_end(), verilog_writer::write_module_definition_end(), VHDL_writer::write_module_instance_end(), verilog_writer::write_module_instance_end(), VHDL_writer::write_module_parametrization(), verilog_writer::write_module_parametrization(), verilog_writer::write_module_parametrization_decl(), VHDL_writer::write_port_decl_tail(), VHDL_writer::write_present_state_update(), verilog_writer::write_present_state_update(), verilog_writer::write_state_declaration(), VHDL_writer::write_transition_output_functions(), VHDL_writer::write_vector_port_binding(), and verilog_writer::write_vector_port_binding().
void IndentedOutputStream::Indent | ( | ) |
Manually increase the indenting of the code.
Definition at line 165 of file indented_output_stream.cpp.
References delta, and indent_spaces.
Referenced by VHDL_writer::write_component_declaration(), verilog_writer::write_module_declaration(), VHDL_writer::write_module_definition_begin(), VHDL_writer::write_module_instance_begin(), verilog_writer::write_module_instance_begin(), VHDL_writer::write_module_internal_declaration(), VHDL_writer::write_module_parametrization(), verilog_writer::write_module_parametrization(), verilog_writer::write_module_parametrization_decl(), VHDL_writer::write_port_decl_header(), VHDL_writer::write_present_state_update(), verilog_writer::write_present_state_update(), verilog_writer::write_state_declaration(), VHDL_writer::write_transition_output_functions(), VHDL_writer::write_vector_port_binding(), and verilog_writer::write_vector_port_binding().
void IndentedOutputStream::WriteFile | ( | const std::string & | file_name | ) |
Write the indented output on a file.
file_name | is the name of the file |
Definition at line 183 of file indented_output_stream.cpp.
References output_stream.
Referenced by Append(), CreateAddressTranslation::Exec(), HLSCWriter::WriteFile(), language_writer::WriteFile(), and CWriter::WriteFile().
const std::string IndentedOutputStream::WriteString | ( | ) |
Write the indented output on a string.
Definition at line 176 of file indented_output_stream.cpp.
References output_stream.
Referenced by language_writer::WriteString().
|
private |
char that increments the indent space by a delta
Definition at line 76 of file indented_output_stream.hpp.
Referenced by Append().
|
private |
delta indent space
Definition at line 79 of file indented_output_stream.hpp.
Referenced by Append(), Deindent(), and Indent().
|
private |
number of spaces used to indent after a new line print
Definition at line 70 of file indented_output_stream.hpp.
Referenced by Append(), AppendIndent(), Deindent(), Indent(), and ~IndentedOutputStream().
|
private |
Definition at line 81 of file indented_output_stream.hpp.
Referenced by Append().
|
private |
char that increments the indent space by a delta
Definition at line 73 of file indented_output_stream.hpp.
Referenced by Append().
|
private |
The actual stream.
Definition at line 67 of file indented_output_stream.hpp.
Referenced by Append(), AppendChar(), AppendIndent(), AppendIndented(), WriteFile(), and WriteString().