00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef KHOLIDAYS_HOLIDAYPARSERDRIVERPLAN_P_H
00023 #define KHOLIDAYS_HOLIDAYPARSERDRIVERPLAN_P_H
00024
00025 #include <fstream>
00026
00027 #include <QByteArray>
00028
00029 #include "../holidayparserdriver_p.h"
00030
00031 namespace KHolidays {
00032
00033 class HolidayScannerPlan;
00034 class HolidayParserPlan;
00035 class location;
00036
00051 class HolidayParserDriverPlan : public HolidayParserDriver
00052 {
00053 public:
00054
00060 HolidayParserDriverPlan( const QString &planFilename );
00061
00065 ~HolidayParserDriverPlan();
00066
00072 void error( const KHolidays::location &errorLocation, const QString &errorMessage );
00073
00079 void error( const QString &errorMessage );
00080
00081 protected:
00085 void parse();
00086
00090 void parseMetadata();
00091
00092
00093 friend class HolidayParserPlan;
00094
00095
00096 QString filePath();
00097
00098
00099 int adjustedMonthNumber( int month );
00100 bool isLeapYear( int year );
00101 int parseYear();
00102
00103
00104 int julianDayFromEventName( const QString &eventName );
00105 int julianDayFromEaster();
00106 int julianDayFromPascha();
00107 int julianDayFromMonthDay( int month, int day );
00108 int julianDayFromRelativeWeekday( int occurrence, int weekday, int jd );
00109 int julianDayFromWeekdayInMonth( int occurrence, int weekday, int month );
00110
00111
00112 void setFileCountryCode( const QString &countryCode );
00113 void setFileLanguageCode( const QString &languageCode );
00114 void setFileName( const QString &ame );
00115 void setFileDescription( const QString &description );
00116 void setEventName( const QString &eventName );
00117 void setEventColorName( int nameColor );
00118 void setEventColorDay( int dayColor );
00119 void setEventCalendarType( const QString &calendarType = "gregorian" );
00120 void setEventDate( int eventYear, int eventMonth, int eventDay );
00121 void setEventDate( int jd );
00122
00123
00124 void setFromEaster( int offset, int duration );
00125 void setFromPascha( int offset, int duration );
00126 void setFromDate( int offset, int condition, int duration );
00127 void setFromWeekdayInMonth( int occurrence, int weekday, int month, int offset, int duration );
00128 void setFromRelativeWeekday( int occurrence, int weekday, int offset, int duration );
00129 void setEvent( int event_jd, int observe_offset, int duration );
00130
00131 private:
00132
00133 int monthsInYear( int year );
00134 int daysInMonth( int year, int month );
00135 int julianDay( int year, int month, int day );
00136 void julianDayToDate( int jd, int *year, int *month, int *day );
00137 QDate easter( int year );
00138 QDate pascha( int year );
00139
00140 int conditionalOffset( int year, int month, int day, int condition );
00141
00142 QByteArray m_scanData;
00143
00144 bool m_traceParsing;
00145 HolidayParserPlan *m_parser;
00146
00147 bool m_traceScanning;
00148 HolidayScannerPlan *m_scanner;
00149
00150 QDate m_parseYearStart;
00151 QDate m_parseYearEaster;
00152 QDate m_parseYearPascha;
00153
00154 QString m_eventCalendarType;
00155 QString m_eventName;
00156 int m_eventYear;
00157 int m_eventMonth;
00158 int m_eventDay;
00159 int m_eventColorName;
00160 int m_eventColorDay;
00161 };
00162
00163 }
00164
00165 #endif // KHOLIDAYS_HOLIDAYPARSERDRIVERPLAN_P_H