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

KHolidays Library

holidayparserdriverplan_p.h
00001 /*
00002     This file is part of the kholidays library.
00003 
00004     Copyright 2010 John Layt <john@layt.net>
00005 
00006     This library is free software; you can redistribute it and/or
00007     modify it under the terms of the GNU Library General Public
00008     License as published by the Free Software Foundation; either
00009     version 2 of the License, or (at your option) any later version.
00010 
00011     This library is distributed in the hope that it will be useful,
00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014     GNU Library General Public License for more details.
00015 
00016     You should have received a copy of the GNU Library General Public License
00017     along with this library; see the file COPYING.LIB.  If not, write to the
00018     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00019     Boston, MA 02110-1301, USA.
00020 */
00021 
00022 #ifndef KHOLIDAYS_HOLIDAYPARSERDRIVERPLAN_P_H
00023 #define KHOLIDAYS_HOLIDAYPARSERDRIVERPLAN_P_H
00024 
00025 #include <fstream>
00026 
00027 #include <QByteArray>
00028 #include <QStringList>
00029 
00030 #include "../holidayparserdriver_p.h"
00031 
00032 namespace KHolidays {
00033 
00034 class HolidayScannerPlan;
00035 class HolidayParserPlan;
00036 class location;
00037 
00052 class HolidayParserDriverPlan : public HolidayParserDriver
00053 {
00054 public:
00055 
00061     HolidayParserDriverPlan( const QString &planFilename );
00062 
00066     ~HolidayParserDriverPlan();
00067 
00073     void error( const KHolidays::location &errorLocation, const QString &errorMessage );
00074 
00080     void error( const QString &errorMessage );
00081 
00082 protected:
00086     void parse();
00087 
00091     void parseMetadata();
00092 
00093     // Bison C++ skeleton required friend for Bison parser class implementation
00094     friend class HolidayParserPlan;
00095 
00096     // Accessor methods for parser to talk to driver
00097     QString filePath();
00098 
00099     // Calendar and date calculation utilities
00100     int   adjustedMonthNumber( int month );
00101     bool  isLeapYear( int year );
00102     int   parseYear();
00103 
00104     // Utilities for parser to calculate interim Julian Day Number during parsing
00105     int   julianDayFromEventName( const QString &eventName );
00106     int   julianDayFromEaster();
00107     int   julianDayFromPascha();
00108     int   julianDayFromMonthDay( int month, int day );
00109     int   julianDayFromRelativeWeekday( int occurrence, int weekday, int jd );
00110     int   julianDayFromWeekdayInMonth( int occurrence, int weekday, int month );
00111 
00112     // Utilities for parser to set variables during parsing
00113     void  setFileCountryCode( const QString &countryCode );
00114     void  setFileLanguageCode( const QString &languageCode );
00115     void  setFileName( const QString &ame );
00116     void  setFileDescription( const QString &description );
00117     void  setEventName( const QString &eventName );
00118     void  setEventColorName( int nameColor );
00119     void  setEventColorDay( int dayColor );
00120     void  setEventCalendarType( const QString &calendarType = "gregorian" );
00121     void  setEventDate( int eventYear, int eventMonth, int eventDay );
00122     void  setEventDate( int jd );
00123 
00124     // Terminal functions for parser to create holidays from parsed variables
00125     void  setFromEaster( int offset, int duration );
00126     void  setFromPascha( int offset, int duration );
00127     void  setFromDate( int offset, int condition, int duration );
00128     void  setFromWeekdayInMonth( int occurrence, int weekday, int month, int offset, int duration );
00129     void  setFromRelativeWeekday( int occurrence, int weekday, int offset, int duration );
00130     void  setEvent( int event_jd, int observe_offset, int duration );
00131 
00132 private:
00133     // Calendar and date calculation utilities
00134     int   monthsInYear( int year );
00135     int   daysInMonth( int year, int month );
00136     int   julianDay( int year, int month, int day );
00137     void  julianDayToDate( int jd, int *year, int *month, int *day );
00138     QDate easter( int year );
00139     QDate pascha( int year );
00140 
00141     int   conditionalOffset( int year, int month, int day, int condition );
00142 
00143     void  addHoliday( const QDate &date, int duration );
00144 
00145     QByteArray          m_scanData;                 // Holiday file stored as a string
00146 
00147     QStringList         m_fileCalendarTypes;        // List of all Calendar Systems used in file
00148 
00149     bool                m_traceParsing;             // Bison C++ skeleton enable tracing in Bison parser class
00150     HolidayParserPlan  *m_parser;                   // Bison C++ skeleton Bison parser class implementation
00151 
00152     bool                m_traceScanning;            // Flex C++ enable tracing in Flex scanner class
00153     HolidayScannerPlan *m_scanner;                  // Flex C++ scanner class implementation
00154 
00155     bool                m_parseMetadataOnly;        // Only parse file for metadata
00156     QDate               m_parseYearStart;           // First day of year being parsed
00157     QDate               m_parseYearEaster;          // Easter in the parse year, Gregorian only
00158     QDate               m_parseYearPascha;          // Orthodox Easter in the parse year, Gregorian only
00159 
00160     QString             m_eventCalendarType;        // Calendar System for event rule
00161     QString             m_eventName;                // Event name text
00162     int                 m_eventYear;                // Event date fields
00163     int                 m_eventMonth;               // Event date fields
00164     int                 m_eventDay;                 // Event date fields
00165     int                 m_eventColorName;           // Color of event name text
00166     int                 m_eventColorDay;            // Color of event day number
00167 };
00168 
00169 }
00170 
00171 #endif // KHOLIDAYS_HOLIDAYPARSERDRIVERPLAN_P_H
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Thu May 10 2012 22:17:10 by doxygen 1.8.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KHolidays Library

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

kdepimlibs-4.8.3 API Reference

Skip menu "kdepimlibs-4.8.3 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • 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