std::string get_month_name(unsigned char month);
+
+/**
+ * @brief represents some days of a week.
+ *
+ */
class WEEK
{
private:
public:
enum WEEKDAY { SU=0, MO=1, TU=2, WE=3, TH=4, FR=5, SA=6 };
-
+
// throws out_of_range if illegal week
WEEK(const std::string& daystring);
-
- WEEK(const std::bitset<7> &days)
- : days(days)
+
+ WEEK(const std::bitset<7> &_days)
+ : days(_days)
{ }
-
+
WEEK()
{ }
-
+
void clear()
{ days.reset(); }
-
+
operator std::bitset<7>() const
{ return days; }
-
+
void set(WEEKDAY d, bool value=true)
{ days[d]=value; }
-
+
bool all_set() const
{ return (days.count()==7); }
bool none_set() const
{ return days.none(); }
-
+
std::string get_daystring() const;
std::string get_displaystring() const;
std::string get_netfilterstring() const;
-
+
static std::string get_day_display(WEEKDAY day);
static std::string get_english_display(WEEKDAY day);
-};
+
+ // some operators for convenience:
+
+ WEEK& operator&=(const WEEK& rhs)
+ {
+ days &= rhs.days;
+ return *this;
+ }
+
+ WEEK& operator|=(const WEEK& rhs)
+ {
+ days|= rhs.days;
+ return *this;
+ }
+
+ WEEK& operator^=(const WEEK& rhs)
+ {
+ days^= rhs.days;
+ return *this;
+ }
+
+ bool operator==(const WEEK& rhs)
+ {
+ return days == rhs.days;
+ }
+
+ bool operator!=(const WEEK& rhs)
+ {
+ return days != rhs.days;
+ }
+
+}; // eo class WEEK
+
+
+/**
+ * @brief delivers a week containing the days which are in both weeks.
+ * @param lhs first week.
+ * @param rhs second week.
+ * @return week which has only those days which are in both weeks.
+ */
+inline WEEK operator&(const WEEK& lhs, const WEEK& rhs)
+{
+ WEEK result(lhs);
+ return result &= rhs;
+} // eo operator&(const WEEK&,const WEEK&)
+
+
+/**
+ * @brief delivers a week containing the days which are at least in one of both weeks.
+ * @param lhs first week.
+ * @param rhs second week.
+ * @return week which has only those days which are at least in one of both weeks.
+ */
+inline WEEK operator|(const WEEK& lhs, const WEEK& rhs)
+{
+ WEEK result(lhs);
+ return result |= rhs;
+} // eo operator&(const WEEK&,const WEEK&)
+
+
+/**
+ * @brief delivers a week containing the days which are in only one of both weeks.
+ * @param lhs first week.
+ * @param rhs second week.
+ * @return week which has only those days which are in only one of both weeks.
+ */
+inline WEEK operator^(const WEEK& lhs, const WEEK& rhs)
+{
+ WEEK result(lhs);
+ return result ^= rhs;
+} // eo operator&(const WEEK&,const WEEK&)
/**