Pointwise Plugin SDK
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
PwpFileRecord Class Reference

Manages FORTRAN unformatted file records. More...

#include <PwpFile.h>

+ Inheritance diagram for PwpFileRecord:
+ Collaboration diagram for PwpFileRecord:

Public Member Functions

virtual bool beginRecord ()
 Starts an unformatted record. More...
 
virtual bool beginRecord (PWP_UINT32 bytes, PWP_UINT32 count=1)
 Starts a fixed size unformatted record. More...
 
virtual bool endRecord ()
 Ends an unformatted record. More...
 
PwpFilefile ()
 Get this record's file object. More...
 
const PwpFilefile () const
 Get this record's file object. More...
 
virtual void getFmtFieldDouble (int &width, int &prec) const
 
virtual void getFmtFieldSingle (int &width, int &prec) const
 
virtual FormatType getFmtType () const
 
bool getPos (sysFILEPOS &pos) const
 Get the current file position of this record's file object. More...
 
 PwpFileRecord (PwpFile &file, bool doBeginRecord=true)
 Constructor. More...
 
 PwpFileRecord (PwpFile &file, PWP_UINT32 bytes, PWP_UINT32 count=1)
 Constructor. More...
 
virtual void setFmtFieldDouble (const int width, const int prec)
 
virtual void setFmtFieldSingle (const int width, const int prec)
 
virtual void setFmtType (FormatType type)
 
virtual bool write (PWP_UINT32 val, const char *suffix=0, const char *prefix=0)
 Writes a integer value with proper encoding and byte order. More...
 
virtual bool write (const char *val, PWP_INT size=-1, char pad=0)
 Writes a string value. More...
 
virtual bool write (PWP_FLOAT val, const char *suffix=0, const char *prefix=0)
 Writes a floating point value with proper precision, encoding and byte order. More...
 
virtual bool write (PWP_INT64 val, const char *suffix=0, const char *prefix=0)
 Writes a integer value with proper encoding and byte order. More...
 
virtual bool write (PWP_UINT8 val, const char *suffix=0, const char *prefix=0)
 Writes a integer value with proper encoding and byte order. More...
 
virtual bool write (PWP_INT32 val, const char *suffix=0, const char *prefix=0)
 Writes a integer value with proper encoding and byte order. More...
 
virtual bool write (PWP_INT16 val, const char *suffix=0, const char *prefix=0)
 Writes a integer value with proper encoding and byte order. More...
 
virtual bool write (PWP_INT8 val, const char *suffix=0, const char *prefix=0)
 Writes a integer value with proper encoding and byte order. More...
 
virtual bool write (PWP_REAL val, const char *suffix=0, const char *prefix=0)
 Writes a floating point value with proper precision, encoding and byte order. More...
 
virtual bool write (PWP_UINT16 val, const char *suffix=0, const char *prefix=0)
 Writes a integer value with proper encoding and byte order. More...
 
virtual bool write (PWP_UINT64 val, const char *suffix=0, const char *prefix=0)
 Writes a integer value with proper encoding and byte order. More...
 
template<typename T >
bool writeAt (sysFILEPOS pos, const T &val, const char *suffix=0, const char *prefix=0)
 Writes an endian enforced value directly at a given file position. More...
 
virtual ~PwpFileRecord ()
 Destructor. More...
 
- Public Member Functions inherited from PwpWriterInterface
bool writef (PWP_INT size, char pad, const char *fmt,...)
 Writes a formatted string value. More...
 
bool writef (const char *fmt,...)
 Writes a formatted string value. More...
 
virtual ~PwpWriterInterface ()
 Destructor. More...
 

Private Member Functions

PwpFileRecordoperator= (const PwpFileRecord &)
 

Private Attributes

PwpFilefile_
 

Additional Inherited Members

- Public Types inherited from PwpWriterInterface
enum  FormatType {
  FormatG = G_,
  FormatWdPrecG = G_ | Wd_ | Prec_,
  FormatWdG = G_ | Wd_,
  FormatPrecG = G_ | Prec_,
  FormatF = F_,
  FormatWdPrecF = F_ | Wd_ | Prec_,
  FormatWdF = F_ | Wd_,
  FormatPrecF = F_ | Prec_,
  FormatE = E_,
  FormatWdPrecE = E_ | Wd_ | Prec_,
  FormatWdE = E_ | Wd_,
  FormatPrecE = E_ | Prec_
}
 Formatted output types for floating point values. More...
 
- Protected Types inherited from PwpWriterInterface
enum  {
  G_ = 0x00,
  F_ = 0x01,
  E_ = 0x02,
  GFEMask_ = 0x0F,
  Wd_ = 0x10,
  Prec_ = 0x20,
  WdPrec_ = Wd_ | Prec_,
  WPMask_ = 0xF0
}
 Bit flags use to build public FormatX enums. More...
 

