12#ifndef ZYPP_BASE_IOSTREAM_H
13#define ZYPP_BASE_IOSTREAM_H
16#include <boost/io/ios_state.hpp>
51 inline std::ostream &
copy( std::istream & from_r, std::ostream & to_r )
56 while ( from_r && from_r.get( ch ) )
65 inline std::ostream &
copyIndent( std::istream & from_r, std::ostream & to_r,
const std::string & indent_r =
"> " )
71 while ( from_r && from_r.get( ch ) )
75 indent = ( ch ==
'\n' );
85 inline void tee( std::istream & from_r, std::ostream & to1_r, std::ostream & to2_r )
87 if ( from_r && ( to1_r ||to2_r ) )
90 while ( from_r && from_r.get( ch ) )
116 EachLine( std::istream & str_r,
unsigned lineNo_r = 0 );
154 while ( num_r-- &&
next() )
186 int forEachLine( std::istream & str_r,
const function<
bool(
int, std::string)>& consume_r )
ZYPP_API;
201 int simpleParseFile( std::istream & str_r, ParseFlags flags_r, function<
bool(
int, std::string)> consume_r )
ZYPP_API;
204 inline int simpleParseFile( std::istream & str_r, function<
bool(
int, std::string)> consume_r )
bool next(unsigned num_r)
Advance num_r lines.
void setLineNo(unsigned lineNo_r)
Set current line number.
std::streamoff lineStart() const
std::string & operator*()
const std::string * operator->() const
Access the current line.
unsigned lineNo() const
Return the current line number.
bool valid() const
Whether this contains a valid line to consume.
bool next()
Advance to next line.
const std::string & operator*() const
Access the current 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::noncopyable NonCopyable
Ensure derived classes cannot be copied.
Iostream related utilities.
int forEachLine(std::istream &str_r, const function< bool(int, std::string)> &consume_r)
Simple lineparser: Call functor consume_r for each line.
ParseFlag
simpleParseFile modifications before consuming a line.
int simpleParseFile(std::istream &str_r, ParseFlags flags_r, function< bool(int, std::string)> consume_r)
Simple lineparser optionally trimming and skipping comments.
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 "> " ).
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 "> " ).
boost::io::ios_base_all_saver IosFmtFlagsSaver
Save and restore streams width, precision and fmtflags.
std::string getline(std::istream &str)
Read one line from stream.
std::ostream & copy(std::istream &from_r, std::ostream &to_r)
Copy istream to ostream.
Easy-to use interface to the ZYPP dependency resolver.
const Arch Arch_armv7hnl Arch_armv7nhl ZYPP_API
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
#define ZYPP_DECLARE_FLAGS(Name, Enum)