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

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