*/
void Week::clear()
{
- Days.reset();
+ Days.reset(); //lint !e534
IsValid = true;
}
nr[0]=daystring[p];
nr[1]=0;
istringstream c(nr);
- int wnr=-1;
- if (!(c >> wnr) || wnr<0 || wnr >6)
+ unsigned int wnr=7;
+ if (!(c >> wnr) || wnr > 6)
{
IsValid = false;
return IsValid;
}
- new_days.set(wnr);
+ new_days.set(wnr); //lint !e534
}
// Atomic switch-over
Days = new_days;
*/
bool Week::set(const WeekDay day, bool value)
{
- if (day < 0 || day >= _WeekDay_END)
+ if (day >= _WeekDay_END)
{
IsValid = false;
return IsValid;
}
- Days[day]=value;
+ Days.set(static_cast<size_t>(day), value); //lint !e534
+
return IsValid;
}
*/
bool Week::get(WeekDay day) const
{
- return Days[day];
+ return Days.test(static_cast<size_t>(day));
}
/**
*/
bool Week::is_set(WeekDay day) const
{
- return Days[day];
+ return Days.test(static_cast<size_t>(day));
}
/**
@param start weekday to start checking
@note returns 0 if the start-day is set
*/
-int Week::days_till_set(WeekDay start)
+unsigned int Week::days_till_set(WeekDay start) const
{
if (none_set())
- return -1;
+ return 0;
for (unsigned int days=0; days < 8; days++)
{
throw logic_error("can't find next weekday");
// fake
- return -1;
+ return 0; //lint !e527
}
/**
@param start weekday to start checking
@note returns 0 if the start-day is set
*/
-int Week::days_since_set(WeekDay start)
+unsigned int Week::days_since_set(WeekDay start) const
{
if (none_set())
- return -1;
+ return 0;
for (unsigned int days=0; days < 8; days++)
{
- int check=start-days;
+ int check=start-static_cast<int>(days);
if (check < 0)
check+=7;
if (is_set(static_cast<WeekDay>(check)))
throw logic_error("can't find next weekday");
// fake
- return -1;
+ return 0; //lint !e527
}
/**
{
ostringstream out;
- for (int i = 0; i < 7; i++)
+ for (unsigned int i = 0; i < 7; i++)
if (Days[i])
out << i;
string weekdays_str;
// From Monday to Saturday
- int j;
+ int j = 0;
for (int i = 1; i < 7; i++)
{
if (Days[i])
}
// special: sunday
- if (Days[0] && j != 7)
+ if (Days[0] && j != 7)
{
if (!weekdays_str.empty())
weekdays_str += ", ";
{
string out;
- for (int i = 0; i < 7; i++)
+ for (unsigned int i = 0; i < 7; i++)
if (Days[i])
{
if (!out.empty())
{
string weekday_str;
- switch (day) {
+ switch (day)
+ {
case Mo:
weekday_str = i18n("Mon");
break;
break;
default:
break;
- }
+ } //lint !e788: Don't complain about unused _WeekDay_END
return weekday_str;
}
{
string weekday_str;
- switch (day) {
+ switch (day)
+ {
case Mo:
weekday_str = "Mon";
break;
break;
default:
break;
- }
+ } //lint !e788: Don't complain about unused _WeekDay_END
return weekday_str;
}