home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 Mobile / Chip_Mobile_2001.iso / palm / business / printcar / printcar.exe / src / DB / ResourceDatabase.cc < prev    next >
C/C++ Source or Header  |  2000-06-04  |  1KB  |  48 lines

  1. //
  2. //  $Id: ResourceDatabase.cc,v 1.1 2000/06/04 00:51:06 sergey Exp $
  3. //
  4.  
  5. #include <Pilot.h>
  6. #include "ResourceDatabase.h"
  7. #include "Record.h"
  8. #include "DbError.h"
  9. #include "Util/Assert.h"
  10.  
  11.  
  12. namespace DB
  13. {
  14.     // operations
  15.  
  16.     int ResourceDatabase::resourceCount() const
  17.     {
  18.         assert(isOpened());
  19.         return DmNumResources(openRef());
  20.     }
  21.  
  22.     int ResourceDatabase::findResource(long resourceType, int resourceID) const
  23.     {
  24.         assert(isOpened());
  25.         return DmFindResource(openRef(), resourceType, resourceID, 0);
  26.     }
  27.  
  28.     bool ResourceDatabase::readResource(int index, Record& resource) const
  29.     {
  30.         assert(isOpened());
  31.  
  32.         VoidHand resourceHandle = DmGetResourceIndex(openRef(), index);
  33.         if (resourceHandle == 0)
  34.         {
  35.             DbError::readRecordError(__FILE__, __LINE__, DmGetLastErr());
  36.             return false;
  37.         }
  38.  
  39.         return resource.restore(index, resourceHandle);
  40.     }
  41.  
  42.     bool ResourceDatabase::readResource(long resourceType, int resourceID, Record& resource) const
  43.     {
  44.         return readResource(findResource(resourceType, resourceID), resource);
  45.     }
  46. }
  47. // namespace DB
  48.