Detailed Description

Manages FORTRAN unformatted file records.

The PwpFileRecord class manages all writes to pwpUnformatted records.

Record management is only performed for pwpUnformatted files. For all other modes, PwpFileRecord method calls are passed directly through to the underlying file object.

Sample Usage:

See PwpFile for usage.

Definition at line 903 of file PwpFile.h.

Constructor & Destructor Documentation

PwpFileRecord::PwpFileRecord ( PwpFile file,
bool  doBeginRecord = true 
)

Constructor.

Constructs a PwpFileRecord object bound to the specified file.

Parameters
fileA file object.
doBeginRecordIf true, beginRecord() is called.
Note
Record management is only performed for pwpUnformatted files. For all other modes, PwpFileRecord method calls are passed directly through to the underlying file object.

Definition at line 1366 of file PwpFile.cxx.

References beginRecord().

PwpFileRecord::PwpFileRecord ( PwpFile file,
PWP_UINT32  bytes,
PWP_UINT32  count = 1 
)

Constructor.

Constructs a fixed size PwpFileRecord object bound to the specified file. See PwpWriterInterface::beginRecord(bytes, count) for important performance information. The call to endRecord() will fail if the number of bytes written to the record is not equal to (bytes * count).

Parameters
fileA file object.
bytesdata item size.
countnumber of data items.
Note
This constructor always calls beginRecord(bytes, count).
Record management is only performed for pwpUnformatted files. For all other modes, PwpFileRecord method calls are passed directly through to the underlying file object.

Definition at line 1375 of file PwpFile.cxx.

References beginRecord().

PwpFileRecord::~PwpFileRecord ( )
virtual

Destructor.

Definition at line 1382 of file PwpFile.cxx.

References endRecord(), file_, and PwpFile::isOpen().

Member Function Documentation

bool PwpFileRecord::beginRecord ( )
virtual

Starts an unformatted record.

Starts an unformatted record. If a record is already active, it will be closed.

Returns
true on success.
Note
Records are ignored by all modes except pwpUnformatted.

Implements PwpWriterInterface.

Definition at line 1391 of file PwpFile.cxx.

References PwpFile::beginRecord(), and file_.

Referenced by PwpFileRecord().

bool PwpFileRecord::beginRecord ( PWP_UINT32  bytes,
PWP_UINT32  count = 1 
)
virtual

Starts a fixed size unformatted record.

Starts a fixed size unformatted record. If a record is already active, it will be closed.

Fixed size record I/O is significantly faster than variable sized records. Fixed size records should be used, if possible, when there are large numbers (> ~1e6) of records written to an export file.

The call to endRecord() will fail if the number of bytes written to the record is not equal to (bytes * count).

Returns
true on success.
Note
Records are ignored by all modes except pwpUnformatted.

Implements PwpWriterInterface.

Definition at line 1397 of file PwpFile.cxx.

References PwpFile::beginRecord(), and file_.

bool PwpFileRecord::endRecord ( )
virtual

Ends an unformatted record.

Ends an active record for files opened with pwpUnformatted mode.

Returns
true on success.
Note
Records are ignored by all modes except pwpUnformatted.

Implements PwpWriterInterface.

Definition at line 1403 of file PwpFile.cxx.

References PwpFile::endRecord(), and file_.

Referenced by ~PwpFileRecord().

PwpFile& PwpFileRecord::file ( )
inline

Get this record's file object.

Returns
A reference to the file object.

Definition at line 941 of file PwpFile.h.

References file_.

const PwpFile& PwpFileRecord::file ( ) const
inline

Get this record's file object.

Returns
A const reference to the file object.

Definition at line 947 of file PwpFile.h.

References file_.

void PwpFileRecord::getFmtFieldDouble ( int &  width,
int &  prec 
) const
virtual

Implements PwpWriterInterface.

Definition at line 1510 of file PwpFile.cxx.

References file_, and PwpFile::getFmtFieldDouble().

void PwpFileRecord::getFmtFieldSingle ( int &  width,
int &  prec 
) const
virtual

Implements PwpWriterInterface.

Definition at line 1496 of file PwpFile.cxx.

References file_, and PwpFile::getFmtFieldSingle().

PwpWriterInterface::FormatType PwpFileRecord::getFmtType ( ) const
virtual

Implements PwpWriterInterface.

Definition at line 1525 of file PwpFile.cxx.

References file_, and PwpFile::getFmtType().

bool PwpFileRecord::getPos ( sysFILEPOS pos) const
inline

