diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-01-05 11:55:15 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-01-05 11:55:15 +0200 |
commit | 9fb791e9fad6c63fc1dac49f4d05ae63b8a3db9b (patch) | |
tree | d60322d4382ca5f97b676c5abe2e39524f35eab4 /build2/name.cxx | |
parent | f159b1dac68c8714f7ba71ca168e3b695891aad9 (diff) |
Rename build directory/namespace to build2
Diffstat (limited to 'build2/name.cxx')
-rw-r--r-- | build2/name.cxx | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/build2/name.cxx b/build2/name.cxx new file mode 100644 index 0000000..9ebfa1f --- /dev/null +++ b/build2/name.cxx @@ -0,0 +1,63 @@ +// file : build2/name.cxx -*- C++ -*- +// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd +// license : MIT; see accompanying LICENSE file + +#include <build2/name> + +#include <ostream> + +#include <build2/diagnostics> + +using namespace std; + +namespace build2 +{ + ostream& + operator<< (ostream& os, const name& n) + { + if (n.proj != nullptr) + os << *n.proj << '%'; + + // If the value is empty, then we want to print the directory + // inside {}, e.g., dir{bar/}, not bar/dir{}. We also want to + // print {} for an empty name. + // + bool d (!n.dir.empty ()); + bool v (!n.value.empty ()); + bool t (!n.type.empty () || (!d && !v)); + + if (v) + os << n.dir; + + if (t) + os << n.type << '{'; + + if (v) + os << n.value; + else + os << n.dir; + + if (t) + os << '}'; + + return os; + } + + ostream& + operator<< (ostream& os, const names& ns) + { + for (auto i (ns.begin ()), e (ns.end ()); i != e; ) + { + const name& n (*i); + ++i; + os << n; + + if (n.pair != '\0') + os << n.pair; + else if (i != e) + os << ' '; + } + + return os; + } +} |