CBMC
Loading...
Searching...
No Matches
format.h
Go to the documentation of this file.
1/*******************************************************************\
2
3Module:
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
9#ifndef CPROVER_UTIL_FORMAT_H
10#define CPROVER_UTIL_FORMAT_H
11
12#include <iosfwd>
13#include <sstream>
14#include <string>
15
18template <typename T>
20{
21public:
22 explicit format_containert(const T &_o) : o(_o)
23 {
24 }
25
26 const T &o;
27};
28
29template <typename T>
30static inline std::ostream &
31operator<<(std::ostream &os, const format_containert<T> &f)
32{
33 return format_rec(os, f.o);
34}
35
36template <typename T>
37static inline format_containert<T> format(const T &o)
38{
39 return format_containert<T>(o);
40}
41
42template <typename T>
43std::string format_to_string(const T &o)
44{
45 std::ostringstream oss;
46 oss << format(o);
47 return oss.str();
48}
49
50#endif // CPROVER_UTIL_FORMAT_H
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
The below enables convenient syntax for feeding objects into streams, via stream << format(o)
Definition format.h:20
format_containert(const T &_o)
Definition format.h:22
const T & o
Definition format.h:26
static format_containert< T > format(const T &o)
Definition format.h:37
std::string format_to_string(const T &o)
Definition format.h:43
static std::ostream & operator<<(std::ostream &os, const format_containert< T > &f)
Definition format.h:31
static std::ostream & format_rec(std::ostream &os, const multi_ary_exprt &src)
This formats a multi-ary expression, adding parentheses where indicated by bracket_subexpression.