libzypp
11.13.5
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
RepoFileReader.cc
Go to the documentation of this file.
1
/*---------------------------------------------------------------------\
2
| ____ _ __ __ ___ |
3
| |__ / \ / / . \ . \ |
4
| / / \ V /| _/ _/ |
5
| / /__ | | | | | | |
6
| /_____||_| |_| |_| |
7
| |
8
\---------------------------------------------------------------------*/
12
#include <iostream>
13
#include "
zypp/base/Logger.h
"
14
#include "
zypp/base/String.h
"
15
#include "
zypp/base/Regex.h
"
16
#include "
zypp/base/InputStream.h
"
17
#include "
zypp/base/UserRequestException.h
"
18
19
#include "
zypp/parser/IniDict.h
"
20
#include "
zypp/parser/RepoFileReader.h
"
21
22
using
std::endl;
23
using
zypp::parser::IniDict
;
24
26
namespace
zypp
27
{
28
29
namespace
parser
30
{
31
36
static
void
repositories_in_stream
(
const
InputStream
&is,
37
const
RepoFileReader::ProcessRepo
&callback,
38
const
ProgressData::ReceiverFnc
&progress )
39
{
40
parser::IniDict
dict(is);
41
for
(
parser::IniDict::section_const_iterator
its = dict.
sectionsBegin
();
42
its != dict.
sectionsEnd
();
43
++its )
44
{
45
RepoInfo
info;
46
info.
setAlias
(*its);
47
Url
url
;
48
49
for
(
IniDict::entry_const_iterator
it = dict.
entriesBegin
(*its);
50
it != dict.
entriesEnd
(*its);
51
++it )
52
{
53
//MIL << (*it).first << endl;
54
if
(it->first ==
"name"
)
55
info.
setName
(it-> second);
56
else
if
( it->first ==
"enabled"
)
57
info.
setEnabled
(
str::strToTrue
( it->second ) );
58
else
if
( it->first ==
"priority"
)
59
info.
setPriority
( str::strtonum<unsigned>( it->second ) );
60
else
if
( it->first ==
"baseurl"
&& !it->second.empty())
61
url = it->second;
62
else
if ( it->first ==
"path"
)
63
info.
setPath
( Pathname(it->second) );
64
else
if
( it->first ==
"type"
)
65
info.
setType
(
repo::RepoType
(it->second));
66
else
if
( it->first ==
"autorefresh"
)
67
info.
setAutorefresh
(
str::strToTrue
( it->second ) );
68
else
if
( it->first ==
"mirrorlist"
&& !it->second.empty())
69
info.
setMirrorListUrl
(
Url
(it->second));
70
else
if
( it->first ==
"gpgkey"
&& !it->second.empty())
71
{
72
std::vector<std::string> keys;
73
str::split
( it->second, std::back_inserter(keys) );
74
if
( ! keys.empty() )
75
info.
setGpgKeyUrl
(
Url
(*keys.begin()) );
76
}
77
else
if
( it->first ==
"gpgcheck"
)
78
info.
setGpgCheck
(
str::strToTrue
( it->second ) );
79
else
if
( it->first ==
"keeppackages"
)
80
info.
setKeepPackages
(
str::strToTrue
( it->second ) );
81
else
if
( it->first ==
"service"
)
82
info.
setService
( it->second );
83
else
if
( it->first ==
"proxy"
)
84
{
85
if
(it->second !=
"_none_"
)
86
{
87
str::regex
ex(
"^(.*):([0-9]+)$"
);
88
str::smatch
what;
89
if
(
str::regex_match
(it->second, what, ex)){
90
url.
setQueryParam
(
"proxy"
, what[1]);
91
url.
setQueryParam
(
"proxyport"
, what[2]);
92
}
93
}
94
}
else
95
ERR
<<
"Unknown attribute in ["
<< *its <<
"]: "
<< it->second <<
" ignored"
<< endl;
96
}
97
if
(url.
isValid
())
98
info.
addBaseUrl
(url);
99
info.
setFilepath
(is.
path
());
100
MIL
<< info << endl;
101
// add it to the list.
102
callback(info);
103
//if (!progress.tick())
104
// ZYPP_THROW(AbortRequestException());
105
}
106
}
107
109
//
110
// CLASS NAME : RepoFileReader
111
//
113
114
RepoFileReader::RepoFileReader
(
const
Pathname & repo_file,
115
const
ProcessRepo
& callback,
116
const
ProgressData::ReceiverFnc
&progress )
117
: _callback(callback)
118
{
119
repositories_in_stream
(
InputStream
(repo_file),
_callback
, progress);
120
}
121
122
RepoFileReader::RepoFileReader
(
const
InputStream
&is,
123
const
ProcessRepo
& callback,
124
const
ProgressData::ReceiverFnc
&progress )
125
: _callback(callback)
126
{
127
repositories_in_stream
(is,
_callback
, progress);
128
}
129
130
RepoFileReader::~RepoFileReader
()
131
{}
132
133
134
std::ostream &
operator<<
( std::ostream & str,
const
RepoFileReader
& obj )
135
{
136
return
str;
137
}
138
140
}
// namespace parser
143
}
// namespace zypp
zypp
parser
RepoFileReader.cc
Generated by
1.8.1