]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/io/server/src/tagged_parameter.h
update
[l4.git] / l4 / pkg / io / server / src / tagged_parameter.h
1 #pragma once
2
3 #include "expression.h"
4
5 class Tagged_parameter
6 {
7 public:
8   Expression *get(char const *tag)
9   {
10     for (Tagged_parameter *c = this; c; c = c->_next)
11       {
12         if (c->_tag == tag)
13           {
14             c->mark_used();
15             return c->_val;
16           }
17       }
18     return 0;
19   }
20
21   Tagged_parameter(cxx::String const &tag, Expression *val)
22   : _next(0), _tag(tag), _val(val), _used(false)
23   {}
24
25   Tagged_parameter *prepend(Tagged_parameter *n)
26   { n->_next = this; return n; }
27
28   static void del_all(Tagged_parameter *f, bool del_expr = true)
29   {
30     while (f)
31       {
32         Tagged_parameter *c = f;
33         f = c->_next;
34
35         if (del_expr)
36           Expression::del_all(c->_val);
37
38         delete c;
39       }
40   }
41
42   Tagged_parameter *next() { return _next; }
43   cxx::String const &tag() const { return _tag; }
44   Expression *val() const { return _val; }
45
46   void mark_used() { _used = true; }
47
48   bool used() const { return _used; }
49
50 private:
51   Tagged_parameter *_next;
52   cxx::String const _tag;
53   Expression *_val;
54   bool _used;
55 };
56
57