OSDN Git Service

- Added better status reporting functions.
[tjqt4port/tj2qt4.git] / taskjuggler / ProjectFile.h
1 /*
2  * ProjectFile.h - TaskJuggler
3  *
4  * Copyright (c) 2001, 2002 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 of version 2 of the GNU General Public License as
8  * published by the Free Software Foundation.
9  *
10  * $Id$
11  */
12
13 #ifndef _ProjectFile_h_
14 #define _ProjectFile_h_
15
16 #include <time.h>
17
18 #include <qptrlist.h>
19
20 #include "Token.h"
21 #include "MacroTable.h"
22 #include "FileInfo.h"
23
24 class Project;
25 class Task;
26 class Resource;
27 class Account;
28 class Shift;
29 class Booking;
30 class Interval;
31 class Operation;
32 class Report;
33 class ReportHtml;
34
35 /**
36  * @short File Parser for project files.
37  * @author Chris Schlaeger <cs@suse.de>
38  */
39 class ProjectFile
40 {
41 public:
42         /**
43          * A ProjectFile cannot exist without a project. So the constructor needs
44          * to know what Project object to fill, when it parses the project files.
45          */
46         ProjectFile(Project* p);
47         ~ProjectFile() { }
48
49         /**
50          * The top-level project files needs to be opened before the parser can be
51          * started.
52          * @param file The file name of the file to start with.
53          * @param parentPath The path of the file that included this file. This
54          * feature is for internal use only. It's not part of the public API. 
55          * @param taskPrefix The ID prefix of the parent task. This is needed when
56          * the tasks of the project file should be read as a sub-task of an
57          * already existing task.
58          */
59         bool open(const QString& file, const QString& parentPath,
60                           const QString& taskPrefix);
61         /**
62          * Close the just read input file.
63          */
64         bool close();
65         
66         /**
67          * Calling the parse function will start the processing of the opened
68          * project file. It will automatically read all include files as well. The
69          * collected data is stored into the Project object.
70          */
71         bool parse();
72
73         /*
74          * The rest of the public methods are for use by FileInfo and are not part
75          * of the library public interface.
76          */
77         
78         TokenType nextToken(QString& token);
79         void returnToken(TokenType t, const QString& buf)
80         {
81                 if (!openFiles.isEmpty())
82                         openFiles.last()->returnToken(t, buf);
83         }
84         const QString& getFile()
85         {
86                 if (openFiles.isEmpty())
87                         return QString::null;
88                 return openFiles.last()->getFile(); 
89         }
90         int getLine()
91         {
92                 if (openFiles.isEmpty())
93                         return -1;
94                 return openFiles.last()->getLine(); 
95         }
96
97         bool moreFiles() { return !openFiles.isEmpty(); }
98
99         const QString& getTaskPrefix();
100
101         void fatalError(const char* msg, ...);
102
103         MacroTable& getMacros() { return macros; }
104
105 private:
106         ProjectFile() {};       // don't use
107
108         bool readProject();
109         bool readInclude();
110         bool readTask(Task* parent);
111         bool readTaskSupplement(QString prefix);
112         bool readTaskBody(Task* task);
113         bool readResource(Resource* parent);
114         bool readResourceSupplement();
115         bool readResourceBody(Resource* r);
116         bool readVacation(time_t& from, time_t& to, bool readName = FALSE,
117                                           QString* = 0);
118         bool readAccount(Account* parent);
119         bool readShift(Shift* parent);
120         Shift* readShiftSelection(time_t& from, time_t& to);
121         Booking* readBooking();
122         bool readCredit(Account* a);
123         bool readAllocate(Task* t);
124         bool readPlanTimeFrame(double& d, bool workingDays);
125         bool readTimeValue(ulong& value);
126         bool readPercent(double& value);
127         bool readWorkingHours(int& dayOfWeek, QPtrList<Interval>* l);
128         bool readPriority(int& priority);
129         bool checkReportInterval(ReportHtml* report);
130         bool readHTMLReport(const QString& reportType);
131         bool readHTMLAccountReport();
132         bool readExportReport();
133         bool readXMLReport();
134         bool readHtmlUrl(ReportHtml* report);
135 #ifdef HAVE_KDE
136         bool readICalTaskReport();
137 #endif
138         Operation* readLogicalExpression(int precedence = 0);
139         Operation* readFunctionCall(const QString& name);
140         bool readSorting(Report* report, int which);
141         time_t date2time(const QString& date);
142         int hhmm2time(const QString& hhmm);
143
144         QString masterFile;
145         Project* proj;
146         QPtrList<FileInfo> openFiles;
147         QStringList includedFiles;
148         MacroTable macros;
149 };
150
151 #endif