mCRL2
Loading...
Searching...
No Matches
load_aterm.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_LOAD_ATERM_H
13#define MCRL2_CORE_LOAD_ATERM_H
14
17
18namespace mcrl2 {
19
20namespace core {
21
22namespace detail {
23
24inline
25std::string file_source(const std::string& filename)
26{
27 if (filename.empty() || filename == "-")
28 {
29 return "standard input";
30 }
31 return filename;
32}
33
34} // namespace detail
35
43inline
44atermpp::aterm load_aterm(std::istream& stream,
45 bool binary = true,
46 const std::string& format = "aterm",
47 const std::string& source = "",
49{
50 atermpp::aterm result;
51 try
52 {
53 if (binary)
54 {
55 atermpp::binary_aterm_istream(stream) >> transformer >> result;
56 }
57 else
58 {
59 atermpp::text_aterm_istream(stream) >> transformer >> result;
60 }
61 }
62 catch (std::exception &e)
63 {
64 if (source.empty())
65 {
66 throw mcrl2::runtime_error("Failed to read a valid " + format + " from the input.\n" + e.what());
67 }
68 else
69 {
70 throw mcrl2::runtime_error("Failed to read a valid " + format + " from the input " + source + ".\n" + e.what());
71 }
72 }
73 return result;
74}
75
76} // namespace core
77
78} // namespace mcrl2
79
80#endif // MCRL2_CORE_LOAD_ATERM_H
Reads terms from a stream in the steamable binary aterm format.
Reads terms in textual format from an input stream.
Standard exception class for reporting runtime errors.
Definition exception.h:27
aterm identity(const aterm &x)
The default transformer that maps each term to itself.
Definition aterm_io.h:26
aterm(const aterm &) aterm_transformer
A function that is applied to all terms. The resulting term should only use a subset of the original ...
Definition aterm_io.h:23
std::string file_source(const std::string &filename)
Definition load_aterm.h:25
atermpp::aterm load_aterm(std::istream &stream, bool binary=true, const std::string &format="aterm", const std::string &source="", atermpp::aterm_transformer transformer=atermpp::identity)
Attempts to read an aterm from a stream.
Definition load_aterm.h:44
A class that takes a linear process specification and checks all tau-summands of that LPS for conflue...
Definition indexed_set.h:72