aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-11 14:02:28 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-11 14:02:28 +0000
commit0d78a2182b17e84276520f354b5eb6a8e151b9bf (patch)
tree1b0d4596ea213f03dab179aed6058257ccd83530
parentcc9a5b5398a299ade3e9e83fb5f8e69413771716 (diff)
downloadpaludis-0d78a2182b17e84276520f354b5eb6a8e151b9bf.tar.gz
paludis-0d78a2182b17e84276520f354b5eb6a8e151b9bf.tar.xz
Export more information from AmbiguousPackageNameError
-rw-r--r--paludis/package_database.hh38
1 files changed, 37 insertions, 1 deletions
diff --git a/paludis/package_database.hh b/paludis/package_database.hh
index 64c2177..cd9a3f9 100644
--- a/paludis/package_database.hh
+++ b/paludis/package_database.hh
@@ -25,15 +25,20 @@
#include <paludis/repository.hh>
#include <paludis/util/counted_ptr.hh>
#include <paludis/util/exception.hh>
+#include <paludis/util/iterator.hh>
#include <paludis/util/instantiation_policy.hh>
#include <paludis/util/join.hh>
#include <paludis/util/private_implementation_pattern.hh>
+#include <paludis/util/stringify.hh>
#include <paludis/util/smart_record.hh>
#include <paludis/util/collection.hh>
#include <paludis/version_metadata.hh>
#include <paludis/version_spec.hh>
#include <ostream>
+#include <algorithm>
+#include <functional>
+#include <iterator>
namespace paludis
{
@@ -113,6 +118,10 @@ namespace paludis
*/
class AmbiguousPackageNameError : public PackageDatabaseLookupError
{
+ private:
+ const std::string & _name;
+ std::list<std::string> _names;
+
public:
/**
* Constructor.
@@ -120,14 +129,41 @@ namespace paludis
template <typename I_>
AmbiguousPackageNameError(const std::string & name,
I_ begin, const I_ end) throw ();
+
+ /**
+ * Destructor.
+ */
+ virtual ~AmbiguousPackageNameError() throw ()
+ {
+ }
+
+ const std::string & name() const
+ {
+ return _name;
+ }
+
+ typedef std::list<std::string>::const_iterator OptionsIterator;
+
+ OptionsIterator begin_options() const
+ {
+ return _names.begin();
+ }
+
+ OptionsIterator end_options() const
+ {
+ return _names.end();
+ }
};
template <typename I_>
AmbiguousPackageNameError::AmbiguousPackageNameError(const std::string & name,
I_ begin, const I_ end) throw () :
PackageDatabaseLookupError("Ambiguous package name '" + name + "' (candidates are " +
- join(begin, end, ", ") + ")")
+ join(begin, end, ", ") + ")"),
+ _name(name)
{
+ std::transform(begin, end, std::back_inserter(_names),
+ &stringify<typename std::iterator_traits<I_>::value_type>);
}
/**