ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

ucommon::filestream Class Reference

#include <stream.h>

Inheritance diagram for ucommon::filestream:
[legend]
Collaboration diagram for ucommon::filestream:
[legend]

Public Types

enum  access_t { RDONLY, WRONLY, RDWR }
 

Public Member Functions

 filestream ()
 
 filestream (const filestream &copy)
 
 filestream (const char *path, unsigned mode, fsys::access_t access, size_t bufsize=512)
 
 filestream (const char *path, fsys::access_t access, size_t bufsize=512)
 
virtual ~filestream ()
 
 operator bool () const
 
bool operator! () const
 
void open (const char *filename, fsys::access_t access, size_t buffering=512)
 
void open (const char *filename, unsigned mode, fsys::access_t access, size_t buffering=512)
 
void close (void)
 
void seek (fsys::offset_t offset)
 
void rewind (void)
 
int err (void) const
 
- Public Member Functions inherited from ucommon::StreamBuffer
int sync (void)
 
bool is_open (void) const
 
 operator bool () const
 
bool operator! () const
 

Protected Member Functions

int underflow (void) __OVERRIDE
 
int overflow (int ch) __OVERRIDE
 
- Protected Member Functions inherited from ucommon::StreamBuffer
 StreamBuffer ()
 
int uflow () __OVERRIDE
 
void release (void)
 
void allocate (size_t size)
 

Protected Attributes

fsys_t fd
 
fsys::access_t ac
 
- Protected Attributes inherited from ucommon::StreamBuffer
size_t bufsize
 
char * gbuf
 
char * pbuf
 

Private Member Functions

__LOCAL void allocate (size_t size, fsys::access_t mode)
 

Detailed Description

Streamable file class based on low level fsys io. This differs from the normal fstream classes as it may apply to other kinds of file streams.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 347 of file stream.h.

Member Enumeration Documentation

◆ access_t

Enumerator
RDONLY 
WRONLY 
RDWR 

Definition at line 350 of file stream.h.

Constructor & Destructor Documentation

◆ filestream() [1/4]

ucommon::filestream::filestream ( )

Create an unopened pipe stream.

Definition at line 620 of file stream.cpp.

◆ filestream() [2/4]

ucommon::filestream::filestream ( const filestream copy)

Create duplicate stream.

Definition at line 625 of file stream.cpp.

References allocate(), ucommon::copy(), fd, and ucommon::is().

◆ filestream() [3/4]

ucommon::filestream::filestream ( const char *  path,
unsigned  mode,
fsys::access_t  access,
size_t  bufsize = 512 
)

Create and open a file stream.

Definition at line 640 of file stream.cpp.

References open().

◆ filestream() [4/4]

ucommon::filestream::filestream ( const char *  path,
fsys::access_t  access,
size_t  bufsize = 512 
)

Open file stream.

Definition at line 634 of file stream.cpp.

References open().

◆ ~filestream()

ucommon::filestream::~filestream ( )
virtual

Destroy a file stream.

Definition at line 646 of file stream.cpp.

References close().

Member Function Documentation

◆ allocate()

◆ close()

void ucommon::filestream::close ( void  )

Close an active stream connection.

Definition at line 667 of file stream.cpp.

References ucommon::StreamBuffer::bufsize, ucommon::fsys::close(), fd, ucommon::StreamBuffer::release(), and ucommon::StreamBuffer::sync().

Referenced by open(), overflow(), underflow(), and ~filestream().

◆ err()

int ucommon::filestream::err ( void  ) const
inline

Get error flag from last i/o operation.

Returns
last error.

Definition at line 448 of file stream.h.

References ucommon::fsys::err().

◆ open() [1/2]

void ucommon::filestream::open ( const char *  filename,
fsys::access_t  access,
size_t  buffering = 512 
)

Open a stream connection to a tcp service.

Definition at line 745 of file stream.cpp.

References allocate(), close(), fd, ucommon::is(), and ucommon::fsys::open().

Referenced by filestream().

◆ open() [2/2]

void ucommon::filestream::open ( const char *  filename,
unsigned  mode,
fsys::access_t  access,
size_t  buffering = 512 
)

Create a stream connection to a tcp service.

Definition at line 737 of file stream.cpp.

References allocate(), close(), fd, ucommon::is(), and ucommon::fsys::open().

◆ operator bool()

ucommon::filestream::operator bool ( ) const
inline

See if stream connection is active.

Returns
true if stream is active.

Definition at line 410 of file stream.h.

◆ operator!()

bool ucommon::filestream::operator! ( void  ) const
inline

See if stream is disconnected.

Returns
true if stream disconnected.

Definition at line 418 of file stream.h.

◆ overflow()

int ucommon::filestream::overflow ( int  ch)
protected

This streambuf method is used to write the output buffer through the established pipe connection.

Parameters
chchar to push through.
Returns
char pushed through.

Definition at line 781 of file stream.cpp.

References ucommon::StreamBuffer::bufsize, close(), EOF, fd, ucommon::StreamBuffer::pbuf, PUT, and ucommon::fsys::write().

◆ rewind()

void ucommon::filestream::rewind ( void  )

◆ seek()

void ucommon::filestream::seek ( fsys::offset_t  offset)

Seek position.

Definition at line 651 of file stream.cpp.

References ucommon::StreamBuffer::bufsize, fd, ucommon::fsys::seek(), and ucommon::StreamBuffer::sync().

◆ underflow()

int ucommon::filestream::underflow ( void  )
protected

This streambuf method is used to load the input buffer through the established pipe connection.

Returns
char from get buffer, EOF if not connected.

Definition at line 753 of file stream.cpp.

References ucommon::StreamBuffer::bufsize, ucommon::clear(), close(), EOF, fd, ucommon::StreamBuffer::gbuf, GET, and ucommon::fsys::read().

Member Data Documentation

◆ ac

fsys::access_t ucommon::filestream::ac
protected

Definition at line 361 of file stream.h.

Referenced by allocate().

◆ fd

fsys_t ucommon::filestream::fd
protected

Definition at line 360 of file stream.h.

Referenced by close(), filestream(), open(), overflow(), rewind(), seek(), and underflow().


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