From e8381d5e5e19166001561244f7a9db5742f1090a Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 15 Nov 2019 09:49:38 +0200 Subject: Add path_name_view struct --- libbutl/path.ixx | 90 +++++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 66 insertions(+), 24 deletions(-) (limited to 'libbutl/path.ixx') 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 + inline std::basic_ostream& + to_stream (std::basic_ostream& os, + const basic_path& 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 + inline basic_path_name

:: + basic_path_name (basic_path_name&& p) + : basic_path_name (p.path, std::move (p.name)) + { + } + + template + inline basic_path_name

:: + basic_path_name (const basic_path_name& p) + : basic_path_name (p.path, p.name) + { + } + + template + inline basic_path_name

& basic_path_name

:: + operator= (basic_path_name&& p) + { + if (this != &p) + { + this->path = p.path; + name = std::move (p.name); + } + + return *this; + } + + template + inline basic_path_name

& basic_path_name

:: + operator= (const basic_path_name& p) + { + if (this != &p) + { + this->path = p.path; + name = p.name; + } + + return *this; + } + // basic_path_name_value // template @@ -743,28 +809,4 @@ LIBBUTL_MODEXPORT namespace butl //@@ MOD Clang needs this for some reason. return *this; } - - template - inline std::basic_ostream& - to_stream (std::basic_ostream& os, - const basic_path& 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; - } } -- cgit v1.1