about summary refs log tree commit diff
path: root/src/libnix/aterm.hh
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-11-16T18·31+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-11-16T18·31+0000
commit45610ae675f6f8d6ecbd48c495cb7012b143d531 (patch)
tree02728674874e94ff89148ae44111be11733f293c /src/libnix/aterm.hh
parent3e5a019a070cbaac7d1248e208c66da9fdb23313 (diff)
* An forward non-random access input iterator class for ATermLists.
Diffstat (limited to 'src/libnix/aterm.hh')
-rw-r--r--src/libnix/aterm.hh22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/libnix/aterm.hh b/src/libnix/aterm.hh
index 1e4ee80eeab5..16d8d6bb6dfd 100644
--- a/src/libnix/aterm.hh
+++ b/src/libnix/aterm.hh
@@ -14,6 +14,28 @@ string atPrint(ATerm t);
 /* Write an ATerm to an output stream. */
 ostream & operator << (ostream & stream, ATerm e);
 
+class ATermIterator
+{
+    ATermList t;
+
+public:
+    ATermIterator(ATermList _t) : t(_t) { }
+    ATermIterator & operator ++ ()
+    {
+        t = ATgetNext(t);
+        return *this;
+    }
+    ATerm operator * ()
+    {
+        return ATgetFirst(t);
+    }
+    operator bool ()
+    {
+        return t != ATempty;
+    }
+};
+
+
 /* Type-safe matching. */
 
 struct ATMatcher