|
/* Gamelon(tm) File I/O Library Sample Code C++ Language */ /* (C)1994 Menai Corporation(tm) Released for public use */
/* Example 2a. How to put a series of objects into an */ /* empty aggregate using the PreFirst position. */ /* The PreFirst position is defined to be prior to */ /* the first object within the immediately enclosing */ /* aggregate. If the aggregate is empty, PreFirst is */ /* defined to be prior to any potential position of */ /* objects contained within the aggregate. PreFirst */ /* is shown graphically as: */ /* { } */ /* < */ /* Normally, PreFirst is only shown when one or more */ /* Cursors are actually in the PreFirst position. */ /* When in the PreFirst position, a cursor may only */ /* append objects after its current position. Insert, */ /* Replace, Remove and Modify alterations are not */ /* possible from the PreFirst position. The following */ /* API calls may be used to add a series of data */ /* objects from the PreFirst position (assume an */ /* empty file): */
#include <stdlib.h> #include "gfcursor.hpp"
int main(void) { short i = 2; char ch = 'b'; double db = 3.14159; int valid; CURSOR *c = new CURSOR("newfile"); c>eCursorQueryValid(&valid); if (!valid) exit(1); c>eCursorMoveIn(); /* Since aggregate is empty, Cursor moves to the */ /* Null position. Cursor must move to PreFirst or */ /* PostLast in order to make alterations. */ c>eCursorMovePreFirst(); c>eAltAppend(); c>eObjWrite(i); c>eAltAppend(); c>eObjWrite(ch); c>eAltAppend(); c>eObjWrite(db); delete c; return 0; } /* Ending file layout: */ /* { } */ /* [3.14159]['b'][2] */
/* Note that the each Append alteration placed the */ /* object in the location immediately following the */ /* PreFirst position (resulting in the objects being */ /* ordered in the opposite order from the order in */ /* which they were written). */ |
||||||||||||||
| |
||||||||||||||
|
Home | Product | Consulting | Programming | Reviews | Company | Site Map | Guest Book |
||||||||||||||
|
Menai Corporation, 1010 El Camino Real, Suite 300, Menlo Park, California 94025-4335 |
||||||||||||||
|
Copyright © 1996-98 Menai Corporation. All Rights Reserved. Menai, Gamelon and gamelon(stylized) are worldwide trademarks of Menai Corporation, registered in the United States of America, and the .[g] logo is a worldwide trademark of Menai Corporation. All other trademarks are owned by their respective owners. |
||||||||||||||