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 12886 : ATermIterator(ATermList _t) : t(_t) { }
21 : ATermIterator & operator ++ ()
22 15551 : {
23 15551 : t = ATgetNext(t);
24 15551 : return *this;
25 : }
26 : ATerm operator * ()
27 17614 : {
28 17614 : return ATgetFirst(t);
29 : }
30 : operator bool ()
31 21994 : {
32 21994 : 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 :
47 : }
48 :
49 :
50 : /* Write an ATerm to an output stream. */
51 : std::ostream & operator << (std::ostream & stream, ATerm e);
52 :
53 :
54 : #endif /* !__ATERM_H */
|