diff options
Diffstat (limited to 'build2/utility.cxx')
-rw-r--r-- | build2/utility.cxx | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/build2/utility.cxx b/build2/utility.cxx index 3f078a7..b517deb 100644 --- a/build2/utility.cxx +++ b/build2/utility.cxx @@ -6,10 +6,45 @@ #include <cstdlib> // strtol() +#include <build2/context> +#include <build2/diagnostics> + using namespace std; namespace build2 { + // + // <build2/types> + // + + ostream& + operator<< (ostream& os, const path& p) + { + return os << (stream_verb (os) < 2 ? diag_relative (p) : p.string ()); + } + + ostream& + operator<< (ostream& os, const dir_path& d) + { + if (stream_verb (os) < 2) + os << diag_relative (d); // Adds trailing '/'. + else + { + const string& s (d.string ()); + + // Print the directory with trailing '/'. + // + if (!s.empty ()) + os << s << (dir_path::traits::is_separator (s.back ()) ? "" : "/"); + } + + return os; + } + + // + // <build2/utility> + // + const string empty_string; const path empty_path; const dir_path empty_dir_path; |