diff options
Diffstat (limited to 'paludis/repositories')
28 files changed, 1339 insertions, 115 deletions
diff --git a/paludis/repositories/accounts/accounts_dep_key.cc b/paludis/repositories/accounts/accounts_dep_key.cc index d208bee2b..d7d3aec1d 100644 --- a/paludis/repositories/accounts/accounts_dep_key.cc +++ b/paludis/repositories/accounts/accounts_dep_key.cc @@ -32,6 +32,7 @@ #include <paludis/util/pimp-impl.hh> #include <paludis/partially_made_package_dep_spec.hh> #include <paludis/always_enabled_dependency_label.hh> +#include <paludis/pretty_printer.hh> #include <sstream> #include <list> @@ -155,3 +156,22 @@ AccountsDepKey::pretty_print_flat(const DependencySpecTree::ItemFormatter & f) c return s.str(); } +const std::string +AccountsDepKey::pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions &) const +{ + std::stringstream s; + + for (std::list<std::shared_ptr<PackageDepSpec> >::const_iterator i(_imp->specs->begin()), + i_end(_imp->specs->end()) ; i != i_end ; ++i) + { + if (! s.str().empty()) + s << ", "; + + s << pretty_printer.prettify(**i); + } + + return s.str(); +} + diff --git a/paludis/repositories/accounts/accounts_dep_key.hh b/paludis/repositories/accounts/accounts_dep_key.hh index b31cdc2c8..d269c00fb 100644 --- a/paludis/repositories/accounts/accounts_dep_key.hh +++ b/paludis/repositories/accounts/accounts_dep_key.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2009 Ciaran McCreesh + * Copyright (c) 2009, 2010 Ciaran McCreesh * * 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 @@ -49,6 +49,10 @@ namespace paludis PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::shared_ptr<const DependenciesLabelSequence> initial_labels() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; } } diff --git a/paludis/repositories/cran/Makefile.am b/paludis/repositories/cran/Makefile.am index 63e31388a..7746b5339 100644 --- a/paludis/repositories/cran/Makefile.am +++ b/paludis/repositories/cran/Makefile.am @@ -22,6 +22,7 @@ noinst_HEADERS = \ keys.hh \ normalise.hh \ dep_spec_pretty_printer.hh \ + spec_tree_pretty_printer.hh \ package_dep_spec.hh libpaludiscranrepository_la_SOURCES = \ @@ -35,6 +36,7 @@ libpaludiscranrepository_la_SOURCES = \ masks.cc \ keys.cc \ dep_spec_pretty_printer.cc \ + spec_tree_pretty_printer.cc \ package_dep_spec.cc \ $(paludis_repositories_cran_include_HEADERS) diff --git a/paludis/repositories/cran/keys.cc b/paludis/repositories/cran/keys.cc index 02f0e4c85..de397230d 100644 --- a/paludis/repositories/cran/keys.cc +++ b/paludis/repositories/cran/keys.cc @@ -21,6 +21,7 @@ #include <paludis/repositories/cran/cran_package_id.hh> #include <paludis/repositories/cran/cran_dep_parser.hh> #include <paludis/repositories/cran/dep_spec_pretty_printer.hh> +#include <paludis/repositories/cran/spec_tree_pretty_printer.hh> #include <paludis/util/sequence.hh> #include <paludis/util/stringify.hh> #include <paludis/util/join.hh> @@ -34,6 +35,7 @@ #include <paludis/repository.hh> #include <paludis/environment.hh> #include <paludis/package_database.hh> +#include <paludis/call_pretty_printer.hh> #include <functional> using namespace paludis; @@ -89,6 +91,14 @@ PackageIDSequenceKey::pretty_print_flat(const Formatter<PackageID> & f) const std::cref(f), _1, format::Plain())); } +const std::string +PackageIDSequenceKey::pretty_print_value( + const PrettyPrinter & p, const PrettyPrintOptions &) const +{ + using namespace std::placeholders; + return join(value()->begin(), value()->end(), " ", CallPrettyPrinter(p)); +} + PackageIDKey::PackageIDKey(const Environment * const e, const std::string & r, const std::string & h, const CRANPackageID * const v, const MetadataKeyType t) : _env(e), @@ -106,6 +116,12 @@ PackageIDKey::value() const } const std::string +PackageIDKey::pretty_print_value(const PrettyPrinter & p, const PrettyPrintOptions &) const +{ + return p.prettify(value()); +} + +const std::string PackageIDKey::raw_name() const { return _r; @@ -229,6 +245,15 @@ DepKey::pretty_print_flat(const DependencySpecTree::ItemFormatter & f) const return stringify(p); } +const std::string +DepKey::pretty_print_value( + const PrettyPrinter & printer, const PrettyPrintOptions & options) const +{ + SpecTreePrettyPrinter p(printer, options); + value()->top()->accept(p); + return stringify(p); +} + const std::shared_ptr<const DependenciesLabelSequence> DepKey::initial_labels() const { diff --git a/paludis/repositories/cran/keys.hh b/paludis/repositories/cran/keys.hh index c2b38883e..4faa6025d 100644 --- a/paludis/repositories/cran/keys.hh +++ b/paludis/repositories/cran/keys.hh @@ -56,6 +56,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class PackageIDKey : @@ -81,6 +85,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class DepKey : @@ -112,6 +120,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; } } diff --git a/paludis/repositories/cran/spec_tree_pretty_printer.cc b/paludis/repositories/cran/spec_tree_pretty_printer.cc new file mode 100644 index 000000000..40e43399d --- /dev/null +++ b/paludis/repositories/cran/spec_tree_pretty_printer.cc @@ -0,0 +1,134 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2010 Ciaran McCreesh + * + * 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/repositories/cran/spec_tree_pretty_printer.hh> +#include <paludis/util/pimp-impl.hh> +#include <paludis/util/indirect_iterator-impl.hh> +#include <paludis/util/stringify.hh> +#include <paludis/util/options.hh> +#include <paludis/util/accept_visitor.hh> +#include <paludis/pretty_printer.hh> +#include <algorithm> +#include <ostream> +#include <sstream> + +using namespace paludis; +using namespace paludis::cranrepository; + +namespace paludis +{ + template <> + struct Imp<SpecTreePrettyPrinter> + { + std::stringstream s; + const PrettyPrinter & printer; + const PrettyPrintOptions options; + const unsigned indent; + const bool multiline; + bool need_comma; + + Imp( + const PrettyPrinter & p, const PrettyPrintOptions & o) : + printer(p), + options(o), + indent(0), + multiline(o[ppo_multiline_allowed]), + need_comma(false) + { + } + }; +} + +SpecTreePrettyPrinter::SpecTreePrettyPrinter( + const PrettyPrinter & p, const PrettyPrintOptions & o) : + Pimp<SpecTreePrettyPrinter>(p, o) +{ +} + +SpecTreePrettyPrinter::~SpecTreePrettyPrinter() +{ +} + +void +SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) +{ + if (_imp->multiline) + _imp->s << _imp->printer.indentify(_imp->indent); + else if (_imp->need_comma) + _imp->s << ", "; + else + _imp->need_comma = true; + + _imp->s << _imp->printer.prettify(*node.spec()); + + if (_imp->multiline) + _imp->s << _imp->printer.newline(); +} + +void +SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) +{ + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); +} + +void +SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) +{ + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); +} + +void +SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) +{ + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); +} + +void +SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &) +{ +} + +void +SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<DependenciesLabelsDepSpec>::Type &) +{ +} + +void +SpecTreePrettyPrinter::visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node) +{ + if (_imp->multiline) + _imp->s << _imp->printer.indentify(_imp->indent); + else if (_imp->need_comma) + _imp->s << ", "; + else + _imp->need_comma = true; + + _imp->s << _imp->printer.prettify(*node.spec()); + + if (_imp->multiline) + _imp->s << _imp->printer.newline(); +} + +std::ostream & +paludis::cranrepository::operator<< (std::ostream & s, const SpecTreePrettyPrinter & p) +{ + s << p._imp->s.str(); + return s; +} + diff --git a/paludis/repositories/cran/spec_tree_pretty_printer.hh b/paludis/repositories/cran/spec_tree_pretty_printer.hh new file mode 100644 index 000000000..78e2994d4 --- /dev/null +++ b/paludis/repositories/cran/spec_tree_pretty_printer.hh @@ -0,0 +1,61 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2010 Ciaran McCreesh + * + * 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_REPOSITORIES_CRAN_SPEC_TREE_PRETTY_PRINTER_HH +#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_CRAN_SPEC_TREE_PRETTY_PRINTER_HH 1 + +#include <paludis/util/pimp.hh> +#include <paludis/spec_tree.hh> +#include <paludis/dep_spec-fwd.hh> +#include <paludis/formatter.hh> +#include <paludis/pretty_print_options-fwd.hh> +#include <paludis/pretty_printer-fwd.hh> +#include <iosfwd> + +namespace paludis +{ + namespace cranrepository + { + class PALUDIS_VISIBLE SpecTreePrettyPrinter : + private Pimp<SpecTreePrettyPrinter> + { + friend std::ostream & operator<< (std::ostream &, const SpecTreePrettyPrinter &); + + public: + SpecTreePrettyPrinter( + const PrettyPrinter & p, const PrettyPrintOptions &); + + ~SpecTreePrettyPrinter(); + + ///\} + + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<DependenciesLabelsDepSpec>::Type & node); + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type & node); + }; + + std::ostream & operator<< (std::ostream & s, const SpecTreePrettyPrinter & p) PALUDIS_VISIBLE; + } +} + +#endif diff --git a/paludis/repositories/e/Makefile.am b/paludis/repositories/e/Makefile.am index 46235845e..b9f2e6ef0 100644 --- a/paludis/repositories/e/Makefile.am +++ b/paludis/repositories/e/Makefile.am @@ -83,6 +83,7 @@ noinst_HEADERS = \ profile_file.hh \ required_use_verifier.hh \ source_uri_finder.hh \ + spec_tree_pretty_printer.hh \ traditional_layout.hh \ traditional_profile.hh \ use_desc.hh \ @@ -153,6 +154,7 @@ libpaludiserepository_la_SOURCES = \ registration.cc \ required_use_verifier.cc \ source_uri_finder.cc \ + spec_tree_pretty_printer.cc \ traditional_layout.cc \ traditional_profile.cc \ use_desc.cc \ diff --git a/paludis/repositories/e/e_key.cc b/paludis/repositories/e/e_key.cc index 61bef825b..3a7bd52ce 100644 --- a/paludis/repositories/e/e_key.cc +++ b/paludis/repositories/e/e_key.cc @@ -25,6 +25,7 @@ #include <paludis/repositories/e/vdb_contents_tokeniser.hh> #include <paludis/repositories/e/e_repository.hh> #include <paludis/repositories/e/myoption.hh> +#include <paludis/repositories/e/spec_tree_pretty_printer.hh> #include <paludis/util/pretty_print.hh> #include <paludis/util/pimp-impl.hh> @@ -51,6 +52,7 @@ #include <paludis/stringify_formatter-impl.hh> #include <paludis/dep_spec_flattener.hh> #include <paludis/literal_metadata_key.hh> +#include <paludis/call_pretty_printer.hh> #include <algorithm> #include <functional> @@ -167,6 +169,16 @@ EDependenciesKey::initial_labels() const return _imp->labels; } +const std::string +EDependenciesKey::pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions & options) const +{ + SpecTreePrettyPrinter p(pretty_printer, options); + value()->top()->accept(p); + return stringify(p); +} + std::string EDependenciesKey::pretty_print(const DependencySpecTree::ItemFormatter & f) const { @@ -254,6 +266,16 @@ ELicenseKey::value() const return _imp->value; } +const std::string +ELicenseKey::pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions & options) const +{ + SpecTreePrettyPrinter p(pretty_printer, options); + value()->top()->accept(p); + return stringify(p); +} + std::string ELicenseKey::pretty_print(const LicenseSpecTree::ItemFormatter & f) const { @@ -342,6 +364,16 @@ EFetchableURIKey::value() const return _imp->value; } +const std::string +EFetchableURIKey::pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions & options) const +{ + SpecTreePrettyPrinter p(pretty_printer, options); + value()->top()->accept(p); + return stringify(p); +} + std::string EFetchableURIKey::pretty_print(const FetchableURISpecTree::ItemFormatter & f) const { @@ -467,6 +499,16 @@ ESimpleURIKey::value() const return _imp->value; } +const std::string +ESimpleURIKey::pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions & options) const +{ + SpecTreePrettyPrinter p(pretty_printer, options); + value()->top()->accept(p); + return stringify(p); +} + std::string ESimpleURIKey::pretty_print(const SimpleURISpecTree::ItemFormatter & f) const { @@ -554,6 +596,16 @@ EPlainTextSpecKey::value() const return _imp->value; } +const std::string +EPlainTextSpecKey::pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions & options) const +{ + SpecTreePrettyPrinter p(pretty_printer, options); + value()->top()->accept(p); + return stringify(p); +} + std::string EPlainTextSpecKey::pretty_print(const PlainTextSpecTree::ItemFormatter & f) const { @@ -642,6 +694,16 @@ EMyOptionsKey::value() const return _imp->value; } +const std::string +EMyOptionsKey::pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions & options) const +{ + SpecTreePrettyPrinter p(pretty_printer, options); + value()->top()->accept(p); + return stringify(p); +} + std::string EMyOptionsKey::pretty_print(const PlainTextSpecTree::ItemFormatter & f) const { @@ -730,6 +792,16 @@ ERequiredUseKey::value() const return _imp->value; } +const std::string +ERequiredUseKey::pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions & options) const +{ + SpecTreePrettyPrinter p(pretty_printer, options); + value()->top()->accept(p); + return stringify(p); +} + std::string ERequiredUseKey::pretty_print(const RequiredUseSpecTree::ItemFormatter & f) const { @@ -817,6 +889,16 @@ EProvideKey::value() const return _imp->value; } +const std::string +EProvideKey::pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions & options) const +{ + SpecTreePrettyPrinter p(pretty_printer, options); + value()->top()->accept(p); + return stringify(p); +} + std::string EProvideKey::pretty_print(const ProvideSpecTree::ItemFormatter & f) const { @@ -904,6 +986,12 @@ EKeywordsKey::value() const return _imp->value; } +const std::string +EKeywordsKey::pretty_print_value(const PrettyPrinter & p, const PrettyPrintOptions &) const +{ + return join(value()->begin(), value()->end(), " ", CallPrettyPrinter(p)); +} + std::string EKeywordsKey::pretty_print_flat(const Formatter<KeywordName> & f) const { @@ -1026,6 +1114,13 @@ EStringSetKey::pretty_print_flat(const Formatter<std::string> & f) const return join(value()->begin(), value()->end(), " ", std::bind(&format_string, _1, f)); } +const std::string +EStringSetKey::pretty_print_value( + const PrettyPrinter & p, const PrettyPrintOptions &) const +{ + return join(value()->begin(), value()->end(), " ", CallPrettyPrinter(p)); +} + namespace paludis { template <> diff --git a/paludis/repositories/e/e_key.hh b/paludis/repositories/e/e_key.hh index 62f344dee..6589da8ff 100644 --- a/paludis/repositories/e/e_key.hh +++ b/paludis/repositories/e/e_key.hh @@ -85,6 +85,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class EFetchableURIKey : @@ -114,6 +118,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class ESimpleURIKey : @@ -138,6 +146,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class EPlainTextSpecKey : @@ -163,6 +175,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class EMyOptionsKey : @@ -187,6 +203,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class ERequiredUseKey : @@ -211,6 +231,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class EProvideKey : @@ -235,6 +259,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class ELicenseKey : @@ -261,6 +289,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class EKeywordsKey : @@ -283,6 +315,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class EStringSetKey : @@ -303,6 +339,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class EContentsKey : diff --git a/paludis/repositories/e/info_metadata_key.cc b/paludis/repositories/e/info_metadata_key.cc index 1e78bc554..11744495a 100644 --- a/paludis/repositories/e/info_metadata_key.cc +++ b/paludis/repositories/e/info_metadata_key.cc @@ -42,6 +42,8 @@ #include <paludis/environment.hh> #include <paludis/package_id.hh> #include <paludis/formatter.hh> +#include <paludis/pretty_printer.hh> +#include <paludis/call_pretty_printer.hh> #include <map> #include <algorithm> @@ -225,6 +227,15 @@ InfoVarsMetadataKey::pretty_print_flat(const Formatter<std::string> & f) const } const std::string +InfoVarsMetadataKey::pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions &) const +{ + using namespace std::placeholders; + return join(value()->begin(), value()->end(), " ", CallPrettyPrinter(pretty_printer)); +} + +const std::string InfoPkgsMetadataKey::raw_name() const { return "info_pkgs"; diff --git a/paludis/repositories/e/info_metadata_key.hh b/paludis/repositories/e/info_metadata_key.hh index e4db7518b..ea3dc9fe1 100644 --- a/paludis/repositories/e/info_metadata_key.hh +++ b/paludis/repositories/e/info_metadata_key.hh @@ -50,6 +50,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; } diff --git a/paludis/repositories/e/spec_tree_pretty_printer.cc b/paludis/repositories/e/spec_tree_pretty_printer.cc new file mode 100644 index 000000000..363d5e01f --- /dev/null +++ b/paludis/repositories/e/spec_tree_pretty_printer.cc @@ -0,0 +1,545 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2010 Ciaran McCreesh + * + * 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/repositories/e/spec_tree_pretty_printer.hh> +#include <paludis/util/indirect_iterator-impl.hh> +#include <paludis/util/save.hh> +#include <paludis/util/accept_visitor.hh> +#include <paludis/util/pimp-impl.hh> +#include <paludis/pretty_printer.hh> +#include <paludis/dep_spec_annotations.hh> +#include <algorithm> +#include <sstream> + +using namespace paludis; +using namespace paludis::erepository; + +namespace paludis +{ + template<> + struct Imp<SpecTreePrettyPrinter> + { + std::stringstream s; + const PrettyPrinter & pretty_printer; + const PrettyPrintOptions options; + + unsigned indent; + bool extra_label_indent; + bool use_newlines; + bool outer_block; + bool all_needs_parens; + bool need_space; + + Imp(const PrettyPrinter & p, const PrettyPrintOptions & o) : + pretty_printer(p), + options(o), + indent(0), + extra_label_indent(false), + use_newlines(options[ppo_multiline_allowed]), + outer_block(true), + all_needs_parens(false), + need_space(false) + { + } + }; +} + +SpecTreePrettyPrinter::SpecTreePrettyPrinter( + const PrettyPrinter & p, + const PrettyPrintOptions & o) : + Pimp<SpecTreePrettyPrinter>(p, o) +{ +} + +SpecTreePrettyPrinter::~SpecTreePrettyPrinter() = default; + +std::ostream & +paludis::erepository::operator<< (std::ostream & s, const SpecTreePrettyPrinter & p) +{ + s << p._imp->s.str(); + return s; +} + +namespace +{ + struct IsLabelVisitor + { + bool result; + + IsLabelVisitor() : + result(false) + { + } + + void visit(const GenericSpecTree::NodeType<PlainTextDepSpec>::Type &) + { + } + + void visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type &) + { + } + + void visit(const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type &) + { + } + + void visit(const GenericSpecTree::NodeType<LicenseDepSpec>::Type &) + { + } + + void visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type &) + { + } + + void visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type &) + { + } + + void visit(const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type &) + { + result = true; + } + + void visit(const GenericSpecTree::NodeType<URILabelsDepSpec>::Type &) + { + result = true; + } + + void visit(const GenericSpecTree::NodeType<DependenciesLabelsDepSpec>::Type &) + { + result = true; + } + + void visit(const GenericSpecTree::NodeType<NamedSetDepSpec>::Type &) + { + } + + void visit(const GenericSpecTree::NodeType<AllDepSpec>::Type &) + { + } + + void visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type &) + { + } + + void visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type &) + { + } + + void visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type &) + { + } + }; + + bool is_label(const GenericSpecTree::BasicNode & i) + { + IsLabelVisitor v; + i.accept(v); + return v.result; + } +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<AllDepSpec>::Type & node) +{ + bool need_parens(_imp->all_needs_parens || node.spec()->maybe_annotations() || + (! _imp->outer_block && indirect_iterator(node.end()) != std::find_if(indirect_iterator(node.begin()), + indirect_iterator(node.end()), + is_label))); + Save<bool> old_outer(&_imp->outer_block, false); + Save<bool> old_needs_parens(&_imp->all_needs_parens, false); + + if (need_parens) + { + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + _imp->s << "("; + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; + } + + { + Save<unsigned> old_indent(&_imp->indent, need_parens ? _imp->indent +1 : _imp->indent); + Save<bool> extra_label_indent(&_imp->extra_label_indent, need_parens ? false : _imp->extra_label_indent); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + if (need_parens) + { + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + _imp->s << ")"; + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; + } +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type & node) +{ + Save<bool> old_outer(&_imp->outer_block, false); + Save<bool> old_needs_parens(&_imp->all_needs_parens, true); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + _imp->s << "|| ("; + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; + + { + Save<unsigned> old_indent(&_imp->indent, _imp->indent + 1); + Save<bool> extra_label_indent(&_imp->extra_label_indent, false); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + _imp->s << ")"; + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type & node) +{ + Save<bool> old_outer(&_imp->outer_block, false); + Save<bool> old_needs_parens(&_imp->all_needs_parens, true); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + _imp->s << "^^ ("; + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; + + { + Save<unsigned> old_indent(&_imp->indent, _imp->indent + 1); + Save<bool> extra_label_indent(&_imp->extra_label_indent, false); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + _imp->s << ")"; + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & node) +{ + Save<bool> old_outer(&_imp->outer_block, false); + Save<bool> old_needs_parens(&_imp->all_needs_parens, false); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + + _imp->s << _imp->pretty_printer.prettify(*node.spec()) << " ("; + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; + + { + Save<unsigned> old_indent(&_imp->indent, _imp->indent + 1); + Save<bool> extra_label_indent(&_imp->extra_label_indent, false); + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + _imp->s << ")"; + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type & node) +{ + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + + _imp->s << _imp->pretty_printer.prettify(*node.spec()); + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<PlainTextDepSpec>::Type & node) +{ + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + + _imp->s << _imp->pretty_printer.prettify(*node.spec()); + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<NamedSetDepSpec>::Type & node) +{ + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + + _imp->s << _imp->pretty_printer.prettify(*node.spec()); + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<LicenseDepSpec>::Type & node) +{ + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + + _imp->s << _imp->pretty_printer.prettify(*node.spec()); + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type & node) +{ + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + + _imp->s << _imp->pretty_printer.prettify(*node.spec()); + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type & node) +{ + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + + _imp->s << _imp->pretty_printer.prettify(*node.spec()); + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type & node) +{ + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + + _imp->s << _imp->pretty_printer.prettify(*node.spec()); + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<URILabelsDepSpec>::Type & node) +{ + if (_imp->extra_label_indent) + { + _imp->extra_label_indent = false; + _imp->indent -= 1; + } + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + + _imp->s << _imp->pretty_printer.prettify(*node.spec()); + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; + + if (! _imp->extra_label_indent) + { + _imp->extra_label_indent = true; + _imp->indent += 1; + } +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type & node) +{ + if (_imp->extra_label_indent) + { + _imp->extra_label_indent = false; + _imp->indent -= 1; + } + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + + _imp->s << _imp->pretty_printer.prettify(*node.spec()); + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; + + if (! _imp->extra_label_indent) + { + _imp->extra_label_indent = true; + _imp->indent += 1; + } +} + +void +SpecTreePrettyPrinter::visit(const GenericSpecTree::NodeType<DependenciesLabelsDepSpec>::Type & node) +{ + if (_imp->extra_label_indent) + { + _imp->extra_label_indent = false; + _imp->indent -= 1; + } + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.indentify(_imp->indent); + else if (_imp->need_space) + _imp->s << " "; + + _imp->s << _imp->pretty_printer.prettify(*node.spec()); + + do_annotations(*node.spec()); + + if (_imp->use_newlines) + _imp->s << _imp->pretty_printer.newline(); + else + _imp->need_space = true; + + if (!_imp->extra_label_indent) + { + _imp->extra_label_indent = true; + _imp->indent += 1; + } +} + +void +SpecTreePrettyPrinter::do_annotations(const DepSpec & p) +{ + if (p.maybe_annotations() && (p.maybe_annotations()->begin() != p.maybe_annotations()->end())) + { + _imp->s << " [[ "; + + for (auto m(p.maybe_annotations()->begin()), m_end(p.maybe_annotations()->end()) ; + m != m_end ; ++m) + { + _imp->s << m->key() << " = [" << (m->value().empty() ? " " : " " + m->value() + " ") << "] "; + } + _imp->s << "]]"; + } +} + diff --git a/paludis/repositories/e/spec_tree_pretty_printer.hh b/paludis/repositories/e/spec_tree_pretty_printer.hh new file mode 100644 index 000000000..a44ecfc1f --- /dev/null +++ b/paludis/repositories/e/spec_tree_pretty_printer.hh @@ -0,0 +1,72 @@ +/* vim: set sw=4 sts=4 et foldmethod=syntax : */ + +/* + * Copyright (c) 2010 Ciaran McCreesh + * + * 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_REPOSITORIES_E_SPEC_TREE_PRETTY_PRINTER_HH +#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_SPEC_TREE_PRETTY_PRINTER_HH 1 + +#include <paludis/util/attributes.hh> +#include <paludis/dep_spec.hh> +#include <paludis/spec_tree.hh> +#include <paludis/metadata_key-fwd.hh> +#include <paludis/environment-fwd.hh> +#include <paludis/package_id-fwd.hh> +#include <paludis/pretty_print_options-fwd.hh> +#include <paludis/pretty_printer-fwd.hh> + +namespace paludis +{ + namespace erepository + { + class PALUDIS_VISIBLE SpecTreePrettyPrinter : + private Pimp<SpecTreePrettyPrinter> + { + friend std::ostream & operator<< (std::ostream &, const SpecTreePrettyPrinter &); + + private: + void do_annotations(const DepSpec &); + + public: + SpecTreePrettyPrinter( + const PrettyPrinter &, + const PrettyPrintOptions & + ); + + ~SpecTreePrettyPrinter(); + + void visit(const GenericSpecTree::NodeType<AllDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<AnyDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<ExactlyOneDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<ConditionalDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<PackageDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<BlockDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<DependenciesLabelsDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<NamedSetDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<SimpleURIDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<FetchableURIDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<URILabelsDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<PlainTextDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<PlainTextLabelDepSpec>::Type & node); + void visit(const GenericSpecTree::NodeType<LicenseDepSpec>::Type & node); + }; + + std::ostream & operator<< (std::ostream & s, const SpecTreePrettyPrinter & p) PALUDIS_VISIBLE; + } +} + +#endif diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc index d77c79557..7338d2b09 100644 --- a/paludis/repositories/fake/fake_package_id.cc +++ b/paludis/repositories/fake/fake_package_id.cc @@ -31,6 +31,8 @@ #include <paludis/user_dep_spec.hh> #include <paludis/package_database.hh> #include <paludis/always_enabled_dependency_label.hh> +#include <paludis/pretty_printer.hh> +#include <paludis/call_pretty_printer.hh> #include <paludis/util/stringify.hh> #include <paludis/util/mutex.hh> #include <paludis/util/pimp-impl.hh> @@ -58,81 +60,6 @@ using namespace paludis::fakerepository; namespace paludis { template <typename C_> - struct Imp<FakeMetadataValueKey<C_> > - { - const std::string raw_name; - const std::string human_name; - const MetadataKeyType type; - C_ value; - - Imp(const std::string & r, const std::string & h, const MetadataKeyType t, const C_ & c) : - raw_name(r), - human_name(h), - type(t), - value(c) - { - } - }; -} - -template <typename C_> -FakeMetadataValueKey<C_>::FakeMetadataValueKey( - const std::string & r, const std::string & h, const MetadataKeyType t, const C_ & c) : - Pimp<FakeMetadataValueKey<C_> >(r, h, t, c), - _imp(Pimp<FakeMetadataValueKey<C_> >::_imp) -{ -} - -template <typename C_> -FakeMetadataValueKey<C_>::~FakeMetadataValueKey() -{ -} - -template <typename C_> -const C_ -FakeMetadataValueKey<C_>::value() const -{ - return this->_imp->value; -} - -template <typename C_> -const std::string -FakeMetadataValueKey<C_>::raw_name() const -{ - return this->_imp->raw_name; -} - -template <typename C_> -const std::string -FakeMetadataValueKey<C_>::human_name() const -{ - return this->_imp->human_name; -} - -template <typename C_> -MetadataKeyType -FakeMetadataValueKey<C_>::type() const -{ - return this->_imp->type; -} - -template <typename C_> -std::string -FakeMetadataValueKey<C_>::pretty_print() const -{ - return stringify(value()); -} - -template <typename C_> -void -FakeMetadataValueKey<C_>::set_value(const C_ & c) -{ - this->_imp->value = c; -} - -namespace paludis -{ - template <typename C_> struct Imp<FakeMetadataCollectionKey<C_> > { std::shared_ptr<C_> collection; @@ -197,6 +124,15 @@ FakeMetadataCollectionKey<C_>::type() const return this->_imp->type; } +template <typename C_> +const std::string +FakeMetadataCollectionKey<C_>::pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions &) const +{ + return join(value()->begin(), value()->end(), " ", CallPrettyPrinter(pretty_printer)); +} + FakeMetadataKeywordSetKey::FakeMetadataKeywordSetKey(const std::string & r, const std::string & h, const std::string & v, const MetadataKeyType t, const std::shared_ptr<const PackageID> & i, const Environment * const e) : @@ -347,6 +283,14 @@ FakeMetadataSpecTreeKey<C_>::pretty_print_flat(const typename C_::ItemFormatter return _imp->string_value; } +template <typename C_> +const std::string +FakeMetadataSpecTreeKey<C_>::pretty_print_value( + const PrettyPrinter &, const PrettyPrintOptions &) const +{ + return _imp->string_value; +} + FakeMetadataSpecTreeKey<FetchableURISpecTree>::FakeMetadataSpecTreeKey(const std::string & r, const std::string & h, const std::string & v, const std::function<const std::shared_ptr<const FetchableURISpecTree> (const std::string &)> & f, const MetadataKeyType t) : Pimp<FakeMetadataSpecTreeKey<FetchableURISpecTree> >(f, r, h, t), @@ -390,6 +334,12 @@ FakeMetadataSpecTreeKey<FetchableURISpecTree>::value() const return _imp->value; } +const std::string +FakeMetadataSpecTreeKey<FetchableURISpecTree>::pretty_print_value(const PrettyPrinter &, const PrettyPrintOptions &) const +{ + return _imp->string_value; +} + std::string FakeMetadataSpecTreeKey<FetchableURISpecTree>::pretty_print(const FetchableURISpecTree::ItemFormatter &) const { @@ -434,6 +384,12 @@ FakeMetadataSpecTreeKey<DependencySpecTree>::value() const return _imp->value; } +const std::string +FakeMetadataSpecTreeKey<DependencySpecTree>::pretty_print_value(const PrettyPrinter &, const PrettyPrintOptions &) const +{ + return _imp->string_value; +} + std::string FakeMetadataSpecTreeKey<DependencySpecTree>::pretty_print(const DependencySpecTree::ItemFormatter &) const { @@ -731,7 +687,7 @@ namespace paludis std::shared_ptr<FakeMetadataSpecTreeKey<FetchableURISpecTree> > src_uri; std::shared_ptr<FakeMetadataSpecTreeKey<SimpleURISpecTree> > homepage; std::shared_ptr<FakeMetadataChoicesKey> choices; - std::shared_ptr<FakeMetadataValueKey<long> > hitchhiker; + std::shared_ptr<LiteralMetadataValueKey<long> > hitchhiker; std::shared_ptr<LiteralMetadataStringSetKey> behaviours; std::shared_ptr<Set<std::string> > behaviours_set; @@ -1044,7 +1000,7 @@ FakePackageID::need_keys_added() const _imp->behaviours = std::make_shared<LiteralMetadataStringSetKey>("BEHAVIOURS", "Behaviours", mkt_internal, _imp->behaviours_set); - _imp->hitchhiker = std::make_shared<FakeMetadataValueKey<long>>("HITCHHIKER", "Hitchhiker", + _imp->hitchhiker = std::make_shared<LiteralMetadataValueKey<long>>("HITCHHIKER", "Hitchhiker", mkt_internal, 42); _imp->keywords = std::make_shared<FakeMetadataKeywordSetKey>("KEYWORDS", "Keywords", "test", mkt_normal, shared_from_this(), _imp->env); @@ -1312,19 +1268,19 @@ FakePackageID::size_of_all_distfiles_key() const return std::shared_ptr<const MetadataValueKey<long> >(); } -const std::shared_ptr<FakeMetadataValueKey<long> > -FakePackageID::hitchhiker_key() -{ - need_keys_added(); - return _imp->hitchhiker; -} - char FakePackageID::use_expand_separator() const { return '_'; } +const std::string +FakeMetadataKeywordSetKey::pretty_print_value( + const PrettyPrinter & pretty_printer, const PrettyPrintOptions &) const +{ + return join(value()->begin(), value()->end(), " ", CallPrettyPrinter(pretty_printer)); +} + std::string FakeMetadataKeywordSetKey::pretty_print_flat(const Formatter<KeywordName> & f) const { @@ -1392,6 +1348,3 @@ template class FakeMetadataSpecTreeKey<SimpleURISpecTree>; template class FakeMetadataCollectionKey<KeywordNameSet>; -template class FakeMetadataValueKey<bool>; -template class FakeMetadataValueKey<long>; - diff --git a/paludis/repositories/fake/fake_package_id.hh b/paludis/repositories/fake/fake_package_id.hh index ad2ecb354..fe27a4324 100644 --- a/paludis/repositories/fake/fake_package_id.hh +++ b/paludis/repositories/fake/fake_package_id.hh @@ -31,31 +31,6 @@ namespace paludis class FakeRepositoryBase; template <typename C_> - class PALUDIS_VISIBLE FakeMetadataValueKey : - public MetadataValueKey<C_>, - private Pimp<FakeMetadataValueKey<C_> > - { - protected: - typename Pimp<FakeMetadataValueKey<C_> >::ImpPtr & _imp; - - public: - FakeMetadataValueKey(const std::string &, const std::string &, const MetadataKeyType, - const C_ &); - - ~FakeMetadataValueKey(); - - virtual const C_ value() const PALUDIS_ATTRIBUTE((warn_unused_result)); - void set_value(const C_ &); - - virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); - virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); - - virtual std::string pretty_print() const - PALUDIS_ATTRIBUTE((warn_unused_result)); - }; - - template <typename C_> class PALUDIS_VISIBLE FakeMetadataCollectionKey : public MetadataCollectionKey<C_>, private Pimp<FakeMetadataCollectionKey<C_> > @@ -74,6 +49,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class PALUDIS_VISIBLE FakeMetadataKeywordSetKey : @@ -87,6 +66,10 @@ namespace paludis virtual std::string pretty_print_flat(const Formatter<KeywordName> &) const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; template <typename C_> @@ -116,6 +99,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; template <> @@ -149,6 +136,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; template <> @@ -183,6 +174,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class PALUDIS_VISIBLE FakeMetadataChoicesKey : @@ -307,7 +302,6 @@ namespace paludis const std::shared_ptr<FakeMetadataSpecTreeKey<FetchableURISpecTree> > fetches_key(); const std::shared_ptr<FakeMetadataSpecTreeKey<SimpleURISpecTree> > homepage_key(); const std::shared_ptr<FakeMetadataChoicesKey> choices_key(); - const std::shared_ptr<FakeMetadataValueKey<long> > hitchhiker_key(); const std::shared_ptr<Set<std::string> > behaviours_set(); diff --git a/paludis/repositories/gemcutter/gemcutter_dependencies_key.cc b/paludis/repositories/gemcutter/gemcutter_dependencies_key.cc index f53b70a19..76cb71739 100644 --- a/paludis/repositories/gemcutter/gemcutter_dependencies_key.cc +++ b/paludis/repositories/gemcutter/gemcutter_dependencies_key.cc @@ -39,6 +39,7 @@ #include <paludis/version_requirements.hh> #include <paludis/version_operator.hh> #include <paludis/version_spec.hh> +#include <paludis/pretty_printer.hh> #include <sstream> #include <algorithm> #include <vector> @@ -140,6 +141,81 @@ namespace } }; + struct ValuePrinter + { + std::stringstream s; + const PrettyPrinter & printer; + const PrettyPrintOptions options; + + const unsigned indent; + const bool flat; + bool need_space; + + ValuePrinter( + const PrettyPrinter & p, + const PrettyPrintOptions & o) : + printer(p), + options(o), + indent(0), + flat(! options[ppo_multiline_allowed]), + need_space(false) + { + } + + void visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type & node) + { + if (! flat) + s << printer.indentify(indent + 1); + else if (need_space) + s << " "; + else + need_space = true; + + s << printer.prettify(*node.spec()); + + if (! flat) + s << printer.newline(); + } + + void visit(const DependencySpecTree::NodeType<BlockDepSpec>::Type &) + { + } + + void visit(const DependencySpecTree::NodeType<DependenciesLabelsDepSpec>::Type & node) + { + if (! flat) + s << printer.indentify(indent); + else if (need_space) + s << " "; + else + need_space = true; + + s << printer.prettify(*node.spec()); + + if (! flat) + s << printer.newline(); + } + + void visit(const DependencySpecTree::NodeType<NamedSetDepSpec>::Type &) + { + } + + void visit(const DependencySpecTree::NodeType<AllDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const DependencySpecTree::NodeType<ConditionalDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const DependencySpecTree::NodeType<AnyDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + }; + struct GemcutterDependenciesKeyData : Singleton<GemcutterDependenciesKeyData> { @@ -302,5 +378,15 @@ GemcutterDependenciesKey::pretty_print_flat(const DependencySpecTree::ItemFormat return p.s.str(); } +const std::string +GemcutterDependenciesKey::pretty_print_value( + const PrettyPrinter & printer, + const PrettyPrintOptions & options) const +{ + ValuePrinter p{printer, options}; + _imp->value->top()->accept(p); + return p.s.str(); +} + template class Pimp<GemcutterDependenciesKey>; diff --git a/paludis/repositories/gemcutter/gemcutter_dependencies_key.hh b/paludis/repositories/gemcutter/gemcutter_dependencies_key.hh index b1e973e2c..09f9d7e8f 100644 --- a/paludis/repositories/gemcutter/gemcutter_dependencies_key.hh +++ b/paludis/repositories/gemcutter/gemcutter_dependencies_key.hh @@ -70,6 +70,10 @@ namespace paludis virtual const std::shared_ptr<const DependenciesLabelSequence> initial_labels() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; } } diff --git a/paludis/repositories/gemcutter/gemcutter_uri_key.cc b/paludis/repositories/gemcutter/gemcutter_uri_key.cc index c17ee5047..27ecfe4cd 100644 --- a/paludis/repositories/gemcutter/gemcutter_uri_key.cc +++ b/paludis/repositories/gemcutter/gemcutter_uri_key.cc @@ -23,6 +23,7 @@ #include <paludis/util/pimp-impl.hh> #include <paludis/spec_tree.hh> #include <paludis/dep_spec.hh> +#include <paludis/pretty_printer.hh> #include <sstream> #include <algorithm> @@ -79,6 +80,53 @@ namespace std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); } }; + + struct ValuePrinter + { + std::stringstream s; + const PrettyPrinter & printer; + const PrettyPrintOptions options; + + const unsigned indent; + const bool flat; + bool need_space; + + ValuePrinter( + const PrettyPrinter & p, + const PrettyPrintOptions & o) : + printer(p), + options(o), + indent(0), + flat(! options[ppo_multiline_allowed]), + need_space(false) + { + } + + void visit(const SimpleURISpecTree::NodeType<SimpleURIDepSpec>::Type & node) + { + if (! flat) + s << printer.indentify(indent + 1); + else if (need_space) + s << " "; + else + need_space = true; + + s << printer.prettify(*node.spec()); + + if (! flat) + s << printer.newline(); + } + + void visit(const SimpleURISpecTree::NodeType<AllDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const SimpleURISpecTree::NodeType<ConditionalDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + }; } namespace paludis @@ -140,6 +188,15 @@ GemcutterURIKey::type() const return _imp->type; } +const std::string +GemcutterURIKey::pretty_print_value( + const PrettyPrinter & printer, const PrettyPrintOptions & options) const +{ + ValuePrinter p{printer, options}; + _imp->value->top()->accept(p); + return p.s.str(); +} + std::string GemcutterURIKey::pretty_print(const SimpleURISpecTree::ItemFormatter & f) const { diff --git a/paludis/repositories/gemcutter/gemcutter_uri_key.hh b/paludis/repositories/gemcutter/gemcutter_uri_key.hh index 7d4a555c2..6aa0e6d16 100644 --- a/paludis/repositories/gemcutter/gemcutter_uri_key.hh +++ b/paludis/repositories/gemcutter/gemcutter_uri_key.hh @@ -64,6 +64,10 @@ namespace paludis */ virtual std::string pretty_print_flat(const SimpleURISpecTree::ItemFormatter &) const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; } } diff --git a/paludis/repositories/unavailable/unavailable_repository_dependencies_key.cc b/paludis/repositories/unavailable/unavailable_repository_dependencies_key.cc index cf563ef17..bc2df967b 100644 --- a/paludis/repositories/unavailable/unavailable_repository_dependencies_key.cc +++ b/paludis/repositories/unavailable/unavailable_repository_dependencies_key.cc @@ -26,6 +26,7 @@ #include <paludis/dep_label.hh> #include <paludis/comma_separated_dep_parser.hh> #include <paludis/comma_separated_dep_printer.hh> +#include <paludis/comma_separated_dep_pretty_printer.hh> #include <paludis/always_enabled_dependency_label.hh> #include <memory> @@ -107,6 +108,16 @@ UnavailableRepositoryDependenciesKey::type() const return _imp->type; } +const std::string +UnavailableRepositoryDependenciesKey::pretty_print_value( + const PrettyPrinter & printer, + const PrettyPrintOptions & options) const +{ + CommaSeparatedDepPrettyPrinter p(printer, options); + _imp->value->top()->accept(p); + return p.result(); +} + std::string UnavailableRepositoryDependenciesKey::pretty_print(const DependencySpecTree::ItemFormatter & f) const { diff --git a/paludis/repositories/unavailable/unavailable_repository_dependencies_key.hh b/paludis/repositories/unavailable/unavailable_repository_dependencies_key.hh index 02e33a3c6..e7de9855d 100644 --- a/paludis/repositories/unavailable/unavailable_repository_dependencies_key.hh +++ b/paludis/repositories/unavailable/unavailable_repository_dependencies_key.hh @@ -50,6 +50,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; } } diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc index 69b236d31..7e9a20efe 100644 --- a/paludis/repositories/unpackaged/installed_id.cc +++ b/paludis/repositories/unpackaged/installed_id.cc @@ -47,8 +47,11 @@ #include <paludis/user_dep_spec.hh> #include <paludis/comma_separated_dep_parser.hh> #include <paludis/comma_separated_dep_printer.hh> +#include <paludis/comma_separated_dep_pretty_printer.hh> #include <paludis/formatter.hh> #include <paludis/always_enabled_dependency_label.hh> +#include <paludis/pretty_printer.hh> +#include <paludis/call_pretty_printer.hh> #include <functional> using namespace paludis; @@ -309,6 +312,13 @@ namespace { return _type; } + + virtual const std::string pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions &) const + { + return join(value()->begin(), value()->end(), " ", CallPrettyPrinter(pretty_printer)); + } }; class InstalledUnpackagedDependencyKey : @@ -387,6 +397,15 @@ namespace { return _type; } + + virtual const std::string pretty_print_value( + const PrettyPrinter & printer, + const PrettyPrintOptions & options) const + { + CommaSeparatedDepPrettyPrinter p(printer, options); + value()->top()->accept(p); + return p.result(); + } }; } diff --git a/paludis/repositories/unpackaged/unpackaged_key.cc b/paludis/repositories/unpackaged/unpackaged_key.cc index d66a0a68e..cbd7fd726 100644 --- a/paludis/repositories/unpackaged/unpackaged_key.cc +++ b/paludis/repositories/unpackaged/unpackaged_key.cc @@ -27,6 +27,7 @@ #include <paludis/elike_choices.hh> #include <paludis/comma_separated_dep_printer.hh> #include <paludis/comma_separated_dep_parser.hh> +#include <paludis/comma_separated_dep_pretty_printer.hh> #include <memory> using namespace paludis; @@ -95,6 +96,15 @@ UnpackagedDependencyKey::type() const return _imp->type; } +const std::string +UnpackagedDependencyKey::pretty_print_value( + const PrettyPrinter & printer, const PrettyPrintOptions & options) const +{ + CommaSeparatedDepPrettyPrinter p(printer, options); + _imp->value->top()->accept(p); + return p.result(); +} + std::string UnpackagedDependencyKey::pretty_print(const DependencySpecTree::ItemFormatter & f) const { diff --git a/paludis/repositories/unpackaged/unpackaged_key.hh b/paludis/repositories/unpackaged/unpackaged_key.hh index ffcb0760f..c6053a04e 100644 --- a/paludis/repositories/unpackaged/unpackaged_key.hh +++ b/paludis/repositories/unpackaged/unpackaged_key.hh @@ -1,7 +1,7 @@ /* vim: set sw=4 sts=4 et foldmethod=syntax : */ /* - * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh + * Copyright (c) 2007, 2008, 2009, 2010 Ciaran McCreesh * * 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 @@ -52,6 +52,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class UnpackagedChoicesKey : diff --git a/paludis/repositories/unwritten/unwritten_repository_file.cc b/paludis/repositories/unwritten/unwritten_repository_file.cc index 01018f60b..b9541e8b7 100644 --- a/paludis/repositories/unwritten/unwritten_repository_file.cc +++ b/paludis/repositories/unwritten/unwritten_repository_file.cc @@ -36,6 +36,7 @@ #include <paludis/formatter.hh> #include <paludis/user_dep_spec.hh> #include <paludis/spec_tree.hh> +#include <paludis/pretty_printer.hh> #include <paludis/util/pimp-impl.hh> #include <paludis/util/wrapped_forward_iterator-impl.hh> @@ -116,6 +117,34 @@ namespace } }; + struct UnwrittenHomepagePrettyPrinter + { + std::stringstream s; + const PrettyPrinter & pretty_printer; + + UnwrittenHomepagePrettyPrinter(const PrettyPrinter & p) : + pretty_printer(p) + { + } + + void visit(const SimpleURISpecTree::NodeType<AllDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const SimpleURISpecTree::NodeType<ConditionalDepSpec>::Type & node) + { + std::for_each(indirect_iterator(node.begin()), indirect_iterator(node.end()), accept_visitor(*this)); + } + + void visit(const SimpleURISpecTree::NodeType<SimpleURIDepSpec>::Type & node) + { + if (! s.str().empty()) + s << " "; + s << pretty_printer.prettify(*node.spec()); + } + }; + struct UnwrittenHomepageKey : MetadataSpecTreeKey<SimpleURISpecTree> { @@ -167,6 +196,15 @@ namespace { return _type; } + + virtual const std::string pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions &) const + { + UnwrittenHomepagePrettyPrinter p(pretty_printer); + value()->top()->accept(p); + return p.s.str(); + } }; } diff --git a/paludis/repositories/virtuals/package_id.cc b/paludis/repositories/virtuals/package_id.cc index 30f780acc..902850016 100644 --- a/paludis/repositories/virtuals/package_id.cc +++ b/paludis/repositories/virtuals/package_id.cc @@ -46,6 +46,7 @@ #include <paludis/filtered_generator.hh> #include <paludis/partially_made_package_dep_spec.hh> #include <paludis/always_enabled_dependency_label.hh> +#include <paludis/pretty_printer.hh> using namespace paludis; using namespace paludis::virtuals; @@ -154,6 +155,14 @@ VirtualsDepKey::pretty_print_flat(const DependencySpecTree::ItemFormatter & f) c return pretty_print(f); } +const std::string +VirtualsDepKey::pretty_print_value( + const PrettyPrinter & pretty_printer, + const PrettyPrintOptions &) const +{ + return pretty_printer.prettify(*_imp->spec); +} + const std::shared_ptr<const DependenciesLabelSequence> VirtualsDepKey::initial_labels() const { diff --git a/paludis/repositories/virtuals/package_id.hh b/paludis/repositories/virtuals/package_id.hh index 30513f50f..bd4e984d9 100644 --- a/paludis/repositories/virtuals/package_id.hh +++ b/paludis/repositories/virtuals/package_id.hh @@ -57,6 +57,10 @@ namespace paludis virtual const std::string raw_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual const std::string human_name() const PALUDIS_ATTRIBUTE((warn_unused_result)); virtual MetadataKeyType type() const PALUDIS_ATTRIBUTE((warn_unused_result)); + + virtual const std::string pretty_print_value( + const PrettyPrinter &, + const PrettyPrintOptions &) const PALUDIS_ATTRIBUTE((warn_unused_result)); }; class VirtualsPackageID : |