ROSE  0.9.12.28
BaseSemanticsFormatter.h
1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics2_BaseSemantics_Formatter_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics2_BaseSemantics_Formatter_H
3 
4 #include <BaseSemanticsTypes.h>
5 
6 namespace Rose {
7 namespace BinaryAnalysis {
8 namespace InstructionSemantics2 {
9 namespace BaseSemantics {
10 
14 class Formatter {
15 public:
16  Formatter(): regdict(NULL), suppress_initial_values(false), indentation_suffix(" "), show_latest_writers(true),
17  show_properties(true) {}
18  virtual ~Formatter() {}
19 
22  const RegisterDictionary *get_register_dictionary() const { return regdict; }
23  void set_register_dictionary(const RegisterDictionary *rd) { regdict = rd; }
29  bool get_suppress_initial_values() const { return suppress_initial_values; }
30  void set_suppress_initial_values(bool b=true) { suppress_initial_values=b; }
36  std::string get_line_prefix() const { return line_prefix; }
37  void set_line_prefix(const std::string &s) { line_prefix = s; }
42  std::string get_indentation_suffix() const { return indentation_suffix; }
43  void set_indentation_suffix(const std::string &s) { indentation_suffix = s; }
48  bool get_show_latest_writers() const { return show_latest_writers; }
49  void set_show_latest_writers(bool b=true) { show_latest_writers = b; }
50  void clear_show_latest_writers() { show_latest_writers = false; }
55  bool get_show_properties() const { return show_properties; }
56  void set_show_properties(bool b=true) { show_properties = b; }
57  void clear_show_properties() { show_properties = false; }
60 protected:
61  const RegisterDictionary *regdict;
62  bool suppress_initial_values;
63  std::string line_prefix;
64  std::string indentation_suffix;
65  bool show_latest_writers;
66  bool show_properties;
67 };
68 
72 class Indent {
73 private:
74  Formatter &fmt;
75  std::string old_line_prefix;
76 public:
77  Indent(Formatter &fmt): fmt(fmt) {
78  old_line_prefix = fmt.get_line_prefix();
79  fmt.set_line_prefix(old_line_prefix + fmt.get_indentation_suffix());
80  }
81  ~Indent() {
82  fmt.set_line_prefix(old_line_prefix);
83  }
84 };
85 
86 } // namespace
87 } // namespace
88 } // namespace
89 } // namespace
90 
91 #endif
void clear_show_latest_writers()
Whether to show latest writer information for register and memory states.
void set_line_prefix(const std::string &s)
The string to print at the start of each line.
void clear_suppress_initial_values()
Whether register initial values should be suppressed.
bool get_suppress_initial_values() const
Whether register initial values should be suppressed.
std::string get_indentation_suffix() const
Indentation string appended to the line prefix for multi-level, multi-line outputs.
Main namespace for the ROSE library.
void set_suppress_initial_values(bool b=true)
Whether register initial values should be suppressed.
void set_show_latest_writers(bool b=true)
Whether to show latest writer information for register and memory states.
bool get_show_latest_writers() const
Whether to show latest writer information for register and memory states.
const RegisterDictionary * get_register_dictionary() const
The register dictionary which is used for printing register names.
void set_show_properties(bool b=true)
Whether to show register properties.
std::string get_line_prefix() const
The string to print at the start of each line.
bool get_show_properties() const
Whether to show register properties.
Defines registers available for a particular architecture.
Definition: Registers.h:35
void set_indentation_suffix(const std::string &s)
Indentation string appended to the line prefix for multi-level, multi-line outputs.
void set_register_dictionary(const RegisterDictionary *rd)
The register dictionary which is used for printing register names.
Adjusts a Formatter for one additional level of indentation.