diff options
author | David Robillard <d@drobilla.net> | 2007-07-26 11:29:31 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2007-07-26 11:29:31 +0000 |
commit | 47fb95d6086c2c67086316a25b4c0858783d3c2b (patch) | |
tree | 4ac9934f1f38b0b6ed42f41b2bd9d7cdbc90c2f8 /raul/Path.hpp | |
parent | 25b9a123b60f769506a829542d05f38b1e95d51b (diff) | |
download | raul-47fb95d6086c2c67086316a25b4c0858783d3c2b.tar.gz raul-47fb95d6086c2c67086316a25b4c0858783d3c2b.tar.bz2 raul-47fb95d6086c2c67086316a25b4c0858783d3c2b.zip |
Added PathTable, simple pretty wrapper around Table which provides super fast
"find all descendants".
I couldn't deal with the 'one big table' or 'parents own/lookup children' decision,
so I came up with this thing instead. It's pretty cool I guess.
git-svn-id: http://svn.drobilla.net/lad/raul@635 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'raul/Path.hpp')
-rw-r--r-- | raul/Path.hpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/raul/Path.hpp b/raul/Path.hpp index 5776309..d8ef751 100644 --- a/raul/Path.hpp +++ b/raul/Path.hpp @@ -21,6 +21,7 @@ #include <cctype> #include <string> #include <cassert> +#include <iostream> using std::string; namespace Raul { @@ -120,6 +121,14 @@ public: else return (*this) + "/"; } + + /** Return true if \a child is equal to, or a descendant of \a parent */ + static bool descendant_comparator(const Path& parent, const Path& child) + { + return ( child == parent + || (!strncmp(parent.c_str(), child.c_str(), parent.length()) + && child[parent.length()] == '/') ); + } }; |