aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-21 18:30:48 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-21 18:30:48 +0000
commitb373502b50935e9b068b0dc344bf81273de216dd (patch)
tree2cfe903b9c070ffcac32c8896412ff2380b35fb0
parentc34b2651b6ad541b6084f627f3ed48104cfc20c5 (diff)
downloadpaludis-b373502b50935e9b068b0dc344bf81273de216dd.tar.gz
paludis-b373502b50935e9b068b0dc344bf81273de216dd.tar.xz
Merge category_name_part_validator, category_name_part_error into category_name_part. Separate files are overkill here.
-rw-r--r--paludis/category_name_part.cc33
-rw-r--r--paludis/category_name_part.hh38
-rw-r--r--paludis/category_name_part_error.cc28
-rw-r--r--paludis/category_name_part_error.hh52
-rw-r--r--paludis/category_name_part_validator.cc49
-rw-r--r--paludis/category_name_part_validator.hh51
-rw-r--r--paludis/files.m42
7 files changed, 69 insertions, 184 deletions
diff --git a/paludis/category_name_part.cc b/paludis/category_name_part.cc
index 7f84ca1..a25aeea 100644
--- a/paludis/category_name_part.cc
+++ b/paludis/category_name_part.cc
@@ -19,3 +19,36 @@
#include "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 (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
index 4512395..ee2ed3b 100644
--- a/paludis/category_name_part.hh
+++ b/paludis/category_name_part.hh
@@ -21,18 +21,52 @@
#define PALUDIS_GUARD_PALUDIS_CATEGORY_NAME_PART_HH 1
#include <paludis/validated.hh>
-#include <paludis/category_name_part_validator.hh>
+#include <paludis/name_error.hh>
+#include <paludis/private_implementation_pattern.hh>
#include <string>
/** \file
- * Declaration for the CategoryNamePart class.
+ * 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.
*
diff --git a/paludis/category_name_part_error.cc b/paludis/category_name_part_error.cc
deleted file mode 100644
index 4aded7b..0000000
--- a/paludis/category_name_part_error.cc
+++ /dev/null
@@ -1,28 +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 "category_name_part_error.hh"
-
-using namespace paludis;
-
-CategoryNamePartError::CategoryNamePartError(const std::string & name) throw () :
- NameError(name, "category name part")
-{
-}
-
diff --git a/paludis/category_name_part_error.hh b/paludis/category_name_part_error.hh
deleted file mode 100644
index 9823473..0000000
--- a/paludis/category_name_part_error.hh
+++ /dev/null
@@ -1,52 +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_ERROR_HH
-#define PALUDIS_GUARD_PALUDIS_CATEGORY_NAME_PART_ERROR_HH 1
-
-#include <paludis/name_error.hh>
-#include <string>
-
-/** \file
- * Declaration for the CategoryNamePartError exception.
- *
- * \ingroup Exception
- * \ingroup Database
- */
-
-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 ();
- };
-}
-
-#endif
diff --git a/paludis/category_name_part_validator.cc b/paludis/category_name_part_validator.cc
deleted file mode 100644
index e5e7bec..0000000
--- a/paludis/category_name_part_validator.cc
+++ /dev/null
@@ -1,49 +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 "category_name_part_validator.hh"
-#include "category_name_part_error.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 (std::string::npos != s.find_first_not_of(allowed_chars))
- break;
-
- return;
-
- } while (false);
-
- Context c("When validating category name '" + s + "':");
- throw CategoryNamePartError(s);
-}
diff --git a/paludis/category_name_part_validator.hh b/paludis/category_name_part_validator.hh
deleted file mode 100644
index f74cf95..0000000
--- a/paludis/category_name_part_validator.hh
+++ /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
- */
-
-#ifndef PALUDIS_GUARD_PALUDIS_CATEGORY_NAME_PART_VALIDATOR_HH
-#define PALUDIS_GUARD_PALUDIS_CATEGORY_NAME_PART_VALIDATOR_HH 1
-
-#include <string>
-#include <paludis/instantiation_policy.hh>
-
-/** \file
- * Declaration for the CategoryNamePartValidator class.
- *
- * \ingroup Database
- */
-
-namespace paludis
-{
- /**
- * 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 &);
- };
-}
-
-#endif
diff --git a/paludis/files.m4 b/paludis/files.m4
index f2caa3a..5a114b1 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -19,8 +19,6 @@ add(`block_dep_atom', `hh', `cc')
add(`block_error', `hh', `cc')
add(`category_name_part', `hh', `cc')
add(`category_name_part_collection', `hh', `cc')
-add(`category_name_part_error', `hh', `cc')
-add(`category_name_part_validator', `hh', `cc')
add(`circular_dependency_error', `hh', `cc')
add(`comparison_policy', `hh', `cc', `test')
add(`composite_dep_atom', `hh', `cc')