aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-17 07:51:52 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2007-04-17 07:51:52 +0000
commit8f2289d6ab26f6ef1720e750b7568f4443b1c696 (patch)
treea08b208c85cd39a6c5b8af6a7c536a5ad7b738c9
parentfcdbe6272a75949475fc92a2fb9d2fb45f24afc7 (diff)
downloadpaludis-8f2289d6ab26f6ef1720e750b7568f4443b1c696.tar.gz
paludis-8f2289d6ab26f6ef1720e750b7568f4443b1c696.tar.xz
Various interface cleanups
-rw-r--r--paludis/Makefile.am.m48
-rw-r--r--paludis/dep_spec.cc1
-rw-r--r--paludis/dep_spec_TEST.cc1
-rw-r--r--paludis/dep_tag.cc4
-rw-r--r--paludis/environments/environment_maker.cc9
-rw-r--r--paludis/environments/paludis/paludis_config.cc46
-rw-r--r--paludis/environments/paludis/paludis_environment.cc4
-rw-r--r--paludis/environments/portage/Makefile.am1
-rw-r--r--paludis/hooker.cc4
-rw-r--r--paludis/qa/broken_global_variables_check.cc2
-rw-r--r--paludis/qa/defaults_check.cc2
-rw-r--r--paludis/qa/deprecated_functions_check.cc4
-rw-r--r--paludis/qa/digest_collisions_check.cc9
-rw-r--r--paludis/qa/ebuild_check.cc7
-rw-r--r--paludis/qa/ebuild_count_check.cc10
-rw-r--r--paludis/qa/file_check.cc5
-rw-r--r--paludis/qa/function_check.cc4
-rw-r--r--paludis/qa/has_ebuilds_check.cc9
-rw-r--r--paludis/qa/header_check.cc4
-rw-r--r--paludis/qa/package_dir_check.cc7
-rw-r--r--paludis/qa/per_profile_ebuild_check.cc6
-rw-r--r--paludis/qa/profile_check.cc6
-rw-r--r--paludis/qa/profiles_check.cc6
-rw-r--r--paludis/qa/root_check.cc2
-rw-r--r--paludis/qa/subshell_die_check.cc4
-rw-r--r--paludis/qa/variable_assigns_check.cc6
-rw-r--r--paludis/qa/whitespace_check.cc8
-rw-r--r--paludis/repositories/cran/Makefile.am1
-rw-r--r--paludis/repositories/gems/Makefile.am1
-rw-r--r--paludis/repositories/gentoo/Makefile.am1
-rw-r--r--paludis/repositories/gentoo/portage_repository.cc9
-rw-r--r--paludis/repositories/gentoo/portage_repository_entries.cc6
-rw-r--r--paludis/repositories/gentoo/portage_repository_profile.cc1
-rw-r--r--paludis/repositories/gentoo/portage_repository_sets.cc8
-rw-r--r--paludis/repositories/gentoo/use_desc.cc2
-rw-r--r--paludis/repositories/repository_maker.cc10
-rw-r--r--paludis/repositories/virtuals/Makefile.am1
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc1
-rw-r--r--paludis/util/Makefile.am.m434
-rw-r--r--paludis/util/files.m44
-rw-r--r--paludis/util/is_file_with_extension.cc42
-rw-r--r--paludis/util/is_file_with_extension.hh46
-rw-r--r--paludis/util/is_file_with_extension.se23
-rw-r--r--paludis/util/is_file_with_extension_TEST.cc25
-rw-r--r--paludis/util/strip.hh15
-rw-r--r--paludis/util/strip_TEST.cc49
-rw-r--r--paludis/util/virtual_constructor-impl.hh153
-rw-r--r--paludis/util/virtual_constructor.hh113
-rw-r--r--paludis/util/virtual_constructor_TEST.cc1
-rw-r--r--ruby/check.cc1
-rw-r--r--src/clients/adjutrix/display_profiles_use.cc2
-rw-r--r--src/clients/adjutrix/downgrade_check.cc1
-rw-r--r--src/clients/inquisitio/extractor.cc5
-rw-r--r--src/clients/inquisitio/matcher.cc5
-rw-r--r--src/clients/paludis/applets.cc1
-rw-r--r--src/clients/qualudis/qualudis.cc14
56 files changed, 501 insertions, 253 deletions
diff --git a/paludis/Makefile.am.m4 b/paludis/Makefile.am.m4
index 688e15c..a37694e 100644
--- a/paludis/Makefile.am.m4
+++ b/paludis/Makefile.am.m4
@@ -36,20 +36,20 @@ define(`addsr', `define(`srlist', srlist `$1.sr')dnl
define(`srcleanlist', srcleanlist `$1-sr.hh $1-sr.cc')dnl
define(`srheaderlist', srheaderlist `$1-sr.hh')dnl
$1-sr.hh : $1.sr $(top_srcdir)/misc/make_sr.bash
- $(top_srcdir)/misc/make_sr.bash --header $`'(srcdir)/$1.sr > $`'@
+ if ! $(top_srcdir)/misc/make_sr.bash --header $`'(srcdir)/$1.sr > $`'@ ; then rm -f $`'@ ; exit 1 ; fi
$1-sr.cc : $1.sr $(top_srcdir)/misc/make_sr.bash
- $(top_srcdir)/misc/make_sr.bash --source $`'(srcdir)/$1.sr > $`'@
+ if ! $(top_srcdir)/misc/make_sr.bash --source $`'(srcdir)/$1.sr > $`'@ ; then rm -f $`'@ ; exit 1 ; fi
')dnl
define(`addse', `define(`selist', selist `$1.se')dnl
define(`secleanlist', secleanlist `$1-se.hh $1-se.cc')dnl
define(`seheaderlist', seheaderlist `$1-se.hh')dnl
$1-se.hh : $1.se $(top_srcdir)/misc/make_se.bash
- $(top_srcdir)/misc/make_se.bash --header $`'(srcdir)/$1.se > $`'@
+ if ! $(top_srcdir)/misc/make_se.bash --header $`'(srcdir)/$1.se > $`'@ ; them rm -f $`'@ ; exit 1 ; fi
$1-se.cc : $1.se $(top_srcdir)/misc/make_se.bash
- $(top_srcdir)/misc/make_se.bash --source $`'(srcdir)/$1.se > $`'@
+ if ! $(top_srcdir)/misc/make_se.bash --source $`'(srcdir)/$1.se > $`'@ ; then rm -f $`'@ ; exit 1 ; fi
')dnl
define(`addthis', `dnl
diff --git a/paludis/dep_spec.cc b/paludis/dep_spec.cc
index e0546cb..392bb1d 100644
--- a/paludis/dep_spec.cc
+++ b/paludis/dep_spec.cc
@@ -20,6 +20,7 @@
#include <paludis/dep_spec.hh>
#include <paludis/util/log.hh>
#include <paludis/util/collection_concrete.hh>
+#include <paludis/util/iterator.hh>
#include <list>
#include <map>
diff --git a/paludis/dep_spec_TEST.cc b/paludis/dep_spec_TEST.cc
index 341670d..ac72c68 100644
--- a/paludis/dep_spec_TEST.cc
+++ b/paludis/dep_spec_TEST.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/dep_spec.hh>
+#include <paludis/util/iterator.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
diff --git a/paludis/dep_tag.cc b/paludis/dep_tag.cc
index 2e966f7..faf10bf 100644
--- a/paludis/dep_tag.cc
+++ b/paludis/dep_tag.cc
@@ -19,6 +19,7 @@
#include "dep_tag.hh"
#include <paludis/util/compare.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
/** \file
* Implementation for DepTag, DepTagCategory etc.
@@ -28,6 +29,9 @@
using namespace paludis;
+template class VirtualConstructor<std::string, std::tr1::shared_ptr<const DepTagCategory> (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchDepTagCategory> >;
+
#include <paludis/dep_tag-sr.cc>
namespace
diff --git a/paludis/environments/environment_maker.cc b/paludis/environments/environment_maker.cc
index f936baa..5bf897b 100644
--- a/paludis/environments/environment_maker.cc
+++ b/paludis/environments/environment_maker.cc
@@ -22,6 +22,7 @@
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/is_file_with_extension.hh>
#include <paludis/util/system.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
#include <paludis/about.hh>
#include <list>
#include <set>
@@ -30,6 +31,10 @@
using namespace paludis;
+template class VirtualConstructor<std::string,
+ std::tr1::shared_ptr<Environment> (*) (const std::string &),
+ virtual_constructor_not_found::ThrowException<NoSuchEnvironmentTypeError> >;
+
NoSuchEnvironmentTypeError::NoSuchEnvironmentTypeError(const std::string & format) throw ():
ConfigurationError("No available maker for environment type '" + format + "'")
{
@@ -78,8 +83,8 @@ EnvironmentMaker::load_dir(const FSEntry & so_dir)
if (d->is_directory())
load_dir(*d);
- if (! IsFileWithExtension(".so." + stringify(100 * PALUDIS_VERSION_MAJOR +
- PALUDIS_VERSION_MINOR))(*d))
+ if (! is_file_with_extension(*d, ".so." + stringify(100 * PALUDIS_VERSION_MAJOR + PALUDIS_VERSION_MINOR),
+ IsFileWithOptions()))
continue;
/* don't use RTLD_LOCAL, g++ is over happy about template instantiations, and it
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index d932230..5405d10 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -34,11 +34,13 @@
#include <paludis/util/system.hh>
#include <paludis/util/tokeniser.hh>
+#include <tr1/functional>
#include <fstream>
#include <algorithm>
#include <sstream>
#include <list>
#include <map>
+#include <vector>
#include <ctype.h>
#include <sys/types.h>
@@ -317,6 +319,8 @@ PaludisConfigNoDirectoryError::PaludisConfigNoDirectoryError(const std::string &
PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & suffix) :
PrivateImplementationPattern<PaludisConfig>(new Implementation<PaludisConfig>(e))
{
+ using namespace std::tr1::placeholders;
+
Context context("When loading paludis configuration:");
/* indirection */
@@ -424,9 +428,9 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
continue;
std::copy(DirIterator(*dir), DirIterator(),
- filter_inserter(std::back_inserter(repo_files), IsFileWithExtension(".conf")));
+ filter_inserter(std::back_inserter(repo_files), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
std::copy(DirIterator(*dir), DirIterator(),
- filter_inserter(std::back_inserter(repo_files), IsFileWithExtension(".bash")));
+ filter_inserter(std::back_inserter(repo_files), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
std::list<std::tr1::shared_ptr<AssociativeCollection<std::string, std::string> > > later_keys;
@@ -436,7 +440,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
Context local_context("When reading repository file '" + stringify(*repo_file) + "':");
std::tr1::shared_ptr<KeyValueConfigFile> kv;
- if (IsFileWithExtension(".bash")(*repo_file))
+ if (is_file_with_extension(*repo_file, ".bash", IsFileWithOptions()))
{
Command cmd(Command("bash '" + stringify(*repo_file) + "'")
.with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
@@ -508,9 +512,9 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if ((local_config_dir / "keywords.conf.d").exists())
{
std::copy(DirIterator(local_config_dir / "keywords.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), IsFileWithExtension(".conf")));
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
std::copy(DirIterator(local_config_dir / "keywords.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), IsFileWithExtension(".bash")));
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
for (std::list<FSEntry>::const_iterator file(files.begin()), file_end(files.end()) ;
@@ -522,7 +526,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
continue;
std::tr1::shared_ptr<LineConfigFile> f;
- if (IsFileWithExtension(".bash")(*file))
+ if (is_file_with_extension(*file, ".bash", IsFileWithOptions()))
{
Command cmd(Command("bash '" + stringify(*file) + "'")
.with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
@@ -591,9 +595,9 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if ((local_config_dir / "licenses.conf.d").exists())
{
std::copy(DirIterator(local_config_dir / "licenses.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), IsFileWithExtension(".conf")));
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
std::copy(DirIterator(local_config_dir / "licenses.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), IsFileWithExtension(".bash")));
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
for (std::list<FSEntry>::const_iterator file(files.begin()), file_end(files.end()) ;
@@ -605,7 +609,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
continue;
std::tr1::shared_ptr<LineConfigFile> f;
- if (IsFileWithExtension(".bash")(*file))
+ if (is_file_with_extension(*file, ".bash", IsFileWithOptions()))
{
Command cmd(Command("bash '" + stringify(*file) + "'")
.with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
@@ -672,9 +676,9 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if ((local_config_dir / "package_mask.conf.d").exists())
{
std::copy(DirIterator(local_config_dir / "package_mask.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), IsFileWithExtension(".conf")));
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
std::copy(DirIterator(local_config_dir / "package_mask.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), IsFileWithExtension(".bash")));
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
for (std::list<FSEntry>::const_iterator file(files.begin()), file_end(files.end()) ;
@@ -687,7 +691,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
std::tr1::shared_ptr<LineConfigFile> f;
- if (IsFileWithExtension(".bash")(*file))
+ if (is_file_with_extension(*file, ".bash", IsFileWithOptions()))
{
Command cmd(Command("bash '" + stringify(*file) + "'")
.with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
@@ -740,9 +744,9 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if ((local_config_dir / "package_unmask.conf.d").exists())
{
std::copy(DirIterator(local_config_dir / "package_unmask.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), IsFileWithExtension(".conf")));
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
std::copy(DirIterator(local_config_dir / "package_unmask.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), IsFileWithExtension(".bash")));
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
for (std::list<FSEntry>::const_iterator file(files.begin()), file_end(files.end()) ;
@@ -755,7 +759,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
std::tr1::shared_ptr<LineConfigFile> f;
- if (IsFileWithExtension(".bash")(*file))
+ if (is_file_with_extension(*file, ".bash", IsFileWithOptions()))
{
Command cmd(Command("bash '" + stringify(*file) + "'")
.with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
@@ -808,9 +812,9 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if ((local_config_dir / "use.conf.d").exists())
{
std::copy(DirIterator(local_config_dir / "use.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), IsFileWithExtension(".conf")));
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
std::copy(DirIterator(local_config_dir / "use.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), IsFileWithExtension(".bash")));
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
for (std::list<FSEntry>::const_iterator file(files.begin()), file_end(files.end()) ;
@@ -823,7 +827,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
std::tr1::shared_ptr<LineConfigFile> f;
- if (IsFileWithExtension(".bash")(*file))
+ if (is_file_with_extension(*file, ".bash", IsFileWithOptions()))
{
Command cmd(Command("bash '" + stringify(*file) + "'")
.with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
@@ -968,9 +972,9 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
if ((local_config_dir / "mirrors.conf.d").exists())
{
std::copy(DirIterator(local_config_dir / "mirrors.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), IsFileWithExtension(".conf")));
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".conf", IsFileWithOptions())));
std::copy(DirIterator(local_config_dir / "mirrors.conf.d"), DirIterator(),
- filter_inserter(std::back_inserter(files), IsFileWithExtension(".bash")));
+ filter_inserter(std::back_inserter(files), std::tr1::bind(&is_file_with_extension, _1, ".bash", IsFileWithOptions())));
}
for (std::list<FSEntry>::const_iterator file(files.begin()), file_end(files.end()) ;
@@ -983,7 +987,7 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
std::tr1::shared_ptr<LineConfigFile> f;
- if (IsFileWithExtension(".bash")(*file))
+ if (is_file_with_extension(*file, ".bash", IsFileWithOptions()))
{
Command cmd(Command("bash '" + stringify(*file) + "'")
.with_setenv("PALUDIS_LOG_LEVEL", stringify(Log::get_instance()->log_level()))
diff --git a/paludis/environments/paludis/paludis_environment.cc b/paludis/environments/paludis/paludis_environment.cc
index e550cd5..6757392 100644
--- a/paludis/environments/paludis/paludis_environment.cc
+++ b/paludis/environments/paludis/paludis_environment.cc
@@ -677,9 +677,9 @@ PaludisEnvironment::sets_list() const
for (DirIterator d(FSEntry(_imp->config->config_dir()) / "sets"), d_end ;
d != d_end ; ++d)
{
- if (IsFileWithExtension(".conf")(*d))
+ if (is_file_with_extension(*d, ".conf", IsFileWithOptions()))
result->insert(SetName(strip_trailing_string(d->basename(), ".conf")));
- else if (IsFileWithExtension(".bash")(*d))
+ else if (is_file_with_extension(*d, ".bash", IsFileWithOptions()))
result->insert(SetName(strip_trailing_string(d->basename(), ".bash")));
}
diff --git a/paludis/environments/portage/Makefile.am b/paludis/environments/portage/Makefile.am
index e05eb1d..12af891 100644
--- a/paludis/environments/portage/Makefile.am
+++ b/paludis/environments/portage/Makefile.am
@@ -16,6 +16,7 @@ libpaludisportageenvironment_la_SOURCES = \
libpaludisportageenvironment_la_LDFLAGS = -version-info @VERSION_LIB_CURRENT@:@VERSION_LIB_REVISION@:0
libpaludisportageenvironment_la_LIBADD = \
+ $(top_builddir)/paludis/environments/libpaludisenvironments.la \
$(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/libpaludis.la
diff --git a/paludis/hooker.cc b/paludis/hooker.cc
index c8443a4..5fa7b9f 100644
--- a/paludis/hooker.cc
+++ b/paludis/hooker.cc
@@ -320,14 +320,14 @@ Hooker::perform_hook(const Hook & hook) const
for (DirIterator e(d->first / hook.name()), e_end ; e != e_end ; ++e)
{
- if (IsFileWithExtension(".bash")(*e))
+ if (is_file_with_extension(*e, ".bash", IsFileWithOptions()))
if (! hook_files.insert(std::make_pair(strip_trailing_string(e->basename(), ".bash"),
std::tr1::shared_ptr<HookFile>(new BashHookFile(*e, d->second, _imp->env)))).second)
Log::get_instance()->message(ll_warning, lc_context, "Discarding hook file '" + stringify(*e)
+ "' because of naming conflict with '" + stringify(
hook_files.find(stringify(strip_trailing_string(e->basename(), ".bash")))->second->file_name()) + "'");
- if (IsFileWithExtension(".hook")(*e))
+ if (is_file_with_extension(*e, ".hook", IsFileWithOptions()))
if (! hook_files.insert(std::make_pair(strip_trailing_string(e->basename(), ".hook"),
std::tr1::shared_ptr<HookFile>(new FancyHookFile(*e, d->second, _imp->env)))).second)
Log::get_instance()->message(ll_warning, lc_context, "Discarding hook file '" + stringify(*e)
diff --git a/paludis/qa/broken_global_variables_check.cc b/paludis/qa/broken_global_variables_check.cc
index 68c15e0..1512550 100644
--- a/paludis/qa/broken_global_variables_check.cc
+++ b/paludis/qa/broken_global_variables_check.cc
@@ -40,7 +40,7 @@ BrokenGlobalVariablesCheck::operator() (const FSEntry & f) const
if (! f.is_regular_file())
result << Message(qal_skip, "Not a regular file");
- else if (! IsFileWithExtension(".ebuild")(f))
+ else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()))
result << Message(qal_skip, "Not an ebuild file");
else
{
diff --git a/paludis/qa/defaults_check.cc b/paludis/qa/defaults_check.cc
index d9c598f..b0db34d 100644
--- a/paludis/qa/defaults_check.cc
+++ b/paludis/qa/defaults_check.cc
@@ -55,7 +55,7 @@ DefaultsCheck::operator() (const FSEntry & f) const
if (! f.is_regular_file())
result << Message(qal_skip, "Not a regular file");
- else if (! IsFileWithExtension(".ebuild")(f))
+ else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()))
result << Message(qal_skip, "Not an ebuild file");
else
{
diff --git a/paludis/qa/deprecated_functions_check.cc b/paludis/qa/deprecated_functions_check.cc
index 7548660..9edfcb7 100644
--- a/paludis/qa/deprecated_functions_check.cc
+++ b/paludis/qa/deprecated_functions_check.cc
@@ -44,8 +44,8 @@ DeprecatedFunctionsCheck::operator() (const FSEntry & f) const
if (! f.is_regular_file())
result << Message(qal_skip, "Not a regular file");
- else if (! IsFileWithExtension(".ebuild")(f) &&
- ! IsFileWithExtension(".eclass")(f))
+ else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()) &&
+ ! is_file_with_extension(f, ".eclass", IsFileWithOptions()))
result << Message(qal_skip, "Not an ebuild or eclass file");
else
{
diff --git a/paludis/qa/digest_collisions_check.cc b/paludis/qa/digest_collisions_check.cc
index 204c7cd..c6ffe96 100644
--- a/paludis/qa/digest_collisions_check.cc
+++ b/paludis/qa/digest_collisions_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -17,13 +17,14 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <fstream>
-#include <map>
#include <paludis/hashed_containers.hh>
#include <paludis/qa/digest_collisions_check.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/is_file_with_extension.hh>
#include <paludis/util/tokeniser.hh>
+#include <fstream>
+#include <map>
+#include <vector>
using namespace paludis;
using namespace paludis::qa;
@@ -44,7 +45,7 @@ DigestCollisionsCheck::operator() (const FSEntry & d) const
for (DirIterator i(d / "files") ; i != DirIterator() ; ++i)
{
- if (! IsFileWithExtension("digest-", "")(*i))
+ if (! is_file_with_prefix_extension(*i, "digest-", "", IsFileWithOptions()))
continue;
std::fstream f(stringify(*i).c_str());
diff --git a/paludis/qa/ebuild_check.cc b/paludis/qa/ebuild_check.cc
index 05e2bb0..912cc3f 100644
--- a/paludis/qa/ebuild_check.cc
+++ b/paludis/qa/ebuild_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -36,9 +36,14 @@
#include <paludis/qa/pdepend_overlap_check.hh>
#include <paludis/qa/slot_check.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
+
using namespace paludis;
using namespace paludis::qa;
+template class VirtualConstructor<std::string, std::tr1::shared_ptr<EbuildCheck> (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchEbuildCheckTypeError> >;
+
#include <paludis/qa/ebuild_check-sr.cc>
EbuildCheck::EbuildCheck()
diff --git a/paludis/qa/ebuild_count_check.cc b/paludis/qa/ebuild_count_check.cc
index b33f612..b9c69f6 100644
--- a/paludis/qa/ebuild_count_check.cc
+++ b/paludis/qa/ebuild_count_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -17,10 +17,11 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
#include <paludis/qa/ebuild_count_check.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/is_file_with_extension.hh>
+#include <algorithm>
+#include <tr1/functional>
using namespace paludis;
using namespace paludis::qa;
@@ -32,9 +33,12 @@ EbuildCountCheck::EbuildCountCheck()
CheckResult
EbuildCountCheck::operator() (const FSEntry & d) const
{
+ using namespace std::tr1::placeholders;
+
CheckResult result(d, identifier());
- std::size_t count(std::count_if(DirIterator(d), DirIterator(), IsFileWithExtension(".ebuild")));
+ std::size_t count(std::count_if(DirIterator(d), DirIterator(),
+ std::tr1::bind(&is_file_with_extension, _1, ".ebuild", IsFileWithOptions())));
if (count > 20)
result << Message(qal_minor, "Found " + stringify(count) +
" ebuilds, which is too many to count on both hands and both feet");
diff --git a/paludis/qa/file_check.cc b/paludis/qa/file_check.cc
index 8a62787..87a64a9 100644
--- a/paludis/qa/file_check.cc
+++ b/paludis/qa/file_check.cc
@@ -33,9 +33,14 @@
#include <paludis/qa/variable_assigns_check.hh>
#include <paludis/qa/whitespace_check.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
+
using namespace paludis;
using namespace paludis::qa;
+template class VirtualConstructor<std::string, std::tr1::shared_ptr<FileCheck> (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchFileCheckTypeError> >;
+
FileCheck::FileCheck()
{
}
diff --git a/paludis/qa/function_check.cc b/paludis/qa/function_check.cc
index 4e0298f..6422665 100644
--- a/paludis/qa/function_check.cc
+++ b/paludis/qa/function_check.cc
@@ -38,8 +38,8 @@ FunctionCheck::operator() (const FSEntry & f) const
if (! f.is_regular_file())
result << Message(qal_skip, "Not a regular file.");
- else if (! IsFileWithExtension(".ebuild")(f) &&
- ! IsFileWithExtension(".eclass")(f))
+ else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()) &&
+ ! is_file_with_extension(f, ".eclass", IsFileWithOptions()))
result << Message(qal_skip, "Not an ebuild or eclass.");
else
{
diff --git a/paludis/qa/has_ebuilds_check.cc b/paludis/qa/has_ebuilds_check.cc
index 3d850c2..991a23a 100644
--- a/paludis/qa/has_ebuilds_check.cc
+++ b/paludis/qa/has_ebuilds_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -17,10 +17,11 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#include <algorithm>
#include <paludis/qa/has_ebuilds_check.hh>
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/is_file_with_extension.hh>
+#include <algorithm>
+#include <tr1/functional>
using namespace paludis;
using namespace paludis::qa;
@@ -34,8 +35,10 @@ HasEbuildsCheck::operator() (const FSEntry & d) const
{
CheckResult result(d, identifier());
+ using namespace std::tr1::placeholders;
+
if (DirIterator() == std::find_if(DirIterator(d), DirIterator(),
- IsFileWithExtension(d.basename() + "-", ".ebuild")))
+ std::tr1::bind(&is_file_with_prefix_extension, _1, d.basename() + "-", ".ebuild", IsFileWithOptions())))
result << Message(qal_fatal, "No ebuilds found");
return result;
diff --git a/paludis/qa/header_check.cc b/paludis/qa/header_check.cc
index 02638dd..d47ec49 100644
--- a/paludis/qa/header_check.cc
+++ b/paludis/qa/header_check.cc
@@ -42,8 +42,8 @@ HeaderCheck::operator() (const FSEntry & f) const
if (! f.is_regular_file())
result << Message(qal_skip, "Not a regular file");
- else if (! IsFileWithExtension(".ebuild")(f) &&
- ! IsFileWithExtension(".eclass")(f))
+ else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()) &&
+ ! is_file_with_extension(f, ".eclass", IsFileWithOptions()))
result << Message(qal_skip, "Not an ebuild or eclass file");
else
{
diff --git a/paludis/qa/package_dir_check.cc b/paludis/qa/package_dir_check.cc
index db55575..bc55ec8 100644
--- a/paludis/qa/package_dir_check.cc
+++ b/paludis/qa/package_dir_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -26,9 +26,14 @@
#include <paludis/qa/has_misc_files_check.hh>
#include <paludis/qa/package_name_check.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
+
using namespace paludis;
using namespace paludis::qa;
+template class VirtualConstructor<std::string, std::tr1::shared_ptr<PackageDirCheck> (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchPackageDirCheckTypeError> >;
+
PackageDirCheck::PackageDirCheck()
{
}
diff --git a/paludis/qa/per_profile_ebuild_check.cc b/paludis/qa/per_profile_ebuild_check.cc
index a492cfd..6dc48ad 100644
--- a/paludis/qa/per_profile_ebuild_check.cc
+++ b/paludis/qa/per_profile_ebuild_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -19,10 +19,14 @@
#include "per_profile_ebuild_check.hh"
#include <paludis/qa/deps_visible_check.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
using namespace paludis;
using namespace paludis::qa;
+template class VirtualConstructor<std::string, std::tr1::shared_ptr<PerProfileEbuildCheck> (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchPerProfileEbuildCheckTypeError> >;
+
#include <paludis/qa/per_profile_ebuild_check-sr.cc>
PerProfileEbuildCheck::PerProfileEbuildCheck()
diff --git a/paludis/qa/profile_check.cc b/paludis/qa/profile_check.cc
index f452b3e..d99f5b7 100644
--- a/paludis/qa/profile_check.cc
+++ b/paludis/qa/profile_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,10 +20,14 @@
#include "profile_check.hh"
#include <paludis/qa/profile_check.hh>
#include <paludis/qa/profile_paths_exist_check.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
using namespace paludis;
using namespace paludis::qa;
+template class VirtualConstructor<std::string, std::tr1::shared_ptr<ProfileCheck> (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchProfileCheckTypeError> >;
+
#include <paludis/qa/profile_check-sr.cc>
ProfileCheck::ProfileCheck()
diff --git a/paludis/qa/profiles_check.cc b/paludis/qa/profiles_check.cc
index 0d7b91c..2424971 100644
--- a/paludis/qa/profiles_check.cc
+++ b/paludis/qa/profiles_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,10 +20,14 @@
#include <paludis/qa/profiles_check.hh>
#include <paludis/qa/categories_check.hh>
#include <paludis/qa/repo_name_check.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
using namespace paludis;
using namespace paludis::qa;
+template class VirtualConstructor<std::string, std::tr1::shared_ptr<ProfilesCheck> (*) (),
+ virtual_constructor_not_found::ThrowException<NoSuchProfilesCheckTypeError> >;
+
ProfilesCheck::ProfilesCheck()
{
}
diff --git a/paludis/qa/root_check.cc b/paludis/qa/root_check.cc
index 0ff1e6e..92074c4 100644
--- a/paludis/qa/root_check.cc
+++ b/paludis/qa/root_check.cc
@@ -50,7 +50,7 @@ RootCheck::operator() (const FSEntry & f) const
if (! f.is_regular_file())
result << Message(qal_skip, "Not a regular file");
- else if (! IsFileWithExtension(".ebuild")(f))
+ else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()))
result << Message(qal_skip, "Not an ebuild file");
else
{
diff --git a/paludis/qa/subshell_die_check.cc b/paludis/qa/subshell_die_check.cc
index f7777c4..6da2e4e 100644
--- a/paludis/qa/subshell_die_check.cc
+++ b/paludis/qa/subshell_die_check.cc
@@ -39,8 +39,8 @@ SubshellDieCheck::operator() (const FSEntry & f) const
if (! f.is_regular_file())
result << Message(qal_skip, "Not a regular file");
- else if (! IsFileWithExtension(".ebuild")(f) &&
- ! IsFileWithExtension(".eclass")(f))
+ else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()) &&
+ ! is_file_with_extension(f, ".eclass", IsFileWithOptions()))
result << Message(qal_skip, "Not an ebuild or eclass file");
else
{
diff --git a/paludis/qa/variable_assigns_check.cc b/paludis/qa/variable_assigns_check.cc
index c7f10ef..f8a342d 100644
--- a/paludis/qa/variable_assigns_check.cc
+++ b/paludis/qa/variable_assigns_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -51,8 +51,8 @@ VariableAssignsCheck::operator() (const FSEntry & f) const
if (! f.is_regular_file())
result << Message(qal_skip, "Not a regular file");
- else if (! IsFileWithExtension(".ebuild")(f) &&
- ! IsFileWithExtension(".eclass")(f))
+ else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()) &&
+ ! is_file_with_extension(f, ".eclass", IsFileWithOptions()))
result << Message(qal_skip, "Not an ebuild or eclass file");
else
{
diff --git a/paludis/qa/whitespace_check.cc b/paludis/qa/whitespace_check.cc
index b475c39..bd594a7 100644
--- a/paludis/qa/whitespace_check.cc
+++ b/paludis/qa/whitespace_check.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -35,9 +35,9 @@ WhitespaceCheck::operator() (const FSEntry & f) const
if (! f.is_regular_file())
result << Message(qal_skip, "Not a regular file");
- else if (! IsFileWithExtension(".ebuild")(f) &&
- ! IsFileWithExtension(".xml")(f) &&
- ! IsFileWithExtension(".eclass")(f))
+ else if (! is_file_with_extension(f, ".ebuild", IsFileWithOptions()) &&
+ ! is_file_with_extension(f, ".xml", IsFileWithOptions()) &&
+ ! is_file_with_extension(f, ".eclass", IsFileWithOptions()))
result << Message(qal_skip, "Not an ebuild, eclass or xml file");
else
{
diff --git a/paludis/repositories/cran/Makefile.am b/paludis/repositories/cran/Makefile.am
index 26c2a01..683abfc 100644
--- a/paludis/repositories/cran/Makefile.am
+++ b/paludis/repositories/cran/Makefile.am
@@ -46,6 +46,7 @@ libpaludiscranrepository_la_SOURCES = \
if ! MONOLITHIC
libpaludiscranrepository_la_LIBADD = \
+ $(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(DYNAMIC_LD_LIBS)
diff --git a/paludis/repositories/gems/Makefile.am b/paludis/repositories/gems/Makefile.am
index 41e19d5..12a00dd 100644
--- a/paludis/repositories/gems/Makefile.am
+++ b/paludis/repositories/gems/Makefile.am
@@ -51,6 +51,7 @@ libpaludisgemsrepository_la_SOURCES = \
if ! MONOLITHIC
libpaludisgemsrepository_la_LIBADD = \
+ $(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(top_builddir)/paludis/libpaludis.la \
-lyaml \
diff --git a/paludis/repositories/gentoo/Makefile.am b/paludis/repositories/gentoo/Makefile.am
index 580c42e..265b817 100644
--- a/paludis/repositories/gentoo/Makefile.am
+++ b/paludis/repositories/gentoo/Makefile.am
@@ -122,6 +122,7 @@ libpaludisgentoorepository_la_LIBADD = \
else
libpaludisgentoorepository_la_LIBADD = \
+ $(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(top_builddir)/paludis/merger/libpaludismerger.la \
$(top_builddir)/paludis/digests/libpaludisdigests.la \
$(top_builddir)/paludis/libpaludis.la \
diff --git a/paludis/repositories/gentoo/portage_repository.cc b/paludis/repositories/gentoo/portage_repository.cc
index ca4645c..4f7acd2 100644
--- a/paludis/repositories/gentoo/portage_repository.cc
+++ b/paludis/repositories/gentoo/portage_repository.cc
@@ -61,6 +61,7 @@
#include <algorithm>
#include <vector>
#include <limits>
+#include <tr1/functional>
#include <strings.h>
#include <ctype.h>
@@ -413,6 +414,8 @@ PortageRepository::do_category_names() const
std::tr1::shared_ptr<const QualifiedPackageNameCollection>
PortageRepository::do_package_names(const CategoryNamePart & c) const
{
+ using namespace std::tr1::placeholders;
+
/* this isn't particularly fast because it isn't called very often. avoid
* changing the data structures used to make this faster at the expense of
* slowing down single item queries. */
@@ -431,7 +434,7 @@ PortageRepository::do_package_names(const CategoryNamePart & c) const
if (! d->is_directory())
continue;
if (DirIterator() == std::find_if(DirIterator(*d), DirIterator(),
- IsFileWithExtension(_imp->entries_ptr->file_extension())))
+ std::tr1::bind(&is_file_with_extension, _1, _imp->entries_ptr->file_extension(), IsFileWithOptions())))
continue;
try
@@ -570,8 +573,8 @@ PortageRepository::need_version_names(const QualifiedPackageName & n) const
for (DirIterator e(path), e_end ; e != e_end ; ++e)
{
- if (! IsFileWithExtension(stringify(n.package) + "-",
- _imp->entries_ptr->file_extension())(*e))
+ if (! is_file_with_prefix_extension(*e, stringify(n.package) + "-", _imp->entries_ptr->file_extension(),
+ IsFileWithOptions()))
continue;
try
diff --git a/paludis/repositories/gentoo/portage_repository_entries.cc b/paludis/repositories/gentoo/portage_repository_entries.cc
index 0614054..1928e21 100644
--- a/paludis/repositories/gentoo/portage_repository_entries.cc
+++ b/paludis/repositories/gentoo/portage_repository_entries.cc
@@ -20,9 +20,15 @@
#include "portage_repository_entries.hh"
#include "ebuild_entries.hh"
#include "ebin_entries.hh"
+#include <paludis/util/virtual_constructor-impl.hh>
using namespace paludis;
+template class VirtualConstructor<std::string,
+ std::tr1::shared_ptr<PortageRepositoryEntries> (*) (const Environment * const, PortageRepository * const,
+ const PortageRepositoryParams &),
+ virtual_constructor_not_found::ThrowException<NoSuchPortageRepositoryEntriesType> >;
+
PortageRepositoryEntries::PortageRepositoryEntries(const std::string & ext) :
_ext(ext)
{
diff --git a/paludis/repositories/gentoo/portage_repository_profile.cc b/paludis/repositories/gentoo/portage_repository_profile.cc
index 9572520..30d85f5 100644
--- a/paludis/repositories/gentoo/portage_repository_profile.cc
+++ b/paludis/repositories/gentoo/portage_repository_profile.cc
@@ -35,6 +35,7 @@
#include <list>
#include <algorithm>
#include <set>
+#include <vector>
#include <strings.h>
#include <ctype.h>
diff --git a/paludis/repositories/gentoo/portage_repository_sets.cc b/paludis/repositories/gentoo/portage_repository_sets.cc
index acc2bc5..bfcccb0 100644
--- a/paludis/repositories/gentoo/portage_repository_sets.cc
+++ b/paludis/repositories/gentoo/portage_repository_sets.cc
@@ -36,6 +36,7 @@
#include <paludis/util/tokeniser.hh>
#include <list>
+#include <tr1/functional>
#include <set>
#include "config.h"
@@ -119,10 +120,11 @@ PortageRepositorySets::sets_list() const
try
{
+ using namespace std::tr1::placeholders;
+
std::list<FSEntry> repo_sets;
std::copy(DirIterator(_imp->params.setsdir), DirIterator(),
- filter_inserter(std::back_inserter(repo_sets),
- IsFileWithExtension(".conf")));
+ filter_inserter(std::back_inserter(repo_sets), std::tr1::bind(is_file_with_extension, _1, ".conf", IsFileWithOptions())));
std::list<FSEntry>::const_iterator f(repo_sets.begin()),
f_end(repo_sets.end());
@@ -245,7 +247,7 @@ PortageRepositorySets::security_set(bool insecurity) const
for (DirIterator f(_imp->params.securitydir), f_end ; f != f_end; ++f)
{
- if (! IsFileWithExtension("glsa-", ".xml")(*f))
+ if (! is_file_with_prefix_extension(*f, "glsa-", ".xml", IsFileWithOptions()))
continue;
Context local_context("When parsing security advisory '" + stringify(*f) + "':");
diff --git a/paludis/repositories/gentoo/use_desc.cc b/paludis/repositories/gentoo/use_desc.cc
index 32a63fd..6cefc15 100644
--- a/paludis/repositories/gentoo/use_desc.cc
+++ b/paludis/repositories/gentoo/use_desc.cc
@@ -60,7 +60,7 @@ namespace paludis
if ((f / "desc").is_directory())
for (DirIterator d(f / "desc"), d_end ; d != d_end ; ++d)
- if (IsFileWithExtension(".desc")(*d))
+ if (is_file_with_extension(*d, ".desc", IsFileWithOptions()))
add(*d, strip_trailing_string(d->basename(), ".desc") + "_");
}
};
diff --git a/paludis/repositories/repository_maker.cc b/paludis/repositories/repository_maker.cc
index d9623fe..84f6a4c 100644
--- a/paludis/repositories/repository_maker.cc
+++ b/paludis/repositories/repository_maker.cc
@@ -22,6 +22,7 @@
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/is_file_with_extension.hh>
#include <paludis/util/system.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
#include <paludis/about.hh>
#include <list>
#include <dlfcn.h>
@@ -38,6 +39,11 @@
using namespace paludis;
+template class VirtualConstructor<std::string,
+ std::tr1::shared_ptr<Repository> (*) (Environment * const,
+ std::tr1::shared_ptr<const AssociativeCollection<std::string, std::string> >),
+ virtual_constructor_not_found::ThrowException<NoSuchRepositoryTypeError> >;
+
NoSuchRepositoryTypeError::NoSuchRepositoryTypeError(const std::string & format) throw ():
ConfigurationError("No available maker for repository type '" + format + "'")
{
@@ -86,8 +92,8 @@ RepositoryMaker::load_dir(const FSEntry & so_dir)
if (d->is_directory())
load_dir(*d);
- if (! IsFileWithExtension(".so." + stringify(100 * PALUDIS_VERSION_MAJOR +
- PALUDIS_VERSION_MINOR))(*d))
+ if (! is_file_with_extension(*d, ".so." + stringify(100 * PALUDIS_VERSION_MAJOR + PALUDIS_VERSION_MINOR),
+ IsFileWithOptions()))
continue;
/* don't use RTLD_LOCAL, g++ is over happy about template instantiations, and it
diff --git a/paludis/repositories/virtuals/Makefile.am b/paludis/repositories/virtuals/Makefile.am
index afee265..ddcde29 100644
--- a/paludis/repositories/virtuals/Makefile.am
+++ b/paludis/repositories/virtuals/Makefile.am
@@ -39,6 +39,7 @@ libpaludisvirtualsrepository_la_SOURCES = \
if ! MONOLITHIC
libpaludisvirtualsrepository_la_LIBADD = \
+ $(top_builddir)/paludis/repositories/libpaludisrepositories.la \
$(top_builddir)/paludis/libpaludis.la \
$(top_builddir)/paludis/util/libpaludisutil.la \
$(DYNAMIC_LD_LIBS)
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index e2d4b93..4b30a5a 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -25,6 +25,7 @@
#include <paludis/util/fast_unique_copy.hh>
#include <paludis/util/log.hh>
#include <paludis/query.hh>
+#include <vector>
#include "vr_entry.hh"
using namespace paludis;
diff --git a/paludis/util/Makefile.am.m4 b/paludis/util/Makefile.am.m4
index d3065af..271560b 100644
--- a/paludis/util/Makefile.am.m4
+++ b/paludis/util/Makefile.am.m4
@@ -7,6 +7,12 @@ define(`filelist', `')dnl
define(`headerlist', `')dnl
define(`testlist', `')dnl
define(`testscriptlist', `')dnl
+define(`selist', `')dnl
+define(`secleanlist', `')dnl
+define(`seheaderlist', `')dnl
+define(`srlist', `')dnl
+define(`srcleanlist', `')dnl
+define(`srheaderlist', `')dnl
define(`addtest', `define(`testlist', testlist `$1_TEST')dnl
$1_TEST_SOURCES = $1_TEST.cc
$1_TEST_LDADD = \
@@ -20,21 +26,45 @@ define(`addhh', `define(`filelist', filelist `$1.hh')define(`headerlist', header
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(`addsr', `define(`srlist', srlist `$1.sr')dnl
+define(`srcleanlist', srcleanlist `$1-sr.hh $1-sr.cc')dnl
+define(`srheaderlist', srheaderlist `$1-sr.hh')dnl
+$1-sr.hh : $1.sr $(top_srcdir)/misc/make_sr.bash
+ if ! $(top_srcdir)/misc/make_sr.bash --header $`'(srcdir)/$1.sr > $`'@ ; then rm -f $`'@ ; exit 1 ; fi
+
+$1-sr.cc : $1.sr $(top_srcdir)/misc/make_sr.bash
+ if ! $(top_srcdir)/misc/make_sr.bash --source $`'(srcdir)/$1.sr > $`'@ ; then rm -f $`'@ ; exit 1 ; fi
+
+')dnl
+define(`addse', `define(`selist', selist `$1.se')dnl
+define(`secleanlist', secleanlist `$1-se.hh $1-se.cc')dnl
+define(`seheaderlist', seheaderlist `$1-se.hh')dnl
+$1-se.hh : $1.se $(top_srcdir)/misc/make_se.bash
+ if ! $(top_srcdir)/misc/make_se.bash --header $`'(srcdir)/$1.se > $`'@ ; then rm -f $`'@ ; exit 1 ; fi
+
+$1-se.cc : $1.se $(top_srcdir)/misc/make_se.bash
+ if ! $(top_srcdir)/misc/make_se.bash --source $`'(srcdir)/$1.se > $`'@ ; then rm -f $`'@ ; exit 1 ; fi
+
+')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', `sr', `addsr(`$1')', `')dnl
+ifelse(`$2', `se', `addse(`$1')', `')dnl
ifelse(`$2', `test', `addtest(`$1')', `')dnl
ifelse(`$2', `testscript', `addtestscript(`$1')', `')')dnl
define(`add', `addthis(`$1',`$2')addthis(`$1',`$3')addthis(`$1',`$4')dnl
-addthis(`$1',`$5')addthis(`$1',`$6')')dnl
+addthis(`$1',`$5')addthis(`$1',`$6')addthis(`$1',`$7')addthis(`$1',`$8')')dnl
include(`paludis/util/files.m4')
CLEANFILES = *~ gmon.out *.gcov *.gcno *.gcda
MAINTAINERCLEANFILES = Makefile.in Makefile.am paludis.hh \
hashed_containers.hh util.hh
+DISTCLEANFILES = srcleanlist secleanlist
+BUILT_SOURCES = srcleanlist secleanlist
AM_CXXFLAGS = -I$(top_srcdir) @PALUDIS_CXXFLAGS@ @PALUDIS_CXXFLAGS_NO_WOLD_STYLE_CAST@ @PALUDIS_CXXFLAGS_VISIBILITY@
DEFS=\
-DSYSCONFDIR=\"$(sysconfdir)\" \
@@ -68,7 +98,7 @@ lib_LTLIBRARIES = libpaludisutil.la
endif
paludis_util_includedir = $(includedir)/paludis/util/
-paludis_util_include_HEADERS = headerlist
+paludis_util_include_HEADERS = headerlist srheaderlist seheaderlist
Makefile.am : Makefile.am.m4 files.m4
$(top_srcdir)/misc/do_m4.bash Makefile.am
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 9320133..620cbf4 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -23,7 +23,7 @@ add(`fd_holder', `hh')
add(`graph', `hh', `cc', `impl', `test')
add(`iterator', `hh', `test')
add(`instantiation_policy', `hh', `test')
-add(`is_file_with_extension', `hh', `cc', `test', `testscript')
+add(`is_file_with_extension', `hh', `cc', `se', `test', `testscript')
add(`join', `hh', `test')
add(`log', `hh', `cc', `test')
add(`options', `hh', `cc', `test')
@@ -39,6 +39,6 @@ add(`system', `hh', `cc', `test', `testscript')
add(`tokeniser', `hh', `cc', `test')
add(`util', `hh')
add(`validated', `hh', `test')
-add(`virtual_constructor', `hh', `test')
+add(`virtual_constructor', `hh', `impl', `test')
add(`visitor', `hh', `test')
diff --git a/paludis/util/is_file_with_extension.cc b/paludis/util/is_file_with_extension.cc
index 9655b5e..784a592 100644
--- a/paludis/util/is_file_with_extension.cc
+++ b/paludis/util/is_file_with_extension.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -21,11 +21,30 @@
using namespace paludis;
-/** \file
- * Implementation of IsFileWithExtension.
- *
- * \ingroup grpfilesystem
- */
+#include <paludis/util/is_file_with_extension-se.cc>
+
+bool
+paludis::is_file_with_extension(const FSEntry & f, const std::string & s, const IsFileWithOptions & o)
+{
+ return is_file_with_prefix_extension(f, "", s, o);
+}
+
+bool
+paludis::is_file_with_prefix_extension(const FSEntry & f, const std::string & prefix,
+ const std::string & ext, const IsFileWithOptions & o)
+{
+ const std::string filename(f.basename());
+
+ if (filename.length() < ext.length() + prefix.length())
+ return false;
+
+ if (0 != filename.compare(filename.length() - ext.length(), ext.length(), ext))
+ return false;
+ if (0 != filename.compare(0, prefix.length(), prefix))
+ return false;
+
+ return f.is_regular_file() || ((! o[ifwo_no_follow_symlinks]) && f.exists() && f.realpath().is_regular_file());
+}
IsFileWithExtension::IsFileWithExtension(const std::string & ext) :
_prefix(""),
@@ -42,15 +61,6 @@ IsFileWithExtension::IsFileWithExtension(const std::string & prefix, const std::
bool
IsFileWithExtension::operator() (const FSEntry & f) const
{
- const std::string filename(f.basename());
-
- if (filename.length() < _ext.length() + _prefix.length())
- return false;
- if (0 != filename.compare(filename.length() - _ext.length(),
- _ext.length(), _ext))
- return false;
- if (0 != filename.compare(0, _prefix.length(), _prefix))
- return false;
- return f.is_regular_file() || (f.exists() && f.realpath().is_regular_file());
+ return is_file_with_prefix_extension(f, _prefix, _ext, IsFileWithOptions());
}
diff --git a/paludis/util/is_file_with_extension.hh b/paludis/util/is_file_with_extension.hh
index 4e1cbf7..11a7a75 100644
--- a/paludis/util/is_file_with_extension.hh
+++ b/paludis/util/is_file_with_extension.hh
@@ -20,8 +20,9 @@
#ifndef PALUDIS_GUARD_PALUDIS_IS_FILE_WITH_EXTENSION_HH
#define PALUDIS_GUARD_PALUDIS_IS_FILE_WITH_EXTENSION_HH 1
-#include <functional>
#include <paludis/util/fs_entry.hh>
+#include <paludis/util/options.hh>
+#include <functional>
#include <string>
/** \file
@@ -32,14 +33,51 @@
namespace paludis
{
+
+#include <paludis/util/is_file_with_extension-se.hh>
+
+ /**
+ * Options for is_file_with_prefix_extension() and is_file_with_extension().
+ *
+ * \see IsFileWithOption
+ * \see is_file_with_prefix_extension
+ * \see is_file_with_extension
+ * \ingroup grpfilesystem
+ */
+ typedef Options<IsFileWithOption> IsFileWithOptions;
+
+ /**
+ * Return whether an FSEntry is a file with a given extension.
+ *
+ * \see is_file_with_prefix_extension()
+ *
+ * \ingroup grpfilesystem
+ */
+ bool is_file_with_extension(const FSEntry &, const std::string &, const IsFileWithOptions &);
+
+ /**
+ * Return whether an FSEntry is a file with a given prefix and a given
+ * extension prefix.
+ *
+ * \see is_file_with_extension()
+ *
+ * \ingroup grpfilesystem
+ */
+ bool is_file_with_prefix_extension(const FSEntry &, const std::string &, const std::string &, const IsFileWithOptions &);
+
/**
* The IsFileWithExtension class is a functor that determines whether an
* FSEntry instance is a file with a given extension and (optionally) a
* given filename prefix.
*
* \ingroup grpfilesystem
+ * \deprecated Use is_file_with_extension and std::tr1::bind.
*/
- class PALUDIS_VISIBLE IsFileWithExtension :
+#ifdef DOXYGEN
+ class IsFileWithExtension :
+#else
+ class PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((deprecated)) IsFileWithExtension :
+#endif
public std::unary_function<bool, FSEntry>
{
private:
@@ -50,12 +88,12 @@ namespace paludis
/**
* Constructor.
*/
- IsFileWithExtension(const std::string & ext);
+ IsFileWithExtension(const std::string & ext) PALUDIS_ATTRIBUTE((deprecated));
/**
* Constructor.
*/
- IsFileWithExtension(const std::string & prefix, const std::string & ext);
+ IsFileWithExtension(const std::string & prefix, const std::string & ext) PALUDIS_ATTRIBUTE((deprecated));
/**
* Operator.
diff --git a/paludis/util/is_file_with_extension.se b/paludis/util/is_file_with_extension.se
new file mode 100644
index 0000000..6b22118
--- /dev/null
+++ b/paludis/util/is_file_with_extension.se
@@ -0,0 +1,23 @@
+#!/bin/bash
+# vim: set sw=4 sts=4 et ft=sh :
+
+make_enum_IsFileWithOption()
+{
+ prefix ifwo
+
+ key ifwo_no_follow_symlinks "Do not follow symlinks"
+
+ doxygen_comment << "END"
+ /**
+ * Options for is_file_with_extension() and is_file_with_prefix_extension().
+ *
+ * \see IsFileWithOptions
+ * \see is_file_with_extension()
+ * \see is_file_with_prefix_extension()
+ * \ingroup grpfilesystem
+ */
+END
+}
+
+
+
diff --git a/paludis/util/is_file_with_extension_TEST.cc b/paludis/util/is_file_with_extension_TEST.cc
index 43f96b5..9e34061 100644
--- a/paludis/util/is_file_with_extension_TEST.cc
+++ b/paludis/util/is_file_with_extension_TEST.cc
@@ -43,18 +43,15 @@ namespace test_cases
void run()
{
- IsFileWithExtension a("foo");
- IsFileWithExtension b("goat");
-
FSEntry c("teh.foo");
FSEntry d("is_file_with_extension_TEST_file.goat");
TEST_CHECK(d.exists());
- TEST_CHECK( !a(c) );
- TEST_CHECK( !a(d) );
- TEST_CHECK( !b(c) );
- TEST_CHECK( b(d) );
+ TEST_CHECK(! is_file_with_extension(c, "foo", IsFileWithOptions()));
+ TEST_CHECK(! is_file_with_extension(d, "foo", IsFileWithOptions()));
+ TEST_CHECK(! is_file_with_extension(c, "goat", IsFileWithOptions()));
+ TEST_CHECK(is_file_with_extension(d, "goat", IsFileWithOptions()));
}
} test_is_file_with_extension;
@@ -69,20 +66,16 @@ namespace test_cases
void run()
{
- IsFileWithExtension a("teh","foo");
- IsFileWithExtension b("is", "goat");
- IsFileWithExtension c("with", "goat");
-
FSEntry d("teh.foo");
FSEntry e("is_file_with_extension_TEST_file.goat");
TEST_CHECK(e.exists());
- TEST_CHECK( !a(d) );
- TEST_CHECK( !a(e) );
- TEST_CHECK( !b(d) );
- TEST_CHECK( b(e) );
- TEST_CHECK( !c(e) );
+ TEST_CHECK(! is_file_with_prefix_extension(d, "teh", "foo", IsFileWithOptions()));
+ TEST_CHECK(! is_file_with_prefix_extension(e, "teh", "foo", IsFileWithOptions()));
+ TEST_CHECK(! is_file_with_prefix_extension(d, "is", "goat", IsFileWithOptions()));
+ TEST_CHECK(is_file_with_prefix_extension(e, "is", "goat", IsFileWithOptions()));
+ TEST_CHECK(! is_file_with_prefix_extension(e, "with", "goat", IsFileWithOptions()));
}
} test_is_file_with_extension_prefix;
diff --git a/paludis/util/strip.hh b/paludis/util/strip.hh
index 033c02c..c598619 100644
--- a/paludis/util/strip.hh
+++ b/paludis/util/strip.hh
@@ -74,6 +74,7 @@ namespace paludis
* issue with std::bind2nd).
*
* \ingroup grpstrippers
+ * \deprecated Use the function with std::tr1::bind.
* \nosubgrouping
*/
template <std::string (* f_)(const std::string &, const std::string &)>
@@ -87,7 +88,7 @@ namespace paludis
///\name Basic operations
///\{
- StripAdapter(const std::string & second) :
+ StripAdapter(const std::string & second) PALUDIS_ATTRIBUTE((deprecated)) :
_second(second)
{
}
@@ -107,29 +108,33 @@ namespace paludis
* Adapt strip_leading_string to a functor by binding its second argument.
*
* \ingroup grpstrippers
+ * \deprecated Use std::tr1::bind
*/
- typedef StripAdapter<&strip_leading_string> StripLeadingString;
+ typedef StripAdapter<&strip_leading_string> StripLeadingString PALUDIS_ATTRIBUTE((deprecated));
/**
* Adapt strip_leading to a functor by binding its second argument.
*
* \ingroup grpstrippers
+ * \deprecated Use std::tr1::bind
*/
- typedef StripAdapter<&strip_leading> StripLeading;
+ typedef StripAdapter<&strip_leading> StripLeading PALUDIS_ATTRIBUTE((deprecated));
/**
* Adapt strip_trailing_string to a functor by binding its second argument.
*
* \ingroup grpstrippers
+ * \deprecated Use std::tr1::bind
*/
- typedef StripAdapter<&strip_trailing_string> StripTrailingString;
+ typedef StripAdapter<&strip_trailing_string> StripTrailingString PALUDIS_ATTRIBUTE((deprecated));
/**
* Adapt strip_trailing to a functor by binding its second argument.
*
* \ingroup grpstrippers
+ * \deprecated Use std::tr1::bind
*/
- typedef StripAdapter<&strip_trailing> StripTrailing;
+ typedef StripAdapter<&strip_trailing> StripTrailing PALUDIS_ATTRIBUTE((deprecated));
}
#endif
diff --git a/paludis/util/strip_TEST.cc b/paludis/util/strip_TEST.cc
index 240a6d5..40abfc3 100644
--- a/paludis/util/strip_TEST.cc
+++ b/paludis/util/strip_TEST.cc
@@ -44,13 +44,11 @@ namespace test_cases
void run()
{
- StripLeadingString a("foo");
-
- TEST_CHECK("bar" == a("foobar"));
- TEST_CHECK("fishbar" == a("fishbar"));
- TEST_CHECK("" == a("foo"));
- TEST_CHECK("fishfoobar" == a("fishfoobar"));
- TEST_CHECK("blahfoo" == a("blahfoo"));
+ TEST_CHECK("bar" == strip_leading_string("foobar", "foo"));
+ TEST_CHECK("fishbar" == strip_leading_string("fishbar", "foo"));
+ TEST_CHECK("" == strip_leading_string("foo", "foo"));
+ TEST_CHECK("fishfoobar" == strip_leading_string("fishfoobar", "foo"));
+ TEST_CHECK("blahfoo" == strip_leading_string("blahfoo", "foo"));
}
} test_strip_leading_string;
@@ -64,13 +62,11 @@ namespace test_cases
void run()
{
- StripLeading a("foo");
-
- TEST_CHECK("bar" == a("foobar"));
- TEST_CHECK("ishbar" == a("fishbar"));
- TEST_CHECK("" == a("foo"));
- TEST_CHECK("ishfoobar" == a("fishfoobar"));
- TEST_CHECK("blahfoo" == a("blahfoo"));
+ TEST_CHECK("bar" == strip_leading("foobar", "foo"));
+ TEST_CHECK("ishbar" == strip_leading("fishbar", "foo"));
+ TEST_CHECK("" == strip_leading("foo", "foo"));
+ TEST_CHECK("ishfoobar" == strip_leading("fishfoobar", "foo"));
+ TEST_CHECK("blahfoo" == strip_leading("blahfoo", "foo"));
}
} test_strip_leading;
@@ -84,13 +80,11 @@ namespace test_cases
void run()
{
- StripTrailingString a("foo");
-
- TEST_CHECK("foobar" == a("foobar"));
- TEST_CHECK("fishbar" == a("fishbar"));
- TEST_CHECK("" == a("foo"));
- TEST_CHECK("fishfoobar" == a("fishfoobar"));
- TEST_CHECK("blah" == a("blahfoo"));
+ TEST_CHECK("foobar" == strip_trailing_string("foobar", "foo"));
+ TEST_CHECK("fishbar" == strip_trailing_string("fishbar", "foo"));
+ TEST_CHECK("" == strip_trailing_string("foo", "foo"));
+ TEST_CHECK("fishfoobar" == strip_trailing_string("fishfoobar", "foo"));
+ TEST_CHECK("blah" == strip_trailing_string("blahfoo", "foo"));
}
} test_strip_trailing_string;
@@ -104,15 +98,12 @@ namespace test_cases
void run()
{
- StripTrailing a("foo");
-
- TEST_CHECK("foobar" == a("foobar"));
- TEST_CHECK("fishbar" == a("fishbar"));
- TEST_CHECK("" == a("foo"));
- TEST_CHECK("fishfoobar" == a("fishfoobar"));
- TEST_CHECK("blah" == a("blahfoo"));
+ TEST_CHECK("foobar" == strip_trailing("foobar", "foo"));
+ TEST_CHECK("fishbar" == strip_trailing("fishbar", "foo"));
+ TEST_CHECK("" == strip_trailing("foo", "foo"));
+ TEST_CHECK("fishfoobar" == strip_trailing("fishfoobar", "foo"));
+ TEST_CHECK("blah" == strip_trailing("blahfoo", "foo"));
}
} test_strip_trailing;
-
}
diff --git a/paludis/util/virtual_constructor-impl.hh b/paludis/util/virtual_constructor-impl.hh
new file mode 100644
index 0000000..ea2e3cc
--- /dev/null
+++ b/paludis/util/virtual_constructor-impl.hh
@@ -0,0 +1,153 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_VIRTUAL_CONSTRUCTOR_IMPL_HH
+#define PALUDIS_GUARD_PALUDIS_VIRTUAL_CONSTRUCTOR_IMPL_HH 1
+
+#include <paludis/util/virtual_constructor.hh>
+#include <paludis/util/stringify.hh>
+#include <paludis/util/iterator.hh>
+#include <algorithm>
+#include <vector>
+
+/** \file
+ * Declarations for VirtualConstructor and related classes.
+ *
+ * \ingroup grpvc
+ */
+
+namespace paludis
+{
+ /**
+ * Behaviour policy classes for what to do if an appropriate constructor
+ * cannot be found for a VirtualConstructor::find_maker call.
+ *
+ * \ingroup grpvc
+ */
+ namespace virtual_constructor_not_found
+ {
+ template <typename ExceptionType_>
+ template <typename KeyType_, typename ValueType_>
+ ValueType_
+ ThrowException<ExceptionType_>::Parent<KeyType_, ValueType_>::handle_not_found(
+ const KeyType_ & k) const
+ {
+ throw ExceptionType_(k);
+ }
+ }
+
+ /**
+ * For internal use by VirtualConstructor.
+ *
+ * \ingroup grpvc
+ */
+ namespace virtual_constructor_internals
+ {
+ /**
+ * Comparator class for our entries.
+ *
+ * \ingroup grpvc
+ */
+ template <typename First_, typename Second_>
+ struct ComparePairByFirst
+ {
+ /**
+ * Compare, with the entry on the LHS.
+ */
+ bool operator() (const std::pair<First_, Second_> & a, const First_ & b) const
+ {
+ return a.first < b;
+ }
+
+ /**
+ * Compare, with the entry on the RHS.
+ */
+ bool operator() (const First_ & a, const std::pair<First_, Second_> & b) const
+ {
+ return a < b.first;
+ }
+ };
+ }
+
+ template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
+ struct VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>::EntriesHolder
+ {
+ std::vector<std::pair<KeyType_, ValueType_> > entries;
+ };
+
+ template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
+ VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>::VirtualConstructor() :
+ _entries_holder(new EntriesHolder)
+ {
+ }
+
+ template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
+ VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>::~VirtualConstructor()
+ {
+ delete _entries_holder;
+ }
+
+ template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
+ ValueType_
+ VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>::operator[] (const KeyType_ & k) const
+ {
+ return find_maker(k);
+ }
+
+ template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
+ ValueType_
+ VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>::find_maker(
+ const KeyType_ & k) const
+ {
+ std::pair<
+ typename std::vector<std::pair<KeyType_, ValueType_> >::const_iterator,
+ typename std::vector<std::pair<KeyType_, ValueType_> >::const_iterator > m(
+ std::equal_range(_entries_holder->entries.begin(), _entries_holder->entries.end(), k,
+ virtual_constructor_internals::ComparePairByFirst<KeyType_, ValueType_>()));
+ if (m.first == m.second)
+ return this->handle_not_found(k);
+ else
+ return m.first->second;
+ }
+
+ template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
+ void
+ VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>::register_maker(
+ const KeyType_ & k, const ValueType_ & v)
+ {
+ std::pair<
+ typename std::vector<std::pair<KeyType_, ValueType_> >::iterator,
+ typename std::vector<std::pair<KeyType_, ValueType_> >::iterator > m(
+ std::equal_range(_entries_holder->entries.begin(), _entries_holder->entries.end(), k,
+ virtual_constructor_internals::ComparePairByFirst<KeyType_, ValueType_>()));
+ if (m.first == m.second)
+ _entries_holder->entries.insert(m.first, std::make_pair(k, v));
+ }
+
+ template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
+ template <typename T_>
+ void
+ VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>::copy_keys(T_ out_iter) const
+ {
+ std::copy(_entries_holder->entries.begin(), _entries_holder->entries.end(), TransformInsertIterator<
+ T_, SelectFirst<KeyType_, ValueType_> >(out_iter));
+ }
+}
+
+#endif
diff --git a/paludis/util/virtual_constructor.hh b/paludis/util/virtual_constructor.hh
index 5725f47..80839e4 100644
--- a/paludis/util/virtual_constructor.hh
+++ b/paludis/util/virtual_constructor.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@ciaranm.org>
+ * Copyright (c) 2006, 2007 Ciaran McCreesh <ciaranm@ciaranm.org>
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -21,11 +21,8 @@
#define PALUDIS_GUARD_PALUDIS_VIRTUAL_CONSTRUCTOR_HH 1
#include <paludis/util/exception.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/iterator.hh>
-
-#include <algorithm>
-#include <vector>
+#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/instantiation_policy.hh>
/** \file
* Declarations for VirtualConstructor and related classes.
@@ -66,48 +63,6 @@ namespace paludis
ValueType_ handle_not_found(const KeyType_ & k) const PALUDIS_ATTRIBUTE((noreturn));
};
};
-
- template <typename ExceptionType_>
- template <typename KeyType_, typename ValueType_>
- ValueType_
- ThrowException<ExceptionType_>::Parent<KeyType_, ValueType_>::handle_not_found(
- const KeyType_ & k) const
- {
- throw ExceptionType_(k);
- }
- }
-
- /**
- * For internal use by VirtualConstructor.
- *
- * \ingroup grpvc
- */
- namespace virtual_constructor_internals
- {
- /**
- * Comparator class for our entries.
- *
- * \ingroup grpvc
- */
- template <typename First_, typename Second_>
- struct ComparePairByFirst
- {
- /**
- * Compare, with the entry on the LHS.
- */
- bool operator() (const std::pair<First_, Second_> & a, const First_ & b) const
- {
- return a.first < b;
- }
-
- /**
- * Compare, with the entry on the RHS.
- */
- bool operator() (const First_ & a, const std::pair<First_, Second_> & b) const
- {
- return a < b.first;
- }
- };
}
/**
@@ -119,22 +74,22 @@ namespace paludis
*/
template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
class PALUDIS_VISIBLE VirtualConstructor :
- public NotFoundBehaviour_::template Parent<KeyType_, ValueType_>
+ public NotFoundBehaviour_::template Parent<KeyType_, ValueType_>,
+ private InstantiationPolicy<VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>, instantiation_method::NonCopyableTag>
{
- protected:
- /**
- * Our entries, sorted.
- */
- std::vector<std::pair<KeyType_, ValueType_> > entries;
+ private:
+ struct EntriesHolder;
+ EntriesHolder * _entries_holder;
+ protected:
/**
* Constructor.
*/
- VirtualConstructor()
- {
- }
+ VirtualConstructor();
public:
+ ~VirtualConstructor();
+
/**
* The type of our key.
*/
@@ -159,10 +114,7 @@ namespace paludis
/**
* Convenience alias for find_maker.
*/
- ValueType_ operator[] (const KeyType_ & k) const
- {
- return find_maker(k);
- }
+ ValueType_ operator[] (const KeyType_ & k) const;
/**
* Register a new maker.
@@ -175,45 +127,6 @@ namespace paludis
template <typename T_>
void copy_keys(T_ out_iter) const;
};
-
- template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
- ValueType_
- VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>::find_maker(
- const KeyType_ & k) const
- {
- std::pair<
- typename std::vector<std::pair<KeyType_, ValueType_> >::const_iterator,
- typename std::vector<std::pair<KeyType_, ValueType_> >::const_iterator > m(
- std::equal_range(entries.begin(), entries.end(), k,
- virtual_constructor_internals::ComparePairByFirst<KeyType_, ValueType_>()));
- if (m.first == m.second)
- return this->handle_not_found(k);
- else
- return m.first->second;
- }
-
- template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
- void
- VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>::register_maker(
- const KeyType_ & k, const ValueType_ & v)
- {
- std::pair<
- typename std::vector<std::pair<KeyType_, ValueType_> >::iterator,
- typename std::vector<std::pair<KeyType_, ValueType_> >::iterator > m(
- std::equal_range(entries.begin(), entries.end(), k,
- virtual_constructor_internals::ComparePairByFirst<KeyType_, ValueType_>()));
- if (m.first == m.second)
- entries.insert(m.first, std::make_pair(k, v));
- }
-
- template <typename KeyType_, typename ValueType_, typename NotFoundBehaviour_>
- template <typename T_>
- void
- VirtualConstructor<KeyType_, ValueType_, NotFoundBehaviour_>::copy_keys(T_ out_iter) const
- {
- std::copy(entries.begin(), entries.end(), TransformInsertIterator<
- T_, SelectFirst<KeyType_, ValueType_> >(out_iter));
- }
}
#endif
diff --git a/paludis/util/virtual_constructor_TEST.cc b/paludis/util/virtual_constructor_TEST.cc
index 6d7bd59..22ecfe4 100644
--- a/paludis/util/virtual_constructor_TEST.cc
+++ b/paludis/util/virtual_constructor_TEST.cc
@@ -18,6 +18,7 @@
*/
#include <paludis/util/virtual_constructor.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
#include <test/test_framework.hh>
#include <test/test_runner.hh>
#include <set>
diff --git a/ruby/check.cc b/ruby/check.cc
index 3855bf7..0a1edcd 100644
--- a/ruby/check.cc
+++ b/ruby/check.cc
@@ -21,6 +21,7 @@
#include <paludis/qa/check.hh>
#include <paludis/qa/package_dir_check.hh>
#include <paludis/util/stringify.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
#include <paludis/qa/qa.hh>
#include <ruby.h>
diff --git a/src/clients/adjutrix/display_profiles_use.cc b/src/clients/adjutrix/display_profiles_use.cc
index c40ac90..f124684 100644
--- a/src/clients/adjutrix/display_profiles_use.cc
+++ b/src/clients/adjutrix/display_profiles_use.cc
@@ -126,7 +126,7 @@ void do_display_profiles_use(NoConfigEnvironment & env)
for (DirIterator d(env.main_repository_dir() / "profiles" / "desc"), d_end ;
d != d_end ; ++d)
{
- if (! IsFileWithExtension(".desc")(*d))
+ if (! is_file_with_extension(*d, ".desc", IsFileWithOptions()))
continue;
std::string prefix(strip_trailing_string(d->basename(), ".desc"));
diff --git a/src/clients/adjutrix/downgrade_check.cc b/src/clients/adjutrix/downgrade_check.cc
index aab91f9..991ce9b 100644
--- a/src/clients/adjutrix/downgrade_check.cc
+++ b/src/clients/adjutrix/downgrade_check.cc
@@ -25,6 +25,7 @@
#include <paludis/util/tokeniser.hh>
#include <fstream>
#include <iostream>
+#include <vector>
#include <map>
using namespace paludis;
diff --git a/src/clients/inquisitio/extractor.cc b/src/clients/inquisitio/extractor.cc
index 0a2d763..82d7bf6 100644
--- a/src/clients/inquisitio/extractor.cc
+++ b/src/clients/inquisitio/extractor.cc
@@ -20,10 +20,15 @@
#include "extractor.hh"
#include "description_extractor.hh"
#include "name_extractor.hh"
+#include <paludis/util/virtual_constructor-impl.hh>
using namespace inquisitio;
using namespace paludis;
+template class paludis::VirtualConstructor<std::string,
+ std::tr1::shared_ptr<Extractor> (*) (const paludis::Environment &),
+ paludis::virtual_constructor_not_found::ThrowException<NoSuchExtractorError> >;
+
NoSuchExtractorError::NoSuchExtractorError(const std::string & m) throw () :
Exception("No such extractor '" + m + "'")
{
diff --git a/src/clients/inquisitio/matcher.cc b/src/clients/inquisitio/matcher.cc
index c060822..c734441 100644
--- a/src/clients/inquisitio/matcher.cc
+++ b/src/clients/inquisitio/matcher.cc
@@ -20,10 +20,15 @@
#include "matcher.hh"
#include "pcre_matcher.hh"
#include "text_matcher.hh"
+#include <paludis/util/virtual_constructor-impl.hh>
using namespace inquisitio;
using namespace paludis;
+template class paludis::VirtualConstructor<std::string,
+ std::tr1::shared_ptr<Matcher> (*) (const std::string &),
+ paludis::virtual_constructor_not_found::ThrowException<NoSuchMatcherError> >;
+
Matcher::Matcher()
{
}
diff --git a/src/clients/paludis/applets.cc b/src/clients/paludis/applets.cc
index 32ced30..955e034 100644
--- a/src/clients/paludis/applets.cc
+++ b/src/clients/paludis/applets.cc
@@ -28,6 +28,7 @@
#include <paludis/util/dir_iterator.hh>
#include <paludis/util/system.hh>
#include <paludis/util/tokeniser.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
#include <paludis/repositories/repository_maker.hh>
#include <string>
#include <set>
diff --git a/src/clients/qualudis/qualudis.cc b/src/clients/qualudis/qualudis.cc
index 9006c6c..b280e8e 100644
--- a/src/clients/qualudis/qualudis.cc
+++ b/src/clients/qualudis/qualudis.cc
@@ -25,11 +25,13 @@
#include <paludis/util/log.hh>
#include <paludis/util/is_file_with_extension.hh>
#include <paludis/util/strip.hh>
+#include <paludis/util/virtual_constructor-impl.hh>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <set>
+#include <tr1/functional>
#include <libebt/libebt.hh>
#include <libwrapiter/libwrapiter.hh>
@@ -302,7 +304,7 @@ namespace
std::list<FSEntry> files((DirIterator(dir)), DirIterator());
for (std::list<FSEntry>::iterator f(files.begin()) ; f != files.end() ; ++f)
{
- if (! IsFileWithExtension(".ebuild")(*f))
+ if (! is_file_with_extension(*f, ".ebuild", IsFileWithOptions()))
continue;
qa::EbuildCheckData d(
@@ -323,7 +325,7 @@ namespace
std::list<FSEntry> files((DirIterator(dir)), DirIterator());
for (std::list<FSEntry>::iterator f(files.begin()) ; f != files.end() ; ++f)
{
- if (! IsFileWithExtension(".ebuild")(*f))
+ if (! is_file_with_extension(*f, ".ebuild", IsFileWithOptions()))
continue;
for (RepositoryPortageInterface::ProfilesIterator
@@ -444,7 +446,7 @@ namespace
continue;
else if ('.' == d->basename().at(0))
continue;
- else if (IsFileWithExtension(".eclass")(d->basename()))
+ else if (is_file_with_extension(d->basename(), ".eclass", IsFileWithOptions()))
{
bool fatal(false);
@@ -523,6 +525,8 @@ namespace
bool
do_check(const FSEntry & dir)
{
+ using namespace std::tr1::placeholders;
+
Context context("When checking directory '" + stringify(dir) + "':");
if (dir.basename() == "eclass" && dir.is_directory())
@@ -539,8 +543,8 @@ namespace
return do_check_profiles_dir(dir, env);
}
- if (std::count_if(DirIterator(dir), DirIterator(), IsFileWithExtension(
- dir.basename() + "-", ".ebuild")))
+ if (std::count_if(DirIterator(dir), DirIterator(),
+ std::tr1::bind(&is_file_with_prefix_extension, _1, dir.basename() + "-", ".ebuild", IsFileWithOptions())))
{
qa::QAEnvironment env(dir.dirname().dirname(), QualudisCommandLine::get_instance()->a_write_cache_dir.argument(),
QualudisCommandLine::get_instance()->a_master_repository_dir.argument());