mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Unify coding style
Signed-off-by: Thomas Lauf <thomas.lauf@tngtech.com>
This commit is contained in:
parent
159b8c642a
commit
7b4a234f03
64 changed files with 201 additions and 206 deletions
|
@ -141,7 +141,7 @@ bool AtomicFile::impl::exists () const
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool AtomicFile::impl::open ()
|
||||
{
|
||||
assert (!temp_file._data.empty () && !real_file._data.empty ());
|
||||
assert (! temp_file._data.empty () && ! real_file._data.empty ());
|
||||
return real_file.open ();
|
||||
}
|
||||
|
||||
|
@ -231,7 +231,7 @@ void AtomicFile::impl::append (const std::string& content)
|
|||
{
|
||||
try
|
||||
{
|
||||
if (!is_temp_active)
|
||||
if (! is_temp_active)
|
||||
{
|
||||
is_temp_active = true;
|
||||
|
||||
|
@ -435,7 +435,7 @@ void AtomicFile::read (const Path& path, std::vector <std::string>& lines)
|
|||
// finalize_all - Close / Flush all temporary files and rename to final.
|
||||
void AtomicFile::finalize_all ()
|
||||
{
|
||||
if (!impl::allow_atomics)
|
||||
if (! impl::allow_atomics)
|
||||
{
|
||||
throw std::string {"Unable to update database."};
|
||||
}
|
||||
|
|
28
src/CLI.cpp
28
src/CLI.cpp
|
@ -550,7 +550,7 @@ bool CLI::exactMatch (
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::set<int> CLI::getIds () const
|
||||
std::set <int> CLI::getIds () const
|
||||
{
|
||||
std::set <int> ids;
|
||||
|
||||
|
@ -614,9 +614,9 @@ Duration CLI::getDuration () const
|
|||
|
||||
std::vector <std::string> CLI::getDomReferences () const
|
||||
{
|
||||
std::vector<std::string> references;
|
||||
std::vector <std::string> references;
|
||||
|
||||
for (auto &arg : _args)
|
||||
for (auto& arg : _args)
|
||||
{
|
||||
if (arg.hasTag ("DOM"))
|
||||
{
|
||||
|
@ -722,7 +722,7 @@ Range CLI::getRange (const Range& default_range) const
|
|||
args[0] == "from" &&
|
||||
args[1] == "<date>")
|
||||
{
|
||||
the_range = Range ({Datetime (start), 0});
|
||||
the_range = Range {Datetime (start), 0};
|
||||
}
|
||||
// <date> to/- <date>
|
||||
else if (args.size () == 3 &&
|
||||
|
@ -730,7 +730,7 @@ Range CLI::getRange (const Range& default_range) const
|
|||
(args[1] == "to" || args[1] == "-") &&
|
||||
args[2] == "<date>")
|
||||
{
|
||||
the_range = Range ({Datetime (start), Datetime (end)});
|
||||
the_range = Range {Datetime (start), Datetime (end)};
|
||||
}
|
||||
// from <date> to/- <date>
|
||||
else if (args.size () == 4 &&
|
||||
|
@ -739,7 +739,7 @@ Range CLI::getRange (const Range& default_range) const
|
|||
(args[2] == "to" || args[2] == "-") &&
|
||||
args[3] == "<date>")
|
||||
{
|
||||
the_range = Range ({Datetime (start), Datetime (end)});
|
||||
the_range = Range {Datetime (start), Datetime (end)};
|
||||
}
|
||||
// <date> for <duration>
|
||||
else if (args.size () == 3 &&
|
||||
|
@ -747,7 +747,7 @@ Range CLI::getRange (const Range& default_range) const
|
|||
args[1] == "for" &&
|
||||
args[2] == "<duration>")
|
||||
{
|
||||
the_range = Range ({Datetime (start), Datetime (start) + Duration (duration).toTime_t ()});
|
||||
the_range = Range {Datetime (start), Datetime (start) + Duration (duration).toTime_t ()};
|
||||
}
|
||||
// from <date> for <duration>
|
||||
else if (args.size () == 4 &&
|
||||
|
@ -756,7 +756,7 @@ Range CLI::getRange (const Range& default_range) const
|
|||
args[2] == "for" &&
|
||||
args[3] == "<duration>")
|
||||
{
|
||||
the_range = Range ({Datetime (start), Datetime (start) + Duration (duration).toTime_t ()});
|
||||
the_range = Range {Datetime (start), Datetime (start) + Duration (duration).toTime_t ()};
|
||||
}
|
||||
// <duration> before <date>
|
||||
else if (args.size () == 3 &&
|
||||
|
@ -764,7 +764,7 @@ Range CLI::getRange (const Range& default_range) const
|
|||
args[1] == "before" &&
|
||||
args[2] == "<date>")
|
||||
{
|
||||
the_range = Range ({Datetime (start) - Duration (duration).toTime_t (), Datetime (start)});
|
||||
the_range = Range {Datetime (start) - Duration (duration).toTime_t (), Datetime (start)};
|
||||
}
|
||||
// <duration> after <date>
|
||||
else if (args.size () == 3 &&
|
||||
|
@ -772,27 +772,27 @@ Range CLI::getRange (const Range& default_range) const
|
|||
args[1] == "after" &&
|
||||
args[2] == "<date>")
|
||||
{
|
||||
the_range = Range ({Datetime (start), Datetime (start) + Duration (duration).toTime_t ()});
|
||||
the_range = Range {Datetime (start), Datetime (start) + Duration (duration).toTime_t ()};
|
||||
}
|
||||
// <duration> ago
|
||||
else if (args.size () == 2 &&
|
||||
args[0] == "<duration>" &&
|
||||
args[1] == "ago")
|
||||
{
|
||||
the_range = Range ({now - Duration (duration).toTime_t (), 0});
|
||||
the_range = Range {now - Duration (duration).toTime_t (), 0};
|
||||
}
|
||||
// for <duration>
|
||||
else if (args.size () == 2 &&
|
||||
args[0] == "for" &&
|
||||
args[1] == "<duration>")
|
||||
{
|
||||
the_range = Range ({now - Duration (duration).toTime_t (), now});
|
||||
the_range = Range {now - Duration (duration).toTime_t (), now};
|
||||
}
|
||||
// <duration>
|
||||
else if (args.size () == 1 &&
|
||||
args[0] == "<duration>")
|
||||
{
|
||||
the_range = Range ({now - Duration (duration).toTime_t (), now});
|
||||
the_range = Range {now - Duration (duration).toTime_t (), now};
|
||||
}
|
||||
// :all
|
||||
else if (args.size () == 1 && args[0] == "<all>")
|
||||
|
@ -844,7 +844,7 @@ bool CLI::getComplementaryHint (const std::string& base, const bool default_valu
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool CLI::getHint (const std::string &base, const bool default_value) const
|
||||
bool CLI::getHint (const std::string& base, const bool default_value) const
|
||||
{
|
||||
if (findHint (base))
|
||||
{
|
||||
|
|
|
@ -73,7 +73,7 @@ public:
|
|||
std::set <std::string> getTags () const;
|
||||
std::string getAnnotation() const;
|
||||
Duration getDuration() const;
|
||||
std::vector<std::string> getDomReferences () const;
|
||||
std::vector <std::string> getDomReferences () const;
|
||||
Range getRange (const Range& default_range = {0, 0}) const;
|
||||
std::string dump (const std::string& title = "CLI Parser") const;
|
||||
|
||||
|
@ -86,7 +86,7 @@ private:
|
|||
void identifyFilter ();
|
||||
bool exactMatch (const std::string&, const std::string&) const;
|
||||
|
||||
bool findHint (const std::string &hint) const;
|
||||
bool findHint (const std::string&) const;
|
||||
|
||||
public:
|
||||
std::multimap <std::string, std::string> _entities {};
|
||||
|
|
|
@ -62,9 +62,9 @@ Chart::Chart (const ChartConfig& configuration) :
|
|||
|
||||
std::string Chart::render (
|
||||
const Range& range,
|
||||
const std::vector<Interval> &tracked,
|
||||
const std::vector<Range> &exclusions,
|
||||
const std::map<Datetime, std::string> &holidays)
|
||||
const std::vector <Interval>& tracked,
|
||||
const std::vector <Range>& exclusions,
|
||||
const std::map <Datetime, std::string>& holidays)
|
||||
{
|
||||
// Determine hours shown.
|
||||
auto hour_range = determine_hour_range
|
||||
|
@ -86,13 +86,13 @@ std::string Chart::render (
|
|||
out << '\n';
|
||||
|
||||
// Render the axis.
|
||||
if (!with_internal_axis)
|
||||
if (! with_internal_axis)
|
||||
{
|
||||
out << indent << renderAxis (first_hour, last_hour);
|
||||
}
|
||||
|
||||
// For rendering labels on edge detection.
|
||||
Datetime previous{0};
|
||||
Datetime previous {0};
|
||||
|
||||
// Each day is rendered separately.
|
||||
time_t total_work = 0;
|
||||
|
@ -103,7 +103,7 @@ std::string Chart::render (
|
|||
|
||||
// Add an empty string with no color, to reserve width, so this function
|
||||
// can simply concatenate to lines[i].str ().
|
||||
std::vector<Composite> lines (num_lines);
|
||||
std::vector <Composite> lines (num_lines);
|
||||
for (int i = 0; i < num_lines; ++i)
|
||||
{
|
||||
lines[i].add (std::string (total_width, ' '), 0, Color ());
|
||||
|
@ -112,9 +112,9 @@ std::string Chart::render (
|
|||
renderExclusionBlocks (lines, day, first_hour, last_hour, exclusions);
|
||||
|
||||
time_t work = 0;
|
||||
if (!show_intervals)
|
||||
if (! show_intervals)
|
||||
{
|
||||
for (auto &track : tracked)
|
||||
for (auto& track : tracked)
|
||||
{
|
||||
time_t interval_work = 0;
|
||||
renderInterval (lines, day, track, first_hour, interval_work);
|
||||
|
@ -171,9 +171,9 @@ unsigned long Chart::getIndentSize ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Scan all tracked intervals, looking for the earliest and latest hour into
|
||||
// which an interval extends.
|
||||
std::pair<int, int> Chart::determineHourRange (
|
||||
std::pair <int, int> Chart::determineHourRange (
|
||||
const Range& range,
|
||||
const std::vector<Interval> &tracked)
|
||||
const std::vector <Interval>& tracked)
|
||||
{
|
||||
// If there is no data, show the whole day.
|
||||
if (tracked.empty ())
|
||||
|
@ -207,7 +207,7 @@ std::pair<int, int> Chart::determineHourRange (
|
|||
first_hour = clipped.start.hour ();
|
||||
}
|
||||
|
||||
if (!clipped.is_open () && clipped.end.hour () > last_hour)
|
||||
if (! clipped.is_open () && clipped.end.hour () > last_hour)
|
||||
{
|
||||
last_hour = clipped.end.hour ();
|
||||
}
|
||||
|
@ -251,7 +251,7 @@ std::string Chart::renderAxis (const int first_hour, const int last_hour)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Chart::renderMonth (const Datetime &previous, const Datetime &day)
|
||||
std::string Chart::renderMonth (const Datetime& previous, const Datetime& day)
|
||||
{
|
||||
const auto show_month = previous.month () != day.month ();
|
||||
|
||||
|
@ -264,7 +264,7 @@ std::string Chart::renderMonth (const Datetime &previous, const Datetime &day)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Chart::renderWeek (const Datetime &previous, const Datetime &day)
|
||||
std::string Chart::renderWeek (const Datetime& previous, const Datetime& day)
|
||||
{
|
||||
const auto show_week = previous.week () != day.week ();
|
||||
|
||||
|
@ -277,7 +277,7 @@ std::string Chart::renderWeek (const Datetime &previous, const Datetime &day)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Chart::renderWeekday (Datetime &day, const Color &color)
|
||||
std::string Chart::renderWeekday (Datetime& day, const Color& color)
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
|
@ -288,7 +288,7 @@ std::string Chart::renderWeekday (Datetime &day, const Color &color)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Chart::renderDay (Datetime &day, const Color &color)
|
||||
std::string Chart::renderDay (Datetime& day, const Color& color)
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
|
@ -300,15 +300,15 @@ std::string Chart::renderDay (Datetime &day, const Color &color)
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
Color Chart::getDayColor (
|
||||
const Datetime &day,
|
||||
const std::map <Datetime, std::string> &holidays)
|
||||
const Datetime& day,
|
||||
const std::map <Datetime, std::string>& holidays)
|
||||
{
|
||||
if (day.sameDay (reference_datetime))
|
||||
{
|
||||
return color_today;
|
||||
}
|
||||
|
||||
for (auto &entry : holidays)
|
||||
for (auto& entry : holidays)
|
||||
{
|
||||
if (day.sameDay (entry.first))
|
||||
{
|
||||
|
@ -346,7 +346,7 @@ std::string Chart::renderTotal (time_t work)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Chart::renderSubTotal (
|
||||
time_t total_work,
|
||||
const std::string &padding)
|
||||
const std::string& padding)
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
|
@ -366,8 +366,8 @@ std::string Chart::renderSubTotal (
|
|||
}
|
||||
|
||||
void Chart::renderExclusionBlocks (
|
||||
std::vector<Composite> &lines,
|
||||
const Datetime &day,
|
||||
std::vector <Composite>& lines,
|
||||
const Datetime& day,
|
||||
int first_hour,
|
||||
int last_hour,
|
||||
const std::vector <Range>& exclusions)
|
||||
|
@ -399,7 +399,7 @@ void Chart::renderExclusionBlocks (
|
|||
int width = end_block - start_block;
|
||||
std::string block (width, ' ');
|
||||
|
||||
for (auto &line : lines)
|
||||
for (auto& line : lines)
|
||||
{
|
||||
line.add (block, offset, color_exclusion);
|
||||
}
|
||||
|
@ -420,15 +420,15 @@ void Chart::renderExclusionBlocks (
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Chart::renderInterval (
|
||||
std::vector<Composite> &lines,
|
||||
const Datetime &day,
|
||||
const Interval &track,
|
||||
std::vector <Composite>& lines,
|
||||
const Datetime& day,
|
||||
const Interval& track,
|
||||
const int first_hour,
|
||||
time_t &work)
|
||||
time_t& work)
|
||||
{
|
||||
// Ignore any track that doesn't overlap with day.
|
||||
auto day_range = getFullDay (day);
|
||||
if (!day_range.overlaps (track) || (track.is_open () && day > reference_datetime))
|
||||
if (! day_range.overlaps (track) || (track.is_open () && day > reference_datetime))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -476,9 +476,9 @@ void Chart::renderInterval (
|
|||
label = format ("@{1}", track.id);
|
||||
}
|
||||
|
||||
for (auto &tag : track.tags ())
|
||||
for (auto& tag : track.tags ())
|
||||
{
|
||||
if (!label.empty ())
|
||||
if (! label.empty ())
|
||||
{
|
||||
label += ' ';
|
||||
}
|
||||
|
@ -490,7 +490,7 @@ void Chart::renderInterval (
|
|||
|
||||
if (width)
|
||||
{
|
||||
std::vector<std::string> text_lines;
|
||||
std::vector <std::string> text_lines;
|
||||
|
||||
// --
|
||||
// The hang/memory consumption in #309 is due to a bug in libshared's wrapText
|
||||
|
@ -531,11 +531,11 @@ void Chart::renderInterval (
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Chart::renderHolidays (const std::map<Datetime, std::string> &holidays)
|
||||
std::string Chart::renderHolidays (const std::map <Datetime, std::string>& holidays)
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
for (auto &entry : holidays)
|
||||
for (auto& entry : holidays)
|
||||
{
|
||||
out << entry.first.toString ("Y-M-D")
|
||||
<< " "
|
||||
|
@ -548,15 +548,15 @@ std::string Chart::renderHolidays (const std::map<Datetime, std::string> &holida
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Chart::renderSummary (
|
||||
const std::string &indent,
|
||||
const std::string& indent,
|
||||
const Range& range,
|
||||
const std::vector<Range> &exclusions,
|
||||
const std::vector<Interval> &tracked)
|
||||
const std::vector <Range>& exclusions,
|
||||
const std::vector <Interval>& tracked)
|
||||
{
|
||||
std::stringstream out;
|
||||
time_t total_unavailable = 0;
|
||||
|
||||
for (auto &exclusion : exclusions)
|
||||
for (auto& exclusion : exclusions)
|
||||
{
|
||||
if (range.overlaps (exclusion))
|
||||
{
|
||||
|
@ -566,9 +566,9 @@ std::string Chart::renderSummary (
|
|||
|
||||
time_t total_worked = 0;
|
||||
|
||||
if (!show_intervals)
|
||||
if (! show_intervals)
|
||||
{
|
||||
for (auto &interval : tracked)
|
||||
for (auto& interval : tracked)
|
||||
{
|
||||
if (range.overlaps (interval))
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@ private:
|
|||
std::string renderWeekday (Datetime&, const Color&);
|
||||
|
||||
void renderExclusionBlocks (std::vector <Composite>&, const Datetime&, int, int, const std::vector <Range>&);
|
||||
void renderInterval (std::vector<Composite>&, const Datetime&, const Interval&, int, time_t&);
|
||||
void renderInterval (std::vector <Composite>&, const Datetime&, const Interval&, int, time_t&);
|
||||
|
||||
unsigned long getIndentSize ();
|
||||
|
||||
|
@ -79,7 +79,7 @@ private:
|
|||
const Color color_holiday;
|
||||
const Color color_label;
|
||||
const Color color_exclusion;
|
||||
const std::map<std::string, Color> tag_colors;
|
||||
const std::map <std::string, Color> tag_colors;
|
||||
|
||||
const int cell_width;
|
||||
const int reference_hour;
|
||||
|
|
|
@ -53,7 +53,7 @@ public:
|
|||
Color color_holiday;
|
||||
Color color_label;
|
||||
Color color_exclusion;
|
||||
std::map<std::string, Color> tag_colors;
|
||||
std::map <std::string, Color> tag_colors;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -41,7 +41,7 @@ Database::iterator::iterator (files_iterator fbegin, files_iterator fend) :
|
|||
{
|
||||
if (files_end != files_it)
|
||||
{
|
||||
auto &lines = files_it->allLines ();
|
||||
auto& lines = files_it->allLines ();
|
||||
lines_it = lines.rbegin ();
|
||||
lines_end = lines.rend ();
|
||||
while ((lines_it == lines_end) && (files_it != files_end))
|
||||
|
@ -49,7 +49,7 @@ Database::iterator::iterator (files_iterator fbegin, files_iterator fend) :
|
|||
++files_it;
|
||||
if (files_it != files_end)
|
||||
{
|
||||
auto &lines = files_it->allLines ();
|
||||
auto& lines = files_it->allLines ();
|
||||
lines_it = lines.rbegin ();
|
||||
lines_end = lines.rend ();
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ Database::iterator& Database::iterator::operator++ ()
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Database::iterator::operator== (const iterator &other) const
|
||||
bool Database::iterator::operator== (const iterator& other) const
|
||||
{
|
||||
return (other.files_it == other.files_end) ?
|
||||
files_it == files_end :
|
||||
|
@ -96,7 +96,7 @@ bool Database::iterator::operator== (const iterator &other) const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Database::iterator::operator!= (const iterator &other) const
|
||||
bool Database::iterator::operator!= (const iterator& other) const
|
||||
{
|
||||
return ! (*this == other);
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ Database::reverse_iterator::reverse_iterator (files_iterator fbegin,
|
|||
++files_it;
|
||||
if (files_it != files_end)
|
||||
{
|
||||
auto &lines = files_it->allLines ();
|
||||
auto& lines = files_it->allLines ();
|
||||
lines_it = lines.begin ();
|
||||
lines_end = lines.end ();
|
||||
}
|
||||
|
@ -342,12 +342,12 @@ void Database::deleteInterval (const Interval& interval)
|
|||
// Interval belongs in a different file.
|
||||
void Database::modifyInterval (const Interval& from, const Interval& to, bool verbose)
|
||||
{
|
||||
if (!from.empty ())
|
||||
if (! from.empty ())
|
||||
{
|
||||
deleteInterval (from);
|
||||
}
|
||||
|
||||
if (!to.empty ())
|
||||
if (! to.empty ())
|
||||
{
|
||||
addInterval (to, verbose);
|
||||
}
|
||||
|
@ -468,7 +468,7 @@ void Database::initializeTagDatabase ()
|
|||
{
|
||||
try
|
||||
{
|
||||
std::unique_ptr <json::object> json (dynamic_cast <json::object *>(json::parse (content)));
|
||||
std::unique_ptr <json::object> json (dynamic_cast <json::object*> (json::parse (content)));
|
||||
|
||||
if (content.empty () || (json == nullptr))
|
||||
{
|
||||
|
@ -486,7 +486,7 @@ void Database::initializeTagDatabase ()
|
|||
throw format ("Failed to find \"count\" member for tag \"{1}\" in tags database.", key);
|
||||
}
|
||||
|
||||
auto number = dynamic_cast<json::number *> (iter->second);
|
||||
auto number = dynamic_cast <json::number*> (iter->second);
|
||||
_tagInfoDatabase.add (key, TagInfo{(unsigned int) number->_dvalue});
|
||||
}
|
||||
|
||||
|
@ -515,7 +515,7 @@ void Database::initializeTagDatabase ()
|
|||
return;
|
||||
}
|
||||
|
||||
if (!exists)
|
||||
if (! exists)
|
||||
{
|
||||
std::cout << "Tags database does not exist. ";
|
||||
}
|
||||
|
|
|
@ -103,7 +103,7 @@ public:
|
|||
|
||||
void addInterval (const Interval&, bool verbose);
|
||||
void deleteInterval (const Interval&);
|
||||
void modifyInterval (const Interval&, const Interval &, bool verbose);
|
||||
void modifyInterval (const Interval&, const Interval&, bool verbose);
|
||||
|
||||
std::string dump () const;
|
||||
|
||||
|
|
|
@ -151,7 +151,7 @@ void Datafile::commit ()
|
|||
if (_dirty)
|
||||
{
|
||||
AtomicFile file (_file);
|
||||
if (!_lines.empty ())
|
||||
if (! _lines.empty ())
|
||||
{
|
||||
if (file.open ())
|
||||
{
|
||||
|
|
|
@ -1179,7 +1179,7 @@ bool DatetimeParser::initializeOrdinal (Pig& pig)
|
|||
y++;
|
||||
}
|
||||
}
|
||||
else if (!Datetime::timeRelative && (d < number && number <= Datetime::daysInMonth (y, m)))
|
||||
else if (! Datetime::timeRelative && (d < number && number <= Datetime::daysInMonth (y, m)))
|
||||
{
|
||||
if (--m < 1)
|
||||
{
|
||||
|
|
|
@ -53,7 +53,7 @@ Table ExtensionsTable::Builder::build ()
|
|||
table.add ("Extension", true);
|
||||
table.add ("Status", true);
|
||||
|
||||
for (auto &ext: _extensions.all ())
|
||||
for (auto& ext: _extensions.all ())
|
||||
{
|
||||
File program (ext);
|
||||
|
||||
|
@ -64,11 +64,11 @@ Table ExtensionsTable::Builder::build ()
|
|||
// Show extension status.
|
||||
std::string status;
|
||||
|
||||
if (!program.readable ())
|
||||
if (! program.readable ())
|
||||
{
|
||||
status = "Not readable";
|
||||
}
|
||||
else if (!program.executable ())
|
||||
else if (! program.executable ())
|
||||
{
|
||||
status = "No executable";
|
||||
}
|
||||
|
|
|
@ -35,7 +35,7 @@ class ExtensionsTable
|
|||
class Builder
|
||||
{
|
||||
public:
|
||||
Builder& withExtensions (const Extensions &);
|
||||
Builder& withExtensions (const Extensions&);
|
||||
|
||||
Table build ();
|
||||
|
||||
|
|
|
@ -36,14 +36,14 @@ GapsTable::Builder GapsTable::builder ()
|
|||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
GapsTable::Builder& GapsTable::Builder::withRange (const Range &range)
|
||||
GapsTable::Builder& GapsTable::Builder::withRange (const Range& range)
|
||||
{
|
||||
_range = range;
|
||||
return *this;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
GapsTable::Builder& GapsTable::Builder::withIntervals (const std::vector <Range> &intervals)
|
||||
GapsTable::Builder& GapsTable::Builder::withIntervals (const std::vector <Range>& intervals)
|
||||
{
|
||||
_intervals = intervals;
|
||||
return *this;
|
||||
|
@ -68,13 +68,14 @@ Table GapsTable::Builder::build ()
|
|||
// Each day is rendered separately.
|
||||
time_t grand_total = 0;
|
||||
Datetime previous;
|
||||
|
||||
for (Datetime day = _range.start; day < _range.end; day++)
|
||||
{
|
||||
auto day_range = getFullDay (day);
|
||||
time_t daily_total = 0;
|
||||
|
||||
int row = -1;
|
||||
for (auto &gap: subset (day_range, _intervals))
|
||||
|
||||
for (auto& gap: subset (day_range, _intervals))
|
||||
{
|
||||
row = table.addRow ();
|
||||
|
||||
|
@ -88,6 +89,7 @@ Table GapsTable::Builder::build ()
|
|||
|
||||
// Intersect track with day.
|
||||
auto today = day_range.intersect (gap);
|
||||
|
||||
if (gap.is_open ())
|
||||
{
|
||||
today.end = Datetime ();
|
||||
|
|
|
@ -37,8 +37,8 @@ class GapsTable
|
|||
class Builder
|
||||
{
|
||||
public:
|
||||
Builder& withRange (const Range &);
|
||||
Builder& withIntervals (const std::vector <Range> &);
|
||||
Builder& withRange (const Range&);
|
||||
Builder& withIntervals (const std::vector <Range>&);
|
||||
|
||||
Table build ();
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ void Interval::tag (const std::string& tag)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Interval::tag (const std::set<std::string>& tags)
|
||||
void Interval::tag (const std::set <std::string>& tags)
|
||||
{
|
||||
_tags.insert (tags.begin (), tags.end ());
|
||||
}
|
||||
|
@ -93,7 +93,7 @@ void Interval::untag (const std::string& tag)
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Interval::untag (const std::set <std::string>& tags)
|
||||
{
|
||||
std::set<std::string> updated;
|
||||
std::set <std::string> updated;
|
||||
|
||||
std::set_difference (
|
||||
_tags.begin (), _tags.end (),
|
||||
|
@ -144,7 +144,7 @@ std::string Interval::json () const
|
|||
std::stringstream out;
|
||||
out << "{";
|
||||
|
||||
if (!empty ())
|
||||
if (! empty ())
|
||||
{
|
||||
out << "\"id\":" << id;
|
||||
|
||||
|
@ -158,10 +158,10 @@ std::string Interval::json () const
|
|||
out << ",\"end\":\"" << end.toISO () << "\"";
|
||||
}
|
||||
|
||||
if (!_tags.empty ())
|
||||
if (! _tags.empty ())
|
||||
{
|
||||
std::string tags;
|
||||
for (auto &tag : _tags)
|
||||
for (auto& tag : _tags)
|
||||
{
|
||||
if (tags[0])
|
||||
tags += ',';
|
||||
|
@ -174,7 +174,7 @@ std::string Interval::json () const
|
|||
<< ']';
|
||||
}
|
||||
|
||||
if (!annotation.empty ())
|
||||
if (! annotation.empty ())
|
||||
{
|
||||
out << ",\"annotation\":\"" << json::encode (annotation) << "\"";
|
||||
}
|
||||
|
|
|
@ -46,9 +46,9 @@ public:
|
|||
bool hasTag (const std::string&) const;
|
||||
const std::set <std::string>& tags () const;
|
||||
void tag (const std::string&);
|
||||
void tag (const std::set<std::string>&);
|
||||
void tag (const std::set <std::string>&);
|
||||
void untag (const std::string&);
|
||||
void untag (const std::set<std::string>&);
|
||||
void untag (const std::set <std::string>&);
|
||||
void clearTags ();
|
||||
|
||||
void setRange (const Range& range);
|
||||
|
|
|
@ -64,7 +64,7 @@ Interval IntervalFactory::fromSerialization (const std::string& line)
|
|||
std::vector <std::string> tokens = tokenizeSerialization (line);
|
||||
|
||||
// Minimal requirement 'inc'.
|
||||
if (!tokens.empty () && tokens[0] == "inc")
|
||||
if (! tokens.empty () && tokens[0] == "inc")
|
||||
{
|
||||
Interval interval = Interval ();
|
||||
|
||||
|
@ -125,9 +125,9 @@ Interval IntervalFactory::fromJson (const std::string& jsonString)
|
|||
{
|
||||
Interval interval = Interval ();
|
||||
|
||||
if (!jsonString.empty ())
|
||||
if (! jsonString.empty ())
|
||||
{
|
||||
std::unique_ptr <json::object> json (dynamic_cast <json::object *> (json::parse (jsonString)));
|
||||
std::unique_ptr <json::object> json (dynamic_cast <json::object*> (json::parse (jsonString)));
|
||||
|
||||
json::array* tags = (json::array*) json->_data["tags"];
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ bool IntervalFilterAllInRange::accepts (const Interval& interval)
|
|||
return false;
|
||||
}
|
||||
|
||||
if ((!_range.is_started() && !_range.is_ended()) || interval.intersects (_range))
|
||||
if ((! _range.is_started() && ! _range.is_ended()) || interval.intersects (_range))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ public:
|
|||
|
||||
private:
|
||||
const std::set <int> _ids {};
|
||||
std::set<int>::iterator _id_it;
|
||||
std::set<int>::iterator _id_end;
|
||||
std::set <int>::iterator _id_it;
|
||||
std::set <int>::iterator _id_end;
|
||||
};
|
||||
|
||||
#endif //INCLUDE_INTERVALFILTERALLWITHIDS
|
||||
|
|
|
@ -26,10 +26,10 @@
|
|||
|
||||
#include <IntervalFilterAndGroup.h>
|
||||
|
||||
IntervalFilterAndGroup::IntervalFilterAndGroup (std::vector <std::shared_ptr<IntervalFilter>> filters) : _filters (std::move (filters))
|
||||
IntervalFilterAndGroup::IntervalFilterAndGroup (std::vector <std::shared_ptr <IntervalFilter>> filters) : _filters (std::move (filters))
|
||||
{}
|
||||
|
||||
bool IntervalFilterAndGroup::accepts (const Interval &interval)
|
||||
bool IntervalFilterAndGroup::accepts (const Interval& interval)
|
||||
{
|
||||
if (is_done ())
|
||||
{
|
||||
|
|
|
@ -33,13 +33,13 @@
|
|||
class IntervalFilterAndGroup : public IntervalFilter
|
||||
{
|
||||
public:
|
||||
explicit IntervalFilterAndGroup (std::vector <std::shared_ptr<IntervalFilter>> filters);
|
||||
explicit IntervalFilterAndGroup (std::vector <std::shared_ptr <IntervalFilter>> filters);
|
||||
|
||||
bool accepts (const Interval&) final;
|
||||
void reset () override;
|
||||
|
||||
private:
|
||||
const std::vector<std::shared_ptr<IntervalFilter>> _filters = {};
|
||||
const std::vector <std::shared_ptr <IntervalFilter>> _filters = {};
|
||||
};
|
||||
|
||||
#endif //INCLUDED_INTERVALFILTERANDGROUP
|
||||
|
|
|
@ -39,7 +39,7 @@ bool Journal::enabled () const
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
std::vector<Transaction> loadJournal (AtomicFile& undo)
|
||||
std::vector <Transaction> loadJournal (AtomicFile& undo)
|
||||
{
|
||||
std::vector <std::string> read_lines;
|
||||
undo.read (read_lines);
|
||||
|
@ -88,7 +88,7 @@ void Journal::startTransaction ()
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Journal::endTransaction ()
|
||||
{
|
||||
if (!enabled ())
|
||||
if (! enabled ())
|
||||
{
|
||||
assert (_currentTransaction == nullptr);
|
||||
return;
|
||||
|
@ -149,9 +149,9 @@ void Journal::recordIntervalAction (const std::string& before, const std::strin
|
|||
// Actions are only recorded if a transaction is open
|
||||
//
|
||||
void Journal::recordUndoAction (
|
||||
const std::string &type,
|
||||
const std::string &before,
|
||||
const std::string &after)
|
||||
const std::string& type,
|
||||
const std::string& before,
|
||||
const std::string& after)
|
||||
{
|
||||
if (enabled () && _currentTransaction != nullptr)
|
||||
{
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
Transaction popLastTransaction();
|
||||
|
||||
private:
|
||||
void recordUndoAction (const std::string &, const std::string &, const std::string &);
|
||||
void recordUndoAction (const std::string&, const std::string&, const std::string&);
|
||||
|
||||
std::string _location {};
|
||||
std::shared_ptr <Transaction> _currentTransaction = nullptr;
|
||||
|
|
|
@ -99,7 +99,7 @@ bool Range::is_empty () const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Range::contains (const Datetime &datetime) const
|
||||
bool Range::contains (const Datetime& datetime) const
|
||||
{
|
||||
return (! is_started () || start < datetime) &&
|
||||
(! is_ended () || datetime < end);
|
||||
|
@ -130,7 +130,7 @@ bool Range::contains (const Datetime &datetime) const
|
|||
// H [...
|
||||
// I [...
|
||||
//
|
||||
bool Range::overlaps (const Range &other) const
|
||||
bool Range::overlaps (const Range& other) const
|
||||
{
|
||||
if (! is_started () || ! other.is_started ())
|
||||
return false;
|
||||
|
@ -234,7 +234,7 @@ Range Range::intersect (const Range& other) const
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
bool Range::intersects (const Range &other) const
|
||||
bool Range::intersects (const Range& other) const
|
||||
{
|
||||
if (overlaps (other)) {
|
||||
return true;
|
||||
|
|
|
@ -50,10 +50,10 @@ public:
|
|||
|
||||
bool contains (const Datetime&) const;
|
||||
|
||||
bool overlaps (const Range &) const;
|
||||
bool overlaps (const Range&) const;
|
||||
bool encloses (const Range&) const;
|
||||
bool startsWithin (const Range &) const;
|
||||
bool endsWithin (const Range &) const;
|
||||
bool startsWithin (const Range&) const;
|
||||
bool endsWithin (const Range&) const;
|
||||
Range intersect (const Range&) const;
|
||||
bool intersects (const Range&) const;
|
||||
Range combine (const Range&) const;
|
||||
|
|
|
@ -150,7 +150,7 @@ bool Rules::has (const std::string& key) const
|
|||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Return the configuration value given the specified key.
|
||||
std::string Rules::get (const std::string &key, const std::string &defaultValue) const
|
||||
std::string Rules::get (const std::string& key, const std::string& defaultValue) const
|
||||
{
|
||||
auto found = _settings.find (key);
|
||||
|
||||
|
@ -429,7 +429,7 @@ void Rules::parseRuleSettings (
|
|||
// If indent decreased.
|
||||
else if (indent < indents.back ())
|
||||
{
|
||||
while (!indents.empty () && indent != indents.back ())
|
||||
while (! indents.empty () && indent != indents.back ())
|
||||
{
|
||||
indents.pop_back ();
|
||||
hierarchy.pop_back ();
|
||||
|
|
25
src/Rules.h
25
src/Rules.h
|
@ -42,32 +42,25 @@ public:
|
|||
std::string file () const;
|
||||
|
||||
bool has (const std::string&) const;
|
||||
std::string get (const std::string &key, const std::string &defaultValue = "") const;
|
||||
int getInteger (const std::string&, int defaultValue = 0) const;
|
||||
std::string get (const std::string&, const std::string& = "") const;
|
||||
int getInteger (const std::string&, int = 0) const;
|
||||
double getReal (const std::string&) const;
|
||||
bool getBoolean (const std::string&, bool defaultValue = false) const;
|
||||
bool getBoolean (const std::string&, bool = false) const;
|
||||
|
||||
void set (const std::string&, const int);
|
||||
void set (const std::string&, const double);
|
||||
void set (const std::string&, int);
|
||||
void set (const std::string&, double);
|
||||
void set (const std::string&, const std::string&);
|
||||
|
||||
std::vector <std::string> all (const std::string& stem = "") const;
|
||||
std::vector <std::string> all (const std::string& = "") const;
|
||||
bool isRuleType (const std::string&) const;
|
||||
|
||||
std::string dump () const;
|
||||
|
||||
static bool setConfigVariable (Journal& journal,
|
||||
const Rules& rules,
|
||||
std::string name,
|
||||
std::string value,
|
||||
bool confirmation /* = false */);
|
||||
static int unsetConfigVariable (Journal& journal,
|
||||
const Rules& rules,
|
||||
std::string name,
|
||||
bool confirmation /* = false */);
|
||||
static bool setConfigVariable (Journal&, const Rules&, std::string, std::string, bool confirmation);
|
||||
static int unsetConfigVariable (Journal&, const Rules&, std::string, bool confirmation);
|
||||
|
||||
private:
|
||||
void parse (const std::string&, int next = 1);
|
||||
void parse (const std::string&, int = 1);
|
||||
void parseRule (const std::string&);
|
||||
void parseRuleSettings (const std::vector <std::string>&);
|
||||
|
||||
|
|
|
@ -104,7 +104,7 @@ SummaryTable::Builder& SummaryTable::Builder::withRange (const Range& range)
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
SummaryTable::Builder & SummaryTable::Builder::withIntervals (const std::vector<Interval>& tracked)
|
||||
SummaryTable::Builder & SummaryTable::Builder::withIntervals (const std::vector <Interval>& tracked)
|
||||
{
|
||||
_tracked = tracked;
|
||||
return *this;
|
||||
|
|
|
@ -38,9 +38,9 @@ class SummaryTable
|
|||
class Builder
|
||||
{
|
||||
public:
|
||||
Builder& withWeekFormat (const std::string &);
|
||||
Builder& withDateFormat (const std::string &);
|
||||
Builder& withTimeFormat (const std::string &);
|
||||
Builder& withWeekFormat (const std::string&);
|
||||
Builder& withDateFormat (const std::string&);
|
||||
Builder& withTimeFormat (const std::string&);
|
||||
|
||||
Builder& withAnnotations (bool);
|
||||
Builder& withIds (bool, Color);
|
||||
|
@ -48,7 +48,7 @@ class SummaryTable
|
|||
Builder& withWeeks (bool);
|
||||
Builder& withWeekdays (bool);
|
||||
|
||||
Builder& withRange (const Range &);
|
||||
Builder& withRange (const Range&);
|
||||
Builder& withIntervals (const std::vector <Interval>&);
|
||||
|
||||
Table build ();
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
class TagDescription
|
||||
{
|
||||
public:
|
||||
TagDescription (std::string , Color, std::string );
|
||||
TagDescription (std::string , Color, std::string);
|
||||
|
||||
std::string name;
|
||||
Color color;
|
||||
|
|
|
@ -34,7 +34,7 @@ void Transaction::addUndoAction (
|
|||
_actions.emplace_back (type, before, after);
|
||||
}
|
||||
|
||||
std::vector<UndoAction> Transaction::getActions () const
|
||||
std::vector <UndoAction> Transaction::getActions () const
|
||||
{
|
||||
return _actions;
|
||||
}
|
||||
|
|
|
@ -37,10 +37,10 @@ public:
|
|||
|
||||
std::string toString() const;
|
||||
|
||||
std::vector<UndoAction> getActions () const;
|
||||
std::vector <UndoAction> getActions () const;
|
||||
|
||||
private:
|
||||
std::vector<UndoAction> _actions {};
|
||||
std::vector <UndoAction> _actions {};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -29,19 +29,19 @@
|
|||
|
||||
void TransactionsFactory::parseLine (const std::string& line)
|
||||
{
|
||||
if (!line.compare (0, 4, "txn:"))
|
||||
if (! line.compare (0, 4, "txn:"))
|
||||
{
|
||||
_transactions.emplace_back ();
|
||||
}
|
||||
else if (!line.compare (0, 7, " type:"))
|
||||
else if (! line.compare (0, 7, " type:"))
|
||||
{
|
||||
_type = line.substr (8, line.size ());
|
||||
}
|
||||
else if (!line.compare (0, 9, " before:"))
|
||||
else if (! line.compare (0, 9, " before:"))
|
||||
{
|
||||
_before = line.substr (10, line.size ());
|
||||
}
|
||||
else if (!line.compare (0, 8, " after:"))
|
||||
else if (! line.compare (0, 8, " after:"))
|
||||
{
|
||||
_after = line.substr (9, line.size ());
|
||||
_transactions.back ().addUndoAction (_type, _before, _after);
|
||||
|
@ -52,7 +52,7 @@ void TransactionsFactory::parseLine (const std::string& line)
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<Transaction> TransactionsFactory::get ()
|
||||
std::vector <Transaction> TransactionsFactory::get ()
|
||||
{
|
||||
return _transactions;
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ int CmdAnnotate (
|
|||
{
|
||||
throw std::string ("There is no active time tracking.");
|
||||
}
|
||||
else if (!intervals.at (0).is_open ())
|
||||
else if (! intervals.at (0).is_open ())
|
||||
{
|
||||
throw std::string ("At least one ID must be specified. See 'timew help annotate'.");
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ int CmdAnnotate (
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
if (! found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ int CmdCancel (
|
|||
// If there is an open interval, cancel it by deleting it
|
||||
auto latest = getLatestInterval (database);
|
||||
|
||||
if (!latest.is_open ())
|
||||
if (! latest.is_open ())
|
||||
{
|
||||
if (verbose)
|
||||
std::cout << "There is no active time tracking.\n";
|
||||
|
|
|
@ -175,7 +175,7 @@ std::map <Datetime, std::string> createHolidayMap (Rules& rules, Range& range)
|
|||
std::map <Datetime, std::string> mapping;
|
||||
auto holidays = rules.all ("holidays.");
|
||||
|
||||
for (auto &entry : holidays)
|
||||
for (auto& entry : holidays)
|
||||
{
|
||||
auto first_dot = entry.find ('.');
|
||||
auto last_dot = entry.rfind ('.');
|
||||
|
|
|
@ -87,7 +87,7 @@ int CmdConfig (
|
|||
|
||||
change = Rules::setConfigVariable (journal, rules, name, value, confirmation);
|
||||
|
||||
if (!change)
|
||||
if (! change)
|
||||
{
|
||||
rc = 1;
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ int CmdConfig (
|
|||
found = true;
|
||||
}
|
||||
|
||||
if (!found)
|
||||
if (! found)
|
||||
{
|
||||
throw format ("No entry named '{1}' found.", name);
|
||||
}
|
||||
|
|
|
@ -75,7 +75,7 @@ int CmdContinue (
|
|||
throw format ("ID '@{1}' does not correspond to any tracking.", *ids.begin ());
|
||||
}
|
||||
}
|
||||
else if (!tags.empty ())
|
||||
else if (! tags.empty ())
|
||||
{
|
||||
IntervalFilterFirstOf filtering {std::make_shared <IntervalFilterAllWithTags> (tags)};
|
||||
intervals = getTracked (database, rules, filtering);
|
||||
|
|
|
@ -40,7 +40,7 @@ int CmdDefault (Rules& rules, Database& database)
|
|||
IntervalFilterFirstOf filtering (std::make_shared <IntervalFilterAllInRange> (Range {}));
|
||||
auto latest = getTracked (database, rules, filtering);
|
||||
|
||||
if (!latest.empty () && latest.at (0).is_open ())
|
||||
if (! latest.empty () && latest.at (0).is_open ())
|
||||
{
|
||||
if (verbose)
|
||||
{
|
||||
|
|
|
@ -66,7 +66,7 @@ int CmdDelete (
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
if (! found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ int CmdHelpUsage (const Extensions& extensions)
|
|||
<< " timew week [<interval>] [<tag> ...]\n"
|
||||
<< '\n';
|
||||
|
||||
if (!extensions.all ().empty ())
|
||||
if (! extensions.all ().empty ())
|
||||
{
|
||||
std::cout << "Extensions (extensions do not provide help):\n";
|
||||
|
||||
|
|
|
@ -69,7 +69,7 @@ int CmdJoin (
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
if (! found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ int CmdLengthen (
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
if (! found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
|
|
|
@ -109,7 +109,7 @@ int CmdModify (
|
|||
break;
|
||||
}
|
||||
|
||||
if (!modified.is_open () && (modified.start > modified.end))
|
||||
if (! modified.is_open () && (modified.start > modified.end))
|
||||
{
|
||||
throw format ("Cannot modify interval @{1} where start is after end.", id);
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ int CmdMove (
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
if (! found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ static std::string findExtension (
|
|||
return "";
|
||||
}
|
||||
|
||||
std::string basename (const std::string &script_path)
|
||||
std::string basename (const std::string& script_path)
|
||||
{
|
||||
const auto lastSlash = script_path.find_last_of ('/');
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ int CmdResize (
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
if (! found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ int CmdRetag (
|
|||
|
||||
// Gather IDs and TAGs.
|
||||
std::set <int> ids = cli.getIds ();
|
||||
std::set<std::string> tags = cli.getTags ();
|
||||
std::set <std::string> tags = cli.getTags ();
|
||||
|
||||
if (tags.empty ())
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ int CmdRetag (
|
|||
{
|
||||
throw std::string ("There is no active time tracking.");
|
||||
}
|
||||
else if (!latest.at (0).is_open ())
|
||||
else if (! latest.at (0).is_open ())
|
||||
{
|
||||
throw std::string ("At least one ID must be specified. See 'timew help retag'.");
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ int CmdRetag (
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
if (! found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
|
|
|
@ -69,7 +69,7 @@ int CmdShorten (
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
if (! found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
|
|
|
@ -66,7 +66,7 @@ int CmdSplit (
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
if (! found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
|
|
|
@ -123,7 +123,7 @@ int CmdSummary (
|
|||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string renderHolidays (const std::map<Datetime, std::string>& holidays)
|
||||
std::string renderHolidays (const std::map <Datetime, std::string>& holidays)
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ int CmdTag (
|
|||
|
||||
// Gather IDs and TAGs.
|
||||
std::set <int> ids = cli.getIds ();
|
||||
std::set<std::string> tags = cli.getTags ();
|
||||
std::set <std::string> tags = cli.getTags ();
|
||||
|
||||
if (tags.empty ())
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ int CmdTag (
|
|||
{
|
||||
throw std::string ("There is no active time tracking.");
|
||||
}
|
||||
else if (!latest.at (0).is_open ())
|
||||
else if (! latest.at (0).is_open ())
|
||||
{
|
||||
throw std::string ("At least one ID must be specified. See 'timew help tag'.");
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ int CmdTag (
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
if (! found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ static void undoIntervalAction(UndoAction& action, Database& database)
|
|||
database.modifyInterval (after, before, false);
|
||||
}
|
||||
|
||||
static void undoConfigAction (UndoAction& action, Rules &rules, Journal& journal)
|
||||
static void undoConfigAction (UndoAction& action, Rules& rules, Journal& journal)
|
||||
{
|
||||
const std::string& before = action.getBefore ();
|
||||
|
||||
|
|
|
@ -43,7 +43,7 @@ int CmdUntag (
|
|||
|
||||
// Gather IDs and TAGs.
|
||||
std::set <int> ids = cli.getIds ();
|
||||
std::set<std::string> tags = cli.getTags ();
|
||||
std::set <std::string> tags = cli.getTags ();
|
||||
|
||||
if (tags.empty ())
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ int CmdUntag (
|
|||
{
|
||||
throw std::string ("There is no active time tracking.");
|
||||
}
|
||||
else if (!latest.at (0).is_open ())
|
||||
else if (! latest.at (0).is_open ())
|
||||
{
|
||||
throw std::string ("At least one ID must be specified. See 'timew help untag'.");
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ int CmdUntag (
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (!found)
|
||||
if (! found)
|
||||
{
|
||||
throw format ("ID '@{1}' does not correspond to any tracking.", id);
|
||||
}
|
||||
|
|
|
@ -119,7 +119,7 @@ std::vector <Range> getAllExclusions (
|
|||
{
|
||||
for (auto& r : exclusion.ranges (range))
|
||||
{
|
||||
if (!r.is_empty ())
|
||||
if (! r.is_empty ())
|
||||
{
|
||||
exclusionRanges.push_back (r);
|
||||
}
|
||||
|
@ -331,7 +331,7 @@ std::vector <Range> subtractRanges (
|
|||
// An interval matches a filter range if the start/end overlaps
|
||||
bool matchesRange (const Interval& interval, const Range& filter)
|
||||
{
|
||||
return ((!filter.is_started () && !filter.is_ended ()) || interval.intersects (filter));
|
||||
return ((! filter.is_started () && ! filter.is_ended ()) || interval.intersects (filter));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
|
@ -132,7 +132,7 @@ bool domGet (
|
|||
std::set <std::string> tags;
|
||||
for (const auto& interval : tracked)
|
||||
{
|
||||
for (const auto &tag : interval.tags ())
|
||||
for (const auto& tag : interval.tags ())
|
||||
{
|
||||
tags.insert (tag);
|
||||
}
|
||||
|
|
|
@ -73,15 +73,15 @@ std::string configFile () { return configDir () + "/timewarrior.cfg"; }
|
|||
std::string dbDataDir () { return dbDir () + "/data"; }
|
||||
std::string extensionsDir () { return configDir () + "/extensions"; }
|
||||
|
||||
void initializeDirs (const CLI &cli, Rules &rules)
|
||||
void initializeDirs (const CLI& cli, Rules& rules)
|
||||
{
|
||||
Directory configLocation = Directory (configDir ());
|
||||
bool configDirExists = configLocation.exists ();
|
||||
|
||||
if (configDirExists &&
|
||||
(!configLocation.readable () ||
|
||||
!configLocation.writable () ||
|
||||
!configLocation.executable ()))
|
||||
(! configLocation.readable () ||
|
||||
! configLocation.writable () ||
|
||||
! configLocation.executable ()))
|
||||
{
|
||||
throw format ("Config is not readable at '{1}'", configLocation._data);
|
||||
}
|
||||
|
@ -89,19 +89,19 @@ void initializeDirs (const CLI &cli, Rules &rules)
|
|||
Directory dbLocation = Directory (dbDir ());
|
||||
bool dataLocationExists = dbLocation.exists ();
|
||||
if (dataLocationExists &&
|
||||
(!dbLocation.readable () ||
|
||||
!dbLocation.writable () ||
|
||||
!dbLocation.executable ()))
|
||||
(! dbLocation.readable () ||
|
||||
! dbLocation.writable () ||
|
||||
! dbLocation.executable ()))
|
||||
{
|
||||
throw format ("Database is not readable at '{1}'", dbLocation._data);
|
||||
}
|
||||
|
||||
std::string question = "";
|
||||
if (!configDirExists)
|
||||
if (! configDirExists)
|
||||
{
|
||||
question += "Create new config in " + configLocation._data + "?";
|
||||
}
|
||||
if (!dataLocationExists && configLocation._data != dbLocation._data)
|
||||
if (! dataLocationExists && configLocation._data != dbLocation._data)
|
||||
{
|
||||
if (question != "") {
|
||||
question += "\n";
|
||||
|
@ -109,15 +109,15 @@ void initializeDirs (const CLI &cli, Rules &rules)
|
|||
question += "Create new database in " + dbLocation._data + "?";
|
||||
}
|
||||
|
||||
if (!configDirExists || !dataLocationExists)
|
||||
if (! configDirExists || ! dataLocationExists)
|
||||
{
|
||||
if (cli.getHint ("yes", false) || confirm (question))
|
||||
{
|
||||
if (!configDirExists)
|
||||
if (! configDirExists)
|
||||
{
|
||||
configLocation.create (0700);
|
||||
}
|
||||
if (!dataLocationExists)
|
||||
if (! dataLocationExists)
|
||||
{
|
||||
dbLocation.create (0700);
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ void initializeDirs (const CLI &cli, Rules &rules)
|
|||
// Create extensions subdirectory if necessary.
|
||||
Directory extensionsLocation (extensionsDir ());
|
||||
|
||||
if (!extensionsLocation.exists ())
|
||||
if (! extensionsLocation.exists ())
|
||||
{
|
||||
extensionsLocation.create (0700);
|
||||
}
|
||||
|
@ -139,14 +139,14 @@ void initializeDirs (const CLI &cli, Rules &rules)
|
|||
// Create data subdirectory if necessary.
|
||||
Directory dbDataLocation (dbDataDir ());
|
||||
|
||||
if (!dbDataLocation.exists ())
|
||||
if (! dbDataLocation.exists ())
|
||||
{
|
||||
dbDataLocation.create (0700);
|
||||
}
|
||||
|
||||
Path configFileLocation (configFile ());
|
||||
|
||||
if (!configFileLocation.exists ())
|
||||
if (! configFileLocation.exists ())
|
||||
{
|
||||
File (configFileLocation).create (0600);
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ void initializeDirs (const CLI &cli, Rules &rules)
|
|||
rules.set ("temp.config", configFileLocation);
|
||||
|
||||
// Perhaps some subsequent code would like to know this is a new db and possibly a first run.
|
||||
if (!dataLocationExists)
|
||||
if (! dataLocationExists)
|
||||
rules.set ("temp.shiny", 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ void setDebugIndicator (const std::string&);
|
|||
void setDebugColor (const Color&);
|
||||
void debug (const std::string&);
|
||||
|
||||
// utiŀ.cpp
|
||||
// util.cpp
|
||||
std::string escape (const std::string&, int);
|
||||
std::string quoteIfNeeded (const std::string&);
|
||||
std::string join(const std::string& glue, const std::set <std::string>& array);
|
||||
|
|
|
@ -174,7 +174,7 @@ static bool autoAdjust (
|
|||
database.modifyInterval (overlap, modified, verbose);
|
||||
}
|
||||
}
|
||||
else if (!start_within_overlap && end_within_overlap)
|
||||
else if (! start_within_overlap && end_within_overlap)
|
||||
{
|
||||
// end date of new interval within old interval
|
||||
Interval modified {overlap};
|
||||
|
@ -189,7 +189,7 @@ static bool autoAdjust (
|
|||
database.modifyInterval (overlap, modified, verbose);
|
||||
}
|
||||
}
|
||||
else if (!start_within_overlap && !end_within_overlap)
|
||||
else if (! start_within_overlap && ! end_within_overlap)
|
||||
{
|
||||
// new interval encloses old interval
|
||||
database.deleteInterval (overlap);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue