};
///////////////////////////////////////////////////////////////////
- //@{
- /** \relates Arch Builtin architecture.
- * Outside Arch, because some names, like \c i388, are used
- * as \c #define, thus unusable as identifier.
+ /** \name Builtin architecture constants.
+ *
+ * Defined outside Arch as e.g. \c Arch_i386, because some names,
+ * like \c i388, are used as \c #define, thus unusable as identifier
+ * like \c Arch::i386.
*/
+ //@{
+ /** \relates Arch */
extern const Arch Arch_noarch;
+ /** \relates Arch */
extern const Arch Arch_x86_64;
+ /** \relates Arch */
extern const Arch Arch_athlon;
+ /** \relates Arch */
extern const Arch Arch_i686;
+ /** \relates Arch */
extern const Arch Arch_i586;
+ /** \relates Arch */
extern const Arch Arch_i486;
+ /** \relates Arch */
extern const Arch Arch_i386;
+ /** \relates Arch */
extern const Arch Arch_s390x;
+ /** \relates Arch */
extern const Arch Arch_s390;
+ /** \relates Arch */
extern const Arch Arch_ppc64;
+ /** \relates Arch */
extern const Arch Arch_ppc;
+ /** \relates Arch */
extern const Arch Arch_ia64;
//@}
///////////////////////////////////////////////////////////////////
- //@{
- /** \relates Arch */
+ /** \relates Arch stream output. */
inline std::ostream & operator<<( std::ostream & str, const Arch & obj )
{ return str << obj.asString(); }
-
+ /** \name Comparison based on string value. */
+ //@{
+ /** \relates Arch */
inline bool operator==( const Arch & lhs, const Arch & rhs )
{ return lhs.asString() == rhs.asString(); }
+ /** \relates Arch */
inline bool operator==( const Arch & lhs, const std::string & rhs )
{ return lhs.asString() == rhs; }
+ /** \relates Arch */
inline bool operator==( const std::string & lhs, const Arch & rhs )
{ return lhs == rhs.asString(); }
-
+ /** \relates Arch */
inline bool operator!=( const Arch & lhs, const Arch & rhs )
{ return !( lhs == rhs ); }
+ /** \relates Arch */
inline bool operator!=( const Arch & lhs, const std::string & rhs )
{ return !( lhs == rhs ); }
+ /** \relates Arch */
inline bool operator!=( const std::string & lhs, const Arch & rhs )
{ return !( lhs == rhs ); }
-
//@}
///////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////
namespace std
{ /////////////////////////////////////////////////////////////////
- /** \relates Arch Order relation for std::container classes. */
+ /** \relates Arch Default order for std::container based on string value.*/
template<>
inline bool less<zypp::Arch>::operator()( const zypp::Arch & lhs, const zypp::Arch & rhs ) const
{ return lhs.asString() < rhs.asString(); }
Edition::~Edition()
{}
+ /** \todo Beautyfy */
+ std::string Edition::asString() const
+ { return _pimpl->_version + "-" + _pimpl->_release; }
+
Edition::epoch_t Edition::epoch() const
{ return _pimpl->_epoch; }
const std::string & Edition::release() const
{ return _pimpl->_release; }
- /******************************************************************
- **
- ** FUNCTION NAME : operator<<
- ** FUNCTION TYPE : std::ostream &
- */
- std::ostream & operator<<( std::ostream & str, const Edition & obj )
+ /** \todo implement */
+ bool Edition::compare( RelOp op, const Edition & lhs, const Edition & rhs )
{
- return str << obj.version() << '-' << obj.release();
+ return false;
}
-
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
#include <string>
#include "zypp/base/PtrTypes.h"
+
#include "zypp/RelOp.h"
///////////////////////////////////////////////////////////////////
class Edition
{
public:
- /** */
+ /** Type of an epoch. */
typedef unsigned epoch_t;
public:
- /** Default ctor */
+ /** Default ctor. */
Edition();
- /** */
+ /** Ctor taking \a version_r, \a release_r and optional \a epoch_r */
Edition( const std::string & version_r,
const std::string & release_r,
- epoch_t epoch = 0 );
+ epoch_t epoch_r = 0 );
/** Dtor */
~Edition();
/** */
const std::string & release() const;
+ /** String representation of Edition. */
+ std::string asString() const;
+
+ public:
+ /** Compare Editions by relationam operator \a op.
+ * \see RelOp.
+ */
+ static bool compare( RelOp op, const Edition & lhs, const Edition & rhs );
+
private:
/** Hides implementation */
struct Impl;
/** Pointer to implementation */
- base::shared_ptr<Impl> _pimpl;
+ base::ImplPtr<Impl> _pimpl;
};
///////////////////////////////////////////////////////////////////
- /** \relates Edition Stream output */
- extern std::ostream & operator<<( std::ostream & str, const Edition & obj );
+ /** \relates Edition Stream output. */
+ inline std::ostream & operator<<( std::ostream & str, const Edition & obj )
+ { return str << obj.asString(); }
+
+ /** \name Comaprison based on epoch, version, and release. */
+ //@{
+
+ /** \relates Edition */
+ inline bool operator==( const Edition & lhs, const Edition & rhs )
+ { return Edition::compare( EQ, lhs, rhs ); }
+
+ /** \relates Edition */
+ inline bool operator!=( const Edition & lhs, const Edition & rhs )
+ { return Edition::compare( NE, lhs, rhs );; }
+
+ /** \relates Edition */
+ inline bool operator<( const Edition & lhs, const Edition & rhs )
+ { return Edition::compare( LT, lhs, rhs ); }
+
+ /** \relates Edition */
+ inline bool operator<=( const Edition & lhs, const Edition & rhs )
+ { return Edition::compare( LE, lhs, rhs ); }
+
+ /** \relates Edition */
+ inline bool operator>( const Edition & lhs, const Edition & rhs )
+ { return Edition::compare( GT, lhs, rhs ); }
+
+ /** \relates Edition */
+ inline bool operator>=( const Edition & lhs, const Edition & rhs )
+ { return Edition::compare( GE, lhs, rhs ); }
+
+ /** \relates Edition */
+ inline int compare( const Edition & lhs, const Edition & rhs )
+ { return lhs == rhs ? 0 : ( lhs < rhs ? -1 : 1 ); }
+
+ //@}
/////////////////////////////////////////////////////////////////
} // namespace zypp
///////////////////////////////////////////////////////////////////
+
+///////////////////////////////////////////////////////////////////
+namespace std
+{ /////////////////////////////////////////////////////////////////
+ /** \relates Edition Default order for std::container based on string value.*/
+ template<>
+ inline bool less<zypp::Edition>::operator()( const zypp::Edition & lhs, const zypp::Edition & rhs ) const
+ { return lhs.asString() < rhs.asString(); }
+ /** \relates Edition Equality for std::container classes based on string value. */
+ template<>
+ inline bool equal_to<zypp::Edition>::operator()( const zypp::Edition & lhs, const zypp::Edition & rhs ) const
+ { return lhs.asString() == rhs.asString(); }
+ /////////////////////////////////////////////////////////////////
+} // namespace zypp
+///////////////////////////////////////////////////////////////////
+
#endif // ZYPP_EDITION_H
namespace zypp
{ /////////////////////////////////////////////////////////////////
+ /** Relational operators. */
enum RelOp { ANY, EQ, NE, LT, LE, GT, GE, NONE };
/////////////////////////////////////////////////////////////////
: _dptr( dptr )
{}
+ explicit
+ ImplPtr( _Ptr dptr )
+ : _dptr( dptr )
+ {}
+
_D & operator*() { return *_dptr; }
const _D & operator*() const { return *_dptr; };
_D * operator->() { return _dptr.get(); }
_D * unconst() const { return _dptr.get(); }
- private:
+
_Ptr _dptr;
};
///////////////////////////////////////////////////////////////////
_D * unconst() const { return _dptr; }
- private:
+
_P * _dptr;
};
/////////////////////////////////////////////////////////////////