Public Member Functions | List of all members
ustl::fstream Class Reference

Implements file operations. More...

#include <ustl.h>

Inheritance diagram for ustl::fstream:
ustl::ios_base

Public Member Functions

 fstream (void) noexcept
 Default constructor.
 
 fstream (const char *filename, openmode mode=in|out)
 Opens filename in mode.
 
 fstream (int nfd, const char *filename="")
 Attaches to nfd of filename.
 
 ~fstream (void) noexcept
 Destructor. Closes if still open, but without throwing.
 
void open (const char *filename, openmode mode, mode_t perms=0644)
 Opens filename in the given mode. More...
 
void attach (int nfd, const char *filename="")
 Attaches to the given nfd.
 
void detach (void) noexcept
 Detaches from the current fd.
 
void close (void)
 Closes the file and throws on error.
 
void sync (void)
 Synchronizes the file's data and status with the disk.
 
off_t read (void *p, off_t n)
 Reads n bytes into p.
 
off_t readsome (void *p, off_t n)
 Reads at most n bytes into p, stopping when it feels like it.
 
off_t write (const void *p, off_t n)
 Writes n bytes from p.
 
off_t size (void) const
 Returns the file size.
 
off_t seek (off_t n, seekdir whence=beg)
 Moves the current file position to n.
 
off_t pos (void) const noexcept
 Returns the current file position.
 
void stat (struct stat &rs) const
 Get the stat structure.
 
int ioctl (const char *rname, int request, long argument=0)
 Calls the given ioctl. Use IOCTLID macro to pass in both name and request.
 
int ioctl (const char *rname, int request, int argument)
 
int ioctl (const char *rname, int request, void *argument)
 
int fcntl (const char *rname, int request, long argument=0)
 Calls the given fcntl. Use FCNTLID macro to pass in both name and request.
 
int fcntl (const char *rname, int request, int argument)
 
int fcntl (const char *rname, int request, void *argument)
 
void set_nonblock (bool v=true) noexcept
 
memlink mmap (off_t n, off_t offset=0)
 Memory-maps the file and returns a link to it.
 
void munmap (memlink &l)
 Unmaps a memory-mapped area.
 
void msync (memlink &l)
 Synchronizes a memory-mapped area.
 
int fd (void) const
 
bool is_open (void) const
 
off_t tellg (void) const
 
off_t tellp (void) const
 
void seekg (off_t n, seekdir whence=beg)
 
void seekp (off_t n, seekdir whence=beg)
 
void flush (void)
 
const stringname (void) const
 
- Public Member Functions inherited from ustl::ios_base
iostate rdstate (void) const
 
bool bad (void) const
 
bool good (void) const
 
bool fail (void) const
 
bool eof (void) const
 
bool operator! (void) const
 
 operator void * (void) const
 
void clear (iostate v=goodbit)
 
void setstate (iostate v)
 
iostate exceptions (void) const
 
iostate exceptions (iostate v)
 

Additional Inherited Members

- Public Types inherited from ustl::ios_base
enum  fmtflags {
  boolalpha = (1 << 0),
  dec = (1 << 1),
  fixed = (1 << 2),
  hex = (1 << 3),
  internal = (1 << 4),
  left = (1 << 5),
  oct = (1 << 6),
  right = (1 << 7),
  scientific = (1 << 8),
  showbase = (1 << 9),
  showpoint = (1 << 10),
  showpos = (1 << 11),
  skipws = (1 << 12),
  unitbuf = (1 << 13),
  uppercase = (1 << 14),
  adjustfield = (1 << 15),
  basefield = (1 << 16),
  floatfield = (1 << 17)
}
 Used to set parameters for stringstreams. More...
 
enum  openmode_bits {
  in = (1 << 0),
  out = (1 << 1),
  app = (1 << 2),
  ate = (1 << 3),
  binary = (1 << 4),
  trunc = (1 << 5)
}
 For file-based streams, specifies fd mode.
 
enum  seekdir {
  beg,
  cur,
  end
}
 Seek directions, equivalent to SEEK_SET, SEEK_CUR, and SEEK_END.
 
enum  iostate_bits {
  goodbit = 0,
  badbit = (1 << 0),
  eofbit = (1 << 1),
  failbit = (1 << 2)
}
 I/O state bitmasks.
 
typedef uint32_t openmode
 Holds openmode_bits.
 
typedef uint32_t iostate
 Holds iostate_bits for a file stream.
 
typedef file_exception failure
 Thrown by fstream on errors.
 
- Static Public Attributes inherited from ustl::ios_base
static const char c_DefaultDelimiters [16] = DEFAULT_DELIMITERS
 Default word delimiters for stringstreams.
 
- Protected Member Functions inherited from ustl::ios_base
bool set_and_throw (iostate v)
 
void overrun (const char *op, const char *type, uint32_t n, uint32_t p, uint32_t rem)
 Checks that n bytes are available in the stream, or else throws.
 

Detailed Description

Implements file operations.

This is not implemented as a stream, but rather as a base for one. You should use ifstream or ofstream if you want flow operators. Otherwise this only implements functions for binary i/o.

Member Function Documentation

void ustl::fstream::open ( const char *  filename,
openmode  mode,
mode_t  perms = 0644 
)

Opens filename in the given mode.

Warning
The string at filename must exist until the object is closed.

References attach().

Referenced by fstream(), ustl::memblock::read_file(), and ustl::cmemlink::write_file().


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

Generated on Mon Sep 28 2015 17:58:50 for uSTL by Doxygen 1.8.10