OSDN Git Service

- Lot's of bugfixes again.
[tjqt4port/tj2qt4.git] / taskjuggler / MacroTable.h
1 /*
2  * MacroTable.h - TaskJuggler
3  *
4  * Copyright (c) 2001 by Chris Schlaeger <cs@suse.de>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms version 2 of the GNU General Public License as
8  * published by the Free Software Foundation.
9  *
10  * $Id$
11  */
12
13 #ifndef _MacroTable_h_
14 #define _MacroTable_h_
15
16 #include <qstring.h>
17 #include <qstringlist.h>
18 #include <qdict.h>
19 #include <qvaluelist.h>
20
21 class Macro
22 {
23 public:
24         Macro(const QString& n, const QString& v, const QString& f, uint l)
25                 : name(n), value(v), file(f), line(l) { }
26         ~Macro() { }
27
28         const QString& getName() const { return name; }
29         const QString& getValue() const { return value; }
30         const QString& getFile() const { return file; }
31         const uint getLine() const { return line; }
32
33 private:
34         Macro() { }     // don't use this
35
36         QString name;
37         QString value;
38         QString file;
39         uint line;
40 } ;
41
42 class MacroTable
43 {
44 public:
45         MacroTable()
46         {
47                 macros.setAutoDelete(TRUE);
48                 argStack.setAutoDelete(TRUE);
49         }
50         ~MacroTable() { }
51
52         bool addMacro(Macro* m);
53         void pushArguments(QStringList* sl)
54         {
55                 argStack.append(sl);
56         }
57         void popArguments()
58         {
59                 argStack.removeLast();
60         }
61         QString expand(const QString& name);
62         Macro* getMacro(const QString& name) const { return macros[name]; }
63
64 private:
65         QDict<Macro> macros;
66         QPtrList<QStringList> argStack;
67 } ;
68
69 #endif