aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2015-10-06 08:45:41 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2015-10-06 08:45:41 +0200
commit76bcf09fde0b981879ebb76dce0514e03ff88ad4 (patch)
treefb59d0104dfd873a6ecc12766350a4e050b8f3b7
parent9dd19e0fffd832e3b218e8ac4dfef4cc8bad7910 (diff)
Rename dependency condition to constraint, add more operator<<
-rw-r--r--bpkg/manifest10
-rw-r--r--bpkg/manifest.cxx28
2 files changed, 33 insertions, 5 deletions
diff --git a/bpkg/manifest b/bpkg/manifest
index 8f5d975..0c7c693 100644
--- a/bpkg/manifest
+++ b/bpkg/manifest
@@ -237,16 +237,19 @@ namespace bpkg
inline std::ostream&
operator<< (std::ostream& os, comparison c) {return os << to_string (c);}
- struct dependency_condition
+ struct dependency_constraint
{
comparison operation;
bpkg::version version;
};
+ std::ostream&
+ operator<< (std::ostream&, const dependency_constraint&);
+
struct dependency
{
std::string name;
- butl::optional<dependency_condition> condition;
+ butl::optional<dependency_constraint> constraint;
};
std::ostream&
@@ -263,6 +266,9 @@ namespace bpkg
: conditional (d), comment (std::move (c)) {}
};
+ std::ostream&
+ operator<< (std::ostream&, const dependency_alternatives&);
+
// requires
//
class requirement_alternatives: public strings
diff --git a/bpkg/manifest.cxx b/bpkg/manifest.cxx
index cc0065b..771cfaa 100644
--- a/bpkg/manifest.cxx
+++ b/bpkg/manifest.cxx
@@ -384,13 +384,35 @@ namespace bpkg
else throw invalid_argument ("invalid comparion operator '" + s + "'");
}
+ inline ostream&
+ operator<< (ostream& o, const dependency_constraint& c)
+ {
+ return o << c.operation << ' ' << c.version;
+ }
+
ostream&
operator<< (ostream& o, const dependency& d)
{
o << d.name;
- if (d.condition)
- o << " " << d.condition->operation << " " << d.condition->version;
+ if (d.constraint)
+ o << ' ' << *d.constraint;
+
+ return o;
+ }
+
+ ostream&
+ operator<< (ostream& o, const dependency_alternatives& as)
+ {
+ if (as.conditional)
+ o << "? ";
+
+ bool f (true);
+ for (const dependency& a: as)
+ o << (f ? (f = false, "") : " | ") << a;
+
+ if (!as.comment.empty ())
+ o << "; " << as.comment;
return o;
}
@@ -726,7 +748,7 @@ namespace bpkg
}
dependency d {move (nm),
- dependency_condition {operation, move (v)}};
+ dependency_constraint {operation, move (v)}};
da.push_back (move (d));
}
}