home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / strgen.zip / MYSTRGEN.HPP < prev    next >
Text File  |  1996-03-15  |  1KB  |  53 lines

  1.  
  2. #ifndef _MYSTRGEN_
  3.   #define _MYSTRGEN_
  4.  
  5. #ifndef _CUSTOMER_               // replace this with your own header file
  6. #include "customer.hpp"
  7. #endif
  8.  
  9. #ifndef _ISTRGEN_
  10. #include <istrgen.hpp>
  11. #endif
  12.  
  13. #ifndef _ISTRING_
  14. #include <istring.hpp>
  15. #endif
  16.  
  17.  
  18. // change the typedef to point to the object you want
  19. // a string generated for
  20.  
  21. typedef Customer* Element;
  22.  
  23.  class StrgenFn: public IStringGeneratorFn<Element>
  24.   {
  25.    public:
  26.  
  27.     // string generation function - modify this function to return
  28.     // the string generated for your object
  29.  
  30.     IString stringFor(Element const& element)
  31.      { return (element->Name() +
  32.                " " +
  33.                element->Street()) ;
  34.      }
  35.   };
  36.  
  37.  
  38. static StrgenFn strgenfn;     // static global variable which is local
  39.                               // to its translation unit, and has internal
  40.                               // linkage.
  41.                               // This object is required for initializing
  42.                               // the IStringGenerator object
  43.  
  44. class MyStringGen: public IStringGenerator < Element >
  45.   {
  46.     public:
  47.       MyStringGen(): IStringGenerator< Element >
  48.       (IReference< IStringGeneratorFn< Element > > (&strgenfn)) {}
  49.   };
  50.  
  51.  
  52. #endif
  53.