#include <sbuild-mntstream.h>

Public Types | |
| enum | error_code { MNT_OPEN, MNT_READ } |
| Error codes. More... | |
| typedef sbuild::custom_error < error_code > | error |
| Exception type. | |
Public Member Functions | |
| mntstream (std::string const &file) | |
| The constructor. | |
| virtual | ~mntstream () |
| The destructor. | |
| void | open (std::string const &file) |
| Open a mount file for reading. | |
| void | close () |
| Close the mount file. | |
| bool | eof () const |
| Check for End Of File. | |
| bool | bad () const |
| Check for errors. | |
| operator bool () | |
| Check if the mntstream status is good. | |
| bool | operator! () |
| Check if the mntstream status is bad. | |
Private Member Functions | |
| void | read (int quantity=1) |
| Read mntents from the underlying FILE stream into the data deque. | |
Private Attributes | |
| std::string | file |
| The file name. | |
| FILE * | mntfile |
| The underlying FILE stream. | |
| std::deque< mntentry > | data |
| A list of mntentries represents the mount file stream as a LIFO stack. | |
| bool | error_status |
| Error status. | |
| bool | eof_status |
| End of File status. | |
Friends | |
| mntstream & | operator>> (mntstream &stream, mntentry &entry) |
| The overloaded extraction operator. | |
Classes | |
| struct | mntentry |
| An entry in a mntstream. More... | |
This is a wrapper around the setmntent(3), getmntent(3) and endmntent(3) functions, which are used to read a stream of "mntents" through multiple getmntent() calls.
mntstream calls setmntent() and endmntent() automatically, and represents each mntent as a mntstream::mntentry. Like reading from and istream by pulling data out with the >> "extraction operator", mntentries are also extracted from the mntstream with the >> operator.
Exception type.
| mntstream::mntstream | ( | std::string const & | file | ) |
The constructor.
| file | the file to read. |
| mntstream::~mntstream | ( | ) | [virtual] |
The destructor.
| void mntstream::open | ( | std::string const & | file | ) |
Open a mount file for reading.
This uses the openmnt(3) call to open the underlying FILE stream. Any previously open mount file is closed before opening the new one. The mntstream error state is set if the open fails, and an exception will be thrown.
| file | the file to read. |
| void mntstream::close | ( | ) |
| bool mntstream::eof | ( | ) | const |
Check for End Of File.
Note that the end of file status is only set adter a read fails, so this should be checked after each read.
| bool mntstream::bad | ( | ) | const |
| mntstream::operator bool | ( | ) |
| bool mntstream::operator! | ( | ) |
| void mntstream::read | ( | int | quantity = 1 |
) | [private] |
std::string sbuild::mntstream::file [private] |
The file name.
FILE* sbuild::mntstream::mntfile [private] |
The underlying FILE stream.
std::deque<mntentry> sbuild::mntstream::data [private] |
A list of mntentries represents the mount file stream as a LIFO stack.
bool sbuild::mntstream::error_status [private] |
Error status.
bool sbuild::mntstream::eof_status [private] |
End of File status.
1.5.4