Work Place Shell Programming - Part 3

Written by Chris Palchak

Overview
This is the third article in a series of articles on WPS programming. In this article, the following topics will be covered:
 * Referencing WPS objects from a C++ program,
 * Referencing the extended attributes attached to a WPDataFile child object, and,
 * Saving extended attributes when a file is overwritten.

It is not the intent of this writer to provide full listings of working programs in this article. The purpose of this article is to show the reader how to write C++ code that references WPS objects.

The BarChart Class
In previous article in this series, the wpOpen function was overridden to create a BarChart object. The BarChart object was constructed from somSelf. How does the BarChart class get information about the ChartFile object?

The first part of the constructor for BarChart appears as follows:

Reading the ChartFile
ChartFile objects store stock quotes. The quotes are loaded into memory from the file specified by WPS object. Recall that the ChartFile class inherits from WPDataFile. On the C++ side, QuoteTable uses another class QuoteFile, to handle the I/O for the ChartFile. QuoteFile inherits from the standard C++ fstream class.

QuoteFile Implementation
The only QuoteFile functions that are relevant to the WPS are the constructor and the destructor. In addition, a QuoteTable function, ReplaceTable, will be covered.

Updating extended attributes from C++
One of the features of the BarChart class is that it allows the user to modify data from the chart. By right-clicking on a day's bar, a pop-up menu is displayed that provides the user with a variety of choices. When the BarChart is closed, the user has the option to save their changes. This means that the data in the ChartFile object must be replaced. This also means that the last date for which a quote exists may have been changed and this change must be made to the ChartFile object. The QuoteTable class contains the following function that replaces the QuoteFile.