|
blocxx
|
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>
Public Member Functions | |
| IFileStream () | |
| Constructor. | |
| ~IFileStream () | |
| Calls close(). | |
| bool | isOpen () const |
| IFileStream * | open (FILE *fp) |
| If isOpen() == true, returns 0, otherwise initializes the IFileStream to use fp. | |
| IFileStream * | open (AutoDescriptor fd) |
| If isOpen() == true, returns 0, otherwise initializes the IFileStream to use fd. | |
| 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. | |
| IFileStream * | close () |
| If isOpen() == false, returns a null pointer. | |
Private Member Functions | |
| IFileStream (const IFileStream &arg) | |
| IFileStream & | operator= (const IFileStream &arg) |
Private Member Functions inherited from BLOCXX_NAMESPACE::FileBuf | |
| FileBuf () | |
| Constructor. | |
| ~FileBuf () | |
| Calls close(). | |
| bool | isOpen () const |
| FileBuf * | open (FILE *fp) |
| If isOpen() == true, returns 0, otherwise initializes the FileBuf to use fp. | |
| FileBuf * | open (AutoDescriptor fd) |
| If isOpen() == true, returns 0, otherwise initializes the FileBuf to use fd. | |
| FileBuf * | open (const char *path, std::ios_base::openmode mode, mode_t permissions=0666) |
| If isOpen() == true, returns 0, otherwise initializes the FileBuf by opening the file identified by path. | |
| FileBuf * | close () |
| If isOpen() == false, returns a null pointer. | |
Private Member Functions inherited from BLOCXX_NAMESPACE::BaseStreamBuffer | |
| BaseStreamBuffer (EDirectionFlag direction, size_t bufSize=BASE_BUF_SIZE) | |
| Create a base stream buffer. | |
| ~BaseStreamBuffer () | |
| int | underflow () |
| std::streamsize | xsputn (const char *s, std::streamsize n) |
| virtual int | overflow (int c) |
| virtual int | sync () |
| virtual void | initBuffers () |
| virtual void | initGetBuffer () |
| virtual void | initPutBuffer () |
Additional Inherited Members | |
Private Types inherited from BLOCXX_NAMESPACE::BaseStreamBuffer | |
| enum | EDirectionFlag { E_IN , E_OUT , E_IN_OUT } |
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.
| BLOCXX_NAMESPACE::IFileStream::IFileStream | ( | ) |
| BLOCXX_NAMESPACE::IFileStream::~IFileStream | ( | ) |
Calls close().
Definition at line 53 of file IFileStream.cpp.
|
private |
| 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.
Definition at line 94 of file IFileStream.cpp.
References BLOCXX_NAMESPACE::FileBuf::close().
| bool BLOCXX_NAMESPACE::IFileStream::isOpen | ( | ) | const |
Definition at line 58 of file IFileStream.cpp.
References BLOCXX_NAMESPACE::FileBuf::isOpen().
| IFileStream * BLOCXX_NAMESPACE::IFileStream::open | ( | AutoDescriptor | fd | ) |
If isOpen() == true, returns 0, otherwise initializes the IFileStream to use fd.
| fd | The descriptor to use. The IFileStream will take ownership of fd, so close() will close the descriptor. |
Definition at line 74 of file IFileStream.cpp.
References BLOCXX_NAMESPACE::FileBuf::open(), and BLOCXX_NAMESPACE::operator==().
| 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.
| path | A null-terminated string identifying the file to open. |
| mode | A bitmask of the file open mode flags defined in ios_base. Invalid combinations cause the operation to fail. |
| permissions | Specifies 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. |
Definition at line 84 of file IFileStream.cpp.
References BLOCXX_NAMESPACE::FileBuf::open(), and BLOCXX_NAMESPACE::operator==().
| IFileStream * BLOCXX_NAMESPACE::IFileStream::open | ( | FILE * | fp | ) |
If isOpen() == true, returns 0, otherwise initializes the IFileStream to use fp.
| fp | The FILE* to use. The IFileStream will take ownership of fp, so close() will call std::fclose() on fp. |
Definition at line 64 of file IFileStream.cpp.
References BLOCXX_NAMESPACE::FileBuf::open(), and BLOCXX_NAMESPACE::operator==().
|
private |