home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / macros / main2.tde < prev    next >
Encoding:
Text File  |  1996-02-22  |  2.2 KB  |  83 lines

  1. <code DEFINE_MAIN>
  2. --
  3. -- sample driver for the collection class guides
  4. --
  5. //-----------------------------------------------------------------------------
  6. // Usage sample.
  7. //-----------------------------------------------------------------------------
  8. IBoolean printItem($ELEMENT_TYPE$ const& t, void*)
  9. {
  10. <if ($ELEMENT_PTR$)>
  11.   cout << *t << endl;
  12. <else>
  13.   cout << t << endl;
  14. </if>
  15.   return true;
  16. }
  17.  
  18. main()
  19. {
  20.    $CLTN_NAME$ i$CLTN_NAME$;
  21.    $CLTN_NAME$::Cursor myCursor(i$CLTN_NAME$);
  22. --
  23. -- Define values for element (key) initialization
  24. --
  25. <define VAL1>"C.Lau"\</define>
  26. <define VAL2>"T.Glover"\</define>
  27. <define VAL3>"C.Piekny"\</define>
  28. <define VAL4>"D.Birsan"\</define>
  29. --
  30. -- Define elements to add
  31. --
  32.  
  33.    // Use the customized constructor. Revise this if necessary.
  34.    $ELEMENT_CLASS$ element1($VAL1$);
  35.    $ELEMENT_CLASS$ element2($VAL2$);
  36.    $ELEMENT_CLASS$ element3($VAL3$);
  37.    $ELEMENT_CLASS$ element4($VAL4$);
  38.  
  39. --
  40. -- Add the elements.
  41. --
  42. <if ($ELEMENT_PTR$)>
  43.    i$CLTN_NAME$.add(&element1);
  44.    i$CLTN_NAME$.add(&element1);
  45.    i$CLTN_NAME$.add(&element2);
  46.    i$CLTN_NAME$.add(&element3);
  47.    i$CLTN_NAME$.add(&element4);
  48. <else>
  49.    i$CLTN_NAME$.add(element1);
  50.    i$CLTN_NAME$.add(element1);
  51.    i$CLTN_NAME$.add(element2);
  52.    i$CLTN_NAME$.add(element3);
  53.    i$CLTN_NAME$.add(element4);
  54. </if>
  55.  
  56.    // List all the items
  57.    i$CLTN_NAME$.allElementsDo(printItem);
  58.    // List the total number of items
  59.    cout << i$CLTN_NAME$.numberOfElements() << " added" << endl;
  60.  
  61.    // Remove a key item
  62. <if ($STACK_TYPE$)>
  63.    i$CLTN_NAME$.pop();
  64. <else>\<if ($QUEUE_TYPE$)>
  65.    i$CLTN_NAME$.removeFirst();
  66. <else>
  67.    myCursor.setToFirst();
  68.    i$CLTN_NAME$.removeAt(myCursor);
  69. </if>\</if>
  70.  
  71.    // List the total number of items
  72.    cout << "After remove, the total number of items is: ";
  73.    cout << i$CLTN_NAME$.numberOfElements() << "\n\n";
  74.  
  75.    // List all the items
  76.    i$CLTN_NAME$.allElementsDo(printItem);
  77. }
  78.  
  79. //------------------------------------------------------------------------------
  80. // COLLECTION CLASSES: End of VisualAge C++ SmartGuide generation
  81. //------------------------------------------------------------------------------
  82. </code DEFINE_MAIN>
  83.