aboutsummaryrefslogtreecommitdiff
path: root/libbutl/path-io.hxx
blob: a60527d36715f37a5cfbf5c5112d5aee033fee44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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);
  }
}