aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-03-08 02:50:18 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-03-08 02:50:18 +0000
commitbab248ba64ff2a0cf884a6b39ab1601f7e9d8c8a (patch)
tree1d17e86278e13a5ee33bd920bbc16ab79a0d736e
parentd065ddde851601ad1784d626ac649e28ec3912a0 (diff)
downloadpaludis-bab248ba64ff2a0cf884a6b39ab1601f7e9d8c8a.tar.gz
paludis-bab248ba64ff2a0cf884a6b39ab1601f7e9d8c8a.tar.xz
Merge _name files.
-rw-r--r--paludis/category_name_part.cc57
-rw-r--r--paludis/category_name_part.hh86
-rw-r--r--paludis/category_name_part_TEST.cc71
-rw-r--r--paludis/default_config.hh4
-rw-r--r--paludis/dep_atom.hh4
-rw-r--r--paludis/dep_list.hh4
-rw-r--r--paludis/environment.hh3
-rw-r--r--paludis/files.m49
-rw-r--r--paludis/hashed_containers.hh.in4
-rw-r--r--paludis/keyword_name.cc67
-rw-r--r--paludis/keyword_name.hh79
-rw-r--r--paludis/name.cc275
-rw-r--r--paludis/name.hh393
-rw-r--r--paludis/name_TEST.cc209
-rw-r--r--paludis/package_database.hh2
-rw-r--r--paludis/package_name_part.cc71
-rw-r--r--paludis/package_name_part.hh86
-rw-r--r--paludis/package_name_part_TEST.cc110
-rw-r--r--paludis/qa/ebuild_check.hh2
-rw-r--r--paludis/qa/package_name_check.cc2
-rw-r--r--paludis/qualified_package_name.cc51
-rw-r--r--paludis/qualified_package_name.hh134
-rw-r--r--paludis/qualified_package_name_TEST.cc102
-rw-r--r--paludis/repository.hh4
-rw-r--r--paludis/repository_name.cc55
-rw-r--r--paludis/repository_name.hh85
-rw-r--r--paludis/slot_name.cc57
-rw-r--r--paludis/slot_name.hh77
-rw-r--r--paludis/use_flag_name.cc55
-rw-r--r--paludis/use_flag_name.hh77
-rw-r--r--paludis/version_metadata.hh4
31 files changed, 890 insertions, 1349 deletions
diff --git a/paludis/category_name_part.cc b/paludis/category_name_part.cc
deleted file mode 100644
index 185dd86..0000000
--- a/paludis/category_name_part.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/category_name_part.hh>
-
-using namespace paludis;
-
-void
-CategoryNamePartValidator::validate(const std::string & s)
-{
- /* this gets called a lot, make it fast */
-
- static const std::string allowed_chars(
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789-+_");
-
- do
- {
- if (s.empty())
- break;
-
- if ('-' == s.at(0))
- break;
-
- if (std::string::npos != s.find_first_not_of(allowed_chars))
- break;
-
- return;
-
- } while (false);
-
- Context c("When validating category name '" + s + "':");
- throw CategoryNamePartError(s);
-}
-
-CategoryNamePartError::CategoryNamePartError(const std::string & name) throw () :
- NameError(name, "category name part")
-{
-}
-
diff --git a/paludis/category_name_part.hh b/paludis/category_name_part.hh
deleted file mode 100644
index 86f845c..0000000
--- a/paludis/category_name_part.hh
+++ /dev/null
@@ -1,86 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_CATEGORY_NAME_PART_HH
-#define PALUDIS_GUARD_PALUDIS_CATEGORY_NAME_PART_HH 1
-
-#include <paludis/util/exception.hh>
-#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/sorted_collection.hh>
-#include <paludis/util/validated.hh>
-#include <string>
-
-/** \file
- * Declaration for CategoryNamePart and related classes.
- *
- * \ingroup Database
- * \ingroup Exception
- */
-
-namespace paludis
-{
- /**
- * A CategoryNamePartError is thrown if an invalid value is assigned to
- * a CategoryNamePart.
- *
- * \ingroup Exception
- * \ingroup Database
- */
- class CategoryNamePartError : public NameError
- {
- public:
- /**
- * Constructor.
- */
- CategoryNamePartError(const std::string & name) throw ();
- };
-
- /**
- * A CategoryNamePartValidator handles validation rules for the value
- * of a CategoryNamePart.
- *
- * \ingroup Database
- */
- struct CategoryNamePartValidator :
- private InstantiationPolicy<CategoryNamePartValidator, instantiation_method::NonInstantiableTag>
- {
- /**
- * If the parameter is not a valid value for a CategoryNamePart,
- * throw a CategoryNamePartError.
- */
- static void validate(const std::string &);
- };
-
- /**
- * A CategoryNamePart holds a std::string that is a valid name for the
- * category part of a QualifiedPackageName.
- *
- * \ingroup Database
- */
- typedef Validated<std::string, CategoryNamePartValidator> CategoryNamePart;
-
- /**
- * Holds a set of CategoryNamePart instances.
- *
- * \ingroup Database
- */
- typedef SortedCollection<CategoryNamePart> CategoryNamePartCollection;
-}
-
-#endif
diff --git a/paludis/category_name_part_TEST.cc b/paludis/category_name_part_TEST.cc
deleted file mode 100644
index 1e0f50b..0000000
--- a/paludis/category_name_part_TEST.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Mark Loeser <halcy0n@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/category_name_part.hh>
-#include <string>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-
-using namespace test;
-using namespace paludis;
-
-/** \file
- * Test cases for category_name_part.hh .
- *
- * \ingroup Test
- */
-
-namespace test_cases
-{
- /**
- * \test Test CategoryNamePart creation.
- *
- * \ingroup Test
- */
- struct CategoryNamePartCreationTest : public TestCase
- {
- CategoryNamePartCreationTest() : TestCase("creation") { }
-
- void run()
- {
- CategoryNamePart p("foo");
- TEST_CHECK(true);
- }
- } category_package_name_part_creation;
-
- /**
- * \test Test CategoryNamePart validation
- *
- * \ingroup Test
- */
- struct CategoryNamePartValidationTest : public TestCase
- {
- CategoryNamePartValidationTest() : TestCase("validation") {}
-
- void run()
- {
- CategoryNamePart p = CategoryNamePart("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_");
-
- TEST_CHECK_THROWS(p = CategoryNamePart(""), CategoryNamePartError);
- TEST_CHECK_THROWS(p = CategoryNamePart("*"), CategoryNamePartError);
- TEST_CHECK_THROWS(p = CategoryNamePart("foo bar"), CategoryNamePartError);
- }
- } category_package_name_part_validation;
-}
-
diff --git a/paludis/default_config.hh b/paludis/default_config.hh
index 3d79c5d..c0244be 100644
--- a/paludis/default_config.hh
+++ b/paludis/default_config.hh
@@ -21,9 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_DEFAULT_CONFIG_HH 1
#include <paludis/dep_atom.hh>
-#include <paludis/keyword_name.hh>
-#include <paludis/qualified_package_name.hh>
-#include <paludis/use_flag_name.hh>
+#include <paludis/name.hh>
#include <paludis/use_flag_state.hh>
#include <paludis/util/exception.hh>
#include <paludis/util/fs_entry.hh>
diff --git a/paludis/dep_atom.hh b/paludis/dep_atom.hh
index eeea0b7..ad0bd95 100644
--- a/paludis/dep_atom.hh
+++ b/paludis/dep_atom.hh
@@ -21,9 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_DEP_ATOM_HH 1
#include <list>
-#include <paludis/qualified_package_name.hh>
-#include <paludis/slot_name.hh>
-#include <paludis/use_flag_name.hh>
+#include <paludis/name.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/composite_pattern.hh>
#include <paludis/util/counted_ptr.hh>
diff --git a/paludis/dep_list.hh b/paludis/dep_list.hh
index 8395815..6cd4a62 100644
--- a/paludis/dep_list.hh
+++ b/paludis/dep_list.hh
@@ -26,10 +26,8 @@
#include <list>
#include <ostream>
#include <paludis/dep_atom.hh>
+#include <paludis/name.hh>
#include <paludis/qa/environment.hh>
-#include <paludis/qualified_package_name.hh>
-#include <paludis/repository_name.hh>
-#include <paludis/slot_name.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/util/smart_record.hh>
diff --git a/paludis/environment.hh b/paludis/environment.hh
index cf05579..4dfd7c7 100644
--- a/paludis/environment.hh
+++ b/paludis/environment.hh
@@ -20,10 +20,9 @@
#ifndef PALUDIS_GUARD_PALUDIS_ENVIRONMENT_HH
#define PALUDIS_GUARD_PALUDIS_ENVIRONMENT_HH 1
-#include <paludis/keyword_name.hh>
#include <paludis/mask_reasons.hh>
+#include <paludis/name.hh>
#include <paludis/package_database.hh>
-#include <paludis/use_flag_name.hh>
#include <paludis/util/counted_ptr.hh>
#include <paludis/util/instantiation_policy.hh>
diff --git a/paludis/files.m4 b/paludis/files.m4
index 838b42e..c383e39 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -9,7 +9,6 @@ dnl `test', `impl', `testscript'. Note that there isn't much error checking done
dnl on this file at present...
add(`about', `hh', `test')
-add(`category_name_part', `hh', `cc', `test')
add(`config_file', `hh', `cc', `test', `testscript')
add(`default_config', `hh', `cc')
add(`default_environment', `hh', `cc')
@@ -23,21 +22,17 @@ add(`dep_parser', `hh', `cc', `test')
add(`environment', `hh', `cc')
add(`fake_repository', `hh', `cc')
add(`hashed_containers', `hh', `cc', `test')
-add(`keyword_name', `hh', `cc')
add(`mask_reasons', `hh', `cc')
add(`match_package', `hh', `cc')
add(`match_sequence', `hh', `cc', `test')
+add(`name', `hh', `cc', `test')
add(`package_database', `hh', `cc', `test')
-add(`package_name_part', `hh', `cc', `test')
add(`paludis', `hh', `cc')
add(`portage_repository', `hh', `cc')
-add(`qualified_package_name', `hh', `cc', `test')
add(`repository', `hh', `cc')
-add(`repository_name', `hh', `cc')
-add(`slot_name', `hh', `cc')
add(`test_environment', `hh', `cc')
-add(`use_flag_name', `hh', `cc')
add(`use_flag_state', `hh', `cc')
add(`version_metadata', `hh', `cc')
add(`version_operator', `hh', `cc', `test')
add(`version_spec', `hh', `cc', `test')
+
diff --git a/paludis/hashed_containers.hh.in b/paludis/hashed_containers.hh.in
index b9ae6c7..4db4999 100644
--- a/paludis/hashed_containers.hh.in
+++ b/paludis/hashed_containers.hh.in
@@ -26,9 +26,9 @@
#define PALUDIS_HAVE_EXT_HASHES @HAVE_EXT_HASHES@
#define PALUDIS_HAVE_STD_HASHES @HAVE_STD_HASHES@
-#include <paludis/qualified_package_name.hh>
-#include <paludis/version_spec.hh>
+#include <paludis/name.hh>
#include <paludis/util/validated.hh>
+#include <paludis/version_spec.hh>
#if PALUDIS_HAVE_TR1_HASHES
# include <tr1/unordered_set>
diff --git a/paludis/keyword_name.cc b/paludis/keyword_name.cc
deleted file mode 100644
index 701a90f..0000000
--- a/paludis/keyword_name.cc
+++ /dev/null
@@ -1,67 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/keyword_name.hh>
-
-using namespace paludis;
-
-KeywordNameError::KeywordNameError(const std::string & name) throw () :
- NameError(name, "keyword name")
-{
-}
-
-void
-KeywordNameValidator::validate(const std::string & s)
-{
- static const std::string allowed_chars(
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789-+_");
-
- do
- {
- switch (s.length())
- {
- case 0:
- continue;
-
- case 1:
- if ("*" == s)
- return;
- continue;
-
- case 2:
- if ("-*" == s)
- return;
-
- /* fall throuth */
- default:
- if (std::string::npos != s.find_first_not_of(allowed_chars,
- ('~' == s.at(0) ? 1 : 0)))
- continue;
- }
-
- return;
-
- } while (false);
-
- Context c("When validating keyword name '" + s + "':");
- throw KeywordNameError(s);
-}
-
diff --git a/paludis/keyword_name.hh b/paludis/keyword_name.hh
deleted file mode 100644
index a7fbe1c..0000000
--- a/paludis/keyword_name.hh
+++ /dev/null
@@ -1,79 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_KEYWORD_NAME_HH
-#define PALUDIS_GUARD_PALUDIS_KEYWORD_NAME_HH 1
-
-#include <paludis/util/exception.hh>
-#include <paludis/util/instantiation_policy.hh>
-#include <paludis/util/validated.hh>
-
-#include <string>
-
-/** \file
- * Declarations for KeywordName and related classes.
- *
- * \ingroup Environment
- * \ingroup Database
- * \ingroup Exception
- */
-namespace paludis
-{
- /**
- * A KeywordNameValidator handles validation rules for the value of a
- * UseFlagName.
- *
- * \ingroup Environment
- */
- struct 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 &);
- };
-
- /**
- * A KeywordNameError is thrown if an invalid value is assigned to
- * a KeywordNameName.
- *
- * \ingroup Environment
- * \ingroup Exception
- */
- class KeywordNameError : public NameError
- {
- public:
- /**
- * Constructor.
- */
- KeywordNameError(const std::string & name) throw ();
- };
-
- /**
- * A KeywordName holds a std::string that is a valid name for a KEYWORD.
- *
- * \ingroup Database
- */
- typedef Validated<std::string, KeywordNameValidator> KeywordName;
-
-}
-
-#endif
diff --git a/paludis/name.cc b/paludis/name.cc
new file mode 100644
index 0000000..9b600dc
--- /dev/null
+++ b/paludis/name.cc
@@ -0,0 +1,275 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/name.hh>
+#include <paludis/util/stringify.hh>
+
+using namespace paludis;
+
+QualifiedPackageNameError::QualifiedPackageNameError(const std::string & s) throw () :
+ NameError(s, "qualified package name")
+{
+}
+
+std::ostream &
+paludis::operator<< (std::ostream & s, const QualifiedPackageName & q)
+{
+ s << q.get<qpn_category>() << "/" << q.get<qpn_package>();
+ return s;
+}
+
+MakeSmartRecord<QualifiedPackageNameTag>::Type
+QualifiedPackageName::_make_parent(
+ const std::string & s)
+{
+ Context c("When splitting out category and package names from '" + s + "':");
+
+ std::string::size_type p(s.find('/'));
+ if (std::string::npos == p)
+ throw QualifiedPackageNameError(s);
+
+ return MakeSmartRecord<QualifiedPackageNameTag>::Type(
+ CategoryNamePart(s.substr(0, p)),
+ PackageNamePart(s.substr(p + 1)));
+}
+
+void
+UseFlagNameValidator::validate(const std::string & s)
+{
+ static const std::string allowed_chars(
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789-+_:@");
+
+ do
+ {
+ if (s.empty())
+ break;
+
+ if ('-' == s.at(0))
+ break;
+
+ if (std::string::npos != s.find_first_not_of(allowed_chars))
+ break;
+
+ return;
+
+ } while (false);
+
+ Context c("When validating use flag name '" + s + "':");
+
+ throw UseFlagNameError(s);
+}
+
+UseFlagNameError::UseFlagNameError(const std::string & name) throw () :
+ NameError(name, "use flag name")
+{
+}
+
+SlotNameError::SlotNameError(const std::string & name) throw () :
+ NameError(name, "slot name")
+{
+}
+
+void
+SlotNameValidator::validate(const std::string & s)
+{
+ static const std::string allowed_chars(
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789-+_.");
+
+ do
+ {
+ if (s.empty())
+ break;
+
+ if ('-' == s.at(0))
+ break;
+
+ if (std::string::npos != s.find_first_not_of(allowed_chars))
+ break;
+
+ return;
+
+ } while (false);
+
+ Context c("When validating slot name '" + s + "':");
+
+ throw SlotNameError(s);
+}
+
+PackageNamePartError::PackageNamePartError(const std::string & name) throw () :
+ NameError(name, "package name part")
+{
+}
+
+void
+PackageNamePartValidator::validate(const std::string & s)
+{
+ /* this gets called a lot, make it fast */
+
+ static const std::string allowed_chars(
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789-+_");
+
+ static const std::string number_chars(
+ "0123456789");
+
+ if (s.empty() || '-' == s.at(0))
+ {
+ Context c("When validating package name part '" + s + "':");
+ throw PackageNamePartError(s);
+ }
+
+ /* we don't allow - followed by only numbers, because it could be
+ * a version spec. */
+ 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);
+ }
+
+ if ('-' != s[p])
+ continue;
+ if (++p >= s.length())
+ break;
+ if ((std::string::npos != number_chars.find(s[p]) &&
+ std::string::npos == s.find_first_not_of(number_chars, p)) ||
+ (std::string::npos == allowed_chars.find(s[p])))
+ {
+ Context c("When validating package name part '" + s + "':");
+ throw PackageNamePartError(s);
+ }
+ }
+}
+
+void
+CategoryNamePartValidator::validate(const std::string & s)
+{
+ /* this gets called a lot, make it fast */
+
+ static const std::string allowed_chars(
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789-+_");
+
+ do
+ {
+ if (s.empty())
+ break;
+
+ if ('-' == s.at(0))
+ break;
+
+ if (std::string::npos != s.find_first_not_of(allowed_chars))
+ break;
+
+ return;
+
+ } while (false);
+
+ Context c("When validating category name '" + s + "':");
+ throw CategoryNamePartError(s);
+}
+
+CategoryNamePartError::CategoryNamePartError(const std::string & name) throw () :
+ NameError(name, "category name part")
+{
+}
+
+void
+RepositoryNameValidator::validate(const std::string & s)
+{
+ static const std::string allowed_chars(
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789-+_/");
+
+ do
+ {
+ if (s.empty())
+ break;
+
+ if ('-' == s.at(0))
+ break;
+
+ if (std::string::npos != s.find_first_not_of(allowed_chars))
+ break;
+
+ return;
+
+ } while (false);
+
+ Context c("When validating repository name '" + s + "':");
+ throw RepositoryNameError(s);
+}
+
+RepositoryNameError::RepositoryNameError(const std::string & name) throw () :
+ NameError(name, "repository")
+{
+}
+
+KeywordNameError::KeywordNameError(const std::string & name) throw () :
+ NameError(name, "keyword name")
+{
+}
+
+void
+KeywordNameValidator::validate(const std::string & s)
+{
+ static const std::string allowed_chars(
+ "abcdefghijklmnopqrstuvwxyz"
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+ "0123456789-+_");
+
+ do
+ {
+ switch (s.length())
+ {
+ case 0:
+ continue;
+
+ case 1:
+ if ("*" == s)
+ return;
+ continue;
+
+ case 2:
+ if ("-*" == s)
+ return;
+
+ /* fall throuth */
+ default:
+ if (std::string::npos != s.find_first_not_of(allowed_chars,
+ ('~' == s.at(0) ? 1 : 0)))
+ continue;
+ }
+
+ return;
+
+ } while (false);
+
+ Context c("When validating keyword name '" + s + "':");
+ throw KeywordNameError(s);
+}
+
diff --git a/paludis/name.hh b/paludis/name.hh
new file mode 100644
index 0000000..07a84da
--- /dev/null
+++ b/paludis/name.hh
@@ -0,0 +1,393 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#ifndef PALUDIS_GUARD_PALUDIS_NAME_HH
+#define PALUDIS_GUARD_PALUDIS_NAME_HH 1
+
+#include <ostream>
+#include <string>
+#include <paludis/util/exception.hh>
+#include <paludis/util/instantiation_policy.hh>
+#include <paludis/util/smart_record.hh>
+#include <paludis/util/sequential_collection.hh>
+#include <paludis/util/sorted_collection.hh>
+#include <paludis/util/validated.hh>
+
+namespace paludis
+{
+ /**
+ * A PackageNamePartError is thrown if an invalid value is assigned to
+ * a PackageNamePart.
+ *
+ * \ingroup Database
+ * \ingroup Exception
+ */
+ class PackageNamePartError : public NameError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ PackageNamePartError(const std::string & name) throw ();
+ };
+
+ /**
+ * A PackageNamePartValidator handles validation rules for the value
+ * of a PackageNamePart.
+ *
+ * \ingroup Database
+ */
+ struct PackageNamePartValidator :
+ private InstantiationPolicy<PackageNamePartValidator, instantiation_method::NonInstantiableTag>
+ {
+ /**
+ * If the parameter is not a valid value for a PackageNamePart,
+ * throw a PackageNamePartError.
+ */
+ static void validate(const std::string &);
+ };
+
+ /**
+ * A PackageNamePart holds a std::string that is a valid name for the
+ * category part of a QualifiedPackageName.
+ *
+ * \ingroup Database
+ */
+ typedef Validated<std::string, PackageNamePartValidator> PackageNamePart;
+
+ /**
+ * Holds a set of PackageNamePart instances.
+ *
+ * \ingroup Database
+ */
+ typedef SortedCollection<PackageNamePart> PackageNamePartCollection;
+
+ /**
+ * A CategoryNamePartError is thrown if an invalid value is assigned to
+ * a CategoryNamePart.
+ *
+ * \ingroup Exception
+ * \ingroup Database
+ */
+ class CategoryNamePartError : public NameError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ CategoryNamePartError(const std::string & name) throw ();
+ };
+
+ /**
+ * A CategoryNamePartValidator handles validation rules for the value
+ * of a CategoryNamePart.
+ *
+ * \ingroup Database
+ */
+ struct CategoryNamePartValidator :
+ private InstantiationPolicy<CategoryNamePartValidator, instantiation_method::NonInstantiableTag>
+ {
+ /**
+ * If the parameter is not a valid value for a CategoryNamePart,
+ * throw a CategoryNamePartError.
+ */
+ static void validate(const std::string &);
+ };
+
+ /**
+ * A CategoryNamePart holds a std::string that is a valid name for the
+ * category part of a QualifiedPackageName.
+ *
+ * \ingroup Database
+ */
+ typedef Validated<std::string, CategoryNamePartValidator> CategoryNamePart;
+
+ /**
+ * Holds a set of CategoryNamePart instances.
+ *
+ * \ingroup Database
+ */
+ typedef SortedCollection<CategoryNamePart> CategoryNamePartCollection;
+
+ /**
+ * Keys for a QualifiedPackageName.
+ */
+ enum QualifiedPackageNameKeys
+ {
+ qpn_category, ///< The CategoryNamePart part
+ qpn_package, ///< The PackageNamePart part
+ last_qpn ///< Number of values
+ };
+
+ /**
+ * Tags for a QualifiedPackageName.
+ */
+ struct QualifiedPackageNameTag :
+ SmartRecordTag<comparison_mode::FullComparisonTag, comparison_method::SmartRecordCompareByAllTag>,
+ SmartRecordKeys<QualifiedPackageNameKeys, last_qpn>,
+ SmartRecordKey<qpn_category, CategoryNamePart>,
+ SmartRecordKey<qpn_package, PackageNamePart>
+ {
+ };
+
+ /**
+ * A QualifiedPackageName instance holds a CategoryNamePart and
+ * a PackageNamePart.
+ */
+ class QualifiedPackageName :
+ public MakeSmartRecord<QualifiedPackageNameTag>::Type
+ {
+ private:
+ static MakeSmartRecord<QualifiedPackageNameTag>::Type _make_parent(
+ const std::string & s);
+
+ public:
+ /**
+ * Constructor.
+ */
+ QualifiedPackageName(const CategoryNamePart & c, const PackageNamePart & p) :
+ MakeSmartRecord<QualifiedPackageNameTag>::Type(c, p)
+ {
+ }
+
+ /**
+ * Copy constructor.
+ */
+ QualifiedPackageName(const QualifiedPackageName & other) :
+ MakeSmartRecord<QualifiedPackageNameTag>::Type(other)
+ {
+ }
+
+ /**
+ * Constructor, from a raw string.
+ */
+ explicit QualifiedPackageName(const std::string & s) :
+ MakeSmartRecord<QualifiedPackageNameTag>::Type(_make_parent(s))
+ {
+ }
+
+ /**
+ * Assignment.
+ */
+ const QualifiedPackageName & operator= (const QualifiedPackageName & other)
+ {
+ MakeSmartRecord<QualifiedPackageNameTag>::Type::operator= (other);
+ return *this;
+ }
+ };
+
+ /**
+ * Output a QualifiedPackageName to a stream.
+ */
+ std::ostream & operator<< (std::ostream &, const QualifiedPackageName &);
+
+ /**
+ * Holds a collection of QualifiedPackageName instances.
+ */
+ typedef SortedCollection<QualifiedPackageName> QualifiedPackageNameCollection;
+
+ /**
+ * 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).
+ */
+ class QualifiedPackageNameError : public NameError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ QualifiedPackageNameError(const std::string &) throw ();
+ };
+
+ /**
+ * Convenience operator to make a QualifiedPackageName from a
+ * PackageNamePart and a CategoryNamePart.
+ */
+ inline const QualifiedPackageName
+ operator+ (const CategoryNamePart & c, const PackageNamePart & p)
+ {
+ return QualifiedPackageName(c, p);
+ }
+
+ /**
+ * A UseFlagNameError is thrown if an invalid value is assigned to
+ * a UseFlagName.
+ *
+ * \ingroup Database
+ * \ingroup Exception
+ */
+ class UseFlagNameError : public NameError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ UseFlagNameError(const std::string & name) throw ();
+ };
+
+ /**
+ * A UseFlagNameValidator handles validation rules for the value of a
+ * UseFlagName.
+ *
+ * \ingroup Database
+ */
+ struct UseFlagNameValidator :
+ private InstantiationPolicy<UseFlagNameValidator, instantiation_method::NonInstantiableTag>
+ {
+ /**
+ * If the parameter is not a valid value for a UseFlagName,
+ * throw a UseFlagNameError.
+ */
+ static void validate(const std::string &);
+ };
+
+ /**
+ * A UseFlagName holds a std::string that is a valid name for a USE flag.
+ *
+ * \ingroup Database
+ */
+ typedef Validated<std::string, UseFlagNameValidator> UseFlagName;
+
+ /**
+ * A SlotNameError is thrown if an invalid value is assigned to
+ * a SlotName.
+ *
+ * \ingroup Database
+ * \ingroup Exception
+ */
+ class SlotNameError : public NameError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ SlotNameError(const std::string & name) throw ();
+ };
+
+ /**
+ * A SlotNameValidator handles validation rules for the value of a
+ * SlotName.
+ *
+ * \ingroup Database
+ */
+ struct SlotNameValidator :
+ private InstantiationPolicy<SlotNameValidator, instantiation_method::NonInstantiableTag>
+ {
+ /**
+ * If the parameter is not a valid value for a SlotName,
+ * throw a SlotNameError.
+ */
+ static void validate(const std::string &);
+ };
+
+ /**
+ * A SlotName holds a std::string that is a valid name for a SLOT.
+ *
+ * \ingroup Database
+ */
+ typedef Validated<std::string, SlotNameValidator> SlotName;
+
+ /**
+ * A RepositoryNameError is thrown if an invalid value is assigned to
+ * a RepositoryName.
+ *
+ * \ingroup Exception
+ * \ingroup Database
+ */
+ class RepositoryNameError : public NameError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ RepositoryNameError(const std::string & name) throw ();
+ };
+
+ /**
+ * A RepositoryNameValidator handles validation rules for the value
+ * of a RepositoryName.
+ *
+ * \ingroup Database
+ */
+ struct 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 &);
+ };
+
+ /**
+ * A RepositoryNamePart holds a std::string that is a valid name for a
+ * Repository.
+ *
+ * \ingroup Database
+ */
+ typedef Validated<std::string, RepositoryNameValidator> RepositoryName;
+
+ /**
+ * Holds a collection of RepositoryName instances.
+ */
+ typedef SequentialCollection<RepositoryName> RepositoryNameCollection;
+
+ /**
+ * A KeywordNameValidator handles validation rules for the value of a
+ * UseFlagName.
+ *
+ * \ingroup Environment
+ */
+ struct 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 &);
+ };
+
+ /**
+ * A KeywordNameError is thrown if an invalid value is assigned to
+ * a KeywordNameName.
+ *
+ * \ingroup Environment
+ * \ingroup Exception
+ */
+ class KeywordNameError : public NameError
+ {
+ public:
+ /**
+ * Constructor.
+ */
+ KeywordNameError(const std::string & name) throw ();
+ };
+
+ /**
+ * A KeywordName holds a std::string that is a valid name for a KEYWORD.
+ *
+ * \ingroup Database
+ */
+ typedef Validated<std::string, KeywordNameValidator> KeywordName;
+
+}
+
+#endif
diff --git a/paludis/name_TEST.cc b/paludis/name_TEST.cc
new file mode 100644
index 0000000..3944ab5
--- /dev/null
+++ b/paludis/name_TEST.cc
@@ -0,0 +1,209 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
+ *
+ * This file is part of the Paludis package manager. Paludis is free software;
+ * you can redistribute it and/or modify it under the terms of the GNU General
+ * Public License version 2, as published by the Free Software Foundation.
+ *
+ * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+ * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU General Public License along with
+ * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
+ * Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include <paludis/name.hh>
+#include <paludis/util/exception.hh>
+#include <test/test_framework.hh>
+#include <test/test_runner.hh>
+
+using namespace test;
+using namespace paludis;
+
+/** \file
+ * Test cases for QualifiedPackageName.
+ *
+ * \ingroup Test
+ */
+
+namespace test_cases
+{
+ /**
+ * \test Basic QualifiedPackageName tests.
+ *
+ * \ingroup Test
+ */
+ struct QualifiedPackageNameTest : TestCase
+ {
+ QualifiedPackageNameTest() : TestCase("basic") { }
+
+ void run()
+ {
+ QualifiedPackageName a("foo/bar1");
+ TEST_CHECK(true);
+ }
+ } test_qualified_package_name;
+
+ /**
+ * \test Validate QualifiedPackageName tests.
+ *
+ * \ingroup Test
+ */
+ struct QualifiedPackageNameValidateTest : TestCase
+ {
+ QualifiedPackageNameValidateTest() : TestCase("validate") { }
+
+ void run()
+ {
+ QualifiedPackageName a("foo/bar");
+ TEST_CHECK_THROWS(a = QualifiedPackageName("moo"), NameError);
+ TEST_CHECK_THROWS(a = QualifiedPackageName("foo/bar!"), NameError);
+ TEST_CHECK_THROWS(a = QualifiedPackageName("foo/bar/baz"), NameError);
+ }
+ } test_qualified_package_name_validate;
+
+ /**
+ * \test Compare QualifiedPackageName tests.
+ *
+ * \ingroup Test
+ */
+ struct QualifiedPackageNameCompareTest : TestCase
+ {
+ QualifiedPackageNameCompareTest() : TestCase("compare") { }
+
+ void run()
+ {
+ QualifiedPackageName foo1_bar1("foo1/bar1");
+ QualifiedPackageName foo1_bar2("foo1/bar2");
+ QualifiedPackageName foo2_bar1("foo2/bar1");
+
+ TEST_CHECK( (foo1_bar1 < foo1_bar2));
+ TEST_CHECK( (foo1_bar1 <= foo1_bar2));
+ TEST_CHECK(!(foo1_bar1 == foo1_bar2));
+ TEST_CHECK( (foo1_bar1 != foo1_bar2));
+ TEST_CHECK(!(foo1_bar1 >= foo1_bar2));
+ TEST_CHECK(!(foo1_bar1 > foo1_bar2));
+
+ TEST_CHECK(!(foo2_bar1 < foo1_bar2));
+ TEST_CHECK(!(foo2_bar1 <= foo1_bar2));
+ TEST_CHECK(!(foo2_bar1 == foo1_bar2));
+ TEST_CHECK( (foo2_bar1 != foo1_bar2));
+ TEST_CHECK( (foo2_bar1 >= foo1_bar2));
+ TEST_CHECK( (foo2_bar1 > foo1_bar2));
+ }
+ } test_qualified_package_name_compare;
+
+ /**
+ * \test Test CategoryNamePart creation.
+ *
+ * \ingroup Test
+ */
+ struct CategoryNamePartCreationTest : public TestCase
+ {
+ CategoryNamePartCreationTest() : TestCase("creation") { }
+
+ void run()
+ {
+ CategoryNamePart p("foo");
+ TEST_CHECK(true);
+ }
+ } category_package_name_part_creation;
+
+ /**
+ * \test Test CategoryNamePart validation
+ *
+ * \ingroup Test
+ */
+ struct CategoryNamePartValidationTest : public TestCase
+ {
+ CategoryNamePartValidationTest() : TestCase("validation") {}
+
+ void run()
+ {
+ CategoryNamePart p = CategoryNamePart("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-+_");
+
+ TEST_CHECK_THROWS(p = CategoryNamePart(""), CategoryNamePartError);
+ TEST_CHECK_THROWS(p = CategoryNamePart("*"), CategoryNamePartError);
+ TEST_CHECK_THROWS(p = CategoryNamePart("foo bar"), CategoryNamePartError);
+ }
+ } category_package_name_part_validation;
+
+ /**
+ * \test Test PackageNamePart creation.
+ *
+ * \ingroup Test
+ */
+ struct PackageNamePartCreationTest : public TestCase
+ {
+ PackageNamePartCreationTest() : TestCase("creation") { }
+
+ void run()
+ {
+ PackageNamePart p("foo");
+ TEST_CHECK(true);
+ }
+ } test_package_name_part_creation;
+
+ /**
+ * \test Test PackageNamePart validation.
+ *
+ * \ingroup Test
+ */
+ struct PackageNamePartValidationTest : public TestCase
+ {
+ PackageNamePartValidationTest() : TestCase("validation") { }
+
+ void run()
+ {
+ PackageNamePart p("foo-200dpi");
+ TEST_CHECK_THROWS(p = PackageNamePart(""), NameError);
+ TEST_CHECK_THROWS(p = PackageNamePart("!!!"), NameError);
+ TEST_CHECK_THROWS(p = PackageNamePart("foo-2"), NameError);
+ TEST_CHECK_THROWS(p = PackageNamePart("foo-200"), NameError);
+ }
+ } test_package_name_part_validation;
+
+ /**
+ * \test Test PackageNamePart comparison.
+ *
+ * \ingroup Test
+ */
+ struct PackageNamePartComparisonTest : public TestCase
+ {
+ PackageNamePartComparisonTest() : TestCase("comparison") { }
+
+ void run()
+ {
+ PackageNamePart p1("p1");
+ PackageNamePart p2("p2");
+
+ TEST_CHECK( (p1 < p2));
+ TEST_CHECK( (p1 <= p2));
+ TEST_CHECK(!(p1 == p2));
+ TEST_CHECK(!(p1 > p2));
+ TEST_CHECK(!(p1 >= p2));
+ TEST_CHECK( (p1 != p2));
+
+ TEST_CHECK(!(p2 < p2));
+ TEST_CHECK( (p2 <= p2));
+ TEST_CHECK( (p2 == p2));
+ TEST_CHECK(!(p2 > p2));
+ TEST_CHECK( (p2 >= p2));
+ TEST_CHECK(!(p2 != p2));
+
+ TEST_CHECK(!(p2 < p1));
+ TEST_CHECK(!(p2 <= p1));
+ TEST_CHECK(!(p2 == p1));
+ TEST_CHECK( (p2 > p1));
+ TEST_CHECK( (p2 >= p1));
+ TEST_CHECK( (p2 != p1));
+ }
+ } test_package_name_part_comparison;
+
+}
+
diff --git a/paludis/package_database.hh b/paludis/package_database.hh
index 230989f..21415f9 100644
--- a/paludis/package_database.hh
+++ b/paludis/package_database.hh
@@ -21,7 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_PACKAGE_DATABASE_HH 1
#include <paludis/dep_atom.hh>
-#include <paludis/qualified_package_name.hh>
+#include <paludis/name.hh>
#include <paludis/repository.hh>
#include <paludis/util/counted_ptr.hh>
#include <paludis/util/exception.hh>
diff --git a/paludis/package_name_part.cc b/paludis/package_name_part.cc
deleted file mode 100644
index 2f3bc7c..0000000
--- a/paludis/package_name_part.cc
+++ /dev/null
@@ -1,71 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/package_name_part.hh>
-
-using namespace paludis;
-
-PackageNamePartError::PackageNamePartError(const std::string & name) throw () :
- NameError(name, "package name part")
-{
-}
-
-void
-PackageNamePartValidator::validate(const std::string & s)
-{
- /* this gets called a lot, make it fast */
-
- static const std::string allowed_chars(
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789-+_");
-
- static const std::string number_chars(
- "0123456789");
-
- if (s.empty() || '-' == s.at(0))
- {
- Context c("When validating package name part '" + s + "':");
- throw PackageNamePartError(s);
- }
-
- /* we don't allow - followed by only numbers, because it could be
- * a version spec. */
- 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);
- }
-
- if ('-' != s[p])
- continue;
- if (++p >= s.length())
- break;
- if ((std::string::npos != number_chars.find(s[p]) &&
- std::string::npos == s.find_first_not_of(number_chars, p)) ||
- (std::string::npos == allowed_chars.find(s[p])))
- {
- Context c("When validating package name part '" + s + "':");
- throw PackageNamePartError(s);
- }
- }
-}
-
diff --git a/paludis/package_name_part.hh b/paludis/package_name_part.hh
deleted file mode 100644
index 575e62e..0000000
--- a/paludis/package_name_part.hh
+++ /dev/null
@@ -1,86 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_PACKAGE_NAME_PART_HH
-#define PALUDIS_GUARD_PALUDIS_PACKAGE_NAME_PART_HH 1
-
-#include <paludis/util/exception.hh>
-#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/sorted_collection.hh>
-#include <paludis/util/validated.hh>
-#include <string>
-
-/** \file
- * Declarations for PackageNamePart and related classes.
- *
- * \ingroup Database
- * \ingroup Exception
- */
-
-namespace paludis
-{
- /**
- * A PackageNamePartError is thrown if an invalid value is assigned to
- * a PackageNamePart.
- *
- * \ingroup Database
- * \ingroup Exception
- */
- class PackageNamePartError : public NameError
- {
- public:
- /**
- * Constructor.
- */
- PackageNamePartError(const std::string & name) throw ();
- };
-
- /**
- * A PackageNamePartValidator handles validation rules for the value
- * of a PackageNamePart.
- *
- * \ingroup Database
- */
- struct PackageNamePartValidator :
- private InstantiationPolicy<PackageNamePartValidator, instantiation_method::NonInstantiableTag>
- {
- /**
- * If the parameter is not a valid value for a PackageNamePart,
- * throw a PackageNamePartError.
- */
- static void validate(const std::string &);
- };
-
- /**
- * A PackageNamePart holds a std::string that is a valid name for the
- * category part of a QualifiedPackageName.
- *
- * \ingroup Database
- */
- typedef Validated<std::string, PackageNamePartValidator> PackageNamePart;
-
- /**
- * Holds a set of PackageNamePart instances.
- *
- * \ingroup Database
- */
- typedef SortedCollection<PackageNamePart> PackageNamePartCollection;
-}
-
-#endif
diff --git a/paludis/package_name_part_TEST.cc b/paludis/package_name_part_TEST.cc
deleted file mode 100644
index 094e6be..0000000
--- a/paludis/package_name_part_TEST.cc
+++ /dev/null
@@ -1,110 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/package_name_part.hh>
-#include <string>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-
-using namespace test;
-using namespace paludis;
-
-/** \file
- * Test cases for package_name_part.hh .
- *
- * \ingroup Test
- */
-
-namespace test_cases
-{
- /**
- * \test Test PackageNamePart creation.
- *
- * \ingroup Test
- */
- struct PackageNamePartCreationTest : public TestCase
- {
- PackageNamePartCreationTest() : TestCase("creation") { }
-
- void run()
- {
- PackageNamePart p("foo");
- TEST_CHECK(true);
- }
- } test_package_name_part_creation;
-
- /**
- * \test Test PackageNamePart validation.
- *
- * \ingroup Test
- */
- struct PackageNamePartValidationTest : public TestCase
- {
- PackageNamePartValidationTest() : TestCase("validation") { }
-
- void run()
- {
- PackageNamePart p("foo-200dpi");
- TEST_CHECK_THROWS(p = PackageNamePart(""), NameError);
- TEST_CHECK_THROWS(p = PackageNamePart("!!!"), NameError);
- TEST_CHECK_THROWS(p = PackageNamePart("foo-2"), NameError);
- TEST_CHECK_THROWS(p = PackageNamePart("foo-200"), NameError);
- }
- } test_package_name_part_validation;
-
- /**
- * \test Test PackageNamePart comparison.
- *
- * \ingroup Test
- */
- struct PackageNamePartComparisonTest : public TestCase
- {
- PackageNamePartComparisonTest() : TestCase("comparison") { }
-
- void run()
- {
- PackageNamePart p1("p1");
- PackageNamePart p2("p2");
-
- TEST_CHECK( (p1 < p2));
- TEST_CHECK( (p1 <= p2));
- TEST_CHECK(!(p1 == p2));
- TEST_CHECK(!(p1 > p2));
- TEST_CHECK(!(p1 >= p2));
- TEST_CHECK( (p1 != p2));
-
- TEST_CHECK(!(p2 < p2));
- TEST_CHECK( (p2 <= p2));
- TEST_CHECK( (p2 == p2));
- TEST_CHECK(!(p2 > p2));
- TEST_CHECK( (p2 >= p2));
- TEST_CHECK(!(p2 != p2));
-
- TEST_CHECK(!(p2 < p1));
- TEST_CHECK(!(p2 <= p1));
- TEST_CHECK(!(p2 == p1));
- TEST_CHECK( (p2 > p1));
- TEST_CHECK( (p2 >= p1));
- TEST_CHECK( (p2 != p1));
- }
- } test_package_name_part_comparison;
-}
-
-
-
diff --git a/paludis/qa/ebuild_check.hh b/paludis/qa/ebuild_check.hh
index f055f94..2072c40 100644
--- a/paludis/qa/ebuild_check.hh
+++ b/paludis/qa/ebuild_check.hh
@@ -20,10 +20,10 @@
#ifndef PALUDIS_GUARD_PALUDIS_QA_EBUILD_CHECK_HH
#define PALUDIS_GUARD_PALUDIS_QA_EBUILD_CHECK_HH 1
+#include <paludis/name.hh>
#include <paludis/qa/check.hh>
#include <paludis/qa/check_result.hh>
#include <paludis/qa/environment.hh>
-#include <paludis/qualified_package_name.hh>
#include <paludis/util/counted_ptr.hh>
#include <paludis/util/smart_record.hh>
#include <paludis/util/virtual_constructor.hh>
diff --git a/paludis/qa/package_name_check.cc b/paludis/qa/package_name_check.cc
index 6f6cd0a..1390745 100644
--- a/paludis/qa/package_name_check.cc
+++ b/paludis/qa/package_name_check.cc
@@ -17,8 +17,8 @@
* Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include <paludis/name.hh>
#include <paludis/qa/package_name_check.hh>
-#include <paludis/qualified_package_name.hh>
using namespace paludis;
using namespace paludis::qa;
diff --git a/paludis/qualified_package_name.cc b/paludis/qualified_package_name.cc
deleted file mode 100644
index 030dadd..0000000
--- a/paludis/qualified_package_name.cc
+++ /dev/null
@@ -1,51 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/qualified_package_name.hh>
-#include <paludis/util/stringify.hh>
-
-using namespace paludis;
-
-QualifiedPackageNameError::QualifiedPackageNameError(const std::string & s) throw () :
- NameError(s, "qualified package name")
-{
-}
-
-std::ostream &
-paludis::operator<< (std::ostream & s, const QualifiedPackageName & q)
-{
- s << q.get<qpn_category>() << "/" << q.get<qpn_package>();
- return s;
-}
-
-MakeSmartRecord<QualifiedPackageNameTag>::Type
-QualifiedPackageName::_make_parent(
- const std::string & s)
-{
- Context c("When splitting out category and package names from '" + s + "':");
-
- std::string::size_type p(s.find('/'));
- if (std::string::npos == p)
- throw QualifiedPackageNameError(s);
-
- return MakeSmartRecord<QualifiedPackageNameTag>::Type(
- CategoryNamePart(s.substr(0, p)),
- PackageNamePart(s.substr(p + 1)));
-}
-
diff --git a/paludis/qualified_package_name.hh b/paludis/qualified_package_name.hh
deleted file mode 100644
index 7b601ea..0000000
--- a/paludis/qualified_package_name.hh
+++ /dev/null
@@ -1,134 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_QUALIFIED_PACKAGE_NAME_HH
-#define PALUDIS_GUARD_PALUDIS_QUALIFIED_PACKAGE_NAME_HH 1
-
-#include <ostream>
-#include <paludis/category_name_part.hh>
-#include <paludis/package_name_part.hh>
-#include <paludis/util/exception.hh>
-#include <paludis/util/smart_record.hh>
-#include <paludis/util/sorted_collection.hh>
-
-namespace paludis
-{
- /**
- * Keys for a QualifiedPackageName.
- */
- enum QualifiedPackageNameKeys
- {
- qpn_category, ///< The CategoryNamePart part
- qpn_package, ///< The PackageNamePart part
- last_qpn ///< Number of values
- };
-
- /**
- * Tags for a QualifiedPackageName.
- */
- struct QualifiedPackageNameTag :
- SmartRecordTag<comparison_mode::FullComparisonTag, comparison_method::SmartRecordCompareByAllTag>,
- SmartRecordKeys<QualifiedPackageNameKeys, last_qpn>,
- SmartRecordKey<qpn_category, CategoryNamePart>,
- SmartRecordKey<qpn_package, PackageNamePart>
- {
- };
-
- /**
- * A QualifiedPackageName instance holds a CategoryNamePart and
- * a PackageNamePart.
- */
- class QualifiedPackageName :
- public MakeSmartRecord<QualifiedPackageNameTag>::Type
- {
- private:
- static MakeSmartRecord<QualifiedPackageNameTag>::Type _make_parent(
- const std::string & s);
-
- public:
- /**
- * Constructor.
- */
- QualifiedPackageName(const CategoryNamePart & c, const PackageNamePart & p) :
- MakeSmartRecord<QualifiedPackageNameTag>::Type(c, p)
- {
- }
-
- /**
- * Copy constructor.
- */
- QualifiedPackageName(const QualifiedPackageName & other) :
- MakeSmartRecord<QualifiedPackageNameTag>::Type(other)
- {
- }
-
- /**
- * Constructor, from a raw string.
- */
- explicit QualifiedPackageName(const std::string & s) :
- MakeSmartRecord<QualifiedPackageNameTag>::Type(_make_parent(s))
- {
- }
-
- /**
- * Assignment.
- */
- const QualifiedPackageName & operator= (const QualifiedPackageName & other)
- {
- MakeSmartRecord<QualifiedPackageNameTag>::Type::operator= (other);
- return *this;
- }
- };
-
- /**
- * Output a QualifiedPackageName to a stream.
- */
- std::ostream & operator<< (std::ostream &, const QualifiedPackageName &);
-
- /**
- * Holds a collection of QualifiedPackageName instances.
- */
- typedef SortedCollection<QualifiedPackageName> QualifiedPackageNameCollection;
-
- /**
- * 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).
- */
- class QualifiedPackageNameError : public NameError
- {
- public:
- /**
- * Constructor.
- */
- QualifiedPackageNameError(const std::string &) throw ();
- };
-
- /**
- * Convenience operator to make a QualifiedPackageName from a
- * PackageNamePart and a CategoryNamePart.
- */
- inline const QualifiedPackageName
- operator+ (const CategoryNamePart & c, const PackageNamePart & p)
- {
- return QualifiedPackageName(c, p);
- }
-}
-
-#endif
diff --git a/paludis/qualified_package_name_TEST.cc b/paludis/qualified_package_name_TEST.cc
deleted file mode 100644
index e2111d9..0000000
--- a/paludis/qualified_package_name_TEST.cc
+++ /dev/null
@@ -1,102 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/qualified_package_name.hh>
-#include <paludis/util/exception.hh>
-#include <test/test_framework.hh>
-#include <test/test_runner.hh>
-
-using namespace test;
-using namespace paludis;
-
-/** \file
- * Test cases for QualifiedPackageName.
- *
- * \ingroup Test
- */
-
-namespace test_cases
-{
- /**
- * \test Basic QualifiedPackageName tests.
- *
- * \ingroup Test
- */
- struct QualifiedPackageNameTest : TestCase
- {
- QualifiedPackageNameTest() : TestCase("basic") { }
-
- void run()
- {
- QualifiedPackageName a("foo/bar1");
- TEST_CHECK(true);
- }
- } test_qualified_package_name;
-
- /**
- * \test Validate QualifiedPackageName tests.
- *
- * \ingroup Test
- */
- struct QualifiedPackageNameValidateTest : TestCase
- {
- QualifiedPackageNameValidateTest() : TestCase("validate") { }
-
- void run()
- {
- QualifiedPackageName a("foo/bar");
- TEST_CHECK_THROWS(a = QualifiedPackageName("moo"), NameError);
- TEST_CHECK_THROWS(a = QualifiedPackageName("foo/bar!"), NameError);
- TEST_CHECK_THROWS(a = QualifiedPackageName("foo/bar/baz"), NameError);
- }
- } test_qualified_package_name_validate;
-
- /**
- * \test Compare QualifiedPackageName tests.
- *
- * \ingroup Test
- */
- struct QualifiedPackageNameCompareTest : TestCase
- {
- QualifiedPackageNameCompareTest() : TestCase("compare") { }
-
- void run()
- {
- QualifiedPackageName foo1_bar1("foo1/bar1");
- QualifiedPackageName foo1_bar2("foo1/bar2");
- QualifiedPackageName foo2_bar1("foo2/bar1");
-
- TEST_CHECK( (foo1_bar1 < foo1_bar2));
- TEST_CHECK( (foo1_bar1 <= foo1_bar2));
- TEST_CHECK(!(foo1_bar1 == foo1_bar2));
- TEST_CHECK( (foo1_bar1 != foo1_bar2));
- TEST_CHECK(!(foo1_bar1 >= foo1_bar2));
- TEST_CHECK(!(foo1_bar1 > foo1_bar2));
-
- TEST_CHECK(!(foo2_bar1 < foo1_bar2));
- TEST_CHECK(!(foo2_bar1 <= foo1_bar2));
- TEST_CHECK(!(foo2_bar1 == foo1_bar2));
- TEST_CHECK( (foo2_bar1 != foo1_bar2));
- TEST_CHECK( (foo2_bar1 >= foo1_bar2));
- TEST_CHECK( (foo2_bar1 > foo1_bar2));
- }
- } test_qualified_package_name_compare;
-
-}
-
diff --git a/paludis/repository.hh b/paludis/repository.hh
index 1840bc9..d37d801 100644
--- a/paludis/repository.hh
+++ b/paludis/repository.hh
@@ -20,9 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORY_HH
#define PALUDIS_GUARD_PALUDIS_REPOSITORY_HH 1
-#include <paludis/category_name_part.hh>
-#include <paludis/package_name_part.hh>
-#include <paludis/repository_name.hh>
+#include <paludis/name.hh>
#include <paludis/use_flag_state.hh>
#include <paludis/util/attributes.hh>
#include <paludis/util/counted_ptr.hh>
diff --git a/paludis/repository_name.cc b/paludis/repository_name.cc
deleted file mode 100644
index 25390a8..0000000
--- a/paludis/repository_name.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/repository_name.hh>
-
-using namespace paludis;
-
-void
-RepositoryNameValidator::validate(const std::string & s)
-{
- static const std::string allowed_chars(
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789-+_/");
-
- do
- {
- if (s.empty())
- break;
-
- if ('-' == s.at(0))
- break;
-
- if (std::string::npos != s.find_first_not_of(allowed_chars))
- break;
-
- return;
-
- } while (false);
-
- Context c("When validating repository name '" + s + "':");
- throw RepositoryNameError(s);
-}
-
-RepositoryNameError::RepositoryNameError(const std::string & name) throw () :
- NameError(name, "repository")
-{
-}
-
diff --git a/paludis/repository_name.hh b/paludis/repository_name.hh
deleted file mode 100644
index 5e8eca4..0000000
--- a/paludis/repository_name.hh
+++ /dev/null
@@ -1,85 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_REPOSITORY_NAME_HH
-#define PALUDIS_GUARD_PALUDIS_REPOSITORY_NAME_HH 1
-
-#include <paludis/util/exception.hh>
-#include <paludis/util/private_implementation_pattern.hh>
-#include <paludis/util/sequential_collection.hh>
-#include <paludis/util/validated.hh>
-
-#include <string>
-
-/** \file
- * Declaration for RepositoryName and related classes.
- *
- * \ingroup Database
- * \ingroup Exception
- */
-
-namespace paludis
-{
- /**
- * A RepositoryNameError is thrown if an invalid value is assigned to
- * a RepositoryName.
- *
- * \ingroup Exception
- * \ingroup Database
- */
- class RepositoryNameError : public NameError
- {
- public:
- /**
- * Constructor.
- */
- RepositoryNameError(const std::string & name) throw ();
- };
-
- /**
- * A RepositoryNameValidator handles validation rules for the value
- * of a RepositoryName.
- *
- * \ingroup Database
- */
- struct 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 &);
- };
-
- /**
- * A RepositoryNamePart holds a std::string that is a valid name for a
- * Repository.
- *
- * \ingroup Database
- */
- typedef Validated<std::string, RepositoryNameValidator> RepositoryName;
-
- /**
- * Holds a collection of RepositoryName instances.
- */
- typedef SequentialCollection<RepositoryName> RepositoryNameCollection;
-}
-
-#endif
diff --git a/paludis/slot_name.cc b/paludis/slot_name.cc
deleted file mode 100644
index ea58426..0000000
--- a/paludis/slot_name.cc
+++ /dev/null
@@ -1,57 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/slot_name.hh>
-
-using namespace paludis;
-
-SlotNameError::SlotNameError(const std::string & name) throw () :
- NameError(name, "slot name")
-{
-}
-
-void
-SlotNameValidator::validate(const std::string & s)
-{
- static const std::string allowed_chars(
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789-+_.");
-
- do
- {
- if (s.empty())
- break;
-
- if ('-' == s.at(0))
- break;
-
- if (std::string::npos != s.find_first_not_of(allowed_chars))
- break;
-
- return;
-
- } while (false);
-
- Context c("When validating slot name '" + s + "':");
-
- throw SlotNameError(s);
-}
-
-
diff --git a/paludis/slot_name.hh b/paludis/slot_name.hh
deleted file mode 100644
index e2cbd51..0000000
--- a/paludis/slot_name.hh
+++ /dev/null
@@ -1,77 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_SLOT_NAME_HH
-#define PALUDIS_GUARD_PALUDIS_SLOT_NAME_HH 1
-
-#include <paludis/util/exception.hh>
-#include <paludis/util/instantiation_policy.hh>
-#include <paludis/util/validated.hh>
-#include <string>
-
-/** \file
- * Declarations for SlotName and related classes.
- *
- * \ingroup Database
- * \ingroup Exception
- */
-
-namespace paludis
-{
- /**
- * A SlotNameError is thrown if an invalid value is assigned to
- * a SlotName.
- *
- * \ingroup Database
- * \ingroup Exception
- */
- class SlotNameError : public NameError
- {
- public:
- /**
- * Constructor.
- */
- SlotNameError(const std::string & name) throw ();
- };
-
- /**
- * A SlotNameValidator handles validation rules for the value of a
- * SlotName.
- *
- * \ingroup Database
- */
- struct SlotNameValidator :
- private InstantiationPolicy<SlotNameValidator, instantiation_method::NonInstantiableTag>
- {
- /**
- * If the parameter is not a valid value for a SlotName,
- * throw a SlotNameError.
- */
- static void validate(const std::string &);
- };
-
- /**
- * A SlotName holds a std::string that is a valid name for a SLOT.
- *
- * \ingroup Database
- */
- typedef Validated<std::string, SlotNameValidator> SlotName;
-}
-
-#endif
diff --git a/paludis/use_flag_name.cc b/paludis/use_flag_name.cc
deleted file mode 100644
index 13a2952..0000000
--- a/paludis/use_flag_name.cc
+++ /dev/null
@@ -1,55 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#include <paludis/use_flag_name.hh>
-
-using namespace paludis;
-
-void
-UseFlagNameValidator::validate(const std::string & s)
-{
- static const std::string allowed_chars(
- "abcdefghijklmnopqrstuvwxyz"
- "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
- "0123456789-+_:@");
-
- do
- {
- if (s.empty())
- break;
-
- if ('-' == s.at(0))
- break;
-
- if (std::string::npos != s.find_first_not_of(allowed_chars))
- break;
-
- return;
-
- } while (false);
-
- Context c("When validating use flag name '" + s + "':");
-
- throw UseFlagNameError(s);
-}
-
-UseFlagNameError::UseFlagNameError(const std::string & name) throw () :
- NameError(name, "use flag name")
-{
-}
diff --git a/paludis/use_flag_name.hh b/paludis/use_flag_name.hh
deleted file mode 100644
index 4092af2..0000000
--- a/paludis/use_flag_name.hh
+++ /dev/null
@@ -1,77 +0,0 @@
-/* vim: set sw=4 sts=4 et foldmethod=syntax : */
-
-/*
- * Copyright (c) 2005, 2006 Ciaran McCreesh <ciaranm@gentoo.org>
- *
- * This file is part of the Paludis package manager. Paludis is free software;
- * you can redistribute it and/or modify it under the terms of the GNU General
- * Public License version 2, as published by the Free Software Foundation.
- *
- * Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
- * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_USE_FLAG_NAME_HH
-#define PALUDIS_GUARD_PALUDIS_USE_FLAG_NAME_HH 1
-
-#include <paludis/util/exception.hh>
-#include <paludis/util/instantiation_policy.hh>
-#include <paludis/util/validated.hh>
-#include <string>
-
-/** \file
- * Declarations for UseFlagName and related classes.
- *
- * \ingroup Database
- * \ingroup Exception
- */
-
-namespace paludis
-{
- /**
- * A UseFlagNameError is thrown if an invalid value is assigned to
- * a UseFlagName.
- *
- * \ingroup Database
- * \ingroup Exception
- */
- class UseFlagNameError : public NameError
- {
- public:
- /**
- * Constructor.
- */
- UseFlagNameError(const std::string & name) throw ();
- };
-
- /**
- * A UseFlagNameValidator handles validation rules for the value of a
- * UseFlagName.
- *
- * \ingroup Database
- */
- struct UseFlagNameValidator :
- private InstantiationPolicy<UseFlagNameValidator, instantiation_method::NonInstantiableTag>
- {
- /**
- * If the parameter is not a valid value for a UseFlagName,
- * throw a UseFlagNameError.
- */
- static void validate(const std::string &);
- };
-
- /**
- * A UseFlagName holds a std::string that is a valid name for a USE flag.
- *
- * \ingroup Database
- */
- typedef Validated<std::string, UseFlagNameValidator> UseFlagName;
-}
-
-#endif
diff --git a/paludis/version_metadata.hh b/paludis/version_metadata.hh
index ebf06d1..80395f6 100644
--- a/paludis/version_metadata.hh
+++ b/paludis/version_metadata.hh
@@ -20,9 +20,7 @@
#ifndef PALUDIS_GUARD_PALUDIS_VERSION_METADATA_HH
#define PALUDIS_GUARD_PALUDIS_VERSION_METADATA_HH 1
-#include <paludis/keyword_name.hh>
-#include <paludis/qualified_package_name.hh>
-#include <paludis/use_flag_name.hh>
+#include <paludis/name.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/private_implementation_pattern.hh>
#include <paludis/version_metadata.hh>