aboutsummaryrefslogtreecommitdiff
path: root/paludis/resolver/package_or_block_dep_spec.cc
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-19 01:19:21 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-12-19 01:19:21 +0000
commit7d994ad210d8fc308a506ad9c2cd3eeed4607a65 (patch)
treea85245d7592cdd3fc289998e4b863268825c0f3e /paludis/resolver/package_or_block_dep_spec.cc
parentb990aeda2d842664cb12aa75c5cb48142779af82 (diff)
downloadpaludis-7d994ad210d8fc308a506ad9c2cd3eeed4607a65.tar.gz
paludis-7d994ad210d8fc308a506ad9c2cd3eeed4607a65.tar.xz
Do annotations differently
Diffstat (limited to 'paludis/resolver/package_or_block_dep_spec.cc')
-rw-r--r--paludis/resolver/package_or_block_dep_spec.cc42
1 files changed, 15 insertions, 27 deletions
diff --git a/paludis/resolver/package_or_block_dep_spec.cc b/paludis/resolver/package_or_block_dep_spec.cc
index 576ec5755..23ad5349b 100644
--- a/paludis/resolver/package_or_block_dep_spec.cc
+++ b/paludis/resolver/package_or_block_dep_spec.cc
@@ -24,10 +24,10 @@
#include <paludis/util/sequence-impl.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
#include <paludis/util/make_null_shared_ptr.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/serialise-impl.hh>
-#include <paludis/metadata_key.hh>
+#include <paludis/dep_spec_annotations.hh>
#include <paludis/elike_package_dep_spec.hh>
-#include <paludis/elike_annotations.hh>
#include <ostream>
using namespace paludis;
@@ -79,26 +79,16 @@ PackageOrBlockDepSpec::serialise(Serialiser & s) const
;
}
- if (! spec->annotations_key())
+ if (! spec->maybe_annotations())
w.member(SerialiserFlags<>(), "annotations_count", 0);
else
{
int n(0);
- for (MetadataSectionKey::MetadataConstIterator m(spec->annotations_key()->begin_metadata()),
- m_end(spec->annotations_key()->end_metadata()) ;
+ for (auto m(spec->maybe_annotations()->begin()), m_end(spec->maybe_annotations()->end()) ;
m != m_end ; ++m)
{
- const MetadataValueKey<std::string> * k(
- simple_visitor_cast<const MetadataValueKey<std::string> >(**m));
- if (! k)
- {
- Log::get_instance()->message("resolver.sanitised_dependencies.not_a_string", ll_warning, lc_context)
- << "Annotation '" << (*m)->raw_name() << "' not a string. This is probably a bug.";
- continue;
- }
-
- w.member(SerialiserFlags<>(), "annotations_k_" + stringify(n), k->human_name());
- w.member(SerialiserFlags<>(), "annotations_v_" + stringify(n), k->value());
+ w.member(SerialiserFlags<>(), "annotations_k_" + stringify(n), m->key());
+ w.member(SerialiserFlags<>(), "annotations_v_" + stringify(n), m->value());
++n;
}
@@ -124,33 +114,31 @@ PackageOrBlockDepSpec::deserialise(Deserialisation & d, const std::shared_ptr<co
vso_letters_anywhere, vso_dotted_suffixes },
for_id));
- std::shared_ptr<MetadataSectionKey> annotations;
-
- std::shared_ptr<Map<std::string, std::string> > m(std::make_shared<Map<std::string, std::string>>());
+ auto annotations(std::make_shared<DepSpecAnnotations>());
for (int a(0), a_end(v.member<int>("annotations_count")) ;
a != a_end ; ++a)
{
std::string key(v.member<std::string>("annotations_k_" + stringify(a)));
std::string value(v.member<std::string>("annotations_v_" + stringify(a)));
- m->insert(key, value);
+ annotations->add(make_named_values<DepSpecAnnotation>(
+ n::key() = key,
+ n::value() = value
+ ));
}
- if (! m->empty())
- annotations = std::make_shared<ELikeAnnotations>(m);
-
if (block)
{
BlockKind kind(destringify<BlockKind>(v.member<std::string>("block_kind")));
std::string text(v.member<std::string>("text"));
BlockDepSpec b_spec(text, spec, kind);
- if (annotations)
- b_spec.set_annotations_key(annotations);
+ if (annotations->begin() != annotations->end())
+ b_spec.set_annotations(annotations);
return PackageOrBlockDepSpec(b_spec);
}
else
{
- if (annotations)
- spec.set_annotations_key(annotations);
+ if (annotations->begin() != annotations->end())
+ spec.set_annotations(annotations);
return PackageOrBlockDepSpec(spec);
}
}