Get the current file position of this record's file object.

Returns
true on success.

Definition at line 954 of file PwpFile.h.

References file_, and PwpFile::getPos().

PwpFileRecord& PwpFileRecord::operator= ( const PwpFileRecord )
inlineprivate

Definition at line 981 of file PwpFile.h.

void PwpFileRecord::setFmtFieldDouble ( const int  width,
const int  prec 
)
virtual

Implements PwpWriterInterface.

Definition at line 1503 of file PwpFile.cxx.

References file_, and PwpFile::setFmtFieldDouble().

void PwpFileRecord::setFmtFieldSingle ( const int  width,
const int  prec 
)
virtual

Implements PwpWriterInterface.

Definition at line 1489 of file PwpFile.cxx.

References file_, and PwpFile::setFmtFieldSingle().

void PwpFileRecord::setFmtType ( PwpWriterInterface::FormatType  type)
virtual

Implements PwpWriterInterface.

Definition at line 1518 of file PwpFile.cxx.

References file_, and PwpFile::setFmtType().

bool PwpFileRecord::write ( PWP_UINT32  val,
const char *  suffix = 0,
const char *  prefix = 0 
)
virtual

Writes a integer value with proper encoding and byte order.

Parameters
valThe value to write.
suffixString written after val (pwpAscii mode only).
prefixString written before val (pwpAscii mode only).
Returns
true on success.
Note
For pwpBinary and pwpUnformatted modes, byte ordering is enforced.
For pwpUnformatted mode, the record byte count is incremented by sizeof(val).
suffix and prefix are ignored by all modes except pwpAscii.

Implements PwpWriterInterface.

Definition at line 1449 of file PwpFile.cxx.

References file_, and PwpFile::write().

bool PwpFileRecord::write ( const char *  val,
PWP_INT  size = -1,
char  pad = 0 
)
virtual

Writes a string value.

Parameters
valThe string to write.
sizeThe number of string characters to write. If -1, strlen(val) is used.
padIf size > strlen(val), the pad value will be used to fill the remaining characters.
Returns
true on success.
Note
For pwpUnformatted mode, the record byte count is incremented by size or strlen(val) if size is -1.

Implements PwpWriterInterface.

Definition at line 1532 of file PwpFile.cxx.

References file_, and PwpFile::write().

bool PwpFileRecord::write ( PWP_INT8  val,
const char *  suffix = 0,
const char *  prefix = 0 
)
virtual

Writes a integer value with proper encoding and byte order.

Parameters
valThe value to write.
suffixString written after val (pwpAscii mode only).
prefixString written before val (pwpAscii mode only).
Returns
true on success.
Note
For pwpBinary and pwpUnformatted modes, byte ordering is enforced.
For pwpUnformatted mode, the record byte count is incremented by sizeof(val).
suffix and prefix are ignored by all modes except pwpAscii.

Implements PwpWriterInterface.

Definition at line 1433 of file PwpFile.cxx.

References file_, and PwpFile::write().

bool PwpFileRecord::write ( PWP_INT16  val,
const char *  suffix = 0,
const char *  prefix = 0 
)
virtual

Writes a integer value with proper encoding and byte order.

Parameters
valThe value to write.
suffixString written after val (pwpAscii mode only).
prefixString written before val (pwpAscii mode only).
Returns
true on success.
Note
For pwpBinary and pwpUnformatted modes, byte ordering is enforced.
For pwpUnformatted mode, the record byte count is incremented by sizeof(val).
suffix and prefix are ignored by all modes except pwpAscii.

Implements PwpWriterInterface.

Definition at line 1425 of file PwpFile.cxx.

References file_, and PwpFile::write().

bool PwpFileRecord::write ( PWP_UINT16  val,
const char *  suffix = 0,
const char *  prefix = 0 
)
virtual

Writes a integer value with proper encoding and byte order.

Parameters
valThe value to write.
suffixString written after val (pwpAscii mode only).
prefixString written before val (pwpAscii mode only).
Returns
true on success.
Note
For pwpBinary and pwpUnformatted modes, byte ordering is enforced.
For pwpUnformatted mode, the record byte count is incremented by sizeof(val).
suffix and prefix are ignored by all modes except pwpAscii.

Implements PwpWriterInterface.

Definition at line 1457 of file PwpFile.cxx.

References file_, and PwpFile::write().

bool PwpFileRecord::write ( PWP_UINT8  val,
const char *  suffix = 0,
const char *  prefix = 0 
)
virtual

Writes a integer value with proper encoding and byte order.

