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

libzypp 17.38.11

lookupattr.cc
Go to the documentation of this file.
1/*---------------------------------------------------------------------\
2| ____ _ __ __ ___ |
3| |__ / \ / / . \ . \ |
4| / / \ V /| _/ _/ |
5| / /__ | | | | | | |
6| /_____||_| |_| |_| |
7| |
8----------------------------------------------------------------------*/
9#include "lookupattr.h"
10#include <iostream>
11
12#include <zypp/ng/sat/repository.h>
13#include <zypp/ng/sat/solvable.h>
14#include <zypp/ng/idstring.h>
15
16#include <zypp/ng/log/sat/repository.h>
17#include <zypp/ng/log/sat/solvable.h>
18
19extern "C"
20{
21#include <solv/pool.h>
22}
23
24namespace zyppng::log {
25
26 std::ostream &formatter<sat::LookupAttr>::stream(std::ostream &str, const sat::LookupAttr &obj)
27 {
28 if ( obj.attr() == sat::SolvAttr::noAttr )
29 return str << "search nothing";
30
31 if ( obj.attr() )
32 str << "search " << obj.attr() << " in ";
33 else
34 str << "search ALL in ";
35
36 if ( obj.solvable() )
37 return str << obj.solvable();
38 if ( obj.repo() )
39 return str << obj.repo();
40 return str << "pool";
41 }
42
43#if 0
44 std::ostream & dumpOn( std::ostream & str, const sat::LookupAttr & obj )
45 {
46 return zypp::dumpRange( str << obj, obj.begin(), obj.end() );
47 }
48#endif
49
50 std::ostream &formatter<sat::detail::DIWrap>::stream(std::ostream &str, const sat::detail::DIWrap &obj)
51 { return str << obj.get(); }
52
53
54 std::ostream &formatter<sat::LookupAttr::iterator>::stream(std::ostream &str, const sat::LookupAttr::iterator &obj)
55 {
56 const sat::detail::CDataiterator * dip = obj.get();
57 if ( ! dip )
58 return str << "EndOfQuery";
59
60 const auto val = *obj; // cheap two-pointer proxy — valid while iterator is not advanced
61 if ( val.inSolvable() )
62 str << val.inSolvable();
63 else if ( val.inRepo() )
64 str << val.inRepo();
65
66 str << '<' << val.inSolvAttr() << (val.solvAttrSubEntry() ? ">(*" : ">(")
67 << IdString(val.solvAttrType()) << ") = " << val.asString();
68 return str;
69 }
70
71 std::ostream &formatter<sat::detail::CDataiterator *>::stream(std::ostream &str, const sat::detail::CDataiterator *obj)
72 {
73 str << "detail::CDataiterator(";
74 if ( ! obj )
75 {
76 str << "NULL";
77 }
78 else
79 {
80 str << "|" << sat::Repository(obj->repo);
81 str << "|" << sat::Solvable(obj->solvid);
82 str << "|" << IdString(obj->key->name);
83 str << "|" << IdString(obj->key->type);
84 str << "|" << obj->repodataid;
85 str << "|" << obj->repoid;
86 }
87 return str << ")";
88 }
89
90}
zypp::IdString::asString
std::string asString() const
Conversion to std::string.
Definition IdString.h:110
zyppng::sat::LookupAttr::iterator
Result iterator.
Definition lookupattr.h:350
zyppng::sat::LookupAttr::iterator::get
detail::CDataiterator * get() const
Expert backdoor.
Definition lookupattr.h:422
zyppng::sat::LookupAttr
Lightweight attribute value lookup.
Definition lookupattr.h:114
zyppng::sat::LookupAttr::end
iterator end() const
Iterator behind the end of query results.
Definition lookupattr.cc:243
zyppng::sat::LookupAttr::begin
iterator begin() const
Iterator to the begin of query results.
Definition lookupattr.cc:240
zyppng::sat::LookupAttr::attr
SolvAttr attr() const
The SolvAttr to search.
Definition lookupattr.cc:204
zyppng::sat::LookupAttr::solvable
Solvable solvable() const
Whether to search in one Solvable.
Definition lookupattr.cc:228
zyppng::sat::LookupAttr::repo
Repository repo() const
Whether to search in one Repository.
Definition lookupattr.cc:222
zyppng::sat::Repository
Definition repository.h:51
zyppng::sat::SolvAttr::noAttr
static const SolvAttr noAttr
Value representing noAttr ("").
Definition SolvAttr.h:48
zyppng::sat::Solvable
A Solvable object within the sat Pool.
Definition solvable.h:66
zyppng::sat::detail::DIWrap
Wrapper around sat detail::CDataiterator.
Definition lookupattr.h:294
zyppng::sat::detail::DIWrap::get
detail::CDataiterator * get() const
Definition lookupattr.h:334
lookupattr.h
repository.h
solvable.h
str
String related utilities and Regular expression matching.
zypp::dumpRange
std::ostream & dumpRange(std::ostream &str, TIterator begin, TIterator end, const std::string &intro="{", const std::string &pfx="\n ", const std::string &sep="\n ", const std::string &sfx="\n", const std::string &extro="}")
Print range defined by iterators (multiline style).
Definition LogTools.h:419
zypp::dumpOn
std::ostream & dumpOn(std::ostream &str, const Capability &obj)
relates: Capability Detailed stream output
Definition Capability.cc:589
zyppng::log
Definition format.h:29
zyppng::sat::detail::CDataiterator
zypp::sat::detail::CDataiterator CDataiterator
Definition poolconstants.h:33
zyppng::IdString
zypp::IdString IdString
Definition idstring.h:16
repository.h
solvable.h
zyppng::log::formatter
Primary trait for object formatting.
Definition format.h:67
idstring.h