aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-26 16:02:17 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-05-26 16:02:17 +0000
commitf8241e85c77382c4560ad2c39a86d98587492715 (patch)
treed6e02a5a1674f83b3409dfc87b1484f93226495c /src
parent9b7bfeac95df0cbe76fbf60976e789fae2890c5e (diff)
downloadpaludis-f8241e85c77382c4560ad2c39a86d98587492715.tar.gz
paludis-f8241e85c77382c4560ad2c39a86d98587492715.tar.xz
New type safe visitor framework
Diffstat (limited to 'src')
-rw-r--r--src/clients/adjutrix/display_default_system_resolution.cc2
-rw-r--r--src/clients/adjutrix/find_insecure_packages.cc30
-rw-r--r--src/clients/adjutrix/find_reverse_deps.cc55
-rw-r--r--src/clients/adjutrix/what_needs_keywording.cc9
-rw-r--r--src/clients/contrarius/install.cc2
-rw-r--r--src/clients/paludis/do_contents.cc29
-rw-r--r--src/clients/paludis/install.cc2
-rwxr-xr-xsrc/clients/paludis/install_TEST1
-rw-r--r--src/clients/paludis/owner.cc29
-rw-r--r--src/clients/paludis/query.cc7
-rw-r--r--src/output/console_install_task.cc35
-rw-r--r--src/output/console_install_task.hh16
-rw-r--r--src/output/console_query_task.cc115
-rw-r--r--src/output/console_query_task.hh12
-rw-r--r--src/output/licence.cc37
-rw-r--r--src/output/licence.hh22
16 files changed, 221 insertions, 182 deletions
diff --git a/src/clients/adjutrix/display_default_system_resolution.cc b/src/clients/adjutrix/display_default_system_resolution.cc
index ccaf577f4..3888d22ab 100644
--- a/src/clients/adjutrix/display_default_system_resolution.cc
+++ b/src/clients/adjutrix/display_default_system_resolution.cc
@@ -75,7 +75,7 @@ namespace
try
{
- d.add(env.set(SetName("system")), env.default_destinations());
+ d.add(*env.set(SetName("system")), env.default_destinations());
for (DepList::Iterator e(d.begin()), e_end(d.end()) ; e != e_end ; ++e)
cout << " " << e->package << ":" << e->metadata->slot << endl;
diff --git a/src/clients/adjutrix/find_insecure_packages.cc b/src/clients/adjutrix/find_insecure_packages.cc
index 3452e890e..077590bed 100644
--- a/src/clients/adjutrix/find_insecure_packages.cc
+++ b/src/clients/adjutrix/find_insecure_packages.cc
@@ -63,10 +63,8 @@ namespace
}
class ListInsecureVisitor :
- public DepSpecVisitorTypes::ConstVisitor,
- public DepSpecVisitorTypes::ConstVisitor::VisitChildren<ListInsecureVisitor, AllDepSpec>,
- public DepSpecVisitorTypes::ConstVisitor::VisitChildren<ListInsecureVisitor, AnyDepSpec>,
- public DepSpecVisitorTypes::ConstVisitor::VisitChildren<ListInsecureVisitor, UseDepSpec>
+ public ConstVisitor<SetSpecTree>,
+ public ConstVisitor<SetSpecTree>::VisitConstSequence<ListInsecureVisitor, AllDepSpec>
{
private:
const Environment & _env;
@@ -74,35 +72,25 @@ namespace
ArbitrarilyOrderedPackageDatabaseEntryCollectionComparator> _found;
public:
- using DepSpecVisitorTypes::ConstVisitor::VisitChildren<ListInsecureVisitor, AllDepSpec>::visit;
- using DepSpecVisitorTypes::ConstVisitor::VisitChildren<ListInsecureVisitor, AnyDepSpec>::visit;
- using DepSpecVisitorTypes::ConstVisitor::VisitChildren<ListInsecureVisitor, UseDepSpec>::visit;
+ using ConstVisitor<SetSpecTree>::VisitConstSequence<ListInsecureVisitor, AllDepSpec>::visit;
ListInsecureVisitor(const Environment & e) :
_env(e)
{
}
- void visit(const PackageDepSpec * const a)
+ void visit_leaf(const PackageDepSpec & a)
{
tr1::shared_ptr<const PackageDatabaseEntryCollection> insecure(
- _env.package_database()->query(query::Matches(*a), qo_order_by_version));
+ _env.package_database()->query(query::Matches(a), qo_order_by_version));
for (PackageDatabaseEntryCollection::Iterator i(insecure->begin()),
i_end(insecure->end()) ; i != i_end ; ++i)
- if (a->tag())
- _found.insert(std::make_pair(*i, a->tag()->short_text()));
+ if (a.tag())
+ _found.insert(std::make_pair(*i, a.tag()->short_text()));
else
throw InternalError(PALUDIS_HERE, "didn't get a tag");
}
- void visit(const PlainTextDepSpec * const)
- {
- }
-
- void visit(const BlockDepSpec * const)
- {
- }
-
friend std::ostream & operator<< (std::ostream &, const ListInsecureVisitor &);
};
@@ -148,11 +136,11 @@ void do_find_insecure_packages(const Environment & env)
write_repository_header(r->name());
- tr1::shared_ptr<const DepSpec> all_insecure(r->sets_interface->package_set(SetName("insecurity")));
+ tr1::shared_ptr<const SetSpecTree::ConstItem> all_insecure(r->sets_interface->package_set(SetName("insecurity")));
if (! all_insecure)
continue;
ListInsecureVisitor v(env);
- all_insecure->accept(&v);
+ all_insecure->accept(v);
cout << v << endl;
}
}
diff --git a/src/clients/adjutrix/find_reverse_deps.cc b/src/clients/adjutrix/find_reverse_deps.cc
index 77c0ffeeb..29352ae6f 100644
--- a/src/clients/adjutrix/find_reverse_deps.cc
+++ b/src/clients/adjutrix/find_reverse_deps.cc
@@ -43,8 +43,8 @@ using std::endl;
namespace
{
class ReverseDepChecker :
- public DepSpecVisitorTypes::ConstVisitor,
- public DepSpecVisitorTypes::ConstVisitor::VisitChildren<ReverseDepChecker, AllDepSpec>
+ public ConstVisitor<DependencySpecTree>,
+ public ConstVisitor<DependencySpecTree>::VisitConstSequence<ReverseDepChecker, AllDepSpec>
{
private:
tr1::shared_ptr<const PackageDatabase> _db;
@@ -59,7 +59,7 @@ namespace
bool _found_matches;
public:
- using DepSpecVisitorTypes::ConstVisitor::VisitChildren<ReverseDepChecker, AllDepSpec>::visit;
+ using ConstVisitor<DependencySpecTree>::VisitConstSequence<ReverseDepChecker, AllDepSpec>::visit_sequence;
ReverseDepChecker(tr1::shared_ptr<const PackageDatabase> db,
const PackageDatabaseEntryCollection & entries,
@@ -74,10 +74,10 @@ namespace
{
}
- void check(tr1::shared_ptr<const DepSpec> spec, const std::string & depname)
+ void check(tr1::shared_ptr<const DependencySpecTree::ConstItem> spec, const std::string & depname)
{
_depname = depname;
- spec->accept(this);
+ spec->accept(*this);
}
bool found_matches()
@@ -85,43 +85,50 @@ namespace
return _found_matches;
}
- void visit(const AnyDepSpec * const);
+ void visit_sequence(const AnyDepSpec &,
+ DependencySpecTree::ConstSequenceIterator,
+ DependencySpecTree::ConstSequenceIterator);
- void visit(const UseDepSpec * const);
+ void visit_sequence(const UseDepSpec &,
+ DependencySpecTree::ConstSequenceIterator,
+ DependencySpecTree::ConstSequenceIterator);
- void visit(const PackageDepSpec * const);
+ void visit_leaf(const PackageDepSpec &);
- void visit(const PlainTextDepSpec * const);
-
- void visit(const BlockDepSpec * const);
+ void visit_leaf(const BlockDepSpec &)
+ {
+ }
};
void
- ReverseDepChecker::visit(const AnyDepSpec * const a)
+ ReverseDepChecker::visit_sequence(const AnyDepSpec &,
+ DependencySpecTree::ConstSequenceIterator cur,
+ DependencySpecTree::ConstSequenceIterator end)
{
Save<bool> in_any_save(&_in_any, true);
-
- std::for_each(a->begin(), a->end(), accept_visitor(this));
+ std::for_each(cur, end, accept_visitor(*this));
}
void
- ReverseDepChecker::visit(const UseDepSpec * const a)
+ ReverseDepChecker::visit_sequence(const UseDepSpec & a,
+ DependencySpecTree::ConstSequenceIterator cur,
+ DependencySpecTree::ConstSequenceIterator end)
{
Save<bool> in_use_save(&_in_use, true);
Save<std::string> flag_save(&_flags);
if (! _flags.empty())
_flags += " ";
- _flags += (a->inverse() ? "!" : "") + stringify(a->flag());
+ _flags += (a.inverse() ? "!" : "") + stringify(a.flag());
- std::for_each(a->begin(), a->end(), accept_visitor(this));
+ std::for_each(cur, end, accept_visitor(*this));
}
void
- ReverseDepChecker::visit(const PackageDepSpec * const a)
+ ReverseDepChecker::visit_leaf(const PackageDepSpec & a)
{
tr1::shared_ptr<const PackageDatabaseEntryCollection> dep_entries(_db->query(
- query::Matches(*a), qo_order_by_version));
+ query::Matches(a), qo_order_by_version));
tr1::shared_ptr<PackageDatabaseEntryCollection> matches(new PackageDatabaseEntryCollection::Concrete);
bool header_written = false;
@@ -160,16 +167,6 @@ namespace
}
}
- void
- ReverseDepChecker::visit(const PlainTextDepSpec * const)
- {
- }
-
- void
- ReverseDepChecker::visit(const BlockDepSpec * const)
- {
- }
-
void write_repository_header(std::string spec, const std::string &)
{
cout << "Reverse dependencies for '" << spec << "':" << std::endl;
diff --git a/src/clients/adjutrix/what_needs_keywording.cc b/src/clients/adjutrix/what_needs_keywording.cc
index 0c9a62402..4c211cfa4 100644
--- a/src/clients/adjutrix/what_needs_keywording.cc
+++ b/src/clients/adjutrix/what_needs_keywording.cc
@@ -72,13 +72,12 @@ int do_what_needs_keywording(NoConfigEnvironment & env)
p_end(CommandLine::get_instance()->end_parameters()) ; p != p_end ; ++p)
{
if (std::string::npos == p->find('/'))
- d.add(tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(
- tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
- env.package_database()->fetch_unique_qualified_package_name(PackageNamePart(*p)))))),
+ d.add(PackageDepSpec(
+ tr1::shared_ptr<QualifiedPackageName>(new QualifiedPackageName(
+ env.package_database()->fetch_unique_qualified_package_name(PackageNamePart(*p))))),
env.default_destinations());
else
- d.add(tr1::shared_ptr<PackageDepSpec>(new PackageDepSpec(*p, pds_pm_permissive)),
- env.default_destinations());
+ d.add(PackageDepSpec(*p, pds_pm_permissive), env.default_destinations());
}
cout << std::setw(30) << std::left << "Package";
diff --git a/src/clients/contrarius/install.cc b/src/clients/contrarius/install.cc
index 1cfb6f7a8..8b834f58b 100644
--- a/src/clients/contrarius/install.cc
+++ b/src/clients/contrarius/install.cc
@@ -347,7 +347,7 @@ do_install(tr1::shared_ptr<Environment> env, std::string spec_str)
cerr << " ";
LicenceDisplayer ld(cerr, env.get(), *pp);
- meta->license_interface->license()->accept(&ld);
+ meta->license_interface->license()->accept(ld);
}
}
else if (mr_keyword == mm)
diff --git a/src/clients/paludis/do_contents.cc b/src/clients/paludis/do_contents.cc
index eeaa12470..d5a3608ac 100644
--- a/src/clients/paludis/do_contents.cc
+++ b/src/clients/paludis/do_contents.cc
@@ -21,6 +21,7 @@
#include <src/output/colour.hh>
#include "command_line.hh"
#include <paludis/paludis.hh>
+#include <paludis/util/visitor-impl.hh>
#include <iostream>
#include <algorithm>
@@ -32,36 +33,36 @@ using std::endl;
namespace
{
struct ContentsDisplayer :
- ContentsVisitorTypes::ConstVisitor
+ ConstVisitor<ContentsVisitorTypes>
{
- void visit(const ContentsFileEntry * const e)
+ void visit(const ContentsFileEntry & e)
{
- cout << " " << colour(cl_file, e->name()) << endl;
+ cout << " " << colour(cl_file, e.name()) << endl;
}
- void visit(const ContentsDirEntry * const e)
+ void visit(const ContentsDirEntry & e)
{
- cout << " " << colour(cl_dir, e->name()) << endl;
+ cout << " " << colour(cl_dir, e.name()) << endl;
}
- void visit(const ContentsSymEntry * const e)
+ void visit(const ContentsSymEntry & e)
{
- cout << " " << colour(cl_sym, e->name()) << " -> " << e->target() << endl;
+ cout << " " << colour(cl_sym, e.name()) << " -> " << e.target() << endl;
}
- void visit(const ContentsMiscEntry * const e)
+ void visit(const ContentsMiscEntry & e)
{
- cout << " " << colour(cl_misc, e->name()) << endl;
+ cout << " " << colour(cl_misc, e.name()) << endl;
}
- void visit(const ContentsFifoEntry * const e)
+ void visit(const ContentsFifoEntry & e)
{
- cout << " " << colour(cl_fifo, e->name()) << endl;
+ cout << " " << colour(cl_fifo, e.name()) << endl;
}
- void visit(const ContentsDevEntry * const e)
+ void visit(const ContentsDevEntry & e)
{
- cout << " " << colour(cl_dev, e->name()) << endl;
+ cout << " " << colour(cl_dev, e.name()) << endl;
}
};
}
@@ -81,7 +82,7 @@ do_one_contents_entry(
tr1::shared_ptr<const Contents> contents(contents_interface->contents(
e.name, e.version));
ContentsDisplayer d;
- std::for_each(contents->begin(), contents->end(), accept_visitor(&d));
+ std::for_each(indirect_iterator(contents->begin()), indirect_iterator(contents->end()), accept_visitor(d));
}
else
cout << " " << colour(cl_error, "(unknown)") << endl;
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index fe2870730..aa3653d85 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -665,7 +665,7 @@ do_install(tr1::shared_ptr<Environment> env)
cerr << " ";
LicenceDisplayer ld(cerr, env.get(), *pp);
- meta->license_interface->license()->accept(&ld);
+ meta->license_interface->license()->accept(ld);
}
}
else if (mr_keyword == mm)
diff --git a/src/clients/paludis/install_TEST b/src/clients/paludis/install_TEST
index 45b10ac7a..5ad0ca0e8 100755
--- a/src/clients/paludis/install_TEST
+++ b/src/clients/paludis/install_TEST
@@ -6,6 +6,7 @@ PALUDIS_INSTALL_TEST_DIE_PLEASE=yes \
PALUDIS_HOME=./install_TEST_dir/config/ ./paludis --environment :install-test \
--install target --resume-command-template `pwd`/install_TEST_dir/resume && exit 2
( echo -n './paludis ' ; cut -d ' ' -f2- < install_TEST_dir/resume ) > install_TEST_dir/fixedresume
+cat install_TEST_dir/fixedresume
PALUDIS_HOME=./install_TEST_dir/config/ bash `pwd`/install_TEST_dir/fixedresume || exit 3
./install_TEST_dir/root/usr/bin/testbin | grep success >/dev/null || exit 4
grep target install_TEST_dir/root/var/db/pkg/world >/dev/null || exit 5
diff --git a/src/clients/paludis/owner.cc b/src/clients/paludis/owner.cc
index 4d824886f..75a684510 100644
--- a/src/clients/paludis/owner.cc
+++ b/src/clients/paludis/owner.cc
@@ -18,6 +18,7 @@
*/
#include "owner.hh"
+#include <paludis/util/visitor-impl.hh>
#include <src/output/colour.hh>
#include "command_line.hh"
#include <paludis/paludis.hh>
@@ -32,7 +33,7 @@ using std::endl;
namespace
{
struct ContentsFinder :
- ContentsVisitorTypes::ConstVisitor
+ ConstVisitor<ContentsVisitorTypes>
{
bool found;
const std::string query;
@@ -53,34 +54,34 @@ namespace
found |= (std::string::npos != e.find(query));
}
- void visit(const ContentsFileEntry * const e)
+ void visit(const ContentsFileEntry & e)
{
- handle(e->name());
+ handle(e.name());
}
- void visit(const ContentsDirEntry * const e)
+ void visit(const ContentsDirEntry & e)
{
- handle(e->name());
+ handle(e.name());
}
- void visit(const ContentsSymEntry * const e)
+ void visit(const ContentsSymEntry & e)
{
- handle(e->name());
+ handle(e.name());
}
- void visit(const ContentsMiscEntry * const e)
+ void visit(const ContentsMiscEntry & e)
{
- handle(e->name());
+ handle(e.name());
}
- void visit(const ContentsFifoEntry * const e)
+ void visit(const ContentsFifoEntry & e)
{
- handle(e->name());
+ handle(e.name());
}
- void visit(const ContentsDevEntry * const e)
+ void visit(const ContentsDevEntry & e)
{
- handle(e->name());
+ handle(e.name());
}
};
}
@@ -116,7 +117,7 @@ do_one_owner(
PackageDatabaseEntry e(*p, *v, (*r)->name());
tr1::shared_ptr<const Contents> contents((*r)->contents_interface->contents(*p, *v));
ContentsFinder d(query, CommandLine::get_instance()->a_full_match.specified());
- std::for_each(contents->begin(), contents->end(), accept_visitor(&d));
+ std::for_each(indirect_iterator(contents->begin()), indirect_iterator(contents->end()), accept_visitor(d));
if (d.found)
{
cout << " " << e << endl;
diff --git a/src/clients/paludis/query.cc b/src/clients/paludis/query.cc
index 2a8289a4d..cc02eb4b3 100644
--- a/src/clients/paludis/query.cc
+++ b/src/clients/paludis/query.cc
@@ -27,6 +27,7 @@
#include <iostream>
#include <paludis/paludis.hh>
#include <paludis/util/collection_concrete.hh>
+#include <paludis/util/visitor-impl.hh>
#include <string>
/** \file
@@ -76,11 +77,11 @@ void do_one_set_query(
const tr1::shared_ptr<Environment>,
const std::string & q,
MaskReasons &,
- tr1::shared_ptr<DepSpec> set)
+ tr1::shared_ptr<const SetSpecTree::ConstItem> set)
{
cout << "* " << colour(cl_package_name, q) << endl;
DepSpecPrettyPrinter packages(12);
- set->accept(&packages);
+ set->accept(packages);
cout << " " << std::setw(22) << std::left << "Packages:" << std::setw(0)
<< endl << packages << endl;
}
@@ -95,7 +96,7 @@ void do_one_query(
/* we might have a dep spec, but we might just have a simple package name
* without a category. or it might be a set... all should work. */
tr1::shared_ptr<PackageDepSpec> spec;
- tr1::shared_ptr<DepSpec> set;
+ tr1::shared_ptr<const SetSpecTree::ConstItem> set;
if (std::string::npos == q.find('/'))
{
try
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index 0cd6457d0..6ee564832 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -29,6 +29,7 @@
#include <paludis/util/tokeniser.hh>
#include <paludis/util/join.hh>
#include <paludis/util/iterator.hh>
+#include <paludis/util/visitor-impl.hh>
#include <paludis/query.hh>
#include <algorithm>
@@ -647,7 +648,7 @@ void
ConsoleInstallTask::display_tag_summary_tag(tr1::shared_ptr<const DepTag> t)
{
tr1::shared_ptr<DepTagSummaryDisplayer> displayer(make_dep_tag_summary_displayer());
- t->accept(displayer.get());
+ t->accept(*displayer.get());
}
void
@@ -672,29 +673,29 @@ DepTagSummaryDisplayer::~DepTagSummaryDisplayer()
}
void
-DepTagSummaryDisplayer::visit(const GLSADepTag * const tag)
+DepTagSummaryDisplayer::visit(const GLSADepTag & tag)
{
- task()->output_starred_item(task()->render_as_tag(tag->short_text()) + ": "
- + tag->glsa_title());
+ task()->output_starred_item(task()->render_as_tag(tag.short_text()) + ": "
+ + tag.glsa_title());
}
void
-DepTagSummaryDisplayer::visit(const DependencyDepTag * const)
+DepTagSummaryDisplayer::visit(const DependencyDepTag &)
{
}
void
-DepTagSummaryDisplayer::visit(const GeneralSetDepTag * const tag)
+DepTagSummaryDisplayer::visit(const GeneralSetDepTag & tag)
{
std::string desc;
- if (tag->short_text() == "world")
+ if (tag.short_text() == "world")
desc = ": Packages that have been explicitly installed";
- else if (tag->short_text() == "everything")
+ else if (tag.short_text() == "everything")
desc = ": All installed packages";
- else if (tag->short_text() == "system")
+ else if (tag.short_text() == "system")
desc = ": Packages that are part of the base system";
- task()->output_starred_item(task()->render_as_tag(tag->short_text()) + desc);
+ task()->output_starred_item(task()->render_as_tag(tag.short_text()) + desc);
}
void
@@ -964,7 +965,7 @@ ConsoleInstallTask::display_merge_list_entry_tags(const DepListEntry & d, const
all_tags()->insert(*tag);
tr1::shared_ptr<EntryDepTagDisplayer> displayer(make_entry_dep_tag_displayer());
- tag->tag->accept(displayer.get());
+ tag->tag->accept(*displayer.get());
tag_titles.append(displayer->text());
tag_titles.append(", ");
}
@@ -1066,20 +1067,20 @@ EntryDepTagDisplayer::~EntryDepTagDisplayer()
}
void
-EntryDepTagDisplayer::visit(const GLSADepTag * const tag)
+EntryDepTagDisplayer::visit(const GLSADepTag & tag)
{
- text() = tag->short_text();
+ text() = tag.short_text();
}
void
-EntryDepTagDisplayer::visit(const DependencyDepTag * const)
+EntryDepTagDisplayer::visit(const DependencyDepTag &)
{
}
void
-EntryDepTagDisplayer::visit(const GeneralSetDepTag * const tag)
+EntryDepTagDisplayer::visit(const GeneralSetDepTag & tag)
{
- text() = tag->short_text(); // + "<" + tag->source() + ">";
+ text() = tag.short_text(); // + "<" + tag->source() + ">";
}
void
@@ -1117,7 +1118,7 @@ ConsoleInstallTask::display_merge_list_entry_mask_reasons(const DepListEntry & e
output_no_endl(" ");
LicenceDisplayer ld(output_stream(), environment(), e.package);
- metadata->license_interface->license()->accept(&ld);
+ metadata->license_interface->license()->accept(ld);
}
}
else if (mr_keyword == mm)
diff --git a/src/output/console_install_task.hh b/src/output/console_install_task.hh
index 93f0ac2e0..9d94bb0bb 100644
--- a/src/output/console_install_task.hh
+++ b/src/output/console_install_task.hh
@@ -45,7 +45,7 @@ namespace paludis
};
class PALUDIS_VISIBLE DepTagSummaryDisplayer :
- public DepTagVisitorTypes::ConstVisitor
+ public ConstVisitor<DepTagVisitorTypes>
{
private:
ConsoleInstallTask * _task;
@@ -54,9 +54,9 @@ namespace paludis
DepTagSummaryDisplayer(ConsoleInstallTask *) PALUDIS_ATTRIBUTE((nonnull(1)));
virtual ~DepTagSummaryDisplayer();
- void visit(const GLSADepTag * const tag);
- void visit(const DependencyDepTag * const);
- void visit(const GeneralSetDepTag * const tag);
+ void visit(const GLSADepTag &);
+ void visit(const DependencyDepTag &);
+ void visit(const GeneralSetDepTag &);
ConsoleInstallTask * task()
{
@@ -65,7 +65,7 @@ namespace paludis
};
class PALUDIS_VISIBLE EntryDepTagDisplayer :
- public DepTagVisitorTypes::ConstVisitor
+ public ConstVisitor<DepTagVisitorTypes>
{
private:
std::string _text;
@@ -74,9 +74,9 @@ namespace paludis
EntryDepTagDisplayer();
virtual ~EntryDepTagDisplayer();
- void visit(const GLSADepTag * const tag);
- void visit(const DependencyDepTag * const);
- void visit(const GeneralSetDepTag * const tag);
+ void visit(const GLSADepTag & tag);
+ void visit(const DependencyDepTag &);
+ void visit(const GeneralSetDepTag & tag);
std::string & text()
{
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index 40f0e6127..24f7106c3 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -20,6 +20,7 @@
#include "console_query_task.hh"
#include "licence.hh"
#include "use_flag_pretty_printer.hh"
+#include <paludis/util/visitor-impl.hh>
#include <paludis/util/collection_concrete.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/visitor-impl.hh>
@@ -199,7 +200,7 @@ ConsoleQueryTask::display_metadata(const PackageDepSpec &, const PackageDatabase
tr1::shared_ptr<const VersionMetadata> metadata(_imp->env->package_database()->fetch_repository(e.repository)->
version_metadata(e.name, e.version));
- display_metadata_dep("Homepage", "HOMEPAGE", metadata->homepage(), true);
+ display_metadata_uri("Homepage", "HOMEPAGE", metadata->homepage(), true);
display_metadata_key("Description", "DESCRIPTION", metadata->description);
if (metadata->license_interface)
@@ -207,10 +208,10 @@ ConsoleQueryTask::display_metadata(const PackageDepSpec &, const PackageDatabase
if (want_deps() && metadata->deps_interface)
{
- display_metadata_dep("Build dependencies", "DEPEND", metadata->deps_interface->build_depend(), want_raw());
- display_metadata_dep("Runtime dependencies", "RDEPEND", metadata->deps_interface->run_depend(), want_raw());
- display_metadata_dep("Post dependencies", "PDEPEND", metadata->deps_interface->post_depend(), want_raw());
- display_metadata_dep("Suggested dependencies", "SDEPEND", metadata->deps_interface->suggested_depend(), want_raw());
+ display_metadata_dependency("Build dependencies", "DEPEND", metadata->deps_interface->build_depend(), want_raw());
+ display_metadata_dependency("Runtime dependencies", "RDEPEND", metadata->deps_interface->run_depend(), want_raw());
+ display_metadata_dependency("Post dependencies", "PDEPEND", metadata->deps_interface->post_depend(), want_raw());
+ display_metadata_dependency("Suggested dependencies", "SDEPEND", metadata->deps_interface->suggested_depend(), want_raw());
}
if (metadata->origins_interface)
@@ -227,15 +228,15 @@ ConsoleQueryTask::display_metadata(const PackageDepSpec &, const PackageDatabase
if (metadata->ebuild_interface)
{
- display_metadata_dep("Provides", "PROVIDE", metadata->ebuild_interface->provide(), true);
+ display_metadata_provides("Provides", "PROVIDE", metadata->ebuild_interface->provide(), true);
display_metadata_iuse("Use flags", "IUSE", join(metadata->ebuild_interface->iuse()->begin(),
metadata->ebuild_interface->iuse()->end(), " "), e);
if (want_raw())
{
display_metadata_key("Keywords", "KEYWORDS", join(metadata->ebuild_interface->keywords()->begin(),
metadata->ebuild_interface->keywords()->end(), " "));
- display_metadata_dep("SRC_URI", "SRC_URI", metadata->ebuild_interface->src_uri(), true);
- display_metadata_dep("Restrict", "RESTRICT", metadata->ebuild_interface->restrictions(), true);
+ display_metadata_uri("SRC_URI", "SRC_URI", metadata->ebuild_interface->src_uri(), true);
+ display_metadata_restrict("Restrict", "RESTRICT", metadata->ebuild_interface->restrictions(), true);
}
}
@@ -264,7 +265,7 @@ ConsoleQueryTask::display_metadata_key(const std::string & k, const std::string
}
void
-ConsoleQueryTask::display_metadata_license(const std::string & k, const std::string & kk, tr1::shared_ptr<const DepSpec> l,
+ConsoleQueryTask::display_metadata_license(const std::string & k, const std::string & kk, tr1::shared_ptr<const LicenseSpecTree::ConstItem> l,
const PackageDatabaseEntry & display_entry) const
{
output_left_column((want_raw() ? kk : k) + ":");
@@ -272,13 +273,13 @@ ConsoleQueryTask::display_metadata_license(const std::string & k, const std::str
if (want_raw())
{
DepSpecPrettyPrinter p(0, false);
- l->accept(&p);
+ l->accept(p);
output_right_column(stringify(p));
}
else
{
LicenceDisplayer d(output_stream(), _imp->env, display_entry);
- l->accept(&d);
+ l->accept(d);
output_right_column("");
}
}
@@ -286,14 +287,14 @@ ConsoleQueryTask::display_metadata_license(const std::string & k, const std::str
namespace
{
struct IsEmpty :
- DepSpecVisitorTypes::ConstVisitor,
- DepSpecVisitorTypes::ConstVisitor::VisitChildren<IsEmpty, AllDepSpec>,
- DepSpecVisitorTypes::ConstVisitor::VisitChildren<IsEmpty, AnyDepSpec>,
- DepSpecVisitorTypes::ConstVisitor::VisitChildren<IsEmpty, UseDepSpec>
+ ConstVisitor<GenericSpecTree>,
+ ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, AllDepSpec>,
+ ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, AnyDepSpec>,
+ ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, UseDepSpec>
{
- using DepSpecVisitorTypes::ConstVisitor::VisitChildren<IsEmpty, AnyDepSpec>::visit;
- using DepSpecVisitorTypes::ConstVisitor::VisitChildren<IsEmpty, AllDepSpec>::visit;
- using DepSpecVisitorTypes::ConstVisitor::VisitChildren<IsEmpty, UseDepSpec>::visit;
+ using ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, AnyDepSpec>::visit_sequence;
+ using ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, AllDepSpec>::visit_sequence;
+ using ConstVisitor<GenericSpecTree>::VisitConstSequence<IsEmpty, UseDepSpec>::visit_sequence;
bool empty;
@@ -302,55 +303,87 @@ namespace
{
}
- void visit(const PackageDepSpec *)
+ void visit_leaf(const PackageDepSpec &)
{
empty = false;
}
- void visit(const BlockDepSpec *)
+ void visit_leaf(const BlockDepSpec &)
{
empty = false;
}
- void visit(const PlainTextDepSpec *)
+ void visit_leaf(const PlainTextDepSpec &)
{
empty = false;
}
};
- bool is_spec_empty(tr1::shared_ptr<const DepSpec> d)
+ template <typename T_>
+ bool is_spec_empty(tr1::shared_ptr<const T_> d)
{
IsEmpty e;
- d->accept(&e);
+ d->accept(e);
return e.empty;
}
}
-void
-ConsoleQueryTask::display_metadata_dep(const std::string & k, const std::string & kk,
- tr1::shared_ptr<const DepSpec> d, const bool one_line) const
+namespace
{
- if (is_spec_empty(d))
- return;
+ template <typename T_>
+ void display_dep(const ConsoleQueryTask * const q, const std::string & k,
+ const std::string & kk, tr1::shared_ptr<const T_> d, const bool one_line)
+ {
+ if (is_spec_empty(d))
+ return;
- output_left_column((want_raw() ? kk : k) + ":");
+ q->output_left_column((q->want_raw() ? kk : k) + ":");
- if (one_line)
- {
- DepSpecPrettyPrinter p(0, false);
- d->accept(&p);
- output_stream() << p << std::endl;
- }
- else
- {
- output_right_column("");
- DepSpecPrettyPrinter p(left_column_width() + 5);
- d->accept(&p);
- output_stream() << p;
+ if (one_line)
+ {
+ DepSpecPrettyPrinter p(0, false);
+ d->accept(p);
+ q->output_stream() << p << std::endl;
+ }
+ else
+ {
+ q->output_right_column("");
+ DepSpecPrettyPrinter p(q->left_column_width() + 5);
+ d->accept(p);
+ q->output_stream() << p;
+ }
}
}
void
+ConsoleQueryTask::display_metadata_dependency(const std::string & k, const std::string & kk,
+ tr1::shared_ptr<const DependencySpecTree::ConstItem> d, const bool one_line) const
+{
+ display_dep(this, k, kk, d, one_line);
+}
+
+void
+ConsoleQueryTask::display_metadata_uri(const std::string & k, const std::string & kk,
+ tr1::shared_ptr<const URISpecTree::ConstItem> d, const bool one_line) const
+{
+ display_dep(this, k, kk, d, one_line);
+}
+
+void
+ConsoleQueryTask::display_metadata_provides(const std::string & k, const std::string & kk,
+ tr1::shared_ptr<const ProvideSpecTree::ConstItem> d, const bool one_line) const
+{
+ display_dep(this, k, kk, d, one_line);
+}
+
+void
+ConsoleQueryTask::display_metadata_restrict(const std::string & k, const std::string & kk,
+ tr1::shared_ptr<const RestrictSpecTree::ConstItem> d, const bool one_line) const
+{
+ display_dep(this, k, kk, d, one_line);
+}
+
+void
ConsoleQueryTask::display_metadata_pde(const std::string & k, const std::string & kk,
const PackageDatabaseEntry & v) const
{
diff --git a/src/output/console_query_task.hh b/src/output/console_query_task.hh
index 054c2db23..b4cef8c43 100644
--- a/src/output/console_query_task.hh
+++ b/src/output/console_query_task.hh
@@ -46,9 +46,15 @@ namespace paludis
virtual void display_metadata_key(const std::string &, const std::string &,
const std::string &) const;
virtual void display_metadata_license(const std::string &, const std::string &,
- tr1::shared_ptr<const DepSpec>, const PackageDatabaseEntry &) const;
- virtual void display_metadata_dep(const std::string &, const std::string &,
- tr1::shared_ptr<const DepSpec>, const bool one_line) const;
+ tr1::shared_ptr<const LicenseSpecTree::ConstItem>, const PackageDatabaseEntry &) const;
+ virtual void display_metadata_dependency(const std::string &, const std::string &,
+ tr1::shared_ptr<const DependencySpecTree::ConstItem>, const bool one_line) const;
+ virtual void display_metadata_provides(const std::string &, const std::string &,
+ tr1::shared_ptr<const ProvideSpecTree::ConstItem>, const bool one_line) const;
+ virtual void display_metadata_uri(const std::string &, const std::string &,
+ tr1::shared_ptr<const URISpecTree::ConstItem>, const bool one_line) const;
+ virtual void display_metadata_restrict(const std::string &, const std::string &,
+ tr1::shared_ptr<const RestrictSpecTree::ConstItem>, const bool one_line) const;
virtual void display_metadata_pde(const std::string &, const std::string &, const PackageDatabaseEntry &) const;
virtual void display_metadata_time(const std::string &, const std::string &, time_t) const;
virtual void display_metadata_iuse(const std::string &, const std::string &, const std::string &,
diff --git a/src/output/licence.cc b/src/output/licence.cc
index 297673e58..c81f72192 100644
--- a/src/output/licence.cc
+++ b/src/output/licence.cc
@@ -22,44 +22,55 @@
#include <ostream>
#include <algorithm>
+using namespace paludis;
+
void
-LicenceDisplayer::visit(const paludis::AllDepSpec * spec)
+LicenceDisplayer::visit_sequence(const AllDepSpec &,
+ LicenseSpecTree::ConstSequenceIterator begin,
+ LicenseSpecTree::ConstSequenceIterator end)
{
stream << "( ";
- std::for_each(spec->begin(), spec->end(), paludis::accept_visitor(this));
+ std::for_each(begin, end, accept_visitor(*this));
stream << ") ";
}
void
-LicenceDisplayer::visit(const paludis::AnyDepSpec * spec)
+LicenceDisplayer::visit_sequence(const AnyDepSpec &,
+ LicenseSpecTree::ConstSequenceIterator begin,
+ LicenseSpecTree::ConstSequenceIterator end)
{
stream << "|| ( ";
- std::for_each(spec->begin(), spec->end(), paludis::accept_visitor(this));
+ std::for_each(begin, end, accept_visitor(*this));
stream << ") ";
}
void
-LicenceDisplayer::visit(const paludis::UseDepSpec * spec)
+LicenceDisplayer::visit_sequence(const UseDepSpec & spec,
+ LicenseSpecTree::ConstSequenceIterator begin,
+ LicenseSpecTree::ConstSequenceIterator end)
{
- stream << spec->flag() << "? ( ";
- std::for_each(spec->begin(), spec->end(), paludis::accept_visitor(this));
+ if (spec.inverse())
+ stream << "!";
+
+ stream << spec.flag() << "? ( ";
+ std::for_each(begin, end, accept_visitor(*this));
stream << ") ";
}
void
-LicenceDisplayer::visit(const paludis::PlainTextDepSpec * spec)
+LicenceDisplayer::visit_leaf(const PlainTextDepSpec & spec)
{
- if (env->accept_license(spec->text(), db_entry))
- stream << colour(cl_not_masked, spec->text());
+ if (env->accept_license(spec.text(), db_entry))
+ stream << colour(cl_not_masked, spec.text());
else
- stream << colour(cl_masked, "(" + spec->text() + ")!");
+ stream << colour(cl_masked, "(" + spec.text() + ")!");
stream << " ";
}
LicenceDisplayer::LicenceDisplayer(
std::ostream & s,
- const paludis::Environment * const e,
- const paludis::PackageDatabaseEntry & d) :
+ const Environment * const e,
+ const PackageDatabaseEntry & d) :
stream(s),
env(e),
db_entry(d)
diff --git a/src/output/licence.hh b/src/output/licence.hh
index e89400801..33c06c40e 100644
--- a/src/output/licence.hh
+++ b/src/output/licence.hh
@@ -27,7 +27,7 @@
* Display licences.
*/
struct PALUDIS_VISIBLE LicenceDisplayer :
- paludis::DepSpecVisitorTypes::ConstVisitor
+ paludis::ConstVisitor<paludis::LicenseSpecTree>
{
/// Our stream.
std::ostream & stream;
@@ -46,21 +46,21 @@ struct PALUDIS_VISIBLE LicenceDisplayer :
///\name Visit methods
///{
- void visit(const paludis::AllDepSpec * spec);
- void visit(const paludis::AnyDepSpec * spec);
+ void visit_sequence(const paludis::AllDepSpec &,
+ paludis::LicenseSpecTree::ConstSequenceIterator,
+ paludis::LicenseSpecTree::ConstSequenceIterator);
- void visit(const paludis::UseDepSpec * spec);
+ void visit_sequence(const paludis::AnyDepSpec &,
+ paludis::LicenseSpecTree::ConstSequenceIterator,
+ paludis::LicenseSpecTree::ConstSequenceIterator);
- void visit(const paludis::PlainTextDepSpec * spec);
+ void visit_sequence(const paludis::UseDepSpec &,
+ paludis::LicenseSpecTree::ConstSequenceIterator,
+ paludis::LicenseSpecTree::ConstSequenceIterator);
- void visit(const paludis::PackageDepSpec *)
- {
- }
+ void visit_leaf(const paludis::PlainTextDepSpec &);
- void visit(const paludis::BlockDepSpec *)
- {
- }
///}
};