cprover
Loading...
Searching...
No Matches
printf_formatter.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module: printf Formatting
4
5Author: 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{
21public:
22 void operator()(
23 const std::string &format,
24 const std::list<exprt> &_operands);
25
26 void print(std::ostream &out);
27 std::string as_string();
28
29 explicit printf_formattert(const namespacet &_ns):
30 ns(_ns),
31 format_pos(0)
32 {
33 }
34
35protected:
36 const namespacet &ns;
37 std::string format;
38 std::list<exprt> operands;
39 std::list<exprt>::const_iterator next_operand;
40 unsigned format_pos;
41 bool eol() const { return format_pos>=format.size(); }
42
43 class eol_exceptiont { };
44
45 char next()
46 {
47 if(eol())
48 throw eol_exceptiont();
49 return format[format_pos++];
50 }
51
52 void process_char(std::ostream &out);
53 void process_format(std::ostream &out);
54
55 const exprt make_type(const exprt &src, const typet &dest);
56};
57
58#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:91
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