Code Cleanup

- 'measure' now accepts unsigned ints for 'minimum' and 'maximum' args.
This commit is contained in:
Scott Kostyshak 2013-01-09 01:48:40 -05:00 committed by Paul Beckingham
parent 40f2afeb8e
commit 19cc9177b9
42 changed files with 54 additions and 55 deletions

View file

@ -136,11 +136,9 @@ std::string ViewTask::render (std::vector <Task>& data, std::vector <int>& seque
break; break;
// Determine minimum and ideal width for this column. // Determine minimum and ideal width for this column.
int min_; unsigned int min;
int ideal_; unsigned int ideal;
(*i)->measure (data[sequence[s]], min_, ideal_); (*i)->measure (data[sequence[s]], min, ideal);
unsigned int min = min_;
unsigned int ideal = ideal_;
if (min > global_min) global_min = min; if (min > global_min) global_min = min;
if (ideal > global_ideal) global_ideal = ideal; if (ideal > global_ideal) global_ideal = ideal;

View file

@ -128,11 +128,9 @@ std::string ViewText::render ()
for (unsigned int row = 0; row < _data.size (); ++row) for (unsigned int row = 0; row < _data.size (); ++row)
{ {
// Determine minimum and ideal width for this column. // Determine minimum and ideal width for this column.
int min_; unsigned int min;
int ideal_; unsigned int ideal;
_columns[col]->measure (_data[row][col], min_, ideal_); _columns[col]->measure (_data[row][col], min, ideal);
unsigned int min = min_;
unsigned int ideal = ideal_;
if (min > global_min) global_min = min; if (min > global_min) global_min = min;
if (ideal > global_ideal) global_ideal = ideal; if (ideal > global_ideal) global_ideal = ideal;

View file

@ -74,7 +74,7 @@ bool ColumnDate::validate (std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnDate::measure (Task& task, int& minimum, int& maximum) void ColumnDate::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
minimum = maximum = 0; minimum = maximum = 0;

View file

@ -42,7 +42,7 @@ public:
~ColumnDate (); ~ColumnDate ();
virtual bool validate (std::string&); virtual bool validate (std::string&);
virtual void measure (Task&, int&, int&); virtual void measure (Task&, unsigned int&, unsigned int&);
virtual void render (std::vector <std::string>&, Task&, int, Color&); virtual void render (std::vector <std::string>&, Task&, int, Color&);
}; };

View file

@ -79,7 +79,7 @@ void ColumnDepends::setStyle (const std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnDepends::measure (Task& task, int& minimum, int& maximum) void ColumnDepends::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
std::vector <Task> blocking; std::vector <Task> blocking;
dependencyGetBlocking (task, blocking); dependencyGetBlocking (task, blocking);
@ -101,7 +101,7 @@ void ColumnDepends::measure (Task& task, int& minimum, int& maximum)
join (all, " ", blocking_ids); join (all, " ", blocking_ids);
maximum = all.length (); maximum = all.length ();
int length; unsigned int length;
for (i = blocking.begin (); i != blocking.end (); ++i) for (i = blocking.begin (); i != blocking.end (); ++i)
{ {
length = format (i->id).length (); length = format (i->id).length ();

View file

@ -43,7 +43,7 @@ public:
bool validate (std::string&); bool validate (std::string&);
void setStyle (const std::string&); void setStyle (const std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -88,7 +88,7 @@ bool ColumnDescription::validate (std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnDescription::measure (Task& task, int& minimum, int& maximum) void ColumnDescription::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
std::string description = task.get (_name); std::string description = task.get (_name);
@ -113,7 +113,7 @@ void ColumnDescription::measure (Task& task, int& minimum, int& maximum)
std::map <std::string, std::string>::iterator i; std::map <std::string, std::string>::iterator i;
for (i = annos.begin (); i != annos.end (); i++) for (i = annos.begin (); i != annos.end (); i++)
{ {
int len = min_anno + 1 + i->second.length (); unsigned int len = min_anno + 1 + i->second.length ();
if (len > maximum) if (len > maximum)
maximum = len; maximum = len;
} }

View file

@ -42,7 +42,7 @@ public:
~ColumnDescription (); ~ColumnDescription ();
bool validate (std::string&); bool validate (std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -74,7 +74,7 @@ void ColumnDue::setStyle (const std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnDue::measure (Task& task, int& minimum, int& maximum) void ColumnDue::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
minimum = maximum = 0; minimum = maximum = 0;

View file

@ -39,7 +39,7 @@ public:
bool validate (std::string&); bool validate (std::string&);
void setStyle (const std::string&); void setStyle (const std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
}; };

View file

@ -62,7 +62,7 @@ bool ColumnID::validate (std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnID::measure (Task& task, int& minimum, int& maximum) void ColumnID::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
int length; int length;

View file

@ -42,7 +42,7 @@ public:
~ColumnID (); ~ColumnID ();
bool validate (std::string&); bool validate (std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -62,7 +62,7 @@ bool ColumnIMask::validate (std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnIMask::measure (Task& task, int& minimum, int& maximum) void ColumnIMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
minimum = maximum = task.get ("imask").length (); minimum = maximum = task.get ("imask").length ();

View file

@ -42,7 +42,7 @@ public:
~ColumnIMask (); ~ColumnIMask ();
bool validate (std::string&); bool validate (std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -62,7 +62,7 @@ bool ColumnMask::validate (std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnMask::measure (Task& task, int& minimum, int& maximum) void ColumnMask::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
minimum = maximum = task.get ("mask").length (); minimum = maximum = task.get ("mask").length ();

View file

@ -42,7 +42,7 @@ public:
~ColumnMask (); ~ColumnMask ();
bool validate (std::string&); bool validate (std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -64,7 +64,7 @@ bool ColumnParent::validate (std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnParent::measure (Task&, int& minimum, int& maximum) void ColumnParent::measure (Task&, unsigned int& minimum, unsigned int& maximum)
{ {
if (_style == "default" || _style == "long") minimum = maximum = 36; if (_style == "default" || _style == "long") minimum = maximum = 36;
else if (_style == "short") minimum = maximum = 8; else if (_style == "short") minimum = maximum = 8;

View file

@ -42,7 +42,7 @@ public:
~ColumnParent (); ~ColumnParent ();
bool validate (std::string&); bool validate (std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -81,7 +81,7 @@ void ColumnPriority::setStyle (const std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnPriority::measure (Task& task, int& minimum, int& maximum) void ColumnPriority::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
std::string priority = task.get (_name); std::string priority = task.get (_name);

View file

@ -43,7 +43,7 @@ public:
bool validate (std::string&); bool validate (std::string&);
void setStyle (const std::string&); void setStyle (const std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -67,7 +67,7 @@ bool ColumnProject::validate (std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnProject::measure (Task& task, int& minimum, int& maximum) void ColumnProject::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
std::string project = task.get (_name); std::string project = task.get (_name);

View file

@ -42,7 +42,7 @@ public:
~ColumnProject (); ~ColumnProject ();
bool validate (std::string&); bool validate (std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -78,7 +78,7 @@ void ColumnRecur::setStyle (const std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnRecur::measure (Task& task, int& minimum, int& maximum) void ColumnRecur::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
if (_style == "default" || if (_style == "default" ||
_style == "duration") _style == "duration")

View file

@ -43,7 +43,7 @@ public:
bool validate (std::string&); bool validate (std::string&);
void setStyle (const std::string&); void setStyle (const std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -74,7 +74,7 @@ void ColumnScheduled::setStyle (const std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnScheduled::measure (Task& task, int& minimum, int& maximum) void ColumnScheduled::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
minimum = maximum = 0; minimum = maximum = 0;

View file

@ -39,7 +39,7 @@ public:
bool validate (std::string&); bool validate (std::string&);
void setStyle (const std::string&); void setStyle (const std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
}; };

View file

@ -69,7 +69,7 @@ void ColumnStart::setStyle (const std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnStart::measure (Task& task, int& minimum, int& maximum) void ColumnStart::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
minimum = maximum = 0; minimum = maximum = 0;

View file

@ -39,7 +39,7 @@ public:
bool validate (std::string&); bool validate (std::string&);
void setStyle (const std::string&); void setStyle (const std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
}; };

View file

@ -73,7 +73,7 @@ void ColumnStatus::setStyle (const std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnStatus::measure (Task& task, int& minimum, int& maximum) void ColumnStatus::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
Task::status status = task.getStatus (); Task::status status = task.getStatus ();

View file

@ -43,7 +43,7 @@ public:
bool validate (std::string&); bool validate (std::string&);
void setStyle (const std::string&); void setStyle (const std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -71,7 +71,7 @@ void ColumnString::setReport (const std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
// //
void ColumnString::measure (const std::string& value, int& minimum, int& maximum) void ColumnString::measure (const std::string& value, unsigned int& minimum, unsigned int& maximum)
{ {
if (_style == "left" || if (_style == "left" ||
_style == "right" || _style == "right" ||

View file

@ -42,7 +42,7 @@ public:
~ColumnString (); ~ColumnString ();
void setReport (const std::string&); void setReport (const std::string&);
void measure (const std::string&, int&, int&); void measure (const std::string&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, const std::string&, int, Color&); void render (std::vector <std::string>&, const std::string&, int, Color&);
private: private:

View file

@ -83,7 +83,7 @@ void ColumnTags::setStyle (const std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnTags::measure (Task& task, int& minimum, int& maximum) void ColumnTags::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
if (_style == "indicator") minimum = maximum = context.config.get ("tag.indicator").length (); if (_style == "indicator") minimum = maximum = context.config.get ("tag.indicator").length ();
@ -101,8 +101,11 @@ void ColumnTags::measure (Task& task, int& minimum, int& maximum)
split (all, tags, ','); split (all, tags, ',');
std::vector <std::string>::iterator i; std::vector <std::string>::iterator i;
for (i = all.begin (); i != all.end (); ++i) for (i = all.begin (); i != all.end (); ++i)
if ((int)i->length () > minimum) {
unsigned int length_ = i->length ();
if (length_ > minimum)
minimum = i->length () + 1; minimum = i->length () + 1;
}
} }
} }
else else

View file

@ -43,7 +43,7 @@ public:
bool validate (std::string&); bool validate (std::string&);
void setStyle (const std::string&); void setStyle (const std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -77,7 +77,7 @@ bool ColumnUDA::validate (std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
// //
void ColumnUDA::measure (Task& task, int& minimum, int& maximum) void ColumnUDA::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
minimum = maximum = 0; minimum = maximum = 0;

View file

@ -42,7 +42,7 @@ public:
~ColumnUDA (); ~ColumnUDA ();
bool validate (std::string&); bool validate (std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
public: public:

View file

@ -64,7 +64,7 @@ bool ColumnUUID::validate (std::string& value)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnUUID::measure (Task&, int& minimum, int& maximum) void ColumnUUID::measure (Task&, unsigned int& minimum, unsigned int& maximum)
{ {
if (_style == "default" || _style == "long") minimum = maximum = 36; if (_style == "default" || _style == "long") minimum = maximum = 36;
else if (_style == "short") minimum = maximum = 8; else if (_style == "short") minimum = maximum = 8;

View file

@ -42,7 +42,7 @@ public:
~ColumnUUID (); ~ColumnUUID ();
bool validate (std::string&); bool validate (std::string&);
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -56,7 +56,7 @@ ColumnUrgency::~ColumnUrgency ()
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// Set the minimum and maximum widths for the value. // Set the minimum and maximum widths for the value.
void ColumnUrgency::measure (Task& task, int& minimum, int& maximum) void ColumnUrgency::measure (Task& task, unsigned int& minimum, unsigned int& maximum)
{ {
if (_style == "default" || if (_style == "default" ||
_style == "real") _style == "real")

View file

@ -41,7 +41,7 @@ public:
ColumnUrgency (); ColumnUrgency ();
~ColumnUrgency (); ~ColumnUrgency ();
void measure (Task&, int&, int&); void measure (Task&, unsigned int&, unsigned int&);
void render (std::vector <std::string>&, Task&, int, Color&); void render (std::vector <std::string>&, Task&, int, Color&);
private: private:

View file

@ -299,14 +299,14 @@ bool Column::validate (std::string& input)
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// No L10N. // No L10N.
void Column::measure (const std::string&, int&, int&) void Column::measure (const std::string&, unsigned int&, unsigned int&)
{ {
throw std::string ("Virtual method Column::measure not overriden."); throw std::string ("Virtual method Column::measure not overriden.");
} }
//////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////
// No L10N. // No L10N.
void Column::measure (Task&, int&, int&) void Column::measure (Task&, unsigned int&, unsigned int&)
{ {
throw std::string ("Virtual method Column::measure not overriden."); throw std::string ("Virtual method Column::measure not overriden.");
} }

View file

@ -60,8 +60,8 @@ public:
virtual void setReport (const std::string& value) { _report = value; } virtual void setReport (const std::string& value) { _report = value; }
virtual bool validate (std::string&); virtual bool validate (std::string&);
virtual void measure (const std::string&, int&, int&); virtual void measure (const std::string&, unsigned int&, unsigned int&);
virtual void measure (Task&, int&, int&); virtual void measure (Task&, unsigned int&, unsigned int&);
virtual void renderHeader (std::vector <std::string>&, int, Color&); virtual void renderHeader (std::vector <std::string>&, int, Color&);
virtual void render (std::vector <std::string>&, const std::string&, int, Color&); virtual void render (std::vector <std::string>&, const std::string&, int, Color&);
virtual void render (std::vector <std::string>&, Task&, int, Color&); virtual void render (std::vector <std::string>&, Task&, int, Color&);