diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-07-09 11:24:11 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-07-09 11:24:11 +0200 |
commit | 6efb1b1ce3901c7d90402e8e828b07977fe425d0 (patch) | |
tree | 66f79216ceaf346ffbca7f5926f40cfbbeb9b755 /butl/path.txx | |
parent | 5b1c20f2315cd7fc624ffd31abdcc03b409bfcb2 (diff) |
Add path::operator=/(string), path::size()
Diffstat (limited to 'butl/path.txx')
-rw-r--r-- | butl/path.txx | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/butl/path.txx b/butl/path.txx index 35c6956..94fbd90 100644 --- a/butl/path.txx +++ b/butl/path.txx @@ -61,16 +61,31 @@ namespace butl if (r.absolute () && !this->path_.empty ()) // Allow ('' / '/foo'). throw invalid_basic_path<C> (r.path_); - if (this->path_.empty () || r.path_.empty ()) - { - this->path_ += r.path_; - return *this; - } + combine (r.path_.c_str (), r.path_.size ()); + return *this; + } + + template <typename C, typename K> + basic_path<C, K>& basic_path<C, K>:: + operator/= (string_type const& r) + { + if (traits::find_separator (r) != string_type::npos) + throw invalid_basic_path<C> (r); + + combine (r.c_str (), r.size ()); + return *this; + } + + template <typename C, typename K> + basic_path<C, K>& basic_path<C, K>:: + operator/= (const C* r) + { + size_type rn (string_type::traits_type::length (r)); - if (!traits::is_separator (this->path_[this->path_.size () - 1])) - this->path_ += traits::directory_separator; + if (traits::find_separator (r, rn) != nullptr) + throw invalid_basic_path<C> (r); - this->path_ += r.path_; + combine (r, rn); return *this; } |