libzypp 17.37.10

zypp::iostr::EachLine Class Reference

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

`#include <zypp-core/base/IOStream.h>`

Inheritance diagram for zypp::iostr::EachLine:

## Public Member Functions
| EachLine (std::istream &str_r, unsigned lineNo_r=0)
| Ctor taking a stream and reading the 1st line from it.
bool | valid () const
| Whether `this` contains a valid line to consume.
| operator bool () const
| Evaluate class in a boolean context.
unsigned | lineNo () const
| Return the current line number.
std::streamoff | lineStart () const
void | setLineNo (unsigned lineNo_r)
| Set current line number.
const std::string & | operator* () const
| Access the current line.
std::string & | operator* ()
const std::string * | operator-> () const
| Access the current line.
bool | next ()
| Advance to next line.
bool | next (unsigned num_r)
| Advance num_r lines.

## Private Attributes
std::istream & | _str
std::string | _line
std::streamoff | _lineStart
unsigned | _lineNo
bool | _valid

## Detailed Description

Simple lineparser: Traverse each line in a file.

std::ifstream infile( "somefile" );
for( iostr::EachLine in( infile ); in; in.next() )
{
DBG << *in << endl;
}
zypp::iostr::EachLine
Simple lineparser: Traverse each line in a file.
Definition IOStream.h:113
zypp::iostr::EachLine::next
bool next()
Advance to next line.
Definition IOStream.cc:72
DBG
#define DBG
Definition Logger.h:99

Definition at line 112 of file IOStream.h.

## Constructor & Destructor Documentation

## ◆ EachLine()

zypp::iostr::EachLine::EachLine | ( | std::istream & | str_r,
|  | unsigned | lineNo_r = 0 )

Ctor taking a stream and reading the 1st line from it.

Definition at line 58 of file IOStream.cc.

## Member Function Documentation

## ◆ valid()

bool zypp::iostr::EachLine::valid | ( |  | ) | const
| inline

Whether `this` contains a valid line to consume.

Definition at line 119 of file IOStream.h.

## ◆ operator bool()

zypp::iostr::EachLine::operator bool | ( |  | ) | const
| inline explicit

Evaluate class in a boolean context.

Definition at line 123 of file IOStream.h.

## ◆ lineNo()

unsigned zypp::iostr::EachLine::lineNo | ( |  | ) | const
| inline

Return the current line number.

Definition at line 127 of file IOStream.h.

## ◆ lineStart()

std::streamoff zypp::iostr::EachLine::lineStart | ( |  | ) | const
| inline

Definition at line 130 of file IOStream.h.

## ◆ setLineNo()

void zypp::iostr::EachLine::setLineNo | ( | unsigned | lineNo_r | ) |
| inline

Set current line number.

Definition at line 134 of file IOStream.h.

## ◆ operator*() [1/2]

const std::string & zypp::iostr::EachLine::operator* | ( |  | ) | const
| inline

Access the current line.

Definition at line 138 of file IOStream.h.

## ◆ operator*() [2/2]

std::string & zypp::iostr::EachLine::operator* | ( |  | ) |
| inline

Definition at line 141 of file IOStream.h.

## ◆ operator->()

const std::string * zypp::iostr::EachLine::operator-> | ( |  | ) | const
| inline

Access the current line.

Definition at line 145 of file IOStream.h.

## ◆ next() [1/2]

bool zypp::iostr::EachLine::next | ( |  | ) |

Advance to next line.

Definition at line 72 of file IOStream.cc.

## ◆ next() [2/2]

bool zypp::iostr::EachLine::next | ( | unsigned | num_r | ) |
| inline

Advance num_r lines.

Definition at line 152 of file IOStream.h.

## Member Data Documentation

## ◆ _str

std::istream& zypp::iostr::EachLine::_str
| private

Definition at line 160 of file IOStream.h.

## ◆ _line

std::string zypp::iostr::EachLine::_line
| private

Definition at line 161 of file IOStream.h.

## ◆ _lineStart

std::streamoff zypp::iostr::EachLine::_lineStart
| private

Definition at line 162 of file IOStream.h.

## ◆ _lineNo

unsigned zypp::iostr::EachLine::_lineNo
| private

Definition at line 163 of file IOStream.h.

## ◆ _valid

bool zypp::iostr::EachLine::_valid
| private

Definition at line 164 of file IOStream.h.

The documentation for this class was generated from the following files:

- zypp-core/base/IOStream.h
- zypp-core/base/IOStream.cc