15#include <zypp/base/LogTools.h>
16#include <zypp/base/String.h>
17#include <zypp/base/IOStream.h>
18#include <zypp-core/base/UserRequestException>
19#include <zypp-core/parser/ParseException>
25#undef ZYPP_BASE_LOGGER_LOGGROUP
26#define ZYPP_BASE_LOGGER_LOGGROUP "parser::susetags"
68 bool setFileCheckSum( std::map<std::string, CheckSum> & map_r,
const std::string & value )
const
71 std::vector<std::string> words;
72 if (
str::split( value, std::back_inserter( words ) ) == 3 )
74 map_r[words[2]] =
CheckSum( words[0], words[1] );
122 _pimpl->repoindex().descrdir =
"suse/setup/descr";
123 _pimpl->repoindex().datadir =
"suse";
134 if (
_pimpl->hasRepoIndex() )
140 MIL <<
"[Content]" << endl;
160 const std::string & msg_r,
161 const std::string & line_r )
const
164 _pimpl->_inputname.c_str(),
178 MIL <<
"Start parsing content repoindex" << input_r << endl;
181 std::ostringstream s;
182 s <<
"Can't read bad stream: " << input_r;
190 if ( ! ticks.
toMin() )
194 for( ; line; line.
next() )
197 std::string value( *line );
200 if ( key.empty() || *key.c_str() ==
'#' )
206 std::string modifier;
207 std::string::size_type pos = key.rfind(
'.' );
208 if ( pos != std::string::npos )
210 modifier = key.substr( pos+1 );
217 else if ( key ==
"DESCRDIR" )
219 _pimpl->repoindex().descrdir = value;
221 else if ( key ==
"DATADIR" )
223 _pimpl->repoindex().datadir = value;
225 else if ( key ==
"KEY" )
227 if (
_pimpl->setFileCheckSum(
_pimpl->repoindex().signingKeys, value ) )
232 else if ( key ==
"META" )
234 if (
_pimpl->setFileCheckSum(
_pimpl->repoindex().metaFileChecksums, value ) )
239 else if ( key ==
"HASH" )
241 if (
_pimpl->setFileCheckSum(
_pimpl->repoindex().mediaFileChecksums, value ) )
252 if ( ! ticks.
set( input_r.
stream().tellg() ) )
259 if ( ! ticks.
toMax() )
263 MIL <<
"Done parsing " << input_r << endl;
Maintain [min,max] and counter (value) for progress counting.
void sendTo(const ReceiverFnc &fnc_r)
Set ReceiverFnc.
bool toMax()
Set counter value to current max value (unless no range).
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
bool toMin()
Set counter value to current min value.
bool set(value_type val_r)
Set new counter value.
Simple lineparser: Traverse each line in a file.
unsigned lineNo() const
Return the current line number.
bool next()
Advance to next line.
virtual void userRequestedAbort(unsigned lineNo_r)
Called when user(callback) request to abort.
virtual void parse(const InputStream &imput_r, const ProgressData::ReceiverFnc &fnc_r=ProgressData::ReceiverFnc())
Parse the stream.
ContentFileReader()
Default ctor.
virtual void endParse()
Called when the parse is done.
std::string errPrefix(unsigned lineNo_r, const std::string &msg_r=std::string(), const std::string &line_r="-") const
Prefix exception message with line information.
RW_pointer< Impl, rw_pointer::Scoped< Impl > > _pimpl
virtual ~ContentFileReader()
Dtor.
RepoIndexConsumer _repoIndexConsumer
virtual void beginParse()
Called when start parsing.
std::string stripFirstWord(std::string &line, const bool ltrim_first)
std::string form(const char *format,...) __attribute__((format(printf
Printf style construction of std::string.
unsigned split(const C_Str &line_r, TOutputIterator result_r, const C_Str &sepchars_r=" \t", const Trim trim_r=NO_TRIM)
Split line_r into words.
Easy-to use interface to the ZYPP dependency resolver.
ProgressData makeProgressData(const InputStream &input_r)
ContentFileReader implementation.
RepoIndex_Ptr handoutRepoIndex()
bool hasRepoIndex() const
bool setFileCheckSum(std::map< std::string, CheckSum > &map_r, const std::string &value) const
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.