home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / ool.zip / OOL / source / xprofile.cpp < prev    next >
C/C++ Source or Header  |  1997-04-05  |  2KB  |  84 lines

  1. #include "xprofile.h"
  2.  
  3. /*@ 
  4. @class XProfile
  5. @type overview
  6. @symbol _
  7. @remarks XProfile is a class to handle INI-files.
  8. */
  9.  
  10.  
  11. /*@ XProfile::Read(const char *itemName, const void *buffer, const ULONG size)
  12. @group read/write
  13. @remarks Read from a profile
  14. @parameters 
  15. <t '°' c=2>
  16. °char *itemName    °item name to read
  17. °void *buffer        °buffer for the data to read
  18. °ULONG size            °size of the buffer
  19. </t>
  20. */
  21. BOOL XProfile::Read(const char *itemName, void *buffer, ULONG & size)
  22. {
  23.     return PrfQueryProfileData(hini, (PSZ) (char *) appName, (PSZ) itemName, buffer, &size);
  24. }
  25.  
  26.  
  27.  
  28. /*@ XProfile::Read(const char *itemName, const XString*buffer)
  29. @group read/write
  30. @remarks Read from a profile
  31. @parameters 
  32. <t '°' c=2>
  33. °char *itemName        °item name to read
  34. °XString *buffer        °XString-buffer for the data to read
  35. </t>
  36. */
  37. BOOL XProfile::Read(const char *itemName, XString * string)
  38. {
  39.     ULONG size = 2048;
  40.     BOOL rc = Read(itemName, string->GetBuffer(2048), size);
  41.  
  42.     string->ReleaseBuffer();//size
  43.     return rc;
  44. }
  45.  
  46.  
  47. /*@ XProfile::Write(const char *itemName, const void *buffer, const ULONG size)
  48. @group read/write
  49. @remarks Write to a profile
  50. @parameters 
  51. <t '°' c=2>
  52. °char *itemName    °item name to write
  53. °void *buffer        °buffer with the data to write
  54. °ULONG size            °size of the buffer
  55. </t>
  56. */
  57. BOOL XProfile::Write(const char *itemName, const void *buffer, const ULONG size)
  58. {
  59.     return PrfWriteProfileData(hini, (PSZ) (char *) appName, (PSZ) itemName, (PVOID) buffer, size);
  60. }
  61.  
  62.  
  63. /*@ XProfile::Close()
  64. @group open/close
  65. @remarks close a profile
  66. */
  67.  
  68.  
  69. /*@ XProfile::Open()
  70. @group open/close
  71. @remarks Open a profile/create non existing profile
  72. @parameters <t '°' c=2>
  73.                 °XProcess *  °owner process
  74.             °char *      °application title
  75.             °char *      °filename of the profile (default is OS2.INI )
  76.                 </t>
  77. */
  78. BOOL XProfile::Open(const XProcess * proc, const char *appTitle, const char *fileName)
  79. {
  80.     hini = PrfOpenProfile(proc->hab, (PSZ) fileName);
  81.     appName = appTitle;
  82.     return (hini != 0 ? TRUE : FALSE);
  83. }
  84.