aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-13 16:31:53 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-11-13 16:31:53 +0000
commitc22b445963b1b7d8cf2e45da950c902d63cb837b (patch)
tree8634caa6f371a6018dc1326d4e291da8ebd74168 /src
parent72833626ac5df274e559c3f66720615b26340721 (diff)
downloadpaludis-c22b445963b1b7d8cf2e45da950c902d63cb837b.tar.gz
paludis-c22b445963b1b7d8cf2e45da950c902d63cb837b.tar.xz
Add MetadataSectionKey
Diffstat (limited to 'src')
-rw-r--r--src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc4
-rw-r--r--src/clients/inquisitio/key_extractor.cc6
-rw-r--r--src/clients/instruo/instruo.cc97
-rw-r--r--src/clients/qualudis/qualudis.cc11
-rw-r--r--src/output/console_query_task.cc96
-rw-r--r--src/output/console_task.cc4
-rw-r--r--src/output/console_task.hh2
-rw-r--r--src/output/mask_displayer.cc27
8 files changed, 121 insertions, 126 deletions
diff --git a/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc b/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc
index 200f4cd60..0a08f6cc6 100644
--- a/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc
+++ b/src/clients/gtkpaludis/libgtkpaludis/version_info_model.cc
@@ -196,6 +196,10 @@ namespace gtkpaludis
void visit(const MetadataContentsKey &)
{
}
+
+ void visit(const MetadataSectionKey &)
+ {
+ }
};
struct VersionInfoModel::KeyMetadataPopulator :
diff --git a/src/clients/inquisitio/key_extractor.cc b/src/clients/inquisitio/key_extractor.cc
index 436501bed..7f384ef00 100644
--- a/src/clients/inquisitio/key_extractor.cc
+++ b/src/clients/inquisitio/key_extractor.cc
@@ -385,6 +385,12 @@ namespace
result = v.result;
}
}
+
+ void visit(const MetadataSectionKey & k)
+ {
+ std::for_each(indirect_iterator(k.begin_metadata()),
+ indirect_iterator(k.end_metadata()), accept_visitor(*this));
+ }
};
}
diff --git a/src/clients/instruo/instruo.cc b/src/clients/instruo/instruo.cc
index 5a21cfc80..015a37b10 100644
--- a/src/clients/instruo/instruo.cc
+++ b/src/clients/instruo/instruo.cc
@@ -30,6 +30,7 @@
#include <paludis/util/map.hh>
#include <paludis/util/tr1_functional.hh>
#include <paludis/util/visitor-impl.hh>
+#include <paludis/util/visitor_cast.hh>
#include <paludis/util/set.hh>
#include <paludis/environments/no_config/no_config_environment.hh>
#include <paludis/package_database.hh>
@@ -46,88 +47,6 @@ using std::endl;
namespace
{
- struct EAPIFinder :
- ConstVisitor<MetadataKeyVisitorTypes>
- {
- bool ok;
- std::string s;
-
- EAPIFinder() :
- ok(false)
- {
- }
-
- void visit(const MetadataStringKey & k)
- {
- s = k.value();
- ok = true;
- }
-
- void visit(const MetadataPackageIDKey &)
- {
- }
-
- void visit(const MetadataTimeKey &)
- {
- }
-
- void visit(const MetadataContentsKey &)
- {
- }
-
- void visit(const MetadataFSEntryKey &)
- {
- }
-
- void visit(const MetadataRepositoryMaskInfoKey &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<RestrictSpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<ProvideSpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<FetchableURISpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<SimpleURISpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<LicenseSpecTree> &)
- {
- }
-
- void visit(const MetadataSpecTreeKey<DependencySpecTree> &)
- {
- }
-
- void visit(const MetadataSetKey<PackageIDSequence> &)
- {
- }
-
- void visit(const MetadataSetKey<Set<std::string> > &)
- {
- }
-
- void visit(const MetadataSetKey<KeywordNameSet> &)
- {
- }
-
- void visit(const MetadataSetKey<IUseFlagSet> &)
- {
- }
-
- void visit(const MetadataSetKey<UseFlagNameSet> &)
- {
- }
- };
-
struct KeyValidator :
ConstVisitor<MetadataKeyVisitorTypes>
{
@@ -215,6 +134,12 @@ namespace
{
const tr1::shared_ptr<const UseFlagNameSet> & PALUDIS_ATTRIBUTE((unused)) s(k.value());
}
+
+ void visit(const MetadataSectionKey & k)
+ {
+ std::for_each(indirect_iterator(k.begin_metadata()),
+ indirect_iterator(k.end_metadata()), accept_visitor(*this));
+ }
};
}
@@ -315,17 +240,15 @@ main(int argc, char *argv[])
continue;
}
- EAPIFinder f;
- (*eapi_i)->accept(f);
- if (! f.ok)
+ if (! visitor_cast<const MetadataStringKey>(**eapi_i))
{
results.insert(std::make_pair(*i, "EAPI metadata key is not a string key"));
continue;
}
- if (f.s == "UNKNOWN")
+ if (visitor_cast<const MetadataStringKey>(**eapi_i)->value() == "UNKNOWN")
{
- results.insert(std::make_pair(*i, "EAPI is '" + f.s + "'"));
+ results.insert(std::make_pair(*i, "EAPI is 'UNKNOWN'"));
continue;
}
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index 860b6cf37..ab2496b2d 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -144,8 +144,17 @@ namespace
stream << k.raw_name() << "\n";
}
- void visit(const MetadataContentsKey &)
+ void visit(const MetadataContentsKey & k)
{
+ stream << k.raw_name() << "\n";
+ }
+
+ void visit(const MetadataSectionKey & k)
+ {
+ if (k.title_key())
+ stream << k.raw_name() << ": " << k.title_key()->value() << "\n";
+ else
+ stream << k.raw_name() << "\n";
}
};
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index 2e60fb562..f5719a031 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -242,14 +242,17 @@ namespace
const Environment * const env;
const tr1::shared_ptr<const PackageID> id;
const MetadataKeyType type;
+ const unsigned in;
public:
Displayer(const ConsoleQueryTask * const t, const Environment * const e,
- const tr1::shared_ptr<const PackageID> & i, const MetadataKeyType k) :
+ const tr1::shared_ptr<const PackageID> & i, const MetadataKeyType k,
+ const unsigned ind = 0) :
task(t),
env(e),
id(i),
- type(k)
+ type(k),
+ in(ind)
{
}
@@ -260,12 +263,12 @@ namespace
ColourFormatter formatter;
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
}
@@ -278,12 +281,12 @@ namespace
ColourFormatter formatter;
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
}
@@ -296,12 +299,12 @@ namespace
ColourFormatter formatter;
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
}
@@ -314,12 +317,12 @@ namespace
ColourFormatter formatter;
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
}
@@ -332,12 +335,12 @@ namespace
ColourFormatter formatter;
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column("");
task->output_stream() << k.pretty_print(formatter);
}
@@ -351,12 +354,12 @@ namespace
ColourFormatter formatter;
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_stream() << k.pretty_print_flat(formatter);
task->output_right_column("");
}
@@ -370,12 +373,12 @@ namespace
ColourFormatter formatter;
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_stream() << k.pretty_print_flat(formatter);
task->output_right_column("");
}
@@ -389,12 +392,12 @@ namespace
ColourFormatter formatter;
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
ComplexLicenseFinder is_complex;
k.value()->accept(is_complex);
if (is_complex)
@@ -415,12 +418,12 @@ namespace
ColourFormatter formatter;
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column("");
task->output_stream() << k.pretty_print(formatter);
}
@@ -434,12 +437,12 @@ namespace
ColourFormatter formatter;
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column("");
task->output_stream() << k.pretty_print(formatter);
}
@@ -453,12 +456,12 @@ namespace
ColourFormatter formatter;
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(k.pretty_print_flat(formatter));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column("");
task->output_stream() << k.pretty_print_flat(formatter);
task->output_endl();
@@ -472,12 +475,12 @@ namespace
{
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(stringify(*k.value()));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column(stringify(*k.value()));
}
}
@@ -489,17 +492,40 @@ namespace
{
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(stringify(k.value()));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column(stringify(k.value()));
}
}
}
+ void visit(const MetadataSectionKey & k)
+ {
+ if (k.type() == type)
+ {
+ if (task->want_raw())
+ {
+ task->output_left_column(k.raw_name() + ":", in);
+ task->output_right_column("");
+ }
+ else
+ {
+ task->output_left_column((k.title_key() ? k.title_key()->value() : k.human_name()) + ":", in);
+ task->output_right_column("");
+ }
+
+ Displayer v(task, env, id, type, in + 4);
+ for (MetadataSectionKey::MetadataConstIterator kk(k.begin_metadata()), kk_end(k.end_metadata()) ;
+ kk != kk_end ; ++kk)
+ if (*kk != k.title_key())
+ (*kk)->accept(v);
+ }
+ }
+
void visit(const MetadataTimeKey & k)
{
if (0 == k.value())
@@ -514,12 +540,12 @@ namespace
{
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(stringify(buf));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column(stringify(buf));
}
}
@@ -531,18 +557,18 @@ namespace
{
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
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_left_column(k.human_name() + ":", in);
task->output_right_column(stringify(k.value()->mask_file) + ":");
for (Sequence<std::string>::ConstIterator it(k.value()->comment->begin()),
it_end(k.value()->comment->end()); it_end != it; ++it)
{
- task->output_left_column("");
+ task->output_left_column("", in);
task->output_right_column(*it);
}
}
@@ -555,12 +581,12 @@ namespace
{
if (task->want_raw())
{
- task->output_left_column(k.raw_name() + ":");
+ task->output_left_column(k.raw_name() + ":", in);
task->output_right_column(stringify(k.value()));
}
else
{
- task->output_left_column(k.human_name() + ":");
+ task->output_left_column(k.human_name() + ":", in);
task->output_right_column(stringify(k.value()));
}
}
diff --git a/src/output/console_task.cc b/src/output/console_task.cc
index 42dab4af3..09f066d97 100644
--- a/src/output/console_task.cc
+++ b/src/output/console_task.cc
@@ -168,9 +168,9 @@ ConsoleTask::render_plural(int c, const std::string & s, const std::string & p)
}
void
-ConsoleTask::output_left_column(const std::string & s) const
+ConsoleTask::output_left_column(const std::string & s, const unsigned indent) const
{
- output_stream() << " " << std::setw(left_column_width()) << std::left << s << " ";
+ output_stream() << " " << std::string(indent, ' ') << std::setw(left_column_width()) << std::left << s << " ";
}
void
diff --git a/src/output/console_task.hh b/src/output/console_task.hh
index 5d8680030..8a5e3f6d6 100644
--- a/src/output/console_task.hh
+++ b/src/output/console_task.hh
@@ -57,7 +57,7 @@ namespace paludis
virtual void output_no_endl(const std::string &) const;
virtual void output_endl() const;
- virtual void output_left_column(const std::string &) const;
+ virtual void output_left_column(const std::string &, const unsigned indent = 0) const;
virtual void output_right_column(const std::string &) const;
///\}
diff --git a/src/output/mask_displayer.cc b/src/output/mask_displayer.cc
index 0c2db4ea2..5d664e2eb 100644
--- a/src/output/mask_displayer.cc
+++ b/src/output/mask_displayer.cc
@@ -69,6 +69,33 @@ namespace
s << k.value();
}
+ void visit(const MetadataSectionKey & k)
+ {
+ if (k.title_key())
+ s << k.title_key()->value() << ": ";
+ s << "(";
+
+ bool need_comma(false);
+ for (MetadataSectionKey::MetadataConstIterator m(k.begin_metadata()), m_end(k.end_metadata()) ;
+ m != m_end ; ++m)
+ if ((*m) != k.title_key())
+ {
+ if (need_comma)
+ s << ", ";
+ else
+ s << " ";
+
+ KeyPrettyPrinter p;
+ (*m)->accept(p);
+ s << p.s.str();
+ need_comma = true;
+ }
+ s << " )";
+
+ std::for_each(indirect_iterator(k.begin_metadata()),
+ indirect_iterator(k.end_metadata()), accept_visitor(*this));
+ }
+
void visit(const MetadataTimeKey & k)
{
time_t t(k.value());