LTI-Lib latest version v1.9 - last update 10 Apr 2010

lti::getStreamFd Class Reference

This functor can be used to access the file descriptor that is used within a stream object. More...

#include <ltiGetStreamFd.h>

Inheritance diagram for lti::getStreamFd:
Inheritance graph
[legend]
Collaboration diagram for lti::getStreamFd:
Collaboration graph
[legend]

List of all members.

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
getStreamFdcopy (const getStreamFd &other)
getStreamFdoperator= (const getStreamFd &other)
virtual functorclone () const
const parametersgetParameters () 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)

Detailed Description

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


Constructor & Destructor Documentation

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

Parameters:
other the object to be copied
virtual lti::getStreamFd::~getStreamFd (  )  [virtual]

destructor


Member Function Documentation

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.

Parameters:
ins ofstream for which a new FILE structure is to be created.
f will receive the pointer to the newly created FILE structure.
Returns:
true if the file could be successfully opened, false otherwise.
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.

Parameters:
ins ofstream for which a new FILE structure is to be created.
f will receive the pointer to the newly created FILE structure.
Returns:
true if the file could be successfully opened, false otherwise.
bool lti::getStreamFd::apply ( std::fstream &  ins,
int &  fd 
) const

Retrieve the file descriptor associated with the given stream.

Parameters:
ins fstream whose file descriptor is to be returned.
fd will receive the file descriptor, or -1 if it could not be determined.
Returns:
true if the method succeeded, or false otherwise.
bool lti::getStreamFd::apply ( std::ofstream &  ins,
int &  fd 
) const

Retrieve the file descriptor associated with the given stream.

Parameters:
ins ofstream whose file descriptor is to be returned.
fd will receive the file descriptor, or -1 if it could not be determined.
Returns:
true if the method succeeded, or false otherwise.
bool lti::getStreamFd::apply ( std::ifstream &  ins,
int &  fd 
) const

Retrieve the file descriptor associated with the given stream.

Parameters:
ins ifstream whose file descriptor is to be returned.
fd will receive the file descriptor, or -1 if it could not be determined.
Returns:
true if the method succeeded, or false otherwise.
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.

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

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.

Parameters:
ins ifstream whose file descriptor is to be returned.
Returns:
the file descriptor, or -1 if none could be determined.
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.

Parameters:
ins ifstream whose file descriptor is to be returned.
Returns:
the file descriptor, or -1 if none could be determined.
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.

Parameters:
ins ifstream whose file descriptor is to be returned.
Returns:
the file descriptor, or -1 if none could be determined.
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.

Parameters:
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.

Parameters:
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  ) 

alias for copy member

Parameters:
other the functor to be copied
Returns:
a reference to this functor object

Reimplemented from lti::functor.

void lti::getStreamFd::setDuplicate ( bool  d = true  ) 

Sets the duplicateFd parameter according to the given value.


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

Generated on Sat Apr 10 15:28:52 2010 for LTI-Lib by Doxygen 1.6.1