Parameters
valThe value to write.
suffixString written after val (pwpAscii mode only).
prefixString written before val (pwpAscii mode only).
Returns
true on success.
Note
For pwpBinary and pwpUnformatted modes, byte ordering is enforced.
For pwpUnformatted mode, the record byte count is incremented by sizeof(val).
suffix and prefix are ignored by all modes except pwpAscii.

Implements PwpWriterInterface.

Definition at line 1465 of file PwpFile.cxx.

References file_, and PwpFile::write().

bool PwpFileRecord::write ( PWP_UINT64  val,
const char *  suffix = 0,
const char *  prefix = 0 
)
virtual

Writes a integer value with proper encoding and byte order.

Parameters
valThe value to write.
suffixString written after val (pwpAscii mode only).
prefixString written before val (pwpAscii mode only).
Returns
true on success.
Note
For pwpBinary and pwpUnformatted modes, byte ordering is enforced.
For pwpUnformatted mode, the record byte count is incremented by sizeof(val).
suffix and prefix are ignored by all modes except pwpAscii.

Implements PwpWriterInterface.

Definition at line 1441 of file PwpFile.cxx.

References file_, and PwpFile::write().

bool PwpFileRecord::write ( PWP_INT32  val,
const char *  suffix = 0,
const char *  prefix = 0 
)
virtual

Writes a integer value with proper encoding and byte order.

Parameters
valThe value to write.
suffixString written after val (pwpAscii mode only).
prefixString written before val (pwpAscii mode only).
Returns
true on success.
Note
For pwpBinary and pwpUnformatted modes, byte ordering is enforced.
For pwpUnformatted mode, the record byte count is incremented by sizeof(val).
suffix and prefix are ignored by all modes except pwpAscii.

Implements PwpWriterInterface.

Definition at line 1417 of file PwpFile.cxx.

References file_, and PwpFile::write().

bool PwpFileRecord::write ( PWP_INT64  val,
const char *  suffix = 0,
const char *  prefix = 0 
)
virtual

Writes a integer value with proper encoding and byte order.

Parameters
valThe value to write.
suffixString written after val (pwpAscii mode only).
prefixString written before val (pwpAscii mode only).
Returns
true on success.
Note
For pwpBinary and pwpUnformatted modes, byte ordering is enforced.
For pwpUnformatted mode, the record byte count is incremented by sizeof(val).
suffix and prefix are ignored by all modes except pwpAscii.

Implements PwpWriterInterface.

Definition at line 1409 of file PwpFile.cxx.

References file_, and PwpFile::write().

bool PwpFileRecord::write ( PWP_FLOAT  val,
const char *  suffix = 0,
const char *  prefix = 0 
)
virtual

Writes a floating point value with proper precision, encoding and byte order.

Parameters
valThe value to write.
suffixString written after val (pwpAscii mode only).
prefixString written before val (pwpAscii mode only).
Returns
true on success.
Note
For pwpBinary and pwpUnformatted modes, precision and byte ordering is enforced.
For pwpUnformatted mode, the record byte count is incremented by sizeof((precision)val).
suffix and prefix are ignored by all modes except pwpAscii.

Implements PwpWriterInterface.

Definition at line 1473 of file PwpFile.cxx.

References file_, and PwpFile::write().

bool PwpFileRecord::write ( PWP_REAL  val,
const char *  suffix = 0,
const char *  prefix = 0 
)
virtual

Writes a floating point value with proper precision, encoding and byte order.

Parameters
valThe value to write.
suffixString written after val (pwpAscii mode only).
prefixString written before val (pwpAscii mode only).
Returns
true on success.
Note
For pwpBinary and pwpUnformatted modes, precision and byte ordering is enforced.
For pwpUnformatted mode, the record byte count is incremented by sizeof((precision)val).
suffix and prefix are ignored by all modes except pwpAscii.

Implements PwpWriterInterface.

Definition at line 1481 of file PwpFile.cxx.

References file_, and PwpFile::write().

template<typename T >
bool PwpFileRecord::writeAt ( sysFILEPOS  pos,
const T &  val,
const char *  suffix = 0,
const char *  prefix = 0 
)
inline

Writes an endian enforced value directly at a given file position.

The original file position is restored upon successful return.

Parameters
posThe file position from getPos().
valThe value to write.
suffixString written after val (pwpAscii mode only).
prefixString written before val (pwpAscii mode only).
Returns
true on success.
Note
The pwpUnformatted record length is not changed by this call.
See Also
PwpFile::write(sysFILEPOS, PWP_UINT32, PWP_ENDIANNESS)

Definition at line 971 of file PwpFile.h.

References file_, and PwpFile::writeAt().

Member Data Documentation

PwpFile& PwpFileRecord::file_
private

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