19#include <zypp-core/base/UserRequestException>
20#include <zypp-core/parser/ParseException>
26#undef ZYPP_BASE_LOGGER_LOGGROUP
27#define ZYPP_BASE_LOGGER_LOGGROUP "parser::susetags"
48 pWAR(
"Hostile location:", path_r,
"=>", ret );
53 std::string sanitizeEntry(
Pathname path_r )
63 pWAR(
"Hostile location:", path_r,
"=>",
"discard data entry" );
100 bool setFileCheckSum( std::map<std::string, CheckSum> & map_r,
const std::string & value )
const
103 std::vector<std::string> words;
104 if (
str::split( value, std::back_inserter( words ) ) == 3 )
106 std::string pathstr = sanitizeEntry( words[2] );
107 if ( not pathstr.empty() )
108 map_r[std::move(pathstr)] =
CheckSum( words[0], words[1] );
156 _pimpl->repoindex().descrdir =
"suse/setup/descr";
157 _pimpl->repoindex().datadir =
"suse";
168 if (
_pimpl->hasRepoIndex() )
174 MIL <<
"[Content]" << endl;
194 const std::string & msg_r,
195 const std::string & line_r )
const
198 _pimpl->_inputname.c_str(),
212 MIL <<
"Start parsing content repoindex" << input_r << endl;
215 std::ostringstream s;
216 s <<
"Can't read bad stream: " << input_r;
224 if ( ! ticks.
toMin() )
228 for( ; line; line.
next() )
231 std::string value( *line );
234 if ( key.empty() || *key.c_str() ==
'#' )
240 std::string modifier;
241 std::string::size_type pos = key.rfind(
'.' );
242 if ( pos != std::string::npos )
244 modifier = key.substr( pos+1 );
251 else if ( key ==
"DESCRDIR" )
253 _pimpl->repoindex().descrdir = sanitize( value );
255 else if ( key ==
"DATADIR" )
257 _pimpl->repoindex().datadir = sanitize( value );
259 else if ( key ==
"KEY" )
261 if (
_pimpl->setFileCheckSum(
_pimpl->repoindex().signingKeys, value ) )
266 else if ( key ==
"META" )
268 if (
_pimpl->setFileCheckSum(
_pimpl->repoindex().metaFileChecksums, value ) )
273 else if ( key ==
"HASH" )
275 if (
_pimpl->setFileCheckSum(
_pimpl->repoindex().mediaFileChecksums, value ) )
286 if ( ! ticks.
set( input_r.
stream().tellg() ) )
293 if ( ! ticks.
toMax() )
297 MIL <<
"Done parsing " << input_r << endl;
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
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.
bool relativeDotDot() const
Test for a relative path referring to ../.
bool absolute() const
Test for an absolute path.
const std::string & asString() const
String representation.
bool empty() const
Test for an empty path.
Pathname absolutename() const
Return this path, adding a leading '/' if relative.
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.
std::string sconcat(Args &&... args)
Concat words as string.
Easy-to use interface to the ZYPP dependency resolver.
ProgressData makeProgressData(const InputStream &input_r)
relates: ProgressData Setup from InputStream.
static bool warning(const std::string &msg_r, const UserData &userData_r=UserData())
send warning text
ContentFileReader implementation.
RepoIndex_Ptr handoutRepoIndex()
bool hasRepoIndex() const
bool setFileCheckSum(std::map< std::string, CheckSum > &map_r, const std::string &value) const