Enhancement - export.yaml
- Preliminary export.yaml support. No unit tests yet, and no decision on including this feature. It may be that libyaml is the right choice, as an optional dependency.
This commit is contained in:
29
src/Task.cpp
29
src/Task.cpp
@@ -1,7 +1,7 @@
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// task - a command line task list manager.
|
||||
//
|
||||
// Copyright 2006 - 2010, Paul Beckingham.
|
||||
// Copyright 2006 - 2010, Paul Beckingham, Federico Hernandez.
|
||||
// All rights reserved.
|
||||
//
|
||||
// This program is free software; you can redistribute it and/or modify it under
|
||||
@@ -392,6 +392,33 @@ std::string Task::composeCSV () const
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Task::composeYAML () const
|
||||
{
|
||||
std::stringstream out;
|
||||
|
||||
// Task header.
|
||||
out << " task:\n";
|
||||
|
||||
// Get all the supported attribute names.
|
||||
std::vector <std::string> names;
|
||||
Att::allNames (names);
|
||||
std::sort (names.begin (), names.end ());
|
||||
|
||||
foreach (name, names)
|
||||
out << " " << *name << ": " << get (*name) << "\n";
|
||||
|
||||
// Now the annotations, which are not listed by the Att::allNames call.
|
||||
std::vector <Att> annotations;
|
||||
getAnnotations (annotations);
|
||||
foreach (a, annotations)
|
||||
out << " annotation:\n"
|
||||
<< " entry: " << a->name().substr (12) << "\n"
|
||||
<< " description: " << a->value () << "\n";
|
||||
|
||||
return out.str ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Task::getAnnotations (std::vector <Att>& annotations) const
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user