
i'm writing on a programm which uses the boost date_time library
[boost-version = 1.32.0] heavily; while i normally programm in linux
using gcc-3.3.5 i also need to compile my program in windows from time
to time. because it makes life easier with another library [gtkmm-2.4.8]
i'm using mingw-3.4.2; everthing worked fine (my code contains about 10
000 lines using boost_date_time) until i started using a
boost::gregorian::year_based_generator. while gcc-3.3.5 in liux accepts
my code without even a single warning [with -Wall], mingw-3.4.2
complains - it seems that the compiler has problems with
year_based_generator:
calendar.hpp:60: error: variable or field `insertGenerator' declared void
calendar.hpp:60: error: expected `;' before '(' token
calendar.hpp:92: error: expected `)' before '*' token
calendar.hpp:95: error: using-declaration for non-member at class scope
calendar.hpp:95: error: expected `;' before '*' token
here is the header:
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef CL_CALENDAR
#define CL_CALENDAR
#include "boost/date_time/gregorian/gregorian.hpp"
#include <stdexcept>
#include <vector>
#include <map>
#ifndef BG
#define BG boost::gregorian
#endif
/*!@brief besides of providing you with information if the day you are
looking at is a
* working day / saturday / sunday you can also store and
retrieve additional
* information about specific dates */
class calendar
{
public:
enum dayChar { NORMAL_DAY = 0,
SATURDAY = 1,
SUNDAY = 2,
PUBLIC_HOLIDAY = 3,
SPECIAL_DAY = 4 };
/*!@brief obtain a calendar for a given context*/
static calendar& get(unsigned context=0);
/*!@brief remove all calendar instances which have been created so
far*/
static void removeAll();
/*!@brief remove the instance for a given context
*
* @remark you should call this function if you don't need the
instance associated with
* with context any more to avoid memory leaks !
*/
static void remove(unsigned context);
/*!@param[in] tDay the day to mark
* @param[in] character the new character
* @return true if the operation was succesfull
* @note you cant lower the default character of a given day - e.g.
you can't
* give a sunday the character of a normal working day*/
bool markDay(const BG::date& tDay, dayChar character);
/*!@return true if succesfull*/
bool unmarkDay(const BG::date& tDay);
/*!@brief mark a day for every year using a partial_date
*
* @param[in] pDate a partial date
* @param[in] character the new character*/
void markDay(const BG::partial_date& pDate, dayChar character);
/*!@return true if succesfull*/
bool unmarkDay(const BG::partial_date& tDate);
/*!@brief use this function to define more sophisticated (holi)days
*
* @param[in] gen a pointer to a year_based_generator optained from new
* @param[in] manage if true the calendar is responsible for deleting*/
void insertGenerator(BG::year_based_generator *gen, dayChar
character, bool manage=true);
/*!@brief removes all generators inserted with insertGenerator*/
void removeGenerators();
/*!@brief get information from our calendar*/
dayChar getDayCharacter(const BG::date& thatDay) const;
void reset();
int getRegularWorkingDaysWithin(const BG::date_period& tPeriod) const;
/*!@remark this function can be usefull to dump our calendar to a
file */
const std::map