libzypp: zypp/ng/log/sat/capability.cc Source File

libzypp 17.38.7

capability.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------*/
9#include "capability.h"
10
11#include <iostream>
12#include <zypp-core/base/LogTools.h>
13#include <zypp-core/base/String.h>
14#include <zypp/ng/sat/capability.h>
15#include <zypp/ng/sat/capabilities.h>
16#include <zypp/ng/sat/stringpool.h>
17#include <zypp/ng/sat/cap2str.h>
18
19extern "C"
20{
21#include <solv/pool.h>
22}
23
24namespace zyppng {
25
26 namespace log {
27 std::ostream &formatter<sat::Capability>::stream(std::ostream &str, const sat::Capability &obj)
28 {
29 return str << obj.c_str();
30 }
31
32 std::ostream &formatter<sat::CapDetail>::stream(std::ostream &str, const sat::CapDetail &obj)
33 {
34 static const char archsep = '.';
35 switch ( obj.kind() )
36 {
37 case sat::CapDetail::NOCAP:
38 return str << "<NoCap>";
39 break;
40
41 case sat::CapDetail::NAMED:
42 str << obj.name();
43 if ( obj.hasArch() )
44 str << archsep << obj.arch();
45 return str;
46 break;
47
48 case sat::CapDetail::VERSIONED:
49 str << obj.name();
50 if ( obj.hasArch() )
51 str << archsep << obj.arch();
52 return str << " " << obj.op() << " " << obj.ed();
53 break;
54
55 case sat::CapDetail::EXPRESSION:
56 {
57 std::string outs;
58 auto pool = sat::StringPool::instance().getPool();
59 auto op = obj.capRel();
60 if ( obj.capRel() == sat::CapDetail::CAP_NAMESPACE ) {
61 sat::detail::cap2str( outs, pool, obj.lhs().id(), op );
62 outs += "(";
63 sat::detail::cap2str( outs, pool, obj.rhs().id(), op );
64 outs += ")";
65 }
66 else {
67 outs += "(";
68 sat::detail::cap2str( outs, pool, obj.lhs().id(), op );
69 outs += sat::detail::capRel2Str( op );
70 sat::detail::cap2str( outs, pool, obj.rhs().id(), op );
71 outs += ")";
72 }
73 return str << outs;
74 }
75 break;
76 }
77 return str << "<UnknownCap(" << obj.lhs() << " " << obj.capRel() << " " << obj.rhs() << ")>";
78 }
79
80 std::ostream &zyppng::log::formatter<sat::CapDetail::Kind>::stream(std::ostream &str, const sat::CapDetail::Kind &obj)
81 {
82 switch ( obj )
83 {
84 case sat::CapDetail::NOCAP: return str << "NoCap"; break;
85 case sat::CapDetail::NAMED: return str << "NamedCap"; break;
86 case sat::CapDetail::VERSIONED: return str << "VersionedCap"; break;
87 case sat::CapDetail::EXPRESSION: return str << "CapExpression"; break;
88 }
89 return str << "UnknownCap";
90 }
91
92 std::ostream &zyppng::log::formatter<sat::CapDetail::CapRel>::stream(std::ostream &str, const sat::CapDetail::CapRel &obj)
93 {
94 switch ( obj )
95 {
96 case sat::CapDetail::REL_NONE: return str << "NoCapRel"; break;
97 case sat::CapDetail::CAP_AND: return str << "and"; break; // &
98 case sat::CapDetail::CAP_OR: return str << "or"; break; // |
99 case sat::CapDetail::CAP_COND: return str << "if"; break;
100 case sat::CapDetail::CAP_UNLESS: return str << "unless"; break;
101 case sat::CapDetail::CAP_ELSE: return str << "else"; break;
102 case sat::CapDetail::CAP_WITH: return str << "with"; break; // +
103 case sat::CapDetail::CAP_WITHOUT: return str << "without"; break; // -
104 case sat::CapDetail::CAP_NAMESPACE: return str << "NAMESPACE"; break;
105 case sat::CapDetail::CAP_ARCH: return str << "ARCH"; break;
106 }
107 return str << "UnknownCapRel("+zypp::str::numstring(obj)+")";
108 }
109 }
110} // namespace zyppng
LogTools.h
String.h
cap2str.h
zyppng::sat::CapDetail
Helper providing more detailed information about a Capability.
Definition capability.h:339
zyppng::sat::CapDetail::Kind
Kind
Definition capability.h:342
zyppng::sat::CapDetail::NOCAP
@ NOCAP
Definition capability.h:343
zyppng::sat::CapDetail::NAMED
@ NAMED
Definition capability.h:344
zyppng::sat::CapDetail::EXPRESSION
@ EXPRESSION
Definition capability.h:346
zyppng::sat::CapDetail::VERSIONED
@ VERSIONED
Definition capability.h:345
zyppng::sat::CapDetail::ed
Edition ed() const
Definition capability.h:394
zyppng::sat::CapDetail::lhs
Capability lhs() const
Definition capability.h:399
zyppng::sat::CapDetail::name
IdString name() const
Definition capability.h:392
zyppng::sat::CapDetail::capRel
CapRel capRel() const
Definition capability.h:400
zyppng::sat::CapDetail::CapRel
CapRel
Enum values corresponding with libsolv defines.
Definition capability.h:353
zyppng::sat::CapDetail::CAP_ELSE
@ CAP_ELSE
else
Definition capability.h:360
zyppng::sat::CapDetail::CAP_OR
@ CAP_OR
or
Definition capability.h:356
zyppng::sat::CapDetail::CAP_WITH
@ CAP_WITH
with
Definition capability.h:362
zyppng::sat::CapDetail::REL_NONE
@ REL_NONE
Not an expression.
Definition capability.h:354
zyppng::sat::CapDetail::CAP_UNLESS
@ CAP_UNLESS
unless
Definition capability.h:359
zyppng::sat::CapDetail::CAP_ARCH
@ CAP_ARCH
Used internally.
Definition capability.h:366
zyppng::sat::CapDetail::CAP_NAMESPACE
@ CAP_NAMESPACE
Definition capability.h:365
zyppng::sat::CapDetail::CAP_COND
@ CAP_COND
if
Definition capability.h:358
zyppng::sat::CapDetail::CAP_WITHOUT
@ CAP_WITHOUT
without
Definition capability.h:363
zyppng::sat::CapDetail::CAP_AND
@ CAP_AND
and
Definition capability.h:355
zyppng::sat::CapDetail::rhs
Capability rhs() const
Definition capability.h:401
zyppng::sat::CapDetail::hasArch
bool hasArch() const
Definition capability.h:390
zyppng::sat::CapDetail::op
Rel op() const
Definition capability.h:393
zyppng::sat::CapDetail::arch
IdString arch() const
Definition capability.h:391
zyppng::sat::CapDetail::kind
Kind kind() const
Definition capability.h:381
zyppng::sat::Capability
A sat capability.
Definition capability.h:74
zyppng::sat::Capability::id
sat::detail::IdType id() const
Expert backdoor.
Definition capability.h:301
zyppng::sat::Capability::c_str
const char * c_str() const
Conversion to const char *.
Definition capability.cc:342
zyppng::sat::StringPool::getPool
detail::CPool * getPool() const
Explicit accessor for the raw sat-pool.
Definition stringpool.h:60
zyppng::sat::StringPool::instance
static StringPool & instance()
Access the global StringPool instance.
Definition stringpool.cc:18
capability.h
str
String related utilities and Regular expression matching.
zypp::pool
Definition ByIdent.h:24
zypp::str::numstring
std::string numstring(char n, int w=0)
Definition String.h:290
zyppng::log
Definition format.h:29
zyppng::sat::detail::capRel2Str
const char * capRel2Str(int op_r)
Convert a relation operator to its string representation.
Definition cap2str.cc:119
zyppng::sat::detail::cap2str
void cap2str(std::string &outs_r, CPool *pool_r, IdType id_r, int parop_r)
Shared logic to convert a sat ID into a human readable string.
Definition cap2str.cc:56
zyppng
Definition MediaNetworkRequestExecutor.h:16
capabilities.h
capability.h
stringpool.h
zyppng::log::formatter
Primary trait for object formatting.
Definition format.h:67