13#include <boost/mpl/assert.hpp>
14#include <boost/mpl/int.hpp>
17#include <zypp-core/base/IOStream.h>
18#include <zypp-core/base/String.h>
35 static const unsigned tmpBuffLen = 1024;
36 static char tmpBuff[tmpBuffLen];
40 str.getline( tmpBuff, tmpBuffLen );
42 }
while(
str.rdstate() == std::ios::failbit );
100 int forEachLine( std::istream & str_r, function<
bool(
int, std::string)> consume_r )
105 std::string line(
getline( str_r ) );
106 if ( ! (str_r.fail() || str_r.bad()) )
110 if ( consume_r && ! consume_r( lineno, line ) )
124 int simpleParseFile( std::istream & str_r, ParseFlags flags_r, function<
bool(
int, std::string)> consume_r )
127 [&](
int num_r, std::string line_r )->
bool
139 const char* firstNW = line_r.c_str();
140 while ( *firstNW ==
' ' || *firstNW ==
'\t' )
144 case '\0':
if ( flags_r &
PF_SKIP_EMPTY )
return true;
break;
149 return consume_r( num_r, line_r );
bool next()
Advance to next line.
EachLine(std::istream &str_r, unsigned lineNo_r=0)
Ctor taking a stream and reading the 1st line from it.
std::streamoff _lineStart
String related utilities and Regular expression matching.
BOOST_MPL_ASSERT_RELATION(int(PF_LTRIM),==, int(str::L_TRIM))
int forEachLine(std::istream &str_r, function< bool(int, std::string)> consume_r)
Simple lineparser: Call functor consume_r for each line.
int simpleParseFile(std::istream &str_r, ParseFlags flags_r, function< bool(int, std::string)> consume_r)
Simple lineparser optionally trimming and skipping comments.
std::string getline(std::istream &str)
Read one line from stream.
Trim
To define how to trim.
std::string trim(const std::string &s, const Trim trim_r)
Easy-to use interface to the ZYPP dependency resolver.