13 #include <boost/mpl/assert.hpp>
14 #include <boost/mpl/int.hpp>
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
137 if ( flags_r & ~PF_TRIM )
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.
std::streamoff _lineStart
Trim
To define how to trim.
std::string getline(std::istream &str)
Read one line from stream.
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 trim(const std::string &s, const Trim trim_r)
int forEachLine(std::istream &str_r, function< bool(int, std::string)> consume_r)
Simple lineparser: Call functor consume_r for each line.
BOOST_MPL_ASSERT_RELATION(int(PF_LTRIM),==, int(str::L_TRIM))
EachLine(std::istream &str_r, unsigned lineNo_r=0)
Ctor taking a stream and reading the 1st line from it.