ignore
[platform/upstream/libzypp.git] / zypp / NVRA.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/NVRA.h
10  *
11 */
12 #ifndef ZYPP_NVRA_H
13 #define ZYPP_NVRA_H
14
15 #include <iosfwd>
16
17 #include "zypp/NVR.h"
18 #include "zypp/Arch.h"
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 { /////////////////////////////////////////////////////////////////
23
24   ///////////////////////////////////////////////////////////////////
25   //
26   //    CLASS NAME : NVRA
27   //
28   /**  Helper storing Name, Edition and Arch. */
29   struct NVRA : public NVR
30   {
31     /** Default ctor */
32     NVRA()
33     {}
34
35     /** Ctor */
36     explicit
37     NVRA( const std::string & name_r,
38           const Edition & edition_r = Edition(),
39           const Arch & arch_r = Arch() )
40     : NVR( name_r, edition_r )
41     , arch( arch_r )
42     {}
43
44     /** Ctor */
45     explicit
46     NVRA( const NVR & nvr_r,
47           const Arch & arch_r = Arch() )
48     : NVR( nvr_r )
49     , arch( arch_r )
50     {}
51
52     /** Ctor from Resolvable::constPtr */
53     explicit
54     NVRA( ResTraits<Resolvable>::constPtrType res_r );
55
56     /**  */
57     Arch arch;
58
59   public:
60     /** Comparison mostly for std::container */
61     static int compare( const NVRA & lhs, const NVRA & rhs )
62     {
63       int res = NVR::compare( lhs, rhs );
64       if ( res )
65         return res;
66       return lhs.arch.compare( rhs.arch );
67     }
68   };
69   ///////////////////////////////////////////////////////////////////
70
71   /** \relates NVRA Stream output */
72   std::ostream & operator<<( std::ostream & str, const NVRA & obj );
73
74   /** \relates NVRA */
75   inline bool operator==( const NVRA & lhs, const NVRA & rhs )
76   { return compareByRel( Rel::EQ, lhs, rhs ); }
77
78   /** \relates NVRA */
79   inline bool operator!=( const NVRA & lhs, const NVRA & rhs )
80   { return compareByRel( Rel::NE, lhs, rhs ); }
81
82   /** \relates NVRA Order in std::container */
83   inline bool operator<( const NVRA & lhs, const NVRA & rhs )
84   { return compareByRel( Rel::LT, lhs, rhs ); }
85
86   /////////////////////////////////////////////////////////////////
87 } // namespace zypp
88 ///////////////////////////////////////////////////////////////////
89 #endif // ZYPP_NVRA_H