home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / powergui / profile / viewprof / viewprof.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-10-29  |  1.5 KB  |  60 lines

  1. //************************************************************
  2. // Profile - Profile Viewer Example             
  3. //
  4. // Copyright (C) 1994, Law, Leong, Love, Olson, Tsuji.
  5. // Copyright (c) 1997 John Wiley & Sons, Inc. 
  6. // All Rights Reserved.
  7. //************************************************************
  8. #include <istring.hpp>
  9. #include <iexcept.hpp>
  10. #include <iostream.h>
  11. #include "vprofarg.hpp"
  12. #include "enhprof.hpp"
  13.  
  14.  
  15. int main ( int argc, char *argv[] )
  16.   {
  17.   int
  18.     rc = 0;
  19.   try
  20.     {
  21.     // Get arguments...
  22.     ViewProfileArgs
  23.       args( argc, argv );
  24.     // Open specified profile...
  25.     EnhancedProfile
  26.       *profile = 0;
  27.     switch ( args.profileType() )
  28.       {
  29.       case ViewProfileArgs::system:
  30.         profile = 
  31.           new EnhancedProfile( IProfile::systemProfile() );
  32.         break;
  33.       case ViewProfileArgs::user:
  34.         profile = 
  35.           new EnhancedProfile( IProfile::userProfile() );
  36.         break;
  37.       default:
  38.         profile = 
  39.           new EnhancedProfile( args.profileName(), false );
  40.       }
  41.     // Dump selected app/key data to standard output...
  42.     profile -> displayOn( cout, 
  43.                           args.applicationName(), 
  44.                           args.key() );
  45.     }
  46.   catch ( const IString &msg )
  47.     {
  48.     // Display error message...
  49.     cout << msg << endl;
  50.     rc = 1;
  51.     }
  52.   catch ( const IException &exception )
  53.     {
  54.     // Display report of system-type error...
  55.     cout << "Error: " << exception.text() << endl;
  56.     rc = 2;
  57.     }
  58.   return rc;
  59.   }
  60.