aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-09-22 09:26:29 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-09-22 09:26:29 +0000
commit538756fb3236428ab50d027176e757c5dd2e3d1e (patch)
tree3cb68fd08fbd696e4d826c2882ab8ffa5057e52f
parent0f48cefea53ccd11d68255c5d52cf620b121303b (diff)
downloadpaludis-538756fb3236428ab50d027176e757c5dd2e3d1e.tar.gz
paludis-538756fb3236428ab50d027176e757c5dd2e3d1e.tar.xz
Formatters
-rw-r--r--paludis/Makefile.am.m41
-rw-r--r--paludis/dep_list/dep_list_TEST.cc13
-rw-r--r--paludis/dep_spec-fwd.hh66
-rw-r--r--paludis/dep_spec.cc27
-rw-r--r--paludis/dep_spec.hh2
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/formatter-fwd.hh41
-rw-r--r--paludis/formatter.cc23
-rw-r--r--paludis/formatter.hh572
-rw-r--r--paludis/metadata_key-fwd.hh2
-rw-r--r--paludis/metadata_key.cc10
-rw-r--r--paludis/metadata_key.hh31
-rw-r--r--paludis/name.cc5
-rw-r--r--paludis/name.sr3
-rw-r--r--paludis/repositories/cran/cran_dep_parser_TEST.cc62
-rw-r--r--paludis/repositories/cran/cran_package_id.cc29
-rw-r--r--paludis/repositories/cran/cran_package_id.hh6
-rw-r--r--paludis/repositories/cran/cran_repository.cc3
-rw-r--r--paludis/repositories/cran/dep_spec_pretty_printer.cc36
-rw-r--r--paludis/repositories/cran/dep_spec_pretty_printer.hh38
-rw-r--r--paludis/repositories/cran/keys.cc42
-rw-r--r--paludis/repositories/cran/keys.hh20
-rw-r--r--paludis/repositories/e/dep_parser_TEST.cc63
-rw-r--r--paludis/repositories/e/dep_spec_pretty_printer.cc248
-rw-r--r--paludis/repositories/e/dep_spec_pretty_printer.hh43
-rw-r--r--paludis/repositories/e/dep_spec_pretty_printer_TEST.cc27
-rw-r--r--paludis/repositories/e/e_key.cc362
-rw-r--r--paludis/repositories/e/e_key.hh72
-rw-r--r--paludis/repositories/e/e_repository_TEST.cc10
-rw-r--r--paludis/repositories/e/e_repository_profile.cc2
-rw-r--r--paludis/repositories/e/e_repository_sets_TEST.cc10
-rw-r--r--paludis/repositories/e/ebuild_flat_metadata_cache.cc4
-rw-r--r--paludis/repositories/e/ebuild_id.cc24
-rw-r--r--paludis/repositories/e/qa/visibility.cc5
-rw-r--r--paludis/repositories/e/vdb_id.cc20
-rw-r--r--paludis/repositories/e/vdb_repository.cc6
-rw-r--r--paludis/repositories/fake/fake_package_id.cc140
-rw-r--r--paludis/repositories/fake/fake_package_id.hh26
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc3
-rw-r--r--paludis/repositories/virtuals/package_id.cc56
-rw-r--r--paludis/repositories/virtuals/package_id.hh7
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc2
-rw-r--r--paludis/stringify_formatter-fwd.hh28
-rw-r--r--paludis/stringify_formatter-impl.hh131
-rw-r--r--paludis/stringify_formatter.cc293
-rw-r--r--paludis/stringify_formatter.hh100
-rw-r--r--paludis/stringify_formatter_TEST.cc120
-rw-r--r--paludis/tasks/report_task.cc18
-rw-r--r--paludis/tasks/report_task.hh20
-rw-r--r--paludis/util/files.m41
-rw-r--r--paludis/util/no_type.hh29
-rw-r--r--paludis/util/visitor-fwd.hh45
-rw-r--r--paludis/util/visitor.hh2
-rw-r--r--python/additional_tests.cc6
-rw-r--r--python/metadata_key.cc62
-rwxr-xr-xpython/metadata_key_TEST.py2
-rw-r--r--python/name.cc10
-rwxr-xr-xpython/name_TEST.py10
-rw-r--r--src/clients/contrarius/install.cc2
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/Makefile.am1
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc228
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh79
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc209
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/version_info_model.hh4
-rw-r--r--src/clients/paludis/install.cc1
-rw-r--r--src/clients/paludis/query.cc2
-rw-r--r--src/clients/paludis/report.cc59
-rw-r--r--src/clients/qualudis/qualudis.cc12
-rw-r--r--src/output/Makefile.am4
-rw-r--r--src/output/colour.hh2
-rw-r--r--src/output/colour_formatter.cc386
-rw-r--r--src/output/colour_formatter.hh103
-rw-r--r--src/output/console_install_task.cc93
-rw-r--r--src/output/console_install_task.hh4
-rw-r--r--src/output/console_query_task.cc282
-rw-r--r--src/output/console_query_task.hh8
-rw-r--r--src/output/licence.cc82
-rw-r--r--src/output/licence.hh69
-rw-r--r--src/output/mask_displayer.cc243
-rw-r--r--src/output/mask_displayer.hh53
-rw-r--r--src/output/use_flag_pretty_printer.cc295
-rw-r--r--src/output/use_flag_pretty_printer.hh79
82 files changed, 4175 insertions, 1166 deletions
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index e83fced..4aa31e8 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -175,6 +175,7 @@ TESTS_ENVIRONMENT = env \
PALUDIS_PYTHON_DIR="$(top_srcdir)/python/" \
LD_LIBRARY_PATH="`echo $$LD_LIBRARY_PATH: | sed -e 's,^:,,'`` \
$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/.libs/ \
+ `:`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/paludis/util/.libs/ \
`:`$(top_srcdir)/paludis/repositories/e/ebuild/utils/canonicalise $(top_builddir)/python/.libs/`" \
bash $(top_srcdir)/test/run_test.sh
diff --git a/paludis/dep_list/dep_list_TEST.cc b/paludis/dep_list/dep_list_TEST.cc
index 4a73f9e..d5ac3f4 100644
--- a/paludis/dep_list/dep_list_TEST.cc
+++ b/paludis/dep_list/dep_list_TEST.cc
@@ -22,6 +22,7 @@
#include <paludis/util/set.hh>
#include <paludis/package_id.hh>
#include <paludis/mask.hh>
+#include <paludis/stringify_formatter-impl.hh>
#include <paludis/repositories/fake/fake_package_id.hh>
#include <paludis/dep_list/override_functions.hh>
#include <paludis/repositories/e/dep_spec_pretty_printer.hh>
@@ -1738,7 +1739,8 @@ namespace test_cases
{
cat_three_has_tag_from_cat_one = true;
TEST_CHECK_STRINGIFY_EQUAL(*tag->dependency(), "cat/three");
- erepository::DepSpecPrettyPrinter pretty(0, false);
+ StringifyFormatter ff;
+ erepository::DepSpecPrettyPrinter pretty(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
tag->conditions()->accept(pretty);
TEST_CHECK_STRINGIFY_EQUAL(pretty, "cat/three");
}
@@ -1748,14 +1750,16 @@ namespace test_cases
if ("<cat/three-1" == stringify(*tag->dependency()))
{
cat_three_has_first_tag_from_cat_two = true;
- erepository::DepSpecPrettyPrinter pretty(0, false);
+ StringifyFormatter ff;
+ erepository::DepSpecPrettyPrinter pretty(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
tag->conditions()->accept(pretty);
TEST_CHECK_STRINGIFY_EQUAL(pretty, "enabled? ( || ( <cat/three-1 ) )");
}
else if ("cat/three:0" == stringify(*tag->dependency()))
{
cat_three_has_second_tag_from_cat_two = true;
- erepository::DepSpecPrettyPrinter pretty(0, false);
+ StringifyFormatter ff;
+ erepository::DepSpecPrettyPrinter pretty(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
tag->conditions()->accept(pretty);
TEST_CHECK_STRINGIFY_EQUAL(pretty, "enabled? ( || ( cat/three:0 ) )");
}
@@ -1781,7 +1785,8 @@ namespace test_cases
tr1::static_pointer_cast<const DependencyDepTag>(tags->begin()->tag));
TEST_CHECK_EQUAL(deptag->short_text(), "cat/two-1:0::repo");
TEST_CHECK_STRINGIFY_EQUAL(*deptag->dependency(), "=cat/four-1");
- erepository::DepSpecPrettyPrinter pretty(0, false);
+ StringifyFormatter ff;
+ erepository::DepSpecPrettyPrinter pretty(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
deptag->conditions()->accept(pretty);
TEST_CHECK_STRINGIFY_EQUAL(pretty, "enabled? ( || ( =cat/four-1 ) )");
diff --git a/paludis/dep_spec-fwd.hh b/paludis/dep_spec-fwd.hh
index 3824d11..6e0fea2 100644
--- a/paludis/dep_spec-fwd.hh
+++ b/paludis/dep_spec-fwd.hh
@@ -22,7 +22,8 @@
#include <iosfwd>
#include <string>
-#include <paludis/dep_label.hh>
+#include <paludis/dep_label-fwd.hh>
+#include <paludis/formatter-fwd.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/visitor.hh>
@@ -74,6 +75,27 @@ namespace paludis
std::ostream & operator<< (std::ostream &, const LabelsDepSpec<DependencyLabelVisitorTypes> &) PALUDIS_VISIBLE;
/**
+ * A BlockDepSpec can be written to an ostream.
+ *
+ * \ingroup grpdepspecs
+ */
+ std::ostream & operator<< (std::ostream &, const BlockDepSpec &) PALUDIS_VISIBLE;
+
+ /**
+ * A URIDepSpec can be written to an ostream.
+ *
+ * \ingroup grpdepspecs
+ */
+ std::ostream & operator<< (std::ostream &, const URIDepSpec &) PALUDIS_VISIBLE;
+
+ /**
+ * A UseDepSpec can be written to an ostream.
+ *
+ * \ingroup grpdepspecs
+ */
+ std::ostream & operator<< (std::ostream &, const UseDepSpec &) PALUDIS_VISIBLE;
+
+ /**
* A generic DepSpec heirarchy.
*
* \ingroup grpdepspecs
@@ -93,6 +115,15 @@ namespace paludis
ConstTreeSequence<GenericSpecTree, UseDepSpec>
>
{
+ typedef Formatter<
+ UseDepSpec,
+ PlainTextDepSpec,
+ URIDepSpec,
+ PackageDepSpec,
+ BlockDepSpec,
+ LabelsDepSpec<URILabelVisitorTypes>,
+ LabelsDepSpec<DependencyLabelVisitorTypes>
+ > Formatter;
};
/**
@@ -110,6 +141,10 @@ namespace paludis
ConstTreeSequence<LicenseSpecTree, UseDepSpec>
>
{
+ typedef Formatter<
+ UseDepSpec,
+ PlainTextDepSpec
+ > Formatter;
};
/**
@@ -127,6 +162,11 @@ namespace paludis
ConstTreeSequence<URISpecTree, UseDepSpec>
>
{
+ typedef Formatter<
+ UseDepSpec,
+ URIDepSpec,
+ LabelsDepSpec<URILabelVisitorTypes>
+ > Formatter;
};
/**
@@ -146,6 +186,13 @@ namespace paludis
ConstTreeSequence<FlattenableSpecTree, UseDepSpec>
>
{
+ typedef Formatter<
+ UseDepSpec,
+ PlainTextDepSpec,
+ URIDepSpec,
+ PackageDepSpec,
+ BlockDepSpec
+ > Formatter;
};
/**
@@ -162,6 +209,10 @@ namespace paludis
ConstTreeSequence<ProvideSpecTree, UseDepSpec>
>
{
+ typedef Formatter<
+ UseDepSpec,
+ PackageDepSpec
+ > Formatter;
};
/**
@@ -178,6 +229,10 @@ namespace paludis
ConstTreeSequence<RestrictSpecTree, UseDepSpec>
>
{
+ typedef Formatter<
+ UseDepSpec,
+ PlainTextDepSpec
+ > Formatter;
};
/**
@@ -197,6 +252,12 @@ namespace paludis
ConstTreeSequence<DependencySpecTree, UseDepSpec>
>
{
+ typedef Formatter<
+ UseDepSpec,
+ PackageDepSpec,
+ BlockDepSpec,
+ LabelsDepSpec<DependencyLabelVisitorTypes>
+ > Formatter;
};
/**
@@ -212,6 +273,9 @@ namespace paludis
ConstTreeSequence<SetSpecTree, AllDepSpec>
>
{
+ typedef Formatter<
+ PackageDepSpec
+ > Formatter;
};
}
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index e5960b0..06ef737 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -647,6 +647,33 @@ paludis::operator<< (std::ostream & s, const PlainTextDepSpec & a)
}
std::ostream &
+paludis::operator<< (std::ostream & s, const BlockDepSpec & a)
+{
+ s << "!" << *a.blocked_spec();
+ return s;
+}
+
+std::ostream &
+paludis::operator<< (std::ostream & s, const UseDepSpec & a)
+{
+ if (a.inverse())
+ s << "!";
+ s << a.flag() << "?";
+ return s;
+}
+
+std::ostream &
+paludis::operator<< (std::ostream & s, const URIDepSpec & p)
+{
+ if (! p.renamed_url_suffix().empty())
+ s << p.original_url() << " -> " << p.renamed_url_suffix();
+ else
+ s << p.original_url();
+
+ return s;
+}
+
+std::ostream &
paludis::operator<< (std::ostream & s, const PackageDepSpec & a)
{
if (a.version_requirements_ptr())
diff --git a/paludis/dep_spec.hh b/paludis/dep_spec.hh
index c368c12..8c63f48 100644
--- a/paludis/dep_spec.hh
+++ b/paludis/dep_spec.hh
@@ -22,7 +22,7 @@
#include <paludis/dep_spec-fwd.hh>
#include <paludis/dep_tag-fwd.hh>
-#include <paludis/dep_label-fwd.hh>
+#include <paludis/dep_label.hh>
#include <paludis/name.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/clone.hh>
diff --git a/paludis/files.m4 b/paludis/files.m4
index da5cc12..15dd880 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -19,6 +19,7 @@ add(`dep_tag', `hh', `cc', `fwd', `sr')
add(`distribution', `hh', `cc', `fwd', `sr')
add(`environment', `hh', `fwd', `cc', `se')
add(`environment_implementation', `hh', `cc')
+add(`formatter', `hh', `fwd', `cc')
add(`hashed_containers', `hh', `cc', `test')
add(`hook', `hh', `cc', `fwd',`se', `sr')
add(`hooker', `hh', `cc', `test', `testscript')
@@ -36,6 +37,7 @@ add(`repository', `hh', `fwd', `cc', `sr')
add(`repository_info', `hh', `fwd', `cc')
add(`repository_name_cache', `hh', `cc', `test', `testscript')
add(`set_file', `hh', `cc', `se', `sr', `test', `testscript')
+add(`stringify_formatter', `hh', `cc', `fwd', `impl', `test')
add(`syncer', `hh', `cc', `sr')
add(`version_operator', `hh', `cc', `fwd', `se', `test')
add(`version_requirements', `hh', `cc', `fwd', `sr')
diff --git a/paludis/formatter-fwd.hh b/paludis/formatter-fwd.hh
new file mode 100644
index 0000000..a7904a5
--- /dev/null
+++ b/paludis/formatter-fwd.hh
@@ -0,0 +1,41 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_FORMATTER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_FORMATTER_FWD_HH 1
+
+#include <paludis/util/no_type.hh>
+
+namespace paludis
+{
+ template <
+ typename T1_,
+ typename T2_ = NoType<2u>,
+ typename T3_ = NoType<3u>,
+ typename T4_ = NoType<4u>,
+ typename T5_ = NoType<5u>,
+ typename T6_ = NoType<6u>,
+ typename T7_ = NoType<7u>,
+ typename T8_ = NoType<8u>,
+ typename T9_ = NoType<9u>
+ >
+ class Formatter;
+}
+
+#endif
diff --git a/paludis/formatter.cc b/paludis/formatter.cc
new file mode 100644
index 0000000..ec15555
--- /dev/null
+++ b/paludis/formatter.cc
@@ -0,0 +1,23 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/formatter.hh>
+
+using namespace paludis;
+
diff --git a/paludis/formatter.hh b/paludis/formatter.hh
new file mode 100644
index 0000000..d4ec9f3
--- /dev/null
+++ b/paludis/formatter.hh
@@ -0,0 +1,572 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_FORMATTER_HH
+#define PALUDIS_GUARD_PALUDIS_FORMATTER_HH 1
+
+#include <paludis/formatter-fwd.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+#include <paludis/util/attributes.hh>
+#include <string>
+
+namespace paludis
+{
+ class PlainTextDepSpec;
+ class UseDepSpec;
+ class PackageDepSpec;
+
+ namespace format
+ {
+ struct Plain
+ {
+ };
+
+ struct Enabled
+ {
+ };
+
+ struct Disabled
+ {
+ };
+
+ struct Masked
+ {
+ };
+
+ struct Forced
+ {
+ };
+
+ struct Changed
+ {
+ };
+
+ struct Added
+ {
+ };
+
+ struct Accepted
+ {
+ };
+
+ struct Unaccepted
+ {
+ };
+
+ struct Installed
+ {
+ };
+
+ struct Installable
+ {
+ };
+
+ struct PlainRoles;
+ struct IUseRoles;
+ struct UseRoles;
+ struct AcceptableRoles;
+ struct PackageRoles;
+ struct NoRoles;
+
+ template <typename T_>
+ struct CategorySelector
+ {
+ typedef PlainRoles Category;
+ };
+
+ template <>
+ struct CategorySelector<IUseFlag>
+ {
+ typedef IUseRoles Category;
+ };
+
+ template <>
+ struct CategorySelector<UseFlagName>
+ {
+ typedef UseRoles Category;
+ };
+
+ template <>
+ struct CategorySelector<UseDepSpec>
+ {
+ typedef UseRoles Category;
+ };
+
+ template <>
+ struct CategorySelector<PlainTextDepSpec>
+ {
+ typedef AcceptableRoles Category;
+ };
+
+ template <>
+ struct CategorySelector<KeywordName>
+ {
+ typedef AcceptableRoles Category;
+ };
+
+ template <>
+ struct CategorySelector<PackageDepSpec>
+ {
+ typedef PackageRoles Category;
+ };
+
+ template <>
+ struct CategorySelector<PackageID>
+ {
+ typedef PackageRoles Category;
+ };
+
+ template <typename T_>
+ struct CategorySelector<tr1::shared_ptr<T_> >
+ {
+ typedef typename CategorySelector<T_>::Category Category;
+ };
+
+ template <typename T_>
+ struct CategorySelector<const T_>
+ {
+ typedef typename CategorySelector<T_>::Category Category;
+ };
+
+ template <unsigned u_>
+ struct CategorySelector<NoType<u_> >
+ {
+ typedef NoRoles Category;
+ };
+ }
+
+ template <typename T_, typename C_>
+ struct CanFormatBase;
+
+ template <typename T_>
+ class PALUDIS_VISIBLE CanFormatBase<T_, format::PlainRoles>
+ {
+ public:
+ CanFormatBase()
+ {
+ }
+
+ virtual ~CanFormatBase()
+ {
+ }
+
+ virtual std::string format(const T_ &, const format::Plain &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ template <typename T_>
+ class PALUDIS_VISIBLE CanFormatBase<T_, format::AcceptableRoles>
+ {
+ public:
+ CanFormatBase()
+ {
+ }
+
+ virtual ~CanFormatBase()
+ {
+ }
+
+ virtual std::string format(const T_ &, const format::Plain &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string format(const T_ &, const format::Accepted &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string format(const T_ &, const format::Unaccepted &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ template <typename T_>
+ class PALUDIS_VISIBLE CanFormatBase<T_, format::UseRoles>
+ {
+ public:
+ CanFormatBase()
+ {
+ }
+
+ virtual ~CanFormatBase()
+ {
+ }
+
+ virtual std::string format(const T_ &, const format::Plain &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string format(const T_ &, const format::Enabled &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string format(const T_ &, const format::Disabled &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string format(const T_ &, const format::Forced &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string format(const T_ &, const format::Masked &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ template <typename T_>
+ class PALUDIS_VISIBLE CanFormatBase<T_, format::IUseRoles>
+ {
+ public:
+ CanFormatBase()
+ {
+ }
+
+ virtual ~CanFormatBase()
+ {
+ }
+
+ virtual std::string format(const T_ &, const format::Plain &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string format(const T_ &, const format::Enabled &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string format(const T_ &, const format::Disabled &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string format(const T_ &, const format::Forced &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string format(const T_ &, const format::Masked &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string decorate(const T_ &, const std::string &, const format::Added &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string decorate(const T_ &, const std::string &, const format::Changed &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ template <typename T_>
+ class PALUDIS_VISIBLE CanFormatBase<T_, format::PackageRoles>
+ {
+ public:
+ CanFormatBase()
+ {
+ }
+
+ virtual ~CanFormatBase()
+ {
+ }
+
+ virtual std::string format(const T_ &, const format::Plain &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string format(const T_ &, const format::Installed &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string format(const T_ &, const format::Installable &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ template <unsigned u_>
+ class PALUDIS_VISIBLE CanFormatBase<NoType<u_>, format::NoRoles>
+ {
+ public:
+ CanFormatBase()
+ {
+ }
+ };
+
+ template <typename T_>
+ class PALUDIS_VISIBLE CanFormat :
+ public CanFormatBase<T_, typename format::CategorySelector<T_>::Category>
+ {
+ public:
+ CanFormat()
+ {
+ }
+ };
+
+ class PALUDIS_VISIBLE CanSpace
+ {
+ public:
+ CanSpace()
+ {
+ }
+
+ virtual ~CanSpace()
+ {
+ }
+
+ virtual std::string newline() const = 0;
+ virtual std::string indent(const int) const = 0;
+ };
+
+ template <typename T_, typename C_, unsigned u_>
+ class FormatFunctionsByProxy;
+
+ template <typename T_, unsigned u_>
+ class PALUDIS_VISIBLE FormatFunctionsByProxy<T_, format::PlainRoles, u_> :
+ public CanFormat<T_>
+ {
+ private:
+ const CanFormat<T_> * const _proxy;
+
+ public:
+ FormatFunctionsByProxy(const CanFormat<T_> * const p) :
+ _proxy(p)
+ {
+ }
+
+ virtual std::string format(const T_ & s, const format::Plain & p) const
+ {
+ return _proxy->format(s, p);
+ }
+ };
+
+ template <typename T_, unsigned u_>
+ class PALUDIS_VISIBLE FormatFunctionsByProxy<T_, format::AcceptableRoles, u_> :
+ public CanFormat<T_>
+ {
+ private:
+ const CanFormat<T_> * const _proxy;
+
+ public:
+ FormatFunctionsByProxy(const CanFormat<T_> * const p) :
+ _proxy(p)
+ {
+ }
+
+ virtual std::string format(const T_ & s, const format::Plain & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string format(const T_ & s, const format::Accepted & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string format(const T_ & s, const format::Unaccepted & p) const
+ {
+ return _proxy->format(s, p);
+ }
+ };
+
+ template <typename T_, unsigned u_>
+ class PALUDIS_VISIBLE FormatFunctionsByProxy<T_, format::UseRoles, u_> :
+ public CanFormat<T_>
+ {
+ private:
+ const CanFormat<T_> * const _proxy;
+
+ public:
+ FormatFunctionsByProxy(const CanFormat<T_> * const p) :
+ _proxy(p)
+ {
+ }
+
+ virtual std::string format(const T_ & s, const format::Plain & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string format(const T_ & s, const format::Enabled & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string format(const T_ & s, const format::Disabled & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string format(const T_ & s, const format::Forced & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string format(const T_ & s, const format::Masked & p) const
+ {
+ return _proxy->format(s, p);
+ }
+ };
+
+ template <typename T_, unsigned u_>
+ class PALUDIS_VISIBLE FormatFunctionsByProxy<T_, format::IUseRoles, u_> :
+ public CanFormat<T_>
+ {
+ private:
+ const CanFormat<T_> * const _proxy;
+
+ public:
+ FormatFunctionsByProxy(const CanFormat<T_> * const p) :
+ _proxy(p)
+ {
+ }
+
+ virtual std::string format(const T_ & s, const format::Plain & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string format(const T_ & s, const format::Enabled & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string format(const T_ & s, const format::Disabled & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string format(const T_ & s, const format::Forced & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string format(const T_ & s, const format::Masked & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string decorate(const T_ & t, const std::string & s, const format::Changed & p) const
+ {
+ return _proxy->decorate(t, s, p);
+ }
+
+ virtual std::string decorate(const T_ & t, const std::string & s, const format::Added & p) const
+ {
+ return _proxy->decorate(t, s, p);
+ }
+ };
+
+ template <typename T_, unsigned u_>
+ class PALUDIS_VISIBLE FormatFunctionsByProxy<T_, format::PackageRoles, u_> :
+ public CanFormat<T_>
+ {
+ private:
+ const CanFormat<T_> * const _proxy;
+
+ public:
+ FormatFunctionsByProxy(const CanFormat<T_> * const p) :
+ _proxy(p)
+ {
+ }
+
+ virtual std::string format(const T_ & s, const format::Plain & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string format(const T_ & s, const format::Installed & p) const
+ {
+ return _proxy->format(s, p);
+ }
+
+ virtual std::string format(const T_ & s, const format::Installable & p) const
+ {
+ return _proxy->format(s, p);
+ }
+ };
+
+ template <unsigned u_>
+ class PALUDIS_VISIBLE FormatFunctionsByProxy<NoType<u_>, format::NoRoles, u_>
+ {
+ public:
+ FormatFunctionsByProxy(const void * const)
+ {
+ }
+
+ void format(const NoType<u_> &) const;
+ };
+
+ template <
+ typename T1_,
+ typename T2_,
+ typename T3_,
+ typename T4_,
+ typename T5_,
+ typename T6_,
+ typename T7_,
+ typename T8_,
+ typename T9_
+ >
+ class PALUDIS_VISIBLE Formatter :
+ public FormatFunctionsByProxy<T1_, typename format::CategorySelector<T1_>::Category, 1>,
+ public FormatFunctionsByProxy<T2_, typename format::CategorySelector<T2_>::Category, 2>,
+ public FormatFunctionsByProxy<T3_, typename format::CategorySelector<T3_>::Category, 3>,
+ public FormatFunctionsByProxy<T4_, typename format::CategorySelector<T4_>::Category, 4>,
+ public FormatFunctionsByProxy<T5_, typename format::CategorySelector<T5_>::Category, 5>,
+ public FormatFunctionsByProxy<T6_, typename format::CategorySelector<T6_>::Category, 6>,
+ public FormatFunctionsByProxy<T7_, typename format::CategorySelector<T7_>::Category, 7>,
+ public FormatFunctionsByProxy<T8_, typename format::CategorySelector<T8_>::Category, 8>,
+ public FormatFunctionsByProxy<T9_, typename format::CategorySelector<T9_>::Category, 9>,
+ public CanSpace
+ {
+ private:
+ const CanSpace * const _proxy;
+
+ public:
+ template <typename T_>
+ Formatter(const T_ & t) :
+ FormatFunctionsByProxy<T1_, typename format::CategorySelector<T1_>::Category, 1>(&t),
+ FormatFunctionsByProxy<T2_, typename format::CategorySelector<T2_>::Category, 2>(&t),
+ FormatFunctionsByProxy<T3_, typename format::CategorySelector<T3_>::Category, 3>(&t),
+ FormatFunctionsByProxy<T4_, typename format::CategorySelector<T4_>::Category, 4>(&t),
+ FormatFunctionsByProxy<T5_, typename format::CategorySelector<T5_>::Category, 5>(&t),
+ FormatFunctionsByProxy<T6_, typename format::CategorySelector<T6_>::Category, 6>(&t),
+ FormatFunctionsByProxy<T7_, typename format::CategorySelector<T7_>::Category, 7>(&t),
+ FormatFunctionsByProxy<T8_, typename format::CategorySelector<T8_>::Category, 8>(&t),
+ FormatFunctionsByProxy<T9_, typename format::CategorySelector<T9_>::Category, 9>(&t),
+ _proxy(&t)
+ {
+ }
+
+ Formatter(const Formatter & other) :
+ FormatFunctionsByProxy<T1_, typename format::CategorySelector<T1_>::Category, 1>(other),
+ FormatFunctionsByProxy<T2_, typename format::CategorySelector<T2_>::Category, 2>(other),
+ FormatFunctionsByProxy<T3_, typename format::CategorySelector<T3_>::Category, 3>(other),
+ FormatFunctionsByProxy<T4_, typename format::CategorySelector<T4_>::Category, 4>(other),
+ FormatFunctionsByProxy<T5_, typename format::CategorySelector<T5_>::Category, 5>(other),
+ FormatFunctionsByProxy<T6_, typename format::CategorySelector<T6_>::Category, 6>(other),
+ FormatFunctionsByProxy<T7_, typename format::CategorySelector<T7_>::Category, 7>(other),
+ FormatFunctionsByProxy<T8_, typename format::CategorySelector<T8_>::Category, 8>(other),
+ FormatFunctionsByProxy<T9_, typename format::CategorySelector<T9_>::Category, 9>(other),
+ CanSpace(other),
+ _proxy(other._proxy)
+ {
+ }
+
+ using FormatFunctionsByProxy<T1_, typename format::CategorySelector<T1_>::Category, 1>::format;
+ using FormatFunctionsByProxy<T2_, typename format::CategorySelector<T2_>::Category, 2>::format;
+ using FormatFunctionsByProxy<T3_, typename format::CategorySelector<T3_>::Category, 3>::format;
+ using FormatFunctionsByProxy<T4_, typename format::CategorySelector<T4_>::Category, 4>::format;
+ using FormatFunctionsByProxy<T5_, typename format::CategorySelector<T5_>::Category, 5>::format;
+ using FormatFunctionsByProxy<T6_, typename format::CategorySelector<T6_>::Category, 6>::format;
+ using FormatFunctionsByProxy<T7_, typename format::CategorySelector<T7_>::Category, 7>::format;
+ using FormatFunctionsByProxy<T8_, typename format::CategorySelector<T8_>::Category, 8>::format;
+ using FormatFunctionsByProxy<T9_, typename format::CategorySelector<T9_>::Category, 9>::format;
+
+ virtual std::string newline() const
+ {
+ return _proxy->newline();
+ }
+
+ virtual std::string indent(const int i) const
+ {
+ return _proxy->indent(i);
+ }
+ };
+}
+
+#endif
diff --git a/paludis/metadata_key-fwd.hh b/paludis/metadata_key-fwd.hh
index 9a37b3f..b71eb4d 100644
--- a/paludis/metadata_key-fwd.hh
+++ b/paludis/metadata_key-fwd.hh
@@ -21,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_METADATA_KEY_FWD_HH 1
#include <paludis/util/attributes.hh>
+#include <paludis/name-fwd.hh>
#include <iosfwd>
namespace paludis
@@ -35,6 +36,7 @@ namespace paludis
class MetadataRepositoryMaskInfoKey;
class MetadataFSEntryKey;
template <typename C_> class MetadataSetKey;
+ template <> class MetadataSetKey<IUseFlagSet>;
template <typename C_> class MetadataSpecTreeKey;
#include <paludis/metadata_key-se.hh>
diff --git a/paludis/metadata_key.cc b/paludis/metadata_key.cc
index 9ae97c8..b78db75 100644
--- a/paludis/metadata_key.cc
+++ b/paludis/metadata_key.cc
@@ -17,11 +17,14 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include "metadata_key.hh"
+#include <paludis/metadata_key.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/name.hh>
using namespace paludis;
@@ -108,6 +111,11 @@ MetadataSetKey<C_>::MetadataSetKey(const std::string & r, const std::string & h,
{
}
+MetadataSetKey<IUseFlagSet>::MetadataSetKey(const std::string & r, const std::string & h, const MetadataKeyType t) :
+ MetadataKey(r, h, t)
+{
+}
+
template <typename C_>
MetadataSpecTreeKey<C_>::MetadataSpecTreeKey(const std::string & r, const std::string & h, const MetadataKeyType t) :
MetadataKey(r, h, t)
diff --git a/paludis/metadata_key.hh b/paludis/metadata_key.hh
index 4b71621..4bdd283 100644
--- a/paludis/metadata_key.hh
+++ b/paludis/metadata_key.hh
@@ -27,6 +27,7 @@
#include <paludis/dep_spec-fwd.hh>
#include <paludis/contents-fwd.hh>
#include <paludis/repository-fwd.hh>
+#include <paludis/formatter-fwd.hh>
#include <paludis/util/fs_entry-fwd.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/instantiation_policy.hh>
@@ -159,6 +160,32 @@ namespace paludis
public:
virtual const tr1::shared_ptr<const C_> value() const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string pretty_print_flat(const Formatter<typename C_::value_type> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+ };
+
+ template <>
+ class PALUDIS_VISIBLE MetadataSetKey<IUseFlagSet> :
+ public MetadataKey,
+ public ConstAcceptInterfaceVisitsThis<MetadataKeyVisitorTypes, MetadataSetKey<IUseFlagSet> >
+ {
+ protected:
+ MetadataSetKey(const std::string &, const std::string &, const MetadataKeyType);
+
+ public:
+ virtual const tr1::shared_ptr<const IUseFlagSet> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string pretty_print_flat(const Formatter<IUseFlag> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
+
+ virtual std::string pretty_print_flat_with_comparison(
+ const Environment * const,
+ const tr1::shared_ptr<const PackageID> &,
+ const Formatter<IUseFlag> &
+ ) const
+ PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
};
template <typename C_>
@@ -173,10 +200,10 @@ namespace paludis
virtual const tr1::shared_ptr<const typename C_::ConstItem> value() const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- virtual std::string pretty_print() const
+ virtual std::string pretty_print(const typename C_::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
- virtual std::string pretty_print_flat() const
+ virtual std::string pretty_print_flat(const typename C_::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result)) = 0;
};
}
diff --git a/paludis/name.cc b/paludis/name.cc
index 3afa6ab..e472198 100644
--- a/paludis/name.cc
+++ b/paludis/name.cc
@@ -407,9 +407,10 @@ namespace
}
}
-IUseFlag::IUseFlag(const std::string & s, IUseFlagParseMode m) try:
+IUseFlag::IUseFlag(const std::string & s, IUseFlagParseMode m, const std::string::size_type p) try:
flag(get_flag(s)),
- state(get_state(s, m))
+ state(get_state(s, m)),
+ prefix_delim_pos(p)
{
}
catch (const UseFlagNameError &)
diff --git a/paludis/name.sr b/paludis/name.sr
index c65e9e0..29eca3e 100644
--- a/paludis/name.sr
+++ b/paludis/name.sr
@@ -30,11 +30,12 @@ make_class_IUseFlag()
key flag UseFlagName
key state UseFlagState
+ key prefix_delim_pos "std::string::size_type"
comparison_operators all flag
extra_constructors <<END
- IUseFlag(const std::string &, const IUseFlagParseMode);
+ IUseFlag(const std::string &, const IUseFlagParseMode, const std::string::size_type);
END
doxygen_comment << "END"
diff --git a/paludis/repositories/cran/cran_dep_parser_TEST.cc b/paludis/repositories/cran/cran_dep_parser_TEST.cc
index 5463d5b..37803c5 100644
--- a/paludis/repositories/cran/cran_dep_parser_TEST.cc
+++ b/paludis/repositories/cran/cran_dep_parser_TEST.cc
@@ -20,9 +20,11 @@
#include <paludis/dep_spec.hh>
#include <paludis/dep_spec_flattener.hh>
#include <paludis/repositories/cran/cran_dep_parser.hh>
+#include <paludis/repositories/cran/dep_spec_pretty_printer.hh>
#include <paludis/environments/test/test_environment.hh>
#include <paludis/util/system.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/stringify_formatter.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -30,57 +32,6 @@
using namespace test;
using namespace paludis;
-namespace
-{
- struct Stringifier :
- ConstVisitor<DependencySpecTree>
- {
- std::ostringstream s;
-
- void visit_leaf(const PackageDepSpec & p)
- {
- s << p << " ";
- }
-
- void visit_leaf(const BlockDepSpec &)
- {
- s << "!!!BLOCK!!!";
- }
-
- void visit_leaf(const LabelsDepSpec<DependencyLabelVisitorTypes> &)
- {
- s << "!!!LABEL!!!";
- }
-
- void visit_sequence(const AllDepSpec &,
- DependencySpecTree::ConstSequenceIterator cur,
- DependencySpecTree::ConstSequenceIterator end)
- {
- s << "ALL(";
- std::for_each(cur, end, accept_visitor(*this));
- s << ")";
- }
-
- void visit_sequence(const AnyDepSpec &,
- DependencySpecTree::ConstSequenceIterator cur,
- DependencySpecTree::ConstSequenceIterator end)
- {
- s << "ANY(";
- std::for_each(cur, end, accept_visitor(*this));
- s << ")";
- }
-
- void visit_sequence(const UseDepSpec &,
- DependencySpecTree::ConstSequenceIterator cur,
- DependencySpecTree::ConstSequenceIterator end)
- {
- s << "USE(";
- std::for_each(cur, end, accept_visitor(*this));
- s << ")";
- }
- };
-}
-
namespace test_cases
{
struct CRANDepParserTest : TestCase
@@ -89,22 +40,23 @@ namespace test_cases
void run()
{
- Stringifier d1, d2, d3;
+ StringifyFormatter ff;
+ cranrepository::DepSpecPrettyPrinter d1(0, ff, 0, false), d2(0, ff, 0, false), d3(0, ff, 0, false);
// test R dependency
std::string dep1("R (>= 2.0.0)");
cranrepository::parse_depends(dep1)->accept(d1);
- TEST_CHECK_EQUAL(d1.s.str(), "ALL(>=dev-lang/R-2.0.0 )");
+ TEST_CHECK_EQUAL(stringify(d1), ">=dev-lang/R-2.0.0");
// test varying whitespaces
std::string dep2("testpackage1 \t(<1.9)");
cranrepository::parse_depends(dep2)->accept(d2);
- TEST_CHECK_EQUAL(d2.s.str(), "ALL(<cran/testpackage1-1.9 )");
+ TEST_CHECK_EQUAL(stringify(d2), "<cran/testpackage1-1.9");
// test for package-name and version normalisation
std::string dep3("R.matlab (>= 2.3-1)");
cranrepository::parse_depends(dep3)->accept(d3);
- TEST_CHECK_EQUAL(d3.s.str(), "ALL(>=cran/R-matlab-2.3.1 )");
+ TEST_CHECK_EQUAL(stringify(d3), ">=cran/R-matlab-2.3.1");
}
} test_cran_dep_parser;
}
diff --git a/paludis/repositories/cran/cran_package_id.cc b/paludis/repositories/cran/cran_package_id.cc
index e6ad4a4..911ac42 100644
--- a/paludis/repositories/cran/cran_package_id.cc
+++ b/paludis/repositories/cran/cran_package_id.cc
@@ -54,6 +54,8 @@ namespace paludis
template <>
struct Implementation<CRANPackageID>
{
+ const Environment * const env;
+
const tr1::shared_ptr<const Repository> repository;
const tr1::shared_ptr<const CRANRepository> cran_repository;
const tr1::shared_ptr<const CRANInstalledRepository> cran_installed_repository;
@@ -70,7 +72,9 @@ namespace paludis
tr1::shared_ptr<DepKey> depends_key;
tr1::shared_ptr<DepKey> suggests_key;
- Implementation(const tr1::shared_ptr<const CRANRepository> & r, const FSEntry & f) :
+ Implementation(const Environment * const e,
+ const tr1::shared_ptr<const CRANRepository> & r, const FSEntry & f) :
+ env(e),
repository(r),
cran_repository(r),
name("cran/" + cran_name_to_internal(strip_trailing_string(f.basename(), ".DESCRIPTION"))),
@@ -78,7 +82,9 @@ namespace paludis
{
}
- Implementation(const tr1::shared_ptr<const CRANRepository> & c, const CRANPackageID * const r, const std::string & t) :
+ Implementation(const Environment * const e,
+ const tr1::shared_ptr<const CRANRepository> & c, const CRANPackageID * const r, const std::string & t) :
+ env(e),
repository(c),
cran_repository(c),
name("cran/" + cran_name_to_internal(t)),
@@ -89,8 +95,8 @@ namespace paludis
};
}
-CRANPackageID::CRANPackageID(const tr1::shared_ptr<const CRANRepository> & r, const FSEntry & f) :
- PrivateImplementationPattern<CRANPackageID>(new Implementation<CRANPackageID>(r, f)),
+CRANPackageID::CRANPackageID(const Environment * const env, const tr1::shared_ptr<const CRANRepository> & r, const FSEntry & f) :
+ PrivateImplementationPattern<CRANPackageID>(new Implementation<CRANPackageID>(env, r, f)),
_imp(PrivateImplementationPattern<CRANPackageID>::_imp.get())
{
Context context("When parsing file '" + stringify(f) + "' to create a CRAN Package ID:");
@@ -188,13 +194,13 @@ CRANPackageID::CRANPackageID(const tr1::shared_ptr<const CRANRepository> & r, co
Context local_context("When handling Contains: key:");
std::list<std::string> tokens;
WhitespaceTokeniser::get_instance()->tokenise(file.get("Contains"), std::back_inserter(tokens));
- _imp->contains_key.reset(new PackageIDSequenceKey("Contains", "Contains", mkt_normal));
+ _imp->contains_key.reset(new PackageIDSequenceKey(_imp->env, "Contains", "Contains", mkt_normal));
add_metadata_key(_imp->contains_key);
for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ;
t != t_end ; ++t)
{
if (*t != stringify(name().package))
- _imp->contains_key->push_back(make_shared_ptr(new CRANPackageID(_imp->cran_repository, this, *t)));
+ _imp->contains_key->push_back(make_shared_ptr(new CRANPackageID(_imp->env, _imp->cran_repository, this, *t)));
else
{
/* yay CRAN... */
@@ -207,17 +213,17 @@ CRANPackageID::CRANPackageID(const tr1::shared_ptr<const CRANRepository> & r, co
if (! file.get("Suggests").empty())
{
Context local_context("When handling Suggests: key:");
- _imp->suggests_key.reset(new DepKey("Suggests", "Suggests", file.get("Suggests"), mkt_dependencies));
+ _imp->suggests_key.reset(new DepKey(_imp->env, "Suggests", "Suggests", file.get("Suggests"), mkt_dependencies));
add_metadata_key(_imp->suggests_key);
}
if (! file.get("Depends").empty())
{
Context local_context("When handling Depends: key:");
- _imp->depends_key.reset(new DepKey("Depends", "Depends", file.get("Depends") + ", R", mkt_dependencies));
+ _imp->depends_key.reset(new DepKey(_imp->env, "Depends", "Depends", file.get("Depends") + ", R", mkt_dependencies));
}
else
- _imp->depends_key.reset(new DepKey("Depends", "Depends", "R", mkt_dependencies));
+ _imp->depends_key.reset(new DepKey(_imp->env, "Depends", "Depends", "R", mkt_dependencies));
add_metadata_key(_imp->depends_key);
}
catch (const Exception & e)
@@ -259,8 +265,9 @@ CRANPackageID::CRANPackageID(const tr1::shared_ptr<const CRANRepository> & r, co
#endif
}
-CRANPackageID::CRANPackageID(const tr1::shared_ptr<const CRANRepository> & c, const CRANPackageID * const r, const std::string & t) :
- PrivateImplementationPattern<CRANPackageID>(new Implementation<CRANPackageID>(c, r, t)),
+CRANPackageID::CRANPackageID(const Environment * const e,
+ const tr1::shared_ptr<const CRANRepository> & c, const CRANPackageID * const r, const std::string & t) :
+ PrivateImplementationPattern<CRANPackageID>(new Implementation<CRANPackageID>(e, c, r, t)),
_imp(PrivateImplementationPattern<CRANPackageID>::_imp.get())
{
Context context("When creating contained ID '" + stringify(t) + "' in " + stringify(*r) + "':");
diff --git a/paludis/repositories/cran/cran_package_id.hh b/paludis/repositories/cran/cran_package_id.hh
index e4cb9d3..7bb6658 100644
--- a/paludis/repositories/cran/cran_package_id.hh
+++ b/paludis/repositories/cran/cran_package_id.hh
@@ -44,8 +44,10 @@ namespace paludis
virtual void need_masks_added() const;
public:
- CRANPackageID(const tr1::shared_ptr<const CRANRepository> &, const FSEntry &);
- CRANPackageID(const tr1::shared_ptr<const CRANRepository> &, const CRANPackageID * const, const std::string &);
+ CRANPackageID(const Environment * const, const tr1::shared_ptr<const CRANRepository> &,
+ const FSEntry &);
+ CRANPackageID(const Environment * const, const tr1::shared_ptr<const CRANRepository> &,
+ const CRANPackageID * const, const std::string &);
~CRANPackageID();
virtual const std::string canonical_form(const PackageIDCanonicalForm) const;
diff --git a/paludis/repositories/cran/cran_repository.cc b/paludis/repositories/cran/cran_repository.cc
index 8a1339f..9735aea 100644
--- a/paludis/repositories/cran/cran_repository.cc
+++ b/paludis/repositories/cran/cran_repository.cc
@@ -219,7 +219,8 @@ CRANRepository::need_ids() const
for (DirIterator d(_imp->params.location), d_end ; d != d_end ; ++d)
if (is_file_with_extension(*d, ".DESCRIPTION", IsFileWithOptions()))
{
- tr1::shared_ptr<cranrepository::CRANPackageID> id(new cranrepository::CRANPackageID(shared_from_this(), *d));
+ tr1::shared_ptr<cranrepository::CRANPackageID> id(new cranrepository::CRANPackageID(_imp->params.environment,
+ shared_from_this(), *d));
if (! _imp->ids.insert(std::make_pair(id->name(), id)).second)
Log::get_instance()->message(ll_warning, lc_context) << "Couldn't insert package '" << *id << "' due to name collision";
diff --git a/paludis/repositories/cran/dep_spec_pretty_printer.cc b/paludis/repositories/cran/dep_spec_pretty_printer.cc
index ccbcfe4..3b27245 100644
--- a/paludis/repositories/cran/dep_spec_pretty_printer.cc
+++ b/paludis/repositories/cran/dep_spec_pretty_printer.cc
@@ -21,6 +21,9 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/environment.hh>
+#include <paludis/query.hh>
+#include <paludis/package_database.hh>
#include <ostream>
#include <sstream>
@@ -33,11 +36,19 @@ namespace paludis
struct Implementation<DepSpecPrettyPrinter>
{
std::stringstream s;
+ const Environment * const env;
+ GenericSpecTree::Formatter formatter;
const unsigned indent;
const bool multiline;
bool need_comma;
- Implementation(const unsigned u, const bool m) :
+ Implementation(
+ const Environment * const e,
+ const GenericSpecTree::Formatter & f,
+ const unsigned u,
+ const bool m) :
+ env(e),
+ formatter(f),
indent(u),
multiline(m),
need_comma(false)
@@ -46,8 +57,9 @@ namespace paludis
};
}
-DepSpecPrettyPrinter::DepSpecPrettyPrinter(const unsigned initial_indent, const bool multiline) :
- PrivateImplementationPattern<DepSpecPrettyPrinter>(new Implementation<DepSpecPrettyPrinter>(initial_indent, multiline))
+DepSpecPrettyPrinter::DepSpecPrettyPrinter(const Environment * const e,
+ const GenericSpecTree::Formatter & f, const unsigned initial_indent, const bool multiline) :
+ PrivateImplementationPattern<DepSpecPrettyPrinter>(new Implementation<DepSpecPrettyPrinter>(e, f, initial_indent, multiline))
{
}
@@ -59,16 +71,28 @@ void
DepSpecPrettyPrinter::visit_leaf(const PackageDepSpec & p)
{
if (_imp->multiline)
- _imp->s << std::string(_imp->indent, ' ');
+ _imp->s << _imp->formatter.indent(_imp->indent);
else if (_imp->need_comma)
_imp->s << ", ";
else
_imp->need_comma = true;
- _imp->s << stringify(p);
+ if (_imp->env)
+ {
+ if (! _imp->env->package_database()->query(query::Matches(p) &
+ query::InstalledAtRoot(_imp->env->root()), qo_whatever)->empty())
+ _imp->s << _imp->formatter.format(p, format::Installed());
+ else if (! _imp->env->package_database()->query(query::Matches(p) &
+ query::SupportsAction<InstallAction>() & query::NotMasked(), qo_whatever)->empty())
+ _imp->s << _imp->formatter.format(p, format::Installable());
+ else
+ _imp->s << _imp->formatter.format(p, format::Plain());
+ }
+ else
+ _imp->s << _imp->formatter.format(p, format::Plain());
if (_imp->multiline)
- _imp->s << std::endl;
+ _imp->s << _imp->formatter.newline();
}
void
diff --git a/paludis/repositories/cran/dep_spec_pretty_printer.hh b/paludis/repositories/cran/dep_spec_pretty_printer.hh
index cfa5b94..765210d 100644
--- a/paludis/repositories/cran/dep_spec_pretty_printer.hh
+++ b/paludis/repositories/cran/dep_spec_pretty_printer.hh
@@ -22,13 +22,20 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/formatter.hh>
+#include <paludis/environment-fwd.hh>
#include <iosfwd>
namespace paludis
{
namespace cranrepository
{
- class DepSpecPrettyPrinter :
+ /**
+ * Pretty printer for CRAN dep heirarchies.
+ *
+ * \ingroup grpcranrepository
+ */
+ class PALUDIS_VISIBLE DepSpecPrettyPrinter :
private PrivateImplementationPattern<DepSpecPrettyPrinter>,
public ConstVisitor<DependencySpecTree>,
public ConstVisitor<DependencySpecTree>::VisitConstSequence<DepSpecPrettyPrinter, AllDepSpec>,
@@ -38,9 +45,34 @@ namespace paludis
friend std::ostream & operator<< (std::ostream &, const DepSpecPrettyPrinter &);
public:
- DepSpecPrettyPrinter(const unsigned initial_indent, const bool multiline);
+ ///\name Basic operations
+ ///\{
+
+ /**
+ * Constructor.
+ *
+ * \param env An optional environment, to use for formatting PackageDepSpec items
+ * as format::Installed() etc. May be null, in which case format::Plain() is
+ * always used.
+ *
+ * \param formatter The formatter to use. If no fancy formatting is required, use
+ * StringifyFormatter.
+ *
+ * \param initial_indent Amount of indenting to use. Should probably be 0 if
+ * use_newlines is false.
+ *
+ * \param use_newlines Whether to format over multiple lines.
+ */
+ DepSpecPrettyPrinter(
+ const Environment * const env,
+ const GenericSpecTree::Formatter & formatter,
+ unsigned initial_indent,
+ bool use_newlines);
+
~DepSpecPrettyPrinter();
+ ///\}
+
void visit_leaf(const PackageDepSpec &);
void visit_leaf(const BlockDepSpec &);
@@ -48,7 +80,7 @@ namespace paludis
void visit_leaf(const DependencyLabelDepSpec &);
};
- std::ostream & operator<< (std::ostream & s, const DepSpecPrettyPrinter & p);
+ std::ostream & operator<< (std::ostream & s, const DepSpecPrettyPrinter & p) PALUDIS_VISIBLE;
}
}
diff --git a/paludis/repositories/cran/keys.cc b/paludis/repositories/cran/keys.cc
index 1272f82..35910ac 100644
--- a/paludis/repositories/cran/keys.cc
+++ b/paludis/repositories/cran/keys.cc
@@ -24,7 +24,13 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/iterator.hh>
+#include <paludis/util/tr1_functional.hh>
#include <paludis/dep_spec.hh>
+#include <paludis/stringify_formatter-impl.hh>
+#include <paludis/formatter.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
using namespace paludis;
using namespace paludis::cranrepository;
@@ -42,15 +48,15 @@ URIKey::value() const
}
std::string
-URIKey::pretty_print() const
+URIKey::pretty_print(const URISpecTree::Formatter & f) const
{
- return _v;
+ return f.format(_v, format::Plain());
}
std::string
-URIKey::pretty_print_flat() const
+URIKey::pretty_print_flat(const URISpecTree::Formatter & f) const
{
- return _v;
+ return f.format(_v, format::Plain());
}
StringKey::StringKey(const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
@@ -78,8 +84,10 @@ FSLocationKey::value() const
return _v;
}
-PackageIDSequenceKey::PackageIDSequenceKey(const std::string & r, const std::string & h, const MetadataKeyType t) :
+PackageIDSequenceKey::PackageIDSequenceKey(const Environment * const e,
+ const std::string & r, const std::string & h, const MetadataKeyType t) :
MetadataSetKey<PackageIDSequence>(r, h, t),
+ _env(e),
_v(new PackageIDSequence)
{
}
@@ -96,6 +104,17 @@ PackageIDSequenceKey::push_back(const tr1::shared_ptr<const PackageID> & i)
_v->push_back(i);
}
+std::string
+PackageIDSequenceKey::pretty_print_flat(const Formatter<tr1::shared_ptr<const PackageID> > & f) const
+{
+ using namespace tr1::placeholders;
+ return join(value()->begin(), value()->end(), " ", tr1::bind(
+ static_cast<std::string (Formatter<tr1::shared_ptr<const PackageID> >::*)(
+ const tr1::shared_ptr<const PackageID> &, const format::Plain &) const>(
+ &Formatter<tr1::shared_ptr<const PackageID> >::format),
+ tr1::cref(f), _1, format::Plain()));
+}
+
PackageIDKey::PackageIDKey(const std::string & r, const std::string & h,
const CRANPackageID * const v, const MetadataKeyType t) :
MetadataPackageIDKey(r, h, t),
@@ -109,9 +128,10 @@ PackageIDKey::value() const
return _v->shared_from_this();
}
-DepKey::DepKey(const std::string & r, const std::string & h, const std::string & v,
+DepKey::DepKey(const Environment * const e, const std::string & r, const std::string & h, const std::string & v,
const MetadataKeyType t) :
MetadataSpecTreeKey<DependencySpecTree>(r, h, t),
+ _env(e),
_v(v)
{
}
@@ -129,17 +149,19 @@ DepKey::value() const
}
std::string
-DepKey::pretty_print() const
+DepKey::pretty_print(const DependencySpecTree::Formatter & f) const
{
- DepSpecPrettyPrinter p(12, true);
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_env, ff, 12, true);
value()->accept(p);
return stringify(p);
}
std::string
-DepKey::pretty_print_flat() const
+DepKey::pretty_print_flat(const DependencySpecTree::Formatter & f) const
{
- DepSpecPrettyPrinter p(0, false);
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_env, ff, 0, false);
value()->accept(p);
return stringify(p);
}
diff --git a/paludis/repositories/cran/keys.hh b/paludis/repositories/cran/keys.hh
index 44efba6..0bfae08 100644
--- a/paludis/repositories/cran/keys.hh
+++ b/paludis/repositories/cran/keys.hh
@@ -23,6 +23,7 @@
#include <paludis/metadata_key.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/mutex.hh>
+#include <paludis/util/sequence.hh>
namespace paludis
{
@@ -42,10 +43,10 @@ namespace paludis
virtual const tr1::shared_ptr<const URISpecTree::ConstItem> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print() const
+ virtual std::string pretty_print(const URISpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print_flat() const
+ virtual std::string pretty_print_flat(const URISpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -79,15 +80,20 @@ namespace paludis
public MetadataSetKey<PackageIDSequence>
{
private:
+ const Environment * const _env;
const tr1::shared_ptr<PackageIDSequence> _v;
public:
- PackageIDSequenceKey(const std::string &, const std::string &, const MetadataKeyType);
+ PackageIDSequenceKey(const Environment * const,
+ const std::string &, const std::string &, const MetadataKeyType);
virtual const tr1::shared_ptr<const PackageIDSequence> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
void push_back(const tr1::shared_ptr<const PackageID> &);
+
+ virtual std::string pretty_print_flat(const Formatter<tr1::shared_ptr<const PackageID> > &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
class PackageIDKey :
@@ -107,20 +113,22 @@ namespace paludis
public MetadataSpecTreeKey<DependencySpecTree>
{
private:
+ const Environment * const _env;
mutable Mutex _m;
mutable tr1::shared_ptr<DependencySpecTree::ConstItem> _c;
const std::string _v;
public:
- DepKey(const std::string &, const std::string &, const std::string &, const MetadataKeyType);
+ DepKey(const Environment * const,
+ const std::string &, const std::string &, const std::string &, const MetadataKeyType);
virtual const tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print() const
+ virtual std::string pretty_print(const DependencySpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print_flat() const
+ virtual std::string pretty_print_flat(const DependencySpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
}
diff --git a/paludis/repositories/e/dep_parser_TEST.cc b/paludis/repositories/e/dep_parser_TEST.cc
index 89be483..e6baf2f 100644
--- a/paludis/repositories/e/dep_parser_TEST.cc
+++ b/paludis/repositories/e/dep_parser_TEST.cc
@@ -21,6 +21,7 @@
#include <paludis/repositories/e/dep_parser.hh>
#include <paludis/repositories/e/eapi.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/stringify_formatter.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <sstream>
#include <test/test_framework.hh>
@@ -47,7 +48,8 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, false);
+ StringifyFormatter ff;
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend("",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "");
@@ -64,7 +66,8 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, false);
+ StringifyFormatter ff;
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend(" \n \t",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "");
@@ -81,7 +84,8 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, false);
+ StringifyFormatter ff;
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend("app-editors/vim",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "app-editors/vim");
@@ -98,17 +102,19 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d1(0, false);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter d1(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend(">=app-editors/vim-6.4_alpha",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d1);
TEST_CHECK_EQUAL(stringify(d1), ">=app-editors/vim-6.4_alpha");
- DepSpecPrettyPrinter d2(0, false);
+ DepSpecPrettyPrinter d2(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend("=app-editors/vim-6.4_alpha-r1",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d2);
TEST_CHECK_EQUAL(stringify(d2), "=app-editors/vim-6.4_alpha-r1");
- DepSpecPrettyPrinter d3(0, false);
+ DepSpecPrettyPrinter d3(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend(">=app-editors/vim-6.4_alpha:one",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d3);
TEST_CHECK_EQUAL(stringify(d3), ">=app-editors/vim-6.4_alpha:one");
@@ -125,7 +131,9 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, false);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend("app-editors/vim app-misc/hilite \nsys-apps/findutils",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "app-editors/vim app-misc/hilite sys-apps/findutils");
@@ -138,7 +146,9 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, false);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend("|| ( one/one two/two )",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "|| ( one/one two/two )");
@@ -151,7 +161,9 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, false);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend("|| ( one/one foo? ( two/two ) )",
*EAPIData::get_instance()->eapi_from_string("0"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "|| ( one/one foo? ( two/two ) )");
@@ -159,7 +171,7 @@ namespace test_cases
TEST_CHECK_THROWS(parse_depend("|| ( one/one foo? ( two/two ) )",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
- DepSpecPrettyPrinter e(0, false);
+ DepSpecPrettyPrinter e(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend("|| ( one/one ( foo? ( two/two ) ) )",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(e);
TEST_CHECK_EQUAL(stringify(e), "|| ( one/one ( foo? ( two/two ) ) )");
@@ -176,7 +188,9 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, false);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend(" ( one/one two/two ) ",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "one/one two/two");
@@ -193,7 +207,9 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, false);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend("foo? ( one/one )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "foo? ( one/one )");
}
@@ -209,7 +225,9 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, false);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend("!foo? ( one/one )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "!foo? ( one/one )");
}
@@ -221,11 +239,13 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, true);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, true, 0);
parse_uri("a\n->\tb", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "a -> b\n");
- DepSpecPrettyPrinter e(0, true);
+ DepSpecPrettyPrinter e(0, tr1::shared_ptr<const PackageID>(), ff, 0, true, 0);
parse_uri("a-> b", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(e);
TEST_CHECK_EQUAL(stringify(e), "a->\nb\n");
@@ -244,7 +264,9 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, false);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
TEST_CHECK_THROWS(parse_depend("!foo? ( one/one",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_depend("!foo? ( one/one ) )",
@@ -268,7 +290,9 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, false);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
TEST_CHECK_THROWS(parse_depend("||",
*EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(d), DepStringError);
TEST_CHECK_THROWS(parse_depend("|| ",
@@ -314,7 +338,9 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter d(0, false);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter d(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
parse_depend("build: one/one",
*EAPIData::get_instance()->eapi_from_string("exheres-0"))->accept(d);
TEST_CHECK_EQUAL(stringify(d), "build: one/one");
@@ -323,3 +349,4 @@ namespace test_cases
}
} test_dep_spec_parser_labels;
}
+
diff --git a/paludis/repositories/e/dep_spec_pretty_printer.cc b/paludis/repositories/e/dep_spec_pretty_printer.cc
index 9c1287d..8fbf3c8 100644
--- a/paludis/repositories/e/dep_spec_pretty_printer.cc
+++ b/paludis/repositories/e/dep_spec_pretty_printer.cc
@@ -20,11 +20,16 @@
#include <algorithm>
#include <sstream>
#include <paludis/dep_spec.hh>
+#include <paludis/metadata_key.hh>
+#include <paludis/formatter.hh>
#include <paludis/repositories/e/dep_spec_pretty_printer.hh>
#include <paludis/util/save.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/environment.hh>
+#include <paludis/query.hh>
+#include <paludis/package_database.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
/** \file
@@ -42,16 +47,30 @@ namespace paludis
struct Implementation<DepSpecPrettyPrinter>
{
std::stringstream s;
+ const Environment * const env;
+ const tr1::shared_ptr<const PackageID> id;
+ GenericSpecTree::Formatter formatter;
unsigned indent;
bool extra_label_indent;
bool use_newlines;
+ bool plain_text_is_license;
bool outer_block;
bool need_space;
- Implementation(unsigned i, bool b) :
- indent(i),
+ Implementation(
+ const Environment * const e,
+ const tr1::shared_ptr<const PackageID> & i,
+ const GenericSpecTree::Formatter & f,
+ unsigned in,
+ bool b,
+ bool c) :
+ env(e),
+ id(i),
+ formatter(f),
+ indent(in),
extra_label_indent(false),
use_newlines(b),
+ plain_text_is_license(c),
outer_block(true),
need_space(false)
{
@@ -59,8 +78,14 @@ namespace paludis
};
}
-DepSpecPrettyPrinter::DepSpecPrettyPrinter(unsigned i, bool b) :
- PrivateImplementationPattern<DepSpecPrettyPrinter>(new Implementation<DepSpecPrettyPrinter>(i, b))
+DepSpecPrettyPrinter::DepSpecPrettyPrinter(
+ const Environment * const e,
+ const tr1::shared_ptr<const PackageID> & id,
+ const GenericSpecTree::Formatter & f,
+ unsigned i,
+ bool b,
+ bool c) :
+ PrivateImplementationPattern<DepSpecPrettyPrinter>(new Implementation<DepSpecPrettyPrinter>(e, id, f, i, b, c))
{
}
@@ -82,20 +107,34 @@ DepSpecPrettyPrinter::visit_sequence(const AllDepSpec &,
{
if (! _imp->outer_block)
{
- _imp->s << indent() << "(";
- _imp->s << newline();
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+ _imp->s << "(";
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
+ else
+ _imp->need_space = true;
}
{
- Save<unsigned> old_indent(&_imp->indent, _imp->outer_block ? _imp->indent : _imp->indent + 4);
+ Save<unsigned> old_indent(&_imp->indent, _imp->outer_block ? _imp->indent : _imp->indent + 1);
Save<bool> extra_label_indent(&_imp->extra_label_indent, _imp->outer_block ? _imp->extra_label_indent : false);
std::for_each(cur, end, accept_visitor(*this));
}
if (! _imp->outer_block)
{
- _imp->s << indent() << ")";
- _imp->s << newline();
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+ _imp->s << ")";
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
+ else
+ _imp->need_space = true;
}
}
@@ -106,15 +145,31 @@ DepSpecPrettyPrinter::visit_sequence(const AnyDepSpec &,
{
Save<bool> old_outer(&_imp->outer_block, false);
- _imp->s << indent() << "|| (";
- _imp->s << newline();
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+ _imp->s << "|| (";
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
+ else
+ _imp->need_space = true;
+
{
- Save<unsigned> old_indent(&_imp->indent, _imp->indent + 4);
+ Save<unsigned> old_indent(&_imp->indent, _imp->indent + 1);
Save<bool> extra_label_indent(&_imp->extra_label_indent, false);
std::for_each(cur, end, accept_visitor(*this));
}
- _imp->s << indent() << ")";
- _imp->s << newline();
+
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+ _imp->s << ")";
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
+ else
+ _imp->need_space = true;
}
void
@@ -124,48 +179,125 @@ DepSpecPrettyPrinter::visit_sequence(const UseDepSpec & a,
{
Save<bool> old_outer(&_imp->outer_block, false);
- _imp->s << indent() << (a.inverse() ? "!" : "") << a.flag() << "? (";
- _imp->s << newline();
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+
+ if (_imp->env && _imp->id)
+ {
+ if (_imp->env->query_use(a.flag(), *_imp->id))
+ _imp->s << _imp->formatter.format(a, format::Enabled()) << " (";
+ else
+ _imp->s << _imp->formatter.format(a, format::Disabled()) << " (";
+ }
+ else
+ _imp->s << _imp->formatter.format(a, format::Plain()) << " (";
+
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
+ else
+ _imp->need_space = true;
+
{
- Save<unsigned> old_indent(&_imp->indent, _imp->indent + 4);
+ Save<unsigned> old_indent(&_imp->indent, _imp->indent + 1);
Save<bool> extra_label_indent(&_imp->extra_label_indent, false);
std::for_each(cur, end, accept_visitor(*this));
}
- _imp->s << indent() << ")";
- _imp->s << newline();
+
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+ _imp->s << ")";
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
+ else
+ _imp->need_space = true;
}
void
DepSpecPrettyPrinter::visit_leaf(const PackageDepSpec & p)
{
- _imp->s << indent() << p;
- _imp->s << newline();
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+
+ if (_imp->env)
+ {
+ if (! _imp->env->package_database()->query(query::Matches(p) &
+ query::InstalledAtRoot(_imp->env->root()), qo_whatever)->empty())
+ _imp->s << _imp->formatter.format(p, format::Installed());
+ else if (! _imp->env->package_database()->query(query::Matches(p) &
+ query::SupportsAction<InstallAction>() & query::NotMasked(), qo_whatever)->empty())
+ _imp->s << _imp->formatter.format(p, format::Installable());
+ else
+ _imp->s << _imp->formatter.format(p, format::Plain());
+ }
+ else
+ _imp->s << _imp->formatter.format(p, format::Plain());
+
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
+ else
+ _imp->need_space = true;
}
void
DepSpecPrettyPrinter::visit_leaf(const PlainTextDepSpec & p)
{
- _imp->s << indent() << p.text();
- _imp->s << newline();
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+
+ if (_imp->env && _imp->id && _imp->plain_text_is_license)
+ {
+ if (_imp->env->accept_license(p.text(), *_imp->id))
+ _imp->s << _imp->formatter.format(p, format::Accepted());
+ else
+ _imp->s << _imp->formatter.format(p, format::Unaccepted());
+ }
+ else
+ _imp->s << _imp->formatter.format(p, format::Plain());
+
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
+ else
+ _imp->need_space = true;
}
void
DepSpecPrettyPrinter::visit_leaf(const URIDepSpec & p)
{
- if (! p.renamed_url_suffix().empty())
- {
- _imp->s << indent() << p.original_url() << " -> " << p.renamed_url_suffix();
- }
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+
+ _imp->s << _imp->formatter.format(p, format::Plain());
+
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
else
- _imp->s << indent() << p.original_url();
- _imp->s << newline();
+ _imp->need_space = true;
}
void
DepSpecPrettyPrinter::visit_leaf(const BlockDepSpec & b)
{
- _imp->s << indent() << "!" << *b.blocked_spec();
- _imp->s << newline();
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+
+ _imp->s << _imp->formatter.format(b, format::Plain());
+
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
+ else
+ _imp->need_space = true;
}
void
@@ -174,16 +306,25 @@ DepSpecPrettyPrinter::visit_leaf(const LabelsDepSpec<URILabelVisitorTypes> & l)
if (_imp->extra_label_indent)
{
_imp->extra_label_indent = false;
- _imp->indent -= 4;
+ _imp->indent -= 1;
}
- _imp->s << indent() << stringify(l);
- _imp->s << newline();
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
+
+ _imp->s << _imp->formatter.format(l, format::Plain());
+
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.newline();
+ else
+ _imp->need_space = true;
if (! _imp->extra_label_indent)
{
_imp->extra_label_indent = true;
- _imp->indent += 4;
+ _imp->indent += 1;
}
}
@@ -193,42 +334,25 @@ DepSpecPrettyPrinter::visit_leaf(const DependencyLabelDepSpec & l)
if (_imp->extra_label_indent)
{
_imp->extra_label_indent = false;
- _imp->indent -= 4;
+ _imp->indent -= 1;
}
- _imp->s << indent() << stringify(l);
- _imp->s << newline();
+ if (_imp->use_newlines)
+ _imp->s << _imp->formatter.indent(_imp->indent);
+ else if (_imp->need_space)
+ _imp->s << " ";
- if (!_imp->extra_label_indent)
- {
- _imp->extra_label_indent = true;
- _imp->indent += 4;
- }
-}
+ _imp->s << _imp->formatter.format(l, format::Plain());
-std::string
-DepSpecPrettyPrinter::newline()
-{
if (_imp->use_newlines)
- return "\n";
+ _imp->s << _imp->formatter.newline();
else
- {
_imp->need_space = true;
- return "";
- }
-}
-std::string
-DepSpecPrettyPrinter::indent()
-{
- if (_imp->use_newlines)
- return std::string(_imp->indent, ' ');
- else if (_imp->need_space)
+ if (!_imp->extra_label_indent)
{
- _imp->need_space = false;
- return " ";
+ _imp->extra_label_indent = true;
+ _imp->indent += 1;
}
- else
- return "";
}
diff --git a/paludis/repositories/e/dep_spec_pretty_printer.hh b/paludis/repositories/e/dep_spec_pretty_printer.hh
index b997b05..9733646 100644
--- a/paludis/repositories/e/dep_spec_pretty_printer.hh
+++ b/paludis/repositories/e/dep_spec_pretty_printer.hh
@@ -22,11 +22,14 @@
#include <iosfwd>
#include <paludis/dep_spec.hh>
+#include <paludis/metadata_key-fwd.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/package_id-fwd.hh>
/** \file
- * Declarations for the DepSpecPrettyPrinter class.
+ * Declarations for the paludis::erepository::DepSpecPrettyPrinter class.
*
- * \ingroup grpdepspecprettyprinter
+ * \ingroup grperepository
*/
namespace paludis
@@ -36,7 +39,7 @@ namespace paludis
/**
* Pretty print dependency specs.
*
- * \ingroup grpdepspecprettyprinter
+ * \ingroup grperepository
*/
class PALUDIS_VISIBLE DepSpecPrettyPrinter :
public ConstVisitor<GenericSpecTree>,
@@ -44,15 +47,37 @@ namespace paludis
{
friend std::ostream & operator<< (std::ostream &, const DepSpecPrettyPrinter &);
- private:
- std::string newline();
- std::string indent();
-
public:
///\name Basic operations
///\{
- DepSpecPrettyPrinter(unsigned initial_indent, bool use_newlines = true);
+ /**
+ * Constructor.
+ *
+ * \param env An optional environment, to use for formatting PackageDepSpec items
+ * as format::Installed() etc. May be null, in which case format::Plain() is
+ * always used.
+ *
+ * \param id The ID to use for determining use flag formatting. May be null, in
+ * which case format::Plain() is used.
+ *
+ * \param formatter The formatter to use. If no fancy formatting is required, use
+ * StringifyFormatter.
+ *
+ * \param initial_indent Amount of indenting to use. Should probably be 0 if
+ * use_newlines is false.
+ *
+ * \param use_newlines Whether to format over multiple lines.
+ *
+ * \param plain_text_is_license Whether plain text is a license.
+ */
+ DepSpecPrettyPrinter(
+ const Environment * const env,
+ const tr1::shared_ptr<const PackageID> & id,
+ const GenericSpecTree::Formatter & formatter,
+ unsigned initial_indent,
+ bool use_newlines,
+ const bool plain_text_is_license);
~DepSpecPrettyPrinter();
@@ -91,7 +116,7 @@ namespace paludis
/**
* Output a DepSpecPrettyPrinter to an ostream.
*
- * \ingroup grpdepspecprettyprinter
+ * \ingroup grperepository
*/
std::ostream & operator<< (std::ostream & s, const DepSpecPrettyPrinter & p) PALUDIS_VISIBLE;
}
diff --git a/paludis/repositories/e/dep_spec_pretty_printer_TEST.cc b/paludis/repositories/e/dep_spec_pretty_printer_TEST.cc
index 0065593..ac8bdf9 100644
--- a/paludis/repositories/e/dep_spec_pretty_printer_TEST.cc
+++ b/paludis/repositories/e/dep_spec_pretty_printer_TEST.cc
@@ -20,6 +20,7 @@
#include "dep_spec_pretty_printer.hh"
#include <paludis/repositories/e/dep_parser.hh>
#include <paludis/repositories/e/eapi.hh>
+#include <paludis/stringify_formatter.hh>
#include <paludis/util/visitor-impl.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <test/test_runner.hh>
@@ -37,27 +38,29 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter p1(0, false);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter p1(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
parse_depend("foo/bar bar/baz", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p1);
TEST_CHECK_STRINGIFY_EQUAL(p1, "foo/bar bar/baz");
- DepSpecPrettyPrinter p2(0, false);
+ DepSpecPrettyPrinter p2(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
parse_depend("foo/bar moo? ( bar/baz )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p2);
TEST_CHECK_STRINGIFY_EQUAL(p2, "foo/bar moo? ( bar/baz )");
- DepSpecPrettyPrinter p3(0, false);
+ DepSpecPrettyPrinter p3(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
parse_depend("|| ( a/b ( c/d e/f ) )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p3);
TEST_CHECK_STRINGIFY_EQUAL(p3, "|| ( a/b ( c/d e/f ) )");
- DepSpecPrettyPrinter p4(0, false);
+ DepSpecPrettyPrinter p4(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
parse_license("( ( ( ) a ) b )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p4);
TEST_CHECK_STRINGIFY_EQUAL(p4, "a b");
- DepSpecPrettyPrinter p5(0, false);
+ DepSpecPrettyPrinter p5(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
parse_uri("( a -> b c x? ( d e ) )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p5);
TEST_CHECK_STRINGIFY_EQUAL(p5, "a -> b c x? ( d e )");
- DepSpecPrettyPrinter p6(0, false);
+ DepSpecPrettyPrinter p6(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
parse_uri("a manual: b x? ( c mirrors-first: d manual: e ) f",
*EAPIData::get_instance()->eapi_from_string("exheres-0"))->accept(p6);
TEST_CHECK_STRINGIFY_EQUAL(p6, "a manual: b x? ( c mirrors-first: d manual: e ) f");
@@ -70,24 +73,26 @@ namespace test_cases
void run()
{
- DepSpecPrettyPrinter p1(4);
+ StringifyFormatter ff;
+
+ DepSpecPrettyPrinter p1(0, tr1::shared_ptr<const PackageID>(), ff, 1, true, 0);
parse_depend("foo/bar bar/baz", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p1);
TEST_CHECK_STRINGIFY_EQUAL(p1, " foo/bar\n bar/baz\n");
- DepSpecPrettyPrinter p2(4);
+ DepSpecPrettyPrinter p2(0, tr1::shared_ptr<const PackageID>(), ff, 1, true, 0);
parse_depend("foo/bar moo? ( bar/baz )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p2);
TEST_CHECK_STRINGIFY_EQUAL(p2, " foo/bar\n moo? (\n bar/baz\n )\n");
- DepSpecPrettyPrinter p3(4);
+ DepSpecPrettyPrinter p3(0, tr1::shared_ptr<const PackageID>(), ff, 1, true, 0);
parse_depend("|| ( a/b ( c/d e/f ) )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p3);
TEST_CHECK_STRINGIFY_EQUAL(p3, " || (\n a/b\n (\n c/d\n"
" e/f\n )\n )\n");
- DepSpecPrettyPrinter p4(4);
+ DepSpecPrettyPrinter p4(0, tr1::shared_ptr<const PackageID>(), ff, 1, true, 0);
parse_license("( ( ( ) a ) b )", *EAPIData::get_instance()->eapi_from_string("paludis-1"))->accept(p4);
TEST_CHECK_STRINGIFY_EQUAL(p4, " a\n b\n");
- DepSpecPrettyPrinter p5(4);
+ DepSpecPrettyPrinter p5(0, tr1::shared_ptr<const PackageID>(), ff, 1, true, 0);
parse_uri("a manual: b x? ( c mirrors-first: d manual: e ) f",
*EAPIData::get_instance()->eapi_from_string("exheres-0"))->accept(p5);
TEST_CHECK_STRINGIFY_EQUAL(p5, " a\n manual:\n b\n x? (\n c\n"
diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc
index 2ad9abe..fac6c54 100644
--- a/paludis/repositories/e/e_key.cc
+++ b/paludis/repositories/e/e_key.cc
@@ -33,8 +33,13 @@
#include <paludis/util/set.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/idle_action_pool.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/visitor-impl.hh>
#include <paludis/contents.hh>
+#include <paludis/repository.hh>
+#include <paludis/environment.hh>
+#include <paludis/stringify_formatter-impl.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
@@ -42,6 +47,7 @@
#include <list>
#include <vector>
#include <fstream>
+#include <map>
using namespace paludis;
using namespace paludis::erepository;
@@ -91,13 +97,17 @@ namespace paludis
template <>
struct Implementation<EDependenciesKey>
{
+ const Environment * const env;
const tr1::shared_ptr<const ERepositoryID> id;
const std::string string_value;
mutable Mutex value_mutex;
mutable tr1::shared_ptr<const DependencySpecTree::ConstItem> value;
mutable tr1::function<void () throw ()> value_used;
- Implementation(const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ Implementation(
+ const Environment * const e,
+ const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ env(e),
id(i),
string_value(v)
{
@@ -105,10 +115,12 @@ namespace paludis
};
}
-EDependenciesKey::EDependenciesKey(const tr1::shared_ptr<const ERepositoryID> & id,
+EDependenciesKey::EDependenciesKey(
+ const Environment * const e,
+ const tr1::shared_ptr<const ERepositoryID> & id,
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSpecTreeKey<DependencySpecTree>(r, h, t),
- PrivateImplementationPattern<EDependenciesKey>(new Implementation<EDependenciesKey>(id, v)),
+ PrivateImplementationPattern<EDependenciesKey>(new Implementation<EDependenciesKey>(e, id, v)),
_imp(PrivateImplementationPattern<EDependenciesKey>::_imp.get())
{
}
@@ -139,17 +151,19 @@ EDependenciesKey::value() const
}
std::string
-EDependenciesKey::pretty_print() const
+EDependenciesKey::pretty_print(const DependencySpecTree::Formatter & f) const
{
- DepSpecPrettyPrinter p(12, true);
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 12, true, false);
value()->accept(p);
return stringify(p);
}
std::string
-EDependenciesKey::pretty_print_flat() const
+EDependenciesKey::pretty_print_flat(const DependencySpecTree::Formatter & f) const
{
- DepSpecPrettyPrinter p(0, false);
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, false);
value()->accept(p);
return stringify(p);
}
@@ -182,13 +196,16 @@ namespace paludis
template <>
struct Implementation<ELicenseKey>
{
+ const Environment * const env;
const tr1::shared_ptr<const ERepositoryID> id;
const std::string string_value;
mutable Mutex value_mutex;
mutable tr1::shared_ptr<const LicenseSpecTree::ConstItem> value;
mutable tr1::function<void () throw ()> value_used;
- Implementation(const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ Implementation(const Environment * const e,
+ const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ env(e),
id(i),
string_value(v)
{
@@ -196,10 +213,12 @@ namespace paludis
};
}
-ELicenseKey::ELicenseKey(const tr1::shared_ptr<const ERepositoryID> & id,
+ELicenseKey::ELicenseKey(
+ const Environment * const e,
+ const tr1::shared_ptr<const ERepositoryID> & id,
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSpecTreeKey<LicenseSpecTree>(r, h, t),
- PrivateImplementationPattern<ELicenseKey>(new Implementation<ELicenseKey>(id, v)),
+ PrivateImplementationPattern<ELicenseKey>(new Implementation<ELicenseKey>(e, id, v)),
_imp(PrivateImplementationPattern<ELicenseKey>::_imp.get())
{
}
@@ -230,17 +249,19 @@ ELicenseKey::value() const
}
std::string
-ELicenseKey::pretty_print() const
+ELicenseKey::pretty_print(const LicenseSpecTree::Formatter & f) const
{
- DepSpecPrettyPrinter p(12, true);
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 12, true, true);
value()->accept(p);
return stringify(p);
}
std::string
-ELicenseKey::pretty_print_flat() const
+ELicenseKey::pretty_print_flat(const LicenseSpecTree::Formatter & f) const
{
- DepSpecPrettyPrinter p(0, false);
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, true);
value()->accept(p);
return stringify(p);
}
@@ -273,12 +294,14 @@ namespace paludis
template <>
struct Implementation<EURIKey>
{
+ const Environment * const env;
const tr1::shared_ptr<const ERepositoryID> id;
const std::string string_value;
mutable Mutex value_mutex;
mutable tr1::shared_ptr<const URISpecTree::ConstItem> value;
- Implementation(const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ Implementation(const Environment * const e, const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ env(e),
id(i),
string_value(v)
{
@@ -286,10 +309,11 @@ namespace paludis
};
}
-EURIKey::EURIKey(const tr1::shared_ptr<const ERepositoryID> & id,
+EURIKey::EURIKey(const Environment * const e,
+ const tr1::shared_ptr<const ERepositoryID> & id,
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSpecTreeKey<URISpecTree>(r, h, t),
- PrivateImplementationPattern<EURIKey>(new Implementation<EURIKey>(id, v)),
+ PrivateImplementationPattern<EURIKey>(new Implementation<EURIKey>(e, id, v)),
_imp(PrivateImplementationPattern<EURIKey>::_imp.get())
{
}
@@ -312,17 +336,19 @@ EURIKey::value() const
}
std::string
-EURIKey::pretty_print() const
+EURIKey::pretty_print(const URISpecTree::Formatter & f) const
{
- DepSpecPrettyPrinter p(12, true);
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 12, true, false);
value()->accept(p);
return stringify(p);
}
std::string
-EURIKey::pretty_print_flat() const
+EURIKey::pretty_print_flat(const URISpecTree::Formatter & f) const
{
- DepSpecPrettyPrinter p(0, false);
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, false);
value()->accept(p);
return stringify(p);
}
@@ -332,12 +358,14 @@ namespace paludis
template <>
struct Implementation<ERestrictKey>
{
+ const Environment * const env;
const tr1::shared_ptr<const ERepositoryID> id;
const std::string string_value;
mutable Mutex value_mutex;
mutable tr1::shared_ptr<const RestrictSpecTree::ConstItem> value;
- Implementation(const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ Implementation(const Environment * const e, const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ env(e),
id(i),
string_value(v)
{
@@ -345,10 +373,11 @@ namespace paludis
};
}
-ERestrictKey::ERestrictKey(const tr1::shared_ptr<const ERepositoryID> & id,
+ERestrictKey::ERestrictKey(const Environment * const e,
+ const tr1::shared_ptr<const ERepositoryID> & id,
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSpecTreeKey<RestrictSpecTree>(r, h, t),
- PrivateImplementationPattern<ERestrictKey>(new Implementation<ERestrictKey>(id, v)),
+ PrivateImplementationPattern<ERestrictKey>(new Implementation<ERestrictKey>(e, id, v)),
_imp(PrivateImplementationPattern<ERestrictKey>::_imp.get())
{
}
@@ -371,17 +400,19 @@ ERestrictKey::value() const
}
std::string
-ERestrictKey::pretty_print() const
+ERestrictKey::pretty_print(const RestrictSpecTree::Formatter & f) const
{
- DepSpecPrettyPrinter p(12, true);
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 12, true, false);
value()->accept(p);
return stringify(p);
}
std::string
-ERestrictKey::pretty_print_flat() const
+ERestrictKey::pretty_print_flat(const RestrictSpecTree::Formatter & f) const
{
- DepSpecPrettyPrinter p(0, false);
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, false);
value()->accept(p);
return stringify(p);
}
@@ -391,12 +422,14 @@ namespace paludis
template <>
struct Implementation<EProvideKey>
{
+ const Environment * const env;
const tr1::shared_ptr<const ERepositoryID> id;
const std::string string_value;
mutable Mutex value_mutex;
mutable tr1::shared_ptr<const ProvideSpecTree::ConstItem> value;
- Implementation(const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ Implementation(const Environment * const e, const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ env(e),
id(i),
string_value(v)
{
@@ -404,10 +437,10 @@ namespace paludis
};
}
-EProvideKey::EProvideKey(const tr1::shared_ptr<const ERepositoryID> & id,
+EProvideKey::EProvideKey(const Environment * const e, const tr1::shared_ptr<const ERepositoryID> & id,
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSpecTreeKey<ProvideSpecTree>(r, h, t),
- PrivateImplementationPattern<EProvideKey>(new Implementation<EProvideKey>(id, v)),
+ PrivateImplementationPattern<EProvideKey>(new Implementation<EProvideKey>(e, id, v)),
_imp(PrivateImplementationPattern<EProvideKey>::_imp.get())
{
}
@@ -430,17 +463,19 @@ EProvideKey::value() const
}
std::string
-EProvideKey::pretty_print() const
+EProvideKey::pretty_print(const ProvideSpecTree::Formatter & f) const
{
- DepSpecPrettyPrinter p(12, true);
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 12, true, false);
value()->accept(p);
return stringify(p);
}
std::string
-EProvideKey::pretty_print_flat() const
+EProvideKey::pretty_print_flat(const ProvideSpecTree::Formatter & f) const
{
- DepSpecPrettyPrinter p(0, false);
+ StringifyFormatter ff(f);
+ DepSpecPrettyPrinter p(_imp->env, _imp->id, ff, 0, false, false);
value()->accept(p);
return stringify(p);
}
@@ -451,23 +486,27 @@ namespace paludis
struct Implementation<EIUseKey>
{
const tr1::shared_ptr<const ERepositoryID> id;
+ const Environment * const env;
const std::string string_value;
mutable Mutex value_mutex;
mutable tr1::shared_ptr<IUseFlagSet> value;
mutable tr1::function<void () throw ()> value_used;
- Implementation(const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ Implementation(const tr1::shared_ptr<const ERepositoryID> & i, const Environment * const e, const std::string & v) :
id(i),
+ env(e),
string_value(v)
{
}
};
}
-EIUseKey::EIUseKey(const tr1::shared_ptr<const ERepositoryID> & id,
+EIUseKey::EIUseKey(
+ const Environment * const e,
+ const tr1::shared_ptr<const ERepositoryID> & id,
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSetKey<IUseFlagSet>(r, h, t),
- PrivateImplementationPattern<EIUseKey>(new Implementation<EIUseKey>(id, v)),
+ PrivateImplementationPattern<EIUseKey>(new Implementation<EIUseKey>(id, e, v)),
_imp(PrivateImplementationPattern<EIUseKey>::_imp.get())
{
}
@@ -496,9 +535,23 @@ EIUseKey::value() const
_imp->value.reset(new IUseFlagSet);
std::list<std::string> tokens;
WhitespaceTokeniser::get_instance()->tokenise(_imp->string_value, std::back_inserter(tokens));
+
+ tr1::shared_ptr<const UseFlagNameSet> prefixes;
+ if (_imp->id->repository()->use_interface)
+ prefixes = _imp->id->repository()->use_interface->use_expand_prefixes();
+ else
+ prefixes.reset(new UseFlagNameSet);
+
for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ;
t != t_end ; ++t)
- _imp->value->insert(IUseFlag(*t, _imp->id->eapi()->supported->iuse_flag_parse_mode));
+ {
+ IUseFlag f(*t, _imp->id->eapi()->supported->iuse_flag_parse_mode, std::string::npos);
+ for (UseFlagNameSet::Iterator p(prefixes->begin()), p_end(prefixes->end()) ;
+ p != p_end ; ++p)
+ if (0 == stringify(f.flag).compare(0, stringify(*p).length(), stringify(*p), 0, stringify(*p).length()))
+ f.prefix_delim_pos = stringify(*p).length();
+ _imp->value->insert(f);
+ }
return _imp->value;
}
@@ -511,13 +564,7 @@ EIUseKey::idle_load() const
{
try
{
- _imp->value.reset(new IUseFlagSet);
- std::list<std::string> tokens;
- WhitespaceTokeniser::get_instance()->tokenise(_imp->string_value, std::back_inserter(tokens));
- for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ;
- t != t_end ; ++t)
- _imp->value->insert(IUseFlag(*t, _imp->id->eapi()->supported->iuse_flag_parse_mode));
- _imp->value_used = tr1::bind(tr1::mem_fn(&IdleActionPool::increase_used_stat), IdleActionPool::get_instance());
+ tr1::shared_ptr<const IUseFlagSet> PALUDIS_ATTRIBUTE((unused)) a(value());
}
catch (...)
{
@@ -532,29 +579,188 @@ EIUseKey::idle_load() const
return iar_already_completed;
}
+std::string
+EIUseKey::pretty_print_flat(const Formatter<IUseFlag> & f) const
+{
+ std::string result;
+ std::multimap<std::string, IUseFlag> prefixes;
+ for (IUseFlagSet::Iterator i(value()->begin()), i_end(value()->end()) ;
+ i != i_end ; ++i)
+ {
+ if (std::string::npos != i->prefix_delim_pos)
+ {
+ prefixes.insert(std::make_pair(stringify(i->flag).substr(0, i->prefix_delim_pos), *i));
+ continue;
+ }
+
+ if (! result.empty())
+ result.append(" ");
+
+ if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_mask(i->flag, *_imp->id))
+ result.append(f.format(*i, format::Masked()));
+ else if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_force(i->flag, *_imp->id))
+ result.append(f.format(*i, format::Forced()));
+ else if (_imp->env->query_use(i->flag, *_imp->id))
+ result.append(f.format(*i, format::Enabled()));
+ else
+ result.append(f.format(*i, format::Disabled()));
+ }
+
+ for (std::multimap<std::string, IUseFlag>::const_iterator j(prefixes.begin()), j_end(prefixes.end()) ;
+ j != j_end ; ++j)
+ {
+ if (! result.empty())
+ result.append(" ");
+
+ if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_mask(j->second.flag, *_imp->id))
+ result.append(f.format(j->second, format::Masked()));
+ else if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_force(j->second.flag, *_imp->id))
+ result.append(f.format(j->second, format::Forced()));
+ else if (_imp->env->query_use(j->second.flag, *_imp->id))
+ result.append(f.format(j->second, format::Enabled()));
+ else
+ result.append(f.format(j->second, format::Disabled()));
+ }
+
+ return result;
+}
+
+std::string
+EIUseKey::pretty_print_flat_with_comparison(
+ const Environment * const env,
+ const tr1::shared_ptr<const PackageID> & id,
+ const Formatter<IUseFlag> & f) const
+{
+ std::string result;
+ std::multimap<std::string, IUseFlag> prefixes;
+ for (IUseFlagSet::Iterator i(value()->begin()), i_end(value()->end()) ;
+ i != i_end ; ++i)
+ {
+ if (std::string::npos != i->prefix_delim_pos)
+ {
+ prefixes.insert(std::make_pair(stringify(i->flag).substr(0, i->prefix_delim_pos), *i));
+ continue;
+ }
+
+ if (! result.empty())
+ result.append(" ");
+
+ std::string l;
+ bool n;
+
+ if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_mask(i->flag, *_imp->id))
+ {
+ l = f.format(*i, format::Masked());
+ n = false;
+ }
+ else if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_force(i->flag, *_imp->id))
+ {
+ l = f.format(*i, format::Forced());
+ n = true;
+ }
+ else if (_imp->env->query_use(i->flag, *_imp->id))
+ {
+ l = f.format(*i, format::Enabled());
+ n = true;
+ }
+ else
+ {
+ l = f.format(*i, format::Disabled());
+ n = false;
+ }
+
+ if (! id->iuse_key())
+ l = f.decorate(*i, l, format::Added());
+ else
+ {
+ using namespace tr1::placeholders;
+ IUseFlagSet::Iterator p(std::find_if(id->iuse_key()->value()->begin(), id->iuse_key()->value()->end(),
+ tr1::bind(std::equal_to<UseFlagName>(), i->flag, tr1::bind<const UseFlagName>(&IUseFlag::flag, _1))));
+
+ if (p == id->iuse_key()->value()->end())
+ l = f.decorate(*i, l, format::Added());
+ else if (n != env->query_use(i->flag, *id))
+ l = f.decorate(*i, l, format::Changed());
+ }
+
+ result.append(l);
+ }
+
+ for (std::multimap<std::string, IUseFlag>::const_iterator j(prefixes.begin()), j_end(prefixes.end()) ;
+ j != j_end ; ++j)
+ {
+ if (! result.empty())
+ result.append(" ");
+
+ std::string l;
+ bool n;
+
+ if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_mask(j->second.flag, *_imp->id))
+ {
+ l = f.format(j->second, format::Masked());
+ n = false;
+ }
+ else if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_force(j->second.flag, *_imp->id))
+ {
+ l = f.format(j->second, format::Forced());
+ n = true;
+ }
+ else if (_imp->env->query_use(j->second.flag, *_imp->id))
+ {
+ l = f.format(j->second, format::Enabled());
+ n = true;
+ }
+ else
+ {
+ l = f.format(j->second, format::Disabled());
+ n = false;
+ }
+
+ if (! id->iuse_key())
+ l = f.decorate(j->second, l, format::Added());
+ else
+ {
+ using namespace tr1::placeholders;
+ IUseFlagSet::Iterator p(std::find_if(id->iuse_key()->value()->begin(), id->iuse_key()->value()->end(),
+ tr1::bind(std::equal_to<UseFlagName>(), j->second.flag, tr1::bind<const UseFlagName>(&IUseFlag::flag, _1))));
+
+ if (p == id->iuse_key()->value()->end())
+ l = f.decorate(j->second, l, format::Added());
+ else if (n != env->query_use(j->second.flag, *id))
+ l = f.decorate(j->second, l, format::Changed());
+ }
+
+ result.append(l);
+ }
+
+ return result;
+}
+
namespace paludis
{
template <>
struct Implementation<EKeywordsKey>
{
const tr1::shared_ptr<const ERepositoryID> id;
+ const Environment * const env;
const std::string string_value;
mutable Mutex value_mutex;
mutable tr1::shared_ptr<KeywordNameSet> value;
mutable tr1::function<void () throw ()> value_used;
- Implementation(const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ Implementation(const tr1::shared_ptr<const ERepositoryID> & i, const Environment * const e, const std::string & v) :
id(i),
+ env(e),
string_value(v)
{
}
};
}
-EKeywordsKey::EKeywordsKey(const tr1::shared_ptr<const ERepositoryID> & id,
+EKeywordsKey::EKeywordsKey(const Environment * const e, const tr1::shared_ptr<const ERepositoryID> & id,
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSetKey<KeywordNameSet>(r, h, t),
- PrivateImplementationPattern<EKeywordsKey>(new Implementation<EKeywordsKey>(id, v)),
+ PrivateImplementationPattern<EKeywordsKey>(new Implementation<EKeywordsKey>(id, e, v)),
_imp(PrivateImplementationPattern<EKeywordsKey>::_imp.get())
{
}
@@ -610,28 +816,51 @@ EKeywordsKey::idle_load() const
return iar_already_completed;
}
+std::string
+EKeywordsKey::pretty_print_flat(const Formatter<KeywordName> & f) const
+{
+ std::string result;
+ for (KeywordNameSet::Iterator i(value()->begin()), i_end(value()->end()) ;
+ i != i_end ; ++i)
+ {
+ if (! result.empty())
+ result.append(" ");
+
+ tr1::shared_ptr<KeywordNameSet> k(new KeywordNameSet);
+ k->insert(*i);
+ if (_imp->env->accept_keywords(k, *_imp->id))
+ result.append(f.format(*i, format::Accepted()));
+ else
+ result.append(f.format(*i, format::Unaccepted()));
+ }
+
+ return result;
+}
+
namespace paludis
{
template <>
struct Implementation<EUseKey>
{
const tr1::shared_ptr<const ERepositoryID> id;
+ const Environment * const env;
const std::string string_value;
mutable Mutex value_mutex;
mutable tr1::shared_ptr<UseFlagNameSet> value;
- Implementation(const tr1::shared_ptr<const ERepositoryID> & i, const std::string & v) :
+ Implementation(const tr1::shared_ptr<const ERepositoryID> & i, const Environment * const e, const std::string & v) :
id(i),
+ env(e),
string_value(v)
{
}
};
}
-EUseKey::EUseKey(const tr1::shared_ptr<const ERepositoryID> & id,
+EUseKey::EUseKey(const Environment * const e, const tr1::shared_ptr<const ERepositoryID> & id,
const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t) :
MetadataSetKey<UseFlagNameSet>(r, h, t),
- PrivateImplementationPattern<EUseKey>(new Implementation<EUseKey>(id, v)),
+ PrivateImplementationPattern<EUseKey>(new Implementation<EUseKey>(id, e, v)),
_imp(PrivateImplementationPattern<EUseKey>::_imp.get())
{
}
@@ -659,6 +888,29 @@ EUseKey::value() const
return _imp->value;
}
+std::string
+EUseKey::pretty_print_flat(const Formatter<UseFlagName> & f) const
+{
+ std::string result;
+ for (UseFlagNameSet::Iterator i(value()->begin()), i_end(value()->end()) ;
+ i != i_end ; ++i)
+ {
+ if (! result.empty())
+ result.append(" ");
+
+ if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_mask(*i, *_imp->id))
+ result.append(f.format(*i, format::Masked()));
+ else if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_force(*i, *_imp->id))
+ result.append(f.format(*i, format::Forced()));
+ else if (_imp->env->query_use(*i, *_imp->id))
+ result.append(f.format(*i, format::Enabled()));
+ else
+ result.append(f.format(*i, format::Disabled()));
+ }
+
+ return result;
+}
+
namespace paludis
{
template <>
@@ -703,6 +955,12 @@ EInheritedKey::value() const
return _imp->value;
}
+std::string
+EInheritedKey::pretty_print_flat(const Formatter<std::string> &) const
+{
+ return join(value()->begin(), value()->end(), " ");
+}
+
namespace paludis
{
template <>
diff --git a/paludis/repositories/e/e_key.hh b/paludis/repositories/e/e_key.hh
index 22c6712..86fb782 100644
--- a/paludis/repositories/e/e_key.hh
+++ b/paludis/repositories/e/e_key.hh
@@ -23,6 +23,7 @@
#include <paludis/metadata_key.hh>
#include <paludis/util/idle_action_pool-fwd.hh>
#include <paludis/util/fs_entry.hh>
+#include <paludis/util/set.hh>
namespace paludis
{
@@ -70,17 +71,19 @@ namespace paludis
Implementation<EDependenciesKey> * const _imp;
public:
- EDependenciesKey(const tr1::shared_ptr<const ERepositoryID> &,
+ EDependenciesKey(
+ const Environment * const,
+ const tr1::shared_ptr<const ERepositoryID> &,
const std::string &, const std::string &, const std::string &, const MetadataKeyType);
~EDependenciesKey();
virtual const tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print() const
+ virtual std::string pretty_print(const DependencySpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print_flat() const
+ virtual std::string pretty_print_flat(const DependencySpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
IdleActionResult idle_load() const;
@@ -94,17 +97,18 @@ namespace paludis
Implementation<EURIKey> * const _imp;
public:
- EURIKey(const tr1::shared_ptr<const ERepositoryID> &,
+ EURIKey(const Environment * const,
+ const tr1::shared_ptr<const ERepositoryID> &,
const std::string &, const std::string &, const std::string &, const MetadataKeyType);
~EURIKey();
virtual const tr1::shared_ptr<const URISpecTree::ConstItem> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print() const
+ virtual std::string pretty_print(const URISpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print_flat() const
+ virtual std::string pretty_print_flat(const URISpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -116,17 +120,18 @@ namespace paludis
Implementation<ERestrictKey> * const _imp;
public:
- ERestrictKey(const tr1::shared_ptr<const ERepositoryID> &,
+ ERestrictKey(const Environment * const,
+ const tr1::shared_ptr<const ERepositoryID> &,
const std::string &, const std::string &, const std::string &, const MetadataKeyType);
~ERestrictKey();
virtual const tr1::shared_ptr<const RestrictSpecTree::ConstItem> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print() const
+ virtual std::string pretty_print(const RestrictSpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print_flat() const
+ virtual std::string pretty_print_flat(const RestrictSpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -138,17 +143,18 @@ namespace paludis
Implementation<EProvideKey> * const _imp;
public:
- EProvideKey(const tr1::shared_ptr<const ERepositoryID> &,
+ EProvideKey(const Environment * const,
+ const tr1::shared_ptr<const ERepositoryID> &,
const std::string &, const std::string &, const std::string &, const MetadataKeyType);
~EProvideKey();
virtual const tr1::shared_ptr<const ProvideSpecTree::ConstItem> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print() const
+ virtual std::string pretty_print(const ProvideSpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print_flat() const
+ virtual std::string pretty_print_flat(const ProvideSpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -160,7 +166,9 @@ namespace paludis
Implementation<ELicenseKey> * const _imp;
public:
- ELicenseKey(const tr1::shared_ptr<const ERepositoryID> &,
+ ELicenseKey(
+ const Environment * const,
+ const tr1::shared_ptr<const ERepositoryID> &,
const std::string &, const std::string &, const std::string &, const MetadataKeyType);
~ELicenseKey();
@@ -169,10 +177,10 @@ namespace paludis
IdleActionResult idle_load() const;
- virtual std::string pretty_print() const
+ virtual std::string pretty_print(const LicenseSpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print_flat() const
+ virtual std::string pretty_print_flat(const LicenseSpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -184,7 +192,9 @@ namespace paludis
Implementation<EIUseKey> * const _imp;
public:
- EIUseKey(const tr1::shared_ptr<const ERepositoryID> &,
+ EIUseKey(
+ const Environment * const,
+ const tr1::shared_ptr<const ERepositoryID> &,
const std::string &, const std::string &, const std::string &, const MetadataKeyType);
~EIUseKey();
@@ -192,6 +202,16 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
IdleActionResult idle_load() const;
+
+ virtual std::string pretty_print_flat(const Formatter<IUseFlag> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string pretty_print_flat_with_comparison(
+ const Environment * const,
+ const tr1::shared_ptr<const PackageID> &,
+ const Formatter<IUseFlag> &
+ ) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
class EKeywordsKey :
@@ -202,7 +222,9 @@ namespace paludis
Implementation<EKeywordsKey> * const _imp;
public:
- EKeywordsKey(const tr1::shared_ptr<const ERepositoryID> &,
+ EKeywordsKey(
+ const Environment * const,
+ const tr1::shared_ptr<const ERepositoryID> &,
const std::string &, const std::string &, const std::string &, const MetadataKeyType);
~EKeywordsKey();
@@ -210,6 +232,9 @@ namespace paludis
PALUDIS_ATTRIBUTE((warn_unused_result));
IdleActionResult idle_load() const;
+
+ virtual std::string pretty_print_flat(const Formatter<KeywordName> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
class EUseKey :
@@ -220,12 +245,17 @@ namespace paludis
Implementation<EUseKey> * const _imp;
public:
- EUseKey(const tr1::shared_ptr<const ERepositoryID> &,
+ EUseKey(
+ const Environment * const,
+ const tr1::shared_ptr<const ERepositoryID> &,
const std::string &, const std::string &, const std::string &, const MetadataKeyType);
~EUseKey();
const tr1::shared_ptr<const UseFlagNameSet> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string pretty_print_flat(const Formatter<UseFlagName> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
class EInheritedKey :
@@ -242,6 +272,9 @@ namespace paludis
const tr1::shared_ptr<const Set<std::string> > value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string pretty_print_flat(const Formatter<std::string> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
class EContentsKey :
@@ -252,7 +285,8 @@ namespace paludis
Implementation<EContentsKey> * const _imp;
public:
- EContentsKey(const tr1::shared_ptr<const ERepositoryID> &,
+ EContentsKey(
+ const tr1::shared_ptr<const ERepositoryID> &,
const std::string &, const std::string &, const FSEntry &, const MetadataKeyType);
~EContentsKey();
diff --git a/paludis/repositories/e/e_repository_TEST.cc b/paludis/repositories/e/e_repository_TEST.cc
index 1cb318c..886542d 100644
--- a/paludis/repositories/e/e_repository_TEST.cc
+++ b/paludis/repositories/e/e_repository_TEST.cc
@@ -33,6 +33,7 @@
#include <paludis/metadata_key.hh>
#include <paludis/query.hh>
#include <paludis/action.hh>
+#include <paludis/stringify_formatter.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <test/test_framework.hh>
@@ -522,11 +523,12 @@ namespace test_cases
TEST_CHECK(id1->end_metadata() != id1->find_metadata("EAPI"));
TEST_CHECK(id1->short_description_key());
TEST_CHECK_EQUAL(id1->short_description_key()->value(), "The Description");
- erepository::DepSpecPrettyPrinter pd(0, false);
+ StringifyFormatter ff;
+ erepository::DepSpecPrettyPrinter pd(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
TEST_CHECK(id1->build_dependencies_key());
id1->build_dependencies_key()->value()->accept(pd);
TEST_CHECK_STRINGIFY_EQUAL(pd, "foo/bar");
- erepository::DepSpecPrettyPrinter pr(0, false);
+ erepository::DepSpecPrettyPrinter pr(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
TEST_CHECK(id1->run_dependencies_key());
id1->run_dependencies_key()->value()->accept(pr);
TEST_CHECK_STRINGIFY_EQUAL(pr, "foo/bar");
@@ -537,11 +539,11 @@ namespace test_cases
TEST_CHECK(id2->end_metadata() != id2->find_metadata("EAPI"));
TEST_CHECK(id2->short_description_key());
TEST_CHECK_EQUAL(id2->short_description_key()->value(), "dquote \" squote ' backslash \\ dollar $");
- erepository::DepSpecPrettyPrinter pd2(0, false);
+ erepository::DepSpecPrettyPrinter pd2(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
TEST_CHECK(id2->build_dependencies_key());
id2->build_dependencies_key()->value()->accept(pd2);
TEST_CHECK_STRINGIFY_EQUAL(pd2, "foo/bar bar/baz");
- erepository::DepSpecPrettyPrinter pr2(0, false);
+ erepository::DepSpecPrettyPrinter pr2(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
TEST_CHECK(id2->run_dependencies_key());
id2->run_dependencies_key()->value()->accept(pr2);
TEST_CHECK_STRINGIFY_EQUAL(pr2, "foo/bar");
diff --git a/paludis/repositories/e/e_repository_profile.cc b/paludis/repositories/e/e_repository_profile.cc
index 96ce7ab..a643012 100644
--- a/paludis/repositories/e/e_repository_profile.cc
+++ b/paludis/repositories/e/e_repository_profile.cc
@@ -719,7 +719,7 @@ ERepositoryProfile::use_state_ignoring_masks(const UseFlagName & u,
{
if (e.iuse_key())
{
- IUseFlagSet::Iterator i(e.iuse_key()->value()->find(IUseFlag(u, use_unspecified)));
+ IUseFlagSet::Iterator i(e.iuse_key()->value()->find(IUseFlag(u, use_unspecified, std::string::npos)));
if (i != e.iuse_key()->value()->end())
result = i->state;
}
diff --git a/paludis/repositories/e/e_repository_sets_TEST.cc b/paludis/repositories/e/e_repository_sets_TEST.cc
index a19fdc8..66b36b4 100644
--- a/paludis/repositories/e/e_repository_sets_TEST.cc
+++ b/paludis/repositories/e/e_repository_sets_TEST.cc
@@ -26,6 +26,7 @@
#include <paludis/util/system.hh>
#include <paludis/util/map.hh>
#include <paludis/util/set.hh>
+#include <paludis/stringify_formatter.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -96,7 +97,8 @@ namespace test_cases
env.package_database()->add_repository(0, installed);
tr1::shared_ptr<SetSpecTree::ConstItem> set1(repo->sets_interface->package_set(SetName("set1")));
- erepository::DepSpecPrettyPrinter pretty(0, false);
+ StringifyFormatter ff;
+ erepository::DepSpecPrettyPrinter pretty(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
set1->accept(pretty);
TEST_CHECK_STRINGIFY_EQUAL(pretty, "cat-one/foo >=cat-two/bar-2");
}
@@ -130,7 +132,8 @@ namespace test_cases
env.package_database()->add_repository(1, repo);
tr1::shared_ptr<SetSpecTree::ConstItem> insecurity(repo->sets_interface->package_set(SetName("insecurity")));
- erepository::DepSpecPrettyPrinter pretty(0, false);
+ StringifyFormatter ff;
+ erepository::DepSpecPrettyPrinter pretty(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
insecurity->accept(pretty);
TEST_CHECK_STRINGIFY_EQUAL(pretty, "=cat-one/foo-1::test-repo-1 =cat-two/bar-1.5::test-repo-1 "
"=cat-two/bar-1.5.1::test-repo-1 =cat-three/baz-1.0::test-repo-1 "
@@ -171,7 +174,8 @@ namespace test_cases
env.package_database()->add_repository(0, installed);
tr1::shared_ptr<const SetSpecTree::ConstItem> security(repo->sets_interface->package_set(SetName("security")));
- erepository::DepSpecPrettyPrinter pretty(0, false);
+ StringifyFormatter ff;
+ erepository::DepSpecPrettyPrinter pretty(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
security->accept(pretty);
TEST_CHECK_STRINGIFY_EQUAL(pretty, "=cat-two/bar-2.0::test-repo-1 =cat-three/baz-1.3::test-repo-1");
}
diff --git a/paludis/repositories/e/ebuild_flat_metadata_cache.cc b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
index 2bdc30d..a5f1cb1 100644
--- a/paludis/repositories/e/ebuild_flat_metadata_cache.cc
+++ b/paludis/repositories/e/ebuild_flat_metadata_cache.cc
@@ -24,6 +24,7 @@
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/set.hh>
#include <paludis/repositories/e/dep_spec_pretty_printer.hh>
+#include <paludis/stringify_formatter.hh>
#include <paludis/repositories/e/eapi.hh>
#include <paludis/util/tr1_functional.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
@@ -157,7 +158,8 @@ namespace
template <typename T_>
std::string flatten(const T_ & d)
{
- DepSpecPrettyPrinter p(0, false);
+ StringifyFormatter ff;
+ DepSpecPrettyPrinter p(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, false);
d->accept(p);
return stringify(p);
}
diff --git a/paludis/repositories/e/ebuild_id.cc b/paludis/repositories/e/ebuild_id.cc
index 3746a28..6fb57c0 100644
--- a/paludis/repositories/e/ebuild_id.cc
+++ b/paludis/repositories/e/ebuild_id.cc
@@ -273,10 +273,10 @@ EbuildID::need_keys_added() const
}
_imp->repository_mask = make_shared_ptr(new EMutableRepositoryMaskInfoKey(shared_from_this(), "repository_mask", "Repository masked",
- tr1::static_pointer_cast<const ERepository>(repository())->repository_masked(*this), mkt_normal));
+ tr1::static_pointer_cast<const ERepository>(repository())->repository_masked(*this), mkt_internal));
add_metadata_key(_imp->repository_mask);
_imp->profile_mask = make_shared_ptr(new EMutableRepositoryMaskInfoKey(shared_from_this(), "profile_mask", "Profile masked",
- tr1::static_pointer_cast<const ERepository>(repository())->profile()->profile_masked(*this), mkt_normal));
+ tr1::static_pointer_cast<const ERepository>(repository())->profile()->profile_masked(*this), mkt_internal));
add_metadata_key(_imp->profile_mask);
}
@@ -672,7 +672,7 @@ void
EbuildID::load_build_depend(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->build_dependencies.reset(new EDependenciesKey(shared_from_this(), r, h, v, mkt_dependencies));
+ _imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), r, h, v, mkt_dependencies));
add_metadata_key(_imp->build_dependencies);
}
@@ -680,7 +680,7 @@ void
EbuildID::load_run_depend(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->run_dependencies.reset(new EDependenciesKey(shared_from_this(), r, h, v, mkt_dependencies));
+ _imp->run_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), r, h, v, mkt_dependencies));
add_metadata_key(_imp->run_dependencies);
}
@@ -688,7 +688,7 @@ void
EbuildID::load_post_depend(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->post_dependencies.reset(new EDependenciesKey(shared_from_this(), r, h, v, mkt_dependencies));
+ _imp->post_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), r, h, v, mkt_dependencies));
add_metadata_key(_imp->post_dependencies);
}
@@ -696,7 +696,7 @@ void
EbuildID::load_src_uri(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->src_uri.reset(new EURIKey(shared_from_this(), r, h, v, mkt_dependencies));
+ _imp->src_uri.reset(new EURIKey(_imp->environment, shared_from_this(), r, h, v, mkt_dependencies));
add_metadata_key(_imp->src_uri);
}
@@ -704,7 +704,7 @@ void
EbuildID::load_homepage(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->homepage.reset(new EURIKey(shared_from_this(), r, h, v, mkt_significant));
+ _imp->homepage.reset(new EURIKey(_imp->environment, shared_from_this(), r, h, v, mkt_significant));
add_metadata_key(_imp->homepage);
}
@@ -712,7 +712,7 @@ void
EbuildID::load_license(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->license.reset(new ELicenseKey(shared_from_this(), r, h, v, mkt_normal));
+ _imp->license.reset(new ELicenseKey(_imp->environment, shared_from_this(), r, h, v, mkt_internal));
add_metadata_key(_imp->license);
}
@@ -720,7 +720,7 @@ void
EbuildID::load_restrict(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->restrictions.reset(new ERestrictKey(shared_from_this(), r, h, v, mkt_internal));
+ _imp->restrictions.reset(new ERestrictKey(_imp->environment, shared_from_this(), r, h, v, mkt_internal));
add_metadata_key(_imp->restrictions);
}
@@ -728,7 +728,7 @@ void
EbuildID::load_provide(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->provide.reset(new EProvideKey(shared_from_this(), r, h, v, mkt_dependencies));
+ _imp->provide.reset(new EProvideKey(_imp->environment, shared_from_this(), r, h, v, mkt_dependencies));
add_metadata_key(_imp->provide);
}
@@ -736,7 +736,7 @@ void
EbuildID::load_iuse(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->iuse.reset(new EIUseKey(shared_from_this(), r, h, v, mkt_normal));
+ _imp->iuse.reset(new EIUseKey(_imp->environment, shared_from_this(), r, h, v, mkt_normal));
add_metadata_key(_imp->iuse);
}
@@ -744,7 +744,7 @@ void
EbuildID::load_keywords(const std::string & r, const std::string & h, const std::string & v) const
{
Lock l(_imp->mutex);
- _imp->keywords.reset(new EKeywordsKey(shared_from_this(), r, h, v, mkt_normal));
+ _imp->keywords.reset(new EKeywordsKey(_imp->environment, shared_from_this(), r, h, v, mkt_internal));
add_metadata_key(_imp->keywords);
}
diff --git a/paludis/repositories/e/qa/visibility.cc b/paludis/repositories/e/qa/visibility.cc
index 71766d4..0cc0e8e 100644
--- a/paludis/repositories/e/qa/visibility.cc
+++ b/paludis/repositories/e/qa/visibility.cc
@@ -35,6 +35,7 @@
#include <paludis/package_id.hh>
#include <paludis/version_requirements.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/stringify_formatter.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <set>
#include <algorithm>
@@ -237,7 +238,9 @@ namespace
{
if (reporter)
{
- erepository::DepSpecPrettyPrinter printer(0, false);
+ StringifyFormatter ff;
+ erepository::DepSpecPrettyPrinter printer(0, tr1::shared_ptr<const PackageID>(),
+ ff, 0, false, 0);
std::for_each(begin, end, accept_visitor(printer));
reporter->message(QAMessage(entry, qaml_normal, name, "No item in block '|| ( "
+ stringify(printer) + " )' visible for profile '"
diff --git a/paludis/repositories/e/vdb_id.cc b/paludis/repositories/e/vdb_id.cc
index 6a02434..46b1659 100644
--- a/paludis/repositories/e/vdb_id.cc
+++ b/paludis/repositories/e/vdb_id.cc
@@ -164,7 +164,7 @@ VDBID::need_keys_added() const
if (! env->env_use.empty())
if ((_imp->dir / env->env_use).exists())
{
- _imp->use.reset(new EUseKey(shared_from_this(), env->env_use, env->description_use,
+ _imp->use.reset(new EUseKey(_imp->environment, shared_from_this(), env->env_use, env->description_use,
file_contents(_imp->dir / env->env_use), mkt_internal));
add_metadata_key(_imp->use);
}
@@ -180,7 +180,7 @@ VDBID::need_keys_added() const
if (! vars->metadata_iuse.empty())
if ((_imp->dir / vars->metadata_iuse).exists())
{
- _imp->iuse.reset(new EIUseKey(shared_from_this(), vars->metadata_iuse, vars->description_iuse,
+ _imp->iuse.reset(new EIUseKey(_imp->environment, shared_from_this(), vars->metadata_iuse, vars->description_iuse,
file_contents(_imp->dir / vars->metadata_iuse), mkt_normal));
add_metadata_key(_imp->iuse);
}
@@ -188,7 +188,7 @@ VDBID::need_keys_added() const
if (! vars->metadata_license.empty())
if ((_imp->dir / vars->metadata_license).exists())
{
- _imp->license.reset(new ELicenseKey(shared_from_this(), vars->metadata_license, vars->description_license,
+ _imp->license.reset(new ELicenseKey(_imp->environment, shared_from_this(), vars->metadata_license, vars->description_license,
file_contents(_imp->dir / vars->metadata_license), mkt_normal));
add_metadata_key(_imp->license);
}
@@ -196,7 +196,7 @@ VDBID::need_keys_added() const
if (! vars->metadata_provide.empty())
if ((_imp->dir / vars->metadata_provide).exists())
{
- _imp->provide.reset(new EProvideKey(shared_from_this(), vars->metadata_provide, vars->description_provide,
+ _imp->provide.reset(new EProvideKey(_imp->environment, shared_from_this(), vars->metadata_provide, vars->description_provide,
file_contents(_imp->dir / vars->metadata_provide), mkt_internal));
add_metadata_key(_imp->provide);
}
@@ -204,7 +204,7 @@ VDBID::need_keys_added() const
if (! vars->metadata_build_depend.empty())
if ((_imp->dir / vars->metadata_build_depend).exists())
{
- _imp->build_dependencies.reset(new EDependenciesKey(shared_from_this(), vars->metadata_build_depend,
+ _imp->build_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_build_depend,
vars->description_build_depend, file_contents(_imp->dir / vars->metadata_build_depend), mkt_dependencies));
add_metadata_key(_imp->build_dependencies);
}
@@ -212,7 +212,7 @@ VDBID::need_keys_added() const
if (! vars->metadata_run_depend.empty())
if ((_imp->dir / vars->metadata_run_depend).exists())
{
- _imp->run_dependencies.reset(new EDependenciesKey(shared_from_this(), vars->metadata_run_depend,
+ _imp->run_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_run_depend,
vars->description_run_depend, file_contents(_imp->dir / vars->metadata_run_depend), mkt_dependencies));
add_metadata_key(_imp->run_dependencies);
}
@@ -220,7 +220,7 @@ VDBID::need_keys_added() const
if (! vars->metadata_pdepend.empty())
if ((_imp->dir / vars->metadata_pdepend).exists())
{
- _imp->post_dependencies.reset(new EDependenciesKey(shared_from_this(), vars->metadata_pdepend,
+ _imp->post_dependencies.reset(new EDependenciesKey(_imp->environment, shared_from_this(), vars->metadata_pdepend,
vars->description_pdepend, file_contents(_imp->dir / vars->metadata_pdepend), mkt_dependencies));
add_metadata_key(_imp->post_dependencies);
}
@@ -228,7 +228,7 @@ VDBID::need_keys_added() const
if (! vars->metadata_restrict.empty())
if ((_imp->dir / vars->metadata_restrict).exists())
{
- _imp->restrictions.reset(new ERestrictKey(shared_from_this(), vars->metadata_restrict, vars->description_restrict,
+ _imp->restrictions.reset(new ERestrictKey(_imp->environment, shared_from_this(), vars->metadata_restrict, vars->description_restrict,
file_contents(_imp->dir / vars->metadata_restrict), mkt_internal));
add_metadata_key(_imp->restrictions);
}
@@ -236,7 +236,7 @@ VDBID::need_keys_added() const
if (! vars->metadata_src_uri.empty())
if ((_imp->dir / vars->metadata_src_uri).exists())
{
- _imp->src_uri.reset(new EURIKey(shared_from_this(), vars->metadata_src_uri, vars->description_src_uri,
+ _imp->src_uri.reset(new EURIKey(_imp->environment, shared_from_this(), vars->metadata_src_uri, vars->description_src_uri,
file_contents(_imp->dir / vars->metadata_src_uri), mkt_dependencies));
add_metadata_key(_imp->src_uri);
}
@@ -252,7 +252,7 @@ VDBID::need_keys_added() const
if (! vars->metadata_homepage.empty())
if ((_imp->dir / vars->metadata_homepage).exists())
{
- _imp->homepage.reset(new EURIKey(shared_from_this(), vars->metadata_homepage, vars->description_homepage,
+ _imp->homepage.reset(new EURIKey(_imp->environment, shared_from_this(), vars->metadata_homepage, vars->description_homepage,
file_contents(_imp->dir / vars->metadata_homepage), mkt_significant));
add_metadata_key(_imp->homepage);
}
diff --git a/paludis/repositories/e/vdb_repository.cc b/paludis/repositories/e/vdb_repository.cc
index 0e32ceb..1ad7f7b 100644
--- a/paludis/repositories/e/vdb_repository.cc
+++ b/paludis/repositories/e/vdb_repository.cc
@@ -45,6 +45,7 @@
#include <paludis/set_file.hh>
#include <paludis/version_operator.hh>
#include <paludis/version_requirements.hh>
+#include <paludis/stringify_formatter.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/tr1_functional.hh>
@@ -919,8 +920,9 @@ VDBRepository::regenerate_provides_cache() const
if (! (*e)->provide_key())
continue;
- tr1::shared_ptr<const ProvideSpecTree::ConstItem> provide((*e)->provide_key()->value());;
- DepSpecPrettyPrinter p(0, false);
+ tr1::shared_ptr<const ProvideSpecTree::ConstItem> provide((*e)->provide_key()->value());
+ StringifyFormatter ff;
+ DepSpecPrettyPrinter p(0, tr1::shared_ptr<const PackageID>(), ff, 0, false, 0);
provide->accept(p);
std::string provide_str(strip_leading(strip_trailing(stringify(p), " \t\r\n"), " \t\r\n"));
if (provide_str.empty())
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index ece4476..40d3c6a 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -25,6 +25,7 @@
#include <paludis/action.hh>
#include <paludis/environment.hh>
#include <paludis/version_spec.hh>
+#include <paludis/formatter.hh>
#include <paludis/dep_spec.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/util/stringify.hh>
@@ -52,14 +53,23 @@ namespace paludis
struct Implementation<FakeMetadataSetKey<C_> >
{
tr1::shared_ptr<C_> collection;
+ const PackageID * const id;
+ const Environment * const env;
+
+ Implementation(const PackageID * const i, const Environment * const e) :
+ id(i),
+ env(e)
+ {
+ }
};
}
template <typename C_>
FakeMetadataSetKey<C_>::FakeMetadataSetKey(
- const std::string & r, const std::string & h, const MetadataKeyType t) :
+ const std::string & r, const std::string & h, const MetadataKeyType t, const PackageID * const i,
+ const Environment * const e) :
MetadataSetKey<C_>(r, h, t),
- PrivateImplementationPattern<FakeMetadataSetKey<C_> >(new Implementation<FakeMetadataSetKey<C_> >),
+ PrivateImplementationPattern<FakeMetadataSetKey<C_> >(new Implementation<FakeMetadataSetKey<C_> >(i, e)),
_imp(PrivateImplementationPattern<FakeMetadataSetKey<C_> >::_imp.get())
{
}
@@ -77,8 +87,9 @@ FakeMetadataSetKey<C_>::value() const
}
FakeMetadataKeywordSetKey::FakeMetadataKeywordSetKey(const std::string & r,
- const std::string & h, const std::string & v, const MetadataKeyType t) :
- FakeMetadataSetKey<KeywordNameSet>(r, h, t)
+ const std::string & h, const std::string & v, const MetadataKeyType t,
+ const PackageID * const i, const Environment * const e) :
+ FakeMetadataSetKey<KeywordNameSet>(r, h, t, i, e)
{
set_from_string(v);
}
@@ -91,8 +102,9 @@ FakeMetadataKeywordSetKey::set_from_string(const std::string & s)
}
FakeMetadataIUseSetKey::FakeMetadataIUseSetKey(const std::string & r,
- const std::string & h, const std::string & v, const IUseFlagParseMode m, const MetadataKeyType t) :
- FakeMetadataSetKey<IUseFlagSet>(r, h, t)
+ const std::string & h, const std::string & v, const IUseFlagParseMode m, const MetadataKeyType t,
+ const PackageID * const i, const Environment * const e) :
+ FakeMetadataSetKey<IUseFlagSet>(r, h, t, i, e)
{
set_from_string(v, m);
}
@@ -105,7 +117,7 @@ FakeMetadataIUseSetKey::set_from_string(const std::string & s, const IUseFlagPar
WhitespaceTokeniser::get_instance()->tokenise(s, std::back_inserter(tokens));
for (std::list<std::string>::const_iterator t(tokens.begin()), t_end(tokens.end()) ;
t != t_end ; ++t)
- _imp->collection->insert(IUseFlag(*t, m));
+ _imp->collection->insert(IUseFlag(*t, m, std::string::npos));
}
namespace paludis
@@ -157,14 +169,14 @@ FakeMetadataSpecTreeKey<C_>::value() const
template <typename C_>
std::string
-FakeMetadataSpecTreeKey<C_>::pretty_print() const
+FakeMetadataSpecTreeKey<C_>::pretty_print(const typename C_::Formatter &) const
{
return _imp->string_value;
}
template <typename C_>
std::string
-FakeMetadataSpecTreeKey<C_>::pretty_print_flat() const
+FakeMetadataSpecTreeKey<C_>::pretty_print_flat(const typename C_::Formatter &) const
{
return _imp->string_value;
}
@@ -275,14 +287,14 @@ namespace paludis
mutable bool has_masks;
Implementation(const Environment * const e, const tr1::shared_ptr<const FakeRepositoryBase> & r,
- const QualifiedPackageName & q, const VersionSpec & v) :
+ const QualifiedPackageName & q, const VersionSpec & v, const PackageID * const id) :
env(e),
repository(r),
name(q),
version(v),
slot("0"),
- keywords(new FakeMetadataKeywordSetKey("KEYWORDS", "Keywords", "test", mkt_normal)),
- iuse(new FakeMetadataIUseSetKey("IUSE", "Used USE flags", "", iuse_pm_permissive, mkt_normal)),
+ keywords(new FakeMetadataKeywordSetKey("KEYWORDS", "Keywords", "test", mkt_normal, id, env)),
+ iuse(new FakeMetadataIUseSetKey("IUSE", "Used USE flags", "", iuse_pm_permissive, mkt_normal, id, env)),
license(new FakeMetadataSpecTreeKey<LicenseSpecTree>("LICENSE", "Licenses",
"", tr1::bind(&erepository::parse_license, _1,
*erepository::EAPIData::get_instance()->eapi_from_string("0")), mkt_normal)),
@@ -312,7 +324,7 @@ namespace paludis
FakePackageID::FakePackageID(const Environment * const e, const tr1::shared_ptr<const FakeRepositoryBase> & r,
const QualifiedPackageName & q, const VersionSpec & v) :
- PrivateImplementationPattern<FakePackageID>(new Implementation<FakePackageID>(e, r, q, v)),
+ PrivateImplementationPattern<FakePackageID>(new Implementation<FakePackageID>(e, r, q, v, this)),
_imp(PrivateImplementationPattern<FakePackageID>::_imp.get())
{
add_metadata_key(_imp->keywords);
@@ -760,6 +772,108 @@ FakePackageID::fs_location_key() const
return tr1::shared_ptr<const MetadataFSEntryKey>();
}
+std::string
+FakeMetadataIUseSetKey::pretty_print_flat(const Formatter<IUseFlag> & f) const
+{
+ std::string result;
+ for (IUseFlagSet::Iterator i(value()->begin()), i_end(value()->end()) ;
+ i != i_end ; ++i)
+ {
+ if (! result.empty())
+ result.append(" ");
+
+ if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_mask(i->flag, *_imp->id))
+ result.append(f.format(*i, format::Masked()));
+ else if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_force(i->flag, *_imp->id))
+ result.append(f.format(*i, format::Forced()));
+ else if (_imp->env->query_use(i->flag, *_imp->id))
+ result.append(f.format(*i, format::Enabled()));
+ else
+ result.append(f.format(*i, format::Disabled()));
+ }
+
+ return result;
+}
+
+std::string
+FakeMetadataIUseSetKey::pretty_print_flat_with_comparison(
+ const Environment * const env,
+ const tr1::shared_ptr<const PackageID> & id,
+ const Formatter<IUseFlag> & f) const
+{
+ std::string result;
+ for (IUseFlagSet::Iterator i(value()->begin()), i_end(value()->end()) ;
+ i != i_end ; ++i)
+ {
+ if (! result.empty())
+ result.append(" ");
+
+ std::string l;
+ bool n;
+
+ if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_mask(i->flag, *_imp->id))
+ {
+ l = f.format(*i, format::Masked());
+ n = false;
+ }
+ else if (_imp->id->repository()->use_interface && _imp->id->repository()->use_interface->query_use_force(i->flag, *_imp->id))
+ {
+ l = f.format(*i, format::Forced());
+ n = true;
+ }
+ else if (_imp->env->query_use(i->flag, *_imp->id))
+ {
+ l = f.format(*i, format::Enabled());
+ n = true;
+ }
+ else
+ {
+ l = f.format(*i, format::Disabled());
+ n = true;
+ }
+
+ if (! id->iuse_key())
+ l = f.decorate(*i, l, format::Added());
+ else
+ {
+ using namespace tr1::placeholders;
+ IUseFlagSet::Iterator p(std::find_if(id->iuse_key()->value()->begin(), id->iuse_key()->value()->end(),
+ tr1::bind(std::equal_to<UseFlagName>(), i->flag, tr1::bind<const UseFlagName>(&IUseFlag::flag, _1))));
+
+ if (p == id->iuse_key()->value()->end())
+ l = f.decorate(*i, l, format::Added());
+ else if (n != env->query_use(i->flag, *id))
+ l = f.decorate(*i, l, format::Changed());
+ }
+
+ result.append(l);
+ }
+
+ return result;
+}
+
+
+std::string
+FakeMetadataKeywordSetKey::pretty_print_flat(const Formatter<KeywordName> & f) const
+{
+ std::string result;
+ for (KeywordNameSet::Iterator i(value()->begin()), i_end(value()->end()) ;
+ i != i_end ; ++i)
+ {
+ if (! result.empty())
+ result.append(" ");
+
+ tr1::shared_ptr<KeywordNameSet> k(new KeywordNameSet);
+ k->insert(*i);
+ if (_imp->env->accept_keywords(k, *_imp->id))
+ result.append(f.format(*i, format::Accepted()));
+ else
+ result.append(f.format(*i, format::Unaccepted()));
+ }
+
+ return result;
+}
+
template class FakeMetadataSpecTreeKey<LicenseSpecTree>;
template class FakeMetadataSpecTreeKey<ProvideSpecTree>;
template class FakeMetadataSpecTreeKey<DependencySpecTree>;
diff --git a/paludis/repositories/fake/fake_package_id.hh b/paludis/repositories/fake/fake_package_id.hh
index a9bd7cd..20739ce 100644
--- a/paludis/repositories/fake/fake_package_id.hh
+++ b/paludis/repositories/fake/fake_package_id.hh
@@ -24,6 +24,7 @@
#include <paludis/metadata_key.hh>
#include <paludis/mask.hh>
#include <paludis/util/tr1_functional.hh>
+#include <paludis/util/set.hh>
namespace paludis
{
@@ -37,7 +38,8 @@ namespace paludis
protected:
Implementation<FakeMetadataSetKey> * const _imp;
- FakeMetadataSetKey(const std::string &, const std::string &, const MetadataKeyType);
+ FakeMetadataSetKey(const std::string &, const std::string &, const MetadataKeyType,
+ const PackageID * const, const Environment * const);
public:
~FakeMetadataSetKey();
@@ -49,9 +51,13 @@ namespace paludis
public FakeMetadataSetKey<KeywordNameSet>
{
public:
- FakeMetadataKeywordSetKey(const std::string &, const std::string &, const std::string &, const MetadataKeyType);
+ FakeMetadataKeywordSetKey(const std::string &, const std::string &, const std::string &, const MetadataKeyType,
+ const PackageID * const, const Environment * const);
void set_from_string(const std::string &);
+
+ virtual std::string pretty_print_flat(const Formatter<KeywordName> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
class PALUDIS_VISIBLE FakeMetadataIUseSetKey :
@@ -59,9 +65,19 @@ namespace paludis
{
public:
FakeMetadataIUseSetKey(const std::string &, const std::string &, const std::string &, const IUseFlagParseMode,
- const MetadataKeyType);
+ const MetadataKeyType, const PackageID * const, const Environment * const);
void set_from_string(const std::string &, const IUseFlagParseMode);
+
+ virtual std::string pretty_print_flat(const Formatter<IUseFlag> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ virtual std::string pretty_print_flat_with_comparison(
+ const Environment * const,
+ const tr1::shared_ptr<const PackageID> &,
+ const Formatter<IUseFlag> &
+ ) const
+ PALUDIS_ATTRIBUTE((warn_unused_result));
};
template <typename C_>
@@ -82,10 +98,10 @@ namespace paludis
void set_from_string(const std::string &);
- virtual std::string pretty_print() const
+ virtual std::string pretty_print(const typename C_::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print_flat() const
+ virtual std::string pretty_print_flat(const typename C_::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 19537f9..1fe5dde 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -159,7 +159,8 @@ InstalledVirtualsRepository::need_ids() const
if (i == _imp->ids.end())
i = _imp->ids.insert(std::make_pair(p->virtual_name, make_shared_ptr(new PackageIDSequence))).first;
- tr1::shared_ptr<const PackageID> id(new virtuals::VirtualsPackageID(shared_from_this(), p->virtual_name, p->provided_by, false));
+ tr1::shared_ptr<const PackageID> id(new virtuals::VirtualsPackageID(
+ _imp->env, shared_from_this(), p->virtual_name, p->provided_by, false));
i->second->push_back(id);
}
}
diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc
index ab44c44..e3a5d19 100644
--- a/paludis/repositories/virtuals/package_id.cc
+++ b/paludis/repositories/virtuals/package_id.cc
@@ -28,11 +28,15 @@
#include <paludis/name.hh>
#include <paludis/dep_spec.hh>
#include <paludis/version_spec.hh>
+#include <paludis/environment.hh>
#include <paludis/version_requirements.hh>
#include <paludis/metadata_key.hh>
+#include <paludis/formatter.hh>
#include <paludis/hashed_containers.hh>
#include <paludis/action.hh>
#include <paludis/mask.hh>
+#include <paludis/package_database.hh>
+#include <paludis/query.hh>
using namespace paludis;
using namespace paludis::virtuals;
@@ -53,9 +57,11 @@ namespace paludis
template <>
struct Implementation<VirtualsDepKey>
{
+ const Environment * const env;
const tr1::shared_ptr<const TreeLeaf<DependencySpecTree, PackageDepSpec> > value;
- Implementation(const tr1::shared_ptr<const PackageID> & v, bool exact) :
+ Implementation(const Environment * const e, const tr1::shared_ptr<const PackageID> & v, bool exact) :
+ env(e),
value(exact ?
new TreeLeaf<DependencySpecTree, PackageDepSpec>(make_shared_ptr(new PackageDepSpec(
make_shared_ptr(new QualifiedPackageName(v->name())),
@@ -93,10 +99,10 @@ VirtualsPackageIDKey::value() const
return _imp->value;
}
-VirtualsDepKey::VirtualsDepKey(const std::string & r, const std::string & h,
+VirtualsDepKey::VirtualsDepKey(const Environment * const e, const std::string & r, const std::string & h,
const tr1::shared_ptr<const PackageID> & v, const bool exact) :
MetadataSpecTreeKey<DependencySpecTree>(r, h, mkt_dependencies),
- PrivateImplementationPattern<VirtualsDepKey>(new Implementation<VirtualsDepKey>(v, exact)),
+ PrivateImplementationPattern<VirtualsDepKey>(new Implementation<VirtualsDepKey>(e, v, exact)),
_imp(PrivateImplementationPattern<VirtualsDepKey>::_imp.get())
{
}
@@ -112,15 +118,39 @@ VirtualsDepKey::value() const
}
std::string
-VirtualsDepKey::pretty_print() const
+VirtualsDepKey::pretty_print(const DependencySpecTree::Formatter & f) const
{
- return stringify(*_imp->value->item());
+ if (_imp->env)
+ {
+ if (! _imp->env->package_database()->query(query::Matches(*_imp->value->item()) &
+ query::InstalledAtRoot(_imp->env->root()), qo_whatever)->empty())
+ return f.format(*_imp->value->item(), format::Installed());
+ else if (! _imp->env->package_database()->query(query::Matches(*_imp->value->item()) &
+ query::SupportsAction<InstallAction>() & query::NotMasked(), qo_whatever)->empty())
+ return f.format(*_imp->value->item(), format::Installable());
+ else
+ return f.format(*_imp->value->item(), format::Plain());
+ }
+ else
+ return f.format(*_imp->value->item(), format::Plain());
}
std::string
-VirtualsDepKey::pretty_print_flat() const
+VirtualsDepKey::pretty_print_flat(const DependencySpecTree::Formatter & f) const
{
- return stringify(*_imp->value->item());
+ if (_imp->env)
+ {
+ if (! _imp->env->package_database()->query(query::Matches(*_imp->value->item()) &
+ query::InstalledAtRoot(_imp->env->root()), qo_whatever)->empty())
+ return f.format(*_imp->value->item(), format::Installed());
+ else if (! _imp->env->package_database()->query(query::Matches(*_imp->value->item()) &
+ query::SupportsAction<InstallAction>() & query::NotMasked(), qo_whatever)->empty())
+ return f.format(*_imp->value->item(), format::Installable());
+ else
+ return f.format(*_imp->value->item(), format::Plain());
+ }
+ else
+ return f.format(*_imp->value->item(), format::Plain());
}
namespace paludis
@@ -128,6 +158,7 @@ namespace paludis
template <>
struct Implementation<VirtualsPackageID>
{
+ const Environment * const env;
const tr1::shared_ptr<const Repository> repository;
const QualifiedPackageName name;
const VersionSpec version;
@@ -137,17 +168,19 @@ namespace paludis
mutable bool has_masks;
mutable Mutex mutex;
- Implementation(
+ Implementation(
+ const Environment * const e,
const tr1::shared_ptr<const Repository> & o,
const QualifiedPackageName & n,
const tr1::shared_ptr<const PackageID> & p,
const bool b) :
+ env(e),
repository(o),
name(n),
version(p->version()),
virtual_for(new virtuals::VirtualsPackageIDKey(p)),
- bdep(new virtuals::VirtualsDepKey("DEPEND", "Build dependencies", p, b)),
- rdep(new virtuals::VirtualsDepKey("RDEPEND", "Run dependencies", p, b)),
+ bdep(new virtuals::VirtualsDepKey(e, "DEPEND", "Build dependencies", p, b)),
+ rdep(new virtuals::VirtualsDepKey(e, "RDEPEND", "Run dependencies", p, b)),
has_masks(false)
{
}
@@ -155,12 +188,13 @@ namespace paludis
}
VirtualsPackageID::VirtualsPackageID(
+ const Environment * const e,
const tr1::shared_ptr<const Repository> & owner,
const QualifiedPackageName & virtual_name,
const tr1::shared_ptr<const PackageID> & virtual_for,
const bool exact) :
PrivateImplementationPattern<VirtualsPackageID>(
- new Implementation<VirtualsPackageID>(owner, virtual_name, virtual_for, exact)),
+ new Implementation<VirtualsPackageID>(e, owner, virtual_name, virtual_for, exact)),
_imp(PrivateImplementationPattern<VirtualsPackageID>::_imp.get())
{
add_metadata_key(_imp->virtual_for);
diff --git a/paludis/repositories/virtuals/package_id.hh b/paludis/repositories/virtuals/package_id.hh
index b4da2ee..beca99f 100644
--- a/paludis/repositories/virtuals/package_id.hh
+++ b/paludis/repositories/virtuals/package_id.hh
@@ -51,17 +51,17 @@ namespace paludis
Implementation<VirtualsDepKey> * const _imp;
public:
- VirtualsDepKey(const std::string &, const std::string &,
+ VirtualsDepKey(const Environment * const, const std::string &, const std::string &,
const tr1::shared_ptr<const PackageID> &, const bool);
~VirtualsDepKey();
virtual const tr1::shared_ptr<const DependencySpecTree::ConstItem> value() const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print() const
+ virtual std::string pretty_print(const DependencySpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
- virtual std::string pretty_print_flat() const
+ virtual std::string pretty_print_flat(const DependencySpecTree::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result));
};
@@ -78,6 +78,7 @@ namespace paludis
public:
VirtualsPackageID(
+ const Environment * const,
const tr1::shared_ptr<const Repository> & repo,
const QualifiedPackageName & virtual_name,
const tr1::shared_ptr<const PackageID> & virtual_for,
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index b41e579..e60f699 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -346,7 +346,7 @@ VirtualsRepository::make_virtual_package_id(
throw InternalError(PALUDIS_HERE, "tried to make a virtual package id using '" + stringify(virtual_name) + "', '"
+ stringify(*provider) + "'");
- return make_shared_ptr(new virtuals::VirtualsPackageID(shared_from_this(), virtual_name, provider, true));
+ return make_shared_ptr(new virtuals::VirtualsPackageID(_imp->env, shared_from_this(), virtual_name, provider, true));
}
bool
diff --git a/paludis/stringify_formatter-fwd.hh b/paludis/stringify_formatter-fwd.hh
new file mode 100644
index 0000000..d867c6c
--- /dev/null
+++ b/paludis/stringify_formatter-fwd.hh
@@ -0,0 +1,28 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_STRINGIFY_FORMATTER_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_STRINGIFY_FORMATTER_FWD_HH 1
+
+namespace paludis
+{
+ class StringifyFormatter;
+}
+
+#endif
diff --git a/paludis/stringify_formatter-impl.hh b/paludis/stringify_formatter-impl.hh
new file mode 100644
index 0000000..19d99fb
--- /dev/null
+++ b/paludis/stringify_formatter-impl.hh
@@ -0,0 +1,131 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_STRINGIFY_FORMATTER_IMPL_HH
+#define PALUDIS_GUARD_PALUDIS_STRINGIFY_FORMATTER_IMPL_HH 1
+
+#include <paludis/stringify_formatter.hh>
+#include <paludis/util/tr1_type_traits.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+
+namespace paludis
+{
+ template <>
+ struct Implementation<StringifyFormatter>
+ {
+ const CanFormat<IUseFlag> * const f_iuse;
+ const CanFormat<UseFlagName> * const f_use;
+ const CanFormat<KeywordName> * const f_keyword;
+ const CanFormat<PackageDepSpec> * const f_package;
+ const CanFormat<BlockDepSpec> * const f_block;
+ const CanFormat<URIDepSpec> * const f_uri;
+ const CanFormat<LabelsDepSpec<DependencyLabelVisitorTypes> > * const f_dep_label;
+ const CanFormat<LabelsDepSpec<URILabelVisitorTypes> > * const f_uri_label;
+ const CanFormat<PlainTextDepSpec> * const f_plain;
+ const CanFormat<UseDepSpec> * const f_use_dep;
+ const CanSpace * const f_space;
+
+ Implementation(
+ const CanFormat<IUseFlag> * const f_iuse_v,
+ const CanFormat<UseFlagName> * const f_use_v,
+ const CanFormat<KeywordName> * const f_keyword_v,
+ const CanFormat<PackageDepSpec> * const f_package_v,
+ const CanFormat<BlockDepSpec> * const f_block_v,
+ const CanFormat<URIDepSpec> * const f_uri_v,
+ const CanFormat<LabelsDepSpec<DependencyLabelVisitorTypes> > * const f_dep_label_v,
+ const CanFormat<LabelsDepSpec<URILabelVisitorTypes> > * const f_uri_label_v,
+ const CanFormat<PlainTextDepSpec> * const f_plain_v,
+ const CanFormat<UseDepSpec> * const f_use_dep_v,
+ const CanSpace * const f_space_v
+ ) :
+ f_iuse(f_iuse_v),
+ f_use(f_use_v),
+ f_keyword(f_keyword_v),
+ f_package(f_package_v),
+ f_block(f_block_v),
+ f_uri(f_uri_v),
+ f_dep_label(f_dep_label_v),
+ f_uri_label(f_uri_label_v),
+ f_plain(f_plain_v),
+ f_use_dep(f_use_dep_v),
+ f_space(f_space_v)
+ {
+ }
+ };
+
+ template <bool b_, typename T_>
+ struct StringifyFormatterGetForwarder
+ {
+ static const CanFormat<T_> * get(const CanFormat<T_> * const t)
+ {
+ return t;
+ }
+ };
+
+ template <typename T_>
+ struct StringifyFormatterGetForwarder<false, T_>
+ {
+ static const CanFormat<T_> * get(const void * const)
+ {
+ return 0;
+ }
+ };
+
+ template <bool b_>
+ struct StringifyFormatterGetSpaceForwarder
+ {
+ static const CanSpace * get(const CanSpace * const t)
+ {
+ return t;
+ }
+ };
+
+ template <>
+ struct StringifyFormatterGetSpaceForwarder<false>
+ {
+ static const CanSpace * get(const void * const)
+ {
+ return 0;
+ }
+ };
+
+ template <typename T_>
+ StringifyFormatter::StringifyFormatter(const T_ & t) :
+ PrivateImplementationPattern<StringifyFormatter>(new Implementation<StringifyFormatter>(
+ StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<IUseFlag> *>::value, IUseFlag>::get(&t),
+ StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<UseFlagName> *>::value, UseFlagName>::get(&t),
+ StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<KeywordName> *>::value, KeywordName>::get(&t),
+ StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<PackageDepSpec> *>::value, PackageDepSpec>::get(&t),
+ StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<BlockDepSpec> *>::value, BlockDepSpec>::get(&t),
+ StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<URIDepSpec> *>::value, URIDepSpec>::get(&t),
+ StringifyFormatterGetForwarder<
+ tr1::is_convertible<T_ *, CanFormat<LabelsDepSpec<DependencyLabelVisitorTypes> > *>::value,
+ LabelsDepSpec<DependencyLabelVisitorTypes> >::get(&t),
+ StringifyFormatterGetForwarder<
+ tr1::is_convertible<T_ *, CanFormat<LabelsDepSpec<URILabelVisitorTypes> > *>::value,
+ LabelsDepSpec<URILabelVisitorTypes> >::get(&t),
+ StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<PlainTextDepSpec> *>::value, PlainTextDepSpec>::get(&t),
+ StringifyFormatterGetForwarder<tr1::is_convertible<T_ *, CanFormat<UseDepSpec> *>::value, UseDepSpec>::get(&t),
+ StringifyFormatterGetSpaceForwarder<tr1::is_convertible<T_ *, CanSpace *>::value>::get(&t)
+ ))
+ {
+ }
+}
+
+#endif
diff --git a/paludis/stringify_formatter.cc b/paludis/stringify_formatter.cc
new file mode 100644
index 0000000..cceeb6d
--- /dev/null
+++ b/paludis/stringify_formatter.cc
@@ -0,0 +1,293 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/stringify_formatter.hh>
+#include <paludis/stringify_formatter-impl.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/dep_label.hh>
+
+using namespace paludis;
+
+StringifyFormatter::StringifyFormatter() :
+ PrivateImplementationPattern<StringifyFormatter>(new Implementation<StringifyFormatter>(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
+{
+}
+
+StringifyFormatter::~StringifyFormatter()
+{
+}
+
+std::string
+StringifyFormatter::format(const UseFlagName & s, const format::Enabled & k) const
+{
+ if (_imp->f_use)
+ return _imp->f_use->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const UseFlagName & s, const format::Disabled & k) const
+{
+ if (_imp->f_use)
+ return _imp->f_use->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const UseFlagName & s, const format::Forced & k) const
+{
+ if (_imp->f_use)
+ return _imp->f_use->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const UseFlagName & s, const format::Masked & k) const
+{
+ if (_imp->f_use)
+ return _imp->f_use->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const UseFlagName & s, const format::Plain & k) const
+{
+ if (_imp->f_use)
+ return _imp->f_use->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const IUseFlag & s, const format::Enabled & k) const
+{
+ if (_imp->f_iuse)
+ return _imp->f_iuse->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const IUseFlag & s, const format::Disabled & k) const
+{
+ if (_imp->f_iuse)
+ return _imp->f_iuse->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const IUseFlag & s, const format::Forced & k) const
+{
+ if (_imp->f_iuse)
+ return _imp->f_iuse->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const IUseFlag & s, const format::Masked & k) const
+{
+ if (_imp->f_iuse)
+ return _imp->f_iuse->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::decorate(const IUseFlag & f, const std::string & s, const format::Changed & k) const
+{
+ if (_imp->f_iuse)
+ return _imp->f_iuse->decorate(f, s, k);
+ return s;
+}
+
+std::string
+StringifyFormatter::decorate(const IUseFlag & f, const std::string & s, const format::Added & k) const
+{
+ if (_imp->f_iuse)
+ return _imp->f_iuse->decorate(f, s, k);
+ return s;
+}
+
+std::string
+StringifyFormatter::format(const IUseFlag & s, const format::Plain & k) const
+{
+ if (_imp->f_iuse)
+ return _imp->f_iuse->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const KeywordName & s, const format::Accepted & k) const
+{
+ if (_imp->f_keyword)
+ return _imp->f_keyword->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const KeywordName & s, const format::Unaccepted & k) const
+{
+ if (_imp->f_keyword)
+ return _imp->f_keyword->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const KeywordName & s, const format::Plain & k) const
+{
+ if (_imp->f_keyword)
+ return _imp->f_keyword->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const PackageDepSpec & s, const format::Plain & k) const
+{
+ if (_imp->f_package)
+ return _imp->f_package->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const PackageDepSpec & s, const format::Installed & k) const
+{
+ if (_imp->f_package)
+ return _imp->f_package->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const PackageDepSpec & s, const format::Installable & k) const
+{
+ if (_imp->f_package)
+ return _imp->f_package->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const BlockDepSpec & s, const format::Plain & k) const
+{
+ if (_imp->f_block)
+ return _imp->f_block->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const URIDepSpec & s, const format::Plain & k) const
+{
+ if (_imp->f_uri)
+ return _imp->f_uri->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const LabelsDepSpec<DependencyLabelVisitorTypes> & s, const format::Plain & k) const
+{
+ if (_imp->f_dep_label)
+ return _imp->f_dep_label->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const LabelsDepSpec<URILabelVisitorTypes> & s, const format::Plain & k) const
+{
+ if (_imp->f_uri_label)
+ return _imp->f_uri_label->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const PlainTextDepSpec & s, const format::Plain & k) const
+{
+ if (_imp->f_plain)
+ return _imp->f_plain->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const PlainTextDepSpec & s, const format::Accepted & k) const
+{
+ if (_imp->f_plain)
+ return _imp->f_plain->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const PlainTextDepSpec & s, const format::Unaccepted & k) const
+{
+ if (_imp->f_plain)
+ return _imp->f_plain->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const UseDepSpec & s, const format::Enabled & k) const
+{
+ if (_imp->f_use_dep)
+ return _imp->f_use_dep->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const UseDepSpec & s, const format::Disabled & k) const
+{
+ if (_imp->f_use_dep)
+ return _imp->f_use_dep->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const UseDepSpec & s, const format::Forced & k) const
+{
+ if (_imp->f_use_dep)
+ return _imp->f_use_dep->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const UseDepSpec & s, const format::Masked & k) const
+{
+ if (_imp->f_use_dep)
+ return _imp->f_use_dep->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::format(const UseDepSpec & s, const format::Plain & k) const
+{
+ if (_imp->f_use_dep)
+ return _imp->f_use_dep->format(s, k);
+ return stringify(s);
+}
+
+std::string
+StringifyFormatter::newline() const
+{
+ if (_imp->f_space)
+ return _imp->f_space->newline();
+ return "\n";
+}
+
+std::string
+StringifyFormatter::indent(const int i) const
+{
+ if (_imp->f_space)
+ return _imp->f_space->indent(i);
+ return std::string(4 * i, ' ');
+}
+
diff --git a/paludis/stringify_formatter.hh b/paludis/stringify_formatter.hh
new file mode 100644
index 0000000..e799858
--- /dev/null
+++ b/paludis/stringify_formatter.hh
@@ -0,0 +1,100 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_STRINGIFY_FORMATTER_HH
+#define PALUDIS_GUARD_PALUDIS_STRINGIFY_FORMATTER_HH 1
+
+#include <paludis/stringify_formatter-fwd.hh>
+#include <paludis/formatter.hh>
+#include <paludis/name.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+
+namespace paludis
+{
+ class PALUDIS_VISIBLE StringifyFormatter :
+ private PrivateImplementationPattern<StringifyFormatter>,
+ public CanFormat<UseFlagName>,
+ public CanFormat<IUseFlag>,
+ public CanFormat<KeywordName>,
+ public CanFormat<PackageDepSpec>,
+ public CanFormat<BlockDepSpec>,
+ public CanFormat<URIDepSpec>,
+ public CanFormat<LabelsDepSpec<DependencyLabelVisitorTypes> >,
+ public CanFormat<LabelsDepSpec<URILabelVisitorTypes> >,
+ public CanFormat<PlainTextDepSpec>,
+ public CanFormat<UseDepSpec>,
+ public CanSpace
+ {
+ private:
+ StringifyFormatter(const StringifyFormatter &);
+
+ public:
+ StringifyFormatter();
+
+ template <typename T_> StringifyFormatter(const T_ &);
+
+ ~StringifyFormatter();
+
+ virtual std::string format(const UseFlagName &, const format::Enabled &) const;
+ virtual std::string format(const UseFlagName &, const format::Disabled &) const;
+ virtual std::string format(const UseFlagName &, const format::Forced &) const;
+ virtual std::string format(const UseFlagName &, const format::Masked &) const;
+ virtual std::string format(const UseFlagName &, const format::Plain &) const;
+
+ virtual std::string format(const IUseFlag &, const format::Enabled &) const;
+ virtual std::string format(const IUseFlag &, const format::Disabled &) const;
+ virtual std::string format(const IUseFlag &, const format::Forced &) const;
+ virtual std::string format(const IUseFlag &, const format::Masked &) const;
+ virtual std::string format(const IUseFlag &, const format::Plain &) const;
+ virtual std::string decorate(const IUseFlag &, const std::string &, const format::Changed &) const;
+ virtual std::string decorate(const IUseFlag &, const std::string &, const format::Added &) const;
+
+ virtual std::string format(const KeywordName &, const format::Accepted &) const;
+ virtual std::string format(const KeywordName &, const format::Unaccepted &) const;
+ virtual std::string format(const KeywordName &, const format::Plain &) const;
+
+ virtual std::string format(const PackageDepSpec &, const format::Plain &) const;
+ virtual std::string format(const PackageDepSpec &, const format::Installed &) const;
+ virtual std::string format(const PackageDepSpec &, const format::Installable &) const;
+
+ virtual std::string format(const BlockDepSpec &, const format::Plain &) const;
+
+ virtual std::string format(const URIDepSpec &, const format::Plain &) const;
+
+ virtual std::string format(const LabelsDepSpec<DependencyLabelVisitorTypes> &, const format::Plain &) const;
+
+ virtual std::string format(const LabelsDepSpec<URILabelVisitorTypes> &, const format::Plain &) const;
+
+ virtual std::string format(const PlainTextDepSpec &, const format::Plain &) const;
+ virtual std::string format(const PlainTextDepSpec &, const format::Accepted &) const;
+ virtual std::string format(const PlainTextDepSpec &, const format::Unaccepted &) const;
+
+ virtual std::string format(const UseDepSpec &, const format::Enabled &) const;
+ virtual std::string format(const UseDepSpec &, const format::Disabled &) const;
+ virtual std::string format(const UseDepSpec &, const format::Forced &) const;
+ virtual std::string format(const UseDepSpec &, const format::Masked &) const;
+ virtual std::string format(const UseDepSpec &, const format::Plain &) const;
+
+ virtual std::string newline() const;
+ virtual std::string indent(const int) const;
+ };
+}
+
+#endif
diff --git a/paludis/stringify_formatter_TEST.cc b/paludis/stringify_formatter_TEST.cc
new file mode 100644
index 0000000..dd7ea37
--- /dev/null
+++ b/paludis/stringify_formatter_TEST.cc
@@ -0,0 +1,120 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/stringify_formatter.hh>
+#include <paludis/stringify_formatter-impl.hh>
+#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/dep_spec.hh>
+#include <test/test_runner.hh>
+#include <test/test_framework.hh>
+
+using namespace test;
+using namespace paludis;
+
+namespace
+{
+ std::string format_two(const KeywordName & k, const UseFlagName & n,
+ const Formatter<KeywordName, UseFlagName> & f)
+ {
+ return f.format(k, format::Accepted()) + " " + f.format(n, format::Enabled());
+ }
+
+ std::string format_three(const PackageDepSpec & k, const BlockDepSpec & d, const UseDepSpec & u,
+ const GenericSpecTree::Formatter & f)
+ {
+ return f.format(k, format::Plain()) + " " + f.format(d, format::Plain()) + " " + f.format(u, format::Enabled());
+ }
+
+ class PartialFormatter :
+ public CanFormat<KeywordName>,
+ public CanFormat<PackageDepSpec>
+ {
+ private:
+ PartialFormatter(const PartialFormatter &);
+
+ public:
+ PartialFormatter()
+ {
+ }
+
+ virtual std::string format(const KeywordName & s, const format::Accepted &) const
+ {
+ return "<" + stringify(s) + ">";
+ }
+
+ virtual std::string format(const KeywordName & s, const format::Unaccepted &) const
+ {
+ return "<" + stringify(s) + ">";
+ }
+
+ virtual std::string format(const KeywordName & s, const format::Plain &) const
+ {
+ return "<" + stringify(s) + ">";
+ }
+
+ virtual std::string format(const PackageDepSpec & s, const format::Plain &) const
+ {
+ return "<" + stringify(s) + ">";
+ }
+
+ virtual std::string format(const PackageDepSpec & s, const format::Installed &) const
+ {
+ return "<" + stringify(s) + ">";
+ }
+
+ virtual std::string format(const PackageDepSpec & s, const format::Installable &) const
+ {
+ return "<" + stringify(s) + ">";
+ }
+ };
+}
+
+namespace test_cases
+{
+ struct StringifyFormatterTest : TestCase
+ {
+ StringifyFormatterTest() : TestCase("stringify formatter") { }
+
+ void run()
+ {
+ StringifyFormatter ff;
+ std::string s(format_two(KeywordName("one"), UseFlagName("two"), ff));
+ TEST_CHECK_EQUAL(s, "one two");
+ }
+ } test_stringify_formatter;
+
+ struct StringifyFormatterPartialTest : TestCase
+ {
+ StringifyFormatterPartialTest() : TestCase("stringify formatter partial") { }
+
+ void run()
+ {
+ PartialFormatter f;
+ StringifyFormatter ff(f);
+ BlockDepSpec b(make_shared_ptr(new PackageDepSpec("cat/pkg", pds_pm_permissive)));
+ UseDepSpec u(UseFlagName("foo"), true);
+ std::string s(format_three(
+ PackageDepSpec("cat/pkg", pds_pm_permissive),
+ b, u,
+ ff));
+ TEST_CHECK_EQUAL(s, "<cat/pkg> !cat/pkg !foo?");
+ }
+ } test_stringify_formatter_partial;
+}
+
diff --git a/paludis/tasks/report_task.cc b/paludis/tasks/report_task.cc
index f7bb13a..15f5b12 100644
--- a/paludis/tasks/report_task.cc
+++ b/paludis/tasks/report_task.cc
@@ -221,24 +221,24 @@ ReportTask::execute()
if (is_masked || is_vulnerable || is_missing || is_unused)
{
- on_report_package_failure_pre(**v);
+ on_report_package_failure_pre(*v);
if (is_masked)
- on_report_package_is_masked(**v, *origin);
+ on_report_package_is_masked(*v, origin);
if (is_vulnerable)
{
- on_report_package_is_vulnerable_pre(**v);
+ on_report_package_is_vulnerable_pre(*v);
for (VulnerableChecker::ConstIterator itag(pi.first) ; itag != pi.second ; ++itag)
- on_report_package_is_vulnerable(**v, itag->second->short_text());
- on_report_package_is_vulnerable_post(**v);
+ on_report_package_is_vulnerable(*v, itag->second->short_text());
+ on_report_package_is_vulnerable_post(*v);
}
if (is_missing)
- on_report_package_is_missing(**v, *repo_name);
+ on_report_package_is_missing(*v, *repo_name);
if (is_unused)
- on_report_package_is_unused(**v);
- on_report_package_failure_post(**v);
+ on_report_package_is_unused(*v);
+ on_report_package_failure_post(*v);
}
else
- on_report_package_success(**v);
+ on_report_package_success(*v);
}
on_report_check_package_post(*p);
diff --git a/paludis/tasks/report_task.hh b/paludis/tasks/report_task.hh
index 5be4cec..7129afa 100644
--- a/paludis/tasks/report_task.hh
+++ b/paludis/tasks/report_task.hh
@@ -59,15 +59,17 @@ namespace paludis
virtual void on_report_all_pre() = 0;
virtual void on_report_check_package_pre(const QualifiedPackageName & p) = 0;
- virtual void on_report_package_success(const PackageID & id) = 0;
- virtual void on_report_package_failure_pre(const PackageID & id) = 0;
- virtual void on_report_package_is_masked(const PackageID & installed, const PackageID & origin) = 0;
- virtual void on_report_package_is_vulnerable_pre(const PackageID & id) = 0;
- virtual void on_report_package_is_vulnerable(const PackageID & id, const std::string & tag) = 0;
- virtual void on_report_package_is_vulnerable_post(const PackageID & id) = 0;
- virtual void on_report_package_is_missing(const PackageID & id, const RepositoryName & repo_name) = 0;
- virtual void on_report_package_is_unused(const PackageID & id) = 0;
- virtual void on_report_package_failure_post(const PackageID & id) = 0;
+ virtual void on_report_package_success(const tr1::shared_ptr<const PackageID> & id) = 0;
+ virtual void on_report_package_failure_pre(const tr1::shared_ptr<const PackageID> & id) = 0;
+ virtual void on_report_package_is_masked(const tr1::shared_ptr<const PackageID> & id,
+ const tr1::shared_ptr<const PackageID> & origin) = 0;
+ virtual void on_report_package_is_vulnerable_pre(const tr1::shared_ptr<const PackageID> & id) = 0;
+ virtual void on_report_package_is_vulnerable(const tr1::shared_ptr<const PackageID> & id, const std::string & tag) = 0;
+ virtual void on_report_package_is_vulnerable_post(const tr1::shared_ptr<const PackageID> & id) = 0;
+ virtual void on_report_package_is_missing(const tr1::shared_ptr<const PackageID> & id,
+ const RepositoryName & repo_name) = 0;
+ virtual void on_report_package_is_unused(const tr1::shared_ptr<const PackageID> & id) = 0;
+ virtual void on_report_package_failure_post(const tr1::shared_ptr<const PackageID> & id) = 0;
virtual void on_report_check_package_post(const QualifiedPackageName & p) = 0;
virtual void on_report_all_post() = 0;
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index d2993c2..402c3b5 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -30,6 +30,7 @@ add(`log', `hh', `cc', `se', `test')
add(`make_shared_ptr', `hh', `fwd')
add(`map', `hh', `fwd', `impl', `cc')
add(`mutex', `hh', `cc', `test')
+add(`no_type', `hh')
add(`operators', `hh')
add(`options', `hh', `fwd', `cc', `test')
add(`output_wrapper', `test', `testscript')
diff --git a/paludis/util/no_type.hh b/paludis/util/no_type.hh
new file mode 100644
index 0000000..d94856f
--- /dev/null
+++ b/paludis/util/no_type.hh
@@ -0,0 +1,29 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_NO_TYPE_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_NO_TYPE_HH 1
+
+namespace paludis
+{
+ template <unsigned u_>
+ class NoType;
+}
+
+#endif
diff --git a/paludis/util/visitor-fwd.hh b/paludis/util/visitor-fwd.hh
index 30092f1..abedecd 100644
--- a/paludis/util/visitor-fwd.hh
+++ b/paludis/util/visitor-fwd.hh
@@ -20,13 +20,12 @@
#ifndef PALUDIS_GUARD_PALUDIS_UTIL_VISITOR_FWD_HH
#define PALUDIS_GUARD_PALUDIS_UTIL_VISITOR_FWD_HH 1
+#include <paludis/util/no_type.hh>
+
namespace paludis
{
namespace visitor_internals
{
- template <unsigned u_>
- class NoType;
-
template <typename H_>
class ConstAcceptInterface;
@@ -120,26 +119,26 @@ namespace paludis
template <
typename Heirarchy_,
typename BasicNode_,
- typename ContainedItem1_ = visitor_internals::NoType<1>,
- typename ContainedItem2_ = visitor_internals::NoType<2>,
- typename ContainedItem3_ = visitor_internals::NoType<3>,
- typename ContainedItem4_ = visitor_internals::NoType<4>,
- typename ContainedItem5_ = visitor_internals::NoType<5>,
- typename ContainedItem6_ = visitor_internals::NoType<6>,
- typename ContainedItem7_ = visitor_internals::NoType<7>,
- typename ContainedItem8_ = visitor_internals::NoType<8>,
- typename ContainedItem9_ = visitor_internals::NoType<9>,
- typename ContainedItem10_ = visitor_internals::NoType<10>,
- typename ContainedItem11_ = visitor_internals::NoType<11>,
- typename ContainedItem12_ = visitor_internals::NoType<12>,
- typename ContainedItem13_ = visitor_internals::NoType<13>,
- typename ContainedItem14_ = visitor_internals::NoType<14>,
- typename ContainedItem15_ = visitor_internals::NoType<15>,
- typename ContainedItem16_ = visitor_internals::NoType<16>,
- typename ContainedItem17_ = visitor_internals::NoType<17>,
- typename ContainedItem18_ = visitor_internals::NoType<18>,
- typename ContainedItem19_ = visitor_internals::NoType<19>,
- typename ContainedItem20_ = visitor_internals::NoType<20> >
+ typename ContainedItem1_ = NoType<1>,
+ typename ContainedItem2_ = NoType<2>,
+ typename ContainedItem3_ = NoType<3>,
+ typename ContainedItem4_ = NoType<4>,
+ typename ContainedItem5_ = NoType<5>,
+ typename ContainedItem6_ = NoType<6>,
+ typename ContainedItem7_ = NoType<7>,
+ typename ContainedItem8_ = NoType<8>,
+ typename ContainedItem9_ = NoType<9>,
+ typename ContainedItem10_ = NoType<10>,
+ typename ContainedItem11_ = NoType<11>,
+ typename ContainedItem12_ = NoType<12>,
+ typename ContainedItem13_ = NoType<13>,
+ typename ContainedItem14_ = NoType<14>,
+ typename ContainedItem15_ = NoType<15>,
+ typename ContainedItem16_ = NoType<16>,
+ typename ContainedItem17_ = NoType<17>,
+ typename ContainedItem18_ = NoType<18>,
+ typename ContainedItem19_ = NoType<19>,
+ typename ContainedItem20_ = NoType<20> >
class VisitorTypes;
template <typename I_>
diff --git a/paludis/util/visitor.hh b/paludis/util/visitor.hh
index 7c15371..f73f55e 100644
--- a/paludis/util/visitor.hh
+++ b/paludis/util/visitor.hh
@@ -1218,7 +1218,7 @@ namespace paludis
* \nosubgrouping
*/
template <typename I_, typename H_, unsigned u_>
- struct PALUDIS_VISIBLE GetConstItemVisits<I_, H_, const visitor_internals::NoType<u_> >
+ struct PALUDIS_VISIBLE GetConstItemVisits<I_, H_, const NoType<u_> >
{
};
diff --git a/python/additional_tests.cc b/python/additional_tests.cc
index 109b7ef..decb0a2 100644
--- a/python/additional_tests.cc
+++ b/python/additional_tests.cc
@@ -29,6 +29,7 @@
#include <paludis/repositories/fake/fake_package_id.hh>
#include <paludis/mask.hh>
#include <paludis/hook.hh>
+#include <paludis/stringify_formatter-impl.hh>
using namespace paludis;
namespace bp = boost::python;
@@ -180,8 +181,9 @@ namespace metadata_key
{
test_metadata_key(m);
m.value();
- m.pretty_print();
- m.pretty_print_flat();
+ StringifyFormatter ff;
+ m.pretty_print(ff);
+ m.pretty_print_flat(ff);
}
}
diff --git a/python/metadata_key.cc b/python/metadata_key.cc
index c746990..c4d343e 100644
--- a/python/metadata_key.cc
+++ b/python/metadata_key.cc
@@ -22,8 +22,12 @@
#include <paludis/metadata_key.hh>
#include <paludis/name.hh>
+#include <paludis/formatter.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/sequence.hh>
using namespace paludis;
using namespace paludis::python;
@@ -286,6 +290,58 @@ struct MetadataSetKeyWrapper :
else
throw PythonMethodNotImplemented("MetadataSetKey", "value");
}
+
+ std::string pretty_print_flat(const Formatter<typename C_::value_type> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ Lock l(get_mutex());
+
+ /* todo: make an override */
+ return join(value()->begin(), value()->end(), " ");
+ }
+};
+
+template <>
+struct MetadataSetKeyWrapper<IUseFlagSet> :
+ MetadataSetKey<IUseFlagSet>,
+ bp::wrapper<MetadataSetKey<IUseFlagSet> >
+{
+ MetadataSetKeyWrapper(const std::string & r, const std::string & h, const MetadataKeyType t) :
+ MetadataSetKey<IUseFlagSet>(r, h, t)
+ {
+ }
+
+ virtual const tr1::shared_ptr<const IUseFlagSet> value() const
+ PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ Lock l(get_mutex());
+
+ if (bp::override f = this->get_override("value"))
+ return f();
+ else
+ throw PythonMethodNotImplemented("MetadataSetKey", "value");
+ }
+
+ std::string pretty_print_flat(const Formatter<IUseFlag> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ Lock l(get_mutex());
+
+ /* todo: make an override */
+ return join(value()->begin(), value()->end(), " ");
+ }
+
+ std::string pretty_print_flat_with_comparison(
+ const Environment * const,
+ const tr1::shared_ptr<const PackageID> &,
+ const Formatter<IUseFlag> &) const
+ PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ Lock l(get_mutex());
+
+ /* todo: make an override */
+ return join(value()->begin(), value()->end(), " ");
+ }
};
template <typename C_>
@@ -309,22 +365,24 @@ struct MetadataSpecTreeKeyWrapper :
throw PythonMethodNotImplemented("MetadataSpecTreeKey", "value");
}
- virtual std::string pretty_print() const
+ virtual std::string pretty_print(const typename C_::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result))
{
Lock l(get_mutex());
+ // todo: use the formatter
if (bp::override f = this->get_override("pretty_print"))
return f();
else
throw PythonMethodNotImplemented("MetadataSpecTreeKey", "pretty_print");
}
- virtual std::string pretty_print_flat() const
+ virtual std::string pretty_print_flat(const typename C_::Formatter &) const
PALUDIS_ATTRIBUTE((warn_unused_result))
{
Lock l(get_mutex());
+ // todo: use the formatter
if (bp::override f = this->get_override("pretty_print_flat"))
return f();
else
diff --git a/python/metadata_key_TEST.py b/python/metadata_key_TEST.py
index 663f0fc..69185a4 100755
--- a/python/metadata_key_TEST.py
+++ b/python/metadata_key_TEST.py
@@ -149,7 +149,7 @@ class TestCase_02_MetadataKeys_suclassing(unittest.TestCase):
MetadataIUseFlagIterableKey.__init__(self, "raw", "human", MetadataKeyType.NORMAL)
def value(self):
- return [IUseFlag("iuse", IUseFlagParseMode.PERMISSIVE)]
+ return [IUseFlag("iuse", IUseFlagParseMode.PERMISSIVE, -1)]
test_metadata_iuse_flag_set_key(TestKey())
diff --git a/python/name.cc b/python/name.cc
index e84aa33..3a209a0 100644
--- a/python/name.cc
+++ b/python/name.cc
@@ -249,9 +249,11 @@ void expose_name()
(
"IUseFlag",
"Represents an IUse flag.",
- bp::init<const std::string &, IUseFlagParseMode>("__init__(string, IUseFlagParseMode")
+ bp::init<const std::string &, IUseFlagParseMode, const std::string::size_type>(
+ "__init__(string, IUseFlagParseMode, Integer)")
)
- .def(bp::init<const UseFlagName &, const UseFlagState &>("__init__(UseFlagName, UseFlagState)"))
+ .def(bp::init<const UseFlagName &, const UseFlagState &, const std::string::size_type>(
+ "__init__(UseFlagName, UseFlagState, Integer)"))
.def_readwrite("flag", &IUseFlag::flag,
"[rw] UseFlagName"
@@ -261,6 +263,10 @@ void expose_name()
"[rw] UseFlagState"
)
+ .def_readwrite("prefix_delim_pos", &IUseFlag::prefix_delim_pos,
+ "[rw] Integer"
+ )
+
.def("__cmp__", &py_cmp<IUseFlag>)
.def(bp::self_ns::str(bp::self))
diff --git a/python/name_TEST.py b/python/name_TEST.py
index 285ea22..bc88447 100755
--- a/python/name_TEST.py
+++ b/python/name_TEST.py
@@ -33,8 +33,8 @@ class TestCase_Names(unittest.TestCase):
self.names["repo"] = RepositoryName("repo")
self.names["keyword"] = KeywordName("keyword")
self.names["set"] = SetName("set")
- IUseFlag("foo", IUseFlagParseMode.PERMISSIVE)
- IUseFlag("foo", UseFlagState.ENABLED)
+ IUseFlag("foo", IUseFlagParseMode.PERMISSIVE, -1)
+ IUseFlag("foo", UseFlagState.ENABLED, -1)
def test_2_create_error(self):
self.assertRaises(PackageNamePartError, PackageNamePart, ":bad")
@@ -56,11 +56,11 @@ class TestCase_Names(unittest.TestCase):
for (k, v) in self.names.items():
self.assertEqual(str(v), k)
- self.assertEqual(str(IUseFlag("foo", UseFlagState.ENABLED)), "+foo")
+ self.assertEqual(str(IUseFlag("foo", UseFlagState.ENABLED, -1)), "+foo")
def test_4_operators(self):
self.assert_(CategoryNamePart("cat-foo") + PackageNamePart("pkg") == QualifiedPackageName("cat-foo/pkg"))
- self.assert_(IUseFlag("foo", UseFlagState.ENABLED) == IUseFlag("+foo", IUseFlagParseMode.PERMISSIVE))
+ self.assert_(IUseFlag("foo", UseFlagState.ENABLED, -1) == IUseFlag("+foo", IUseFlagParseMode.PERMISSIVE, 2))
def test_5_data_members(self):
@@ -72,7 +72,7 @@ class TestCase_Names(unittest.TestCase):
self.assertEqual(str(qpn.category), "blah")
self.assertEqual(str(qpn.package), "bar")
- iuf = IUseFlag("foo", UseFlagState.ENABLED)
+ iuf = IUseFlag("foo", UseFlagState.ENABLED, -1)
iuf.flag = "blah"
iuf.state = UseFlagState.DISABLED
self.assertEqual(str(iuf), "-blah")
diff --git a/src/clients/contrarius/install.cc b/src/clients/contrarius/install.cc
index d187ba4..1bb51c0 100644
--- a/src/clients/contrarius/install.cc
+++ b/src/clients/contrarius/install.cc
@@ -2,6 +2,7 @@
/*
* Copyright (c) 2006 Danny van Dyk <kugelfang@gentoo.org>
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,7 +21,6 @@
#include "install.hh"
#include <src/output/colour.hh>
#include <src/output/console_install_task.hh>
-#include <src/output/licence.hh>
#include <iostream>
#include <limits>
diff --git a/src/clients/gtkpaludis/libgtkpaludis/Makefile.am b/src/clients/gtkpaludis/libgtkpaludis/Makefile.am
index f0e5adf..80a41c0 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/Makefile.am
+++ b/src/clients/gtkpaludis/libgtkpaludis/Makefile.am
@@ -11,6 +11,7 @@ libgtkpaludis_a_SOURCES = \
main_notebook_page.cc main_notebook_page.hh \
main_window.cc main_window.hh \
markup.cc markup.hh \
+ markup_formatter.cc markup_formatter.hh \
messages_page.cc messages_page.hh \
package_buttons.cc package_buttons.hh \
packages_filter.cc packages_filter.hh \
diff --git a/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc b/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc
new file mode 100644
index 0000000..486315f
--- /dev/null
+++ b/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.cc
@@ -0,0 +1,228 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#include "markup_formatter.hh"
+#include "markup.hh"
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/set.hh>
+#include <paludis/name.hh>
+
+using namespace gtkpaludis;
+using namespace paludis;
+
+std::string
+MarkupFormatter::format(const IUseFlag & f, const format::Plain &) const
+{
+ return markup_escape(stringify(f));
+}
+
+std::string
+MarkupFormatter::format(const IUseFlag & f, const format::Enabled &) const
+{
+ return markup_foreground("green", markup_escape(stringify(f.flag)));
+}
+
+std::string
+MarkupFormatter::format(const IUseFlag & f, const format::Disabled &) const
+{
+ return markup_foreground("red", markup_escape("-" + stringify(f.flag)));
+}
+
+std::string
+MarkupFormatter::format(const IUseFlag & f, const format::Forced &) const
+{
+ return markup_foreground("green", markup_escape("(" + stringify(f.flag) + ")"));
+}
+
+std::string
+MarkupFormatter::format(const IUseFlag & f, const format::Masked &) const
+{
+ return markup_foreground("red", markup_escape("(-" + stringify(f.flag) + ")"));
+}
+
+std::string
+MarkupFormatter::decorate(const IUseFlag &, const std::string & f, const format::Added &) const
+{
+ return f + "+";
+}
+
+std::string
+MarkupFormatter::decorate(const IUseFlag &, const std::string & f, const format::Changed &) const
+{
+ return f + "*";
+}
+
+std::string
+MarkupFormatter::format(const UseFlagName & f, const format::Plain &) const
+{
+ return markup_escape(stringify(f));
+}
+
+std::string
+MarkupFormatter::format(const UseFlagName & f, const format::Enabled &) const
+{
+ return markup_foreground("green", markup_escape(stringify(f)));
+}
+
+std::string
+MarkupFormatter::format(const UseFlagName & f, const format::Disabled &) const
+{
+ return markup_foreground("red", markup_escape(stringify(f)));
+}
+
+std::string
+MarkupFormatter::format(const UseFlagName & f, const format::Forced &) const
+{
+ return markup_foreground("green", markup_escape("(" + stringify(f) + ")"));
+}
+
+std::string
+MarkupFormatter::format(const UseFlagName & f, const format::Masked &) const
+{
+ return markup_foreground("red", markup_escape("(" + stringify(f) + ")"));
+}
+
+std::string
+MarkupFormatter::format(const UseDepSpec & f, const format::Plain &) const
+{
+ return markup_escape(stringify(f));
+}
+
+std::string
+MarkupFormatter::format(const UseDepSpec & f, const format::Enabled &) const
+{
+ return markup_foreground("green", markup_escape(stringify(f)));
+}
+
+std::string
+MarkupFormatter::format(const UseDepSpec & f, const format::Disabled &) const
+{
+ return markup_foreground("red", markup_escape(stringify(f)));
+}
+
+std::string
+MarkupFormatter::format(const UseDepSpec & f, const format::Forced &) const
+{
+ return markup_foreground("green", markup_escape("(" + stringify(f) + ")"));
+}
+
+std::string
+MarkupFormatter::format(const UseDepSpec & f, const format::Masked &) const
+{
+ return markup_foreground("red", markup_escape("(" + stringify(f) + ")"));
+}
+
+std::string
+MarkupFormatter::format(const PackageDepSpec & f, const format::Plain &) const
+{
+ return markup_escape(stringify(f));
+}
+
+std::string
+MarkupFormatter::format(const PackageDepSpec & f, const format::Installed &) const
+{
+ return markup_foreground("blue", markup_escape(stringify(f)));
+}
+
+std::string
+MarkupFormatter::format(const PackageDepSpec & f, const format::Installable &) const
+{
+ return markup_foreground("darkblue", markup_escape(stringify(f)));
+}
+
+std::string
+MarkupFormatter::format(const PlainTextDepSpec & f, const format::Plain &) const
+{
+ return markup_escape(stringify(f));
+}
+
+std::string
+MarkupFormatter::format(const PlainTextDepSpec & f, const format::Accepted &) const
+{
+ return markup_foreground("green", markup_escape(stringify(f)));
+}
+
+std::string
+MarkupFormatter::format(const PlainTextDepSpec & f, const format::Unaccepted &) const
+{
+ return markup_foreground("red", markup_escape(stringify(f)));
+}
+
+std::string
+MarkupFormatter::format(const KeywordName & f, const format::Plain &) const
+{
+ return markup_escape(stringify(f));
+}
+
+std::string
+MarkupFormatter::format(const KeywordName & f, const format::Accepted &) const
+{
+ return markup_foreground("green", markup_escape(stringify(f)));
+}
+
+std::string
+MarkupFormatter::format(const KeywordName & f, const format::Unaccepted &) const
+{
+ return markup_foreground("red", markup_escape(stringify(f)));
+}
+
+std::string
+MarkupFormatter::format(const std::string & f, const format::Plain &) const
+{
+ return markup_escape(stringify(f));
+}
+
+std::string
+MarkupFormatter::format(const LabelsDepSpec<URILabelVisitorTypes> & f, const format::Plain &) const
+{
+ return markup_escape(stringify(f));
+}
+
+std::string
+MarkupFormatter::format(const LabelsDepSpec<DependencyLabelVisitorTypes> & f, const format::Plain &) const
+{
+ return markup_escape(stringify(f));
+}
+
+std::string
+MarkupFormatter::format(const URIDepSpec & f, const format::Plain &) const
+{
+ return markup_escape(stringify(f));
+}
+
+std::string
+MarkupFormatter::format(const BlockDepSpec & f, const format::Plain &) const
+{
+ return markup_escape(stringify(f));
+}
+
+std::string
+MarkupFormatter::format(const tr1::shared_ptr<const PackageID> & f, const format::Plain &) const
+{
+ return markup_escape(stringify(*f));
+}
+
+std::string
+MarkupFormatter::format(const tr1::shared_ptr<const PackageID> & f, const format::Installed &) const
+{
+ return markup_foreground("blue", markup_escape(stringify(*f)));
+}
+
+std::string
+MarkupFormatter::format(const tr1::shared_ptr<const PackageID> & f, const format::Installable &) const
+{
+ return markup_foreground("darkblue", markup_escape(stringify(*f)));
+}
+
+std::string
+MarkupFormatter::newline() const
+{
+ return "\n";
+}
+
+std::string
+MarkupFormatter::indent(const int i) const
+{
+ return std::string(4 * i, ' ');
+}
+
diff --git a/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh b/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh
new file mode 100644
index 0000000..edef0e5
--- /dev/null
+++ b/src/clients/gtkpaludis/libgtkpaludis/markup_formatter.hh
@@ -0,0 +1,79 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+#ifndef GTKPALUDIS_GUARD_LIBGTKPALUDIS_MARKUP_FORMATTER_HH
+#define GTKPALUDIS_GUARD_LIBGTKPALUDIS_MARKUP_FORMATTER_HH 1
+
+#include <paludis/formatter.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
+
+namespace gtkpaludis
+{
+ class MarkupFormatter :
+ public paludis::CanFormat<paludis::UseFlagName>,
+ public paludis::CanFormat<paludis::IUseFlag>,
+ public paludis::CanFormat<paludis::KeywordName>,
+ public paludis::CanFormat<paludis::UseDepSpec>,
+ public paludis::CanFormat<paludis::PackageDepSpec>,
+ public paludis::CanFormat<paludis::BlockDepSpec>,
+ public paludis::CanFormat<paludis::LabelsDepSpec<paludis::DependencyLabelVisitorTypes> >,
+ public paludis::CanFormat<paludis::LabelsDepSpec<paludis::URILabelVisitorTypes> >,
+ public paludis::CanFormat<paludis::PlainTextDepSpec>,
+ public paludis::CanFormat<paludis::URIDepSpec>,
+ public paludis::CanFormat<paludis::tr1::shared_ptr<const paludis::PackageID> >,
+ public paludis::CanFormat<std::string>,
+ public paludis::CanSpace
+ {
+ public:
+ std::string format(const paludis::IUseFlag &, const paludis::format::Plain &) const;
+ std::string format(const paludis::IUseFlag &, const paludis::format::Enabled &) const;
+ std::string format(const paludis::IUseFlag &, const paludis::format::Disabled &) const;
+ std::string format(const paludis::IUseFlag &, const paludis::format::Forced &) const;
+ std::string format(const paludis::IUseFlag &, const paludis::format::Masked &) const;
+ std::string decorate(const paludis::IUseFlag &, const std::string &, const paludis::format::Added &) const;
+ std::string decorate(const paludis::IUseFlag &, const std::string &, const paludis::format::Changed &) const;
+
+ std::string format(const paludis::UseFlagName &, const paludis::format::Plain &) const;
+ std::string format(const paludis::UseFlagName &, const paludis::format::Enabled &) const;
+ std::string format(const paludis::UseFlagName &, const paludis::format::Disabled &) const;
+ std::string format(const paludis::UseFlagName &, const paludis::format::Forced &) const;
+ std::string format(const paludis::UseFlagName &, const paludis::format::Masked &) const;
+
+ std::string format(const paludis::UseDepSpec &, const paludis::format::Plain &) const;
+ std::string format(const paludis::UseDepSpec &, const paludis::format::Enabled &) const;
+ std::string format(const paludis::UseDepSpec &, const paludis::format::Disabled &) const;
+ std::string format(const paludis::UseDepSpec &, const paludis::format::Forced &) const;
+ std::string format(const paludis::UseDepSpec &, const paludis::format::Masked &) const;
+
+ std::string format(const paludis::PackageDepSpec &, const paludis::format::Plain &) const;
+ std::string format(const paludis::PackageDepSpec &, const paludis::format::Installed &) const;
+ std::string format(const paludis::PackageDepSpec &, const paludis::format::Installable &) const;
+
+ std::string format(const paludis::PlainTextDepSpec &, const paludis::format::Plain &) const;
+ std::string format(const paludis::PlainTextDepSpec &, const paludis::format::Accepted &) const;
+ std::string format(const paludis::PlainTextDepSpec &, const paludis::format::Unaccepted &) const;
+
+ std::string format(const paludis::KeywordName &, const paludis::format::Plain &) const;
+ std::string format(const paludis::KeywordName &, const paludis::format::Accepted &) const;
+ std::string format(const paludis::KeywordName &, const paludis::format::Unaccepted &) const;
+
+ std::string format(const std::string &, const paludis::format::Plain &) const;
+
+ std::string format(const paludis::LabelsDepSpec<paludis::URILabelVisitorTypes> &, const paludis::format::Plain &) const;
+
+ std::string format(const paludis::LabelsDepSpec<paludis::DependencyLabelVisitorTypes> &, const paludis::format::Plain &) const;
+
+ std::string format(const paludis::URIDepSpec &, const paludis::format::Plain &) const;
+
+ std::string format(const paludis::BlockDepSpec &, const paludis::format::Plain &) const;
+
+ std::string format(const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::format::Plain &) const;
+ std::string format(const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::format::Installed &) const;
+ std::string format(const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::format::Installable &) const;
+
+ std::string newline() const;
+ std::string indent(const int) const;
+ };
+}
+
+#endif
diff --git a/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc b/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc
index fd83187..d0bb9ed 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc
@@ -4,14 +4,17 @@
#include "query_window.hh"
#include "versions_page.hh"
#include "markup.hh"
+#include "markup_formatter.hh"
#include <paludis/util/iterator.hh>
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/set.hh>
+#include <paludis/util/strip.hh>
#include <paludis/package_id.hh>
#include <paludis/environment.hh>
#include <paludis/package_database.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/query.hh>
+#include <paludis/mask.hh>
#include <paludis/metadata_key.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
@@ -95,39 +98,196 @@ VersionInfoModel::populate()
_imp->versions_page->get_id()), "Populating version information model");
}
-void
-VersionInfoModel::populate_in_paludis_thread(tr1::shared_ptr<const PackageID> p)
+namespace gtkpaludis
{
- tr1::shared_ptr<PopulateData> data(new PopulateData);
+ struct VersionInfoModel::MetadataPopulator :
+ ConstVisitor<MetadataKeyVisitorTypes>
+ {
+ MarkupFormatter formatter;
- if (p)
+ virtual void got_key(const MetadataKey & k, const std::string & s) = 0;
+
+ void visit(const MetadataSetKey<IUseFlagSet> & k)
+ {
+ got_key(k, k.pretty_print_flat(formatter));
+ }
+
+ void visit(const MetadataSetKey<Set<std::string> > & k)
+ {
+ got_key(k, k.pretty_print_flat(formatter));
+ }
+
+ void visit(const MetadataSetKey<UseFlagNameSet> & k)
+ {
+ got_key(k, k.pretty_print_flat(formatter));
+ }
+
+ void visit(const MetadataSetKey<KeywordNameSet> & k)
+ {
+ got_key(k, k.pretty_print_flat(formatter));
+ }
+
+ void visit(const MetadataSpecTreeKey<DependencySpecTree> & k)
+ {
+ got_key(k, k.pretty_print_flat(formatter));
+ }
+
+ void visit(const MetadataSpecTreeKey<URISpecTree> & k)
+ {
+ got_key(k, k.pretty_print_flat(formatter));
+ }
+
+ void visit(const MetadataSpecTreeKey<LicenseSpecTree> & k)
+ {
+ got_key(k, k.pretty_print_flat(formatter));
+ }
+
+ void visit(const MetadataSpecTreeKey<ProvideSpecTree> & k)
+ {
+ got_key(k, k.pretty_print_flat(formatter));
+ }
+
+ void visit(const MetadataSpecTreeKey<RestrictSpecTree> & k)
+ {
+ got_key(k, k.pretty_print_flat(formatter));
+ }
+
+ void visit(const MetadataSetKey<PackageIDSequence> & k)
+ {
+ got_key(k, k.pretty_print_flat(formatter));
+ }
+
+ void visit(const MetadataPackageIDKey & k)
+ {
+ got_key(k, markup_escape(stringify(*k.value())));
+ }
+
+ void visit(const MetadataStringKey & k)
+ {
+ got_key(k, markup_escape(stringify(k.value())));
+ }
+
+ void visit(const MetadataTimeKey & k)
+ {
+ char buf[255];
+ time_t t(k.value());
+ if (! strftime(buf, 254, "%c", gmtime(&t)))
+ buf[0] = '\0';
+
+ got_key(k, markup_escape(stringify(buf)));
+ }
+
+ void visit(const MetadataRepositoryMaskInfoKey & k)
+ {
+ if (! k.value())
+ return;
+
+ got_key(k, markup_escape(stringify(k.value()->mask_file) + ": " +
+ join(k.value()->comment->begin(), k.value()->comment->end(), " ")));
+ }
+
+ void visit(const MetadataFSEntryKey & k)
+ {
+ got_key(k, markup_escape(stringify(k.value())));
+ }
+
+ void visit(const MetadataContentsKey &)
+ {
+ }
+ };
+
+ struct VersionInfoModel::KeyMetadataPopulator :
+ VersionInfoModel::MetadataPopulator
{
- if (p->short_description_key())
- data->items.push_back(PopulateDataItem("Description", markup_escape(p->short_description_key()->value())));
+ tr1::shared_ptr<VersionInfoModel::PopulateData> data;
+ const MetadataKeyType type;
- if (p->homepage_key())
- data->items.push_back(PopulateDataItem("Homepage", markup_escape(p->homepage_key()->pretty_print_flat())));
+ KeyMetadataPopulator(const tr1::shared_ptr<VersionInfoModel::PopulateData> & d, const MetadataKeyType t) :
+ data(d),
+ type(t)
+ {
+ }
- if (p->keywords_key())
+ virtual void got_key(const MetadataKey & k, const std::string & s)
{
- std::string km;
- tr1::shared_ptr<const KeywordNameSet> keywords(p->keywords_key()->value());
- for (KeywordNameSet::Iterator k(keywords->begin()), k_end(keywords->end()) ;
- k != k_end ; ++k)
- {
- if (! km.empty())
- km.append(" ");
+ if (k.type() != type)
+ return;
- tr1::shared_ptr<KeywordNameSet> kc(new KeywordNameSet);
- kc->insert(*k);
- if (_imp->query_window->environment()->accept_keywords(kc, *p))
- km.append(markup_bold(markup_escape(stringify(*k))));
- else
- km.append(markup_italic(markup_escape(stringify(*k))));
- }
+ data->items.push_back(PopulateDataItem(k.human_name(), s));
+ }
+ };
- data->items.push_back(PopulateDataItem("Keywords", km));
+ struct VersionInfoModel::MaskMetadataPopulator :
+ VersionInfoModel::MetadataPopulator
+ {
+ std::string result;
+
+ virtual void got_key(const MetadataKey &, const std::string & s)
+ {
+ result = s;
+ }
+ };
+
+ struct VersionInfoModel::MaskPopulator :
+ ConstVisitor<MaskVisitorTypes>
+ {
+ tr1::shared_ptr<VersionInfoModel::PopulateData> data;
+
+ MaskPopulator(const tr1::shared_ptr<VersionInfoModel::PopulateData> & d) :
+ data(d)
+ {
+ }
+
+ void visit(const UserMask & k)
+ {
+ data->items.push_back(PopulateDataItem("Masked by " + strip_leading_string(k.description(), "by "),
+ markup_escape(k.description())));
}
+
+ void visit(const AssociationMask & k)
+ {
+ data->items.push_back(PopulateDataItem("Masked by " + strip_leading_string(k.description(), "by "),
+ markup_escape(stringify(*k.associated_package()))));
+ }
+
+ void visit(const UnsupportedMask & k)
+ {
+ data->items.push_back(PopulateDataItem("Masked by " + strip_leading_string(k.description(), "by "),
+ markup_escape(k.explanation())));
+ }
+
+ void visit(const RepositoryMask & k)
+ {
+ MaskMetadataPopulator p;
+ if (k.mask_key())
+ k.mask_key()->accept(p);
+ data->items.push_back(PopulateDataItem("Masked by " + strip_leading_string(k.description(), "by "), p.result));
+ }
+
+ void visit(const UnacceptedMask & k)
+ {
+ MaskMetadataPopulator p;
+ if (k.unaccepted_key())
+ k.unaccepted_key()->accept(p);
+ data->items.push_back(PopulateDataItem("Masked by " + strip_leading_string(k.description(), "by "), p.result));
+ }
+ };
+}
+
+void
+VersionInfoModel::populate_in_paludis_thread(tr1::shared_ptr<const PackageID> p)
+{
+ tr1::shared_ptr<PopulateData> data(new PopulateData);
+ if (p)
+ {
+ KeyMetadataPopulator mps(data, mkt_significant);
+ std::for_each(indirect_iterator(p->begin_metadata()), indirect_iterator(p->end_metadata()), accept_visitor(mps));
+
+ KeyMetadataPopulator mpn(data, mkt_normal);
+ std::for_each(indirect_iterator(p->begin_metadata()), indirect_iterator(p->end_metadata()), accept_visitor(mpn));
+
+ MaskPopulator mpm(data);
+ std::for_each(indirect_iterator(p->begin_masks()), indirect_iterator(p->end_masks()), accept_visitor(mpm));
}
_imp->query_window->gui_thread_action(
@@ -148,4 +308,3 @@ VersionInfoModel::populate_in_gui_thread(tr1::shared_ptr<const VersionInfoModel:
}
}
-
diff --git a/src/clients/gtkpaludis/libgtkpaludis/version_info_model.hh b/src/clients/gtkpaludis/libgtkpaludis/version_info_model.hh
index 984b305..e65443c 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/version_info_model.hh
+++ b/src/clients/gtkpaludis/libgtkpaludis/version_info_model.hh
@@ -19,6 +19,10 @@ namespace gtkpaludis
public Gtk::TreeStore
{
protected:
+ class MetadataPopulator;
+ class KeyMetadataPopulator;
+ class MaskMetadataPopulator;
+ class MaskPopulator;
class PopulateData;
void populate_in_paludis_thread(paludis::tr1::shared_ptr<const paludis::PackageID>);
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index d8cb98b..78326e5 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -19,7 +19,6 @@
#include <src/output/colour.hh>
#include "install.hh"
-#include <src/output/licence.hh>
#include <src/output/console_install_task.hh>
#include <src/common_args/do_help.hh>
diff --git a/src/clients/paludis/query.cc b/src/clients/paludis/query.cc
index 118838d..148c4fc 100644
--- a/src/clients/paludis/query.cc
+++ b/src/clients/paludis/query.cc
@@ -19,8 +19,6 @@
#include <src/output/colour.hh>
#include "query.hh"
-#include <src/output/licence.hh>
-#include <src/output/use_flag_pretty_printer.hh>
#include <src/output/console_query_task.hh>
#include <functional>
#include <iomanip>
diff --git a/src/clients/paludis/report.cc b/src/clients/paludis/report.cc
index 61b4800..bfba935 100644
--- a/src/clients/paludis/report.cc
+++ b/src/clients/paludis/report.cc
@@ -19,6 +19,7 @@
#include "report.hh"
#include <src/output/colour.hh>
+#include <src/output/mask_displayer.hh>
#include <paludis/tasks/report_task.hh>
#include <paludis/mask.hh>
#include <paludis/package_id.hh>
@@ -40,26 +41,28 @@ namespace
private:
int _n_packages;
int _n_errors;
+ const Environment * const env;
public:
- OurReportTask(tr1::shared_ptr<Environment> env) :
- ReportTask(env.get()),
+ OurReportTask(tr1::shared_ptr<Environment> e) :
+ ReportTask(e.get()),
_n_packages(0),
- _n_errors(0)
+ _n_errors(0),
+ env(e.get())
{
}
virtual void on_report_all_pre();
virtual void on_report_check_package_pre(const QualifiedPackageName & p);
- virtual void on_report_package_success(const PackageID & id);
- virtual void on_report_package_failure_pre(const PackageID & id);
- virtual void on_report_package_is_masked(const PackageID & installed, const PackageID & origin);
- virtual void on_report_package_is_vulnerable_pre(const PackageID & id);
- virtual void on_report_package_is_vulnerable(const PackageID & id, const std::string & tag);
- virtual void on_report_package_is_vulnerable_post(const PackageID & id);
- virtual void on_report_package_is_missing(const PackageID & id, const RepositoryName & repo_name);
- virtual void on_report_package_is_unused(const PackageID & id);
- virtual void on_report_package_failure_post(const PackageID & id);
+ virtual void on_report_package_success(const tr1::shared_ptr<const PackageID> & id);
+ virtual void on_report_package_failure_pre(const tr1::shared_ptr<const PackageID> & id);
+ virtual void on_report_package_is_masked(const tr1::shared_ptr<const PackageID> & id, const tr1::shared_ptr<const PackageID> & origin);
+ virtual void on_report_package_is_vulnerable_pre(const tr1::shared_ptr<const PackageID> & id);
+ virtual void on_report_package_is_vulnerable(const tr1::shared_ptr<const PackageID> & id, const std::string & tag);
+ virtual void on_report_package_is_vulnerable_post(const tr1::shared_ptr<const PackageID> & id);
+ virtual void on_report_package_is_missing(const tr1::shared_ptr<const PackageID> & id, const RepositoryName & repo_name);
+ virtual void on_report_package_is_unused(const tr1::shared_ptr<const PackageID> & id);
+ virtual void on_report_package_failure_post(const tr1::shared_ptr<const PackageID> & id);
virtual void on_report_check_package_post(const QualifiedPackageName & p);
virtual void on_report_all_post();
@@ -81,68 +84,74 @@ namespace
}
void
- OurReportTask::on_report_package_success(const PackageID &)
+ OurReportTask::on_report_package_success(const tr1::shared_ptr<const PackageID> &)
{
}
void
- OurReportTask::on_report_package_failure_pre(const PackageID & pde)
+ OurReportTask::on_report_package_failure_pre(const tr1::shared_ptr<const PackageID> & pde)
{
- cout << "* " << colour(cl_package_name, pde) << " NOT OK";
+ cout << "* " << colour(cl_package_name, *pde) << " NOT OK";
}
void
- OurReportTask::on_report_package_is_masked(const PackageID &, const PackageID & origin)
+ OurReportTask::on_report_package_is_masked(const tr1::shared_ptr<const PackageID> & id,
+ const tr1::shared_ptr<const PackageID> & origin)
{
cout << endl << " Masked by: ";
bool comma(false);
- for (PackageID::MasksIterator m(origin.begin_masks()), m_end(origin.end_masks()) ;
+ for (PackageID::MasksIterator m(origin->begin_masks()), m_end(origin->end_masks()) ;
m != m_end ; ++m)
{
if (comma)
cout << ", ";
- cout << colour(cl_masked, (*m)->description());
+
+ MaskDisplayer d(env, id, true);
+ (*m)->accept(d);
+ cout << d.result();
+
comma = true;
}
- cout << " in its original repository '" << origin.repository()->name() << "'";
+ cout << " in its original repository '" << origin->repository()->name() << "'";
++_n_errors;
}
void
- OurReportTask::on_report_package_is_vulnerable_pre(const PackageID &)
+ OurReportTask::on_report_package_is_vulnerable_pre(const tr1::shared_ptr<const PackageID> &)
{
cout << endl << " Affected by:";
}
void
- OurReportTask::on_report_package_is_vulnerable(const PackageID &, const std::string & tag)
+ OurReportTask::on_report_package_is_vulnerable(const tr1::shared_ptr<const PackageID> &, const std::string & tag)
{
cout << " " << colour(cl_tag, tag);
++_n_errors;
}
void
- OurReportTask::on_report_package_is_vulnerable_post(const PackageID &)
+ OurReportTask::on_report_package_is_vulnerable_post(const tr1::shared_ptr<const PackageID> &)
{
}
void
- OurReportTask::on_report_package_is_missing(const PackageID &, const RepositoryName & repo_name)
+ OurReportTask::on_report_package_is_missing(const tr1::shared_ptr<const PackageID> &,
+ const RepositoryName & repo_name)
{
cout << endl << " No longer exists in its original repository '" << repo_name << "'";
++_n_errors;
}
void
- OurReportTask::on_report_package_is_unused(const PackageID &)
+ OurReportTask::on_report_package_is_unused(const tr1::shared_ptr<const PackageID> &)
{
cout << endl << " Not used by any package in world";
++_n_errors;
}
void
- OurReportTask::on_report_package_failure_post(const PackageID &)
+ OurReportTask::on_report_package_failure_post(const tr1::shared_ptr<const PackageID> &)
{
cout << endl << endl;
}
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index 4760d19..03115a0 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -28,6 +28,7 @@
#include <paludis/util/virtual_constructor-impl.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/stringify_formatter.hh>
#include <paludis/environments/no_config/no_config_environment.hh>
#include <cstdlib>
@@ -59,6 +60,7 @@ namespace
ConstVisitor<MetadataKeyVisitorTypes>
{
std::ostringstream stream;
+ StringifyFormatter formatter;
void visit(const MetadataSetKey<IUseFlagSet> & k)
{
@@ -82,27 +84,27 @@ namespace
void visit(const MetadataSpecTreeKey<DependencySpecTree> & k)
{
- stream << k.raw_name() << ": " << k.pretty_print_flat();
+ stream << k.raw_name() << ": " << k.pretty_print_flat(formatter);
}
void visit(const MetadataSpecTreeKey<URISpecTree> & k)
{
- stream << k.raw_name() << ": " << k.pretty_print_flat();
+ stream << k.raw_name() << ": " << k.pretty_print_flat(formatter);
}
void visit(const MetadataSpecTreeKey<LicenseSpecTree> & k)
{
- stream << k.raw_name() << ": " << k.pretty_print_flat();
+ stream << k.raw_name() << ": " << k.pretty_print_flat(formatter);
}
void visit(const MetadataSpecTreeKey<ProvideSpecTree> & k)
{
- stream << k.raw_name() << ": " << k.pretty_print_flat();
+ stream << k.raw_name() << ": " << k.pretty_print_flat(formatter);
}
void visit(const MetadataSpecTreeKey<RestrictSpecTree> & k)
{
- stream << k.raw_name() << ": " << k.pretty_print_flat();
+ stream << k.raw_name() << ": " << k.pretty_print_flat(formatter);
}
void visit(const MetadataSetKey<PackageIDSequence> & k)
diff --git a/src/output/Makefile.am b/src/output/Makefile.am
index 03fe536..c3efa06 100644
--- a/src/output/Makefile.am
+++ b/src/output/Makefile.am
@@ -7,11 +7,11 @@ BUILT_SOURCES = console_install_task-sr.hh console_install_task-sr.cc
noinst_LIBRARIES = liboutput.a
liboutput_a_SOURCES = \
colour.cc colour.hh \
+ colour_formatter.cc colour_formatter.hh \
console_task.cc console_task.hh \
console_install_task.cc console_install_task.hh \
console_query_task.cc console_query_task.hh \
- use_flag_pretty_printer.cc use_flag_pretty_printer.hh \
- licence.cc licence.hh
+ mask_displayer.cc mask_displayer.hh
AM_CXXFLAGS = -I$(top_srcdir) -I$(top_srcdir)/src @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_VISIBILITY@
diff --git a/src/output/colour.hh b/src/output/colour.hh
index c6b8e41..e2d9814 100644
--- a/src/output/colour.hh
+++ b/src/output/colour.hh
@@ -42,6 +42,7 @@ enum Colour
#if PALUDIS_COLOUR_PINK==1
cl_package_name = cl_bold_pink,
+ cl_installable_package_name = cl_pink,
cl_repository_name = cl_pink,
cl_flag_on = cl_pink,
cl_flag_off = cl_red,
@@ -55,6 +56,7 @@ enum Colour
cl_key_name = cl_pink,
#else
cl_package_name = cl_bold_blue,
+ cl_installable_package_name = cl_blue,
cl_repository_name = cl_blue,
cl_flag_on = cl_green,
cl_flag_off = cl_red,
diff --git a/src/output/colour_formatter.cc b/src/output/colour_formatter.cc
new file mode 100644
index 0000000..433b665
--- /dev/null
+++ b/src/output/colour_formatter.cc
@@ -0,0 +1,386 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "colour_formatter.hh"
+#include "colour.hh"
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/set.hh>
+#include <paludis/name.hh>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<ColourFormatter>
+ {
+ mutable std::string active_prefix;
+
+ const tr1::shared_ptr<UseFlagNameSet> seen_new_use_flag_names;
+ const tr1::shared_ptr<UseFlagNameSet> seen_changed_use_flag_names;
+ const tr1::shared_ptr<UseFlagNameSet> seen_use_flag_names;
+ const tr1::shared_ptr<UseFlagNameSet> seen_use_expand_prefixes;
+
+ Implementation() :
+ seen_new_use_flag_names(new UseFlagNameSet),
+ seen_changed_use_flag_names(new UseFlagNameSet),
+ seen_use_flag_names(new UseFlagNameSet),
+ seen_use_expand_prefixes(new UseFlagNameSet)
+ {
+ }
+ };
+}
+
+ColourFormatter::ColourFormatter() :
+ PrivateImplementationPattern<ColourFormatter>(new Implementation<ColourFormatter>)
+{
+}
+
+ColourFormatter::~ColourFormatter()
+{
+}
+
+const tr1::shared_ptr<const UseFlagNameSet>
+ColourFormatter::seen_new_use_flag_names() const
+{
+ return _imp->seen_new_use_flag_names;
+}
+
+const tr1::shared_ptr<const UseFlagNameSet>
+ColourFormatter::seen_changed_use_flag_names() const
+{
+ return _imp->seen_changed_use_flag_names;
+}
+
+const tr1::shared_ptr<const UseFlagNameSet>
+ColourFormatter::seen_use_flag_names() const
+{
+ return _imp->seen_use_flag_names;
+}
+
+const tr1::shared_ptr<const UseFlagNameSet>
+ColourFormatter::seen_use_expand_prefixes() const
+{
+ return _imp->seen_use_expand_prefixes;
+}
+
+std::string
+ColourFormatter::format(const IUseFlag & f, const format::Plain &) const
+{
+ _imp->seen_use_flag_names->insert(f.flag);
+ std::string g(stringify(f.flag)), h;
+
+ if (std::string::npos != f.prefix_delim_pos)
+ {
+ std::string p(g.substr(0, f.prefix_delim_pos));
+ if (_imp->active_prefix == p)
+ g.erase(0, f.prefix_delim_pos + 1);
+ else
+ {
+ _imp->active_prefix = p;
+ _imp->seen_use_expand_prefixes->insert(UseFlagName(_imp->active_prefix));
+ h = _imp->active_prefix + ": ";
+ g.erase(0, f.prefix_delim_pos + 1);
+ }
+ }
+
+ return h + g;
+}
+
+std::string
+ColourFormatter::format(const IUseFlag & f, const format::Enabled &) const
+{
+ _imp->seen_use_flag_names->insert(f.flag);
+ std::string g(stringify(f.flag)), h;
+
+ if (std::string::npos != f.prefix_delim_pos)
+ {
+ std::string p(g.substr(0, f.prefix_delim_pos));
+ if (_imp->active_prefix == p)
+ g.erase(0, f.prefix_delim_pos + 1);
+ else
+ {
+ _imp->active_prefix = p;
+ _imp->seen_use_expand_prefixes->insert(UseFlagName(_imp->active_prefix));
+ h = _imp->active_prefix + ": ";
+ g.erase(0, f.prefix_delim_pos + 1);
+ }
+ }
+
+ return h + colour(cl_flag_on, g);
+}
+
+std::string
+ColourFormatter::format(const IUseFlag & f, const format::Disabled &) const
+{
+ _imp->seen_use_flag_names->insert(f.flag);
+ std::string g(stringify(f.flag)), h;
+
+ if (std::string::npos != f.prefix_delim_pos)
+ {
+ std::string p(g.substr(0, f.prefix_delim_pos));
+ if (_imp->active_prefix == p)
+ g.erase(0, f.prefix_delim_pos + 1);
+ else
+ {
+ _imp->active_prefix = p;
+ _imp->seen_use_expand_prefixes->insert(UseFlagName(_imp->active_prefix));
+ h = _imp->active_prefix + ": ";
+ g.erase(0, f.prefix_delim_pos + 1);
+ }
+ }
+
+ return h + colour(cl_flag_off, g);
+}
+
+std::string
+ColourFormatter::format(const IUseFlag & f, const format::Forced &) const
+{
+ _imp->seen_use_flag_names->insert(f.flag);
+ std::string g(stringify(f.flag)), h;
+
+ if (std::string::npos != f.prefix_delim_pos)
+ {
+ std::string p(g.substr(0, f.prefix_delim_pos));
+ if (_imp->active_prefix == p)
+ g.erase(0, f.prefix_delim_pos + 1);
+ else
+ {
+ _imp->active_prefix = p;
+ _imp->seen_use_expand_prefixes->insert(UseFlagName(_imp->active_prefix));
+ h = _imp->active_prefix + ": ";
+ g.erase(0, f.prefix_delim_pos + 1);
+ }
+ }
+
+ return h + colour(cl_flag_on, "(" + g + ")");
+}
+
+std::string
+ColourFormatter::format(const IUseFlag & f, const format::Masked &) const
+{
+ _imp->seen_use_flag_names->insert(f.flag);
+ std::string g(stringify(f.flag)), h;
+
+ if (std::string::npos != f.prefix_delim_pos)
+ {
+ std::string p(g.substr(0, f.prefix_delim_pos));
+ if (_imp->active_prefix == p)
+ g.erase(0, f.prefix_delim_pos + 1);
+ else
+ {
+ _imp->active_prefix = p;
+ _imp->seen_use_expand_prefixes->insert(UseFlagName(_imp->active_prefix));
+ h = _imp->active_prefix + ": ";
+ g.erase(0, f.prefix_delim_pos + 1);
+ }
+ }
+
+ return h + colour(cl_flag_off, "(" + g + ")");
+}
+
+std::string
+ColourFormatter::decorate(const IUseFlag & i, const std::string & f, const format::Added &) const
+{
+ _imp->seen_new_use_flag_names->insert(i.flag);
+ return f + "+";
+}
+
+std::string
+ColourFormatter::decorate(const IUseFlag & i, const std::string & f, const format::Changed &) const
+{
+ _imp->seen_changed_use_flag_names->insert(i.flag);
+ return f + "*";
+}
+
+std::string
+ColourFormatter::format(const UseFlagName & f, const format::Plain &) const
+{
+ return stringify(f);
+}
+
+std::string
+ColourFormatter::format(const UseFlagName & f, const format::Enabled &) const
+{
+ return colour(cl_flag_on, f);
+}
+
+std::string
+ColourFormatter::format(const UseFlagName & f, const format::Disabled &) const
+{
+ return colour(cl_flag_off, f);
+}
+
+std::string
+ColourFormatter::format(const UseFlagName & f, const format::Forced &) const
+{
+ return colour(cl_flag_on, "(" + stringify(f) + ")");
+}
+
+std::string
+ColourFormatter::format(const UseFlagName & f, const format::Masked &) const
+{
+ return colour(cl_flag_off, "(" + stringify(f) + ")");
+}
+
+std::string
+ColourFormatter::format(const UseDepSpec & f, const format::Plain &) const
+{
+ return stringify(f);
+}
+
+std::string
+ColourFormatter::format(const UseDepSpec & f, const format::Enabled &) const
+{
+ return colour(cl_flag_on, f);
+}
+
+std::string
+ColourFormatter::format(const UseDepSpec & f, const format::Disabled &) const
+{
+ return colour(cl_flag_off, f);
+}
+
+std::string
+ColourFormatter::format(const UseDepSpec & f, const format::Forced &) const
+{
+ return colour(cl_flag_on, "(" + stringify(f) + ")");
+}
+
+std::string
+ColourFormatter::format(const UseDepSpec & f, const format::Masked &) const
+{
+ return colour(cl_flag_off, "(" + stringify(f) + ")");
+}
+
+std::string
+ColourFormatter::format(const PackageDepSpec & f, const format::Plain &) const
+{
+ return stringify(f);
+}
+
+std::string
+ColourFormatter::format(const PackageDepSpec & f, const format::Installed &) const
+{
+ return colour(cl_package_name, f);
+}
+
+std::string
+ColourFormatter::format(const PackageDepSpec & f, const format::Installable &) const
+{
+ return colour(cl_installable_package_name, f);
+}
+
+std::string
+ColourFormatter::format(const PlainTextDepSpec & f, const format::Plain &) const
+{
+ return stringify(f);
+}
+
+std::string
+ColourFormatter::format(const PlainTextDepSpec & f, const format::Accepted &) const
+{
+ return colour(cl_flag_on, f);
+}
+
+std::string
+ColourFormatter::format(const PlainTextDepSpec & f, const format::Unaccepted &) const
+{
+ return colour(cl_flag_off, f);
+}
+
+std::string
+ColourFormatter::format(const KeywordName & f, const format::Plain &) const
+{
+ return stringify(f);
+}
+
+std::string
+ColourFormatter::format(const KeywordName & f, const format::Accepted &) const
+{
+ return colour(cl_flag_on, f);
+}
+
+std::string
+ColourFormatter::format(const KeywordName & f, const format::Unaccepted &) const
+{
+ return colour(cl_flag_off, f);
+}
+
+std::string
+ColourFormatter::format(const std::string & f, const format::Plain &) const
+{
+ return stringify(f);
+}
+
+std::string
+ColourFormatter::format(const LabelsDepSpec<URILabelVisitorTypes> & f, const format::Plain &) const
+{
+ return stringify(f);
+}
+
+std::string
+ColourFormatter::format(const LabelsDepSpec<DependencyLabelVisitorTypes> & f, const format::Plain &) const
+{
+ return stringify(f);
+}
+
+std::string
+ColourFormatter::format(const URIDepSpec & f, const format::Plain &) const
+{
+ return stringify(f);
+}
+
+std::string
+ColourFormatter::format(const BlockDepSpec & f, const format::Plain &) const
+{
+ return stringify(f);
+}
+
+std::string
+ColourFormatter::format(const tr1::shared_ptr<const PackageID> & f, const format::Plain &) const
+{
+ return stringify(*f);
+}
+
+std::string
+ColourFormatter::format(const tr1::shared_ptr<const PackageID> & f, const format::Installed &) const
+{
+ return colour(cl_package_name, *f);
+}
+
+std::string
+ColourFormatter::format(const tr1::shared_ptr<const PackageID> & f, const format::Installable &) const
+{
+ return colour(cl_installable_package_name, *f);
+}
+
+std::string
+ColourFormatter::newline() const
+{
+ return "\n";
+}
+
+std::string
+ColourFormatter::indent(const int i) const
+{
+ return std::string(4 * i, ' ');
+}
+
diff --git a/src/output/colour_formatter.hh b/src/output/colour_formatter.hh
new file mode 100644
index 0000000..3e62e8b
--- /dev/null
+++ b/src/output/colour_formatter.hh
@@ -0,0 +1,103 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_SRC_OUTPUT_COLOUR_FORMATTER_HH
+#define PALUDIS_GUARD_SRC_OUTPUT_COLOUR_FORMATTER_HH 1
+
+#include <paludis/formatter.hh>
+#include <paludis/name-fwd.hh>
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/util/private_implementation_pattern.hh>
+
+class ColourFormatter :
+ public paludis::CanFormat<paludis::UseFlagName>,
+ public paludis::CanFormat<paludis::IUseFlag>,
+ public paludis::CanFormat<paludis::KeywordName>,
+ public paludis::CanFormat<paludis::UseDepSpec>,
+ public paludis::CanFormat<paludis::PackageDepSpec>,
+ public paludis::CanFormat<paludis::BlockDepSpec>,
+ public paludis::CanFormat<paludis::LabelsDepSpec<paludis::DependencyLabelVisitorTypes> >,
+ public paludis::CanFormat<paludis::LabelsDepSpec<paludis::URILabelVisitorTypes> >,
+ public paludis::CanFormat<paludis::PlainTextDepSpec>,
+ public paludis::CanFormat<paludis::URIDepSpec>,
+ public paludis::CanFormat<paludis::tr1::shared_ptr<const paludis::PackageID> >,
+ public paludis::CanFormat<std::string>,
+ public paludis::CanSpace,
+ private paludis::PrivateImplementationPattern<ColourFormatter>
+{
+ public:
+ ColourFormatter();
+ ~ColourFormatter();
+
+ const paludis::tr1::shared_ptr<const paludis::UseFlagNameSet> seen_new_use_flag_names() const;
+ const paludis::tr1::shared_ptr<const paludis::UseFlagNameSet> seen_changed_use_flag_names() const;
+ const paludis::tr1::shared_ptr<const paludis::UseFlagNameSet> seen_use_flag_names() const;
+ const paludis::tr1::shared_ptr<const paludis::UseFlagNameSet> seen_use_expand_prefixes() const;
+
+ std::string format(const paludis::IUseFlag &, const paludis::format::Plain &) const;
+ std::string format(const paludis::IUseFlag &, const paludis::format::Enabled &) const;
+ std::string format(const paludis::IUseFlag &, const paludis::format::Disabled &) const;
+ std::string format(const paludis::IUseFlag &, const paludis::format::Forced &) const;
+ std::string format(const paludis::IUseFlag &, const paludis::format::Masked &) const;
+ std::string decorate(const paludis::IUseFlag &, const std::string &, const paludis::format::Added &) const;
+ std::string decorate(const paludis::IUseFlag &, const std::string &, const paludis::format::Changed &) const;
+
+ std::string format(const paludis::UseFlagName &, const paludis::format::Plain &) const;
+ std::string format(const paludis::UseFlagName &, const paludis::format::Enabled &) const;
+ std::string format(const paludis::UseFlagName &, const paludis::format::Disabled &) const;
+ std::string format(const paludis::UseFlagName &, const paludis::format::Forced &) const;
+ std::string format(const paludis::UseFlagName &, const paludis::format::Masked &) const;
+
+ std::string format(const paludis::UseDepSpec &, const paludis::format::Plain &) const;
+ std::string format(const paludis::UseDepSpec &, const paludis::format::Enabled &) const;
+ std::string format(const paludis::UseDepSpec &, const paludis::format::Disabled &) const;
+ std::string format(const paludis::UseDepSpec &, const paludis::format::Forced &) const;
+ std::string format(const paludis::UseDepSpec &, const paludis::format::Masked &) const;
+
+ std::string format(const paludis::PackageDepSpec &, const paludis::format::Plain &) const;
+ std::string format(const paludis::PackageDepSpec &, const paludis::format::Installed &) const;
+ std::string format(const paludis::PackageDepSpec &, const paludis::format::Installable &) const;
+
+ std::string format(const paludis::PlainTextDepSpec &, const paludis::format::Plain &) const;
+ std::string format(const paludis::PlainTextDepSpec &, const paludis::format::Accepted &) const;
+ std::string format(const paludis::PlainTextDepSpec &, const paludis::format::Unaccepted &) const;
+
+ std::string format(const paludis::KeywordName &, const paludis::format::Plain &) const;
+ std::string format(const paludis::KeywordName &, const paludis::format::Accepted &) const;
+ std::string format(const paludis::KeywordName &, const paludis::format::Unaccepted &) const;
+
+ std::string format(const std::string &, const paludis::format::Plain &) const;
+
+ std::string format(const paludis::LabelsDepSpec<paludis::URILabelVisitorTypes> &, const paludis::format::Plain &) const;
+
+ std::string format(const paludis::LabelsDepSpec<paludis::DependencyLabelVisitorTypes> &, const paludis::format::Plain &) const;
+
+ std::string format(const paludis::URIDepSpec &, const paludis::format::Plain &) const;
+
+ std::string format(const paludis::BlockDepSpec &, const paludis::format::Plain &) const;
+
+ std::string format(const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::format::Plain &) const;
+ std::string format(const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::format::Installed &) const;
+ std::string format(const paludis::tr1::shared_ptr<const paludis::PackageID> &, const paludis::format::Installable &) const;
+
+ std::string newline() const;
+ std::string indent(const int) const;
+};
+
+#endif
diff --git a/src/output/console_install_task.cc b/src/output/console_install_task.cc
index 27f506b..ede4380 100644
--- a/src/output/console_install_task.cc
+++ b/src/output/console_install_task.cc
@@ -19,8 +19,8 @@
#include "console_install_task.hh"
#include "colour.hh"
-#include "use_flag_pretty_printer.hh"
-#include "licence.hh"
+#include "colour_formatter.hh"
+#include "mask_displayer.hh"
#include <paludis/util/log.hh>
#include <paludis/util/sr.hh>
@@ -532,7 +532,7 @@ ConsoleInstallTask::display_merge_list_post_use_descriptions(const std::string &
continue;
break;
- case uds_unchanged:
+ case uds_all:
if (! want_unchanged_use_flags())
continue;
break;
@@ -939,11 +939,23 @@ ConsoleInstallTask::_add_descriptions(tr1::shared_ptr<const UseFlagNameSet> c,
if (i)
d = i->describe_use_flag(*f, *p);
- _all_use_descriptions->insert(UseDescription::create()
+ UseDescription e(UseDescription::create()
.flag(*f)
.state(s)
.package_id(p)
.description(d));
+
+ Set<UseDescription, UseDescriptionComparator>::Iterator x(_all_use_descriptions->find(e));
+ if (_all_use_descriptions->end() == x)
+ _all_use_descriptions->insert(e);
+ else
+ {
+ if (x->state < e.state)
+ {
+ _all_use_descriptions->erase(e);
+ _all_use_descriptions->insert(e);
+ }
+ }
}
}
@@ -957,25 +969,27 @@ ConsoleInstallTask::display_merge_list_entry_use(const DepListEntry & d,
return;
output_no_endl(" ");
- tr1::shared_ptr<UseFlagPrettyPrinter> printer(make_use_flag_pretty_printer());
- tr1::shared_ptr<const PackageID> old_id;
- tr1::shared_ptr<const IUseFlagSet> old;
+ ColourFormatter formatter;
+ tr1::shared_ptr<const PackageID> old_id;
if (! existing_slot_repo->empty())
old_id = *existing_slot_repo->last();
else if (! existing_repo->empty())
old_id = *existing_repo->last();
- if (old_id && old_id->iuse_key())
- old = old_id->iuse_key()->value();
-
if (d.package_id->iuse_key())
- printer->print_package_flags(d.package_id, d.package_id->iuse_key()->value(), old_id, old);
+ {
+ if (old_id)
+ output_stream() << d.package_id->iuse_key()->pretty_print_flat_with_comparison(environment(), old_id, formatter);
+ else
+ output_stream() << d.package_id->iuse_key()->pretty_print_flat(formatter);
+ }
- _add_descriptions(printer->new_flags(), d.package_id, uds_new);
- _add_descriptions(printer->changed_flags(), d.package_id, uds_changed);
- _add_descriptions(printer->unchanged_flags(), d.package_id, uds_unchanged);
- std::copy(printer->expand_prefixes()->begin(), printer->expand_prefixes()->end(), _all_expand_prefixes->inserter());
+ _add_descriptions(formatter.seen_new_use_flag_names(), d.package_id, uds_new);
+ _add_descriptions(formatter.seen_changed_use_flag_names(), d.package_id, uds_changed);
+ _add_descriptions(formatter.seen_use_flag_names(), d.package_id, uds_all);
+ std::copy(formatter.seen_use_expand_prefixes()->begin(), formatter.seen_use_expand_prefixes()->end(),
+ _all_expand_prefixes->inserter());
}
void
@@ -1107,12 +1121,6 @@ ConsoleInstallTask::make_entry_dep_tag_displayer()
return tr1::shared_ptr<EntryDepTagDisplayer>(new EntryDepTagDisplayer());
}
-tr1::shared_ptr<UseFlagPrettyPrinter>
-ConsoleInstallTask::make_use_flag_pretty_printer()
-{
- return tr1::shared_ptr<UseFlagPrettyPrinter>(new UseFlagPrettyPrinter(environment()));
-}
-
EntryDepTagDisplayer::EntryDepTagDisplayer()
{
}
@@ -1143,40 +1151,6 @@ EntryDepTagDisplayer::visit(const GeneralSetDepTag & tag)
text() = tag.short_text(); // + "<" + tag->source() + ">";
}
-namespace
-{
- struct MaskDisplayer :
- ConstVisitor<MaskVisitorTypes>
- {
- std::ostringstream s;
-
- void visit(const UnacceptedMask & m)
- {
- s << m.description();
- }
-
- void visit(const RepositoryMask & m)
- {
- s << m.description();
- }
-
- void visit(const UserMask & m)
- {
- s << m.description();
- }
-
- void visit(const UnsupportedMask & m)
- {
- s << m.description();
- }
-
- void visit(const AssociationMask & m)
- {
- s << m.description();
- }
- };
-}
-
void
ConsoleInstallTask::display_merge_list_entry_mask_reasons(const DepListEntry & e)
{
@@ -1188,9 +1162,9 @@ ConsoleInstallTask::display_merge_list_entry_mask_reasons(const DepListEntry & e
{
if (need_comma)
output_no_endl(", ");
- MaskDisplayer d;
+ MaskDisplayer d(environment(), e.package_id, true);
(*m)->accept(d);
- output_no_endl(d.s.str());
+ output_no_endl(d.result());
}
output_endl();
@@ -1307,7 +1281,10 @@ ConsoleInstallTask::on_all_masked_error(const AllMaskedError & e)
{
if (need_comma)
output_stream() << ", ";
- output_stream() << (*m)->description();
+
+ MaskDisplayer d(environment(), *pp, true);
+ (*m)->accept(d);
+ output_no_endl(d.result());
need_comma = true;
}
diff --git a/src/output/console_install_task.hh b/src/output/console_install_task.hh
index c90fa69..42e025b 100644
--- a/src/output/console_install_task.hh
+++ b/src/output/console_install_task.hh
@@ -23,7 +23,6 @@
#include <paludis/tasks/install_task.hh>
#include <paludis/util/set.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
-#include <src/output/use_flag_pretty_printer.hh>
#include <src/output/console_task.hh>
#include <iosfwd>
@@ -33,7 +32,7 @@ namespace paludis
enum UseDescriptionState
{
- uds_unchanged,
+ uds_all,
uds_changed,
uds_new
};
@@ -287,7 +286,6 @@ namespace paludis
tr1::shared_ptr<DepTagSummaryDisplayer> make_dep_tag_summary_displayer();
tr1::shared_ptr<EntryDepTagDisplayer> make_entry_dep_tag_displayer();
- tr1::shared_ptr<UseFlagPrettyPrinter> make_use_flag_pretty_printer();
///\}
};
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index 27b7e2d..6d3e601 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -18,8 +18,8 @@
*/
#include "console_query_task.hh"
-#include "licence.hh"
-#include "use_flag_pretty_printer.hh"
+#include "mask_displayer.hh"
+#include "colour_formatter.hh"
#include <paludis/util/visitor-impl.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/visitor-impl.hh>
@@ -28,6 +28,7 @@
#include <paludis/util/map.hh>
#include <paludis/util/map-impl.hh>
#include <paludis/util/join.hh>
+#include <paludis/util/strip.hh>
#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <libwrapiter/libwrapiter_output_iterator.hh>
#include <paludis/query.hh>
@@ -93,6 +94,7 @@ ConsoleQueryTask::show(const PackageDepSpec & a, tr1::shared_ptr<const PackageID
display_header(a, display_entry);
display_versions_by_repository(a, entries, display_entry);
display_metadata(a, display_entry);
+ display_masks(a, display_entry);
output_endl();
}
@@ -190,42 +192,90 @@ namespace
void visit(const MetadataSetKey<IUseFlagSet> & k)
{
if (k.type() == type)
- task->display_metadata_iuse(k.human_name(), k.raw_name(), join(k.value()->begin(), k.value()->end(), " "),
- id, k.value());
+ {
+ ColourFormatter formatter;
+ if (task->want_raw())
+ {
+ task->output_left_column(k.raw_name() + ":");
+ task->output_right_column(k.pretty_print_flat(formatter));
+ }
+ else
+ {
+ task->output_left_column(k.human_name() + ":");
+ task->output_right_column(k.pretty_print_flat(formatter));
+ }
+ }
}
void visit(const MetadataSetKey<Set<std::string> > & k)
{
if (k.type() == type)
- task->display_metadata_key(k.human_name(), k.raw_name(), join(k.value()->begin(), k.value()->end(), " "));
+ {
+ ColourFormatter formatter;
+ if (task->want_raw())
+ {
+ task->output_left_column(k.raw_name() + ":");
+ task->output_right_column(k.pretty_print_flat(formatter));
+ }
+ else
+ {
+ task->output_left_column(k.human_name() + ":");
+ task->output_right_column(k.pretty_print_flat(formatter));
+ }
+ }
}
void visit(const MetadataSetKey<UseFlagNameSet> & k)
{
if (k.type() == type)
- task->display_metadata_key(k.human_name(), k.raw_name(), join(k.value()->begin(), k.value()->end(), " "));
+ {
+ ColourFormatter formatter;
+ if (task->want_raw())
+ {
+ task->output_left_column(k.raw_name() + ":");
+ task->output_right_column(k.pretty_print_flat(formatter));
+ }
+ else
+ {
+ task->output_left_column(k.human_name() + ":");
+ task->output_right_column(k.pretty_print_flat(formatter));
+ }
+ }
}
void visit(const MetadataSetKey<KeywordNameSet> & k)
{
if (k.type() == type)
- task->display_metadata_key(k.human_name(), k.raw_name(), join(k.value()->begin(), k.value()->end(), " "));
+ {
+ ColourFormatter formatter;
+ if (task->want_raw())
+ {
+ task->output_left_column(k.raw_name() + ":");
+ task->output_right_column(k.pretty_print_flat(formatter));
+ }
+ else
+ {
+ task->output_left_column(k.human_name() + ":");
+ task->output_right_column(k.pretty_print_flat(formatter));
+ }
+ }
}
void visit(const MetadataSpecTreeKey<DependencySpecTree> & k)
{
if (k.type() == type)
{
+ ColourFormatter formatter;
if (task->want_raw())
{
task->output_left_column(k.raw_name() + ":");
- task->output_right_column(k.pretty_print_flat());
+ task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
task->output_left_column(k.human_name() + ":");
task->output_right_column("");
- task->output_stream() << k.pretty_print();
+ task->output_stream() << k.pretty_print(formatter);
task->output_endl();
}
}
@@ -235,15 +285,16 @@ namespace
{
if (k.type() == type)
{
+ ColourFormatter formatter;
if (task->want_raw())
{
task->output_left_column(k.raw_name() + ":");
- task->output_right_column(k.pretty_print_flat());
+ task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
task->output_left_column(k.human_name() + ":");
- task->output_stream() << k.pretty_print_flat();
+ task->output_stream() << k.pretty_print_flat(formatter);
task->output_right_column("");
}
}
@@ -253,17 +304,18 @@ namespace
{
if (k.type() == type)
{
+ ColourFormatter formatter;
if (task->want_raw())
{
task->output_left_column(k.raw_name() + ":");
- task->output_right_column(k.pretty_print_flat());
+ task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
task->output_left_column(k.human_name() + ":");
- LicenceDisplayer d(task->output_stream(), env, id);
- k.value()->accept(d);
task->output_right_column("");
+ task->output_stream() << k.pretty_print(formatter);
+ task->output_endl();
}
}
}
@@ -272,16 +324,17 @@ namespace
{
if (k.type() == type)
{
+ ColourFormatter formatter;
if (task->want_raw())
{
task->output_left_column(k.raw_name() + ":");
- task->output_right_column(k.pretty_print_flat());
+ task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
task->output_left_column(k.human_name() + ":");
task->output_right_column("");
- task->output_stream() << k.pretty_print();
+ task->output_stream() << k.pretty_print(formatter);
task->output_endl();
}
}
@@ -291,16 +344,17 @@ namespace
{
if (k.type() == type)
{
+ ColourFormatter formatter;
if (task->want_raw())
{
task->output_left_column(k.raw_name() + ":");
- task->output_right_column(k.pretty_print_flat());
+ task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
task->output_left_column(k.human_name() + ":");
task->output_right_column("");
- task->output_stream() << k.pretty_print();
+ task->output_stream() << k.pretty_print(formatter);
task->output_endl();
}
}
@@ -310,25 +364,18 @@ namespace
{
if (k.type() == type)
{
- if (k.value()->empty() || next(k.value()->begin()) == k.value()->end())
- task->display_metadata_pde(k.human_name(), k.raw_name(), **k.value()->begin());
- else if (task->want_raw())
+ ColourFormatter formatter;
+ if (task->want_raw())
{
task->output_left_column(k.raw_name() + ":");
- task->output_right_column(join(indirect_iterator(k.value()->begin()), indirect_iterator(k.value()->end()), ", "));
+ task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
- for (PackageIDSequence::Iterator i(k.value()->begin()), i_end(k.value()->end()) ;
- i != i_end ; ++i)
- {
- if (i == k.value()->begin())
- task->output_left_column(k.human_name() + ":");
- else
- task->output_left_column("");
-
- task->output_right_column(task->render_as_package_name(stringify(**i)));
- }
+ task->output_left_column(k.human_name() + ":");
+ task->output_right_column("");
+ task->output_stream() << k.pretty_print_flat(formatter);
+ task->output_endl();
}
}
}
@@ -336,31 +383,101 @@ namespace
void visit(const MetadataPackageIDKey & k)
{
if (k.type() == type)
- task->display_metadata_pde(k.human_name(), k.raw_name(), *k.value());
+ {
+ if (task->want_raw())
+ {
+ task->output_left_column(k.raw_name() + ":");
+ task->output_right_column(stringify(*k.value()));
+ }
+ else
+ {
+ task->output_left_column(k.human_name() + ":");
+ task->output_right_column(stringify(*k.value()));
+ }
+ }
}
void visit(const MetadataStringKey & k)
{
if (k.type() == type)
- task->display_metadata_key(k.human_name(), k.raw_name(), k.value());
+ {
+ if (task->want_raw())
+ {
+ task->output_left_column(k.raw_name() + ":");
+ task->output_right_column(stringify(k.value()));
+ }
+ else
+ {
+ task->output_left_column(k.human_name() + ":");
+ task->output_right_column(stringify(k.value()));
+ }
+ }
}
void visit(const MetadataTimeKey & k)
{
+ if (0 == k.value())
+ return;
+
+ time_t t(k.value());
+ char buf[255];
+ if (! strftime(buf, 254, "%c", gmtime(&t)))
+ buf[0] = '\0';
+
if (k.type() == type)
- task->display_metadata_time(k.human_name(), k.raw_name(), k.value());
+ {
+ if (task->want_raw())
+ {
+ task->output_left_column(k.raw_name() + ":");
+ task->output_right_column(stringify(buf));
+ }
+ else
+ {
+ task->output_left_column(k.human_name() + ":");
+ task->output_right_column(stringify(buf));
+ }
+ }
}
void visit(const MetadataRepositoryMaskInfoKey & k)
{
- if (k.type() == type)
- task->display_metadata_repository_mask_info(k.human_name(), k.raw_name(), k.value());
+ if (k.type() == type && k.value())
+ {
+ if (task->want_raw())
+ {
+ task->output_left_column(k.raw_name() + ":");
+ task->output_right_column(stringify(k.value()->mask_file) + ": " +
+ join(k.value()->comment->begin(), k.value()->comment->end(), " "));
+ }
+ else
+ {
+ task->output_left_column(k.human_name() + ":");
+ task->output_right_column(stringify(k.value()->mask_file) + ":");
+ for (Sequence<std::string>::Iterator it(k.value()->comment->begin()),
+ it_end(k.value()->comment->end()); it_end != it; ++it)
+ {
+ task->output_left_column("");
+ task->output_right_column(*it);
+ }
+ }
+ }
}
void visit(const MetadataFSEntryKey & k)
{
if (k.type() == type)
- task->display_metadata_key(k.human_name(), k.raw_name(), stringify(k.value()));
+ {
+ if (task->want_raw())
+ {
+ task->output_left_column(k.raw_name() + ":");
+ task->output_right_column(stringify(k.value()));
+ }
+ else
+ {
+ task->output_left_column(k.human_name() + ":");
+ task->output_right_column(stringify(k.value()));
+ }
+ }
}
void visit(const MetadataContentsKey &)
@@ -391,6 +508,19 @@ ConsoleQueryTask::display_metadata(const PackageDepSpec &, const tr1::shared_ptr
}
}
+void
+ConsoleQueryTask::display_masks(const PackageDepSpec &, const tr1::shared_ptr<const PackageID> & id) const
+{
+ for (PackageID::MasksIterator m(id->begin_masks()), m_end(id->end_masks()) ;
+ m != m_end ; ++m)
+ {
+ MaskDisplayer d(_imp->env, id, false);
+ (*m)->accept(d);
+ output_left_column("Masked by " + strip_leading_string((*m)->description(), "by ") + ":");
+ output_right_column(d.result());
+ }
+}
+
namespace
{
std::string normalise(const std::string & s)
@@ -468,82 +598,6 @@ namespace
}
}
-void
-ConsoleQueryTask::display_metadata_pde(const std::string & k, const std::string & kk,
- const PackageID & v) const
-{
- output_left_column((want_raw() ? kk : k) + ":");
- output_right_column(stringify(v));
-}
-
-void
-ConsoleQueryTask::display_metadata_time(const std::string & k, const std::string & kk,
- time_t t) const
-{
- if (0 == t)
- return;
-
- if (want_raw())
- {
- output_left_column(kk + ":");
- output_right_column(stringify(t));
- }
- else
- {
- char buf[255];
- if (strftime(buf, 254, "%c", gmtime(&t)))
- {
- output_left_column(k + ":");
- output_right_column(stringify(buf));
- }
- }
-}
-
-void
-ConsoleQueryTask::display_metadata_repository_mask_info(const std::string & k, const std::string & kk,
- tr1::shared_ptr<const RepositoryMaskInfo> i) const
-{
- if (! i)
- return;
-
- if (want_raw())
- {
- output_left_column(kk + ":");
- output_right_column(stringify(i->mask_file) + ": " + join(i->comment->begin(), i->comment->end(), " "));
- }
- else
- {
- output_left_column(k + ":");
- output_right_column(stringify(i->mask_file) + ":");
- for (Sequence<std::string>::Iterator it(i->comment->begin()),
- it_end(i->comment->end()); it_end != it; ++it)
- {
- output_left_column("");
- output_right_column(*it);
- }
- }
-}
-
-void
-ConsoleQueryTask::display_metadata_iuse(const std::string & k, const std::string & kk,
- const std::string & v, const tr1::shared_ptr<const PackageID> & id,
- const tr1::shared_ptr<const IUseFlagSet> & e) const
-{
- if (v.empty())
- return;
-
- output_left_column((want_raw() ? kk : k) + ":");
-
- if (want_raw())
- output_right_column(normalise(v));
- else
- {
- UseFlagPrettyPrinter printer(_imp->env);
- printer.print_package_flags(id, e);
- output_right_column("");
- }
-}
-
const tr1::shared_ptr<const Map<char, std::string> >
ConsoleQueryTask::masks_to_explain() const
{
diff --git a/src/output/console_query_task.hh b/src/output/console_query_task.hh
index fcea10c..fa4ed31 100644
--- a/src/output/console_query_task.hh
+++ b/src/output/console_query_task.hh
@@ -52,12 +52,8 @@ namespace paludis
virtual void display_metadata_key(const std::string &, const std::string &,
const std::string &) const;
- virtual void display_metadata_pde(const std::string &, const std::string &, const PackageID &) const;
- virtual void display_metadata_time(const std::string &, const std::string &, time_t) const;
- virtual void display_metadata_repository_mask_info(const std::string &, const std::string &, tr1::shared_ptr<const RepositoryMaskInfo>) const;
- virtual void display_metadata_iuse(const std::string &, const std::string &, const std::string &,
- const tr1::shared_ptr<const PackageID> & id,
- const tr1::shared_ptr<const IUseFlagSet> &) const;
+
+ virtual void display_masks(const PackageDepSpec &, const tr1::shared_ptr<const PackageID> &) const;
virtual bool want_deps() const = 0;
virtual bool want_raw() const = 0;
diff --git a/src/output/licence.cc b/src/output/licence.cc
deleted file mode 100644
index aebb50e..0000000
--- a/src/output/licence.cc
+++ /dev/null
@@ -1,82 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "licence.hh"
-#include "colour.hh"
-#include <paludis/dep_spec.hh>
-#include <paludis/environment.hh>
-#include <ostream>
-#include <algorithm>
-#include <libwrapiter/libwrapiter_forward_iterator.hh>
-
-using namespace paludis;
-
-void
-LicenceDisplayer::visit_sequence(const AllDepSpec &,
- LicenseSpecTree::ConstSequenceIterator begin,
- LicenseSpecTree::ConstSequenceIterator end)
-{
- stream << "( ";
- std::for_each(begin, end, accept_visitor(*this));
- stream << ") ";
-}
-
-void
-LicenceDisplayer::visit_sequence(const AnyDepSpec &,
- LicenseSpecTree::ConstSequenceIterator begin,
- LicenseSpecTree::ConstSequenceIterator end)
-{
- stream << "|| ( ";
- std::for_each(begin, end, accept_visitor(*this));
- stream << ") ";
-}
-
-void
-LicenceDisplayer::visit_sequence(const UseDepSpec & spec,
- LicenseSpecTree::ConstSequenceIterator begin,
- LicenseSpecTree::ConstSequenceIterator end)
-{
- if (spec.inverse())
- stream << "!";
-
- stream << spec.flag() << "? ( ";
- std::for_each(begin, end, accept_visitor(*this));
- stream << ") ";
-}
-
-void
-LicenceDisplayer::visit_leaf(const PlainTextDepSpec & spec)
-{
- if (env->accept_license(spec.text(), *package_id))
- stream << colour(cl_not_masked, spec.text());
- else
- stream << colour(cl_masked, "(" + spec.text() + ")!");
- stream << " ";
-}
-
-LicenceDisplayer::LicenceDisplayer(
- std::ostream & s,
- const Environment * const e,
- const tr1::shared_ptr<const PackageID> & d) :
- stream(s),
- env(e),
- package_id(d)
-{
-}
-
diff --git a/src/output/licence.hh b/src/output/licence.hh
deleted file mode 100644
index 6677425..0000000
--- a/src/output/licence.hh
+++ /dev/null
@@ -1,69 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_SRC_LICENCE_HH
-#define PALUDIS_GUARD_SRC_LICENCE_HH 1
-
-#include <paludis/environment-fwd.hh>
-#include <paludis/package_id-fwd.hh>
-#include <paludis/dep_spec-fwd.hh>
-#include <iosfwd>
-
-/**
- * Display licences.
- */
-struct PALUDIS_VISIBLE LicenceDisplayer :
- paludis::ConstVisitor<paludis::LicenseSpecTree>
-{
- /// Our stream.
- std::ostream & stream;
-
- /// Our environment.
- const paludis::Environment * const env;
-
- /// Our db entry.
- const paludis::tr1::shared_ptr<const paludis::PackageID> package_id;
-
- /// Constructor.
- LicenceDisplayer(
- std::ostream & stream,
- const paludis::Environment * const e,
- const paludis::tr1::shared_ptr<const paludis::PackageID> & d);
-
- ///\name Visit methods
- ///{
-
- void visit_sequence(const paludis::AllDepSpec &,
- paludis::LicenseSpecTree::ConstSequenceIterator,
- paludis::LicenseSpecTree::ConstSequenceIterator);
-
- void visit_sequence(const paludis::AnyDepSpec &,
- paludis::LicenseSpecTree::ConstSequenceIterator,
- paludis::LicenseSpecTree::ConstSequenceIterator);
-
- void visit_sequence(const paludis::UseDepSpec &,
- paludis::LicenseSpecTree::ConstSequenceIterator,
- paludis::LicenseSpecTree::ConstSequenceIterator);
-
- void visit_leaf(const paludis::PlainTextDepSpec &);
-
- ///}
-};
-
-#endif
diff --git a/src/output/mask_displayer.cc b/src/output/mask_displayer.cc
new file mode 100644
index 0000000..5a7f0bd
--- /dev/null
+++ b/src/output/mask_displayer.cc
@@ -0,0 +1,243 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "mask_displayer.hh"
+#include "colour.hh"
+#include "colour_formatter.hh"
+#include <paludis/util/private_implementation_pattern-impl.hh>
+#include <paludis/util/join.hh>
+#include <paludis/util/sequence.hh>
+#include <paludis/util/set.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/iterator.hh>
+#include <paludis/util/visitor-impl.hh>
+#include <paludis/metadata_key.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
+#include <sstream>
+
+using namespace paludis;
+
+namespace paludis
+{
+ template <>
+ struct Implementation<MaskDisplayer>
+ {
+ std::ostringstream s;
+
+ const Environment * const env;
+ const tr1::shared_ptr<const PackageID> id;
+ const bool want_description;
+
+ Implementation(const Environment * const e, const tr1::shared_ptr<const PackageID> & i,
+ const bool w) :
+ env(e),
+ id(i),
+ want_description(w)
+ {
+ }
+ };
+}
+
+namespace
+{
+ struct KeyPrettyPrinter :
+ ConstVisitor<MetadataKeyVisitorTypes>
+ {
+ std::ostringstream s;
+
+ void visit(const MetadataPackageIDKey & k)
+ {
+ s << *k.value();
+ }
+
+ void visit(const MetadataStringKey & k)
+ {
+ s << k.value();
+ }
+
+ void visit(const MetadataTimeKey & k)
+ {
+ time_t t(k.value());
+ char buf[255];
+ if (! strftime(buf, 254, "%c", gmtime(&t)))
+ buf[0] = '\0';
+ s << stringify(buf);
+ }
+
+ void visit(const MetadataContentsKey &)
+ {
+ }
+
+ void visit(const MetadataRepositoryMaskInfoKey & k)
+ {
+ s << k.value()->mask_file << ": " <<
+ join(k.value()->comment->begin(), k.value()->comment->end(), " ");
+ }
+
+ void visit(const MetadataFSEntryKey & k)
+ {
+ s << k.value();
+ }
+
+ void visit(const MetadataSetKey<UseFlagNameSet> & k)
+ {
+ ColourFormatter formatter;
+ s << k.pretty_print_flat(formatter);
+ }
+
+ void visit(const MetadataSetKey<IUseFlagSet> & k)
+ {
+ ColourFormatter formatter;
+ s << k.pretty_print_flat(formatter);
+ }
+
+ void visit(const MetadataSetKey<Set<std::string> > & k)
+ {
+ ColourFormatter formatter;
+ s << k.pretty_print_flat(formatter);
+ }
+
+ void visit(const MetadataSetKey<PackageIDSequence> & k)
+ {
+ ColourFormatter formatter;
+ s << k.pretty_print_flat(formatter);
+ }
+
+ void visit(const MetadataSpecTreeKey<URISpecTree> & k)
+ {
+ ColourFormatter formatter;
+ s << k.pretty_print_flat(formatter);
+ }
+
+ void visit(const MetadataSpecTreeKey<LicenseSpecTree> & k)
+ {
+ ColourFormatter formatter;
+ s << k.pretty_print_flat(formatter);
+ }
+
+ void visit(const MetadataSpecTreeKey<DependencySpecTree> & k)
+ {
+ ColourFormatter formatter;
+ s << k.pretty_print_flat(formatter);
+ }
+
+ void visit(const MetadataSetKey<KeywordNameSet> & k)
+ {
+ ColourFormatter formatter;
+ s << k.pretty_print_flat(formatter);
+ }
+
+ void visit(const MetadataSpecTreeKey<ProvideSpecTree> & k)
+ {
+ ColourFormatter formatter;
+ s << k.pretty_print_flat(formatter);
+ }
+
+ void visit(const MetadataSpecTreeKey<RestrictSpecTree> & k)
+ {
+ ColourFormatter formatter;
+ s << k.pretty_print_flat(formatter);
+ }
+ };
+}
+
+MaskDisplayer::MaskDisplayer(const Environment * const e, const tr1::shared_ptr<const PackageID> & id,
+ const bool want_description) :
+ PrivateImplementationPattern<MaskDisplayer>(new Implementation<MaskDisplayer>(e, id, want_description))
+{
+}
+
+MaskDisplayer::~MaskDisplayer()
+{
+}
+
+std::string
+MaskDisplayer::result() const
+{
+ return _imp->s.str();
+}
+
+void
+MaskDisplayer::visit(const UnacceptedMask & m)
+{
+ if (_imp->want_description)
+ _imp->s << m.description() << " (";
+
+ if (m.unaccepted_key())
+ {
+ KeyPrettyPrinter k;
+ m.unaccepted_key()->accept(k);
+ _imp->s << k.s.str();
+ }
+
+ if (_imp->want_description)
+ _imp->s << ")";
+}
+
+void
+MaskDisplayer::visit(const UserMask & m)
+{
+ _imp->s << m.description();
+}
+
+void
+MaskDisplayer::visit(const RepositoryMask & m)
+{
+ if (_imp->want_description)
+ {
+ _imp->s << m.description();
+
+ if (m.mask_key())
+ {
+ KeyPrettyPrinter k;
+ m.mask_key()->accept(k);
+ _imp->s << " (" << k.s.str() << ")";
+ }
+ }
+ else
+ {
+ if (m.mask_key())
+ {
+ KeyPrettyPrinter k;
+ m.mask_key()->accept(k);
+ _imp->s << k.s.str();
+ }
+ else
+ _imp->s << m.description();
+ }
+}
+
+void
+MaskDisplayer::visit(const UnsupportedMask & m)
+{
+ if (_imp->want_description)
+ _imp->s << m.description() << " (" << m.explanation() << ")";
+ else
+ _imp->s << m.explanation();
+}
+
+void
+MaskDisplayer::visit(const AssociationMask & m)
+{
+ if (_imp->want_description)
+ _imp->s << m.description() << " (associated package '" << *m.associated_package() << "')";
+ else
+ _imp->s << *m.associated_package();
+}
+
diff --git a/src/output/mask_displayer.hh b/src/output/mask_displayer.hh
new file mode 100644
index 0000000..9841dea
--- /dev/null
+++ b/src/output/mask_displayer.hh
@@ -0,0 +1,53 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_SRC_OUTPUT_MASK_DISPLAYER_HH
+#define PALUDIS_GUARD_PALUDIS_SRC_OUTPUT_MASK_DISPLAYER_HH 1
+
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/mask.hh>
+#include <paludis/environment-fwd.hh>
+#include <paludis/package_id-fwd.hh>
+
+namespace paludis
+{
+ class MaskDisplayer :
+ public ConstVisitor<MaskVisitorTypes>,
+ private PrivateImplementationPattern<MaskDisplayer>
+ {
+ public:
+ MaskDisplayer(const Environment * const, const tr1::shared_ptr<const PackageID> &,
+ const bool want_description);
+ ~MaskDisplayer();
+
+ std::string result() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ void visit(const UnacceptedMask & m);
+
+ void visit(const RepositoryMask & m);
+
+ void visit(const UserMask & m);
+
+ void visit(const UnsupportedMask & m);
+
+ void visit(const AssociationMask & m);
+ };
+}
+
+#endif
diff --git a/src/output/use_flag_pretty_printer.cc b/src/output/use_flag_pretty_printer.cc
deleted file mode 100644
index 1edb2ac..0000000
--- a/src/output/use_flag_pretty_printer.cc
+++ /dev/null
@@ -1,295 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include "use_flag_pretty_printer.hh"
-#include <paludis/environment.hh>
-#include <paludis/package_id.hh>
-#include <paludis/package_database.hh>
-#include <paludis/util/iterator.hh>
-#include <paludis/util/tr1_functional.hh>
-#include <paludis/util/set.hh>
-#include <paludis/util/log.hh>
-#include <paludis/metadata_key.hh>
-#include <libwrapiter/libwrapiter_forward_iterator.hh>
-#include <libwrapiter/libwrapiter_output_iterator.hh>
-#include "colour.hh"
-#include <iostream>
-#include <set>
-
-using namespace paludis;
-
-UseFlagPrettyPrinter::UseFlagPrettyPrinter(const Environment * const e) :
- _env(e),
- _need_space(false),
- _new_flags(new UseFlagNameSet),
- _changed_flags(new UseFlagNameSet),
- _unchanged_flags(new UseFlagNameSet),
- _expand_prefixes(new UseFlagNameSet)
-{
-}
-
-UseFlagPrettyPrinter::~UseFlagPrettyPrinter()
-{
-}
-
-std::string::size_type
-UseFlagPrettyPrinter::use_expand_delim_pos(const UseFlagName & u,
- const tr1::shared_ptr<const UseFlagNameSet> c) const
-{
- for (UseFlagNameSet::Iterator i(c->begin()), i_end(c->end()) ; i != i_end ; ++i)
- if (i->data().length() < u.data().length())
- if (0 == u.data().compare(0, i->data().length(), i->data(), 0, i->data().length()))
- {
- Log::get_instance()->message(ll_debug, lc_context) << "use_expand_delim_pos for '" << u
- << "' is '" << i->data().length() << "'";
- return i->data().length();
- }
-
- Log::get_instance()->message(ll_debug, lc_context) << "use_expand_delim_pos for '" << u
- << "' is npos";
- return std::string::npos;
-}
-
-void
-UseFlagPrettyPrinter::print_package_flags(
- const tr1::shared_ptr<const PackageID> & pkg,
- const tr1::shared_ptr<const IUseFlagSet> & iuse_c,
- const tr1::shared_ptr<const PackageID> & old_pkg,
- const tr1::shared_ptr<const IUseFlagSet> & old_iuse_c)
-{
- std::set<UseFlagName> iuse, old_iuse;
-
- std::copy(iuse_c->begin(), iuse_c->end(),
- transform_inserter(std::inserter(iuse, iuse.begin()), tr1::mem_fn(&IUseFlag::flag)));
-
- if (old_pkg && old_iuse_c)
- std::copy(old_iuse_c->begin(), old_iuse_c->end(),
- transform_inserter(std::inserter(old_iuse, old_iuse.begin()), tr1::mem_fn(&IUseFlag::flag)));
-
- const RepositoryUseInterface * const use_interface(pkg->repository()->use_interface);
-
- /* first pass: only non-expand flags */
- for (std::set<UseFlagName>::const_iterator flag(iuse.begin()), flag_end(iuse.end()) ;
- flag != flag_end ; ++flag)
- {
- if (use_interface)
- if (std::string::npos != use_expand_delim_pos(*flag, use_interface->use_expand_prefixes()))
- continue;
-
- if (environment()->query_use(*flag, *pkg))
- {
- if (use_interface && use_interface->query_use_force(*flag, *pkg))
- output_flag(render_as_forced_flag(stringify(*flag)));
- else
- output_flag(render_as_enabled_flag(stringify(*flag)));
- }
- else
- {
- if (use_interface && use_interface->query_use_mask(*flag, *pkg))
- output_flag(render_as_masked_flag(stringify(*flag)));
- else
- output_flag(render_as_disabled_flag(stringify(*flag)));
- }
-
- if (old_iuse_c)
- {
- if (old_iuse.end() != old_iuse.find(*flag))
- {
- if (environment()->query_use(*flag, *pkg) != environment()->query_use(*flag, *old_pkg))
- {
- _changed_flags->insert(*flag);
- output_flag_changed_mark();
- }
- else
- _unchanged_flags->insert(*flag);
- }
- else
- {
- _new_flags->insert(*flag);
- output_flag_is_new_mark();
- }
- }
- else
- _new_flags->insert(*flag);
- }
-
- /* second pass: only expand flags */
- UseFlagName old_expand_name("OFTEN_NOT_BEEN_ON_BOATS");
- for (std::set<UseFlagName>::const_iterator flag(iuse.begin()), flag_end(iuse.end()) ;
- flag != flag_end ; ++flag)
- {
- std::string::size_type delim_pos(0);
- if (use_interface)
- {
- if (std::string::npos == ((delim_pos = use_expand_delim_pos(*flag,
- use_interface->use_expand_prefixes()))))
- continue;
- if (use_interface->use_expand_hidden_prefixes()->count(UseFlagName(flag->data().substr(0, delim_pos))))
- continue;
- }
-
- UseFlagName expand_name(flag->data().substr(0, delim_pos)),
- expand_value(flag->data().substr(delim_pos + 1));
-
- _expand_prefixes->insert(expand_name);
-
- if (expand_name != old_expand_name)
- {
- output_expand_prefix(stringify(expand_name));
- old_expand_name = expand_name;
- }
-
- if (environment()->query_use(*flag, *pkg))
- {
- if (use_interface && use_interface->query_use_force(*flag, *pkg))
- output_flag(render_as_forced_flag(stringify(expand_value)));
- else
- output_flag(render_as_enabled_flag(stringify(expand_value)));
- }
- else
- {
- if (use_interface && use_interface->query_use_mask(*flag, *pkg))
- output_flag(render_as_masked_flag(stringify(expand_value)));
- else
- output_flag(render_as_disabled_flag(stringify(expand_value)));
- }
-
- if (old_pkg)
- {
- if (old_iuse.end() != old_iuse.find(*flag))
- {
- if (environment()->query_use(*flag, *pkg) != environment()->query_use(*flag, *old_pkg))
- {
- _changed_flags->insert(*flag);
- output_flag_changed_mark();
- }
- else
- _unchanged_flags->insert(*flag);
- }
- else
- {
- _new_flags->insert(*flag);
- output_flag_is_new_mark();
- }
- }
- else
- _new_flags->insert(*flag);
- }
-}
-
-void
-UseFlagPrettyPrinter::output_flag(const std::string & s)
-{
- if (_need_space)
- output_stream() << " ";
-
- output_stream() << s;
-
- _need_space = true;
-}
-
-void
-UseFlagPrettyPrinter::output_flag_changed_mark()
-{
- output_stream() << "*";
-}
-
-void
-UseFlagPrettyPrinter::output_flag_is_new_mark()
-{
- output_stream() << "%";
-}
-
-void
-UseFlagPrettyPrinter::output_expand_prefix(const std::string & s)
-{
- if (_need_space)
- output_stream() << " ";
-
- output_stream() << s << ":";
-
- _need_space = true;
-}
-
-std::string
-UseFlagPrettyPrinter::render_as_enabled_flag(const std::string & s) const
-{
- return colour(cl_flag_on, s);
-}
-
-std::string
-UseFlagPrettyPrinter::render_as_disabled_flag(const std::string & s) const
-{
- return colour(cl_flag_off, "-" + s);
-}
-
-std::string
-UseFlagPrettyPrinter::render_as_forced_flag(const std::string & s) const
-{
- return colour(cl_flag_on, "(" + s + ")");
-}
-
-std::string
-UseFlagPrettyPrinter::render_as_masked_flag(const std::string & s) const
-{
- return colour(cl_flag_off, "(-" + s + ")");
-}
-
-std::ostream &
-UseFlagPrettyPrinter::output_stream() const
-{
- return std::cout;
-}
-
-bool
-UseFlagPrettyPrinter::need_space() const
-{
- return _need_space;
-}
-
-const Environment *
-UseFlagPrettyPrinter::environment() const
-{
- return _env;
-}
-
-tr1::shared_ptr<const UseFlagNameSet>
-UseFlagPrettyPrinter::new_flags() const
-{
- return _new_flags;
-}
-
-tr1::shared_ptr<const UseFlagNameSet>
-UseFlagPrettyPrinter::changed_flags() const
-{
- return _changed_flags;
-}
-
-tr1::shared_ptr<const UseFlagNameSet>
-UseFlagPrettyPrinter::unchanged_flags() const
-{
- return _unchanged_flags;
-}
-
-tr1::shared_ptr<const UseFlagNameSet>
-UseFlagPrettyPrinter::expand_prefixes() const
-{
- return _expand_prefixes;
-}
-
diff --git a/src/output/use_flag_pretty_printer.hh b/src/output/use_flag_pretty_printer.hh
deleted file mode 100644
index 8f8c5f1..0000000
--- a/src/output/use_flag_pretty_printer.hh
+++ /dev/null
@@ -1,79 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_SRC_USE_FLAG_PRETTY_PRINTER_HH
-#define PALUDIS_GUARD_SRC_USE_FLAG_PRETTY_PRINTER_HH 1
-
-#include <paludis/name-fwd.hh>
-#include <paludis/environment-fwd.hh>
-#include <paludis/package_id-fwd.hh>
-#include <iosfwd>
-
-namespace paludis
-{
- class Environment;
-
- class PALUDIS_VISIBLE UseFlagPrettyPrinter
- {
- private:
- const Environment * const _env;
- bool _need_space;
-
- tr1::shared_ptr<UseFlagNameSet> _new_flags;
- tr1::shared_ptr<UseFlagNameSet> _changed_flags;
- tr1::shared_ptr<UseFlagNameSet> _unchanged_flags;
- tr1::shared_ptr<UseFlagNameSet> _expand_prefixes;
-
- protected:
- std::string::size_type use_expand_delim_pos(const UseFlagName & u,
- const tr1::shared_ptr<const UseFlagNameSet> c) const;
-
- public:
- UseFlagPrettyPrinter(const Environment * const);
- virtual ~UseFlagPrettyPrinter();
-
- virtual void print_package_flags(
- const tr1::shared_ptr<const PackageID> &,
- const tr1::shared_ptr<const IUseFlagSet> &,
- const tr1::shared_ptr<const PackageID> & w = tr1::shared_ptr<const PackageID>(),
- const tr1::shared_ptr<const IUseFlagSet> & x = tr1::shared_ptr<const IUseFlagSet>());
-
- virtual void output_flag(const std::string &);
- virtual void output_flag_changed_mark();
- virtual void output_flag_is_new_mark();
- virtual void output_expand_prefix(const std::string &);
-
- virtual std::string render_as_enabled_flag(const std::string &) const;
- virtual std::string render_as_disabled_flag(const std::string &) const;
- virtual std::string render_as_forced_flag(const std::string &) const;
- virtual std::string render_as_masked_flag(const std::string &) const;
-
- virtual std::ostream & output_stream() const;
-
- const Environment * environment() const;
- bool need_space() const;
-
- tr1::shared_ptr<const UseFlagNameSet> new_flags() const;
- tr1::shared_ptr<const UseFlagNameSet> changed_flags() const;
- tr1::shared_ptr<const UseFlagNameSet> unchanged_flags() const;
- tr1::shared_ptr<const UseFlagNameSet> expand_prefixes() const;
- };
-}
-
-#endif