Pointwise Plugin SDK
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 (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_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_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_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_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_UINT32 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...
 
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...
 
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 (const char *fmt,...)
 Writes a formatted string value. More...
 
bool writef (PWP_INT size, char pad, 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() [1/2]

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 1386 of file PwpFile.cxx.

References beginRecord().

◆ PwpFileRecord() [2/2]

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 1395 of file PwpFile.cxx.

References beginRecord().

◆ ~PwpFileRecord()

PwpFileRecord::~PwpFileRecord ( )
virtual

Destructor.

Definition at line 1402 of file PwpFile.cxx.

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

Member Function Documentation

◆ beginRecord() [1/2]

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 1411 of file PwpFile.cxx.

References PwpFile::beginRecord(), and file_.

Referenced by PwpFileRecord().

◆ beginRecord() [2/2]

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 1417 of file PwpFile.cxx.

References PwpFile::beginRecord(), and file_.

◆ endRecord()

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 1423 of file PwpFile.cxx.

References PwpFile::endRecord(), and file_.

Referenced by ~PwpFileRecord().

◆ file() [1/2]

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_.

◆ file() [2/2]

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_.

◆ getFmtFieldDouble()

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

Implements PwpWriterInterface.

Definition at line 1530 of file PwpFile.cxx.

References file_, and PwpFile::getFmtFieldDouble().

◆ getFmtFieldSingle()

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

Implements PwpWriterInterface.

Definition at line 1516 of file PwpFile.cxx.

References file_, and PwpFile::getFmtFieldSingle().

◆ getFmtType()

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

Implements PwpWriterInterface.

Definition at line 1545 of file PwpFile.cxx.

References file_, and PwpFile::getFmtType().

◆ getPos()

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().

◆ operator=()

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

Definition at line 981 of file PwpFile.h.

◆ setFmtFieldDouble()

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

Implements PwpWriterInterface.

Definition at line 1523 of file PwpFile.cxx.

References file_, and PwpFile::setFmtFieldDouble().

◆ setFmtFieldSingle()

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

Implements PwpWriterInterface.

Definition at line 1509 of file PwpFile.cxx.

References file_, and PwpFile::setFmtFieldSingle().

◆ setFmtType()

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

Implements PwpWriterInterface.

Definition at line 1538 of file PwpFile.cxx.

References file_, and PwpFile::setFmtType().

◆ write() [1/11]

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 1552 of file PwpFile.cxx.

References file_, and PwpFile::write().

◆ write() [2/11]

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 1493 of file PwpFile.cxx.

References file_, and PwpFile::write().

◆ write() [3/11]

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 1445 of file PwpFile.cxx.

References file_, and PwpFile::write().

◆ write() [4/11]

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 1437 of file PwpFile.cxx.

References file_, and PwpFile::write().

◆ write() [5/11]

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 1429 of file PwpFile.cxx.

References file_, and PwpFile::write().

◆ write() [6/11]

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 1453 of file PwpFile.cxx.

References file_, and PwpFile::write().

◆ write() [7/11]

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 1501 of file PwpFile.cxx.

References file_, and PwpFile::write().

◆ write() [8/11]

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 1477 of file PwpFile.cxx.

References file_, and PwpFile::write().

◆ write() [9/11]

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 1469 of file PwpFile.cxx.

References file_, and PwpFile::write().

◆ write() [10/11]

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 1461 of file PwpFile.cxx.

References file_, and PwpFile::write().

◆ write() [11/11]

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 1485 of file PwpFile.cxx.

References file_, and PwpFile::write().

◆ writeAt()

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

◆ file_

PwpFile& PwpFileRecord::file_
private

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