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