latest version v1.9 - last update 10 Apr 2010 |
This functor can be used to access the file descriptor that is used within a stream object. More...
#include <ltiGetStreamFd.h>
Classes | |
class | parameters |
the parameters for the class streamAccess More... | |
Public Member Functions | |
getStreamFd () | |
getStreamFd (const parameters &par) | |
getStreamFd (const getStreamFd &other) | |
virtual | ~getStreamFd () |
virtual const char * | getTypeName () const |
getStreamFd & | copy (const getStreamFd &other) |
getStreamFd & | operator= (const getStreamFd &other) |
virtual functor * | clone () const |
const parameters & | getParameters () const |
bool | apply (std::ifstream &ins, int &fd) const |
bool | apply (std::ofstream &ins, int &fd) const |
bool | apply (std::fstream &ins, int &fd) const |
std::ofstream * | newOutputStream (int fd, bool buffered=true) const |
std::ifstream * | newInputStream (int fd, bool buffered=true) const |
bool | apply (std::ofstream &ins, FILE *&f) const |
bool | apply (std::ifstream &ins, FILE *&f) const |
int | getfd (std::ifstream &ins) const |
int | getfd (std::ofstream &ins) const |
int | getfd (std::fstream &ins) const |
void | setDuplicate (bool d=true) |
This functor can be used to access the file descriptor that is used within a stream object.
Its primary purpose is to use it on machines or implementations of the iostreams that do not offer legal methods of obtaining it.
This class is strongly system and compiler dependend
lti::getStreamFd::getStreamFd | ( | ) |
default constructor
lti::getStreamFd::getStreamFd | ( | const parameters & | par | ) |
Construct a functor using the given parameters.
lti::getStreamFd::getStreamFd | ( | const getStreamFd & | other | ) |
copy constructor
other | the object to be copied |
virtual lti::getStreamFd::~getStreamFd | ( | ) | [virtual] |
destructor
bool lti::getStreamFd::apply | ( | std::ifstream & | ins, | |
FILE *& | f | |||
) | const |
Create a new FILE structure from the given input stream.
WARNING: It is strongly advisable to use this method only with the duplicateFd parameter set to true. The returned FILE file must be closed with fclose.
ins | ofstream for which a new FILE structure is to be created. | |
f | will receive the pointer to the newly created FILE structure. |
bool lti::getStreamFd::apply | ( | std::ofstream & | ins, | |
FILE *& | f | |||
) | const |
Create a new FILE structure from the given output stream.
WARNING: It is strongly advisable to use this method only with the duplicateFd parameter set to true. The returned FILE file must be closed with fclose.
ins | ofstream for which a new FILE structure is to be created. | |
f | will receive the pointer to the newly created FILE structure. |
bool lti::getStreamFd::apply | ( | std::fstream & | ins, | |
int & | fd | |||
) | const |
Retrieve the file descriptor associated with the given stream.
ins | fstream whose file descriptor is to be returned. | |
fd | will receive the file descriptor, or -1 if it could not be determined. |
bool lti::getStreamFd::apply | ( | std::ofstream & | ins, | |
int & | fd | |||
) | const |
Retrieve the file descriptor associated with the given stream.
ins | ofstream whose file descriptor is to be returned. | |
fd | will receive the file descriptor, or -1 if it could not be determined. |
bool lti::getStreamFd::apply | ( | std::ifstream & | ins, | |
int & | fd | |||
) | const |
Retrieve the file descriptor associated with the given stream.
ins | ifstream whose file descriptor is to be returned. | |
fd | will receive the file descriptor, or -1 if it could not be determined. |
virtual functor* lti::getStreamFd::clone | ( | ) | const [virtual] |
returns a pointer to a clone of this functor.
Implements lti::functor.
getStreamFd& lti::getStreamFd::copy | ( | const getStreamFd & | other | ) |
copy data of "other" functor.
other | the functor to be copied |
Reimplemented from lti::functor.
int lti::getStreamFd::getfd | ( | std::fstream & | ins | ) | const |
Retrieve the file descriptor associated with the given stream.
This method ignores the value of the duplicateFd parameter; the file descriptor is never duplicated.
ins | ifstream whose file descriptor is to be returned. |
int lti::getStreamFd::getfd | ( | std::ofstream & | ins | ) | const |
Retrieve the file descriptor associated with the given stream.
This method ignores the value of the duplicateFd parameter; the file descriptor is never duplicated.
ins | ifstream whose file descriptor is to be returned. |
int lti::getStreamFd::getfd | ( | std::ifstream & | ins | ) | const |
Retrieve the file descriptor associated with the given stream.
This method ignores the value of the duplicateFd parameter; the file descriptor is never duplicated.
ins | ifstream whose file descriptor is to be returned. |
const parameters& lti::getStreamFd::getParameters | ( | ) | const |
returns used parameters
Reimplemented from lti::functor.
virtual const char* lti::getStreamFd::getTypeName | ( | ) | const [virtual] |
returns the name of this type ("getStreamFd")
Reimplemented from lti::functor.
std::ifstream* lti::getStreamFd::newInputStream | ( | int | fd, | |
bool | buffered = true | |||
) | const |
Creates a new input stream that wraps around the given file descriptor.
If the duplicateFd parameter is true, the file descriptor will be duplicated, and the duplicated fd will be closed when the stream is closed. Otherwise, the file descriptor will not be duplicated and not be closed.
fd | the file descriptor | |
buffered | a flag that tells if the stream should be buffered (default) or not. |
std::ofstream* lti::getStreamFd::newOutputStream | ( | int | fd, | |
bool | buffered = true | |||
) | const |
Creates a new output stream that wraps around the given file descriptor.
If the duplicateFd parameter is true, the file descriptor will be duplicated, and the duplicated fd will be closed when the stream is closed. Otherwise, the file descriptor will not be duplicated and not be closed.
fd | the file descriptor | |
buffered | a flag that tells if the stream should be buffered (default) or not. |
getStreamFd& lti::getStreamFd::operator= | ( | const getStreamFd & | other | ) |
void lti::getStreamFd::setDuplicate | ( | bool | d = true |
) |
Sets the duplicateFd parameter according to the given value.