cprover
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_ANSI_C_PRINTF_FORMATTER_H
13 #define CPROVER_ANSI_C_PRINTF_FORMATTER_H
14 
15 #include <util/expr.h>
16 #include <util/namespace.h>
17 
19 {
20 public:
21  void operator()(
22  const std::string &format,
23  const std::list<exprt> &_operands);
24 
25  void print(std::ostream &out);
26  std::string as_string();
27 
28  explicit printf_formattert(const namespacet &_ns):ns(_ns)
29  {
30  }
31 
32 protected:
33  const namespacet &ns;
34  std::string format;
35  std::list<exprt> operands;
36  std::list<exprt>::const_iterator next_operand;
37  unsigned format_pos;
38  bool eol() const { return format_pos>=format.size(); }
39 
40  class eol_exceptiont { };
41 
42  char next()
43  {
44  if(eol())
45  throw eol_exceptiont();
46  return format[format_pos++];
47  }
48 
49  void process_char(std::ostream &out);
50  void process_format(std::ostream &out);
51 
52  const exprt make_type(const exprt &src, const typet &dest);
53 };
54 
55 #endif // CPROVER_ANSI_C_PRINTF_FORMATTER_H
The type of an expression.
Definition: type.h:20
void process_char(std::ostream &out)
std::list< exprt >::const_iterator next_operand
printf_formattert(const namespacet &_ns)
std::list< exprt > operands
TO_BE_DOCUMENTED.
Definition: namespace.h:62
const namespacet & ns
Base class for all expressions.
Definition: expr.h:46
void process_format(std::ostream &out)
void print(std::ostream &out)
void operator()(const std::string &format, const std::list< exprt > &_operands)
std::string as_string()
const exprt make_type(const exprt &src, const typet &dest)