aboutsummaryrefslogtreecommitdiff
path: root/libbutl/path-io.mxx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2019-11-07 11:11:45 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2019-11-07 11:11:45 +0200
commit23d4deb111bfff9c282c20989573c4b0775e4c16 (patch)
tree9763c7e2cbce36581673eb69b652f67e2f7cfa6f /libbutl/path-io.mxx
parentb2ac741e2b806f4565beeef34b12c95b6b3fdd41 (diff)
Add path_name struct, open_file_or{stdin,stdout}() functions
Diffstat (limited to 'libbutl/path-io.mxx')
-rw-r--r--libbutl/path-io.mxx19
1 files changed, 12 insertions, 7 deletions
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 <typename C, typename K>
inline std::basic_ostream<C>&
- operator<< (std::basic_ostream<C>& os, basic_path<C, K> const& p)
+ operator<< (std::basic_ostream<C>& os, const basic_path<C, K>& p)
{
return os << p.string ();
}
+
+ template <typename C, typename P>
+ inline std::basic_ostream<C>&
+ operator<< (std::basic_ostream<C>& os, const basic_path_name<P>& pn)
+ {
+ return os << (pn.name ? *pn.name : pn.path->string ());
+ }
}