#include <FileBuf.hpp>

Public Member Functions | |
| 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 | |
| virtual int | buffer_to_device (const char *c, int n) |
| Writes the buffer to the "device". | |
| virtual int | buffer_from_device (char *c, int n) |
| Fill the buffer from the "device". | |
| std::ios_base::openmode | posixModeToCppMode (int posixMode) |
| Converts POSIX io open mode flags to C++ iostream open mode. | |
| int | cppModeToPOSIXMode (std::ios_base::openmode cppMode) |
| Converts C++ iostream open mode to POSIX io open mode. | |
| const char * | cppModeToCMode (std::ios_base::openmode cppMode) |
| Converts C++ iostream open mode to C stdio file open mode or the empty string on error (never returns null). | |
| FileBuf (const FileBuf &arg) | |
| FileBuf & | operator= (const FileBuf &arg) |
Private Attributes | |
| ::FILE * | m_file |
FileBuf does not support all the operations that a std::filebuf does. FileBuf does not support seeking, character putback, facets, i18n. Basically all it does is support reading and writing.
Definition at line 58 of file FileBuf.hpp.
| BLOCXX_NAMESPACE::FileBuf::FileBuf | ( | ) |
| BLOCXX_NAMESPACE::FileBuf::~FileBuf | ( | ) |
| BLOCXX_NAMESPACE::FileBuf::FileBuf | ( | const FileBuf & | arg | ) | [private] |
| bool BLOCXX_NAMESPACE::FileBuf::isOpen | ( | ) | const |
Reimplemented in BLOCXX_NAMESPACE::IFileStream.
Definition at line 68 of file FileBuf.cpp.
References m_file.
Referenced by buffer_from_device(), close(), BLOCXX_NAMESPACE::IFileStream::isOpen(), and open().
| FileBuf * BLOCXX_NAMESPACE::FileBuf::open | ( | FILE * | fp | ) |
If isOpen() == true, returns 0, otherwise initializes the FileBuf to use fp.
| fp | The FILE* to use. The FileBuf will take ownership of fp, so close() will call std::fclose() on fp. |
Reimplemented in BLOCXX_NAMESPACE::IFileStream.
Definition at line 74 of file FileBuf.cpp.
References isOpen(), and m_file.
Referenced by BLOCXX_NAMESPACE::IFileStream::open(), and open().
| FileBuf * BLOCXX_NAMESPACE::FileBuf::open | ( | AutoDescriptor | fd | ) |
If isOpen() == true, returns 0, otherwise initializes the FileBuf to use fd.
| fd | The descriptor to use. The FileBuf will take ownership of fd, so close() will close the descriptor. |
Reimplemented in BLOCXX_NAMESPACE::IFileStream.
Definition at line 86 of file FileBuf.cpp.
References cppModeToCMode(), BLOCXX_NAMESPACE::AutoResource< Policy >::get(), isOpen(), m_file, posixModeToCppMode(), and BLOCXX_NAMESPACE::AutoResource< Policy >::release().
| FileBuf * BLOCXX_NAMESPACE::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.
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. |
Reimplemented in BLOCXX_NAMESPACE::IFileStream.
Definition at line 146 of file FileBuf.cpp.
References BLOCXX_INVALID_HANDLE, cppModeToCMode(), cppModeToPOSIXMode(), BLOCXX_NAMESPACE::AutoResource< Policy >::get(), isOpen(), m_file, open(), and BLOCXX_NAMESPACE::AutoResource< Policy >::release().
| FileBuf * BLOCXX_NAMESPACE::FileBuf::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.
Reimplemented in BLOCXX_NAMESPACE::IFileStream.
Definition at line 181 of file FileBuf.cpp.
References isOpen(), and m_file.
Referenced by BLOCXX_NAMESPACE::IFileStream::close(), and ~FileBuf().
| int BLOCXX_NAMESPACE::FileBuf::buffer_to_device | ( | const char * | c, | |
| int | n | |||
| ) | [private, virtual] |
Writes the buffer to the "device".
| c | A pointer to the start of the buffer | |
| n | the number of bytes to write |
Reimplemented from BLOCXX_NAMESPACE::BaseStreamBuffer.
Definition at line 192 of file FileBuf.cpp.
References m_file.
| int BLOCXX_NAMESPACE::FileBuf::buffer_from_device | ( | char * | c, | |
| int | n | |||
| ) | [private, virtual] |
Fill the buffer from the "device".
| c | A pointer to the beginning of the buffer | |
| n | The number of bytes to be read into the buffer. |
| IOException | on failure. |
Reimplemented from BLOCXX_NAMESPACE::BaseStreamBuffer.
Definition at line 206 of file FileBuf.cpp.
References BLOCXX_THROW_ERRNO_MSG, isOpen(), and m_file.
| std::ios_base::openmode BLOCXX_NAMESPACE::FileBuf::posixModeToCppMode | ( | int | posixMode | ) | [private] |
Converts POSIX io open mode flags to C++ iostream open mode.
| posixMode | The POSIX io open mode flags. |
Definition at line 235 of file FileBuf.cpp.
Referenced by open().
| int BLOCXX_NAMESPACE::FileBuf::cppModeToPOSIXMode | ( | std::ios_base::openmode | cppMode | ) | [private] |
Converts C++ iostream open mode to POSIX io open mode.
| cppMode | The C++ iostream open mode flags. |
Definition at line 252 of file FileBuf.cpp.
Referenced by open().
| const char * BLOCXX_NAMESPACE::FileBuf::cppModeToCMode | ( | std::ios_base::openmode | cppMode | ) | [private] |
Converts C++ iostream open mode to C stdio file open mode or the empty string on error (never returns null).
| cppMode | C++ iostream mode |
Definition at line 280 of file FileBuf.cpp.
Referenced by open().
::FILE* BLOCXX_NAMESPACE::FileBuf::m_file [private] |
Definition at line 183 of file FileBuf.hpp.
Referenced by buffer_from_device(), buffer_to_device(), close(), isOpen(), and open().
1.5.6