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

KHolidays Library

  • sources
  • kde-4.12
  • kdepimlibs
  • 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 #include <string>
27 
28 #include <QByteArray>
29 #include <QStringList>
30 
31 #include "../holidayparserdriver_p.h"
32 
33 namespace KHolidays {
34 
35 class HolidayScannerPlan;
36 class HolidayParserPlan;
37 class location;
38 
53 class HolidayParserDriverPlan : public HolidayParserDriver
54 {
55 public:
56 
62  HolidayParserDriverPlan( const QString &planFilename );
63 
67  ~HolidayParserDriverPlan();
68 
74  void error( const KHolidays::location &errorLocation, const QString &errorMessage );
75 
81  void error( const QString &errorMessage );
82 
83 protected:
87  void parse();
88 
92  void parseMetadata();
93 
94  // Bison C++ skeleton required friend for Bison parser class implementation
95  friend class HolidayParserPlan;
96 
97  // Accessor methods for parser to talk to driver
98  QString filePath();
99  std::string *fileToParse() const;
100 
101  // Calendar and date calculation utilities
102  int adjustedMonthNumber( int month );
103  bool isLeapYear( int year );
104  int parseYear();
105 
106  // Utilities for parser to calculate interim Julian Day Number during parsing
107  int julianDayFromEventName( const QString &eventName );
108  int julianDayFromEaster();
109  int julianDayFromPascha();
110  int julianDayFromMonthDay( int month, int day );
111  int julianDayFromRelativeWeekday( int occurrence, int weekday, int jd );
112  int julianDayFromWeekdayInMonth( int occurrence, int weekday, int month );
113 
114  // Utilities for parser to set variables during parsing
115  void setFileCountryCode( const QString &countryCode );
116  void setFileLanguageCode( const QString &languageCode );
117  void setFileName( const QString &ame );
118  void setFileDescription( const QString &description );
119  void setEventName( const QString &eventName );
120  void setEventColorName( int nameColor );
121  void setEventColorDay( int dayColor );
122  void setEventCalendarType( const QString &calendarType = "gregorian" );
123  void setEventDate( int eventYear, int eventMonth, int eventDay );
124  void setEventDate( int jd );
125 
126  // Terminal functions for parser to create holidays from parsed variables
127  void setFromEaster( int offset, int duration );
128  void setFromPascha( int offset, int duration );
129  void setFromDate( int offset, int condition, int duration );
130  void setFromWeekdayInMonth( int occurrence, int weekday, int month, int offset, int duration );
131  void setFromRelativeWeekday( int occurrence, int weekday, int offset, int duration );
132  void setEvent( int event_jd, int observe_offset, int duration );
133 
134 private:
135  // Calendar and date calculation utilities
136  int monthsInYear( int year );
137  int daysInMonth( int year, int month );
138  int julianDay( int year, int month, int day );
139  void julianDayToDate( int jd, int *year, int *month, int *day );
140  QDate easter( int year );
141  QDate pascha( int year );
142 
143  int conditionalOffset( int year, int month, int day, int condition );
144 
145  void addHoliday( const QDate &date, int duration );
146 
147  QByteArray m_scanData; // Holiday file stored as a string
148 
149  QStringList m_fileCalendarTypes; // List of all Calendar Systems used in file
150 
151  bool m_traceParsing; // Bison C++ skeleton enable tracing in Bison parser class
152  HolidayParserPlan *m_parser; // Bison C++ skeleton Bison parser class implementation
153 
154  bool m_traceScanning; // Flex C++ enable tracing in Flex scanner class
155  HolidayScannerPlan *m_scanner; // Flex C++ scanner class implementation
156 
157  bool m_parseMetadataOnly; // Only parse file for metadata
158  QDate m_parseYearStart; // First day of year being parsed
159  QDate m_parseYearEaster; // Easter in the parse year, Gregorian only
160  QDate m_parseYearPascha; // Orthodox Easter in the parse year, Gregorian only
161 
162  QString m_eventCalendarType; // Calendar System for event rule
163  QString m_eventName; // Event name text
164  int m_eventYear; // Event date fields
165  int m_eventMonth; // Event date fields
166  int m_eventDay; // Event date fields
167  int m_eventColorName; // Color of event name text
168  int m_eventColorDay; // Color of event day number
169 
170  std::string *m_fileToParse;
171 };
172 
173 }
174 
175 #endif // KHOLIDAYS_HOLIDAYPARSERDRIVERPLAN_P_H
KHolidays::HolidayParserDriverPlan::error
void error(const KHolidays::location &errorLocation, const QString &errorMessage)
Bison C++ skeleton error message handling.
Definition: holidayparserdriverplan.cpp:79
KHolidays::HolidayParserDriverPlan::~HolidayParserDriverPlan
~HolidayParserDriverPlan()
Destructor.
Definition: holidayparserdriverplan.cpp:71
KHolidays::HolidayParserDriver
HolidayParserDriver abstract base class.
Definition: holidayparserdriver_p.h:44
KHolidays::HolidayScannerPlan
HolidayScannerPlan implementation class.
Definition: holidayscannerplan_p.h:63
KHolidays::HolidayParserDriverPlan::parseMetadata
void parseMetadata()
Parse the file for metadata only and populate the metadata variables.
Definition: holidayparserdriverplan.cpp:119
KHolidays::HolidayParserPlan
A Bison parser.
Definition: holidayparserplan.hpp:114
KHolidays::HolidayParserDriverPlan::parse
void parse()
Actually parse the file, new plan format implementation.
Definition: holidayparserdriverplan.cpp:93
KHolidays::location
Abstract a location.
Definition: location.hh:51
KHolidays::HolidayParserDriverPlan::HolidayParserDriverPlan
HolidayParserDriverPlan(const QString &planFilename)
Constructor of Plan file parser driver.
Definition: holidayparserdriverplan.cpp:52
KHolidays::HolidayParserDriverPlan
HolidayParserDriverPlan implementation class.
Definition: holidayparserdriverplan_p.h:53
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:06 by doxygen 1.8.7 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 API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



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