blocxx
Public Member Functions | Private Member Functions

BLOCXX_NAMESPACE::IFileStream Class Reference

The purpose of this class is to provide an alternative implementation of std::ifstream that is based on a FILE*, and can be created using a FILE*, a raw file descriptor or an instance of blocxx::File. More...

#include <IFileStream.hpp>

Inheritance diagram for BLOCXX_NAMESPACE::IFileStream:
BLOCXX_NAMESPACE::FileBuf

List of all members.

Public Member Functions

 IFileStream ()
 Constructor.
 ~IFileStream ()
 Calls close().
bool isOpen () const
IFileStreamopen (FILE *fp)
 If isOpen() == true, returns 0, otherwise initializes the IFileStream to use fp.
IFileStreamopen (AutoDescriptor fd)
 If isOpen() == true, returns 0, otherwise initializes the IFileStream to use fd.
IFileStreamopen (const char *path, std::ios_base::openmode mode, mode_t permissions=0666)
 If isOpen() == true, returns 0, otherwise initializes the IFileStream by opening the file identified by path.
IFileStreamclose ()
 If isOpen() == false, returns a null pointer.

Private Member Functions

 IFileStream (const IFileStream &arg)
IFileStreamoperator= (const IFileStream &arg)

Detailed Description

The purpose of this class is to provide an alternative implementation of std::ifstream that is based on a FILE*, and can be created using a FILE*, a raw file descriptor or an instance of blocxx::File.

IFileStream does not support all the operations that a std::ifstream does. IFileStream does not support seeking, character putback, facets, i18n. Basically all it does support is reading.

Definition at line 57 of file IFileStream.hpp.


Constructor & Destructor Documentation

usr src packages BUILD blocxx src blocxx IFileStream cpp BLOCXX_NAMESPACE::IFileStream::IFileStream ( )

Constructor.

isOpen() == false

Definition at line 48 of file IFileStream.cpp.

BLOCXX_NAMESPACE::IFileStream::~IFileStream ( )

Calls close().

Definition at line 54 of file IFileStream.cpp.

BLOCXX_NAMESPACE::IFileStream::IFileStream ( const IFileStream arg) [private]

Member Function Documentation

IFileStream * BLOCXX_NAMESPACE::IFileStream::close ( )

If isOpen() == false, returns a null pointer.

If a put area exists, calls overflow(EOF) to flush characters. Finally it closes the file. If any of the calls to overflow or std::fclose fails then close fails.

Postcondition:
isOpen() == false.
Returns:
IFileStream*: this if successful, 0 otherwise.

Reimplemented from BLOCXX_NAMESPACE::FileBuf.

Definition at line 95 of file IFileStream.cpp.

References BLOCXX_NAMESPACE::FileBuf::close().

bool BLOCXX_NAMESPACE::IFileStream::isOpen ( ) const
Returns:
bool: true if a previous call to open succeeded (returned a non-null value) and there has been no intervening call to close.

Reimplemented from BLOCXX_NAMESPACE::FileBuf.

Definition at line 59 of file IFileStream.cpp.

IFileStream * BLOCXX_NAMESPACE::IFileStream::open ( FILE *  fp)

If isOpen() == true, returns 0, otherwise initializes the IFileStream to use fp.

Parameters:
fpThe FILE* to use. The IFileStream will take ownership of fp, so close() will call std::fclose() on fp.
Returns:
IFileStream*: this if successful, 0 otherwise.

Reimplemented from BLOCXX_NAMESPACE::FileBuf.

Definition at line 65 of file IFileStream.cpp.

References BLOCXX_NAMESPACE::FileBuf::open().

IFileStream * BLOCXX_NAMESPACE::IFileStream::open ( const char *  path,
std::ios_base::openmode  mode,
mode_t  permissions = 0666 
)

If isOpen() == true, returns 0, otherwise initializes the IFileStream by opening the file identified by path.

If the open operation succeeds and (mode & ios_base::ate) != 0, positions the file to the end. If the repositioning operation fails, calls close() and returns a null pointer to indicate failure.

Parameters:
pathA null-terminated string identifying the file to open.
modeA bitmask of the file open mode flags defined in ios_base. Invalid combinations cause the operation to fail.
permissionsSpecifies the permissions to use in case a new file is created. It is modified by the process's umask in the usual way: the permissions of the created file are (mode & ~umask). Note that this mode only applies to future accesses of the newly created file; the open call that creates a read-only file may well return a read/write file descriptor.
Returns:
IFileStream*: this if successful, 0 otherwise.

Reimplemented from BLOCXX_NAMESPACE::FileBuf.

Definition at line 85 of file IFileStream.cpp.

References BLOCXX_NAMESPACE::FileBuf::open().

IFileStream * BLOCXX_NAMESPACE::IFileStream::open ( AutoDescriptor  fd)

If isOpen() == true, returns 0, otherwise initializes the IFileStream to use fd.

Parameters:
fdThe descriptor to use. The IFileStream will take ownership of fd, so close() will close the descriptor.
Returns:
IFileStream*: this if successful, 0 otherwise.

Reimplemented from BLOCXX_NAMESPACE::FileBuf.

Definition at line 75 of file IFileStream.cpp.

References BLOCXX_NAMESPACE::FileBuf::open().

IFileStream& BLOCXX_NAMESPACE::IFileStream::operator= ( const IFileStream arg) [private]

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