MIffFile Class Reference

#include <MIffFile.h>

Class Description

Read file images stored on disk.

This class provides a simple C++ interface to the IFF i/o library (flib). A class called MIffTag is used to create the 4 byte tags that are used to distinguish the different block types within an IFF file.

+ Examples:

Public Member Functions

 MIffFile ()
 Default class constructor.
 
 MIffFile (const MString &fileName)
 Alternate class constructor. More...
 
virtual ~MIffFile ()
 Destructor.
 
MStatus open (const MString &fileName)
 Opens the file for reading. More...
 
MStatus close ()
 Close the currently open file. More...
 
bool isActive () const
 Is the file currently active? More...
 
MStatus beginReadGroup (MIffTag &id, MIffTag &type)
 Opens a group for reading. More...
 
MStatus endReadGroup ()
 Closes group currently being read, skipping remaining data (including nested groups). More...
 
const void * getChunk (MIffTag &chunkTag, unsigned *byteCount)
 Opens a chunk for reading. More...
 
MStatus beginGet (MIffTag &chunkTag, unsigned *byteCount)
 Begin grabbing the data. More...
 
MStatus endGet ()
 Finish grabbing the data. More...
 
int get (void *buf, unsigned byteCount, MStatus *stat=NULL)
 Attempt to read 'byteCount' bytes from the file into the buffer pointed to by buf. More...
 
MStatus iffGetShort (short int &result)
 Grabs a short from the active file. More...
 
MStatus iffGetInt (int &result)
 Grabs an integer from the active file. More...
 
MStatus iffGetFloat (float &result)
 Grabs a float from the active file. More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 

Constructor & Destructor Documentation

MIffFile ( const MString fileName)

Alternate class constructor.

Opens the specified file for reading.

Parameters
[in]fileNameThe file name (full path).

Member Function Documentation

MStatus open ( const MString fileName)

Opens the file for reading.

Parameters
[in]fileNameThe file name (full path).
Returns
  • MS::kSuccess if the open was successful,
  • MS::kFailure otherwise.
MStatus close ( )

Close the currently open file.

Returns
  • MS::kSuccess if the close was successful.
  • MS::kFailure Invalid object.
+ Examples:
bool isActive ( ) const

Is the file currently active?

Returns
True if the file is active, false otherwise.
MStatus beginReadGroup ( MIffTag id,
MIffTag type 
)

Opens a group for reading.

A group is composed of several chunks (sub-groups). Provides the id and type of the current group. Can be followed by several calls to chunk reading functions or to nested beginReadGroup(...) calls if needed (depending on the file structure). The function endReadGroup(...) is used to closed a group skipping remaining data (including nested groups).

Parameters
[out]idid of the group being read
[out]typetype of the group being read
Returns
  • MS::kSuccess if the operation was successful,
  • MS::kFailure otherwise.
MStatus endReadGroup ( )

Closes group currently being read, skipping remaining data (including nested groups).

Returns
  • MS::kSuccess if the close was successful
  • MS::kFailure otherwise.
const void * getChunk ( MIffTag chunkTag,
unsigned *  byteCount 
)

Opens a chunk for reading.

A chunk is a block of unstructured data with an associated tag.

Parameters
[out]chunkTagchunk's associated tag
[out]byteCountnumber of bytes in the chunk
Returns
  • Returns a pointer to the data, the content of which should not be modified.
  • NULL if the read was not successful.
MStatus beginGet ( MIffTag chunkTag,
unsigned *  byteCount 
)

Begin grabbing the data.

Parameters
[out]chunkTagtag of current chunk
[out]byteCountnumber of bytes in the chunk
Returns
MS::kSuccess if the read was successful, MS::kFailure otherwise.
MStatus endGet ( )

Finish grabbing the data.

Returns
MS::kSuccess if successful, MS::kFailure otherwise.
int get ( void *  buf,
unsigned  byteCount,
MStatus ReturnStatus = NULL 
)

Attempt to read 'byteCount' bytes from the file into the buffer pointed to by buf.

Parameters
[out]bufpointer to buffer in which to store the data read from the file.
[in]byteCountmaximum number of bytes that buf can hold
[out]ReturnStatusstatus code
Returns
Number of bytes read if successful.
Status Codes:
  • MS::kSuccess Operation successful
  • MS::kFailure Read failure has occurred.
MStatus iffGetShort ( short int &  result)

Grabs a short from the active file.

Parameters
[out]resultthe short value read from the file
Returns
  • MS::kSuccess if the open was successful,
  • MS::kFailure otherwise.
MStatus iffGetInt ( int &  result)

Grabs an integer from the active file.

Parameters
[out]resultthe int value read from the file
Returns
  • MS::kSuccess if the open was successful,
  • MS::fFailure otherwise.
MStatus iffGetFloat ( float &  result)

Grabs a float from the active file.

Parameters
[out]resultthe float value read from the file
Returns
  • MS::kSuccess if the open was successful
  • MS::kFailure Invalid object or read.
const char * className ( )
static

Returns the name of this class.

Returns
The name of this class.

The documentation for this class was generated from the following files:
  • MIffFile.h
  • MIffFile.cpp