12#ifndef ZYPP_BASE_IOSTREAM_H
13#define ZYPP_BASE_IOSTREAM_H
16#include <boost/io/ios_state.hpp>
18#include <zypp-core/base/Flags.h>
19#include <zypp-core/base/PtrTypes.h>
20#include <zypp-core/base/Function.h>
21#include <zypp-core/base/NonCopyable.h>
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
151 bool next(
unsigned num_r )
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 )
void setLineNo(unsigned lineNo_r)
Set current line number.
std::streamoff lineStart() const
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.
ParseFlag
simpleParseFile modifications before consuming a line.
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 "> " ).
int forEachLine(std::istream &str_r, function< bool(int, std::string)> consume_r)
Simple lineparser: Call functor consume_r for each line.
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 "> " ).
int simpleParseFile(std::istream &str_r, ParseFlags flags_r, function< bool(int, std::string)> consume_r)
Simple lineparser optionally trimming and skipping comments.
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.
#define ZYPP_DECLARE_OPERATORS_FOR_FLAGS(Name)
#define ZYPP_DECLARE_FLAGS(Name, Enum)