class PStructuredFile: public PFile

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

Inheritance:


Public

[more] Construction
[more] Structured I/O functions
[more] Structure definition functions

Protected Fields

[more]PINDEX structureSize
Number of bytes in structure.
[more]Element* structure
Array of elements in the structure.
[more]PINDEX numElements
Number of elements in the array.


Inherited from PFile:

Public

Overrides from class PObject

Overrides from class PChannel

File manipulation functions

File channel functions

Protected Fields

oPFilePath path
oBOOL removeOnClose


Inherited from PChannel:

Public Methods

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

Public

Information functions

Reading functions

Writing functions

Miscellaneous functions

Error functions

Protected Fields

oint os_handle
oErrors lastErrorCode[NumErrorGroups+1]
oint lastErrorNumber[NumErrorGroups+1]
oPINDEX lastReadCount
oPINDEX lastWriteCount
oPTimeInterval readTimeout
oPTimeInterval writeTimeout

Protected Methods

ovirtual BOOL ConvertOSError( int libcReturnValue, ErrorGroup group = LastGeneralError )
oBOOL SetErrorValues( Errors errorCode, int osError, ErrorGroup group = LastGeneralError )
oint ReadCharWithTimeout( PTimeInterval & timeout )


Inherited from PObject:

Public

Run Time Type functions

Comparison functions

I/O functions


Documentation

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.

o Construction

o PStructuredFile()
Create a structured file object but do not open it. It does not initially have a valid file name. However, an attempt to open the file using the PFile::Open() function will generate a unique temporary file.

The initial structure size is one byte.

o PStructuredFile( OpenMode mode, int opts = ModeDefault )
Create a unique temporary file name, and open the file in the specified mode and using the specified options. Note that opening a new, unique, temporary file name in ReadOnly mode will always fail. This would only be usefull in a mode and options that will create the file.

The PChannel::IsOpen() function may be used after object construction to determine if the file was successfully opened.

Parameters:
mode - Mode in which to open the file.
opts - OpenOptions enum for open operation.

o PStructuredFile( const PFilePath & name, OpenMode mode = ReadWrite, int opts = ModeDefault )
Create a structured file object with the specified name and open it in the specified mode and with the specified options.

The PChannel::IsOpen() function may be used after object construction to determine if the file was successfully opened.

Parameters:
name - Name of file to open.
mode - Mode in which to open the file.
opts - OpenOptions enum for open operation.

o Structured I/O functions

oBOOL Read( void * buffer )
Read a sequence of bytes into the specified buffer, translating the structure according to the specification made in the SetStructure() function.

Returns:
TRUE if the structure was successfully read.
Parameters:
buffer - Pointer to structure to receive data.

oBOOL Write( const void * buffer )
Write a sequence of bytes into the specified buffer, translating the structure according to the specification made in the SetStructure() function.

Returns:
TRUE if the structure was successfully written.
Parameters:
buffer - Pointer to structure to write data from.

o Structure definition functions

oPINDEX GetStructureSize()
Get the size of each structure in the file.

Returns:
number of bytes in a structure.

oenum ElementType
All element types in a structure

o Character
Element is a single character.

o Integer16
Element is a 16 bit integer.

o Integer32
Element is a 32 bit integer.

o Integer64
Element is a 64 bit integer.

o Float32
Element is a 32 bit IEE floating point number.

o Float64
Element is a 64 bit IEE floating point number.

o Float80
Element is a 80 bit IEE floating point number.

ostruct Element
Elements in the structure definition.

oElementType type
Type of element in structure.

oPINDEX count
Count of elements of this type.

ovoid SetStructure( Element * structure, PINDEX numElements )
Set the structure of each record in the file.
Parameters:
structure - Array of structure elements
numElements - Number of structure elements in structure.

oPINDEX structureSize
Number of bytes in structure.

oElement* structure
Array of elements in the structure.

oPINDEX numElements
Number of elements in the array.


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.