• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.10.5 API Reference
  • KDE Home
  • Contact Us
 

KHolidays Library

  • kholidays
  • parsers
  • plan2
holidayparserdriverplan_p.h
1 /*
2  This file is part of the kholidays library.
3 
4  Copyright 2010 John Layt <john@layt.net>
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Library General Public
8  License as published by the Free Software Foundation; either
9  version 2 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Library General Public License for more details.
15 
16  You should have received a copy of the GNU Library General Public License
17  along with this library; see the file COPYING.LIB. If not, write to the
18  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19  Boston, MA 02110-1301, USA.
20 */
21 
22 #ifndef KHOLIDAYS_HOLIDAYPARSERDRIVERPLAN_P_H
23 #define KHOLIDAYS_HOLIDAYPARSERDRIVERPLAN_P_H
24 
25 #include <fstream>
26 
27 #include <QByteArray>
28 #include <QStringList>
29 
30 #include "../holidayparserdriver_p.h"
31 
32 namespace KHolidays {
33 
34 class HolidayScannerPlan;
35 class HolidayParserPlan;
36 class location;
37 
52 class HolidayParserDriverPlan : public HolidayParserDriver
53 {
54 public:
55 
61  HolidayParserDriverPlan( const QString &planFilename );
62 
66  ~HolidayParserDriverPlan();
67 
73  void error( const KHolidays::location &errorLocation, const QString &errorMessage );
74 
80  void error( const QString &errorMessage );
81 
82 protected:
86  void parse();
87 
91  void parseMetadata();
92 
93  // Bison C++ skeleton required friend for Bison parser class implementation
94  friend class HolidayParserPlan;
95 
96  // Accessor methods for parser to talk to driver
97  QString filePath();
98 
99  // Calendar and date calculation utilities
100  int adjustedMonthNumber( int month );
101  bool isLeapYear( int year );
102  int parseYear();
103 
104  // Utilities for parser to calculate interim Julian Day Number during parsing
105  int julianDayFromEventName( const QString &eventName );
106  int julianDayFromEaster();
107  int julianDayFromPascha();
108  int julianDayFromMonthDay( int month, int day );
109  int julianDayFromRelativeWeekday( int occurrence, int weekday, int jd );
110  int julianDayFromWeekdayInMonth( int occurrence, int weekday, int month );
111 
112  // Utilities for parser to set variables during parsing
113  void setFileCountryCode( const QString &countryCode );
114  void setFileLanguageCode( const QString &languageCode );
115  void setFileName( const QString &ame );
116  void setFileDescription( const QString &description );
117  void setEventName( const QString &eventName );
118  void setEventColorName( int nameColor );
119  void setEventColorDay( int dayColor );
120  void setEventCalendarType( const QString &calendarType = "gregorian" );
121  void setEventDate( int eventYear, int eventMonth, int eventDay );
122  void setEventDate( int jd );
123 
124  // Terminal functions for parser to create holidays from parsed variables
125  void setFromEaster( int offset, int duration );
126  void setFromPascha( int offset, int duration );
127  void setFromDate( int offset, int condition, int duration );
128  void setFromWeekdayInMonth( int occurrence, int weekday, int month, int offset, int duration );
129  void setFromRelativeWeekday( int occurrence, int weekday, int offset, int duration );
130  void setEvent( int event_jd, int observe_offset, int duration );
131 
132 private:
133  // Calendar and date calculation utilities
134  int monthsInYear( int year );
135  int daysInMonth( int year, int month );
136  int julianDay( int year, int month, int day );
137  void julianDayToDate( int jd, int *year, int *month, int *day );
138  QDate easter( int year );
139  QDate pascha( int year );
140 
141  int conditionalOffset( int year, int month, int day, int condition );
142 
143  void addHoliday( const QDate &date, int duration );
144 
145  QByteArray m_scanData; // Holiday file stored as a string
146 
147  QStringList m_fileCalendarTypes; // List of all Calendar Systems used in file
148 
149  bool m_traceParsing; // Bison C++ skeleton enable tracing in Bison parser class
150  HolidayParserPlan *m_parser; // Bison C++ skeleton Bison parser class implementation
151 
152  bool m_traceScanning; // Flex C++ enable tracing in Flex scanner class
153  HolidayScannerPlan *m_scanner; // Flex C++ scanner class implementation
154 
155  bool m_parseMetadataOnly; // Only parse file for metadata
156  QDate m_parseYearStart; // First day of year being parsed
157  QDate m_parseYearEaster; // Easter in the parse year, Gregorian only
158  QDate m_parseYearPascha; // Orthodox Easter in the parse year, Gregorian only
159 
160  QString m_eventCalendarType; // Calendar System for event rule
161  QString m_eventName; // Event name text
162  int m_eventYear; // Event date fields
163  int m_eventMonth; // Event date fields
164  int m_eventDay; // Event date fields
165  int m_eventColorName; // Color of event name text
166  int m_eventColorDay; // Color of event day number
167 };
168 
169 }
170 
171 #endif // KHOLIDAYS_HOLIDAYPARSERDRIVERPLAN_P_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:25:09 by doxygen 1.8.3.1 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHolidays Library

Skip menu "KHolidays Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal