libzypp  11.13.5
zypp::iostr Namespace Reference

Iostream related utilities. More...

Classes

class  EachLine
 Simple lineparser: Traverse each line in a file. More...

Typedefs

typedef
boost::io::ios_base_all_saver 
IosFmtFlagsSaver
 Save and restore streams width, precision and fmtflags.

Enumerations

enum  ParseFlag {
  PF_LTRIM = 1 << 0, PF_RTRIM = 1 << 1, PF_TRIM = PF_LTRIM | PF_RTRIM, PF_SKIP_EMPTY = 1 << 2,
  PF_SKIP_SHARP_COMMENT = 1 << 3
}
 simpleParseFile modifications before consuming a line. More...

Functions

std::string getline (std::istream &str)
 Read one line from stream.
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))
 BOOST_MPL_ASSERT_RELATION (int(PF_RTRIM),==, int(str::R_TRIM))
int simpleParseFile (std::istream &str_r, ParseFlags flags_r, function< bool(int, std::string)> consume_r)
 Simple lineparser optionally trimming and skipping comments.
std::ostream & copy (std::istream &from_r, std::ostream &to_r)
 Copy istream to ostream.
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 "> " ).
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 "> " ).
 ZYPP_DECLARE_FLAGS (ParseFlags, ParseFlag)
 ZYPP_DECLARE_OPERATORS_FOR_FLAGS (ParseFlags)
int simpleParseFile (std::istream &str_r, function< bool(int, std::string)> consume_r)

Detailed Description

Iostream related utilities.


Typedef Documentation

typedef boost::io::ios_base_all_saver zypp::iostr::IosFmtFlagsSaver

Save and restore streams width, precision and fmtflags.

Definition at line 36 of file IOStream.h.


Enumeration Type Documentation

simpleParseFile modifications before consuming a line.

Enumerator:
PF_LTRIM 
PF_RTRIM 
PF_TRIM 
PF_SKIP_EMPTY 
PF_SKIP_SHARP_COMMENT 

Definition at line 195 of file IOStream.h.


Function Documentation

std::string zypp::iostr::getline ( std::istream &  str)

Read one line from stream.

Reads everything up to the next newline or EOF. newline is read but not returned.

See also:
forEachLine

Definition at line 33 of file IOStream.cc.

int zypp::iostr::forEachLine ( std::istream &  str_r,
function< bool(int, std::string)>  consume_r 
)

Simple lineparser: Call functor consume_r for each line.

Parameters:
str_ristream to read from.
consume_rcallback function taking linenumber and content

The loop is aborted if the callback returns false.

iostr::forEachLine( InputStream( "/my/file/to/read.txt" ),
[]( int num_r, std::string line_r )->bool
{
MIL << " [" num_r << "]'" << line_r << "'" << endl;
return true;
} );
Returns:
Number if lines consumed (negative if aborted by callback).

Definition at line 100 of file IOStream.cc.

zypp::iostr::BOOST_MPL_ASSERT_RELATION ( int(PF_LTRIM)  ,
int(str::L_TRIM)   
)
zypp::iostr::BOOST_MPL_ASSERT_RELATION ( int(PF_RTRIM)  ,
int(str::R_TRIM)   
)
int zypp::iostr::simpleParseFile ( std::istream &  str_r,
ParseFlags  flags_r,
function< bool(int, std::string)>  consume_r 
)

Simple lineparser optionally trimming and skipping comments.

Definition at line 124 of file IOStream.cc.

std::ostream& zypp::iostr::copy ( std::istream &  from_r,
std::ostream &  to_r 
)
inline

Copy istream to ostream.

Returns:
reference to the ostream.

Definition at line 51 of file IOStream.h.

std::ostream& zypp::iostr::copyIndent ( std::istream &  from_r,
std::ostream &  to_r,
const std::string &  indent_r = "> " 
)
inline

Copy istream to ostream, prefixing each line with indent_r (default "> " ).

Returns:
reference to the ostream.

Definition at line 65 of file IOStream.h.

void zypp::iostr::tee ( std::istream &  from_r,
std::ostream &  to1_r,
std::ostream &  to2_r 
)
inline

Copy istream to ostream, prefixing each line with indent_r (default "> " ).

Returns:
reference to the ostream.

Definition at line 85 of file IOStream.h.

zypp::iostr::ZYPP_DECLARE_FLAGS ( ParseFlags  ,
ParseFlag   
)
zypp::iostr::ZYPP_DECLARE_OPERATORS_FOR_FLAGS ( ParseFlags  )
int zypp::iostr::simpleParseFile ( std::istream &  str_r,
function< bool(int, std::string)>  consume_r 
)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Definition at line 210 of file IOStream.h.