home *** CD-ROM | disk | FTP | other *** search
- #ifndef _IPROFMGR_
- #define _IPROFMGR_
- /*******************************************************************************
- * FILE NAME: IPROFMGR.HPP *
- * *
- * DESCRIPTION: *
- * Declaration of the class(es): *
- * IProfileMgr - Manages the .INI files. *
- * *
- * COPYRIGHT: *
- * (C) Copyright IBM Corporation 1992 *
- * All Rights Reserved *
- * Licensed Materials * Property of IBM *
- * *
- * HISTORY: *
- *$Log: R:/IBMCLASS/IBASEAPP/VCS/IPROFMGR.HPV $ *
- //
- // Rev 1.3 25 Oct 1992 16:58:40 nunn
- // changed library name to ICLUI
- //
- // Rev 1.2 24 Oct 1992 17:38:50 tsuji
- // Format/documentation in the style of the standard header (by Tim Hertz).
- *******************************************************************************/
- #ifndef _IVBASE_
- #include <ivbase.hpp>
- #endif
- #ifndef _IHANDLE_
- #include <ihandle.hpp>
- #endif
-
- // Forward declarations for other classes:
- class IString;
-
- const unsigned long IC_PROFILE = 0;
- const unsigned long IC_USERPROFILE = -1;
- const unsigned long IC_SYSTEMPROFILE = -2;
-
- class IProfileMgr : public IVBase
- /*******************************************************************************
- * This class encapsulates the OS/2 profile management functions. *
- * *
- * The profile stores information using two keys. The major key is called the *
- * application name or "appName". The minor key is called the key name or *
- * "keyName". The appName must be set before using any call that requires *
- * a keyName. The appName is set by using the setAppName call. The keyName *
- * is passed in to all the calls that need it. *
- * *
- * EXAMPLE: *
- * pProfMgr = new IProfileMgr; *
- * pProfMgr->setAppName("My_Profile_Options"); *
- * *
- * // To write information into the profile *
- * pProfMgr->write("My_Name", "Tim"); *
- * pProfMgr->write("My_Age", 25); *
- * *
- * // To read information from the profile *
- * IString Name=pProfMgr->readText("My_Name"); *
- * long Age = pProfMgr->readInteger("My_Age"); *
- *******************************************************************************/
- {
- public:
- /*------------------------ CONSTRUCTORS/DESTRUCTORS ----------------------------
- | There are 4 ways to construct instances of this class: |
- | 1. default |
- | Constructs a profile manager that allows reading from both the user and |
- | the system profiles, and writes to the user profile. |
- | 2. IC_USERPROFILE |
- | Constructs a profile manager that reads and writes to the user profile. |
- | 3. IC_SYSTEMPROFILE |
- | Constructs a profile manager that reads and writes to the system profile.|
- | 4. Filename |
- | Constructs a profile manager that reads and writes to an application |
- | profile. The file is created if it doesn't already exist. |
- ------------------------------------------------------------------------------*/
- IProfileMgr (IProfileHandle hini = (IProfileHandle)IC_PROFILE,
- const char* pszFileName = 0);
- virtual
- ~IProfileMgr ();
-
- /*-------------------------- SETTING THE APPNAME -------------------------------
- | This method sets the application name. The application name is the first |
- | key of two needed to access information in the profile. The second key is |
- | the keyname which is specified on each call that needs it. |
- | setAppName - Sets the AppName to use on all the following calls. |
- ------------------------------------------------------------------------------*/
- void
- setAppName (const char* pszAppName);
-
- /*-------------------------- WRITING INFORMATION -------------------------------
- | These functions provide ways to write information into the profile. The |
- | information can be in the form of a string, number, or binary data. |
- | write - Write information into the profile. |
- ------------------------------------------------------------------------------*/
- void
- write (const char* pszKeyName,
- const char* pszText),
- write (const char* pszKeyName,
- long lNumber),
- write (const char* pszKeyName,
- const void* pvData,
- unsigned long ulDataLen);
-
-
- /*-------------------------- PROFILE ENTRY INFORMATION -------------------------
- | These functions get information about a specific profile entry. |
- | length - returns the length (in bytes) of the data stored. |
- | doesKeyNameExist - returns TRUE if an entry exists for the keyName. |
- ------------------------------------------------------------------------------*/
- unsigned long
- length (const char* pszKeyName) const;
-
- Boolean
- doesKeyNameExist (const char* pszKeyName) const;
-
- /*-------------------------- READ INFORMATION ----------------------------------
- | These functions read information from the profile. |
- | readText - reads the information as a string. |
- | readInteger - reads the information as an integer. |
- | readBinary - reads the information as binary data. |
- ------------------------------------------------------------------------------*/
- IString
- readText (const char* pszKeyName) const;
-
- long
- readInteger (const char* pszKeyName) const;
-
- void*
- readBinary (const char* pszKeyName,
- void* pvData = 0,
- unsigned long ulBufSize = 0) const;
-
- /*-------------------------- DELETE INFORMATION --------------------------------
- | These functions delete information from the profile. |
- | deleteKey - Removes a key from the profile. |
- | deleteAllKeys - Removes all the keys in the AppName. |
- ------------------------------------------------------------------------------*/
- void
- deleteKey (const char* pszKeyName),
- deleteAllKeys ();
-
- /*-------------------------- LIST INFORMATION ----------------------------------
- | These functions return a list of keys from the profile. |
- | appNames - Returns a string containing all the appNames in the profile. |
- | keyNames - Returns a string containing all the keyNames in the profile. |
- ------------------------------------------------------------------------------*/
- IString
- appNames () const,
- keyNames () const;
-
- /*-------------------------- PROFILE NAME --------------------------------------
- | These functions return the names of the files used for the user and system |
- | profiles. |
- | userProfileName - Returns the file name of the user profile. |
- | systemProfileName - Returns the file name of the system profile. |
- ------------------------------------------------------------------------------*/
- IString
- userProfileName () const,
- systemProfileName () const;
-
- private:
- /*------------------------------ DATA MEMBERS ----------------------------------
- | pszClAppName - The application name to use. |
- | hiniCl - The handle of the profile being used. |
- ------------------------------------------------------------------------------*/
- char*
- pszClAppName;
-
- IProfileHandle
- hiniCl;
-
- };
-
- #endif