blob: 1bb8d31b6bf00a1c6ddaed2d2bc4041bf1ece01c (
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
// file : build/name.cxx -*- C++ -*-
// copyright : Copyright (c) 2014-2015 Code Synthesis Ltd
// license : MIT; see accompanying LICENSE file
#include <build/name>
#include <ostream>
#include <build/diagnostics>
using namespace std;
namespace build
{
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;
}
}
|