aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-17 14:23:11 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-07-17 14:23:11 +0000
commit58121c4e81db489db745851ed03208df28e64a11 (patch)
tree572b2fc78ad8375758b844fc228d8d3d579d20b2
parent8dee390b21c83cf67d7b93237fa34c14e92ce80d (diff)
downloadpaludis-58121c4e81db489db745851ed03208df28e64a11.tar.gz
paludis-58121c4e81db489db745851ed03208df28e64a11.tar.xz
More libwrapiter conversion
-rw-r--r--paludis/Makefile.am.m42
-rw-r--r--paludis/config_file.cc15
-rw-r--r--paludis/config_file.hh18
-rw-r--r--paludis/config_file_TEST.cc10
-rw-r--r--paludis/contents.hh2
-rw-r--r--paludis/default_config.cc19
-rw-r--r--paludis/default_config.hh3
-rw-r--r--paludis/dep_atom.hh2
-rw-r--r--paludis/dep_atom_flattener.hh2
-rw-r--r--paludis/dep_list.cc12
-rw-r--r--paludis/dep_list.hh5
-rw-r--r--paludis/ebuild.cc12
-rw-r--r--paludis/ebuild.hh6
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/portage_dep_lexer.hh2
-rw-r--r--paludis/qa/environment.cc15
-rw-r--r--paludis/repositories/nothing/nothing_repository.cc14
-rw-r--r--paludis/repositories/nothing/nothing_repository.hh2
-rw-r--r--paludis/repositories/portage/portage_repository.cc51
-rw-r--r--paludis/repositories/portage/portage_repository.hh2
-rw-r--r--paludis/repositories/portage/portage_repository_TEST.cc145
-rw-r--r--paludis/repositories/vdb/vdb_repository.cc12
-rw-r--r--paludis/repositories/vdb/vdb_repository.hh2
-rw-r--r--paludis/repositories/vdb/vdb_repository_TEST.cc22
-rw-r--r--paludis/repository.hh4
-rw-r--r--paludis/util/Makefile.am.m42
-rw-r--r--paludis/util/collection.hh100
-rw-r--r--paludis/util/collection_concrete.hh77
-rw-r--r--paludis/util/exception.cc6
-rw-r--r--paludis/util/exception.hh7
-rw-r--r--src/paludis/install.cc8
31 files changed, 393 insertions, 188 deletions
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index 651c7b3..0981cc7 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -74,5 +74,5 @@ comparison_policy.hh : comparison_policy.hh.m4
$(top_srcdir)/misc/do_m4.bash comparison_policy.hh.m4
ihateautomake.cc : all
- touch $@
+ test -f $@ || touch $@
diff --git a/paludis/config_file.cc b/paludis/config_file.cc
index 22b124a..0116a44 100644
--- a/paludis/config_file.cc
+++ b/paludis/config_file.cc
@@ -29,6 +29,7 @@
#include <fstream>
#include <istream>
#include <list>
+#include <map>
/** \file
* Implementation for config_file.hh classes.
@@ -240,29 +241,29 @@ KeyValueConfigFile::KeyValueConfigFile(const FSEntry & filename) :
}
KeyValueConfigFile::KeyValueConfigFile(std::istream * const s,
- const std::map<std::string, std::string> & m) :
+ AssociativeCollection<std::string, std::string>::ConstPointer m) :
ConfigFile(s),
PrivateImplementationPattern<KeyValueConfigFile>(new Implementation<KeyValueConfigFile>)
{
- _imp->entries.insert(m.begin(), m.end());
+ _imp->entries.insert(m->begin(), m->end());
need_lines();
}
KeyValueConfigFile::KeyValueConfigFile(const std::string & filename,
- const std::map<std::string, std::string> & m) :
+ AssociativeCollection<std::string, std::string>::ConstPointer m) :
ConfigFile(filename),
PrivateImplementationPattern<KeyValueConfigFile>(new Implementation<KeyValueConfigFile>)
{
- _imp->entries.insert(m.begin(), m.end());
+ _imp->entries.insert(m->begin(), m->end());
need_lines();
}
KeyValueConfigFile::KeyValueConfigFile(const FSEntry & filename,
- const std::map<std::string, std::string> & m) :
+ AssociativeCollection<std::string, std::string>::ConstPointer m) :
ConfigFile(filename),
PrivateImplementationPattern<KeyValueConfigFile>(new Implementation<KeyValueConfigFile>)
{
- _imp->entries.insert(m.begin(), m.end());
+ _imp->entries.insert(m->begin(), m->end());
need_lines();
}
@@ -421,6 +422,7 @@ AdvisoryFile::AdvisoryFile(const FSEntry & filename) :
sanitise();
}
+#if 0
AdvisoryFile::AdvisoryFile(std::istream * const s,
const std::map<std::string, std::string> & m) :
ConfigFile(s),
@@ -450,6 +452,7 @@ AdvisoryFile::AdvisoryFile(const FSEntry & filename,
need_lines();
sanitise();
}
+#endif
AdvisoryFile::~AdvisoryFile()
{
diff --git a/paludis/config_file.hh b/paludis/config_file.hh
index 4a95920..ee38639 100644
--- a/paludis/config_file.hh
+++ b/paludis/config_file.hh
@@ -20,15 +20,15 @@
#ifndef PALUDIS_GUARD_PALUDIS_CONFIG_FILE_HH
#define PALUDIS_GUARD_PALUDIS_CONFIG_FILE_HH 1
+#include <paludis/util/collection.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
-#include <libwrapiter/libwrapiter.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <iosfwd>
#include <string>
-#include <map>
/** \file
* Declarations for the ConfigFile classes.
@@ -253,19 +253,19 @@ namespace paludis
* Constructor, from a stream, with defaults.
*/
KeyValueConfigFile(std::istream * const,
- const std::map<std::string, std::string> &);
+ AssociativeCollection<std::string, std::string>::ConstPointer);
/**
* Constructor, from a filename, with defaults.
*/
KeyValueConfigFile(const std::string & filename,
- const std::map<std::string, std::string> &);
+ AssociativeCollection<std::string, std::string>::ConstPointer);
/**
* Constructor, from a filename, with defaults.
*/
KeyValueConfigFile(const FSEntry & filename,
- const std::map<std::string, std::string> &);
+ AssociativeCollection<std::string, std::string>::ConstPointer);
~KeyValueConfigFile();
@@ -352,23 +352,25 @@ namespace paludis
*/
AdvisoryFile(const FSEntry & filename);
+#if 0
/**
* Constructor, from a stream, with defaults.
*/
AdvisoryFile(std::istream * const,
- const std::map<std::string, std::string> &);
+ AssociativeCollection<std::string, std::string>::ConstPointer);
/**
* Constructor, from a filename, with defaults.
*/
AdvisoryFile(const std::string & filename,
- const std::map<std::string, std::string> &);
+ AssociativeCollection<std::string, std::string>::ConstPointer);
/**
* Constructor, from a filename, with defaults.
*/
AdvisoryFile(const FSEntry & filename,
- const std::map<std::string, std::string> &);
+ AssociativeCollection<std::string, std::string>::ConstPointer);
+#endif
~AdvisoryFile();
diff --git a/paludis/config_file_TEST.cc b/paludis/config_file_TEST.cc
index 0ac913a..02ae9e1 100644
--- a/paludis/config_file_TEST.cc
+++ b/paludis/config_file_TEST.cc
@@ -20,6 +20,7 @@
#include <paludis/config_file.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/collection_concrete.hh>
#include <sstream>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -234,10 +235,11 @@ namespace test_cases
TEST_CHECK_EQUAL(ff.get("z"), "foofoo\\$");
std::stringstream t;
- std::map<std::string, std::string> t_defs;
- t_defs.insert(std::make_pair("a", "moo"));
- t_defs.insert(std::make_pair("d", "bar"));
- t_defs.insert(std::make_pair("e", "baz"));
+ AssociativeCollection<std::string, std::string>::Pointer t_defs(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ t_defs->insert("a", "moo");
+ t_defs->insert("d", "bar");
+ t_defs->insert("e", "baz");
t << "a=foo" << std::endl;
t << "b=$a" << std::endl;
t << "c=$d" << std::endl;
diff --git a/paludis/contents.hh b/paludis/contents.hh
index f5265b5..34d143d 100644
--- a/paludis/contents.hh
+++ b/paludis/contents.hh
@@ -26,7 +26,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <string>
-#include <libwrapiter/libwrapiter.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
/** \file
* Declarations for the Contents classes.
diff --git a/paludis/default_config.cc b/paludis/default_config.cc
index 3d7dd0a..be91d04 100644
--- a/paludis/default_config.cc
+++ b/paludis/default_config.cc
@@ -19,6 +19,7 @@
#include <paludis/config_file.hh>
#include <paludis/default_config.hh>
+#include <paludis/util/collection_concrete.hh>
#include <paludis/util/destringify.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/iterator.hh>
@@ -33,6 +34,7 @@
#include <algorithm>
#include <sstream>
#include <list>
+#include <map>
#include <ctype.h>
@@ -154,8 +156,9 @@ DefaultConfig::DefaultConfig() :
_imp->root = root_prefix;
_imp->config_dir = stringify(config_dir);
- std::map<std::string, std::string> conf_vars;
- conf_vars.insert(std::make_pair("ROOT", root_prefix));
+ AssociativeCollection<std::string, std::string>::Pointer conf_vars(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ conf_vars->insert("ROOT", root_prefix);
Log::get_instance()->message(ll_debug, lc_no_context, "DefaultConfig real directory is '"
+ stringify(config_dir) + "', root prefix is '" + root_prefix +
@@ -192,9 +195,15 @@ DefaultConfig::DefaultConfig() :
if (! k.get("importance").empty())
importance = destringify<int>(k.get("importance"));
- std::map<std::string, std::string> keys(k.begin(), k.end());
- keys["repo_file"] = stringify(*repo_file);
- keys["root"] = root_prefix;
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete(k.begin(), k.end()));
+
+ keys->erase("repo_file");
+ keys->insert("repo_file", stringify(*repo_file));
+
+ keys->erase("root");
+ keys->insert("root", root_prefix);
+
_imp->repos.push_back(RepositoryConfigEntry(format, importance, keys));
}
diff --git a/paludis/default_config.hh b/paludis/default_config.hh
index 5b82a2e..cbb531e 100644
--- a/paludis/default_config.hh
+++ b/paludis/default_config.hh
@@ -22,6 +22,7 @@
#include <paludis/dep_atom.hh>
#include <paludis/name.hh>
+#include <paludis/util/collection.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/smart_record.hh>
@@ -85,7 +86,7 @@ namespace paludis
SmartRecordKeys<RepositoryConfigEntryKeys, last_rce>,
SmartRecordKey<rce_format, std::string>,
SmartRecordKey<rce_importance, unsigned>,
- SmartRecordKey<rce_keys, std::map<std::string, std::string> >
+ SmartRecordKey<rce_keys, AssociativeCollection<std::string, std::string>::Pointer >
{
};
diff --git a/paludis/dep_atom.hh b/paludis/dep_atom.hh
index 96a5480..3bbad78 100644
--- a/paludis/dep_atom.hh
+++ b/paludis/dep_atom.hh
@@ -29,7 +29,7 @@
#include <paludis/version_operator.hh>
#include <paludis/version_spec.hh>
-#include <libwrapiter/libwrapiter.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
/** \file
* Declarations for the DepAtom classes.
diff --git a/paludis/dep_atom_flattener.hh b/paludis/dep_atom_flattener.hh
index 609178e..fa2760f 100644
--- a/paludis/dep_atom_flattener.hh
+++ b/paludis/dep_atom_flattener.hh
@@ -26,7 +26,7 @@
#include <paludis/util/attributes.hh>
#include <paludis/util/instantiation_policy.hh>
-#include <libwrapiter/libwrapiter.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
/** \file
* Declarations for DepAtomFlattener.
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index 028b44b..57528fb 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.cc
@@ -21,6 +21,7 @@
#include <paludis/dep_atom_flattener.hh>
#include <paludis/dep_list.hh>
#include <paludis/match_package.hh>
+#include <paludis/util/collection_concrete.hh>
#include <paludis/util/iterator.hh>
#include <paludis/util/join.hh>
#include <paludis/util/log.hh>
@@ -31,6 +32,7 @@
#include <functional>
#include <deque>
#include <vector>
+#include <set>
using namespace paludis;
@@ -389,7 +391,7 @@ DepList::visit(const PackageDepAtom * const p)
}
if (p->tag())
- i->get<dle_tag>().insert(p->tag());
+ i->get<dle_tag>()->insert(p->tag());
return;
}
}
@@ -429,9 +431,10 @@ DepList::visit(const PackageDepAtom * const p)
}
std::list<DepListEntry>::iterator merge_entry;
- std::set<DepTag::ConstPointer, DepTag::Comparator> tags;
+ SortedCollection<DepTag::ConstPointer, DepTag::Comparator>::Pointer tags(
+ new SortedCollection<DepTag::ConstPointer, DepTag::Comparator>::Concrete);
if (p->tag())
- tags.insert(p->tag());
+ tags->insert(p->tag());
if (! match)
{
if (! installed->empty())
@@ -509,7 +512,8 @@ DepList::visit(const PackageDepAtom * const p)
_imp->merge_list.insert(next(merge_entry),
DepListEntry(pp.package(), merge_entry->get<dle_version>(),
p_metadata, merge_entry->get<dle_repository>(), flags,
- std::set<DepTag::ConstPointer, DepTag::Comparator>()));
+ SortedCollection<DepTag::ConstPointer, DepTag::Comparator>::Pointer(
+ new SortedCollection<DepTag::ConstPointer, DepTag::Comparator>::Concrete)));
}
}
diff --git a/paludis/dep_list.hh b/paludis/dep_list.hh
index 8793ff5..8d526d5 100644
--- a/paludis/dep_list.hh
+++ b/paludis/dep_list.hh
@@ -31,9 +31,8 @@
#include <iosfwd>
#include <bitset>
-#include <set>
-#include <libwrapiter/libwrapiter.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
namespace paludis
{
@@ -89,7 +88,7 @@ namespace paludis
SmartRecordKey<dle_metadata, VersionMetadata::ConstPointer>,
SmartRecordKey<dle_repository, RepositoryName>,
SmartRecordKey<dle_flags, DepListEntryFlags>,
- SmartRecordKey<dle_tag, std::set<DepTag::ConstPointer, DepTag::Comparator> >
+ SmartRecordKey<dle_tag, SortedCollection<DepTag::ConstPointer, DepTag::Comparator>::Pointer>
{
};
diff --git a/paludis/ebuild.cc b/paludis/ebuild.cc
index 3b83690..ab53d3a 100644
--- a/paludis/ebuild.cc
+++ b/paludis/ebuild.cc
@@ -270,9 +270,9 @@ EbuildFetchCommand::extend_command(const MakeEnvCommand & cmd)
("PALUDIS_PROFILE_DIRS", join(fetch_params.get<ecfpk_profiles>()->begin(),
fetch_params.get<ecfpk_profiles>()->end(), " ")));
- for (std::map<std::string, std::string>::const_iterator
- i(fetch_params.get<ecfpk_expand_vars>().begin()),
- j(fetch_params.get<ecfpk_expand_vars>().end()) ; i != j ; ++i)
+ for (AssociativeCollection<std::string, std::string>::Iterator
+ i(fetch_params.get<ecfpk_expand_vars>()->begin()),
+ j(fetch_params.get<ecfpk_expand_vars>()->end()) ; i != j ; ++i)
result = result(i->first, i->second);
return result;
@@ -318,9 +318,9 @@ EbuildInstallCommand::extend_command(const MakeEnvCommand & cmd)
install_params.get<ecipk_profiles>()->end(), " "))
("SLOT", stringify(install_params.get<ecipk_slot>())));
- for (std::map<std::string, std::string>::const_iterator
- i(install_params.get<ecipk_expand_vars>().begin()),
- j(install_params.get<ecipk_expand_vars>().end()) ; i != j ; ++i)
+ for (AssociativeCollection<std::string, std::string>::Iterator
+ i(install_params.get<ecipk_expand_vars>()->begin()),
+ j(install_params.get<ecipk_expand_vars>()->end()) ; i != j ; ++i)
result = result(i->first, i->second);
return result;
diff --git a/paludis/ebuild.hh b/paludis/ebuild.hh
index 6ca83e9..a9db44f 100644
--- a/paludis/ebuild.hh
+++ b/paludis/ebuild.hh
@@ -24,9 +24,9 @@
#include <paludis/util/smart_record.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/attributes.hh>
+#include <paludis/util/collection.hh>
#include <paludis/package_database.hh>
#include <string>
-#include <map>
/** \file
* Declarations for the EbuildCommand classes.
@@ -277,7 +277,7 @@ namespace paludis
SmartRecordKey<ecfpk_flat_src_uri, std::string>,
SmartRecordKey<ecfpk_root, std::string>,
SmartRecordKey<ecfpk_profiles, FSEntryCollection::ConstPointer>,
- SmartRecordKey<ecfpk_expand_vars, std::map<std::string, std::string> >,
+ SmartRecordKey<ecfpk_expand_vars, AssociativeCollection<std::string, std::string>::ConstPointer>,
SmartRecordKey<ecfpk_no_fetch, bool>
{
};
@@ -353,7 +353,7 @@ namespace paludis
SmartRecordKey<ecipk_use_expand, std::string>,
SmartRecordKey<ecipk_root, std::string>,
SmartRecordKey<ecipk_profiles, FSEntryCollection::ConstPointer>,
- SmartRecordKey<ecipk_expand_vars, std::map<std::string, std::string> >,
+ SmartRecordKey<ecipk_expand_vars, AssociativeCollection<std::string, std::string>::ConstPointer>,
SmartRecordKey<ecipk_disable_cfgpro, bool>,
SmartRecordKey<ecipk_merge_only, bool>,
SmartRecordKey<ecipk_slot, SlotName>
diff --git a/paludis/files.m4 b/paludis/files.m4
index b8159e3..dd6dc12 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -20,7 +20,7 @@ add(`dep_list', `hh', `cc', `test')
add(`dep_tag', `hh', `cc')
add(`ebuild', `hh', `cc')
add(`environment', `hh', `cc')
-add(`hashed_containers', `hh', `cc', `test')
+add(`hashed_containers', `hhx', `cc', `test')
add(`mask_reasons', `hh', `cc')
add(`match_package', `hh', `cc')
add(`name', `hh', `cc', `test')
diff --git a/paludis/portage_dep_lexer.hh b/paludis/portage_dep_lexer.hh
index 8aa3c78..678a774 100644
--- a/paludis/portage_dep_lexer.hh
+++ b/paludis/portage_dep_lexer.hh
@@ -25,7 +25,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <string>
-#include <libwrapiter/libwrapiter.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
/** \file
* Declarations for the PortageDepLexer class.
diff --git a/paludis/qa/environment.cc b/paludis/qa/environment.cc
index e19ff8c..44266f0 100644
--- a/paludis/qa/environment.cc
+++ b/paludis/qa/environment.cc
@@ -28,13 +28,14 @@ using namespace paludis::qa;
QAEnvironment::QAEnvironment(const FSEntry & base) :
Environment(PackageDatabase::Pointer(new PackageDatabase(this)))
{
- std::map<std::string, std::string> keys;
-
- keys.insert(std::make_pair(std::string("format"), std::string("portage")));
- keys.insert(std::make_pair(std::string("importace"), "1"));
- keys.insert(std::make_pair(std::string("location"), stringify(base)));
- keys.insert(std::make_pair(std::string("cache"), "/var/empty"));
- keys.insert(std::make_pair(std::string("profile"), stringify(base / "profiles" / "base")));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+
+ keys->insert("format", "portage");
+ keys->insert("importace", "1");
+ keys->insert("location", stringify(base));
+ keys->insert("cache", "/var/empty");
+ keys->insert("profile", stringify(base / "profiles" / "base"));
package_database()->add_repository(
RepositoryMaker::get_instance()->find_maker("portage")(this,
diff --git a/paludis/repositories/nothing/nothing_repository.cc b/paludis/repositories/nothing/nothing_repository.cc
index a1ec4e5..d640a75 100644
--- a/paludis/repositories/nothing/nothing_repository.cc
+++ b/paludis/repositories/nothing/nothing_repository.cc
@@ -170,28 +170,28 @@ CountedPtr<Repository>
NothingRepository::make_nothing_repository(
const Environment * const,
const PackageDatabase * const,
- const std::map<std::string, std::string> & m)
+ AssociativeCollection<std::string, std::string>::ConstPointer m)
{
- std::string repo_file(m.end() == m.find("repo_file") ? std::string("?") :
- m.find("repo_file")->second);
+ std::string repo_file(m->end() == m->find("repo_file") ? std::string("?") :
+ m->find("repo_file")->second);
Context context("When making Nothing repository from repo_file '" + repo_file + "':");
std::string location;
- if (m.end() == m.find("location") || ((location = m.find("location")->second)).empty())
+ if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
throw NothingRepositoryConfigurationError("Key 'location' not specified or empty");
std::string sync;
- if (m.end() == m.find("sync") || ((sync = m.find("sync")->second)).empty())
+ if (m->end() == m->find("sync") || ((sync = m->find("sync")->second)).empty())
; // nothing
std::string name;
- if (m.end() == m.find("name") || ((name = m.find("name")->second)).empty())
+ if (m->end() == m->find("name") || ((name = m->find("name")->second)).empty())
throw NothingRepositoryConfigurationError("Key 'name' not specified or empty in '"
+ repo_file + "'");
std::string sync_exclude;
- if (m.end() == m.find("sync_exclude") || ((sync_exclude = m.find("sync_exclude")->second)).empty())
+ if (m->end() == m->find("sync_exclude") || ((sync_exclude = m->find("sync_exclude")->second)).empty())
; // nothing
return CountedPtr<Repository>(new NothingRepository(NothingRepositoryParams::create((
diff --git a/paludis/repositories/nothing/nothing_repository.hh b/paludis/repositories/nothing/nothing_repository.hh
index f862250..8cee5c9 100644
--- a/paludis/repositories/nothing/nothing_repository.hh
+++ b/paludis/repositories/nothing/nothing_repository.hh
@@ -122,7 +122,7 @@ namespace paludis
static CountedPtr<Repository> make_nothing_repository(
const Environment * const env,
const PackageDatabase * const db,
- const std::map<std::string, std::string> &);
+ AssociativeCollection<std::string, std::string>::ConstPointer);
/**
* Destructor.
diff --git a/paludis/repositories/portage/portage_repository.cc b/paludis/repositories/portage/portage_repository.cc
index 5d4997c..3e02372 100644
--- a/paludis/repositories/portage/portage_repository.cc
+++ b/paludis/repositories/portage/portage_repository.cc
@@ -1180,28 +1180,28 @@ CountedPtr<Repository>
PortageRepository::make_portage_repository(
const Environment * const env,
const PackageDatabase * const db,
- const std::map<std::string, std::string> & m)
+ AssociativeCollection<std::string, std::string>::ConstPointer m)
{
- std::string repo_file(m.end() == m.find("repo_file") ? std::string("?") :
- m.find("repo_file")->second);
+ std::string repo_file(m->end() == m->find("repo_file") ? std::string("?") :
+ m->find("repo_file")->second);
Context context("When making Portage repository from repo_file '" + repo_file + "':");
std::string location;
- if (m.end() == m.find("location") || ((location = m.find("location")->second)).empty())
+ if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
throw PortageRepositoryConfigurationError("Key 'location' not specified or empty");
FSEntryCollection::Pointer profiles(new FSEntryCollection::Concrete);
- if (m.end() != m.find("profiles"))
- WhitespaceTokeniser::get_instance()->tokenise(m.find("profiles")->second,
+ if (m->end() != m->find("profiles"))
+ WhitespaceTokeniser::get_instance()->tokenise(m->find("profiles")->second,
create_inserter<FSEntry>(std::back_inserter(*profiles)));
- if (m.end() != m.find("profile") && ! m.find("profile")->second.empty())
+ if (m->end() != m->find("profile") && ! m->find("profile")->second.empty())
{
Log::get_instance()->message(ll_warning, lc_no_context,
"Key 'profile' in '" + repo_file + "' is deprecated, "
- "use 'profiles = " + m.find("profile")->second + "' instead");
+ "use 'profiles = " + m->find("profile")->second + "' instead");
if (profiles->empty())
- profiles->append(m.find("profile")->second);
+ profiles->append(m->find("profile")->second);
else
throw PortageRepositoryConfigurationError("Both 'profile' and 'profiles' keys are present");
}
@@ -1209,16 +1209,16 @@ PortageRepository::make_portage_repository(
throw PortageRepositoryConfigurationError("No profiles have been specified");
FSEntryCollection::Pointer eclassdirs(new FSEntryCollection::Concrete);
- if (m.end() != m.find("eclassdirs"))
- WhitespaceTokeniser::get_instance()->tokenise(m.find("eclassdirs")->second,
+ if (m->end() != m->find("eclassdirs"))
+ WhitespaceTokeniser::get_instance()->tokenise(m->find("eclassdirs")->second,
create_inserter<FSEntry>(std::back_inserter(*eclassdirs)));
- if (m.end() != m.find("eclassdir") && ! m.find("eclassdir")->second.empty())
+ if (m->end() != m->find("eclassdir") && ! m->find("eclassdir")->second.empty())
{
Log::get_instance()->message(ll_warning, lc_no_context,
"Key 'eclassdir' in '" + repo_file + "' is deprecated, "
- "use 'eclassdirs = " + m.find("eclassdir")->second + "' instead");
+ "use 'eclassdirs = " + m->find("eclassdir")->second + "' instead");
if (eclassdirs->empty())
- eclassdirs->append(m.find("eclassdir")->second);
+ eclassdirs->append(m->find("eclassdir")->second);
else
throw PortageRepositoryConfigurationError("Both 'eclassdir' and 'eclassdirs' keys are present");
}
@@ -1226,39 +1226,39 @@ PortageRepository::make_portage_repository(
eclassdirs->append(location + "/eclass");
std::string distdir;
- if (m.end() == m.find("distdir") || ((distdir = m.find("distdir")->second)).empty())
+ if (m->end() == m->find("distdir") || ((distdir = m->find("distdir")->second)).empty())
distdir = location + "/distfiles";
std::string setsdir;
- if (m.end() == m.find("setsdir") || ((setsdir = m.find("setsdir")->second)).empty())
+ if (m->end() == m->find("setsdir") || ((setsdir = m->find("setsdir")->second)).empty())
setsdir = location + "/sets";
std::string securitydir;
- if (m.end() == m.find("securitydir") || ((securitydir = m.find("securitydir")->second)).empty())
+ if (m->end() == m->find("securitydir") || ((securitydir = m->find("securitydir")->second)).empty())
securitydir = location + "/metadata/security";
std::string newsdir;
- if (m.end() == m.find("newsdir") || ((newsdir = m.find("newsdir")->second)).empty())
+ if (m->end() == m->find("newsdir") || ((newsdir = m->find("newsdir")->second)).empty())
newsdir = location + "/metadata/news";
std::string cache;
- if (m.end() == m.find("cache") || ((cache = m.find("cache")->second)).empty())
+ if (m->end() == m->find("cache") || ((cache = m->find("cache")->second)).empty())
cache = location + "/metadata/cache";
std::string sync;
- if (m.end() == m.find("sync") || ((sync = m.find("sync")->second)).empty())
+ if (m->end() == m->find("sync") || ((sync = m->find("sync")->second)).empty())
; // nothing
std::string sync_exclude;
- if (m.end() == m.find("sync_exclude") || ((sync_exclude = m.find("sync_exclude")->second)).empty())
+ if (m->end() == m->find("sync_exclude") || ((sync_exclude = m->find("sync_exclude")->second)).empty())
; // nothing
std::string root;
- if (m.end() == m.find("root") || ((root = m.find("root")->second)).empty())
+ if (m->end() == m->find("root") || ((root = m->find("root")->second)).empty())
root = "/";
std::string buildroot;
- if (m.end() == m.find("buildroot") || ((buildroot = m.find("buildroot")->second)).empty())
+ if (m->end() == m->find("buildroot") || ((buildroot = m->find("buildroot")->second)).empty())
buildroot = "/var/tmp/paludis";
return CountedPtr<Repository>(new PortageRepository(PortageRepositoryParams::create((
@@ -1652,7 +1652,8 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
use += stringify(*uu) + " ";
}
- std::map<std::string, std::string> expand_vars;
+ AssociativeCollection<std::string, std::string>::Pointer expand_vars(
+ new AssociativeCollection<std::string, std::string>::Concrete);
for (UseFlagSet::const_iterator u(_imp->expand_list.begin()),
u_end(_imp->expand_list.end()) ; u != u_end ; ++u)
{
@@ -1667,7 +1668,7 @@ PortageRepository::do_install(const QualifiedPackageName & q, const VersionSpec
xx != xx_end ; ++xx)
value.append(stringify(*xx).erase(0, stringify(*u).length() + 1) + " ");
- expand_vars.insert(std::make_pair(stringify(*u), value));
+ expand_vars->insert(stringify(*u), value);
}
/* Strip trailing space. Some ebuilds rely upon this. From kde-meta.eclass:
diff --git a/paludis/repositories/portage/portage_repository.hh b/paludis/repositories/portage/portage_repository.hh
index 85d0190..27ae3d5 100644
--- a/paludis/repositories/portage/portage_repository.hh
+++ b/paludis/repositories/portage/portage_repository.hh
@@ -190,7 +190,7 @@ namespace paludis
static CountedPtr<Repository> make_portage_repository(
const Environment * const env,
const PackageDatabase * const db,
- const std::map<std::string, std::string> &);
+ AssociativeCollection<std::string, std::string>::ConstPointer m);
/**
* Destructor.
diff --git a/paludis/repositories/portage/portage_repository_TEST.cc b/paludis/repositories/portage/portage_repository_TEST.cc
index f0b42f5..454928b 100644
--- a/paludis/repositories/portage/portage_repository_TEST.cc
+++ b/paludis/repositories/portage/portage_repository_TEST.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/repositories/portage/portage_repository.hh>
+#include <paludis/util/collection_concrete.hh>
#include <paludis/test_environment.hh>
#include <paludis/util/system.hh>
#include <test/test_framework.hh>
@@ -46,10 +47,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo1"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo1/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo1");
+ keys->insert("profile", "portage_repository_TEST_dir/repo1/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "test-repo-1");
@@ -68,10 +70,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo2"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo2/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo2");
+ keys->insert("profile", "portage_repository_TEST_dir/repo2/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "x-repo2");
@@ -90,10 +93,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo3"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo3/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo3");
+ keys->insert("profile", "portage_repository_TEST_dir/repo3/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "x-repo3");
@@ -112,10 +116,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo1"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo1/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo1");
+ keys->insert("profile", "portage_repository_TEST_dir/repo1/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -143,10 +148,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo1"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo1/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo1");
+ keys->insert("profile", "portage_repository_TEST_dir/repo1/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -176,10 +182,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo4"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo4/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo4");
+ keys->insert("profile", "portage_repository_TEST_dir/repo4/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -215,10 +222,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo4"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo4/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo4");
+ keys->insert("profile", "portage_repository_TEST_dir/repo4/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -258,10 +266,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo4"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo4/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo4");
+ keys->insert("profile", "portage_repository_TEST_dir/repo4/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -310,10 +319,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo5"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo5/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo5");
+ keys->insert("profile", "portage_repository_TEST_dir/repo5/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -343,10 +353,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo4"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo4/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo4");
+ keys->insert("profile", "portage_repository_TEST_dir/repo4/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -386,10 +397,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo4"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo4/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo4");
+ keys->insert("profile", "portage_repository_TEST_dir/repo4/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -428,10 +440,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo8"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo8/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo8");
+ keys->insert("profile", "portage_repository_TEST_dir/repo8/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -470,10 +483,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo6"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo6/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo6");
+ keys->insert("profile", "portage_repository_TEST_dir/repo6/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -511,10 +525,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo7"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo7/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo7");
+ keys->insert("profile", "portage_repository_TEST_dir/repo7/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -547,10 +562,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo7"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo7/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo7");
+ keys->insert("profile", "portage_repository_TEST_dir/repo7/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -577,10 +593,11 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "portage"));
- keys.insert(std::make_pair("location", "portage_repository_TEST_dir/repo9"));
- keys.insert(std::make_pair("profile", "portage_repository_TEST_dir/repo9/profiles/profile"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "portage");
+ keys->insert("location", "portage_repository_TEST_dir/repo9");
+ keys->insert("profile", "portage_repository_TEST_dir/repo9/profiles/profile");
PortageRepository::Pointer repo(PortageRepository::make_portage_repository(
&env, env.package_database().raw_pointer(), keys));
diff --git a/paludis/repositories/vdb/vdb_repository.cc b/paludis/repositories/vdb/vdb_repository.cc
index 79c67ad..7de78b8 100644
--- a/paludis/repositories/vdb/vdb_repository.cc
+++ b/paludis/repositories/vdb/vdb_repository.cc
@@ -677,25 +677,25 @@ CountedPtr<Repository>
VDBRepository::make_vdb_repository(
const Environment * const env,
const PackageDatabase * const db,
- const std::map<std::string, std::string> & m)
+ AssociativeCollection<std::string, std::string>::ConstPointer m)
{
Context context("When making VDB repository from repo_file '" +
- (m.end() == m.find("repo_file") ? std::string("?") : m.find("repo_file")->second) + "':");
+ (m->end() == m->find("repo_file") ? std::string("?") : m->find("repo_file")->second) + "':");
std::string location;
- if (m.end() == m.find("location") || ((location = m.find("location")->second)).empty())
+ if (m->end() == m->find("location") || ((location = m->find("location")->second)).empty())
throw VDBRepositoryConfigurationError("Key 'location' not specified or empty");
std::string root;
- if (m.end() == m.find("root") || ((root = m.find("root")->second)).empty())
+ if (m->end() == m->find("root") || ((root = m->find("root")->second)).empty())
root = "/";
std::string world;
- if (m.end() == m.find("world") || ((world = m.find("world")->second)).empty())
+ if (m->end() == m->find("world") || ((world = m->find("world")->second)).empty())
world = location + "/world";
std::string buildroot;
- if (m.end() == m.find("buildroot") || ((buildroot = m.find("buildroot")->second)).empty())
+ if (m->end() == m->find("buildroot") || ((buildroot = m->find("buildroot")->second)).empty())
buildroot = "/var/tmp/paludis";
return CountedPtr<Repository>(new VDBRepository(VDBRepositoryParams::create((
diff --git a/paludis/repositories/vdb/vdb_repository.hh b/paludis/repositories/vdb/vdb_repository.hh
index 4c0b407..18bb536 100644
--- a/paludis/repositories/vdb/vdb_repository.hh
+++ b/paludis/repositories/vdb/vdb_repository.hh
@@ -151,7 +151,7 @@ namespace paludis
static CountedPtr<Repository> make_vdb_repository(
const Environment * const env,
const PackageDatabase * const db,
- const std::map<std::string, std::string> &);
+ AssociativeCollection<std::string, std::string>::ConstPointer m);
/**
* Destructor.
diff --git a/paludis/repositories/vdb/vdb_repository_TEST.cc b/paludis/repositories/vdb/vdb_repository_TEST.cc
index 5ec49ce..5381f7b 100644
--- a/paludis/repositories/vdb/vdb_repository_TEST.cc
+++ b/paludis/repositories/vdb/vdb_repository_TEST.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/repositories/vdb/vdb_repository.hh>
+#include <paludis/util/collection_concrete.hh>
#include <paludis/test_environment.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
@@ -45,9 +46,10 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "vdb"));
- keys.insert(std::make_pair("location", "vdb_repository_TEST_dir/repo1"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "vdb");
+ keys->insert("location", "vdb_repository_TEST_dir/repo1");
VDBRepository::Pointer repo(VDBRepository::make_vdb_repository(
&env, env.package_database().raw_pointer(), keys));
TEST_CHECK_STRINGIFY_EQUAL(repo->name(), "installed");
@@ -66,9 +68,10 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "vdb"));
- keys.insert(std::make_pair("location", "vdb_repository_TEST_dir/repo1"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "vdb");
+ keys->insert("location", "vdb_repository_TEST_dir/repo1");
VDBRepository::Pointer repo(VDBRepository::make_vdb_repository(
&env, env.package_database().raw_pointer(), keys));
@@ -90,9 +93,10 @@ namespace test_cases
void run()
{
TestEnvironment env;
- std::map<std::string, std::string> keys;
- keys.insert(std::make_pair("format", "vdb"));
- keys.insert(std::make_pair("location", "vdb_repository_TEST_dir/repo1"));
+ AssociativeCollection<std::string, std::string>::Pointer keys(
+ new AssociativeCollection<std::string, std::string>::Concrete);
+ keys->insert("format", "vdb");
+ keys->insert("location", "vdb_repository_TEST_dir/repo1");
VDBRepository::Pointer repo(VDBRepository::make_vdb_repository(
&env, env.package_database().raw_pointer(), keys));
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 32bf972..fe12323 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -34,7 +34,7 @@
#include <string>
#include <map>
-#include <libwrapiter/libwrapiter.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
/** \file
* Declarations for the Repository class.
@@ -934,7 +934,7 @@ namespace paludis
*/
typedef VirtualConstructor<std::string,
Repository::Pointer (*) (const Environment * const, const PackageDatabase * const,
- const std::map<std::string, std::string> &),
+ AssociativeCollection<std::string, std::string>::ConstPointer),
virtual_constructor_not_found::ThrowException<NoSuchRepositoryTypeError> > RepositoryMaker;
}
diff --git a/paludis/util/Makefile.am.m4 b/paludis/util/Makefile.am.m4
index f548c87..bfec909 100644
--- a/paludis/util/Makefile.am.m4
+++ b/paludis/util/Makefile.am.m4
@@ -14,10 +14,12 @@ $1_TEST_CXXFLAGS = -I$(top_srcdir)
')dnl
define(`addtestscript', `define(`testscriptlist', testscriptlist `$1_TEST_setup.sh $1_TEST_cleanup.sh')')dnl
define(`addhh', `define(`filelist', filelist `$1.hh')define(`headerlist', headerlist `$1.hh')')dnl
+define(`addhhx', `define(`filelist', filelist `$1.hh')')dnl
define(`addcc', `define(`filelist', filelist `$1.cc')')dnl
define(`addimpl', `define(`filelist', filelist `$1-impl.hh')')dnl
define(`addthis', `dnl
ifelse(`$2', `hh', `addhh(`$1')', `')dnl
+ifelse(`$2', `hhx', `addhhx(`$1')', `')dnl
ifelse(`$2', `cc', `addcc(`$1')', `')dnl
ifelse(`$2', `impl', `addimpl(`$1')', `')dnl
ifelse(`$2', `test', `addtest(`$1')', `')dnl
diff --git a/paludis/util/collection.hh b/paludis/util/collection.hh
index 84a05b3..9fa6727 100644
--- a/paludis/util/collection.hh
+++ b/paludis/util/collection.hh
@@ -22,8 +22,9 @@
#include <paludis/util/counted_ptr.hh>
#include <paludis/util/instantiation_policy.hh>
-#include <iterator>
#include <libwrapiter/libwrapiter.hh>
+#include <iterator>
+#include <functional>
/** \file
* Various wrappers around collections of items, for convenience and
@@ -135,12 +136,12 @@ namespace paludis
*
* \ingroup grpcollections
*/
- template <typename T_>
+ template <typename T_, typename C_ = std::less<T_> >
class SortedCollection :
- private InstantiationPolicy<SortedCollection<T_>, instantiation_method::NonCopyableTag>,
- public InternalCounted<SortedCollection<T_> >,
+ private InstantiationPolicy<SortedCollection<T_, C_>, instantiation_method::NonCopyableTag>,
+ public InternalCounted<SortedCollection<T_, C_> >,
public std::iterator<typename std::iterator_traits<
- typename libwrapiter::ForwardIterator<SequentialCollection<T_>, const T_> >::iterator_category, T_>
+ typename libwrapiter::ForwardIterator<SortedCollection<T_, C_>, const T_> >::iterator_category, T_>
{
protected:
///\name Basic operations
@@ -167,7 +168,7 @@ namespace paludis
///\name Iterate over our items
///\{
- typedef libwrapiter::ForwardIterator<SortedCollection<T_>, const T_> Iterator;
+ typedef libwrapiter::ForwardIterator<SortedCollection<T_, C_>, const T_> Iterator;
virtual Iterator begin() const = 0;
@@ -207,12 +208,12 @@ namespace paludis
/**
* Insert all items from another container.
*/
- virtual bool merge(typename SortedCollection<T_>::ConstPointer o) = 0;
+ virtual bool merge(typename SortedCollection<T_, C_>::ConstPointer o) = 0;
/**
* Our insert iterator type.
*/
- typedef libwrapiter::OutputIterator<SortedCollection<T_>, T_> Inserter;
+ typedef libwrapiter::OutputIterator<SortedCollection<T_, C_>, T_> Inserter;
/**
* Fetch an inserter.
@@ -236,6 +237,89 @@ namespace paludis
///\}
};
+
+ /**
+ * Wrapper around a std::map of a particular item.
+ *
+ * This item cannot be constructed. Use AssociativeCollection::Concrete,
+ * which requires including paludis/util/collection_concrete.hh .
+ *
+ * \ingroup grpcollections
+ */
+ template <typename K_, typename V_>
+ class AssociativeCollection :
+ private InstantiationPolicy<AssociativeCollection<K_, V_>, instantiation_method::NonCopyableTag>,
+ public InternalCounted<AssociativeCollection<K_, V_> >,
+ public std::iterator<typename std::iterator_traits<
+ typename libwrapiter::ForwardIterator<AssociativeCollection<K_, V_>,
+ const std::pair<const K_, V_> > >::iterator_category, const std::pair<const K_, V_> >
+ {
+ protected:
+ ///\name Basic operations
+ ///\{
+
+ AssociativeCollection()
+ {
+ }
+
+ ///\}
+
+ public:
+ class Concrete;
+
+ ///\name Basic operations
+ ///\{
+
+ virtual ~AssociativeCollection()
+ {
+ }
+
+ ///\}
+
+ ///\name Iterate over our items
+ ///\{
+
+ typedef libwrapiter::ForwardIterator<AssociativeCollection<K_, V_>,
+ const std::pair<const K_, V_> > Iterator;
+
+ virtual Iterator begin() const = 0;
+
+ virtual Iterator end() const = 0;
+
+ ///\}
+
+ ///\name Finding items
+ ///\{
+
+ virtual Iterator find(const K_ & v) const = 0;
+
+ ///\}
+
+ ///\name Adding, removing and modifying items
+ ///\{
+
+ /**
+ * Insert an item, return whether we succeeded.
+ */
+ virtual bool insert(const K_ & k, const V_ & v) = 0;
+
+ /**
+ * Erase an item, return whether we succeeded.
+ */
+ virtual bool erase(const K_ & k) = 0;
+
+ ///\}
+
+ ///\name Queries
+ ///\{
+
+ /**
+ * Are we empty?
+ */
+ virtual bool empty() const = 0;
+
+ ///\}
+ };
}
#endif
diff --git a/paludis/util/collection_concrete.hh b/paludis/util/collection_concrete.hh
index f3370d2..ae09111 100644
--- a/paludis/util/collection_concrete.hh
+++ b/paludis/util/collection_concrete.hh
@@ -23,6 +23,7 @@
#include <paludis/util/collection.hh>
#include <list>
#include <set>
+#include <map>
#include <algorithm>
/** \file
@@ -111,12 +112,12 @@ namespace paludis
* \see SortedCollection
* \ingroup grpcollections
*/
- template <typename T_>
- class SortedCollection<T_>::Concrete :
- public SortedCollection<T_>
+ template <typename T_, typename C_ = std::less<T_> >
+ class SortedCollection<T_, C_>::Concrete :
+ public SortedCollection<T_, C_>
{
private:
- std::set<T_> _items;
+ std::set<T_, C_> _items;
public:
///\name Basic operations
@@ -154,7 +155,7 @@ namespace paludis
virtual Iterator last() const
{
- typename std::set<T_>::const_iterator result(_items.end());
+ typename std::set<T_, C_>::const_iterator result(_items.end());
if (result != _items.begin())
--result;
return Iterator(result);
@@ -175,7 +176,7 @@ namespace paludis
return 0 != _items.erase(v);
}
- virtual bool merge(typename SortedCollection<T_>::ConstPointer o)
+ virtual bool merge(typename SortedCollection<T_, C_>::ConstPointer o)
{
bool result(true);
Iterator o_begin(o->begin()), o_end(o->end());
@@ -199,6 +200,70 @@ namespace paludis
return _items.size();
}
};
+
+ /**
+ * Concrete implementation for an AssociativeCollection.
+ *
+ * \see AssociativeCollection
+ * \ingroup grpcollections
+ */
+ template <typename K_, typename V_>
+ class AssociativeCollection<K_, V_>::Concrete :
+ public AssociativeCollection<K_, V_>
+ {
+ private:
+ std::map<K_, V_> _items;
+
+ public:
+ ///\name Basic operations
+ ///\{
+
+ Concrete()
+ {
+ }
+
+ template <typename I_>
+ Concrete(const I_ & b, const I_ & b_end) :
+ _items(b, b_end)
+ {
+ }
+
+ virtual ~Concrete()
+ {
+ }
+
+ ///\}
+
+ virtual Iterator begin() const
+ {
+ return Iterator(_items.begin());
+ }
+
+ virtual Iterator end() const
+ {
+ return Iterator(_items.end());
+ }
+
+ virtual Iterator find(const K_ & v) const
+ {
+ return Iterator(_items.find(v));
+ }
+
+ virtual bool insert(const K_ & k, const V_ & v)
+ {
+ return _items.insert(std::make_pair(k, v)).second;
+ }
+
+ virtual bool erase(const K_ & k)
+ {
+ return 0 != _items.erase(k);
+ }
+
+ virtual bool empty() const
+ {
+ return _items.empty();
+ }
+ };
}
#endif
diff --git a/paludis/util/exception.cc b/paludis/util/exception.cc
index 68fcaa6..9ed7a57 100644
--- a/paludis/util/exception.cc
+++ b/paludis/util/exception.cc
@@ -82,6 +82,12 @@ Exception::~Exception() throw ()
delete _context_data;
}
+bool
+Exception::empty() const
+{
+ return _context_data->empty();
+}
+
const std::string &
Exception::message() const throw ()
{
diff --git a/paludis/util/exception.hh b/paludis/util/exception.hh
index 06fcebe..5731902 100644
--- a/paludis/util/exception.hh
+++ b/paludis/util/exception.hh
@@ -21,7 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_EXCEPTION_HH 1
#include <paludis/util/attributes.hh>
-#include <libwrapiter/libwrapiter.hh>
+#include <libwrapiter/libwrapiter_forward_iterator.hh>
#include <string>
#include <exception>
@@ -116,6 +116,11 @@ namespace paludis
* Make a backtrace.
*/
std::string backtrace(const std::string & delim) const;
+
+ /**
+ * Is our backtrace empty?
+ */
+ bool empty() const;
};
/**
diff --git a/src/paludis/install.cc b/src/paludis/install.cc
index 55241a5..2a22140 100644
--- a/src/paludis/install.cc
+++ b/src/paludis/install.cc
@@ -319,12 +319,12 @@ do_install()
}
/* display tag, add tag to our post display list */
- if (! dep->get<p::dle_tag>().empty())
+ if (! dep->get<p::dle_tag>()->empty())
{
std::string tag_titles;
- for (std::set<p::DepTag::ConstPointer, p::DepTag::Comparator>::const_iterator
- tag(dep->get<p::dle_tag>().begin()),
- tag_end(dep->get<p::dle_tag>().end()) ;
+ for (p::SortedCollection<p::DepTag::ConstPointer, p::DepTag::Comparator>::Iterator
+ tag(dep->get<p::dle_tag>()->begin()),
+ tag_end(dep->get<p::dle_tag>()->end()) ;
tag != tag_end ; ++tag)
{
all_tags.insert(*tag);