Views
Foundation Package API Reference Guide
Product Documentation:
Views Documentation Home
List of all members | Public Member Functions | Static Public Member Functions
IlvInputFile Class Reference

Input/Output class. More...

#include <ilviews/graphics/io.h>

Inherits IlvBaseInputFile.

Inherited by IlvViewInputFile.

Public Member Functions

 IlvInputFile (std::istream &stream)
 Constructor. More...
 
virtual void commentRead (const char *commentString)
 Called when a comment is encountered. More...
 
virtual void graphicObjectsRead (IlUInt nGraphicObjects)
 Called just after the graphic objects have been read. More...
 
virtual void palettesRead (IlUInt nPalettes)
 Called just after the palettes have been read. More...
 
virtual IlBoolean parseBlock (const char *blockName)
 Parses a block of the input file. More...
 
IlvGraphicreadNext ()
 Reads a new object from the stream. More...
 
virtual IlvGraphicreadObject ()
 Read an object from the stream. More...
 
IlvGraphicreadObjectBlock (IlInt &number)
 Reads a complete block describing an object. More...
 
virtual IlvGraphic *const * readObjects (IlvDisplay *display, IlUInt &count)
 Reads all the objects from the stream. More...
 
virtual const char * typeOf () const
 Returns the type of this file reader. More...
 
virtual void unknownLineRead (const char *string)
 Called when an unknown line has been read. More...
 

Static Public Member Functions

static IlvGraphicReadObject (IlvDisplay *display, const char *filename)
 Returns the first graphic object of the specified file. More...
 

Detailed Description

Input/Output class.

Library: views

The IlvInputFile class is the main class for reading objects from a stream.

Constructor & Destructor Documentation

◆ IlvInputFile()

IlvInputFile::IlvInputFile ( std::istream &  stream)

Constructor.

This constructor initializes a new IlvInputFile object that is ready to read from the given stream object.

Parameters
streamThe input stream.

Member Function Documentation

◆ commentRead()

virtual void IlvInputFile::commentRead ( const char *  commentString)
virtual

Called when a comment is encountered.

Called when the file reader finds a comment, that is, a line that begins with two slash characters (//). The rest of the line is passed in the parameter commentString.

Parameters
commentStringThe comment.

◆ graphicObjectsRead()

virtual void IlvInputFile::graphicObjectsRead ( IlUInt  nGraphicObjects)
virtual

Called just after the graphic objects have been read.

Called when all the graphic objects stored in this file have been read, so that you can perform operations on them. The total number of objects that have been read is available in the parameter nGraphicObjects.

Parameters
nGraphicObjectsThe number of graphic objects read.

◆ palettesRead()

virtual void IlvInputFile::palettesRead ( IlUInt  nPalettes)
virtual

Called just after the palettes have been read.

Called just after the palettes have been read from the stream. The number of palettes read is indicated by nPalettes.

Parameters
nPalettesThe number of palettes read.

◆ parseBlock()

virtual IlBoolean IlvInputFile::parseBlock ( const char *  blockName)
virtual

Parses a block of the input file.

Called for each block that is read in this input file. It is designed as virtual so that you can add your own blocks in the Rogue
Wave Views data files. The blocks are written by the associated IlvOutputFile (usually in the IlvOutputFile::saveMoreInfo() function). Each block is identified by a word called the block identifier. This string must be the first word of a new line (which is usually the case since previous blocks should end with a new line), and must start with a letter.

The Rogue Wave Views convention is to have every block identifier be a concatenation of capitalized words.
The block identifier is provided in blockName so that you can compare this string with that of your private block identifier. The input stream pointer is located just after the block identifier, so that you can start reading your block's data.
This function returns IlFalse if no block identifier matches blockName for that particular IlvInputFile subclass. In your implementations, you should return the result of calling the parent class' parseBlock() function, so that parent classes can watch for their own block identifiers.

Parameters
blockNameThe block name.
Returns
IlTrue if the block was read, IlFalse otherwise.

◆ readNext()

IlvGraphic* IlvInputFile::readNext ( )

Reads a new object from the stream.

Reads a new object from the associated stream and returns that object. That is, it reads the palette index and the class name of the object from the stream; then the specific read() function for this class is called so it can read its own information to create a new object.
readNext() performs the opposite task of the operator<< of the IlvOutputFile class.

◆ readObject()

virtual IlvGraphic* IlvInputFile::readObject ( )
virtual

Read an object from the stream.

Reads a new object description by means of a call to the member function readObjectBlock(). It needs to be overloaded for you to get specific object information.
This operation is the exact opposite of the one performed by the member function IlvOutputFile::writeObject() of the IlvOutputFile class.
The version of the member function readObject() that is defined for a given subtype of IlvInputFile must strictly match the one you use for the subtype of the IlvOutputFile class you used when saving the objects.
A typical implementation of the member function readObject() is:

IlvGraphic*
SubTypeOfInputFile::readObject()
{
    // Read whatever is saved before the object description block
    // by means of "getStream() >> ??" calls
    IlInt index;
    IlvGraphic* object = readObjectBlock(index);
    // Read whatever is saved after the object description block
    // by means of "getStream() >> ??" calls
    return object;
}
Returns
The object read.

◆ ReadObject()

static IlvGraphic* IlvInputFile::ReadObject ( IlvDisplay display,
const char *  filename 
)
static

Returns the first graphic object of the specified file.

Parameters
displayThe connection to the display.
filenameThe file name.
Returns
The first graphic object read in the file, or 0 if the file does not contain any object or if the file cannot be opened.

◆ readObjectBlock()

IlvGraphic* IlvInputFile::readObjectBlock ( IlInt number)

Reads a complete block describing an object.

Reads a complete block describing an object. It gets specific information for the object, and then calls the member function readNext() to actually create the object. The new object is then returned and number is set to this object's index in the file.

Parameters
numberThe index of the object in the file.
Returns
The object read.

◆ readObjects()

virtual IlvGraphic* const* IlvInputFile::readObjects ( IlvDisplay display,
IlUInt count 
)
virtual

Reads all the objects from the stream.

Reads in a complete Rogue Wave Views file and returns an array of pointers to the created objects. You should never delete the array as it is internally maintained.
readObjects() performs the opposite task of the member function IlvOutputFile::saveObjects() used with the IlvOutputFile class. Read success status must be checked in the holder. Objects are properly loaded if inputFile->getHolder()->getError() == 0.

Parameters
displayThe connection to the display.
countThe size of the returned array.
Returns
An array of count graphic objects.

◆ typeOf()

virtual const char* IlvInputFile::typeOf ( ) const
virtual

Returns the type of this file reader.

Returns a string that contains the class name of this file reader. It is used only for message output purposes.

Returns
A string that contains the class name of this file reader.

◆ unknownLineRead()

virtual void IlvInputFile::unknownLineRead ( const char *  string)
virtual

Called when an unknown line has been read.

Called when a block identifier is expected and an invalid identifier is found. This happens if a block has just ended and the next line begins with a numerical value. The entire line is available in string. This function is provided so you can still read data files that were produced with older versions of Rogue Wave Views that did not need block descriptors.

Parameters
stringThe unknown line.