2 * ProjectFile.h - TaskJuggler
4 * Copyright (c) 2001, 2002 by Chris Schlaeger <cs@suse.de>
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 _ProjectFile_h_
14 #define _ProjectFile_h_
21 #include <qvaluelist.h>
25 #include "MacroTable.h"
36 FileInfo(ProjectFile* p, const QString& file, const QString& tp);
42 QChar getC(bool expandMacros = TRUE);
44 void expandMarco(QString& c);
46 const QString& getFile() const { return file; }
47 QString getPath() const;
49 int getLine() const { return currLine; }
51 TokenType nextToken(QString& buf);
52 void returnToken(TokenType t, const QString& buf);
56 const QString& getTaskPrefix() { return taskPrefix; }
58 void fatalErrorVA(const char* msg, va_list ap);
59 void fatalError(const char* msg, ...);
62 bool getDateFragment(QString& token, QChar& c);
65 * A pointer to the ProjectFile class that stores all read-in
70 // The name of the file.
73 // The file handle of the file to read.
76 // The stream used to read the file.
79 // The number of the line currently being read.
83 * Macros have file scope. So we keep a stack of macros for each file that
86 QPtrList<Macro> macroStack;
89 * A buffer for the part of the line that has been parsed already. This is
90 * primarily used for error reporting.
95 * A buffer for characters that have been pushed back again. This
96 * simplifies file parsing in some situations.
98 QValueList<QChar> ungetBuf;
101 * Besides read in characters we can also push back a token. Contrary to
102 * characters we can push back only 1 token. This is stored as type and
105 TokenType tokenTypeBuf;
109 * Task trees of include files can not only be added at global scope but
110 * also as sub-trees. This strings stores the prefix that has to be
111 * specified at include times.
119 ProjectFile(Project* p);
122 bool open(const QString& file, const QString& parentPath,
123 const QString& taskPrefix);
126 void setDebugLevel(int l) { debugLevel = l; }
127 void setDebugMode(int m) { debugMode = m; }
129 TokenType nextToken(QString& token);
130 void returnToken(TokenType t, const QString& buf)
132 if (!openFiles.isEmpty())
133 openFiles.last()->returnToken(t, buf);
136 const QString& getFile()
138 if (openFiles.isEmpty())
139 return QString::null;
140 return openFiles.last()->getFile();
144 if (openFiles.isEmpty())
146 return openFiles.last()->getLine();
149 bool moreFiles() { return !openFiles.isEmpty(); }
151 const QString& getTaskPrefix();
153 void fatalError(const char* msg, ...);
155 MacroTable& getMacros() { return macros; }
158 ProjectFile() {}; // don't use
162 bool readTask(Task* parent);
163 bool readTaskSupplement(QString prefix);
164 bool readTaskBody(Task* task);
165 bool readResource(Resource* parent);
166 bool readResourceSupplement();
167 bool readResourceBody(Resource* r);
168 bool readVacation(time_t& from, time_t& to, bool readName = FALSE,
170 bool readAccount(Account* parent);
171 bool readShift(Shift* parent);
172 Shift* readShiftSelection(time_t& from, time_t& to);
173 Booking* readBooking();
174 bool readCredit(Account* a);
175 bool readAllocate(Task* t);
176 bool readPlanTimeFrame(double& d, bool workingDays);
177 bool readTimeValue(ulong& value);
178 bool readPercent(double& value);
179 bool readWorkingHours(int& dayOfWeek, QPtrList<Interval>* l);
180 bool readPriority(int& priority);
181 bool checkReportInterval(ReportHtml* report);
182 bool readHTMLReport(const QString& reportType);
183 bool readHTMLAccountReport();
184 bool readExportReport();
185 bool readXMLReport();
186 bool readHtmlUrl(ReportHtml* report);
188 bool readICalTaskReport();
190 Operation* readLogicalExpression(int precedence = 0);
191 Operation* readFunctionCall(const QString& name);
192 bool readSorting(Report* report, int which);
193 time_t date2time(const QString& date);
194 int hhmm2time(const QString& hhmm);
198 QList<FileInfo> openFiles;
199 QStringList includedFiles;
201 static int debugLevel;
202 static int debugMode;