Code Migration
- Migrated taskd JSON parser into task, to provide encode/decode capability to Task::composeJSON. - Migrated taskd utf8 code, replacing old unused code. - Added unit tests or JSON. - Migrated Tree updates from taskd.
This commit is contained in:
22
src/Tree.cpp
22
src/Tree.cpp
@@ -27,9 +27,8 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include "text.h"
|
||||
#include "Tree.h"
|
||||
#include <text.h>
|
||||
#include <Tree.h>
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// - Tree, Branch and Node are synonymous.
|
||||
@@ -118,6 +117,12 @@ int Tree::branches ()
|
||||
return _branches.size ();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
void Tree::name (const std::string& name)
|
||||
{
|
||||
_name = name;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
std::string Tree::name () const
|
||||
{
|
||||
@@ -135,9 +140,14 @@ void Tree::attribute (const std::string& name, const std::string& value)
|
||||
// Accessor for attributes.
|
||||
void Tree::attribute (const std::string& name, const int value)
|
||||
{
|
||||
std::stringstream s;
|
||||
s << value;
|
||||
_attributes[name] = s.str ();
|
||||
_attributes[name] = format (value);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// Accessor for attributes.
|
||||
void Tree::attribute (const std::string& name, const double value)
|
||||
{
|
||||
_attributes[name] = format (value, 1, 8);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
Reference in New Issue
Block a user