2 * MacroTable.h - TaskJuggler
4 * Copyright (c) 2001, 2002, 2003, 2004, 2005 by Chris Schlaeger <cs@kde.org>
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of version 2 of the GNU General Public License as
8 * published by the Free Software Foundation.
13 #ifndef _MacroTable_h_
14 #define _MacroTable_h_
19 #include <qstringlist.h>
25 Macro(const QString& n, const QString& v, const QString& f, uint l)
26 : name(n), value(v), file(f), line(l) { }
27 Macro(const QString& n, const int v, const QString& f, uint l)
28 : name(n), value(QString::number(v)), file(f), line(l) { }
29 Macro(const QString& n, const long v, const QString& f, uint l)
30 : name(n), value(QString::number(v)), file(f), line(l) { }
31 Macro(const QString& n, const double v, const QString& f, uint l)
32 : name(n), value(QString::number(v)), file(f), line(l) { }
35 const QString& getName() const { return name; }
36 const QString& getValue() const { return value; }
37 const QString& getFile() const { return file; }
38 uint getLine() const { return line; }
50 MacroTable() : defFileName(), defFileLine(0), macros()
52 macros.setAutoDelete(true);
56 bool addMacro(Macro* m);
57 void setMacro(Macro* m);
59 bool deleteMacro(const QString name)
61 return macros.remove(name);
68 QString resolve(const QStringList* argList) const;
69 QString expandReportVariable(QString text, const QStringList* argList) const;
70 Macro* getMacro(const QString& name) const { return macros[name]; }
72 void setLocation(const QString& df, int dl)
79 bool evalExpression(const QString expr) const;
80 void errorMessage(const QString& msg) const;
82 /* We store a file name and a line number in case we need this for
83 * error reports or warnings. This is the location of the macro reference,
84 * not the macro definitions. */