mirror of
https://github.com/GothenburgBitFactory/timewarrior.git
synced 2025-07-07 20:06:39 +02:00
Datafile: Added ::load_intervals
This commit is contained in:
parent
3eee83b874
commit
f2b4cc5873
2 changed files with 34 additions and 0 deletions
|
@ -115,6 +115,35 @@ std::string Datafile::dump () const
|
||||||
return out.str ();
|
return out.str ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
void Datafile::load_intervals ()
|
||||||
|
{
|
||||||
|
if (! _lines_loaded)
|
||||||
|
{
|
||||||
|
load_lines ();
|
||||||
|
|
||||||
|
// Apply previously added lines.
|
||||||
|
for (auto& line : _lines_added)
|
||||||
|
_lines.push_back (line);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto& line : _lines)
|
||||||
|
{
|
||||||
|
if (line[0] == 'i')
|
||||||
|
{
|
||||||
|
Interval i;
|
||||||
|
i.initialize (line);
|
||||||
|
_intervals.push_back (i);
|
||||||
|
}
|
||||||
|
else if (line[0] == 'e')
|
||||||
|
; // TODO Exclusions.
|
||||||
|
else
|
||||||
|
; // TODO Ignore blank lines?
|
||||||
|
}
|
||||||
|
|
||||||
|
_intervals_loaded = true;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
void Datafile::load_lines ()
|
void Datafile::load_lines ()
|
||||||
{
|
{
|
||||||
|
|
|
@ -53,6 +53,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void load_lines ();
|
void load_lines ();
|
||||||
|
void load_intervals ();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// File representing data.
|
// File representing data.
|
||||||
|
@ -65,6 +66,10 @@ private:
|
||||||
std::vector <std::string> _lines_modified {};
|
std::vector <std::string> _lines_modified {};
|
||||||
bool _lines_loaded {false};
|
bool _lines_loaded {false};
|
||||||
|
|
||||||
|
// Intervals parsed from lines.
|
||||||
|
std::vector <Interval> _intervals {};
|
||||||
|
bool _intervals_loaded {false};
|
||||||
|
|
||||||
Datetime _day1 {0};
|
Datetime _day1 {0};
|
||||||
Datetime _dayN {0};
|
Datetime _dayN {0};
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue