mCRL2
Loading...
Searching...
No Matches
print_format.h
Go to the documentation of this file.
1// Author(s): Wieger Wesselink
2// Copyright: see the accompanying file COPYING or copy at
3// https://github.com/mCRL2org/mCRL2/blob/master/COPYING
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// http://www.boost.org/LICENSE_1_0.txt)
8//
11
12#ifndef MCRL2_CORE_PRINT_FORMAT_H
13#define MCRL2_CORE_PRINT_FORMAT_H
14
16#include <string>
17
18namespace mcrl2 {
19
20namespace core {
21
24
30inline
31std::string pp_format_to_string(const print_format_type pp_format)
32{
33 switch (pp_format)
34 {
35 case print_default:
36 return "default";
37 case print_internal:
38 return "internal";
39 default:
40 throw mcrl2::runtime_error("Unknown pretty print format");
41 }
42}
43
44inline
45std::ostream& operator<<(std::ostream& os, const print_format_type& pp_format)
46{
47 os << pp_format_to_string(pp_format);
48 return os;
49}
50
51inline
53{
54 if(s == "default")
55 {
56 return print_default;
57 }
58 else if(s == "internal")
59 {
60 return print_internal;
61 }
62 else
63 {
64 throw mcrl2::runtime_error("Unknown pretty print format " + s);
65 }
66}
67
68inline
69std::istream& operator>>(std::istream& is, print_format_type& f)
70{
71 try
72 {
73 std::string s;
74 is >> s;
75 f = parse_pp_format(s);
76 }
78 {
79 is.setstate(std::ios_base::failbit);
80 }
81 return is;
82}
83
84} // namespace core
85
86} // namespace mcrl2
87
88#endif // MCRL2_CORE_PRINT_FORMAT_H
Standard exception class for reporting runtime errors.
Definition exception.h:27
Exception classes for use in libraries and tools.
print_format_type
print_format_type represents the available pretty print formats
std::string pp_format_to_string(const print_format_type pp_format)
Print string representation of pretty print format.
std::istream & operator>>(std::istream &is, print_format_type &f)
std::ostream & operator<<(std::ostream &out, const identifier_string &x)
print_format_type parse_pp_format(const std::string &s)
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72