1 : #ifndef __ATERM_H
2 : #define __ATERM_H
3 :
4 : #include <aterm2.h>
5 :
6 : #include "types.hh"
7 :
8 :
9 : namespace nix {
10 :
11 :
12 : /* Print an ATerm. */
13 : string atPrint(ATerm t);
14 :
15 : class ATermIterator
16 : {
17 : ATermList t;
18 :
19 : public:
20 35843 : ATermIterator(ATermList _t) : t(_t) { }
21 51991 : ATermIterator & operator ++ ()
22 : {
23 51991 : t = ATgetNext(t);
24 51991 : return *this;
25 : }
26 57762 : ATerm operator * ()
27 : {
28 57762 : return ATgetFirst(t);
29 : }
30 87834 : operator bool ()
31 : {
32 87834 : return t != ATempty;
33 : }
34 : };
35 :
36 :
37 : /* Throw an exception with an error message containing the given
38 : aterm. */
39 : Error badTerm(const format & f, ATerm t);
40 :
41 :
42 : /* Convert strings to ATerms. */
43 : ATerm toATerm(const char * s);
44 : ATerm toATerm(const string & s);
45 :
46 : ATermList toATermList(const StringSet & ss);
47 :
48 : }
49 :
50 :
51 : /* Write an ATerm to an output stream. */
52 : std::ostream & operator << (std::ostream & stream, ATerm e);
53 :
54 :
55 : #endif /* !__ATERM_H */
|