sx360::sxPunchFile Class Reference

#include <sxpunchfile.h>

Collaboration diagram for sx360::sxPunchFile:

Collaboration graph
[legend]
List of all members.


Public Member Functions

  sxPunchFile (ByteMap bmap)
  ~sxPunchFile ()
bool  open (string name, FileSetup setup)
bool  close ()
int  getCardCount ()
sxIterator getIterator () const
const FileSetup getSetup () const
bool  appendRecord (sxRecord *cards)
int  seek (off_t offset, int whence)
unsigned int  getRecordCount ()
off_t  tell ()
bool  read (void *ptr, size_t size)
bool  write (void *ptr, size_t size)

sxPunchFile is the representation of the physical file on disk.  Files can be opened in any of three modes:

READ_ONLY - the file is only available for reading data.  You can change actual values, but any committing to disk will fail.
READ_WRITE - the file is enabled to allow writing back of existing records.
CREATE - the file is only available for writing.

It is important to note that it is not possible to add records on to an existing sxPunchFile.  READ_WRITE works only to modify existing records, not add new ones.  This is because if a file is opened in either READ_ONLY or READ_WRITE an sxIterator is automatically created and retrieves the number of records once when the file is opened.  If you want to add records to an existing sxPunchFile, the preferred method is to open one in READ_ONLY and another in CREATE, copy the records you want by called sxPunchFile::append to the new file.  This also helps to preserve your existing file.

The ability to append existing files may be available in future versions.



Constructor & Destructor Documentation

sxPunchFile::sxPunchFile ( ByteMap  bmap  ) 

Constructor for an sxPunchFile. The parameter is a ByteMap, which if a standard IBM 360 column binary is being used, can be constructed using the default parameters.

sxPunchFile::~sxPunchFile (
 ) 

Destructor for sxPunchFile.


Member Function Documentation

bool sxPunchFile::open ( string  name,


FileSetup  setup  

)


Opens a sxPunchFile.  Returns true is file is open or false if the file cannot be opened.

Parameters:

string name = file name to open.

FileSetup setup = defines how a file should be opened.

bool sxPunchFile::close (
 ) 

Closes the open sxPunchFile.

int sx360::sxPunchFile::getCardCount (
 )  [inline]

Returns the number of cards per record in the file.

sxIterator* sx360::sxPunchFile::getIterator (
 )  const [inline]

Returns the sxIterator that is used to traverse the file if the file was opened in READ_ONLY or READ_WRITE. Otherwise, NULL is returned.

const FileSetup& sx360::sxPunchFile::getSetup (
 )  const [inline]

Returns the FileSetup structure used to create the sxPunchFile.

bool sxPunchFile::appendRecord ( sxRecord cards  ) 

When a file is opened in CREATE mode, this method will write a new record to the end of the file. If the file is not opened in CREATE mode, the return value will be false.

int sxPunchFile::seek ( off_t  offset,


int  whence  

)


Wrapper function for fseeko. No need to a client to call this function.

unsigned int sx360::sxPunchFile::getRecordCount (
 )  [inline]

Returns the number of records in the file.

off_t sx360::sxPunchFile::tell (
 )  [inline]

Returns an off_t to the current offset in the physical file.  off_t is #defined as __int64 on Windows.

bool sx360::sxPunchFile::read ( void *  ptr,


size_t  size  

)

[inline]

Wrapper function for fread.  No need for a client to call this function.

bool sx360::sxPunchFile::write ( void *  ptr,


size_t  size  

)

[inline]

Wrapper function for fwrite.  No need for a client to call this function.


Generated on Fri Jul 27 14:54:01 2007 for sx360 by  doxygen 1.5.2