diff options
author | Karen Arutyunov <karen@codesynthesis.com> | 2021-09-28 19:24:31 +0300 |
---|---|---|
committer | Karen Arutyunov <karen@codesynthesis.com> | 2021-09-28 20:29:59 +0300 |
commit | df1ef68cd8e8582724ce1192bfc202e0b9aeaf0c (patch) | |
tree | b731ca4c68e60c00c7e7d499dbf4868ee7b71f44 /libbutl/path-io.hxx | |
parent | 7a4fc37f264cdb67f2f83fa92703c869215bbc86 (diff) |
Get rid of C++ modules related code and rename *.mxx files to *.hxx
Diffstat (limited to 'libbutl/path-io.hxx')
-rw-r--r-- | libbutl/path-io.hxx | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/libbutl/path-io.hxx b/libbutl/path-io.hxx new file mode 100644 index 0000000..a60527d --- /dev/null +++ b/libbutl/path-io.hxx @@ -0,0 +1,36 @@ +// file : libbutl/path-io.hxx -*- C++ -*- +// license : MIT; see accompanying LICENSE file + +#pragma once + +#include <cassert> +#include <ostream> + +#include <libbutl/path.hxx> + +#include <libbutl/export.hxx> + +namespace butl +{ + // This is the default path IO implementation. It is separate to allow + // 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, const basic_path<C, K>& p) + { + return to_stream (os, p, false /* representation */); + } + + template <typename C, typename P> + inline std::basic_ostream<C>& + operator<< (std::basic_ostream<C>& os, const basic_path_name_view<P>& v) + { + assert (!v.null ()); + + return v.name != nullptr && *v.name ? (os << **v.name) : (os << *v.path); + } +} |