53 void IniParser::consume(
const std::string §ion,
const std::string &key,
const std::string &value )
69 MIL <<
"Start parsing " << input_r << endl;
78 for ( ; line; line.
next() )
82 if (trimmed.empty() || trimmed[0] ==
';' || trimmed[0] ==
'#')
85 if (trimmed[0] ==
'[')
87 std::string section = trimmed.substr(1, trimmed.find(
']')-1);
95 if (pos != std::string::npos)
97 std::string key =
str::rtrim(trimmed.substr(0, pos));
98 if(key.find_first_of(
" \t") != std::string::npos) {
102 std::string value =
str::ltrim(trimmed.substr(pos+1));
112 if ( ! ticks.
set( input_r.
stream().tellg() ) )
119 MIL <<
"Done parsing " << input_r << endl;
void parse(const InputStream &imput_r, const ProgressData::ReceiverFnc &progress=ProgressData::ReceiverFnc())
Parse the stream.
ProgressData makeProgressData(const InputStream &input_r)
void sendTo(const ReceiverFnc &fnc_r)
Set ReceiverFnc.
#define ZYPP_THROW(EXCPT)
Drops a logline and throws the Exception.
bool next()
Advance to next line.
bool toMax()
Set counter value to current max value (unless no range).
unsigned lineNo() const
Return the current line number.
Simple lineparser: Traverse each line in a file.
function< bool(const ProgressData &)> ReceiverFnc
Most simple version of progress reporting The percentage in most cases.
std::string _current_section
std::string ltrim(const std::string &s)
virtual ~IniParser()
Dtor.
virtual void beginParse()
Called when start parsing.
bool toMin()
Set counter value to current min value.
std::string trim(const std::string &s, const Trim trim_r)
Maintain [min,max] and counter (value) for progress counting.
std::string rtrim(const std::string &s)
std::string form(const char *format,...)
Printf style construction of std::string.
virtual void endParse()
Called when the parse is done.
bool set(value_type val_r)
Set new counter value.
virtual void consume(const std::string §ion)
Called when a section is found.