CBMC
printf_formatter.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: printf Formatting
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
11 
12 #ifndef CPROVER_GOTO_PROGRAMS_PRINTF_FORMATTER_H
13 #define CPROVER_GOTO_PROGRAMS_PRINTF_FORMATTER_H
14 
15 #include <util/expr.h>
16 
17 #include <list>
18 
20 {
21 public:
22  void operator()(const std::string &format, const std::list<exprt> &_operands);
23 
24  void print(std::ostream &out);
25  std::string as_string();
26 
27  explicit printf_formattert(const namespacet &_ns) : ns(_ns), format_pos(0)
28  {
29  }
30 
31 protected:
32  const namespacet &ns;
33  std::string format;
34  std::list<exprt> operands;
35  std::list<exprt>::const_iterator next_operand;
36  unsigned format_pos;
37  bool eol() const
38  {
39  return format_pos >= format.size();
40  }
41 
43  {
44  };
45 
46  char next()
47  {
48  if(eol())
49  throw eol_exceptiont();
50  return format[format_pos++];
51  }
52 
53  void process_char(std::ostream &out);
54  void process_format(std::ostream &out);
55 
56  const exprt make_type(const exprt &src, const typet &dest);
57 };
58 
59 #endif // CPROVER_GOTO_PROGRAMS_PRINTF_FORMATTER_H
Base class for all expressions.
Definition: expr.h:56
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
std::list< exprt > operands
const exprt make_type(const exprt &src, const typet &dest)
std::list< exprt >::const_iterator next_operand
std::string as_string()
void operator()(const std::string &format, const std::list< exprt > &_operands)
void process_format(std::ostream &out)
printf_formattert(const namespacet &_ns)
void print(std::ostream &out)
const namespacet & ns
void process_char(std::ostream &out)
The type of an expression, extends irept.
Definition: type.h:29