Enhancements - rules.cpp
- Converted rules.cpp to work under 1.8.0. - Relocated validReportColumns, validSortColumns to parse.cpp.
This commit is contained in:
@@ -3034,63 +3034,4 @@ std::string handleCustomReport (const std::string& report)
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void validReportColumns (const std::vector <std::string>& columns)
|
||||
{
|
||||
std::vector <std::string> bad;
|
||||
|
||||
std::vector <std::string>::const_iterator it;
|
||||
for (it = columns.begin (); it != columns.end (); ++it)
|
||||
if (*it != "id" &&
|
||||
*it != "uuid" &&
|
||||
*it != "project" &&
|
||||
*it != "priority" &&
|
||||
*it != "entry" &&
|
||||
*it != "start" &&
|
||||
*it != "due" &&
|
||||
*it != "age" &&
|
||||
*it != "age_compact" &&
|
||||
*it != "active" &&
|
||||
*it != "tags" &&
|
||||
*it != "recur" &&
|
||||
*it != "recurrence_indicator" &&
|
||||
*it != "tag_indicator" &&
|
||||
*it != "description_only" &&
|
||||
*it != "description")
|
||||
bad.push_back (*it);
|
||||
|
||||
if (bad.size ())
|
||||
{
|
||||
std::string error;
|
||||
join (error, ", ", bad);
|
||||
throw std::string ("Unrecognized column name: ") + error;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void validSortColumns (
|
||||
const std::vector <std::string>& columns,
|
||||
const std::vector <std::string>& sortColumns)
|
||||
{
|
||||
std::vector <std::string> bad;
|
||||
std::vector <std::string>::const_iterator sc;
|
||||
for (sc = sortColumns.begin (); sc != sortColumns.end (); ++sc)
|
||||
{
|
||||
std::vector <std::string>::const_iterator co;
|
||||
for (co = columns.begin (); co != columns.end (); ++co)
|
||||
if (sc->substr (0, sc->length () - 1) == *co)
|
||||
break;
|
||||
|
||||
if (co == columns.end ())
|
||||
bad.push_back (*sc);
|
||||
}
|
||||
|
||||
if (bad.size ())
|
||||
{
|
||||
std::string error;
|
||||
join (error, ", ", bad);
|
||||
throw std::string ("Sort column is not part of the report: ") + error;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user