ROSE  0.11.51.0
Formatter.h
1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics2_BaseSemantics_Formatter_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics2_BaseSemantics_Formatter_H
3 #include <featureTests.h>
4 #ifdef ROSE_ENABLE_BINARY_ANALYSIS
5 
6 #include <Rose/BinaryAnalysis/InstructionSemantics2/BaseSemantics/Types.h>
7 
8 namespace Rose {
9 namespace BinaryAnalysis {
10 namespace InstructionSemantics2 {
11 namespace BaseSemantics {
12 
16 class Formatter {
17 public:
18  Formatter(): regdict(NULL), suppress_initial_values(false), indentation_suffix(" "), show_latest_writers(true),
19  show_properties(true) {}
20  virtual ~Formatter() {}
21 
28  return regdict;
29  }
31  regdict = rd;
32  }
35  // [Robb Matzke 2021-03-18]: deprecated
36  const RegisterDictionary *get_register_dictionary() const ROSE_DEPRECATED("use registerDictionary property") {
37  return registerDictionary();
38  }
39 
40  // [Robb Matzke 2021-03-18]: deprecated
41  void set_register_dictionary(const RegisterDictionary *rd) ROSE_DEPRECATED("use registerDictionary property") {
43  }
44 
48  bool get_suppress_initial_values() const { return suppress_initial_values; }
49  void set_suppress_initial_values(bool b=true) { suppress_initial_values=b; }
55  std::string get_line_prefix() const { return line_prefix; }
56  void set_line_prefix(const std::string &s) { line_prefix = s; }
61  std::string get_indentation_suffix() const { return indentation_suffix; }
62  void set_indentation_suffix(const std::string &s) { indentation_suffix = s; }
67  bool get_show_latest_writers() const { return show_latest_writers; }
68  void set_show_latest_writers(bool b=true) { show_latest_writers = b; }
69  void clear_show_latest_writers() { show_latest_writers = false; }
74  bool get_show_properties() const { return show_properties; }
75  void set_show_properties(bool b=true) { show_properties = b; }
76  void clear_show_properties() { show_properties = false; }
79 protected:
80  const RegisterDictionary *regdict;
81  bool suppress_initial_values;
82  std::string line_prefix;
83  std::string indentation_suffix;
84  bool show_latest_writers;
85  bool show_properties;
86 };
87 
91 class Indent {
92 private:
93  Formatter &fmt;
94  std::string old_line_prefix;
95 public:
96  Indent(Formatter &fmt): fmt(fmt) {
97  old_line_prefix = fmt.get_line_prefix();
98  fmt.set_line_prefix(old_line_prefix + fmt.get_indentation_suffix());
99  }
100  ~Indent() {
101  fmt.set_line_prefix(old_line_prefix);
102  }
103 };
104 
105 } // namespace
106 } // namespace
107 } // namespace
108 } // namespace
109 
110 #endif
111 #endif
void clear_show_latest_writers()
Whether to show latest writer information for register and memory states.
Definition: Formatter.h:69
void set_line_prefix(const std::string &s)
The string to print at the start of each line.
Definition: Formatter.h:56
void clear_suppress_initial_values()
Whether register initial values should be suppressed.
Definition: Formatter.h:50
bool get_suppress_initial_values() const
Whether register initial values should be suppressed.
Definition: Formatter.h:48
std::string get_indentation_suffix() const
Indentation string appended to the line prefix for multi-level, multi-line outputs.
Definition: Formatter.h:61
const RegisterDictionary * registerDictionary() const
Property: Register dictionary.
Definition: Formatter.h:27
Main namespace for the ROSE library.
void set_suppress_initial_values(bool b=true)
Whether register initial values should be suppressed.
Definition: Formatter.h:49
void set_show_latest_writers(bool b=true)
Whether to show latest writer information for register and memory states.
Definition: Formatter.h:68
void registerDictionary(const RegisterDictionary *rd)
Property: Register dictionary.
Definition: Formatter.h:30
bool get_show_latest_writers() const
Whether to show latest writer information for register and memory states.
Definition: Formatter.h:67
Base classes for instruction semantics.
Definition: Dispatcher.h:18
void clear_show_properties()
Whether to show register properties.
Definition: Formatter.h:76
void set_show_properties(bool b=true)
Whether to show register properties.
Definition: Formatter.h:75
std::string get_line_prefix() const
The string to print at the start of each line.
Definition: Formatter.h:55
bool get_show_properties() const
Whether to show register properties.
Definition: Formatter.h:74
Defines registers available for a particular architecture.
Definition: Registers.h:37
void set_indentation_suffix(const std::string &s)
Indentation string appended to the line prefix for multi-level, multi-line outputs.
Definition: Formatter.h:62
Adjusts a Formatter for one additional level of indentation.
Definition: Formatter.h:91