libzypp
17.14.0
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
FileConflicts.cc
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
11
#include <iostream>
12
#include <string>
13
14
#include "
zypp/sat/FileConflicts.h
"
15
#include "
zypp/base/LogTools.h
"
16
#include "
zypp/base/Gettext.h
"
17
#include "
zypp/base/Xml.h
"
18
#include "
zypp/CheckSum.h
"
19
20
using
std::endl;
21
23
namespace
zypp
24
{
26
namespace
sat
27
{
28
std::string
FileConflicts::Conflict::asUserString
()
const
29
{
30
if
(
lhsFilename
() ==
rhsFilename
() )
31
{
32
static
const
char
* text[2][2] = {{
// [lhs][rhs] 0 = installed; 1 = to be installed
33
// TranslatorExplanation %1%(filename) %2%(package1) %3%(package2)
34
N_
(
"File %1%\n"
35
" from package\n"
36
" %2%\n"
37
" conflicts with file from package\n"
38
" %3%"
),
39
// TranslatorExplanation %1%(filename) %2%(package1) %3%(package2)
40
N_
(
"File %1%\n"
41
" from package\n"
42
" %2%\n"
43
" conflicts with file from install of\n"
44
" %3%"
)
45
},{
46
// TranslatorExplanation %1%(filename) %2%(package1) %3%(package2)
47
N_
(
"File %1%\n"
48
" from install of\n"
49
" %2%\n"
50
" conflicts with file from package\n"
51
" %3%"
),
52
// TranslatorExplanation %1%(filename) %2%(package1) %3%(package2)
53
N_
(
"File %1%\n"
54
" from install of\n"
55
" %2%\n"
56
" conflicts with file from install of\n"
57
" %3%"
)
58
}};
59
return
str::Format
( text[
lhsSolvable
().isSystem()?0:1][
rhsSolvable
().isSystem()?0:1] )
60
%
lhsFilename
()
61
%
lhsSolvable
().
asUserString
()
62
%
rhsSolvable
().
asUserString
();
63
}
64
else
65
{
66
static
const
char
* text[2][2] = {{
// [lhs][rhs] 0 = installed; 1 = to be installed
67
// TranslatorExplanation %1%(filename1) %2%(package1) %%3%(filename2) 4%(package2)
68
N_
(
"File %1%\n"
69
" from package\n"
70
" %2%\n"
71
" conflicts with file\n"
72
" %3%\n"
73
" from package\n"
74
" %4%"
),
75
// TranslatorExplanation %1%(filename1) %2%(package1) %3%(filename2) %4%(package2)
76
N_
(
"File %1%\n"
77
" from package\n"
78
" %2%\n"
79
" conflicts with file\n"
80
" %3%\n"
81
" from install of\n"
82
" %4%"
)
83
},{
84
// TranslatorExplanation %1%(filename1) %2%(package1) %3%(filename2) %4%(package2)
85
N_
(
"File %1%\n"
86
" from install of\n"
87
" %2%\n"
88
" conflicts with file\n"
89
" %3%\n"
90
" from package\n"
91
" %4%"
),
92
// TranslatorExplanation %1%(filename1) %2%(package1) %3%(filename2) %4%(package2)
93
N_
(
"File %1%\n"
94
" from install of\n"
95
" %2%\n"
96
" conflicts with file\n"
97
" %3%\n"
98
" from install of\n"
99
" %4%"
)
100
}};
101
return
str::Format
( text[
lhsSolvable
().isSystem()?0:1][
rhsSolvable
().isSystem()?0:1] )
102
%
lhsFilename
()
103
%
lhsSolvable
().
asUserString
()
104
%
rhsFilename
()
105
%
rhsSolvable
().
asUserString
();
106
}
107
}
108
109
std::ostream &
operator<<
( std::ostream & str,
const
FileConflicts
& obj )
110
{
return
dumpRange
( str <<
"("
<< obj.
size
() <<
") "
, obj.
begin
(), obj.
end
() ); }
111
112
std::ostream &
operator<<
( std::ostream & str,
const
FileConflicts::Conflict
& obj )
113
{
114
if
( obj.
lhsFilename
() == obj.
rhsFilename
() )
115
return
str <<
str::Format
(
"%s:\n %s[%s]\n %s[%s]"
)
116
% obj.
lhsFilename
()
117
% obj.
lhsSolvable
()
118
% obj.
lhsFilemd5
()
119
% obj.
rhsSolvable
()
120
% obj.
rhsFilemd5
();
121
122
return
str <<
str::Format
(
"%s - %s:\n %s[%s]\n %s[%s]"
)
123
% obj.
lhsFilename
()
124
% obj.
rhsFilename
()
125
% obj.
lhsSolvable
()
126
% obj.
lhsFilemd5
()
127
% obj.
rhsSolvable
()
128
% obj.
rhsFilemd5
();
129
}
130
131
132
std::ostream &
dumpAsXmlOn
( std::ostream & str,
const
FileConflicts
& obj )
133
{
134
xmlout::Node
guard( str,
"fileconflicts"
, {
"size"
, obj.
size
() } );
135
if
( ! obj.
empty
() )
136
{
137
*guard <<
"\n"
;
138
for
(
const
auto
& el : obj )
139
dumpAsXmlOn
( *guard, el ) <<
"\n"
;
140
}
141
return
str;
142
}
143
144
namespace
145
{
146
std::ostream & dumpAsXmlHelper( std::ostream & str,
const
std::string & tag_r,
IdString
filename_r,
IdString
md5sum_r, Solvable solv_r )
147
{
148
xmlout::Node
guard( str, tag_r );
149
*
xmlout::Node
( *guard,
"file"
) << filename_r;
150
dumpAsXmlOn
( *guard,
CheckSum
( md5sum_r.
asString
() ) );
151
dumpAsXmlOn
( *guard, solv_r );
152
return
str;
153
}
154
}
155
156
std::ostream &
dumpAsXmlOn
( std::ostream & str,
const
FileConflicts::Conflict
& obj )
157
{
158
xmlout::Node
guard( str,
"fileconflict"
);
159
dumpAsXmlHelper( *guard<<
"\n"
,
"lhs"
, obj.
lhsFilename
(), obj.
lhsFilemd5
(), obj.
lhsSolvable
() );
160
dumpAsXmlHelper( *guard<<
"\n"
,
"rhs"
, obj.
rhsFilename
(), obj.
rhsFilemd5
(), obj.
rhsSolvable
() );
161
return
str;
162
}
163
164
}
// namespace sat
166
}
// namespace zypp
zypp
sat
FileConflicts.cc
Generated by
1.8.2