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:
Paul Beckingham
2010-07-11 10:22:36 -04:00
parent 8b02d2bdeb
commit 2b48ae8e38
6 changed files with 67 additions and 10 deletions

View File

@@ -62,8 +62,6 @@ int handleExportCSV (std::string &outs)
<< "'description'"
<< "\n";
int count = 0;
// Get all the tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
@@ -77,10 +75,7 @@ int handleExportCSV (std::string &outs)
context.hooks.trigger ("pre-display", *task);
if (task->getStatus () != Task::recurring)
{
out << task->composeCSV ().c_str ();
++count;
}
}
outs = out.str ();
@@ -106,8 +101,6 @@ int handleExportiCal (std::string &outs)
<< "VERSION:2.0\n"
<< "PRODID:-//GBF//" << PACKAGE_STRING << "//EN\n";
int count = 0;
// Get all the tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
@@ -214,7 +207,6 @@ int handleExportiCal (std::string &outs)
out << "COMMENT:" << anno->value () << "\n";
out << "END:VTODO\n";
++count;
}
}
@@ -228,3 +220,36 @@ int handleExportiCal (std::string &outs)
}
////////////////////////////////////////////////////////////////////////////////
int handleExportYAML (std::string &outs)
{
int rc = 0;
if (context.hooks.trigger ("pre-export-command"))
{
// YAML header.
std::stringstream out;
out << "%YAML 1.1\n"
<< "---\n";
// Get all the tasks.
std::vector <Task> tasks;
context.tdb.lock (context.config.getBoolean ("locking"));
handleRecurrence ();
context.tdb.load (tasks, context.filter);
context.tdb.commit ();
context.tdb.unlock ();
foreach (task, tasks)
{
context.hooks.trigger ("pre-display", *task);
out << task->composeYAML ().c_str ();
}
outs = out.str ();
context.hooks.trigger ("post-export-command");
}
return rc;
}
////////////////////////////////////////////////////////////////////////////////