More type-safe way of checking PDS bits.
This commit is contained in:
parent
d5aa27d785
commit
b5cbb94798
@ -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())
|
||||
|
@ -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')
|
||||
|
@ -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);
|
||||
|
@ -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 &)
|
||||
|
47
paludis/package_dep_spec_properties-fwd.hh
Normal file
47
paludis/package_dep_spec_properties-fwd.hh
Normal file
@ -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
|
59
paludis/package_dep_spec_properties.cc
Normal file
59
paludis/package_dep_spec_properties.cc
Normal file
@ -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;
|
||||
}
|
||||
|
68
paludis/package_dep_spec_properties.hh
Normal file
68
paludis/package_dep_spec_properties.hh
Normal file
@ -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
|
@ -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;
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
{
|
||||
}
|
||||
|
@ -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));
|
||||
|
@ -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,35 +137,51 @@ 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())
|
||||
{
|
||||
std::string pad(std::max<long>(1, 30 - stringify(a).length()), ' ');
|
||||
output_starred_item_no_endl(render_as_package_name(stringify(a)) + pad);
|
||||
}
|
||||
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)
|
||||
)))
|
||||
{
|
||||
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(a).length()), ' ');
|
||||
output_starred_item_no_endl(render_as_package_name(stringify(a)) + pad);
|
||||
}
|
||||
|
||||
if (e->short_description_key())
|
||||
output_no_endl(e->short_description_key()->value());
|
||||
|
Loading…
Reference in New Issue
Block a user