From 23d4deb111bfff9c282c20989573c4b0775e4c16 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Thu, 7 Nov 2019 11:11:45 +0200 Subject: Add path_name struct, open_file_or{stdin,stdout}() functions --- libbutl/path-io.mxx | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'libbutl/path-io.mxx') diff --git a/libbutl/path-io.mxx b/libbutl/path-io.mxx index 6c9f93b..54d884b 100644 --- a/libbutl/path-io.mxx +++ b/libbutl/path-io.mxx @@ -29,17 +29,22 @@ import butl.path; LIBBUTL_MODEXPORT namespace butl { - // This is the default path IO implementation. The reason it is - // separate is because one often wants a custom implementation. - // For example, we may want to print paths as relative to the - // working directory. Or we may want to print '~' for the home - // directory prefix. Or we may want to print dir_path with a - // trailing '/'. + // This is the default path IO implementation. It is separate to allo custom + // implementations. For example, we may want to print paths as relative to + // the working directory. Or we may want to print '~' for the home directory + // prefix. Or we may want to print dir_path with a trailing '/'. // template inline std::basic_ostream& - operator<< (std::basic_ostream& os, basic_path const& p) + operator<< (std::basic_ostream& os, const basic_path& p) { return os << p.string (); } + + template + inline std::basic_ostream& + operator<< (std::basic_ostream& os, const basic_path_name

& pn) + { + return os << (pn.name ? *pn.name : pn.path->string ()); + } } -- cgit v1.1