Logo Search packages:      
Sourcecode: pwlib version File versions  Download package

PStructuredFile Class Reference

#include <sfile.h>

Inheritance diagram for PStructuredFile:

PFile PChannel PObject

List of all members.


Detailed Description

A class representing a a structured file that is portable accross CPU architectures (as in the XDR protocol).

This differs from object serialisation in that the access is always to a disk file and is random access. It would primarily be used for database type applications.

Definition at line 107 of file sfile.h.


Comparison functions

enum  Comparison { LessThan = -1, EqualTo = 0, GreaterThan = 1 }
virtual Comparison CompareObjectMemoryDirect (const PObject &obj) const
bool operator!= (const PObject &obj) const
bool operator< (const PObject &obj) const
bool operator<= (const PObject &obj) const
bool operator== (const PObject &obj) const
bool operator> (const PObject &obj) const
bool operator>= (const PObject &obj) const

Structure definition functions

enum  ElementType {
  Character, Integer16, Integer32, Integer64,
  Float32, Float64, Float80, NumElementTypes
}
 All element types in a structure. More...
PINDEX GetStructureSize ()
void SetStructure (Element *structure, PINDEX numElements)

Error functions

enum  ErrorGroup { LastReadError, LastWriteError, LastGeneralError, NumErrorGroups }
enum  Errors {
  NoError, NotFound, FileExists, DiskFull,
  AccessDenied, DeviceInUse, BadParameter, NoMemory,
  NotOpen, Timeout, Interrupted, BufferTooSmall,
  Miscellaneous, ProtocolFailure, NumNormalisedErrors
}
Errors GetErrorCode (ErrorGroup group=NumErrorGroups) const
int GetErrorNumber (ErrorGroup group=NumErrorGroups) const
virtual PString GetErrorText (ErrorGroup group=NumErrorGroups) const
static PString GetErrorText (Errors lastError, int osError=0)

File channel functions

enum  FilePositionOrigin { Start = SEEK_SET, Current = SEEK_CUR, End = SEEK_END }
 Options for the origin in setting the file position. More...
const PFilePathGetFilePath () const
BOOL GetInfo (PFileInfo &info)
virtual off_t GetLength () const
virtual off_t GetPosition () const
BOOL IsEndOfFile () const
virtual BOOL Open (const PFilePath &name, OpenMode mode=ReadWrite, int opts=ModeDefault)
virtual BOOL Open (OpenMode mode=ReadWrite, int opts=ModeDefault)
void SetFilePath (const PString &path)
virtual BOOL SetLength (off_t len)
BOOL SetPermissions (int permissions)
virtual BOOL SetPosition (off_t pos, FilePositionOrigin origin=Start)
static BOOL GetInfo (const PFilePath &name, PFileInfo &info)
static BOOL SetPermissions (const PFilePath &name, int permissions)

Miscellaneous functions

enum  ShutdownValue { ShutdownRead = 0, ShutdownWrite = 1, ShutdownReadAndWrite = 2 }
void AbortCommandString ()
BOOL SendCommandString (const PString &command)
BOOL SetBufferSize (PINDEX newSize)
virtual BOOL Shutdown (ShutdownValue option)

Scattered read/write functions

typedef std::vector< SliceVectorOfSlice
virtual BOOL Read (const VectorOfSlice &slices)
virtual BOOL Write (const VectorOfSlice &slices)

File manipulation functions

BOOL Access (OpenMode mode)
BOOL Copy (const PFilePath &newname, BOOL force=FALSE)
BOOL Exists () const
BOOL Move (const PFilePath &newname, BOOL force=FALSE)
BOOL Remove (BOOL force=FALSE)
BOOL Rename (const PString &newname, BOOL force=FALSE)
static BOOL Access (const PFilePath &name, OpenMode mode)
static BOOL Copy (const PFilePath &oldname, const PFilePath &newname, BOOL force=FALSE)
static BOOL Exists (const PFilePath &name)
static BOOL Move (const PFilePath &oldname, const PFilePath &newname, BOOL force=FALSE)
static BOOL Remove (const PFilePath &name, BOOL force=FALSE)
static BOOL Rename (const PFilePath &oldname, const PString &newname, BOOL force=FALSE)

Run Time Type functions

