diff options
Diffstat (limited to 'src/Tree.cc')
-rw-r--r-- | src/Tree.cc | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/Tree.cc b/src/Tree.cc index a451f24..7615a3d 100644 --- a/src/Tree.cc +++ b/src/Tree.cc @@ -2,12 +2,18 @@ #include "nodedumper.h" #include <assert.h> +#include <algorithm> + +static bool filter(char c) +{ + return c == ' ' || c == '\n' || c == '\t' || c == '\r'; +} /*! - Returns the cached string representation of the subtree rootet by \a node. + Returns the cached string representation of the subtree rooted by \a node. If node is not cached, the cache will be rebuilt. */ -const std::string &Tree::getString(const AbstractNode &node) const +const std::string Tree::getString(const AbstractNode &node) const { assert(this->root_node); if (!this->nodecache.contains(node)) { @@ -17,7 +23,10 @@ const std::string &Tree::getString(const AbstractNode &node) const assert(this->nodecache.contains(*this->root_node) && "NodeDumper failed to create a cache"); } - return this->nodecache[node]; + std::string str = this->nodecache[node]; + str.erase(std::remove_if(str.begin(), str.end(), filter), str.end()); + + return str; } /*! |