aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-21 17:36:08 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-01-21 17:36:08 +0000
commit7c0d7c9161bdda545d3dba728c6d9b57a7ff422a (patch)
tree666d1adcc9fdaabc3953c134de7fb4ab17140585
parent5afcf5c43994dcce339f17a049cb516794043cff (diff)
downloadpaludis-7c0d7c9161bdda545d3dba728c6d9b57a7ff422a.tar.gz
paludis-7c0d7c9161bdda545d3dba728c6d9b57a7ff422a.tar.xz
Merge use_flag_name_validator, use_flag_name_error into use_flag_name. Separate files are overkill here.
-rw-r--r--paludis/files.m42
-rw-r--r--paludis/use_flag_name.cc31
-rw-r--r--paludis/use_flag_name.hh38
-rw-r--r--paludis/use_flag_name_error.cc27
-rw-r--r--paludis/use_flag_name_error.hh54
-rw-r--r--paludis/use_flag_name_validator.cc49
-rw-r--r--paludis/use_flag_name_validator.hh51
7 files changed, 67 insertions, 185 deletions
diff --git a/paludis/files.m4 b/paludis/files.m4
index c27460b..99d9a94 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -116,8 +116,6 @@ add(`test_environment', `hh', `cc')
add(`transform_insert_iterator', `hh', `cc', `test')
add(`use_dep_atom', `hh', `cc')
add(`use_flag_name', `hh', `cc')
-add(`use_flag_name_error', `hh', `cc')
-add(`use_flag_name_validator', `hh', `cc')
add(`use_flag_state', `hh', `cc')
add(`validated', `hh', `cc', `test')
add(`version_metadata', `hh', `cc')
diff --git a/paludis/use_flag_name.cc b/paludis/use_flag_name.cc
index a2f1959..8ef16c2 100644
--- a/paludis/use_flag_name.cc
+++ b/paludis/use_flag_name.cc
@@ -19,3 +19,34 @@
#include "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 (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
index a93b21a..8cb53a3 100644
--- a/paludis/use_flag_name.hh
+++ b/paludis/use_flag_name.hh
@@ -21,18 +21,52 @@
#define PALUDIS_GUARD_PALUDIS_USE_FLAG_NAME_HH 1
#include <paludis/validated.hh>
-#include <paludis/use_flag_name_validator.hh>
+#include <paludis/name_error.hh>
+#include <paludis/instantiation_policy.hh>
#include <string>
/** \file
- * Declarations for the UseFlagName class.
+ * 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
diff --git a/paludis/use_flag_name_error.cc b/paludis/use_flag_name_error.cc
deleted file mode 100644
index 14e4eb4..0000000
--- a/paludis/use_flag_name_error.cc
+++ /dev/null
@@ -1,27 +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 "use_flag_name_error.hh"
-
-using namespace paludis;
-
-UseFlagNameError::UseFlagNameError(const std::string & name) throw () :
- NameError(name, "use flag name")
-{
-}
diff --git a/paludis/use_flag_name_error.hh b/paludis/use_flag_name_error.hh
deleted file mode 100644
index 3ea629e..0000000
--- a/paludis/use_flag_name_error.hh
+++ /dev/null
@@ -1,54 +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_ERROR_HH
-#define PALUDIS_GUARD_PALUDIS_USE_FLAG_NAME_ERROR_HH 1
-
-#include <paludis/name_error.hh>
-#include <string>
-
-/** \file
- * Declarations for UseFlagNameError.
- *
- * \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 ();
- };
-}
-
-
-
-#endif
diff --git a/paludis/use_flag_name_validator.cc b/paludis/use_flag_name_validator.cc
deleted file mode 100644
index 4f9506a..0000000
--- a/paludis/use_flag_name_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 "use_flag_name_validator.hh"
-#include "use_flag_name_error.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 (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);
-}
-
diff --git a/paludis/use_flag_name_validator.hh b/paludis/use_flag_name_validator.hh
deleted file mode 100644
index 399754c..0000000
--- a/paludis/use_flag_name_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_USE_FLAG_NAME_VALIDATOR_HH
-#define PALUDIS_GUARD_PALUDIS_USE_FLAG_NAME_VALIDATOR_HH 1
-
-#include <paludis/instantiation_policy.hh>
-#include <string>
-
-/** \file
- * Declarations for the UseFlagNameValidator class.
- *
- * \ingroup Database
- */
-
-namespace paludis
-{
- /**
- * 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 &);
- };
-}
-
-#endif