aboutsummaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
Diffstat (limited to 'doc')
-rw-r--r--doc/api/cplusplus/examples/example_dep_spec.cc51
-rw-r--r--doc/configuration/specs.html.part4
2 files changed, 39 insertions, 16 deletions
diff --git a/doc/api/cplusplus/examples/example_dep_spec.cc b/doc/api/cplusplus/examples/example_dep_spec.cc
index f21bdb840..9be91eb5d 100644
--- a/doc/api/cplusplus/examples/example_dep_spec.cc
+++ b/doc/api/cplusplus/examples/example_dep_spec.cc
@@ -23,6 +23,7 @@
#include <cstdlib>
#include <list>
#include <map>
+#include <sstream>
using namespace paludis;
using namespace examples;
@@ -32,6 +33,36 @@ using std::endl;
using std::setw;
using std::left;
+namespace
+{
+ /* Used to print out more information about a UseRequirement. */
+ struct UseRequirementPrinter :
+ ConstVisitor<UseRequirementVisitorTypes>
+ {
+ std::ostringstream s;
+
+ void visit(const EnabledUseRequirement & r)
+ {
+ s << "[" << r.flag() << "]";
+ }
+
+ void visit(const DisabledUseRequirement & r)
+ {
+ s << "[!" << r.flag() << "]";
+ }
+
+ void visit(const EqualUseRequirement & r)
+ {
+ s << "[" << r.flag() << "?] (using '" << *r.package_id() << "')";
+ }
+
+ void visit(const NotEqualUseRequirement & r)
+ {
+ s << "[!" << r.flag() << "?] (using '" << *r.package_id() << "')";
+ }
+ };
+}
+
int main(int argc, char * argv[])
{
try
@@ -113,21 +144,11 @@ int main(int argc, char * argv[])
if (need_join)
cout << " and ";
- switch (u->second)
- {
- case use_enabled:
- case use_unspecified:
- break;
-
- case use_disabled:
- cout << "-";
- break;
-
- case last_use:
- throw InternalError(PALUDIS_HERE, "Bad use requirements");
- }
- cout << u->first;
-
+ /* A UseRequirement could be one of various subclasses. We
+ * use a visitor to do the right thing. */
+ UseRequirementPrinter p;
+ (*u)->accept(p);
+ cout << p.s.str();
need_join = true;
}
cout << endl;
diff --git a/doc/configuration/specs.html.part b/doc/configuration/specs.html.part
index bad1adceb..3ae292db7 100644
--- a/doc/configuration/specs.html.part
+++ b/doc/configuration/specs.html.part
@@ -27,7 +27,9 @@ the following order:</p>
<li><code>:slot</code>: Match only in that slot.</li>
<li><code>::repository</code>: Match only in the named repository.</li>
<li><code>[use]</code> and <code>[-use]</code>: Match only if the named USE flag is enabled / disabled for this
- package. May be specified multiple times with different USE flag names.</li>
+ package. May be specified multiple times with different USE flag names. Additionally, <code>[use?]</code> and
+ <code>[use!?]</code> are available in package contexts, meaning equal to / not equal to the value of the flag
+ for this package.</li>
<li><code>[=1.23]</code>: Match a particular version. Any operator described below
can be used. May be extended to ranged dependencies, using either <code>[=1.23|=1.24|=1.25]</code> for an or
dependency or <code>[&gt;=1.2&amp;&lt;2]</code> for an and dependency.</li>