home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / listpm3.zip / source / ltprof.cpp < prev    next >
C/C++ Source or Header  |  1996-07-08  |  2KB  |  66 lines

  1. /*
  2.     listPM list files under Presentation Manager. Uses Open Class Libarary.
  3.     Copyright (C) 1996  Paul Elliott
  4.  
  5.     This program is free software; you can redistribute it and/or modify
  6.     it under the terms of the GNU General Public License as published by
  7.     the Free Software Foundation; either version 2 of the License, or
  8.     (at your option) any later version.
  9.  
  10.     This program is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.     GNU General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU General Public License
  16.     along with this program; if not, write to the Free Software
  17.     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  18.  
  19.     Paul Elliott
  20.     3987 South Gessner #224
  21.     Houston Tx 77063
  22.     Paul.Elliott@Hrnowl.LoneStar.Org
  23. */
  24. #include "LtProf.hpp"
  25.  
  26. #include <iapp.hpp>
  27. #include <iexcbase.hpp>
  28. #include <iexcept.hpp>
  29.  
  30.  
  31. #include <string.h>
  32. #include <stdlib.h>
  33.  
  34. // constructor for profile storage. create an application profile.
  35. // and store the Key.
  36. ProfStorage::ProfStorage(const IString& app_name,
  37.                          const IString& user_file_id,const IString& id ) :
  38. profile( app_name, user_file_id ),
  39. key(id)
  40. {
  41. };
  42.  
  43. // Read raw data from the profile.
  44. void ProfStorage::read ( char * buf,int count)
  45. {
  46.     IString str= profile.elementWithKey(key);
  47.  
  48.     // if data found is wrong length, throw exception.
  49.     IASSERTPARM( str.length() == count);
  50.  
  51.     // move the bytes to user.
  52.     memmove(buf,(char*)str,count);
  53.  
  54. };
  55.  
  56. // write raw data to the profile.
  57. void ProfStorage::write (const char * buf,int count)
  58. {
  59.  
  60.     // form a string from the raw data.
  61.     IString str(buf,count);
  62.  
  63.     // and write the string to the profile.
  64.     profile.addOrReplaceElementWithKey(key,str);
  65. };
  66.