aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-09 21:14:17 +0100
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2010-06-09 21:14:17 +0100
commit5dbb7636dd880314d5b03379ebfd960b469ee6e9 (patch)
tree6a9a062efbf6aa03dcbdc92b6abf156108904ea2
parentc9137efc3ef08b5c52f775dd853c1c675e80cc64 (diff)
downloadpaludis-5dbb7636dd880314d5b03379ebfd960b469ee6e9.tar.gz
paludis-5dbb7636dd880314d5b03379ebfd960b469ee6e9.tar.xz
Replace Validated with WrappedValue
Slightly cleaner code, and will allow us to pass in additional validation options.
-rw-r--r--.gitignore2
-rw-r--r--paludis/choice-fwd.hh20
-rw-r--r--paludis/choice.cc63
-rw-r--r--paludis/choice.hh62
-rw-r--r--paludis/create_output_manager_info.cc1
-rw-r--r--paludis/elike_dep_parser-fwd.hh3
-rw-r--r--paludis/environment.cc11
-rw-r--r--paludis/environments/no_config/no_config_environment.cc5
-rw-r--r--paludis/environments/paludis/paludis_config.cc4
-rw-r--r--paludis/fuzzy_finder.cc4
-rw-r--r--paludis/generator.cc6
-rw-r--r--paludis/name-fwd.hh84
-rw-r--r--paludis/name.cc281
-rw-r--r--paludis/name.hh209
-rw-r--r--paludis/package_database.cc2
-rw-r--r--paludis/package_id.cc6
-rw-r--r--paludis/paludislike_options_conf.cc1
-rw-r--r--paludis/repositories/e/e_choice_value.hh3
-rw-r--r--paludis/repositories/e/e_choices_key.cc4
-rw-r--r--paludis/repositories/e/e_repository_sets.cc6
-rw-r--r--paludis/repositories/e/iuse.cc4
-rw-r--r--paludis/repositories/e/metadata_xml.cc3
-rw-r--r--paludis/repositories/e/myoption.cc3
-rw-r--r--paludis/repositories/e/myoption.hh3
-rw-r--r--paludis/repositories/e/use_desc.cc6
-rw-r--r--paludis/repositories/e/xml_things.cc1
-rw-r--r--paludis/repositories/fake/fake_package_id.cc4
-rw-r--r--paludis/repositories/unavailable/unavailable_repository_dependencies_key.cc1
-rw-r--r--paludis/repositories/unpackaged/installed_id.cc2
-rw-r--r--paludis/repositories/unpackaged/unpackaged_id.cc2
-rw-r--r--paludis/repositories/unpackaged/unpackaged_key.cc1
-rw-r--r--paludis/repositories/unwritten/unwritten_id.cc2
-rw-r--r--paludis/repositories/virtuals/installed_virtuals_repository.cc8
-rw-r--r--paludis/repositories/virtuals/virtuals_repository.cc10
-rw-r--r--paludis/resolver/decider.cc4
-rw-r--r--paludis/resolver/destination.hh1
-rw-r--r--paludis/unchoices_key.cc1
-rw-r--r--paludis/util/files.m42
-rw-r--r--paludis/util/hashes.hh12
-rw-r--r--paludis/util/stringify.hh10
-rw-r--r--paludis/util/validated.hh150
-rw-r--r--paludis/util/validated_TEST.cc126
-rw-r--r--paludis/util/wrapped_value-fwd.hh (renamed from paludis/util/validated-fwd.hh)32
-rw-r--r--paludis/util/wrapped_value-impl.hh104
-rw-r--r--paludis/util/wrapped_value.hh66
-rw-r--r--paludis/util/wrapped_value_TEST.cc107
-rw-r--r--python/Makefile.am2
-rw-r--r--python/choices.cc11
-rw-r--r--python/iterable.hh7
-rw-r--r--python/name.cc38
-rwxr-xr-xpython/name_TEST.py7
-rw-r--r--python/nice_names.nn1
-rw-r--r--python/validated.hh80
-rw-r--r--python/wrapped_value.hh56
-rw-r--r--ruby/qualified_package_name.cc28
-rw-r--r--ruby/qualified_package_name_TEST.rb16
-rw-r--r--ruby/repository_TEST.rb6
-rw-r--r--src/clients/adjutrix/command_line.cc8
-rw-r--r--src/clients/adjutrix/find_stable_candidates.cc2
-rw-r--r--src/clients/adjutrix/what_needs_keywording.cc2
-rw-r--r--src/clients/appareo/command_line.cc8
-rw-r--r--src/clients/cave/cmd_find_candidates.cc2
-rw-r--r--src/clients/cave/cmd_fix_cache.cc4
-rw-r--r--src/clients/cave/cmd_print_categories.cc8
-rw-r--r--src/clients/cave/cmd_print_repositories.cc2
-rw-r--r--src/clients/cave/cmd_show.cc4
-rw-r--r--src/clients/cave/cmd_sync.cc2
-rw-r--r--src/clients/importare/install.cc4
-rw-r--r--src/clients/inquisitio/command_line.cc11
-rw-r--r--src/clients/paludis/command_line.cc14
-rw-r--r--src/clients/paludis/install.cc4
-rw-r--r--src/output/console_install_task.hh4
-rw-r--r--src/output/console_query_task.cc4
73 files changed, 751 insertions, 1026 deletions
diff --git a/.gitignore b/.gitignore
index f186745..8d63900 100644
--- a/.gitignore
+++ b/.gitignore
@@ -432,12 +432,12 @@ paludis-*.*.*.tar.bz2
/paludis/util/tokeniser_TEST
/paludis/util/tribool_TEST
/paludis/util/util.hh
-/paludis/util/validated_TEST
/paludis/util/virtual_constructor_TEST
/paludis/util/visitor_TEST
/paludis/util/visitor_cast_TEST
/paludis/util/wildcard_expander_TEST
/paludis/util/wrapped_forward_iterator_TEST
+/paludis/util/wrapped_value_TEST
/paludis/version_operator_TEST
/paludis/version_spec_TEST
/pkg-config/paludis.pc
diff --git a/paludis/choice-fwd.hh b/paludis/choice-fwd.hh
index a8aa233..120a9c0 100644
--- a/paludis/choice-fwd.hh
+++ b/paludis/choice-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -21,7 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_CHOICE_FWD_HH 1
#include <paludis/util/attributes.hh>
-#include <paludis/util/validated-fwd.hh>
+#include <paludis/util/wrapped_value-fwd.hh>
/** \file
* Forward declarations for paludis/choice.hh .
@@ -39,9 +39,13 @@ namespace paludis
class ChoiceParams;
- struct ChoicePrefixNameValidator;
- struct ChoiceNameWithPrefixValidator;
- struct UnprefixedChoiceNameValidator;
+ struct ChoicePrefixNameTag;
+ struct ChoiceNameWithPrefixTag;
+ struct UnprefixedChoiceNameTag;
+
+ template <> struct WrappedValueTraits<ChoicePrefixNameTag>;
+ template <> struct WrappedValueTraits<ChoiceNameWithPrefixTag>;
+ template <> struct WrappedValueTraits<UnprefixedChoiceNameTag>;
/**
* A prefix for a choice name ('' for USE, 'linguas' for LINGUAS etc).
@@ -49,7 +53,7 @@ namespace paludis
* \ingroup g_choices
* \since 0.32
*/
- typedef Validated<std::string, ChoicePrefixNameValidator> ChoicePrefixName;
+ typedef WrappedValue<ChoicePrefixNameTag> ChoicePrefixName;
/**
* A choice name, including prefix and delim ('nls' for USE, 'linguas_en' for LINGUAS etc).
@@ -57,7 +61,7 @@ namespace paludis
* \ingroup g_choices
* \since 0.32
*/
- typedef Validated<std::string, ChoiceNameWithPrefixValidator> ChoiceNameWithPrefix;
+ typedef WrappedValue<ChoiceNameWithPrefixTag> ChoiceNameWithPrefix;
/**
* A choice name, without prefix or delim ('nls' for USE, 'en' for LINGUAS etc).
@@ -65,7 +69,7 @@ namespace paludis
* \ingroup g_choices
* \since 0.32
*/
- typedef Validated<std::string, UnprefixedChoiceNameValidator> UnprefixedChoiceName;
+ typedef WrappedValue<UnprefixedChoiceNameTag> UnprefixedChoiceName;
}
#endif
diff --git a/paludis/choice.cc b/paludis/choice.cc
index 1747b18..d818cf3 100644
--- a/paludis/choice.cc
+++ b/paludis/choice.cc
@@ -20,11 +20,12 @@
#include <paludis/choice.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/wrapped_forward_iterator-impl.hh>
+#include <paludis/util/wrapped_output_iterator-impl.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/exception.hh>
-#include <paludis/util/validated.hh>
#include <paludis/util/set-impl.hh>
+#include <paludis/util/wrapped_value-impl.hh>
#include <list>
using namespace paludis;
@@ -52,8 +53,8 @@ ChoicePrefixNameError::ChoicePrefixNameError(const std::string & n) throw () :
{
}
-void
-ChoicePrefixNameValidator::validate(const std::string & s)
+bool
+WrappedValueTraits<ChoicePrefixNameTag>::validate(const std::string & s)
{
if (! s.empty())
{
@@ -61,8 +62,7 @@ ChoicePrefixNameValidator::validate(const std::string & s)
{
case ':':
case '_':
- throw ChoicePrefixNameError(s);
- break;
+ return false;
};
switch (s.at(0))
@@ -70,16 +70,17 @@ ChoicePrefixNameValidator::validate(const std::string & s)
case ':':
case '_':
case '-':
- throw ChoicePrefixNameError(s);
- break;
+ return false;
};
if (s[0] >= 'A' && s[0] <= 'Z')
- throw ChoicePrefixNameError(s);
+ return false;
if (std::string::npos != s.find(" \t\r\n()"))
- throw ChoicePrefixNameError(s);
+ return false;
}
+
+ return true;
}
ChoiceNameWithPrefixError::ChoiceNameWithPrefixError(const std::string & n) throw () :
@@ -87,8 +88,8 @@ ChoiceNameWithPrefixError::ChoiceNameWithPrefixError(const std::string & n) thro
{
}
-void
-ChoiceNameWithPrefixValidator::validate(const std::string & s)
+bool
+WrappedValueTraits<ChoiceNameWithPrefixTag>::validate(const std::string & s)
{
if (s.empty())
throw ChoiceNameWithPrefixError(s);
@@ -97,8 +98,7 @@ ChoiceNameWithPrefixValidator::validate(const std::string & s)
{
case ':':
case '_':
- throw ChoiceNameWithPrefixError(s);
- break;
+ return false;
};
switch (s.at(0))
@@ -106,12 +106,13 @@ ChoiceNameWithPrefixValidator::validate(const std::string & s)
case ':':
case '_':
case '-':
- throw ChoiceNameWithPrefixError(s);
- break;
+ return false;
};
if (std::string::npos != s.find(" \t\r\n()"))
- throw ChoiceNameWithPrefixError(s);
+ return false;
+
+ return true;
}
UnprefixedChoiceNameError::UnprefixedChoiceNameError(const std::string & n) throw () :
@@ -119,17 +120,17 @@ UnprefixedChoiceNameError::UnprefixedChoiceNameError(const std::string & n) thro
{
}
-void
-UnprefixedChoiceNameValidator::validate(const std::string & s)
+bool
+WrappedValueTraits<UnprefixedChoiceNameTag>::validate(const std::string & s)
{
if (s.empty())
- throw ChoiceNameWithPrefixError(s);
+ return false;
switch (s.at(s.length() - 1))
{
case ':':
case '_':
- throw ChoiceNameWithPrefixError(s);
+ return false;
break;
};
@@ -138,12 +139,14 @@ UnprefixedChoiceNameValidator::validate(const std::string & s)
case ':':
case '_':
case '-':
- throw ChoiceNameWithPrefixError(s);
+ return false;
break;
};
if (std::string::npos != s.find(" \t\r\n()"))
- throw ChoiceNameWithPrefixError(s);
+ return false;
+
+ return true;
}
namespace paludis
@@ -198,7 +201,7 @@ Choices::find_by_name_with_prefix(const ChoiceNameWithPrefix & f) const
for (ConstIterator i(begin()), i_end(end()) ;
i != i_end ; ++i)
{
- if (0 != (*i)->prefix().data().compare(0, (*i)->prefix().data().length(), f.data(), 0, (*i)->prefix().data().length()))
+ if (0 != (*i)->prefix().value().compare(0, (*i)->prefix().value().length(), f.value(), 0, (*i)->prefix().value().length()))
continue;
for (Choice::ConstIterator j((*i)->begin()), j_end((*i)->end()) ;
@@ -216,7 +219,7 @@ Choices::has_matching_contains_every_value_prefix(const ChoiceNameWithPrefix & f
for (ConstIterator i(begin()), i_end(end()) ;
i != i_end ; ++i)
{
- if (0 != (*i)->prefix().data().compare(0, (*i)->prefix().data().length(), f.data(), 0, (*i)->prefix().data().length()))
+ if (0 != (*i)->prefix().value().compare(0, (*i)->prefix().value().length(), f.value(), 0, (*i)->prefix().value().length()))
continue;
if ((*i)->contains_every_value())
@@ -320,10 +323,16 @@ template class PrivateImplementationPattern<Choice>;
template class WrappedForwardIterator<Choices::ConstIteratorTag, const std::tr1::shared_ptr<const Choice> >;
template class WrappedForwardIterator<Choice::ConstIteratorTag, const std::tr1::shared_ptr<const ChoiceValue> >;
-template class Validated<std::string, UnprefixedChoiceNameValidator>;
-template class Validated<std::string, ChoicePrefixNameValidator>;
-template class Validated<std::string, ChoiceNameWithPrefixValidator>;
+template class WrappedValue<UnprefixedChoiceNameTag>;
+template std::ostream & paludis::operator<< (std::ostream &, const WrappedValue<UnprefixedChoiceNameTag> &);
+
+template class WrappedValue<ChoicePrefixNameTag>;
+template std::ostream & paludis::operator<< (std::ostream &, const WrappedValue<ChoicePrefixNameTag> &);
+
+template class WrappedValue<ChoiceNameWithPrefixTag>;
+template std::ostream & paludis::operator<< (std::ostream &, const WrappedValue<ChoiceNameWithPrefixTag> &);
template class Set<UnprefixedChoiceName>;
template class WrappedForwardIterator<Set<UnprefixedChoiceName>::ConstIteratorTag, const UnprefixedChoiceName>;
+template class WrappedOutputIterator<Set<UnprefixedChoiceName>::InserterTag, UnprefixedChoiceName>;
diff --git a/paludis/choice.hh b/paludis/choice.hh
index 272586a..de8ce29 100644
--- a/paludis/choice.hh
+++ b/paludis/choice.hh
@@ -26,7 +26,7 @@
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/named_value.hh>
-#include <paludis/util/validated.hh>
+#include <paludis/util/wrapped_value.hh>
#include <tr1/memory>
#include <string>
@@ -96,52 +96,34 @@ namespace paludis
UnprefixedChoiceNameError(const std::string &) throw ();
};
- /**
- * A ChoicePrefixNameValidator handles validation for ChoicePrefixName.
- *
- * \ingroup g_choices
- * \since 0.32
- */
- struct PALUDIS_VISIBLE ChoicePrefixNameValidator :
- private InstantiationPolicy<ChoicePrefixNameValidator, instantiation_method::NonInstantiableTag>
+ template <>
+ struct WrappedValueTraits<ChoicePrefixNameTag>
{
- /**
- * If the parameter is not a valid value for a ChoicePrefixName, throw
- * a ChoicePrefixNameError.
- */
- static void validate(const std::string &);
+ typedef std::string UnderlyingType;
+ typedef void ValidationParamsType;
+ typedef ChoicePrefixNameError ExceptionType;
+
+ static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
};
- /**
- * A ChoiceNameWithPrefixValidator handles validation for ChoicePrefixName.
- *
- * \ingroup g_choices
- * \since 0.32
- */
- struct PALUDIS_VISIBLE ChoiceNameWithPrefixValidator :
- private InstantiationPolicy<ChoiceNameWithPrefixValidator, instantiation_method::NonInstantiableTag>
+ template <>
+ struct WrappedValueTraits<UnprefixedChoiceNameTag>
{
- /**
- * If the parameter is not a valid value for a ChoiceNameWithPrefix, throw
- * a ChoiceNameWithPrefixError.
- */
- static void validate(const std::string &);
+ typedef std::string UnderlyingType;
+ typedef void ValidationParamsType;
+ typedef UnprefixedChoiceNameError ExceptionType;
+
+ static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
};
- /**
- * A UnprefixedChoiceNameValidator handles validation for ChoicePrefixName.
- *
- * \ingroup g_choices
- * \since 0.32
- */
- struct PALUDIS_VISIBLE UnprefixedChoiceNameValidator :
- private InstantiationPolicy<UnprefixedChoiceNameValidator, instantiation_method::NonInstantiableTag>
+ template <>
+ struct WrappedValueTraits<ChoiceNameWithPrefixTag>
{
- /**
- * If the parameter is not a valid value for a UnprefixedChoiceName, throw
- * a UnprefixedChoiceNameError.
- */
- static void validate(const std::string &);
+ typedef std::string UnderlyingType;
+ typedef void ValidationParamsType;
+ typedef ChoiceNameWithPrefixError ExceptionType;
+
+ static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
diff --git a/paludis/create_output_manager_info.cc b/paludis/create_output_manager_info.cc
index b37f6e7..b768e2e 100644
--- a/paludis/create_output_manager_info.cc
+++ b/paludis/create_output_manager_info.cc
@@ -21,7 +21,6 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/exception.hh>
-#include <paludis/util/validated.hh>
#include <paludis/util/set.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/serialise-impl.hh>
diff --git a/paludis/elike_dep_parser-fwd.hh b/paludis/elike_dep_parser-fwd.hh
index e620cbc..8474a05 100644
--- a/paludis/elike_dep_parser-fwd.hh
+++ b/paludis/elike_dep_parser-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -25,6 +25,7 @@
#include <paludis/name-fwd.hh>
#include <tr1/functional>
#include <tr1/memory>
+#include <string>
namespace paludis
{
diff --git a/paludis/environment.cc b/paludis/environment.cc
index 534c799..fa194c9 100644
--- a/paludis/environment.cc
+++ b/paludis/environment.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -18,12 +18,6 @@
*/
#include <paludis/environment.hh>
-#include <paludis/util/exception.hh>
-#include <paludis/util/stringify.hh>
-#include <paludis/util/sequence-impl.hh>
-#include <paludis/util/wrapped_forward_iterator-impl.hh>
-#include <paludis/util/wrapped_output_iterator-impl.hh>
-#include <paludis/util/set-impl.hh>
using namespace paludis;
@@ -31,6 +25,3 @@ Environment::~Environment()
{
}
-template class Set<UnprefixedChoiceName>;
-template class WrappedForwardIterator<Set<UnprefixedChoiceName>::ConstIteratorTag, const UnprefixedChoiceName>;
-template class WrappedOutputIterator<Set<UnprefixedChoiceName>::InserterTag, UnprefixedChoiceName>;
diff --git a/paludis/environments/no_config/no_config_environment.cc b/paludis/environments/no_config/no_config_environment.cc
index ac408ee..d2bd70a 100644
--- a/paludis/environments/no_config/no_config_environment.cc
+++ b/paludis/environments/no_config/no_config_environment.cc
@@ -42,6 +42,7 @@
#include <paludis/hook.hh>
#include <paludis/literal_metadata_key.hh>
#include <paludis/repository_factory.hh>
+#include <paludis/choice.hh>
#include <tr1/unordered_map>
#include <tr1/functional>
#include <algorithm>
@@ -243,9 +244,9 @@ Implementation<NoConfigEnvironment>::initialise(NoConfigEnvironment * const env)
}
/* work out order for repository creation */
- DirectedGraph<RepositoryName, bool, RepositoryNameComparator> repository_deps;
+ DirectedGraph<RepositoryName, bool> repository_deps;
std::for_each(first_iterator(repo_configs.begin()), first_iterator(repo_configs.end()), std::tr1::bind(
- std::tr1::mem_fn(&DirectedGraph<RepositoryName, bool, RepositoryNameComparator>::add_node),
+ std::tr1::mem_fn(&DirectedGraph<RepositoryName, bool>::add_node),
&repository_deps, std::tr1::placeholders::_1));
for (std::tr1::unordered_map<RepositoryName, std::tr1::function<std::string (const std::string &)>, Hash<RepositoryName> >::const_iterator
diff --git a/paludis/environments/paludis/paludis_config.cc b/paludis/environments/paludis/paludis_config.cc
index 75f8e71..8b57461 100644
--- a/paludis/environments/paludis/paludis_config.cc
+++ b/paludis/environments/paludis/paludis_config.cc
@@ -588,9 +588,9 @@ PaludisConfig::PaludisConfig(PaludisEnvironment * const e, const std::string & s
}
/* work out order for repository creation */
- DirectedGraph<RepositoryName, bool, RepositoryNameComparator> repository_deps;
+ DirectedGraph<RepositoryName, bool> repository_deps;
std::for_each(first_iterator(repo_configs.begin()), first_iterator(repo_configs.end()),
- std::tr1::bind(std::tr1::mem_fn(&DirectedGraph<RepositoryName, bool, RepositoryNameComparator>::add_node), &repository_deps, _1));
+ std::tr1::bind(std::tr1::mem_fn(&DirectedGraph<RepositoryName, bool>::add_node), &repository_deps, _1));
for (std::tr1::unordered_map<RepositoryName, std::tr1::function<std::string (const std::string &)>, Hash<RepositoryName> >::const_iterator
r(repo_configs.begin()), r_end(repo_configs.end()) ; r != r_end ; ++r)
diff --git a/paludis/fuzzy_finder.cc b/paludis/fuzzy_finder.cc
index a282d6e..d6a9942 100644
--- a/paludis/fuzzy_finder.cc
+++ b/paludis/fuzzy_finder.cc
@@ -98,8 +98,8 @@ namespace
for (QualifiedPackageNameSet::ConstIterator p(pkgs->begin()),
p_end(pkgs->end()); p_end != p; ++p)
- if (tolower(p->package().data()[0]) == _first_char &&
- _distance_calculator.distance_with(tolower_0_cost(p->package().data())) <= _threshold)
+ if (tolower(p->package().value()[0]) == _first_char &&
+ _distance_calculator.distance_with(tolower_0_cost(p->package().value())) <= _threshold)
result->insert(*p);
return result;
diff --git a/paludis/generator.cc b/paludis/generator.cc
index 401d4b7..626560f 100644
--- a/paludis/generator.cc
+++ b/paludis/generator.cc
@@ -491,8 +491,7 @@ namespace
std::set_intersection(
r1->begin(), r1->end(),
r2->begin(), r2->end(),
- result->inserter(),
- RepositoryNameComparator());
+ result->inserter());
return result;
}
@@ -586,8 +585,7 @@ namespace
std::set_union(
r1->begin(), r1->end(),
r2->begin(), r2->end(),
- result->inserter(),
- RepositoryNameComparator());
+ result->inserter());
return result;
}
diff --git a/paludis/name-fwd.hh b/paludis/name-fwd.hh
index 4ad1fa2..6bf645f 100644
--- a/paludis/name-fwd.hh
+++ b/paludis/name-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -20,11 +20,11 @@
#ifndef PALUDIS_GUARD_PALUDIS_NAME_FWD_HH
#define PALUDIS_GUARD_PALUDIS_NAME_FWD_HH 1
-#include <paludis/util/validated-fwd.hh>
+#include <paludis/util/wrapped_value-fwd.hh>
#include <paludis/util/set-fwd.hh>
#include <paludis/util/sequence-fwd.hh>
#include <paludis/util/attributes.hh>
-#include <string>
+#include <iosfwd>
/** \file
* Forward declarations for paludis/name.hh .
@@ -34,8 +34,9 @@
namespace paludis
{
+ class PackageNamePartTag;
class PackageNamePartError;
- class PackageNamePartValidator;
+ template <> struct WrappedValueTraits<PackageNamePartTag>;
/**
* A PackageNamePart holds a std::string that is a valid name for the
@@ -43,17 +44,13 @@ namespace paludis
*
* \ingroup g_names
*/
- typedef Validated<std::string, PackageNamePartValidator> PackageNamePart;
+ typedef WrappedValue<PackageNamePartTag> PackageNamePart;
- /**
- * Holds a set of PackageNamePart instances.
- *
- * \ingroup g_names
- */
typedef Set<PackageNamePart> PackageNamePartSet;
+ class CategoryNamePartTag;
class CategoryNamePartError;
- class CategoryNamePartValidator;
+ template <> struct WrappedValueTraits<CategoryNamePartTag>;
/**
* A CategoryNamePart holds a std::string that is a valid name for the
@@ -61,13 +58,8 @@ namespace paludis
*
* \ingroup g_names
*/
- typedef Validated<std::string, CategoryNamePartValidator> CategoryNamePart;
+ typedef WrappedValue<CategoryNamePartTag> CategoryNamePart;
- /**
- * Holds a set of CategoryNamePart instances.
- *
- * \ingroup g_names
- */
typedef Set<CategoryNamePart> CategoryNamePartSet;
class QualifiedPackageName;
@@ -80,15 +72,6 @@ namespace paludis
std::ostream & operator<< (std::ostream &, const QualifiedPackageName &) PALUDIS_VISIBLE;
/**
- * Holds a collection of QualifiedPackageName instances.
- *
- * \ingroup g_names
- */
- typedef Set<QualifiedPackageName> QualifiedPackageNameSet;
-
- class QualifiedPackageNameError;
-
- /**
* A CategoryNamePart plus a PackageNamePart is a QualifiedPackageName.
*
* \ingroup g_names
@@ -96,18 +79,22 @@ namespace paludis
inline const QualifiedPackageName
operator+ (const CategoryNamePart & c, const PackageNamePart & p) PALUDIS_ATTRIBUTE((warn_unused_result));
+ class SlotNameTag;
class SlotNameError;
- class SlotNameValidator;
+ template <> struct WrappedValueTraits<SlotNameTag>;
+
+ typedef Set<QualifiedPackageName> QualifiedPackageNameSet;
/**
* A SlotName holds a std::string that is a valid name for a SLOT.
*
* \ingroup g_names
*/
- typedef Validated<std::string, SlotNameValidator> SlotName;
+ typedef WrappedValue<SlotNameTag> SlotName;
+ class RepositoryNameTag;
class RepositoryNameError;
- class RepositoryNameValidator;
+ template <> struct WrappedValueTraits<RepositoryNameTag>;
/**
* A RepositoryName holds a std::string that is a valid name for a
@@ -115,57 +102,34 @@ namespace paludis
*
* \ingroup g_names
*/
- typedef Validated<std::string, RepositoryNameValidator, false> RepositoryName;
+ typedef WrappedValue<RepositoryNameTag> RepositoryName;
- /**
- * Holds a collection of RepositoryName instances.
- *
- * \ingroup g_names
- */
- typedef Sequence<RepositoryName> RepositoryNameSequence;
-
- class RepositoryNameComparator;
-
- /**
- * Holds an arbitrarily ordered collection of RepositoryName instances.
- *
- * \ingroup g_names
- */
- typedef Set<RepositoryName, RepositoryNameComparator> RepositoryNameSet;
+ typedef Set<RepositoryName> RepositoryNameSet;
- class KeywordNameValidator;
+ class KeywordNameTag;
class KeywordNameError;
- class KeywordNameComparator;
+ template <> struct WrappedValueTraits<KeywordNameTag>;
/**
* A KeywordName holds a std::string that is a valid name for a KEYWORD.
*
* \ingroup g_names
*/
- typedef Validated<std::string, KeywordNameValidator, true, KeywordNameComparator> KeywordName;
+ typedef WrappedValue<KeywordNameTag> KeywordName;
- /**
- * Holds a collection of KeywordName instances.
- *
- * \ingroup g_names
- */
typedef Set<KeywordName> KeywordNameSet;
- class SetNameValidator;
+ class SetNameTag;
class SetNameError;
+ template <> struct WrappedValueTraits<SetNameTag>;
/**
* A SetName holds a std::string that is a valid name for a set.
*
* \ingroup g_names
*/
- typedef Validated<std::string, SetNameValidator> SetName;
+ typedef WrappedValue<SetNameTag> SetName;
- /**
- * A collection of set names.
- *
- * \ingroup g_names
- */
typedef Set<SetName> SetNameSet;
}
diff --git a/paludis/name.cc b/paludis/name.cc
index 7f9641e..185e9e4 100644
--- a/paludis/name.cc
+++ b/paludis/name.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -27,6 +27,7 @@
#include <paludis/util/wrapped_output_iterator-impl.hh>
#include <paludis/util/options.hh>
#include <paludis/util/hashes.hh>
+#include <paludis/util/wrapped_value-impl.hh>
#include <ostream>
#include <utility>
@@ -35,9 +36,9 @@ using namespace paludis;
template struct Sequence<RepositoryName>;
template struct WrappedForwardIterator<Sequence<RepositoryName>::ConstIteratorTag, const RepositoryName>;
-template struct Set<RepositoryName, RepositoryNameComparator>;
-template struct WrappedForwardIterator<Set<RepositoryName, RepositoryNameComparator>::ConstIteratorTag, const RepositoryName>;
-template struct WrappedOutputIterator<Set<RepositoryName, RepositoryNameComparator>::InserterTag, RepositoryName>;
+template struct Set<RepositoryName>;
+template struct WrappedForwardIterator<Set<RepositoryName>::ConstIteratorTag, const RepositoryName>;
+template struct WrappedOutputIterator<Set<RepositoryName>::InserterTag, RepositoryName>;
template struct Set<PackageNamePart>;
template struct WrappedForwardIterator<Set<PackageNamePart>::ConstIteratorTag, const PackageNamePart>;
@@ -63,10 +64,23 @@ template struct Set<std::string>;
template struct WrappedForwardIterator<Set<std::string>::ConstIteratorTag, const std::string>;
template struct WrappedOutputIterator<Set<std::string>::InserterTag, std::string>;
-QualifiedPackageNameError::QualifiedPackageNameError(const std::string & s) throw () :
- NameError(s, "qualified package name")
-{
-}
+template struct WrappedValue<RepositoryNameTag>;
+template std::ostream & paludis::operator<< (std::ostream &, const WrappedValue<RepositoryNameTag> &);
+
+template struct WrappedValue<CategoryNamePartTag>;
+template std::ostream & paludis::operator<< (std::ostream &, const WrappedValue<CategoryNamePartTag> &);
+
+template struct WrappedValue<PackageNamePartTag>;
+template std::ostream & paludis::operator<< (std::ostream &, const WrappedValue<PackageNamePartTag> &);
+
+template struct WrappedValue<SlotNameTag>;
+template std::ostream & paludis::operator<< (std::ostream &, const WrappedValue<SlotNameTag> &);
+
+template struct WrappedValue<KeywordNameTag>;
+template std::ostream & paludis::operator<< (std::ostream &, const WrappedValue<KeywordNameTag> &);
+
+template struct WrappedValue<SetNameTag>;
+template std::ostream & paludis::operator<< (std::ostream &, const WrappedValue<SetNameTag> &);
std::ostream &
paludis::operator<< (std::ostream & s, const QualifiedPackageName & q)
@@ -80,32 +94,24 @@ SlotNameError::SlotNameError(const std::string & name) throw () :
{
}
-void
-SlotNameValidator::validate(const std::string & s)
+bool
+WrappedValueTraits<SlotNameTag>::validate(const std::string & s)
{
static const std::string allowed_chars(
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789-+_.");
- do
- {
- if (s.empty())
- break;
-
- if ('-' == s[0] || '.' == s[0])
- break;
-
- if (std::string::npos != s.find_first_not_of(allowed_chars))
- break;
-
- return;
+ if (s.empty())
+ return false;
- } while (false);
+ if ('-' == s[0] || '.' == s[0])
+ return false;
- Context c("When validating slot name '" + s + "':");
+ if (std::string::npos != s.find_first_not_of(allowed_chars))
+ return false;
- throw SlotNameError(s);
+ return true;
}
PackageNamePartError::PackageNamePartError(const std::string & name) throw () :
@@ -113,11 +119,9 @@ PackageNamePartError::PackageNamePartError(const std::string & name) throw () :
{
}
-void
-PackageNamePartValidator::validate(const std::string & s)
+bool
+WrappedValueTraits<PackageNamePartTag>::validate(const std::string & s)
{
- /* this gets called a lot, make it fast */
-
static const std::string allowed_chars(
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
@@ -127,31 +131,25 @@ PackageNamePartValidator::validate(const std::string & s)
"0123456789");
if (s.empty() || '-' == s[0])
- {
- Context c("When validating package name part '" + s + "':");
- throw PackageNamePartError(s);
- }
+ return false;
for (std::string::size_type p(0) ; p < s.length() ; ++p)
{
if (std::string::npos == allowed_chars.find(s[p]))
- {
- Context c("When validating package name part '" + s + "':");
- throw PackageNamePartError(s);
- }
+ return false;
if ((p + 1 < s.length()) && (s[p] == '-') &&
(std::string::npos != number_chars.find(s[p + 1])))
if (std::string::npos == s.find_first_not_of(number_chars, p + 1))
- throw PackageNamePartError(s);
+ return false;
}
+
+ return true;
}
-void
-CategoryNamePartValidator::validate(const std::string & s)
+bool
+WrappedValueTraits<CategoryNamePartTag>::validate(const std::string & s)
{
- /* this gets called a lot, make it fast */
-
// Allow . because crossdev can create, for example,
// cross-i686-unknown-freebsd6.0 --spb
static const std::string allowed_chars(
@@ -159,23 +157,16 @@ CategoryNamePartValidator::validate(const std::string & s)
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789-+_.");
- do
- {
- if (s.empty())
- break;
-
- if ('-' == s[0] || '.' == s[0])
- break;
-
- if (std::string::npos != s.find_first_not_of(allowed_chars))
- break;
+ if (s.empty())
+ return false;
- return;
+ if ('-' == s[0] || '.' == s[0])
+ return false;
- } while (false);
+ if (std::string::npos != s.find_first_not_of(allowed_chars))
+ return false;
- Context c("When validating category name '" + s + "':");
- throw CategoryNamePartError(s);
+ return true;
}
CategoryNamePartError::CategoryNamePartError(const std::string & name) throw () :
@@ -183,31 +174,24 @@ CategoryNamePartError::CategoryNamePartError(const std::string & name) throw ()
{
}
-void
-RepositoryNameValidator::validate(const std::string & s)
+bool
+WrappedValueTraits<RepositoryNameTag>::validate(const std::string & s)
{
static const std::string allowed_chars(
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789-_");
- do
- {
- if (s.empty())
- break;
-
- if ('-' == s[0])
- break;
-
- if (std::string::npos != s.find_first_not_of(allowed_chars))
- break;
+ if (s.empty())
+ return false;
- return;
+ if ('-' == s[0])
+ return false;
- } while (false);
+ if (std::string::npos != s.find_first_not_of(allowed_chars))
+ return false;
- Context c("When validating repository name '" + s + "':");
- throw RepositoryNameError(s);
+ return true;
}
RepositoryNameError::RepositoryNameError(const std::string & name) throw () :
@@ -220,63 +204,36 @@ KeywordNameError::KeywordNameError(const std::string & name) throw () :
{
}
-void
-KeywordNameValidator::validate(const std::string & s)
+bool
+WrappedValueTraits<KeywordNameTag>::validate(const std::string & s)
{
static const std::string allowed_chars(
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789-_");
- do
+ switch (s.length())
{
- switch (s.length())
- {
- case 0:
- continue;
-
- case 1:
- if ("*" == s)
- return;
- continue;
-
- case 2:
- if ("-*" == s)
- return;
-
- /* fall through */
- default:
- if (std::string::npos != s.find_first_not_of(allowed_chars,
- ('~' == s[0] ? 1 : 0)))
- continue;
- }
-
- return;
-
- } while (false);
-
- Context c("When validating keyword name '" + s + "':");
- throw KeywordNameError(s);
-}
-
-bool
-KeywordNameComparator::operator() (const std::string & a, const std::string & b) const
-{
- char a_prefix('~' == a[0] || '-' == a[0] ? a[0] : '\0');
- char b_prefix('~' == b[0] || '-' == b[0] ? b[0] : '\0');
- const std::string a_keyword(a_prefix ? a.substr(1) : a);
- const std::string b_keyword(b_prefix ? b.substr(1) : b);
-
- if (a_keyword == b_keyword)
- {
- if ('\0' == a_prefix && '\0' != b_prefix)
- return true;
- if ('~' == a_prefix && '-' == b_prefix)
- return true;
- return false;
+ case 0:
+ return false;;
+
+ case 1:
+ if ("*" == s)
+ return true;
+ return false;
+
+ case 2:
+ if ("-*" == s)
+ return true;
+
+ /* fall through */
+ default:
+ if (std::string::npos != s.find_first_not_of(allowed_chars,
+ ('~' == s[0] ? 1 : 0)))
+ return false;
}
- else
- return a_keyword < b_keyword;
+
+ return true;
}
namespace
@@ -288,7 +245,7 @@ namespace
std::string::size_type p(s.find('/'));
if (std::string::npos == p)
- throw QualifiedPackageNameError(s);
+ throw CategoryNamePartError("/" + s);
return CategoryNamePart(s.substr(0, p));
@@ -301,7 +258,7 @@ namespace
std::string::size_type p(s.find('/'));
if (std::string::npos == p)
- throw QualifiedPackageNameError(s);
+ throw PackageNamePartError("/" + s);
return PackageNamePart(s.substr(p + 1));
@@ -309,14 +266,14 @@ namespace
}
QualifiedPackageName::QualifiedPackageName(const std::string & s) :
- category(get_category_name_part(s)),
- package(get_package_name_part(s))
+ _cat(get_category_name_part(s)),
+ _pkg(get_package_name_part(s))
{
}
QualifiedPackageName::QualifiedPackageName(const CategoryNamePart & c, const PackageNamePart & p) :
- category(c),
- package(p)
+ _cat(c),
+ _pkg(p)
{
}
@@ -337,52 +294,44 @@ QualifiedPackageName::operator== (const QualifiedPackageName & other) const
return category() == other.category() && package() == other.package();
}
-void
-SetNameValidator::validate(const std::string & s)
+bool
+WrappedValueTraits<SetNameTag>::validate(const std::string & s)
{
static const std::string allowed_chars(
"abcdefghijklmnopqrstuvwxyz"
"ABCDEFGHIJKLMNOPQRSTUVWXYZ"
"0123456789-+_:");
- do
+ if (s.empty())
+ return false;
+
+ if (s.length() > 1 && '*' == s[s.length() - 1] && '*' != s[s.length() - 2])
{
- if (s.empty())
- break;
-
- if (s.length() > 1 && '*' == s[s.length() - 1] && '*' != s[s.length() - 2])
- {
- Context c("When validating set name '" + s + "':");
- validate(s.substr(0, s.length() - 1));
- return;
- }
-
- if ('-' == s[0] || '.' == s[0])
- break;
-
- if (std::string::npos != s.find_first_not_of(allowed_chars))
- break;
-
- std::string::size_type p(s.find(':'));
- if (std::string::npos != p)
- {
- if (++p >= s.length())
- break;
- if (s[p] != ':')
- break;
-
- if (++p >= s.length())
- break;
- if (std::string::npos != s.find(':', p))
- break;
- }
-
- return;
-
- } while (false);
-
- Context c("When validating set name '" + s + "':");
- throw SetNameError(s);
+ Context c("When validating set name '" + s + "':");
+ return validate(s.substr(0, s.length() - 1));
+ }
+
+ if ('-' == s[0] || '.' == s[0])
+ return false;
+
+ if (std::string::npos != s.find_first_not_of(allowed_chars))
+ return false;
+
+ std::string::size_type p(s.find(':'));
+ if (std::string::npos != p)
+ {
+ if (++p >= s.length())
+ return false;
+ if (s[p] != ':')
+ return false;
+
+ if (++p >= s.length())
+ return false;
+ if (std::string::npos != s.find(':', p))
+ return false;
+ }
+
+ return true;
}
SetNameError::SetNameError(const std::string & name) throw () :
diff --git a/paludis/name.hh b/paludis/name.hh
index ebb2582..f386ecb 100644
--- a/paludis/name.hh
+++ b/paludis/name.hh
@@ -22,9 +22,8 @@
#include <paludis/name-fwd.hh>
#include <paludis/util/exception.hh>
-#include <paludis/util/instantiation_policy.hh>
-#include <paludis/util/validated.hh>
-#include <paludis/util/named_value.hh>
+#include <paludis/util/wrapped_value.hh>
+#include <paludis/util/operators.hh>
#include <string>
#include <iosfwd>
@@ -41,12 +40,6 @@
namespace paludis
{
- namespace n
- {
- typedef Name<struct category_name> category;
- typedef Name<struct package_name> package;
- }
-
/**
* A PackageNamePartError is thrown if an invalid value is assigned to
* a PackageNamePart.
@@ -64,20 +57,14 @@ namespace paludis
PackageNamePartError(const std::string & name) throw ();
};
- /**
- * A PackageNamePartValidator handles validation rules for the value
- * of a PackageNamePart.
- *
- * \ingroup g_names
- */
- struct PALUDIS_VISIBLE PackageNamePartValidator :
- private InstantiationPolicy<PackageNamePartValidator, instantiation_method::NonInstantiableTag>
+ template <>
+ struct PALUDIS_VISIBLE WrappedValueTraits<PackageNamePartTag>
{
- /**
- * If the parameter is not a valid value for a PackageNamePart,
- * throw a PackageNamePartError.
- */
- static void validate(const std::string &);
+ typedef std::string UnderlyingType;
+ typedef void ValidationParamsType;
+ typedef PackageNamePartError ExceptionType;
+
+ static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
@@ -97,20 +84,14 @@ namespace paludis
CategoryNamePartError(const std::string & name) throw ();
};
- /**
- * A CategoryNamePartValidator handles validation rules for the value
- * of a CategoryNamePart.
- *
- * \ingroup g_names
- */
- struct PALUDIS_VISIBLE CategoryNamePartValidator :
- private InstantiationPolicy<CategoryNamePartValidator, instantiation_method::NonInstantiableTag>
+ template <>
+ struct PALUDIS_VISIBLE WrappedValueTraits<CategoryNamePartTag>
{
- /**
- * If the parameter is not a valid value for a CategoryNamePart,
- * throw a CategoryNamePartError.
- */
- static void validate(const std::string &);
+ typedef std::string UnderlyingType;
+ typedef void ValidationParamsType;
+ typedef CategoryNamePartError ExceptionType;
+
+ static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
@@ -119,36 +100,31 @@ namespace paludis
* \ingroup g_names
* \nosubgrouping
*/
- struct PALUDIS_VISIBLE QualifiedPackageName :
- relational_operators::HasRelationalOperators
+ class PALUDIS_VISIBLE QualifiedPackageName :
+ public relational_operators::HasRelationalOperators
{
- NamedValue<n::category, CategoryNamePart> category;
- NamedValue<n::package, PackageNamePart> package;
+ private:
+ CategoryNamePart _cat;
+ PackageNamePart _pkg;
- QualifiedPackageName(const CategoryNamePart &, const PackageNamePart &);
- explicit QualifiedPackageName(const std::string &);
+ public:
+ QualifiedPackageName(const CategoryNamePart &, const PackageNamePart &);
+ explicit QualifiedPackageName(const std::string &);
- std::size_t hash() const PALUDIS_ATTRIBUTE((warn_unused_result));
+ std::size_t hash() const PALUDIS_ATTRIBUTE((warn_unused_result));
- bool operator< (const QualifiedPackageName &) const PALUDIS_ATTRIBUTE((warn_unused_result));
- bool operator== (const QualifiedPackageName &) const PALUDIS_ATTRIBUTE((warn_unused_result));
- };
+ bool operator< (const QualifiedPackageName &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ bool operator== (const QualifiedPackageName &) const PALUDIS_ATTRIBUTE((warn_unused_result));
- /**
- * A QualifiedPackageNameError may be thrown if an invalid name is
- * assigned to a QualifiedPackageName (alternatively, the exception
- * raised may be a PackageNamePartError or a CategoryNamePartError).
- *
- * \ingroup g_names
- * \ingroup g_exceptions
- */
- class PALUDIS_VISIBLE QualifiedPackageNameError : public NameError
- {
- public:
- /**
- * Constructor.
- */
- QualifiedPackageNameError(const std::string &) throw ();
+ const CategoryNamePart category() const PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ return _cat;
+ }
+
+ const PackageNamePart package() const PALUDIS_ATTRIBUTE((warn_unused_result))
+ {
+ return _pkg;
+ }
};
inline const QualifiedPackageName
@@ -173,20 +149,14 @@ namespace paludis
SlotNameError(const std::string & name) throw ();
};
- /**
- * A SlotNameValidator handles validation rules for the value of a
- * SlotName.
- *
- * \ingroup g_names
- */
- struct PALUDIS_VISIBLE SlotNameValidator :
- private InstantiationPolicy<SlotNameValidator, instantiation_method::NonInstantiableTag>
+ template <>
+ struct PALUDIS_VISIBLE WrappedValueTraits<SlotNameTag>
{
- /**
- * If the parameter is not a valid value for a SlotName,
- * throw a SlotNameError.
- */
- static void validate(const std::string &);
+ typedef std::string UnderlyingType;
+ typedef void ValidationParamsType;
+ typedef SlotNameError ExceptionType;
+
+ static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
@@ -205,52 +175,14 @@ namespace paludis
RepositoryNameError(const std::string & name) throw ();
};
- /**
- * A RepositoryNameValidator handles validation rules for the value
- * of a RepositoryName.
- *
- * \ingroup g_names
- */
- struct PALUDIS_VISIBLE RepositoryNameValidator :
- private InstantiationPolicy<RepositoryNameValidator, instantiation_method::NonInstantiableTag>
- {
- /**
- * If the parameter is not a valid value for a RepositoryName,
- * throw a RepositoryNameError.
- */
- static void validate(const std::string &);
- };
-
- /**
- * Arbitrary useless comparator for RepositoryName.
- *
- * \ingroup g_names
- */
- struct PALUDIS_VISIBLE RepositoryNameComparator
+ template <>
+ struct PALUDIS_VISIBLE WrappedValueTraits<RepositoryNameTag>
{
- /**
- * Perform the comparison.
- */
- bool operator() (const RepositoryName & lhs, const RepositoryName & rhs) const
- {
- return lhs.data() < rhs.data();
- }
- };
+ typedef std::string UnderlyingType;
+ typedef void ValidationParamsType;
+ typedef RepositoryNameError ExceptionType;
- /**
- * A KeywordNameValidator handles validation rules for the value of a
- * KeywordName.
- *
- * \ingroup g_names
- */
- struct PALUDIS_VISIBLE KeywordNameValidator :
- private InstantiationPolicy<KeywordNameValidator, instantiation_method::NonInstantiableTag>
- {
- /**
- * If the parameter is not a valid value for a KeywordName,
- * throw a KeywordNameError.
- */
- static void validate(const std::string &);
+ static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
@@ -269,35 +201,14 @@ namespace paludis
KeywordNameError(const std::string & name) throw ();
};
- /**
- * Comparator for a KeywordName.
- *
- * \ingroup g_names
- * \since 0.26
- */
- class PALUDIS_VISIBLE KeywordNameComparator
+ template <>
+ struct PALUDIS_VISIBLE WrappedValueTraits<KeywordNameTag>
{
- public:
- /**
- * Perform a less-than comparison.
- */
- bool operator() (const std::string &, const std::string &) const;
- };
+ typedef std::string UnderlyingType;
+ typedef void ValidationParamsType;
+ typedef KeywordNameError ExceptionType;
- /**
- * A SetNameValidator handles validation rules for the value of a
- * SetName.
- *
- * \ingroup g_exceptions
- */
- struct PALUDIS_VISIBLE SetNameValidator :
- private InstantiationPolicy<SetNameValidator, instantiation_method::NonInstantiableTag>
- {
- /**
- * If the parameter is not a valid value for a SetName,
- * throw a SetNameError.
- */
- static void validate(const std::string &);
+ static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
};
/**
@@ -315,6 +226,16 @@ namespace paludis
*/
SetNameError(const std::string & name) throw ();
};
+
+ template <>
+ struct PALUDIS_VISIBLE WrappedValueTraits<SetNameTag>
+ {
+ typedef std::string UnderlyingType;
+ typedef void ValidationParamsType;
+ typedef SetNameError ExceptionType;
+
+ static bool validate(const std::string &) PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
}
#endif
diff --git a/paludis/package_database.cc b/paludis/package_database.cc
index 60e27d6..621c7ff 100644
--- a/paludis/package_database.cc
+++ b/paludis/package_database.cc
@@ -204,7 +204,7 @@ namespace
{
if (a.first != b.first)
return a.first < b.first;
- return RepositoryNameComparator()(a.second, b.second);
+ return a.second < b.second;
}
};
diff --git a/paludis/package_id.cc b/paludis/package_id.cc
index 1d5e5ed..c7e5655 100644
--- a/paludis/package_id.cc
+++ b/paludis/package_id.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -150,10 +150,10 @@ PackageIDSetComparator::operator() (const std::tr1::shared_ptr<const PackageID>
if (a->version() > b->version())
return false;
- if (a->repository()->name().data() < b->repository()->name().data())
+ if (a->repository()->name().value() < b->repository()->name().value())
return true;
- if (a->repository()->name().data() > b->repository()->name().data())
+ if (a->repository()->name().value() > b->repository()->name().value())
return false;
return a->arbitrary_less_than_comparison(*b);
diff --git a/paludis/paludislike_options_conf.cc b/paludis/paludislike_options_conf.cc
index 3728dad..649d1d5 100644
--- a/paludis/paludislike_options_conf.cc
+++ b/paludis/paludislike_options_conf.cc
@@ -20,7 +20,6 @@
#include <paludis/paludislike_options_conf.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/hashes.hh>
-#include <paludis/util/validated.hh>
#include <paludis/util/named_value.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/config_file.hh>
diff --git a/paludis/repositories/e/e_choice_value.hh b/paludis/repositories/e/e_choice_value.hh
index 7ecd06f..20b0afe 100644
--- a/paludis/repositories/e/e_choice_value.hh
+++ b/paludis/repositories/e/e_choice_value.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -21,7 +21,6 @@
#define PALUDIS_GUARD_PALUDIS_REPOSITORIES_E_E_CHOICE_VALUE_HH 1
#include <paludis/util/attributes.hh>
-#include <paludis/util/validated.hh>
#include <paludis/choice.hh>
#include <paludis/name.hh>
#include <tr1/functional>
diff --git a/paludis/repositories/e/e_choices_key.cc b/paludis/repositories/e/e_choices_key.cc
index 1135ce3..54dc236 100644
--- a/paludis/repositories/e/e_choices_key.cc
+++ b/paludis/repositories/e/e_choices_key.cc
@@ -119,7 +119,7 @@ namespace
std::string lower_s;
std::transform(s.begin(), s.end(), std::back_inserter(lower_s), &::tolower);
lower_s.append(delim);
- return (0 == flag.data().compare(0, lower_s.length(), lower_s, 0, lower_s.length()));
+ return (0 == flag.value().compare(0, lower_s.length(), lower_s, 0, lower_s.length()));
}
};
@@ -540,7 +540,7 @@ EChoicesKey::populate_iuse() const
for (std::map<ChoiceNameWithPrefix, ChoiceOptions>::const_iterator i(i_values.begin()), i_end(i_values.end()) ;
i != i_end ; ++i)
if (IsExpand(i->first, delim)(*u))
- values.insert(UnprefixedChoiceName(i->first.data().substr(u->length() + delim.length())));
+ values.insert(UnprefixedChoiceName(i->first.value().substr(u->length() + delim.length())));
for (std::set<UnprefixedChoiceName>::const_iterator v(values.begin()), v_end(values.end()) ;
v != v_end ; ++v)
diff --git a/paludis/repositories/e/e_repository_sets.cc b/paludis/repositories/e/e_repository_sets.cc
index d3d2943..e87a6d3 100644
--- a/paludis/repositories/e/e_repository_sets.cc
+++ b/paludis/repositories/e/e_repository_sets.cc
@@ -102,11 +102,11 @@ ERepositorySets::package_set(const SetName & ss) const
{
using namespace std::tr1::placeholders;
- if ("system" == ss.data())
+ if ("system" == ss.value())
throw InternalError(PALUDIS_HERE, "system set should've been handled by ERepository");
- else if ("security" == ss.data())
+ else if ("security" == ss.value())
return security_set(false);
- else if ("insecurity" == ss.data())
+ else if ("insecurity" == ss.value())
return security_set(true);
std::pair<SetName, SetFileSetOperatorMode> s(find_base_set_name_and_suffix_mode(ss));
diff --git a/paludis/repositories/e/iuse.cc b/paludis/repositories/e/iuse.cc
index 7e6f5b1..7f3c321 100644
--- a/paludis/repositories/e/iuse.cc
+++ b/paludis/repositories/e/iuse.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -22,8 +22,8 @@
#include <paludis/util/stringify.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/tribool.hh>
-#include <paludis/util/validated.hh>
#include <paludis/choice.hh>
+#include <paludis/name.hh>
#include <istream>
#include <ostream>
diff --git a/paludis/repositories/e/metadata_xml.cc b/paludis/repositories/e/metadata_xml.cc
index fd60056..09d3a89 100644
--- a/paludis/repositories/e/metadata_xml.cc
+++ b/paludis/repositories/e/metadata_xml.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -22,7 +22,6 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/instantiation_policy-impl.hh>
#include <paludis/util/map-impl.hh>
-#include <paludis/util/validated.hh>
#include <paludis/util/mutex.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/hashes.hh>
diff --git a/paludis/repositories/e/myoption.cc b/paludis/repositories/e/myoption.cc
index 4044cad..e288ae1 100644
--- a/paludis/repositories/e/myoption.cc
+++ b/paludis/repositories/e/myoption.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -18,7 +18,6 @@
*/
#include <paludis/repositories/e/myoption.hh>
-#include <paludis/util/validated.hh>
#include <paludis/choice.hh>
using namespace paludis;
diff --git a/paludis/repositories/e/myoption.hh b/paludis/repositories/e/myoption.hh
index ea0e1e4..871bfc5 100644
--- a/paludis/repositories/e/myoption.hh
+++ b/paludis/repositories/e/myoption.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -23,6 +23,7 @@
#include <paludis/util/attributes.hh>
#include <paludis/choice-fwd.hh>
#include <utility>
+#include <string>
namespace paludis
{
diff --git a/paludis/repositories/e/use_desc.cc b/paludis/repositories/e/use_desc.cc
index 2a3b31d..39bb94d 100644
--- a/paludis/repositories/e/use_desc.cc
+++ b/paludis/repositories/e/use_desc.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -97,12 +97,12 @@ UseDesc::describe(
std::tr1::unordered_map<QualifiedPackageName, UseDescs, Hash<QualifiedPackageName> >::const_iterator i(_imp->local_descs.find(id));
if (i != _imp->local_descs.end())
{
- UseDescs::const_iterator j(i->second.find(make_pair(prefix, flag)));
+ UseDescs::const_iterator j(i->second.find(std::make_pair(prefix, flag)));
if (j != i->second.end())
return j->second;
}
- UseDescs::const_iterator j(_imp->global_descs.find(make_pair(prefix, flag)));
+ UseDescs::const_iterator j(_imp->global_descs.find(std::make_pair(prefix, flag)));
if (j != _imp->global_descs.end())
return j->second;
diff --git a/paludis/repositories/e/xml_things.cc b/paludis/repositories/e/xml_things.cc
index 5c36c15..1800e44 100644
--- a/paludis/repositories/e/xml_things.cc
+++ b/paludis/repositories/e/xml_things.cc
@@ -24,7 +24,6 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/map.hh>
#include <paludis/util/tokeniser.hh>
-#include <paludis/util/validated.hh>
#include <paludis/choice.hh>
#include <set>
diff --git a/paludis/repositories/fake/fake_package_id.cc b/paludis/repositories/fake/fake_package_id.cc
index 1b2b47f..b60e52f 100644
--- a/paludis/repositories/fake/fake_package_id.cc
+++ b/paludis/repositories/fake/fake_package_id.cc
@@ -523,7 +523,7 @@ namespace
virtual const ChoiceNameWithPrefix name_with_prefix() const
{
- return ChoiceNameWithPrefix((choice->prefix().data().empty() ? "" : stringify(choice->prefix()) + "*") + stringify(value_name));
+ return ChoiceNameWithPrefix((choice->prefix().value().empty() ? "" : stringify(choice->prefix()) + "*") + stringify(value_name));
}
virtual bool enabled() const
@@ -994,7 +994,7 @@ FakePackageID::set_slot(const SlotName & s)
bool
FakePackageID::arbitrary_less_than_comparison(const PackageID & other) const
{
- return slot_key()->value().data() < (other.slot_key() ? stringify(other.slot_key()->value()) : "");
+ return slot_key()->value().value() < (other.slot_key() ? stringify(other.slot_key()->value()) : "");
}
void
diff --git a/paludis/repositories/unavailable/unavailable_repository_dependencies_key.cc b/paludis/repositories/unavailable/unavailable_repository_dependencies_key.cc
index 07a18db..a9232b3 100644
--- a/paludis/repositories/unavailable/unavailable_repository_dependencies_key.cc
+++ b/paludis/repositories/unavailable/unavailable_repository_dependencies_key.cc
@@ -20,7 +20,6 @@
#include <paludis/repositories/unavailable/unavailable_repository_dependencies_key.hh>
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/fs_entry.hh>
-#include <paludis/util/validated.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/set.hh>
#include <paludis/util/make_named_values.hh>
diff --git a/paludis/repositories/unpackaged/installed_id.cc b/paludis/repositories/unpackaged/installed_id.cc
index 94862c0..cca03d2 100644
--- a/paludis/repositories/unpackaged/installed_id.cc
+++ b/paludis/repositories/unpackaged/installed_id.cc
@@ -832,7 +832,7 @@ InstalledUnpackagedID::breaks_portage() const
bool
InstalledUnpackagedID::arbitrary_less_than_comparison(const PackageID & other) const
{
- return slot_key()->value().data() < (other.slot_key() ? stringify(other.slot_key()->value()) : "");
+ return slot_key()->value().value() < (other.slot_key() ? stringify(other.slot_key()->value()) : "");
}
std::size_t
diff --git a/paludis/repositories/unpackaged/unpackaged_id.cc b/paludis/repositories/unpackaged/unpackaged_id.cc
index 7a90b4a..042a38d 100644
--- a/paludis/repositories/unpackaged/unpackaged_id.cc
+++ b/paludis/repositories/unpackaged/unpackaged_id.cc
@@ -469,7 +469,7 @@ UnpackagedID::breaks_portage() const
bool
UnpackagedID::arbitrary_less_than_comparison(const PackageID & other) const
{
- return slot_key()->value().data() < (other.slot_key() ? stringify(other.slot_key()->value()) : "");
+ return slot_key()->value().value() < (other.slot_key() ? stringify(other.slot_key()->value()) : "");
}
std::size_t
diff --git a/paludis/repositories/unpackaged/unpackaged_key.cc b/paludis/repositories/unpackaged/unpackaged_key.cc
index 563d097..de888f4 100644
--- a/paludis/repositories/unpackaged/unpackaged_key.cc
+++ b/paludis/repositories/unpackaged/unpackaged_key.cc
@@ -22,7 +22,6 @@
#include <paludis/util/private_implementation_pattern-impl.hh>
#include <paludis/util/fs_entry.hh>
#include <paludis/util/mutex.hh>
-#include <paludis/util/validated.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/set.hh>
#include <paludis/util/make_named_values.hh>
diff --git a/paludis/repositories/unwritten/unwritten_id.cc b/paludis/repositories/unwritten/unwritten_id.cc
index d21bb73..e947e44 100644
--- a/paludis/repositories/unwritten/unwritten_id.cc
+++ b/paludis/repositories/unwritten/unwritten_id.cc
@@ -184,7 +184,7 @@ UnwrittenID::breaks_portage() const
bool
UnwrittenID::arbitrary_less_than_comparison(const PackageID & other) const
{
- return slot_key()->value().data() < (other.slot_key() ? stringify(other.slot_key()->value()) : "");
+ return slot_key()->value().value() < (other.slot_key() ? stringify(other.slot_key()->value()) : "");
}
std::size_t
diff --git a/paludis/repositories/virtuals/installed_virtuals_repository.cc b/paludis/repositories/virtuals/installed_virtuals_repository.cc
index 33cea88..7fc615f 100644
--- a/paludis/repositories/virtuals/installed_virtuals_repository.cc
+++ b/paludis/repositories/virtuals/installed_virtuals_repository.cc
@@ -168,7 +168,7 @@ InstalledVirtualsRepository::need_ids() const
std::tr1::shared_ptr<const PackageIDSequence>
InstalledVirtualsRepository::package_ids(const QualifiedPackageName & q) const
{
- if (q.category().data() != "virtual")
+ if (q.category().value() != "virtual")
return std::tr1::shared_ptr<PackageIDSequence>(new PackageIDSequence);
need_ids();
@@ -183,7 +183,7 @@ InstalledVirtualsRepository::package_ids(const QualifiedPackageName & q) const
std::tr1::shared_ptr<const QualifiedPackageNameSet>
InstalledVirtualsRepository::package_names(const CategoryNamePart & c) const
{
- if (c.data() != "virtual")
+ if (c.value() != "virtual")
return std::tr1::shared_ptr<QualifiedPackageNameSet>(new QualifiedPackageNameSet);
need_ids();
@@ -206,7 +206,7 @@ InstalledVirtualsRepository::category_names() const
bool
InstalledVirtualsRepository::has_package_named(const QualifiedPackageName & q) const
{
- if (q.category().data() != "virtual")
+ if (q.category().value() != "virtual")
return false;
need_ids();
@@ -217,7 +217,7 @@ InstalledVirtualsRepository::has_package_named(const QualifiedPackageName & q) c
bool
InstalledVirtualsRepository::has_category_named(const CategoryNamePart & c) const
{
- return (c.data() == "virtual");
+ return (c.value() == "virtual");
}
void
diff --git a/paludis/repositories/virtuals/virtuals_repository.cc b/paludis/repositories/virtuals/virtuals_repository.cc
index c26a338..cb0ce85 100644
--- a/paludis/repositories/virtuals/virtuals_repository.cc
+++ b/paludis/repositories/virtuals/virtuals_repository.cc
@@ -252,7 +252,7 @@ VirtualsRepository::need_ids() const
std::tr1::shared_ptr<const PackageIDSequence>
VirtualsRepository::package_ids(const QualifiedPackageName & q) const
{
- if (q.category().data() != "virtual")
+ if (q.category().value() != "virtual")
return std::tr1::shared_ptr<PackageIDSequence>(new PackageIDSequence);
need_ids();
@@ -267,7 +267,7 @@ VirtualsRepository::package_ids(const QualifiedPackageName & q) const
std::tr1::shared_ptr<const QualifiedPackageNameSet>
VirtualsRepository::package_names(const CategoryNamePart & c) const
{
- if (c.data() != "virtual")
+ if (c.value() != "virtual")
return std::tr1::shared_ptr<QualifiedPackageNameSet>(new QualifiedPackageNameSet);
need_ids();
@@ -290,7 +290,7 @@ VirtualsRepository::category_names() const
bool
VirtualsRepository::has_package_named(const QualifiedPackageName & q) const
{
- if (q.category().data() != "virtual")
+ if (q.category().value() != "virtual")
return false;
need_names();
@@ -308,7 +308,7 @@ VirtualsRepository::has_package_named(const QualifiedPackageName & q) const
bool
VirtualsRepository::has_category_named(const CategoryNamePart & c) const
{
- return (c.data() == "virtual");
+ return (c.value() == "virtual");
}
void
@@ -333,7 +333,7 @@ const std::tr1::shared_ptr<const PackageID>
VirtualsRepository::make_virtual_package_id(
const QualifiedPackageName & virtual_name, const std::tr1::shared_ptr<const PackageID> & provider) const
{
- if (virtual_name.category().data() != "virtual")
+ if (virtual_name.category().value() != "virtual")
throw InternalError(PALUDIS_HERE, "tried to make a virtual package id using '" + stringify(virtual_name) + "', '"
+ stringify(*provider) + "'");
diff --git a/paludis/resolver/decider.cc b/paludis/resolver/decider.cc
index f591dbb..b1786d3 100644
--- a/paludis/resolver/decider.cc
+++ b/paludis/resolver/decider.cc
@@ -512,7 +512,7 @@ Decider::_find_replacing(
Context context("When working out what is replaced by '" + stringify(*id) +
"' when it is installed to '" + stringify(repo->name()) + "':");
- std::set<RepositoryName, RepositoryNameComparator> repos;
+ std::set<RepositoryName> repos;
if (repo->installed_root_key())
{
@@ -527,7 +527,7 @@ Decider::_find_replacing(
repos.insert(repo->name());
std::tr1::shared_ptr<PackageIDSequence> result(new PackageIDSequence);
- for (std::set<RepositoryName, RepositoryNameComparator>::const_iterator r(repos.begin()),
+ for (std::set<RepositoryName>::const_iterator r(repos.begin()),
r_end(repos.end()) ;
r != r_end ; ++r)
{
diff --git a/paludis/resolver/destination.hh b/paludis/resolver/destination.hh
index 131b9f0..11acd41 100644
--- a/paludis/resolver/destination.hh
+++ b/paludis/resolver/destination.hh
@@ -23,6 +23,7 @@
#include <paludis/resolver/destination-fwd.hh>
#include <paludis/serialise-fwd.hh>
#include <paludis/util/attributes.hh>
+#include <paludis/util/named_value.hh>
#include <paludis/name.hh>
#include <paludis/package_id-fwd.hh>
#include <tr1/memory>
diff --git a/paludis/unchoices_key.cc b/paludis/unchoices_key.cc
index f92ab52..4d3e5fc 100644
--- a/paludis/unchoices_key.cc
+++ b/paludis/unchoices_key.cc
@@ -20,7 +20,6 @@
#include <paludis/unchoices_key.hh>
#include <paludis/metadata_key.hh>
#include <paludis/choice.hh>
-#include <paludis/util/validated.hh>
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/set.hh>
#include <paludis/util/sequence.hh>
diff --git a/paludis/util/files.m4 b/paludis/util/files.m4
index 6f58b2f..6ca5dc5 100644
--- a/paludis/util/files.m4
+++ b/paludis/util/files.m4
@@ -93,8 +93,8 @@ add(`tokeniser', `hh', `cc', `test')
add(`tribool', `hh', `cc', `fwd', `test')
add(`type_list', `hh', `cc', `fwd')
add(`util', `hh')
-add(`validated', `hh', `fwd', `test')
add(`wildcard_expander', `hh', `cc', `test', `testscript')
add(`wrapped_forward_iterator', `hh', `fwd', `impl', `test')
add(`wrapped_output_iterator', `hh', `fwd', `impl')
+add(`wrapped_value', `hh', `fwd', `impl', `test')
diff --git a/paludis/util/hashes.hh b/paludis/util/hashes.hh
index 2291022..0d38261 100644
--- a/paludis/util/hashes.hh
+++ b/paludis/util/hashes.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -21,7 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_UTIL_HASHES_HH 1
#include <paludis/util/attributes.hh>
-#include <paludis/util/validated-fwd.hh>
+#include <paludis/util/wrapped_value-fwd.hh>
#include <paludis/util/fs_entry-fwd.hh>
#include <cstddef>
#include <utility>
@@ -83,12 +83,12 @@ namespace paludis
}
};
- template <typename D_, typename V_, bool b_, typename C_>
- struct Hash<Validated<D_, V_, b_, C_> >
+ template <typename Tag_>
+ struct Hash<WrappedValue<Tag_> >
{
- std::size_t operator() (const Validated<D_, V_, b_, C_> & v) const
+ std::size_t operator() (const WrappedValue<Tag_> & v) const
{
- return Hash<D_>()(v.data());
+ return Hash<typename WrappedValueTraits<Tag_>::UnderlyingType>()(v.value());
}
};
diff --git a/paludis/util/stringify.hh b/paludis/util/stringify.hh
index ece8faf..a3048ca 100644
--- a/paludis/util/stringify.hh
+++ b/paludis/util/stringify.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -21,7 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_STRINGIFY_HH 1
#include <paludis/util/attributes.hh>
-#include <paludis/util/validated-fwd.hh>
+#include <paludis/util/wrapped_value-fwd.hh>
#include <tr1/memory>
#include <sstream>
#include <string>
@@ -147,11 +147,11 @@ namespace paludis
return std::string(item);
}
- template <typename D_, typename V_, bool c_, typename C_>
+ template <typename Tag_>
inline std::string
- real_stringify(const Validated<D_, V_, c_, C_> & v)
+ real_stringify(const WrappedValue<Tag_> & v)
{
- return stringify(v.data());
+ return stringify(v.value());
}
}
diff --git a/paludis/util/validated.hh b/paludis/util/validated.hh
deleted file mode 100644
index f710511..0000000
--- a/paludis/util/validated.hh
+++ /dev/null
@@ -1,150 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_VALIDATED_HH
-#define PALUDIS_GUARD_PALUDIS_VALIDATED_HH 1
-
-#include <iosfwd>
-#include <functional>
-#include <paludis/util/validated-fwd.hh>
-#include <paludis/util/operators.hh>
-#include <paludis/util/select.hh>
-
-/** \file
- * Validated declarations.
- *
- * \ingroup g_data_structures
- *
- * \section Examples
- *
- * - \ref example_name.cc "example_name.cc" shows basic usage of various defined
- * Validated classes.
- */
-
-namespace paludis
-{
- /**
- * Default comparator for Validated, used to avoid having to include
- * huge standard library headers in a -fwd.
- *
- * \ingroup g_data_structures
- */
- template <typename T_>
- struct PALUDIS_VISIBLE DefaultValidatedComparator :
- std::less<T_>
- {
- };
-
- /**
- * A Validated wraps a particular class instance, ensuring that it always
- * meets certain validation criteria.
- *
- * \ingroup g_data_structures
- */
- template <typename ValidatedDataType_, typename Validator_, bool full_comparison_, typename Comparator_>
- class Validated :
- public Select<full_comparison_,
- relational_operators::HasRelationalOperators,
- equality_operators::HasEqualityOperators>::Type
- {
- private:
- ValidatedDataType_ _value;
-
- public:
- ///\name Basic operations
- ///\{
-
- /**
- * Copy constructor (no validation needed).
- */
- Validated(const Validated<ValidatedDataType_, Validator_, full_comparison_, Comparator_> & other);
-
- /**
- * Constructor (validation needed).
- */
- explicit Validated(const ValidatedDataType_ & value);
-
- /**
- * Assignment (no validation needed).
- */
- const Validated<ValidatedDataType_, Validator_, full_comparison_> & operator=
- (const Validated<ValidatedDataType_, Validator_, full_comparison_> & other)
- {
- _value = other._value;
- return *this;
- }
-
- ///\}
-
- /**
- * Fetch to our ValidatedDataType_. This should not be a cast
- * operator to avoid problems with ambiguous comparison operators.
- */
- const ValidatedDataType_ & data() const
- {
- return _value;
- }
- };
-
- template <typename ValidatedDataType_, typename Validator_, bool full_comparison_, typename Comparator_>
- Validated<ValidatedDataType_, Validator_, full_comparison_, Comparator_>::Validated(
- const Validated<ValidatedDataType_, Validator_, full_comparison_, Comparator_> & other) :
- _value(other._value)
- {
- }
-
- template <typename ValidatedDataType_, typename Validator_, bool full_comparison_, typename Comparator_>
- Validated<ValidatedDataType_, Validator_, full_comparison_, Comparator_>::Validated(
- const ValidatedDataType_ & value) :
- _value(value)
- {
- Validator_::validate(_value);
- }
-
- template <typename ValidatedDataType_, typename Validator_, bool full_comparison_, typename Comparator_>
- bool operator== (
- const Validated<ValidatedDataType_, Validator_, full_comparison_, Comparator_> & a,
- const Validated<ValidatedDataType_, Validator_, full_comparison_, Comparator_> & b)
- {
- return a.data() == b.data();
- }
-
- template <typename ValidatedDataType_, typename Validator_, typename Comparator_>
- bool operator< (
- const Validated<ValidatedDataType_, Validator_, true, Comparator_> & a,
- const Validated<ValidatedDataType_, Validator_, true, Comparator_> & b)
- {
- return Comparator_()(a.data(), b.data());
- }
-
- /**
- * Writing a Validated instance to a stream is done by its data.
- *
- * \ingroup g_data_structures
- */
- template <typename D_, typename V_, bool c_, typename C_>
- std::ostream &
- operator<< (std::ostream & s, const Validated<D_, V_, c_, C_> & v)
- {
- s << v.data();
- return s;
- }
-}
-
-#endif
diff --git a/paludis/util/validated_TEST.cc b/paludis/util/validated_TEST.cc
deleted file mode 100644
index 3da0eba..0000000
--- a/paludis/util/validated_TEST.cc
+++ /dev/null
@@ -1,126 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/util/validated.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-
-using namespace test;
-using namespace paludis;
-
-/** \file
- * Test cases for validated.hh .
- *
- * \ingroup grpvalidated
- */
-
-#ifndef DOXYGEN
-struct PositiveEvenValidator
-{
- struct NotValid
- {
- };
-
- static void validate(int value)
- {
- if ((value < 0) || (value % 2))
- throw NotValid();
- }
-};
-
-typedef Validated<int, PositiveEvenValidator> PositiveEven;
-#endif
-
-namespace test_cases
-{
- /**
- * \test Validated<PositiveEven> tests.
- *
- * \ingroup grpvalidated
- */
- struct ValidatedPositiveEvenTests : TestCase
- {
- ValidatedPositiveEvenTests() : TestCase("Validated<PositiveEven> tests") { }
-
- void run()
- {
- PositiveEven v(2);
- TEST_CHECK_EQUAL(v, PositiveEven(2));
- v = PositiveEven(4);
- TEST_CHECK_EQUAL(v, PositiveEven(4));
- TEST_CHECK_THROWS(((v = PositiveEven(5))), PositiveEvenValidator::NotValid);
- TEST_CHECK_EQUAL(v, PositiveEven(4));
- TEST_CHECK_THROWS(PositiveEven w(5), PositiveEvenValidator::NotValid);
- }
- } test_validated_positive_even;
-
- /**
- * \test Validated<PositiveEven> comparison tests.
- *
- * \ingroup grpvalidated
- */
- struct ValidatedPositiveEvenComparisonTests : TestCase
- {
- ValidatedPositiveEvenComparisonTests() :
- TestCase("Validated<PositiveEven> comparison tests") { }
-
- void run()
- {
- PositiveEven v2(2);
- PositiveEven v4(4);
- PositiveEven v4b(4);
-
- TEST_CHECK(v2 < v4);
- TEST_CHECK(v2 <= v4);
- TEST_CHECK(! (v2 == v4));
- TEST_CHECK(v2 != v4);
- TEST_CHECK(! (v2 >= v4));
- TEST_CHECK(! (v2 > v4));
-
- TEST_CHECK(! (v4 < v2));
- TEST_CHECK(! (v4 <= v2));
- TEST_CHECK(! (v4 == v2));
- TEST_CHECK(v4 != v2);
- TEST_CHECK(v4 >= v2);
- TEST_CHECK(v4 > v2);
-
- TEST_CHECK(! (v2 < v2));
- TEST_CHECK(v2 <= v2);
- TEST_CHECK(v2 == v2);
- TEST_CHECK(! (v2 != v2));
- TEST_CHECK(v2 >= v2);
- TEST_CHECK(! (v2 > v2));
-
- TEST_CHECK(! (v4 < v4));
- TEST_CHECK(v4 <= v4);
- TEST_CHECK(v4 == v4);
- TEST_CHECK(! (v4 != v4));
- TEST_CHECK(v4 >= v4);
- TEST_CHECK(! (v4 > v4));
-
- TEST_CHECK(! (v4 < v4b));
- TEST_CHECK(v4 <= v4b);
- TEST_CHECK(v4 == v4b);
- TEST_CHECK(! (v4 != v4b));
- TEST_CHECK(v4 >= v4b);
- TEST_CHECK(! (v4 > v4b));
- }
- } test_validated_positive_even_comparisons;
-}
-
diff --git a/paludis/util/validated-fwd.hh b/paludis/util/wrapped_value-fwd.hh
index bd71a53..49a1d83 100644
--- a/paludis/util/validated-fwd.hh
+++ b/paludis/util/wrapped_value-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007 Ciaran McCreesh
+ * Copyright (c) 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -17,28 +17,28 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
-#ifndef PALUDIS_GUARD_PALUDIS_UTIL_VALIDATED_FWD_HH
-#define PALUDIS_GUARD_PALUDIS_UTIL_VALIDATED_FWD_HH 1
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_WRAPPED_VALUE_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_WRAPPED_VALUE_FWD_HH 1
+#include <paludis/util/attributes.hh>
#include <iosfwd>
-/** \file
- * Forward declarations for paludis/util/validated.hh .
- *
- * \ingroup g_data_structures
- */
-
namespace paludis
{
- template <typename T_>
- struct DefaultValidatedComparator;
+ template <typename Tag_>
+ struct WrappedValue;
+
+ template <typename Tag_>
+ struct WrappedValueTraits;
+
+ template <typename Type_>
+ struct WrappedValueDevoid;
- template <typename D_, typename, bool = true, typename = DefaultValidatedComparator<D_> >
- class Validated;
+ template <typename Tag_, typename Extra_>
+ struct WrappedValueValidate;
- template <typename D_, typename V_, bool c_, typename C_>
- std::ostream &
- operator<< (std::ostream & s, const Validated<D_, V_, c_, C_> & v);
+ template <typename Tag_>
+ std::ostream & operator<< (std::ostream &, const WrappedValue<Tag_> &) PALUDIS_VISIBLE;
}
#endif
diff --git a/paludis/util/wrapped_value-impl.hh b/paludis/util/wrapped_value-impl.hh
new file mode 100644
index 0000000..f8ef9be
--- /dev/null
+++ b/paludis/util/wrapped_value-impl.hh
@@ -0,0 +1,104 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_WRAPPED_VALUE_IMPL_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_WRAPPED_VALUE_IMPL_HH 1
+
+#include <paludis/util/wrapped_value.hh>
+#include <ostream>
+
+namespace paludis
+{
+ template <typename Tag_, typename Extra_>
+ struct WrappedValueValidate
+ {
+ typedef WrappedValueTraits<Tag_> Type;
+ };
+
+ template <typename Tag_>
+ struct WrappedValueValidate<Tag_, void>
+ {
+ typedef WrappedValueValidate<Tag_, void> Type;
+
+ static bool validate(const typename WrappedValueTraits<Tag_>::UnderlyingType & t, const NoType<0u> *)
+ {
+ return WrappedValueTraits<Tag_>::validate(t);
+ }
+ };
+
+ template <typename Tag_>
+ WrappedValue<Tag_>::WrappedValue(
+ const typename WrappedValueTraits<Tag_>::UnderlyingType & v,
+ const typename WrappedValueDevoid<typename WrappedValueTraits<Tag_>::ValidationParamsType>::Type & p)
+ {
+ if (WrappedValueValidate<Tag_, typename WrappedValueTraits<Tag_>::ValidationParamsType>::Type::validate(v, p))
+ _value.reset(new typename WrappedValueTraits<Tag_>::UnderlyingType(v));
+ else
+ throw typename WrappedValueTraits<Tag_>::ExceptionType(v);
+ }
+
+ template <typename Tag_>
+ WrappedValue<Tag_> &
+ WrappedValue<Tag_>::WrappedValue::operator= (const WrappedValue & v)
+ {
+ _value = v._value;
+ return *this;
+ }
+
+ template <typename Tag_>
+ bool
+ WrappedValue<Tag_>::WrappedValue::operator< (const WrappedValue & other) const
+ {
+ return value() < other.value();
+ }
+
+ template <typename Tag_>
+ bool
+ WrappedValue<Tag_>::WrappedValue::operator== (const WrappedValue & other) const
+ {
+ return value() == other.value();
+ }
+
+ template <typename Tag_>
+ WrappedValue<Tag_>::WrappedValue(const WrappedValue & other) :
+ _value(other._value)
+ {
+ }
+
+ template <typename Tag_>
+ WrappedValue<Tag_>::~WrappedValue()
+ {
+ }
+
+ template <typename Tag_>
+ const typename WrappedValueTraits<Tag_>::UnderlyingType &
+ WrappedValue<Tag_>::value() const
+ {
+ return *_value;
+ }
+
+ template <typename Tag_>
+ std::ostream & operator<< (std::ostream & s, const WrappedValue<Tag_> & v)
+ {
+ s << v.value();
+ return s;
+ }
+}
+
+#endif
diff --git a/paludis/util/wrapped_value.hh b/paludis/util/wrapped_value.hh
new file mode 100644
index 0000000..d77f3e0
--- /dev/null
+++ b/paludis/util/wrapped_value.hh
@@ -0,0 +1,66 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_UTIL_WRAPPED_VALUE_HH
+#define PALUDIS_GUARD_PALUDIS_UTIL_WRAPPED_VALUE_HH 1
+
+#include <paludis/util/wrapped_value-fwd.hh>
+#include <paludis/util/no_type.hh>
+#include <paludis/util/operators.hh>
+#include <tr1/memory>
+
+namespace paludis
+{
+ template <typename T_>
+ struct WrappedValueDevoid
+ {
+ typedef T_ Type;
+ };
+
+ template <>
+ struct WrappedValueDevoid<void>
+ {
+ typedef NoType<0u> * Type;
+ };
+
+ template <typename Tag_>
+ class PALUDIS_VISIBLE WrappedValue :
+ public relational_operators::HasRelationalOperators
+ {
+ private:
+ std::tr1::shared_ptr<const typename WrappedValueTraits<Tag_>::UnderlyingType> _value;
+
+ public:
+ explicit WrappedValue(
+ const typename WrappedValueTraits<Tag_>::UnderlyingType &,
+ const typename WrappedValueDevoid<typename WrappedValueTraits<Tag_>::ValidationParamsType>::Type & = static_cast<NoType<0u> *>(0)
+ );
+
+ WrappedValue & operator= (const WrappedValue &);
+ WrappedValue(const WrappedValue &);
+ ~WrappedValue();
+
+ const typename WrappedValueTraits<Tag_>::UnderlyingType & value() const PALUDIS_ATTRIBUTE((warn_unused_result));
+
+ bool operator< (const WrappedValue &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ bool operator== (const WrappedValue &) const PALUDIS_ATTRIBUTE((warn_unused_result));
+ };
+}
+
+#endif
diff --git a/paludis/util/wrapped_value_TEST.cc b/paludis/util/wrapped_value_TEST.cc
new file mode 100644
index 0000000..ab8a6a9
--- /dev/null
+++ b/paludis/util/wrapped_value_TEST.cc
@@ -0,0 +1,107 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/util/wrapped_value-impl.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+#include <string>
+
+using namespace test;
+using namespace paludis;
+
+namespace
+{
+ typedef WrappedValue<struct DormouseTag> Dormouse;
+
+ struct PALUDIS_VISIBLE NotADormouseError
+ {
+ NotADormouseError(const std::string &)
+ {
+ }
+ };
+
+ typedef WrappedValue<struct CheeseTag> Cheese;
+
+ struct PALUDIS_VISIBLE NoCheeseError
+ {
+ NoCheeseError(const std::string &)
+ {
+ }
+ };
+}
+
+namespace paludis
+{
+ template <>
+ struct WrappedValueTraits<DormouseTag>
+ {
+ typedef std::string UnderlyingType;
+ typedef void ValidationParamsType;
+ typedef NotADormouseError ExceptionType;
+
+ static bool validate(const std::string & s)
+ {
+ return s == "glis glis" || s == "muscardinus avellanarius";
+ }
+ };
+
+ template <>
+ struct WrappedValueTraits<CheeseTag>
+ {
+ typedef std::string UnderlyingType;
+ typedef bool ValidationParamsType;
+ typedef NoCheeseError ExceptionType;
+
+ static bool validate(const std::string & s, const bool tasty)
+ {
+ return s == "stilton" || (s == "camembert" && ! tasty);
+ }
+ };
+};
+
+namespace test_cases
+{
+ struct DormouseTest : TestCase
+ {
+ DormouseTest() : TestCase("dormouse tests") { }
+
+ void run()
+ {
+ Dormouse dormouse("glis glis");
+ TEST_CHECK_EQUAL(dormouse.value(), "glis glis");
+ dormouse = Dormouse("muscardinus avellanarius");
+ TEST_CHECK_EQUAL(dormouse.value(), "muscardinus avellanarius");
+ TEST_CHECK_THROWS(dormouse = Dormouse("mesocricetus auratus"), NotADormouseError);
+ }
+ } test_dormouse;
+
+ struct CheeseTest : TestCase
+ {
+ CheeseTest() : TestCase("cheese tests") { }
+
+ void run()
+ {
+ Cheese cheese("stilton", false);
+ TEST_CHECK_THROWS(cheese = Cheese("camembert", true), NoCheeseError);
+ cheese = Cheese("camembert", false);
+ TEST_CHECK_EQUAL(cheese.value(), "camembert");
+ }
+ } test_cheese;
+}
+
diff --git a/python/Makefile.am b/python/Makefile.am
index de4b0ec..795c182 100644
--- a/python/Makefile.am
+++ b/python/Makefile.am
@@ -53,7 +53,7 @@ IF_PYTHON_SOURCES = \
paludis_python.hh \
options.hh \
iterable.hh \
- validated.hh \
+ wrapped_value.hh \
about.cc \
action.cc \
choices.cc \
diff --git a/python/choices.cc b/python/choices.cc
index 6a174b1..181b580 100644
--- a/python/choices.cc
+++ b/python/choices.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -19,9 +19,8 @@
#include <python/paludis_python.hh>
#include <python/exception.hh>
-#include <python/validated.hh>
+#include <python/wrapped_value.hh>
-#include <paludis/util/validated.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/choice.hh>
@@ -133,7 +132,7 @@ void expose_choices()
"Thrown if an invalid value is assigned to a ChoiceNameWithPrefix.");
register_shared_ptrs_to_python<ChoiceNameWithPrefix>();
- class_validated<ChoiceNameWithPrefix>
+ class_wrapped_value<ChoiceNameWithPrefix>
(
"ChoiceNameWithPrefix",
"A choice name, including prefix and delim."
@@ -144,7 +143,7 @@ void expose_choices()
"Thrown if an invalid value is assigned to a ChoicePrefixName.");
register_shared_ptrs_to_python<ChoicePrefixName>();
- class_validated<ChoicePrefixName>
+ class_wrapped_value<ChoicePrefixName>
(
"ChoicePrefixName",
"A choice prefix name."
@@ -155,7 +154,7 @@ void expose_choices()
"Thrown if an invalid value is assigned to an UnprefixedChoiceName.");
register_shared_ptrs_to_python<UnprefixedChoiceName>();
- class_validated<UnprefixedChoiceName>
+ class_wrapped_value<UnprefixedChoiceName>
(
"UnprefixedChoiceName",
"A choice name, without prefix."
diff --git a/python/iterable.hh b/python/iterable.hh
index 9055374..81a7d24 100644
--- a/python/iterable.hh
+++ b/python/iterable.hh
@@ -25,7 +25,6 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/set.hh>
-#include <paludis/util/validated.hh>
#include <tr1/type_traits>
namespace paludis
@@ -38,10 +37,10 @@ namespace paludis
static const bool value = std::tr1::is_convertible<From_, To_>::value;
};
- template <typename From_, typename ValidatedDataType_, typename Validator_, bool full_comparison_, typename Comparator_>
- struct IsConvertible<From_, Validated<ValidatedDataType_, Validator_, full_comparison_, Comparator_> >
+ template <typename From_, typename Tag_>
+ struct IsConvertible<From_, WrappedValue<Tag_> >
{
- static const bool value = std::tr1::is_convertible<From_, ValidatedDataType_>::value;
+ static const bool value = std::tr1::is_convertible<From_, typename WrappedValueTraits<Tag_>::UnderlyingType>::value;
};
template <typename To_, typename From_, typename C_, bool>
diff --git a/python/name.cc b/python/name.cc
index 1f94fbb..a2edce8 100644
--- a/python/name.cc
+++ b/python/name.cc
@@ -19,7 +19,7 @@
#include <python/paludis_python.hh>
#include <python/exception.hh>
-#include <python/validated.hh>
+#include <python/wrapped_value.hh>
#include <python/iterable.hh>
#include <python/options.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
@@ -41,10 +41,6 @@ void expose_name()
ExceptionRegister::get_instance()->add_exception<CategoryNamePartError>
("CategoryNamePartError", "NameError",
"Thrown if an invalid value is assigned to a CategoryNamePart.");
- ExceptionRegister::get_instance()->add_exception<QualifiedPackageNameError>
- ("QualifiedPackageNameError", "NameError",
- "May be thrown if an invalid name is assigned to a QualifiedPackageName "
- "(alternatively, the exception raised may be a PackageNamePartError or a CategoryNamePartError).");
ExceptionRegister::get_instance()->add_exception<SlotNameError>
("SlotNameError", "NameError",
"Thrown if an invalid value is assigned to a SlotName.");
@@ -62,7 +58,7 @@ void expose_name()
* PackageNamePart
*/
register_shared_ptrs_to_python<PackageNamePart>();
- class_validated<PackageNamePart>
+ class_wrapped_value<PackageNamePart>
(
"PackageNamePart",
"Holds a string that is a valid name for the package part of a QualifiedPackageName."
@@ -81,7 +77,7 @@ void expose_name()
* CategoryNamePart
*/
register_shared_ptrs_to_python<CategoryNamePart>();
- class_validated<CategoryNamePart>
+ class_wrapped_value<CategoryNamePart>
(
"CategoryNamePart",
"Holds a string that is a valid name for the category part of a QualifiedPackageName."
@@ -104,7 +100,7 @@ void expose_name()
* SlotName
*/
register_shared_ptrs_to_python<SlotName>();
- class_validated<SlotName>
+ class_wrapped_value<SlotName>
(
"SlotName",
"Holds a string that is a valid name for a SLOT."
@@ -114,26 +110,16 @@ void expose_name()
* RepositoryName
*/
register_shared_ptrs_to_python<RepositoryName>();
- class_validated<RepositoryName>
+ class_wrapped_value<RepositoryName>
(
"RepositoryName",
"Holds a string that is a valid name for a Repository."
);
/**
- * RepositoryNameIterable
- */
- class_iterable<RepositoryNameSequence>
- (
- "RepositoryNameIterable",
- "Iterable of RepositoryName",
- true
- );
-
- /**
* KeywordName
*/
- class_validated<KeywordName>
+ class_wrapped_value<KeywordName>
(
"KeywordName",
"Holds a string that is a valid name for a KEYWORD."
@@ -152,7 +138,7 @@ void expose_name()
/**
* SetName
*/
- class_validated<SetName>
+ class_wrapped_value<SetName>
(
"SetName",
"Holds a string that is a valid name for a set."
@@ -192,15 +178,13 @@ void expose_name()
.def(bp::init<const CategoryNamePart &, const PackageNamePart &>())
.add_property("category",
- &named_values_getter<QualifiedPackageName, n::category, CategoryNamePart, &QualifiedPackageName::category>,
- &named_values_setter<QualifiedPackageName, n::category, CategoryNamePart, &QualifiedPackageName::category>,
- "[rw] CategoryNamePart"
+ &QualifiedPackageName::category,
+ "[ro] CategoryNamePart"
)
.add_property("package",
- &named_values_getter<QualifiedPackageName, n::package, PackageNamePart, &QualifiedPackageName::package>,
- &named_values_setter<QualifiedPackageName, n::package, PackageNamePart, &QualifiedPackageName::package>,
- "[rw] PackageNamePart"
+ &QualifiedPackageName::package,
+ "[ro] PackageNamePart"
)
.def("__cmp__", &py_cmp<QualifiedPackageName>)
diff --git a/python/name_TEST.py b/python/name_TEST.py
index 15f7d60..3121a49 100755
--- a/python/name_TEST.py
+++ b/python/name_TEST.py
@@ -36,7 +36,7 @@ class TestCase_Names(unittest.TestCase):
def test_2_create_error(self):
self.assertRaises(PackageNamePartError, PackageNamePart, ":bad")
self.assertRaises(CategoryNamePartError, CategoryNamePart, ":bad")
- self.assertRaises(QualifiedPackageNameError, QualifiedPackageName, ":bad")
+ self.assertRaises(CategoryNamePartError, QualifiedPackageName, ":bad")
self.assertRaises(SlotNameError, SlotName, ":bad")
self.assertRaises(RepositoryNameError, RepositoryName, ":bad")
self.assertRaises(KeywordNameError, KeywordName, ":bad")
@@ -44,7 +44,6 @@ class TestCase_Names(unittest.TestCase):
self.assertRaises(Exception, PackageNamePartIterable)
self.assertRaises(Exception, CategoryNamePartIterable)
self.assertRaises(Exception, QualifiedPackageNameIterable)
- self.assertRaises(Exception, RepositoryNameIterable)
def test_3_str(self):
self.test_1_create()
@@ -58,10 +57,6 @@ class TestCase_Names(unittest.TestCase):
qpn = QualifiedPackageName("cat/foo")
self.assertEqual(str(qpn.category), "cat")
self.assertEqual(str(qpn.package), "foo")
- qpn.category = "blah"
- qpn.package = "bar"
- self.assertEqual(str(qpn.category), "blah")
- self.assertEqual(str(qpn.package), "bar")
if __name__ == "__main__":
unittest.main()
diff --git a/python/nice_names.nn b/python/nice_names.nn
index e89b6f5..b7f5cf2 100644
--- a/python/nice_names.nn
+++ b/python/nice_names.nn
@@ -55,7 +55,6 @@ make_nn_NiceNames() {
name "QualifiedPackageNameSet"
name "SlotName"
name "RepositoryName"
- name "RepositoryNameSequence"
name "KeywordName"
name "KeywordNameSet"
name "SetName"
diff --git a/python/validated.hh b/python/validated.hh
deleted file mode 100644
index f4a02ba..0000000
--- a/python/validated.hh
+++ /dev/null
@@ -1,80 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2007 Piotr Jaroszyński
- *
- * 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_PYTHON_VALIDATED_HH
-#define PALUDIS_GUARD_PYTHON_VALIDATED_HH 1
-
-#include <python/paludis_python.hh>
-
-#include <paludis/util/validated.hh>
-
-namespace paludis
-{
- namespace python
- {
- // expose Validated classes
- template <typename V_>
- class class_validated;
-
- template <typename ValidatedDataType_, typename Validator_, typename Comparator_>
- class class_validated<Validated<ValidatedDataType_, Validator_, true, Comparator_> > :
- public boost::python::class_<Validated<ValidatedDataType_, Validator_, true, Comparator_> >
- {
- public:
- class_validated(const std::string & name,
- const std::string & class_doc, const std::string & init_arg="string") :
- boost::python::class_<Validated<ValidatedDataType_, Validator_, true, Comparator_> >(
- name.c_str(), class_doc.c_str(),
- boost::python::init<const ValidatedDataType_ &>(("__init__("+init_arg+")").c_str())
- )
- {
- this->def(boost::python::self_ns::str(boost::python::self));
- this->def("__cmp__",
- &paludis::python::py_cmp<Validated<ValidatedDataType_, Validator_, true, Comparator_> >);
- boost::python::implicitly_convertible<ValidatedDataType_,
- Validated<ValidatedDataType_, Validator_, true, Comparator_> >();
- }
- };
-
- template <typename ValidatedDataType_, typename Validator_, typename Comparator_>
- class class_validated<Validated<ValidatedDataType_, Validator_, false, Comparator_> > :
- public boost::python::class_<Validated<ValidatedDataType_, Validator_, false, Comparator_> >
- {
- public:
- class_validated(const std::string & name,
- const std::string & class_doc, const std::string & init_arg="string") :
- boost::python::class_<Validated<ValidatedDataType_, Validator_, false, Comparator_> >(
- name.c_str(), class_doc.c_str(),
- boost::python::init<const ValidatedDataType_ &>(("__init__("+init_arg+")").c_str())
- )
- {
- this->def(boost::python::self_ns::str(boost::python::self));
- this->def("__eq__",
- &paludis::python::py_eq<Validated<ValidatedDataType_, Validator_, false, Comparator_> >);
- this->def("__ne__",
- &paludis::python::py_ne<Validated<ValidatedDataType_, Validator_, false, Comparator_> >);
- boost::python::implicitly_convertible<ValidatedDataType_,
- Validated<ValidatedDataType_, Validator_, false, Comparator_> >();
- }
- };
-
- } // namespace paludis::python
-} // namespace paludis
-
-#endif
diff --git a/python/wrapped_value.hh b/python/wrapped_value.hh
new file mode 100644
index 0000000..b390b4e
--- /dev/null
+++ b/python/wrapped_value.hh
@@ -0,0 +1,56 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2007 Piotr Jaroszyński
+ * Copyright (c) 2010 Ciaran McCreesh
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PYTHON_WRAPPED_VALUE_HH
+#define PALUDIS_GUARD_PYTHON_WRAPPED_VALUE_HH 1
+
+#include <python/paludis_python.hh>
+#include <paludis/util/wrapped_value.hh>
+
+namespace paludis
+{
+ namespace python
+ {
+ template <typename V_>
+ class class_wrapped_value;
+
+ template <typename Tag_>
+ class class_wrapped_value<WrappedValue<Tag_> > :
+ public boost::python::class_<WrappedValue<Tag_> >
+ {
+ public:
+ class_wrapped_value(const std::string & name,
+ const std::string & class_doc, const std::string & init_arg="string") :
+ boost::python::class_<WrappedValue<Tag_> >(
+ name.c_str(), class_doc.c_str(),
+ boost::python::init<const typename WrappedValueTraits<Tag_>::UnderlyingType &>(("__init__("+init_arg+")").c_str())
+ )
+ {
+ this->def(boost::python::self_ns::str(boost::python::self));
+ this->def("__cmp__",
+ &paludis::python::py_cmp<WrappedValue<Tag_> >);
+ boost::python::implicitly_convertible<typename WrappedValueTraits<Tag_>::UnderlyingType,
+ WrappedValue<Tag_> >();
+ }
+ };
+ }
+}
+
+#endif
diff --git a/ruby/qualified_package_name.cc b/ruby/qualified_package_name.cc
index 74f919d..dedaf65 100644
--- a/ruby/qualified_package_name.cc
+++ b/ruby/qualified_package_name.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2010 Ciaran McCreesh
* Copyright (c) 2008 Richard Brown
*
* This file is part of the Paludis package manager. Paludis is free software;
@@ -80,14 +80,6 @@ namespace
* Fetch the category part of the QualifiedPackageName.
*/
/*
- * Document-method: category=
- *
- * call-seq:
- * category=
- *
- * Set the category.
- */
- /*
* Document-method: package
*
* call-seq:
@@ -95,15 +87,7 @@ namespace
*
* Fetch the package name part of the QualifiedPackageName.
*/
- /*
- * Document-method: package=
- *
- * call-seq:
- * package=
- *
- * Set the package name.
- */
- template <typename T_, typename M_, NamedValue<M_, T_> QualifiedPackageName::* m_>
+ template <typename T_, typename M_, const M_ (QualifiedPackageName::* m_)() const>
struct QPNMember
{
static VALUE
@@ -168,13 +152,9 @@ namespace
rb_define_method(c_qualified_package_name, "hash", RUBY_FUNC_CAST(&Common<QualifiedPackageName>::hash), 0);
rb_define_method(c_qualified_package_name, "eql?", RUBY_FUNC_CAST(&Common<QualifiedPackageName>::equal), 1);
rb_define_method(c_qualified_package_name, "category",
- RUBY_FUNC_CAST((&QPNMember<CategoryNamePart, n::category, &QualifiedPackageName::category>::fetch)), 0);
- rb_define_method(c_qualified_package_name, "category=",
- RUBY_FUNC_CAST((&QPNMember<CategoryNamePart, n::category, &QualifiedPackageName::category>::set)), 1);
+ RUBY_FUNC_CAST((&QPNMember<CategoryNamePart, CategoryNamePart, &QualifiedPackageName::category>::fetch)), 0);
rb_define_method(c_qualified_package_name, "package",
- RUBY_FUNC_CAST((&QPNMember<PackageNamePart, n::package, &QualifiedPackageName::package>::fetch)), 0);
- rb_define_method(c_qualified_package_name, "package=",
- RUBY_FUNC_CAST((&QPNMember<PackageNamePart, n::package, &QualifiedPackageName::package>::set)), 1);
+ RUBY_FUNC_CAST((&QPNMember<PackageNamePart, PackageNamePart, &QualifiedPackageName::package>::fetch)), 0);
}
}
diff --git a/ruby/qualified_package_name_TEST.rb b/ruby/qualified_package_name_TEST.rb
index 8acf27a..0ac18c8 100644
--- a/ruby/qualified_package_name_TEST.rb
+++ b/ruby/qualified_package_name_TEST.rb
@@ -2,7 +2,7 @@
# vim: set sw=4 sts=4 et tw=80 :
#
-# Copyright (c) 2006, 2007, 2008 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008, 2010 Ciaran McCreesh
# Copyright (c) 2008 Richard Brown
#
# This file is part of the Paludis package manager. Paludis is free software;
@@ -80,20 +80,6 @@ module Paludis
assert_equal pkg, qpn.package
end
- def test_setters
- cat = 'foo-bar'
- pkg = 'baz'
- cat_new = 'foo-baz'
- pkg_new = 'bar'
- qpn = QualifiedPackageName.new(cat,pkg)
-
- qpn.category = cat_new
- assert_equal cat_new, qpn.category
-
- qpn.package = pkg_new
- assert_equal pkg_new, qpn.package
- end
-
def test_to_value_type_error
assert_raise TypeError do
QualifiedPackageName.new('foo-bar/baz') <=> 0
diff --git a/ruby/repository_TEST.rb b/ruby/repository_TEST.rb
index fb79348..71da21f 100644
--- a/ruby/repository_TEST.rb
+++ b/ruby/repository_TEST.rb
@@ -2,7 +2,7 @@
# vim: set sw=4 sts=4 et tw=80 :
#
-# Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
+# Copyright (c) 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
# Copyright (c) 2006, 2007, 2008 Richard Brown
#
# This file is part of the Paludis package manager. Paludis is free software;
@@ -318,7 +318,7 @@ module Paludis
assert_raise TypeError do f.add_package(42) end
- assert_raise NameError do f.add_package('test') end
+ assert_raise CategoryNamePartError do f.add_package('test') end
assert_raise CategoryNamePartError do f.add_package('f o o/bar') end
assert_raise PackageNamePartError do f.add_package('foo/b a r') end
end
@@ -362,7 +362,7 @@ module Paludis
assert_raise TypeError do f.add_version('foo-bar', {}, '9') end
assert_raise TypeError do f.add_version('foo-bar', 'baz', Paludis) end
- assert_raise NameError do f.add_version('foo', '42') end
+ assert_raise CategoryNamePartError do f.add_version('foo', '42') end
assert_raise CategoryNamePartError do f.add_version('f o o/bar', '42') end
assert_raise PackageNamePartError do f.add_version('foo/b a r' , '42') end
assert_raise BadVersionSpecError do f.add_version('foo/bar', 'abc') end
diff --git a/src/clients/adjutrix/command_line.cc b/src/clients/adjutrix/command_line.cc
index bc20eba..2fa4b3f 100644
--- a/src/clients/adjutrix/command_line.cc
+++ b/src/clients/adjutrix/command_line.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -86,11 +86,9 @@ CommandLine::CommandLine() :
tree_args(main_options_section(), "Tree action options",
"Options which are relevant for tree actions."),
a_category(&tree_args, "category", 'C',
- "Matches with this category name only (may be specified multiple times)",
- paludis::args::StringSetArg::StringSetArgOptions(), &paludis::CategoryNamePartValidator::validate),
+ "Matches with this category name only (may be specified multiple times)"),
a_package(&tree_args, "package", 'P',
- "Matches with this package name only (may be specified multiple times)",
- paludis::args::StringSetArg::StringSetArgOptions(), &paludis::PackageNamePartValidator::validate),
+ "Matches with this package name only (may be specified multiple times)"),
profile_args(main_options_section(), "Profile action options",
"Options which are relevant for profile actions."),
diff --git a/src/clients/adjutrix/find_stable_candidates.cc b/src/clients/adjutrix/find_stable_candidates.cc
index 3dd851b..9571fde 100644
--- a/src/clients/adjutrix/find_stable_candidates.cc
+++ b/src/clients/adjutrix/find_stable_candidates.cc
@@ -92,7 +92,7 @@ namespace
{
bool operator() (const KeywordName & k) const
{
- return std::string::npos == std::string("-~").find(k.data().at(0));
+ return std::string::npos == std::string("-~").find(k.value().at(0));
}
};
diff --git a/src/clients/adjutrix/what_needs_keywording.cc b/src/clients/adjutrix/what_needs_keywording.cc
index 3492058..f55fa17 100644
--- a/src/clients/adjutrix/what_needs_keywording.cc
+++ b/src/clients/adjutrix/what_needs_keywording.cc
@@ -146,7 +146,7 @@ int do_what_needs_keywording(NoConfigEnvironment & env)
k != k_end ; ++k)
if (*k == KeywordName("-*")
|| *k == target_keyword
- || k->data().substr(1) == stringify(target_arch))
+ || k->value().substr(1) == stringify(target_arch))
current.append(stringify(*k) + " ");
}
diff --git a/src/clients/appareo/command_line.cc b/src/clients/appareo/command_line.cc
index e24d44a..b8441ab 100644
--- a/src/clients/appareo/command_line.cc
+++ b/src/clients/appareo/command_line.cc
@@ -2,7 +2,7 @@
/*
* Copyright (c) 2009 Kim Højgaard-Hansen
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -59,11 +59,9 @@ CommandLine::CommandLine() :
tree_args(main_options_section(), "Tree action options",
"Options which are relevant for tree actions."),
a_category(&tree_args, "category", 'C',
- "Matches with this category name only (may be specified multiple times)",
- args::StringSetArg::StringSetArgOptions(), &CategoryNamePartValidator::validate),
+ "Matches with this category name only (may be specified multiple times)"),
a_package(&tree_args, "package", 'P',
- "Matches with this package name only (may be specified multiple times)",
- args::StringSetArg::StringSetArgOptions(), &PackageNamePartValidator::validate)
+ "Matches with this package name only (may be specified multiple times)")
{
add_usage_line("--manifest");
diff --git a/src/clients/cave/cmd_find_candidates.cc b/src/clients/cave/cmd_find_candidates.cc
index 840ff2a..9d4825f 100644
--- a/src/clients/cave/cmd_find_candidates.cc
+++ b/src/clients/cave/cmd_find_candidates.cc
@@ -118,7 +118,7 @@ FindCandidatesCommand::run(
return EXIT_SUCCESS;
}
-typedef std::set<RepositoryName, RepositoryNameComparator> RepositoryNames;
+typedef std::set<RepositoryName> RepositoryNames;
typedef std::set<CategoryNamePart> CategoryNames;
typedef std::set<QualifiedPackageName> QualifiedPackageNames;
diff --git a/src/clients/cave/cmd_fix_cache.cc b/src/clients/cave/cmd_fix_cache.cc
index 46edc09..01046c6 100644
--- a/src/clients/cave/cmd_fix_cache.cc
+++ b/src/clients/cave/cmd_fix_cache.cc
@@ -99,7 +99,7 @@ FixCacheCommand::run(
if (cmdline.begin_parameters() != cmdline.end_parameters())
throw args::DoHelp("fix-cache takes no parameters");
- std::set<RepositoryName, RepositoryNameComparator> repository_names;
+ std::set<RepositoryName> repository_names;
bool all(true);
@@ -138,7 +138,7 @@ FixCacheCommand::run(
r != r_end; ++r)
repository_names.insert(r->name());
- for (std::set<RepositoryName, RepositoryNameComparator>::const_iterator r(repository_names.begin()), r_end(repository_names.end()) ;
+ for (std::set<RepositoryName>::const_iterator r(repository_names.begin()), r_end(repository_names.end()) ;
r != r_end; ++r)
{
cout << format_general_s(f::fix_cache_fixing(), stringify(*r));
diff --git a/src/clients/cave/cmd_print_categories.cc b/src/clients/cave/cmd_print_categories.cc
index e5be50e..a88f355 100644
--- a/src/clients/cave/cmd_print_categories.cc
+++ b/src/clients/cave/cmd_print_categories.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -68,11 +68,9 @@ namespace
g_filters(main_options_section(), "Filters", "Filter the output. Each filter may be specified more than once. The object "
"specified by the filter does not have to exist."),
a_containing(&g_filters, "containing", '\0', "Show only categories containing this package name. If specified "
- "multiple times, categories containing any of these package names are selected.",
- args::StringSetArg::StringSetArgOptions(), &PackageNamePartValidator::validate),
+ "multiple times, categories containing any of these package names are selected."),
a_repository(&g_filters, "repository", '\0', "Show only categories in this repository. If specified multiple "
- "times, categories in any of these repositories are selected.",
- args::StringSetArg::StringSetArgOptions(), &RepositoryNameValidator::validate)
+ "times, categories in any of these repositories are selected.")
{
add_usage_line("[ --containing pkgname ] [ --repository reponame ]");
}
diff --git a/src/clients/cave/cmd_print_repositories.cc b/src/clients/cave/cmd_print_repositories.cc
index 17e821b..cc9e1d1 100644
--- a/src/clients/cave/cmd_print_repositories.cc
+++ b/src/clients/cave/cmd_print_repositories.cc
@@ -93,7 +93,7 @@ PrintRepositoriesCommand::run(
if (cmdline.begin_parameters() != cmdline.end_parameters())
throw args::DoHelp("print-repositories takes no parameters");
- std::set<RepositoryName, RepositoryNameComparator> repository_names;
+ std::set<RepositoryName> repository_names;
for (IndirectIterator<PackageDatabase::RepositoryConstIterator, const Repository>
r(env->package_database()->begin_repositories()), r_end(env->package_database()->end_repositories());
diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc
index 38ad665..096def9 100644
--- a/src/clients/cave/cmd_show.cc
+++ b/src/clients/cave/cmd_show.cc
@@ -806,7 +806,7 @@ namespace
std::tr1::shared_ptr<const PackageID> best_installable, best_masked_installable, best_not_installed;
std::tr1::shared_ptr<PackageIDSequence> all_installed(new PackageIDSequence);
- std::set<RepositoryName, RepositoryNameComparator> repos;
+ std::set<RepositoryName> repos;
for (PackageIDSequence::ConstIterator i(ids->begin()), i_end(ids->end()) ;
i != i_end ; ++i)
{
@@ -830,7 +830,7 @@ namespace
if (! best_installable)
best_installable = best_not_installed;
- for (std::set<RepositoryName, RepositoryNameComparator>::const_iterator r(repos.begin()), r_end(repos.end()) ;
+ for (std::set<RepositoryName>::const_iterator r(repos.begin()), r_end(repos.end()) ;
r != r_end ; ++r)
{
cout << format_general_s(f::show_package_repository(), stringify(*r));
diff --git a/src/clients/cave/cmd_sync.cc b/src/clients/cave/cmd_sync.cc
index 696ce7c..043909c 100644
--- a/src/clients/cave/cmd_sync.cc
+++ b/src/clients/cave/cmd_sync.cc
@@ -56,7 +56,7 @@ using std::endl;
namespace
{
- typedef std::set<RepositoryName, RepositoryNameComparator> Repos;
+ typedef std::set<RepositoryName> Repos;
struct SyncCommandLine :
CaveCommandCommandLine
diff --git a/src/clients/importare/install.cc b/src/clients/importare/install.cc
index 8bd9600..cc2984b 100644
--- a/src/clients/importare/install.cc
+++ b/src/clients/importare/install.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -39,6 +39,8 @@
#include <paludis/metadata_key.hh>
#include <paludis/mask.hh>
#include <paludis/action.hh>
+#include <paludis/name.hh>
+#include <paludis/choice.hh>
using namespace paludis;
diff --git a/src/clients/inquisitio/command_line.cc b/src/clients/inquisitio/command_line.cc
index a1f42d8..98e634e 100644
--- a/src/clients/inquisitio/command_line.cc
+++ b/src/clients/inquisitio/command_line.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -60,13 +60,10 @@ CommandLine::CommandLine() :
filter_args(main_options_section(), "Filter options",
"Options that control whether or not a package is considered for matching."),
- a_repository(&filter_args, "repository", 'r', "Matches with this repository name only",
- paludis::args::StringSetArg::StringSetArgOptions(), &paludis::RepositoryNameValidator::validate),
+ a_repository(&filter_args, "repository", 'r', "Matches with this repository name only"),
a_repository_format(&filter_args, "repository-format", '\0', "Matches with this repository format only"),
- a_category(&filter_args, "category", '\0', "Matches with this category name only",
- paludis::args::StringSetArg::StringSetArgOptions(), &paludis::CategoryNamePartValidator::validate),
- a_package(&filter_args, "package", '\0', "Matches with this package name only",
- paludis::args::StringSetArg::StringSetArgOptions(), &paludis::PackageNamePartValidator::validate),
+ a_category(&filter_args, "category", '\0', "Matches with this category name only"),
+ a_package(&filter_args, "package", '\0', "Matches with this package name only"),
a_visible_only(&filter_args, "visible-only", 'v', "Only consider visible packages", true),
a_all_versions(&filter_args, "all-versions", 'a', "Check all versions, rather than only one (slower)", true),
a_kind(&filter_args, "kind", 'K', "Packages of this kind only",
diff --git a/src/clients/paludis/command_line.cc b/src/clients/paludis/command_line.cc
index b0a7cd5..df0f432 100644
--- a/src/clients/paludis/command_line.cc
+++ b/src/clients/paludis/command_line.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -108,15 +108,11 @@ CommandLine::CommandLine() :
list_args(main_options_section(), "List options",
"Options relevant for one or more of the --list actions."),
- a_repository(&list_args, "repository", '\0', "Matches with this repository name only",
- paludis::args::StringSetArg::StringSetArgOptions(), &paludis::RepositoryNameValidator::validate),
+ a_repository(&list_args, "repository", '\0', "Matches with this repository name only"),
a_repository_format(&list_args, "repository-format", '\0', "Matches with this repository format only"),
- a_category(&list_args, "category", '\0', "Matches with this category name only",
- paludis::args::StringSetArg::StringSetArgOptions(), &paludis::CategoryNamePartValidator::validate),
- a_package(&list_args, "package", '\0', "Matches with this package name only",
- paludis::args::StringSetArg::StringSetArgOptions(), &paludis::PackageNamePartValidator::validate),
- a_set(&list_args, "set", '\0', "Matches with this package set name only",
- paludis::args::StringSetArg::StringSetArgOptions(), &paludis::SetNameValidator::validate),
+ a_category(&list_args, "category", '\0', "Matches with this category name only"),
+ a_package(&list_args, "package", '\0', "Matches with this package name only"),
+ a_set(&list_args, "set", '\0', "Matches with this package set name only"),
owner_args(main_options_section(), "Owner options",
"Options relevant for the --owner actions."),
diff --git a/src/clients/paludis/install.cc b/src/clients/paludis/install.cc
index c4b61ca..4b40ca7 100644
--- a/src/clients/paludis/install.cc
+++ b/src/clients/paludis/install.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2005, 2006, 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2005, 2006, 2007, 2008, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -39,6 +39,8 @@
#include <paludis/metadata_key.hh>
#include <paludis/mask.hh>
#include <paludis/action.hh>
+#include <paludis/name.hh>
+#include <paludis/choice.hh>
/** \file
* Handle the --install action for the main paludis program.
diff --git a/src/output/console_install_task.hh b/src/output/console_install_task.hh
index beadfdc..422ab5f 100644
--- a/src/output/console_install_task.hh
+++ b/src/output/console_install_task.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2006, 2007, 2008, 2009 Ciaran McCreesh
+ * Copyright (c) 2006, 2007, 2008, 2009, 2010 Ciaran McCreesh
*
* This file is part of the Paludis package manager. Paludis is free software;
* you can redistribute it and/or modify it under the terms of the GNU General
@@ -22,6 +22,8 @@
#include <paludis/install_task.hh>
#include <paludis/util/set.hh>
+#include <paludis/choice.hh>
+#include <paludis/name.hh>
#include <src/output/console_task.hh>
#include <iosfwd>
#include <map>
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index ccb78ba..76524c3 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -206,14 +206,14 @@ ConsoleQueryTask::display_versions_by_repository(const PackageDepSpec &,
const std::tr1::shared_ptr<const PackageID> & display_entry) const
{
/* find all repository names. */
- RepositoryNameSequence repo_names;
+ std::list<RepositoryName> repo_names;
PackageIDSequence::ConstIterator e(entries->begin()), e_end(entries->end());
for ( ; e != e_end ; ++e)
if (repo_names.end() == std::find(repo_names.begin(), repo_names.end(), (*e)->repository()->name()))
repo_names.push_back((*e)->repository()->name());
/* display versions, by repository. */
- RepositoryNameSequence::ConstIterator r(repo_names.begin()), r_end(repo_names.end());
+ std::list<RepositoryName>::const_iterator r(repo_names.begin()), r_end(repo_names.end());
for ( ; r != r_end ; ++r)
{
output_left_column(stringify(*r) + ":");