Imported Upstream version 16.3.2
[platform/upstream/libzypp.git] / zypp / ResolverNamespace.h
1 /*---------------------------------------------------------------------\
2 |                          ____ _   __ __ ___                          |
3 |                         |__  / \ / / . \ . \                         |
4 |                           / / \ V /|  _/  _/                         |
5 |                          / /__ | | | | | |                           |
6 |                         /_____||_| |_| |_|                           |
7 |                                                                      |
8 \---------------------------------------------------------------------*/
9 /** \file       zypp/ResolverNamespace.h
10  */
11 #ifndef ZYPP_RESOLVERNAMESPACE_H
12 #define ZYPP_RESOLVERNAMESPACE_H
13
14 #include <iosfwd>
15 #include <cstdint>
16
17 #include "zypp/base/Flags.h"
18 #include "zypp/IdString.h"
19
20 ///////////////////////////////////////////////////////////////////
21 namespace zypp
22 {
23   /** The resolvers dependency namespaces */
24   enum class ResolverNamespace : std::uint8_t
25   {
26     language    = 1<<0, ///< language support
27     modalias    = 1<<1, ///< hardware support
28     filesystem  = 1<<2, ///< filesystems
29   };
30
31   /** \relates ResolverNamespace Flags */
32   ZYPP_DECLARE_FLAGS_AND_OPERATORS(ResolverNamespaces,ResolverNamespace);
33
34   /** \relates ResolverNamespace The underlying libsolv ID */
35   inline constexpr IdString asIdString( ResolverNamespace obj )
36   {
37     return IdString( obj == ResolverNamespace::language ? sat::detail::namespaceLanguage
38                    : obj == ResolverNamespace::modalias ? sat::detail::namespaceModalias
39                    : obj == ResolverNamespace::filesystem ? sat::detail::namespaceFilesystem
40                    : sat::detail::noId );
41   }
42
43   /** \relates ResolverNamespace String representation */
44   inline std::string asString( ResolverNamespace obj )
45   { return asIdString( obj ).asString(); }
46
47   /** \relates ResolverNamespace Stream output */
48   inline std::ostream & operator<<( std::ostream & str, ResolverNamespace obj )
49   { return str << asIdString( obj ); }
50
51   /** \relates ResolverNamespaces Stream output */
52   inline std::ostream & operator<<( std::ostream & str, ResolverNamespaces obj )
53   {
54     return str << stringify( obj, {
55       { ResolverNamespace::language,    "language" },
56       { ResolverNamespace::modalias,    "modalias" },
57       { ResolverNamespace::filesystem,  "filesystem" },
58     }, "namespace:", "|", "" );
59   }
60
61 } // namespace zypp
62 ///////////////////////////////////////////////////////////////////
63 #endif // ZYPP_RESOLVERNAMESPACE_H