virtual const char * GetClass (unsigned=0) const
virtual BOOL InternalIsDescendant (const char *clsName) const
BOOL IsClass (const char *cls) const
static const char * Class ()

I/O functions

virtual void PrintOn (ostream &strm) const
virtual void ReadFrom (istream &strm)
ostream & operator<< (ostream &strm, const PObject &obj)
istream & operator>> (istream &strm, PObject &obj)

Public Types

enum  PXBlockType { PXReadBlock, PXWriteBlock, PXAcceptBlock, PXConnectBlock }
Construction
enum  OpenMode { ReadOnly, WriteOnly, ReadWrite }
enum  OpenOptions {
  ModeDefault = -1, MustExist = 0, Create = 1, Truncate = 2,
  Exclusive = 4, Temporary = 8, DenySharedRead = 16, DenySharedWrite = 32
}

Public Member Functions

Miscellaneous functions
virtual PObjectClone () const
Overrides from class PChannel
virtual BOOL Close ()
virtual PString GetName () const
Overrides from class PObject
Comparison Compare (const PObject &obj) const
Information functions
virtual PChannelGetBaseReadChannel () const
virtual PChannelGetBaseWriteChannel () const
int GetHandle () const
virtual BOOL IsOpen () const
Reading functions
virtual PINDEX GetLastReadCount () const
PTimeInterval GetReadTimeout () const
virtual void OnReadComplete (void *buf, PINDEX len)
virtual BOOL ReadAsync (void *buf, PINDEX len)
BOOL ReadBlock (void *buf, PINDEX len)
virtual int ReadChar ()
PString ReadString (PINDEX len)
void SetReadTimeout (const PTimeInterval &time)
Writing functions
virtual PINDEX GetLastWriteCount () const
PTimeInterval GetWriteTimeout () const
virtual void OnWriteComplete (const void *buf, PINDEX len)
void SetWriteTimeout (const PTimeInterval &time)
virtual BOOL WriteAsync (const void *buf, PINDEX len)
BOOL WriteChar (int c)
BOOL WriteString (const PString &str)
Overrides from class PObject
virtual PINDEX HashFunction () const
Construction
 PStructuredFile (const PFilePath &name, OpenMode mode=ReadWrite, int opts=ModeDefault)
 PStructuredFile (OpenMode mode, int opts=ModeDefault)
 PStructuredFile ()
Structured I/O functions
BOOL Read (void *buffer)
BOOL Write (const void *buffer)

Static Public Member Functions

static BOOL ConvertOSError (int libcReturnValue, Errors &lastError, int &osError)

Protected Member Functions

virtual BOOL ConvertOSError (int libcReturnValue, ErrorGroup group=LastGeneralError)
int PXClose ()
BOOL PXSetIOBlock (PXBlockType type, const PTimeInterval &timeout)
int ReadCharWithTimeout (PTimeInterval &timeout)
BOOL ReceiveCommandString (int nextChar, const PString &reply, PINDEX &pos, PINDEX start)
BOOL SetErrorValues (Errors errorCode, int osError, ErrorGroup group=LastGeneralError)

Protected Attributes

PString channelName
Errors lastErrorCode [NumErrorGroups+1]
 The platform independant error code.
int lastErrorNumber [NumErrorGroups+1]
 The operating system error number (eg as returned by errno).
PINDEX lastReadCount
 Number of byte last read by the Read() function.
PINDEX lastWriteCount
 Number of byte last written by the Write() function.
PINDEX numElements
 Number of elements in the array.
int os_handle
 The operating system file handle return by standard open() function.
PFilePath path
 The fully qualified path name for the file.
PXBlockType px_lastBlockType
PThreadpx_readThread
PMutex px_selectMutex
PThreadpx_selectThread
PMutex px_threadMutex
PMutex px_writeMutex
PThreadpx_writeThread
PTimeInterval readTimeout
 Timeout for read operations.
BOOL removeOnClose
 File is to be removed when closed.
Elementstructure
 Array of elements in the structure.
PINDEX structureSize
 Number of bytes in structure.
PTimeInterval writeTimeout
 Timeout for write operations.

Private Member Functions

 PCLASSINFO (PStructuredFile, PFile)
BOOL Read (void *buf, PINDEX len)
BOOL Write (const void *buf, PINDEX len)

Classes

struct  Element
 Elements in the structure definition. More...

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

Generated by  Doxygen 1.6.0   Back to index