aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-22 19:21:39 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2009-01-22 19:21:39 +0000
commitb5cbb94798ae28dc1a8277927be4549703214fc4 (patch)
treed6c41dce6ef5aeab8ea75a938f3e8868e4bb0887
parentd5aa27d7859537369060a1c042fdb478bfc3d2df (diff)
downloadpaludis-b5cbb94798ae28dc1a8277927be4549703214fc4.tar.gz
paludis-b5cbb94798ae28dc1a8277927be4549703214fc4.tar.xz
More type-safe way of checking PDS bits.
-rw-r--r--paludis/dep_list.cc66
-rw-r--r--paludis/files.m41
-rw-r--r--paludis/generator.cc19
-rw-r--r--paludis/install_task.cc26
-rw-r--r--paludis/package_dep_spec_properties-fwd.hh47
-rw-r--r--paludis/package_dep_spec_properties.cc59
-rw-r--r--paludis/package_dep_spec_properties.hh68
-rw-r--r--paludis/range_rewriter.cc26
-rw-r--r--paludis/util/named_value-fwd.hh8
-rw-r--r--paludis/util/named_value.hh10
-rw-r--r--paludis/util/tribool-fwd.hh4
-rw-r--r--paludis/util/tribool.cc4
-rw-r--r--paludis/util/tribool.hh4
-rw-r--r--src/output/console_query_task.cc54
14 files changed, 330 insertions, 66 deletions
diff --git a/paludis/dep_list.cc b/paludis/dep_list.cc
index dda724b..3197673 100644
--- a/paludis/dep_list.cc
+++ b/paludis/dep_list.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, 2009 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
@@ -38,6 +38,7 @@
#include <paludis/filter.hh>
#include <paludis/filtered_generator.hh>
#include <paludis/choice.hh>
+#include <paludis/package_dep_spec_properties.hh>
#include <paludis/util/join.hh>
#include <paludis/util/log.hh>
@@ -864,13 +865,20 @@ DepList::AddVisitor::visit(const DependencySpecTree::NodeType<BlockDepSpec>::Typ
/* ignore if it's a virtual/blah (not <virtual/blah-1) block and it's blocking
* ourself */
- if (! (node.spec()->blocked_spec()->version_requirements_ptr() || node.spec()->blocked_spec()->slot_requirement_ptr()
- || node.spec()->blocked_spec()->additional_requirements_ptr()
- || node.spec()->blocked_spec()->from_repository_ptr()
- || node.spec()->blocked_spec()->in_repository_ptr()
- || node.spec()->blocked_spec()->installed_at_path_ptr()
- || node.spec()->blocked_spec()->installable_to_repository_ptr()
- || node.spec()->blocked_spec()->installable_to_path_ptr())
+ if (package_dep_spec_has_properties(*node.spec()->blocked_spec(), make_named_values<PackageDepSpecProperties>(
+ value_for<n::has_additional_requirements>(false),
+ value_for<n::has_category_name_part>(indeterminate),
+ value_for<n::has_from_repository>(false),
+ value_for<n::has_in_repository>(false),
+ value_for<n::has_installable_to_path>(false),
+ value_for<n::has_installable_to_repository>(false),
+ value_for<n::has_installed_at_path>(false),
+ value_for<n::has_package>(indeterminate),
+ value_for<n::has_package_name_part>(indeterminate),
+ value_for<n::has_slot_requirement>(false),
+ value_for<n::has_tag>(indeterminate),
+ value_for<n::has_version_requirements>(false)
+ ))
&& d->_imp->current_package_id())
{
if ((*aa)->name() == d->_imp->current_package_id()->name())
@@ -909,13 +917,20 @@ DepList::AddVisitor::visit(const DependencySpecTree::NodeType<BlockDepSpec>::Typ
/* ignore if it's a virtual/blah (not <virtual/blah-1) block and it's blocking
* ourself */
- if (! (node.spec()->blocked_spec()->version_requirements_ptr() || node.spec()->blocked_spec()->slot_requirement_ptr()
- || node.spec()->blocked_spec()->additional_requirements_ptr()
- || node.spec()->blocked_spec()->in_repository_ptr()
- || node.spec()->blocked_spec()->from_repository_ptr()
- || node.spec()->blocked_spec()->installed_at_path_ptr()
- || node.spec()->blocked_spec()->installable_to_repository_ptr()
- || node.spec()->blocked_spec()->installable_to_path_ptr())
+ if (package_dep_spec_has_properties(*node.spec()->blocked_spec(), make_named_values<PackageDepSpecProperties>(
+ value_for<n::has_additional_requirements>(false),
+ value_for<n::has_category_name_part>(indeterminate),
+ value_for<n::has_from_repository>(false),
+ value_for<n::has_in_repository>(false),
+ value_for<n::has_installable_to_path>(false),
+ value_for<n::has_installable_to_repository>(false),
+ value_for<n::has_installed_at_path>(false),
+ value_for<n::has_package>(indeterminate),
+ value_for<n::has_package_name_part>(indeterminate),
+ value_for<n::has_slot_requirement>(false),
+ value_for<n::has_tag>(indeterminate),
+ value_for<n::has_version_requirements>(false)
+ ))
&& d->_imp->current_package_id())
{
if ((*r)->package_id()->name() == d->_imp->current_package_id()->name())
@@ -939,13 +954,20 @@ DepList::AddVisitor::visit(const DependencySpecTree::NodeType<BlockDepSpec>::Typ
/* ignore if it's a virtual/blah (not <virtual/blah-1) block and it's blocking
* ourself */
- if (! (node.spec()->blocked_spec()->version_requirements_ptr() || node.spec()->blocked_spec()->slot_requirement_ptr()
- || node.spec()->blocked_spec()->additional_requirements_ptr()
- || node.spec()->blocked_spec()->in_repository_ptr()
- || node.spec()->blocked_spec()->from_repository_ptr()
- || node.spec()->blocked_spec()->installed_at_path_ptr()
- || node.spec()->blocked_spec()->installable_to_repository_ptr()
- || node.spec()->blocked_spec()->installable_to_path_ptr())
+ if (package_dep_spec_has_properties(*node.spec()->blocked_spec(), make_named_values<PackageDepSpecProperties>(
+ value_for<n::has_additional_requirements>(false),
+ value_for<n::has_category_name_part>(indeterminate),
+ value_for<n::has_from_repository>(false),
+ value_for<n::has_in_repository>(false),
+ value_for<n::has_installable_to_path>(false),
+ value_for<n::has_installable_to_repository>(false),
+ value_for<n::has_installed_at_path>(false),
+ value_for<n::has_package>(indeterminate),
+ value_for<n::has_package_name_part>(indeterminate),
+ value_for<n::has_slot_requirement>(false),
+ value_for<n::has_tag>(indeterminate),
+ value_for<n::has_version_requirements>(false)
+ ))
&& d->_imp->current_package_id())
{
if (r->package_id()->name() == d->_imp->current_package_id()->name())
diff --git a/paludis/files.m4 b/paludis/files.m4
index 04888a1..883d92d 100644
--- a/paludis/files.m4
+++ b/paludis/files.m4
@@ -55,6 +55,7 @@ add(`ndbam_merger', `hh', `cc')
add(`ndbam_unmerger', `hh', `cc')
add(`override_functions', `hh', `cc')
add(`package_database', `hh', `cc', `fwd', `test')
+add(`package_dep_spec_properties', `hh', `cc', `fwd')
add(`package_id', `hh', `cc', `fwd', `se')
add(`paludis', `hh')
add(`qa', `hh', `cc', `fwd', `se')
diff --git a/paludis/generator.cc b/paludis/generator.cc
index 3fd0c5e..da133ad 100644
--- a/paludis/generator.cc
+++ b/paludis/generator.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 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
@@ -30,6 +30,8 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/wrapped_output_iterator.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/package_dep_spec_properties.hh>
#include <paludis/environment.hh>
#include <paludis/package_database.hh>
#include <paludis/package_id.hh>
@@ -288,7 +290,20 @@ namespace
virtual std::tr1::shared_ptr<const RepositoryNameSet> repositories(
const Environment * const env) const
{
- if ((! spec.in_repository_ptr()) && (! spec.installed_at_path_ptr()))
+ if (package_dep_spec_has_properties(spec, make_named_values<PackageDepSpecProperties>(
+ value_for<n::has_additional_requirements>(indeterminate),
+ value_for<n::has_category_name_part>(indeterminate),
+ value_for<n::has_from_repository>(indeterminate),
+ value_for<n::has_in_repository>(false),
+ value_for<n::has_installable_to_path>(indeterminate),
+ value_for<n::has_installable_to_repository>(indeterminate),
+ value_for<n::has_installed_at_path>(false),
+ value_for<n::has_package>(indeterminate),
+ value_for<n::has_package_name_part>(indeterminate),
+ value_for<n::has_slot_requirement>(indeterminate),
+ value_for<n::has_tag>(indeterminate),
+ value_for<n::has_version_requirements>(indeterminate)
+ )))
return AllGeneratorHandlerBase::repositories(env);
std::tr1::shared_ptr<RepositoryNameSet> result(new RepositoryNameSet);
diff --git a/paludis/install_task.cc b/paludis/install_task.cc
index ccf4771..6cb0177 100644
--- a/paludis/install_task.cc
+++ b/paludis/install_task.cc
@@ -35,6 +35,7 @@
#include <paludis/filter.hh>
#include <paludis/generator.hh>
#include <paludis/filtered_generator.hh>
+#include <paludis/package_dep_spec_properties.hh>
#include <paludis/util/tokeniser.hh>
#include <paludis/util/set.hh>
#include <paludis/util/log.hh>
@@ -1313,16 +1314,25 @@ namespace
void visit(const SetSpecTree::NodeType<PackageDepSpec>::Type & node)
{
- if (node.spec()->slot_requirement_ptr())
- task->on_update_world_skip(*node.spec(), "slot restrictions");
- else if (node.spec()->version_requirements_ptr() && ! node.spec()->version_requirements_ptr()->empty())
- task->on_update_world_skip(*node.spec(), "version restrictions");
- else
+ if (package_dep_spec_has_properties(*node.spec(), make_named_values<PackageDepSpecProperties>(
+ value_for<n::has_additional_requirements>(false),
+ value_for<n::has_category_name_part>(false),
+ value_for<n::has_from_repository>(false),
+ value_for<n::has_in_repository>(false),
+ value_for<n::has_installable_to_path>(false),
+ value_for<n::has_installable_to_repository>(false),
+ value_for<n::has_installed_at_path>(false),
+ value_for<n::has_package>(true),
+ value_for<n::has_package_name_part>(false),
+ value_for<n::has_slot_requirement>(false),
+ value_for<n::has_tag>(indeterminate),
+ value_for<n::has_version_requirements>(false)
+ )))
{
- if (node.spec()->package_ptr())
- env->add_to_world(*node.spec()->package_ptr());
- task->on_update_world(*node.spec());
+ env->add_to_world(*node.spec()->package_ptr());
}
+ else
+ task->on_update_world_skip(*node.spec(), "not a simple cat/pkg");
}
void visit(const SetSpecTree::NodeType<NamedSetDepSpec>::Type &)
diff --git a/paludis/package_dep_spec_properties-fwd.hh b/paludis/package_dep_spec_properties-fwd.hh
new file mode 100644
index 0000000..a0e9b97
--- /dev/null
+++ b/paludis/package_dep_spec_properties-fwd.hh
@@ -0,0 +1,47 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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_PACKAGE_DEP_SPEC_PROPERTIES_FWD_HH
+#define PALUDIS_GUARD_PALUDIS_PACKAGE_DEP_SPEC_PROPERTIES_FWD_HH 1
+
+#include <paludis/dep_spec-fwd.hh>
+#include <paludis/util/attributes.hh>
+
+namespace paludis
+{
+ struct PackageDepSpecProperties;
+
+ /**
+ * Does a PackageDepSpec match the specified property requirements?
+ *
+ * We have a lot of code that wants to know things like "does this spec
+ * consist exactly of a cat/pkg:slot?" and "does this spec have anything
+ * other than a cat, pkg or slot?". All of these places need to be updated
+ * every time a new PackageDepSpec attribute comes along. Using this
+ * function makes sure the compiler catches any properties we haven't
+ * updated.
+ *
+ * \ingroup g_dep_spec
+ * \since 0.34.1
+ */
+ bool package_dep_spec_has_properties(const PackageDepSpec &, const PackageDepSpecProperties &)
+ PALUDIS_VISIBLE PALUDIS_ATTRIBUTE((warn_unused_result));
+}
+
+#endif
diff --git a/paludis/package_dep_spec_properties.cc b/paludis/package_dep_spec_properties.cc
new file mode 100644
index 0000000..1393227
--- /dev/null
+++ b/paludis/package_dep_spec_properties.cc
@@ -0,0 +1,59 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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/package_dep_spec_properties.hh>
+#include <paludis/dep_spec.hh>
+#include <paludis/util/sequence.hh>
+
+using namespace paludis;
+
+namespace
+{
+ inline bool check(const bool c, const Tribool w)
+ {
+ if (w.is_true())
+ return c;
+ else if (w.is_false())
+ return ! c;
+ else
+ return true;
+ }
+}
+
+bool
+paludis::package_dep_spec_has_properties(const PackageDepSpec & spec, const PackageDepSpecProperties & properties)
+{
+ bool result(true);
+
+ result = result && check(spec.additional_requirements_ptr() && ! spec.additional_requirements_ptr()->empty(), properties.has_additional_requirements());
+ result = result && check(spec.category_name_part_ptr(), properties.has_category_name_part());
+ result = result && check(spec.from_repository_ptr(), properties.has_from_repository());
+ result = result && check(spec.in_repository_ptr(), properties.has_in_repository());
+ result = result && check(spec.installable_to_path_ptr(), properties.has_installable_to_path());
+ result = result && check(spec.installable_to_repository_ptr(), properties.has_installable_to_repository());
+ result = result && check(spec.installed_at_path_ptr(), properties.has_installed_at_path());
+ result = result && check(spec.package_ptr(), properties.has_package());
+ result = result && check(spec.package_name_part_ptr(), properties.has_package_name_part());
+ result = result && check(spec.slot_requirement_ptr(), properties.has_slot_requirement());
+ result = result && check(spec.tag(), properties.has_tag());
+ result = result && check(spec.version_requirements_ptr() && ! spec.version_requirements_ptr()->empty(), properties.has_version_requirements());
+
+ return result;
+}
+
diff --git a/paludis/package_dep_spec_properties.hh b/paludis/package_dep_spec_properties.hh
new file mode 100644
index 0000000..b5cabf5
--- /dev/null
+++ b/paludis/package_dep_spec_properties.hh
@@ -0,0 +1,68 @@
+/* vim: set sw=4 sts=4 et foldmethod=syntax : */
+
+/*
+ * Copyright (c) 2009 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_PACKAGE_DEP_SPEC_PROPERTIES_HH
+#define PALUDIS_GUARD_PALUDIS_PACKAGE_DEP_SPEC_PROPERTIES_HH 1
+
+#include <paludis/package_dep_spec_properties-fwd.hh>
+#include <paludis/util/named_value.hh>
+#include <paludis/util/tribool.hh>
+
+namespace paludis
+{
+ namespace n
+ {
+ struct has_additional_requirements;
+ struct has_category_name_part;
+ struct has_from_repository;
+ struct has_in_repository;
+ struct has_installable_to_path;
+ struct has_installable_to_repository;
+ struct has_installed_at_path;
+ struct has_package;
+ struct has_package_name_part;
+ struct has_slot_requirement;
+ struct has_tag;
+ struct has_version_requirements;
+ }
+
+ /**
+ * Parameters for package_dep_spec_has_properties.
+ *
+ * \since 0.34.1
+ * \ingroup g_dep_spec
+ */
+ struct PackageDepSpecProperties
+ {
+ NamedValue<n::has_additional_requirements, Tribool> has_additional_requirements;
+ NamedValue<n::has_category_name_part, Tribool> has_category_name_part;
+ NamedValue<n::has_from_repository, Tribool> has_from_repository;
+ NamedValue<n::has_in_repository, Tribool> has_in_repository;
+ NamedValue<n::has_installable_to_path, Tribool> has_installable_to_path;
+ NamedValue<n::has_installable_to_repository, Tribool> has_installable_to_repository;
+ NamedValue<n::has_installed_at_path, Tribool> has_installed_at_path;
+ NamedValue<n::has_package, Tribool> has_package;
+ NamedValue<n::has_package_name_part, Tribool> has_package_name_part;
+ NamedValue<n::has_slot_requirement, Tribool> has_slot_requirement;
+ NamedValue<n::has_tag, Tribool> has_tag;
+ NamedValue<n::has_version_requirements, Tribool> has_version_requirements;
+ };
+}
+
+#endif
diff --git a/paludis/range_rewriter.cc b/paludis/range_rewriter.cc
index df0065e..f3f54b4 100644
--- a/paludis/range_rewriter.cc
+++ b/paludis/range_rewriter.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2007, 2008 Ciaran McCreesh
+ * Copyright (c) 2007, 2008, 2009 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,6 +20,8 @@
#include <paludis/range_rewriter.hh>
#include <paludis/util/sequence.hh>
#include <paludis/version_requirements.hh>
+#include <paludis/package_dep_spec_properties.hh>
+#include <paludis/util/make_named_values.hh>
#include <paludis/util/stringify.hh>
#include <paludis/util/join.hh>
#include <paludis/util/make_shared_ptr.hh>
@@ -239,14 +241,20 @@ RangeRewriter::visit(const DependencySpecTree::NodeType<PackageDepSpec>::Type &
return;
const PackageDepSpec & a(*node.spec());
- if (a.additional_requirements_ptr() || a.slot_requirement_ptr() || a.package_name_part_ptr()
- || a.category_name_part_ptr() || ! a.version_requirements_ptr() || ! a.package_ptr()
- || a.in_repository_ptr()
- || a.from_repository_ptr()
- || a.installable_to_repository_ptr()
- || a.installable_to_path_ptr()
- || a.installed_at_path_ptr()
- )
+ if (! package_dep_spec_has_properties(a, make_named_values<PackageDepSpecProperties>(
+ value_for<n::has_additional_requirements>(false),
+ value_for<n::has_category_name_part>(false),
+ value_for<n::has_from_repository>(false),
+ value_for<n::has_in_repository>(false),
+ value_for<n::has_installable_to_path>(false),
+ value_for<n::has_installable_to_repository>(false),
+ value_for<n::has_installed_at_path>(false),
+ value_for<n::has_package>(true),
+ value_for<n::has_package_name_part>(false),
+ value_for<n::has_slot_requirement>(false),
+ value_for<n::has_tag>(indeterminate),
+ value_for<n::has_version_requirements>(true)
+ )))
{
_imp->invalid = true;
return;
diff --git a/paludis/util/named_value-fwd.hh b/paludis/util/named_value-fwd.hh
index 922fa11..f0cc90d 100644
--- a/paludis/util/named_value-fwd.hh
+++ b/paludis/util/named_value-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 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,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_UTIL_NAMED_VALUE_FWD_HH 1
#include <string>
+#include <paludis/util/tribool-fwd.hh>
namespace paludis
{
@@ -35,6 +36,11 @@ namespace paludis
template <typename K_>
NamedValue<K_, std::string>
value_for(const char * const v);
+
+ /* Hack: let indeterminate work for Tribools, but ban other magic conversions */
+ template <typename K_>
+ NamedValue<K_, Tribool>
+ value_for(TriboolIndeterminateValueType);
}
#endif
diff --git a/paludis/util/named_value.hh b/paludis/util/named_value.hh
index 11ac56e..dede3fe 100644
--- a/paludis/util/named_value.hh
+++ b/paludis/util/named_value.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 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,6 +21,7 @@
#define PALUDIS_GUARD_PALUDIS_UTIL_NAMED_VALUE_HH 1
#include <paludis/util/named_value-fwd.hh>
+#include <paludis/util/tribool.hh>
namespace paludis
{
@@ -92,6 +93,13 @@ namespace paludis
{
return NamedValue<K_, std::string>(v);
}
+
+ template <typename K_>
+ NamedValue<K_, Tribool>
+ value_for(TriboolIndeterminateValueType v)
+ {
+ return NamedValue<K_, Tribool>(v);
+ }
}
#endif
diff --git a/paludis/util/tribool-fwd.hh b/paludis/util/tribool-fwd.hh
index 9ac6b31..b536c90 100644
--- a/paludis/util/tribool-fwd.hh
+++ b/paludis/util/tribool-fwd.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 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,8 @@ namespace paludis
{
struct Tribool;
+ typedef NoType<0u> * (* TriboolIndeterminateValueType) (const NoType<0u> * const);
+
NoType<0u> * indeterminate(const NoType<0u> * const) PALUDIS_VISIBLE;
}
diff --git a/paludis/util/tribool.cc b/paludis/util/tribool.cc
index da16dfd..9b639c6 100644
--- a/paludis/util/tribool.cc
+++ b/paludis/util/tribool.cc
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 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
@@ -31,7 +31,7 @@ Tribool::Tribool(const bool b) :
{
}
-Tribool::Tribool(NoType<0u> * (*) (const NoType<0u> * const)) :
+Tribool::Tribool(TriboolIndeterminateValueType) :
_value(v_indeterminate)
{
}
diff --git a/paludis/util/tribool.hh b/paludis/util/tribool.hh
index a878155..f6ffc42 100644
--- a/paludis/util/tribool.hh
+++ b/paludis/util/tribool.hh
@@ -1,7 +1,7 @@
/* vim: set sw=4 sts=4 et foldmethod=syntax : */
/*
- * Copyright (c) 2008 Ciaran McCreesh
+ * Copyright (c) 2008, 2009 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,7 +39,7 @@ namespace paludis
public:
Tribool();
Tribool(const bool);
- Tribool(NoType<0u> * (*) (const NoType<0u> * const));
+ Tribool(TriboolIndeterminateValueType);
bool is_true() const PALUDIS_ATTRIBUTE((warn_unused_result));
bool is_false() const PALUDIS_ATTRIBUTE((warn_unused_result));
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index d602e1c..5e326fd 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -29,6 +29,8 @@
#include <paludis/util/strip.hh>
#include <paludis/util/sequence.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/make_named_values.hh>
+#include <paludis/package_dep_spec_properties.hh>
#include <paludis/mask.hh>
#include <paludis/metadata_key.hh>
#include <paludis/package_database.hh>
@@ -135,34 +137,50 @@ ConsoleQueryTask::show_one(const PackageDepSpec & a, const std::tr1::shared_ptr<
void
ConsoleQueryTask::display_header(const PackageDepSpec & a, const std::tr1::shared_ptr<const PackageID> & e) const
{
- if (a.version_requirements_ptr() || a.slot_requirement_ptr() || a.additional_requirements_ptr() ||
- a.in_repository_ptr() ||
- a.from_repository_ptr() ||
- a.installable_to_repository_ptr() ||
- a.installable_to_path_ptr() ||
- a.installed_at_path_ptr())
- output_starred_item(render_as_package_name(stringify(a)));
- else
+ if (package_dep_spec_has_properties(a, make_named_values<PackageDepSpecProperties>(
+ value_for<n::has_additional_requirements>(false),
+ value_for<n::has_category_name_part>(false),
+ value_for<n::has_from_repository>(false),
+ value_for<n::has_in_repository>(false),
+ value_for<n::has_installable_to_path>(false),
+ value_for<n::has_installable_to_repository>(false),
+ value_for<n::has_installed_at_path>(false),
+ value_for<n::has_package>(true),
+ value_for<n::has_package_name_part>(false),
+ value_for<n::has_slot_requirement>(false),
+ value_for<n::has_tag>(indeterminate),
+ value_for<n::has_version_requirements>(false)
+ )))
output_starred_item(render_as_package_name(stringify(e->name())));
+ else
+ output_starred_item(render_as_package_name(stringify(a)));
}
void
ConsoleQueryTask::display_compact(const PackageDepSpec & a, const std::tr1::shared_ptr<const PackageID> & e) const
{
- if (a.version_requirements_ptr() || a.slot_requirement_ptr() || a.additional_requirements_ptr() ||
- a.in_repository_ptr() ||
- a.from_repository_ptr() ||
- a.installable_to_repository_ptr() ||
- a.installable_to_path_ptr() ||
- a.installed_at_path_ptr())
+ if (package_dep_spec_has_properties(a, make_named_values<PackageDepSpecProperties>(
+ value_for<n::has_additional_requirements>(false),
+ value_for<n::has_category_name_part>(false),
+ value_for<n::has_from_repository>(false),
+ value_for<n::has_in_repository>(false),
+ value_for<n::has_installable_to_path>(false),
+ value_for<n::has_installable_to_repository>(false),
+ value_for<n::has_installed_at_path>(false),
+ value_for<n::has_package>(true),
+ value_for<n::has_package_name_part>(false),
+ value_for<n::has_slot_requirement>(false),
+ value_for<n::has_tag>(indeterminate),
+ value_for<n::has_version_requirements>(false)
+ )))
{
- std::string pad(std::max<long>(1, 30 - stringify(a).length()), ' ');
- output_starred_item_no_endl(render_as_package_name(stringify(a)) + pad);
+ std::string pad(std::max<long>(1, 30 - stringify(e->name()).length()), ' ');
+ output_starred_item_no_endl(render_as_package_name(stringify(e->name())) + pad);
}
else
{
- std::string pad(std::max<long>(1, 30 - stringify(e->name()).length()), ' ');
- output_starred_item_no_endl(render_as_package_name(stringify(e->name())) + pad);
+ std::string pad(std::max<long>(1, 30 - stringify(a).length()), ' ');
+ output_starred_item_no_endl(render_as_package_name(stringify(a)) + pad);
}
if (e->short_description_key())