Interval: Added ::serialize

This commit is contained in:
Paul Beckingham 2016-03-20 12:21:17 -04:00
parent e1f9b57d82
commit 171dae6ad2
2 changed files with 17 additions and 0 deletions

View file

@ -77,6 +77,22 @@ void Interval::tag (const std::string& tag)
_tags.insert (tag);
}
////////////////////////////////////////////////////////////////////////////////
std::string Interval::serialize () const
{
std::stringstream out;
out << "inc "
<< (_start.toEpoch () ? _start.toISO () : "")
<< " - "
<< (_end.toEpoch () ? _end.toISO () : "")
<< " #";
for (auto& tag : _tags)
out << " " << tag;
return out.str ();
}
////////////////////////////////////////////////////////////////////////////////
std::string Interval::dump () const
{

View file

@ -48,6 +48,7 @@ public:
std::set <std::string> tags () const;
void tag (const std::string&);
std::string serialize () const;
std::string dump () const;
private: