• Skip to content
  • Skip to link menu
KDE 4.5 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • 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 
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     // Bison C++ skeleton required friend for Bison parser class implementation
00093     friend class HolidayParserPlan;
00094 
00095     // Accessor methods for parser to talk to driver
00096     QString filePath();
00097 
00098     // Calendar and date calculation utilities
00099     int   adjustedMonthNumber( int month );
00100     bool  isLeapYear( int year );
00101     int   parseYear();
00102 
00103     // Utilities for parser to calculate interim Julian Day Number during parsing
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     // Utilities for parser to set variables during parsing
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     // Terminal functions for parser to create holidays from parsed variables
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     // Calendar and date calculation utilities
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;                 // Holiday file stored as a string
00143 
00144     bool                m_traceParsing;             // Bison C++ skeleton enable tracing in Bison parser class
00145     HolidayParserPlan  *m_parser;                   // Bison C++ skeleton Bison parser class implementation
00146 
00147     bool                m_traceScanning;            // Flex C++ enable tracing in Flex scanner class
00148     HolidayScannerPlan *m_scanner;                  // Flex C++ scanner class implementation
00149 
00150     QDate               m_parseYearStart;           // First day of year being parsed
00151     QDate               m_parseYearEaster;          // Easter in the parse year, Gregorian only
00152     QDate               m_parseYearPascha;          // Orthodox Easter in the parse year, Gregorian only
00153 
00154     QString             m_eventCalendarType;        // Calendar System for event rule
00155     QString             m_eventName;                // Event name text
00156     int                 m_eventYear;                // Event date fields
00157     int                 m_eventMonth;               // Event date fields
00158     int                 m_eventDay;                 // Event date fields
00159     int                 m_eventColorName;           // Color of event name text
00160     int                 m_eventColorDay;            // Color of event day number
00161 };
00162 
00163 }
00164 
00165 #endif // KHOLIDAYS_HOLIDAYPARSERDRIVERPLAN_P_H

KHolidays Library

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal