12 #ifndef ZYPP_BASE_IOSTREAM_H
13 #define ZYPP_BASE_IOSTREAM_H
16 #include <boost/io/ios_state.hpp>
45 std::string
getline( std::istream & str );
50 inline std::ostream &
copy( std::istream & from_r, std::ostream & to_r )
55 while ( from_r && from_r.get( ch ) )
64 inline std::ostream &
copyIndent( std::istream & from_r, std::ostream & to_r,
const std::string & indent_r =
"> " )
70 while ( from_r && from_r.get( ch ) )
74 indent = ( ch ==
'\n' );
84 inline void tee( std::istream & from_r, std::ostream & to1_r, std::ostream & to2_r )
86 if ( from_r && ( to1_r ||to2_r ) )
89 while ( from_r && from_r.get( ch ) )
115 EachLine( std::istream & str_r,
unsigned lineNo_r = 0 );
122 explicit operator bool()
const
153 while ( num_r-- &&
next() )
185 int forEachLine( std::istream & str_r,
function<
bool(
int, std::string)> consume_r );
200 int simpleParseFile( std::istream & str_r, ParseFlags flags_r,
function<
bool(
int, std::string)> consume_r );
203 inline int simpleParseFile( std::istream & str_r,
function<
bool(
int, std::string)> consume_r )
212 #endif // ZYPP_BASE_IOSTREAM_H
bool next()
Advance to next line.
bool valid() const
Whether this contains a valid line to consume.
const std::string & operator*() const
Access the current line.
std::streamoff lineStart() const
std::ostream & copyIndent(std::istream &from_r, std::ostream &to_r, const std::string &indent_r="> ")
Copy istream to ostream, prefixing each line with indent_r (default "> " ).
const std::string * operator->() const
Access the current line.
boost::io::ios_base_all_saver IosFmtFlagsSaver
Save and restore streams width, precision and fmtflags.
unsigned lineNo() const
Return the current line number.
Simple lineparser: Traverse each line in a file.
std::streamoff _lineStart
std::string & operator*()
void setLineNo(unsigned lineNo_r)
Set current line number.
ParseFlag
simpleParseFile modifications before consuming a line.
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.
boost::noncopyable NonCopyable
Ensure derived classes cannot be copied.
int forEachLine(std::istream &str_r, function< bool(int, std::string)> consume_r)
Simple lineparser: Call functor consume_r for each line.
bool next(unsigned num_r)
Advance num_r lines.
ZYPP_DECLARE_OPERATORS_FOR_FLAGS(ParseFlags)
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
ZYPP_DECLARE_FLAGS(ParseFlags, ParseFlag)
void tee(std::istream &from_r, std::ostream &to1_r, std::ostream &to2_r)
Copy istream to ostream, prefixing each line with indent_r (default "> " ).
EachLine(std::istream &str_r, unsigned lineNo_r=0)
Ctor taking a stream and reading the 1st line from it.