diff options
Diffstat (limited to 'libbutl/prefix-map.mxx')
-rw-r--r-- | libbutl/prefix-map.mxx | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/libbutl/prefix-map.mxx b/libbutl/prefix-map.mxx index 882f46e..85d7635 100644 --- a/libbutl/prefix-map.mxx +++ b/libbutl/prefix-map.mxx @@ -71,6 +71,20 @@ LIBBUTL_MODEXPORT namespace butl compare (p.c_str (), pn, k.c_str (), pn == kn ? pn : pn + 1) == 0); } + // If the key is not empty, convert the key to its prefix and return + // true. Return false otherwise. + // + bool + prefix (K& k) const + { + if (k.empty ()) + return false; + + size_type p (k.rfind (d_)); + k.resize (p != K::npos ? p : 0); + return true; + } + protected: int compare (const C* x, size_type xn, |