ref: refs/heads/master
commit 22021076f9e24fcd8aa99c9102e697aca45475be
Author: Michael Andres
Date: Thu May 28 19:20:25 2009 +0200
LookupAttr::iterator: Ease retrieval of ID based types.
---
zypp/sat/LookupAttr.cc | 10 ++++++++++
zypp/sat/LookupAttr.h | 13 ++++++++++---
2 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/zypp/sat/LookupAttr.cc b/zypp/sat/LookupAttr.cc
index 8e7961d..cd8cada 100644
--- a/zypp/sat/LookupAttr.cc
+++ b/zypp/sat/LookupAttr.cc
@@ -534,6 +534,13 @@ namespace zypp
case REPOKEY_TYPE_ID:
case REPOKEY_TYPE_IDARRAY:
case REPOKEY_TYPE_CONSTANTID:
+ {
+ detail::IdType id = ::repodata_globalize_id( _dip->data, _dip->kv.id );
+ return ISRELDEP(id) ? Capability( id ).asString()
+ : IdString( id ).asString();
+ }
+ break;
+
case REPOKEY_TYPE_STR:
case REPOKEY_TYPE_DIRSTRARRAY:
{
@@ -687,6 +694,9 @@ namespace zypp
return str;
}
+ template<> CheckSum LookupAttr::iterator::asType<CheckSum>() const
+ { return asCheckSum(); }
+
/////////////////////////////////////////////////////////////////
} // namespace sat
///////////////////////////////////////////////////////////////////
diff --git a/zypp/sat/LookupAttr.h b/zypp/sat/LookupAttr.h
index c18a99e..34a3ecd 100644
--- a/zypp/sat/LookupAttr.h
+++ b/zypp/sat/LookupAttr.h
@@ -382,7 +382,7 @@ namespace zypp
/** Whether this is a string attribute. */
bool solvAttrString() const;
- /** *Whether this string attribute is available as \ref IdString. */
+ /** Whether this string attribute is available as \ref IdString. */
bool solvAttrIdString() const;
/** Whether this is a CheckSum attribute.*/
@@ -472,14 +472,20 @@ namespace zypp
* via \ref c_str and \ref asString.
*/
IdString idStr() const;
+ /** \overload Directly returning the \c Id */
+ detail::IdType id() const
+ { return idStr().id(); }
/** As \ref CheckSum. */
CheckSum asCheckSum() const;
/** Templated return type.
- * Specialized for supported types.
+ * Per default assumes an Id based type, so try to construct
+ * it from the Id.
+ *
+ * Should be specialized for supported types above.
*/
- template<class _Tp> _Tp asType() const;
+ template<class _Tp> _Tp asType() const { return _Tp(id()); }
//@}
///////////////////////////////////////////////////////////////////
@@ -539,6 +545,7 @@ namespace zypp
template<> inline const char * LookupAttr::iterator::asType() const { return c_str(); }
template<> inline std::string LookupAttr::iterator::asTypestd::string() const { return asString(); }
template<> inline IdString LookupAttr::iterator::asType<IdString>() const { return idStr(); }
+ template<> CheckSum LookupAttr::iterator::asType<CheckSum>() const;
template
class ArrayAttr;
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org