diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2019-11-15 09:49:38 +0200 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2019-11-15 20:16:31 +0300 |
commit | e8381d5e5e19166001561244f7a9db5742f1090a (patch) | |
tree | 82c63f9dc164db74cdc7b6702dace947e36edbd0 /libbutl/path.ixx | |
parent | 31ccc33713e3ebd0fc0479d906f114ea33c5d616 (diff) |
Add path_name_view struct
Diffstat (limited to 'libbutl/path.ixx')
-rw-r--r-- | libbutl/path.ixx | 90 |
1 files changed, 66 insertions, 24 deletions
diff --git a/libbutl/path.ixx b/libbutl/path.ixx index 165f06a..77bc9f7 100644 --- a/libbutl/path.ixx +++ b/libbutl/path.ixx @@ -702,6 +702,72 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason. d.tsep_ = 1; // Canonical separator is always first. } + template <typename C, typename K> + inline std::basic_ostream<C>& + to_stream (std::basic_ostream<C>& os, + const basic_path<C, K>& p, + bool representation) + { + os << p.string (); + + if (representation) + { + C sep (p.separator ()); + +#ifndef _WIN32 + if (sep != 0 && !p.root ()) + os << sep; +#else + if (sep != 0) + os << sep; +#endif + } + + return os; + } + + // basic_path_name + // + template <typename P> + inline basic_path_name<P>:: + basic_path_name (basic_path_name&& p) + : basic_path_name (p.path, std::move (p.name)) + { + } + + template <typename P> + inline basic_path_name<P>:: + basic_path_name (const basic_path_name& p) + : basic_path_name (p.path, p.name) + { + } + + template <typename P> + inline basic_path_name<P>& basic_path_name<P>:: + operator= (basic_path_name&& p) + { + if (this != &p) + { + this->path = p.path; + name = std::move (p.name); + } + + return *this; + } + + template <typename P> + inline basic_path_name<P>& basic_path_name<P>:: + operator= (const basic_path_name& p) + { + if (this != &p) + { + this->path = p.path; + name = p.name; + } + + return *this; + } + // basic_path_name_value // template <typename P> @@ -743,28 +809,4 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason. return *this; } - - template <typename C, typename K> - inline std::basic_ostream<C>& - to_stream (std::basic_ostream<C>& os, - const basic_path<C, K>& p, - bool representation) - { - os << p.string (); - - if (representation) - { - C sep (p.separator ()); - -#ifndef _WIN32 - if (sep != 0 && !p.root ()) - os << sep; -#else - if (sep != 0) - os << sep; -#endif - } - - return os; - } } |