ROSE  0.10.5.0
BaseSemanticsFormatter.h
1 #ifndef ROSE_BinaryAnalysis_InstructionSemantics2_BaseSemantics_Formatter_H
2 #define ROSE_BinaryAnalysis_InstructionSemantics2_BaseSemantics_Formatter_H
3 #include <rosePublicConfig.h>
4 #ifdef ROSE_BUILD_BINARY_ANALYSIS_SUPPORT
5 
6 #include <BaseSemanticsTypes.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 
24  const RegisterDictionary *get_register_dictionary() const { return regdict; }
25  void set_register_dictionary(const RegisterDictionary *rd) { regdict = rd; }
31  bool get_suppress_initial_values() const { return suppress_initial_values; }
32  void set_suppress_initial_values(bool b=true) { suppress_initial_values=b; }
38  std::string get_line_prefix() const { return line_prefix; }
39  void set_line_prefix(const std::string &s) { line_prefix = s; }
44  std::string get_indentation_suffix() const { return indentation_suffix; }
45  void set_indentation_suffix(const std::string &s) { indentation_suffix = s; }
50  bool get_show_latest_writers() const { return show_latest_writers; }
51  void set_show_latest_writers(bool b=true) { show_latest_writers = b; }
52  void clear_show_latest_writers() { show_latest_writers = false; }
57  bool get_show_properties() const { return show_properties; }
58  void set_show_properties(bool b=true) { show_properties = b; }
59  void clear_show_properties() { show_properties = false; }
62 protected:
63  const RegisterDictionary *regdict;
64  bool suppress_initial_values;
65  std::string line_prefix;
66  std::string indentation_suffix;
67  bool show_latest_writers;
68  bool show_properties;
69 };
70 
74 class Indent {
75 private:
76  Formatter &fmt;
77  std::string old_line_prefix;
78 public:
79  Indent(Formatter &fmt): fmt(fmt) {
80  old_line_prefix = fmt.get_line_prefix();
81  fmt.set_line_prefix(old_line_prefix + fmt.get_indentation_suffix());
82  }
83  ~Indent() {
84  fmt.set_line_prefix(old_line_prefix);
85  }
86 };
87 
88 } // namespace
89 } // namespace
90 } // namespace
91 } // namespace
92 
93 #endif
94 #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:38
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.