Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

config.h

Go to the documentation of this file.
00001 /*
00002  * config.h
00003  *
00004  * Application/System configuration access class.
00005  *
00006  * Portable Windows Library
00007  *
00008  * Copyright (c) 1993-1998 Equivalence Pty. Ltd.
00009  *
00010  * The contents of this file are subject to the Mozilla Public License
00011  * Version 1.0 (the "License"); you may not use this file except in
00012  * compliance with the License. You may obtain a copy of the License at
00013  * http://www.mozilla.org/MPL/
00014  *
00015  * Software distributed under the License is distributed on an "AS IS"
00016  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
00017  * the License for the specific language governing rights and limitations
00018  * under the License.
00019  *
00020  * The Original Code is Portable Windows Library.
00021  *
00022  * The Initial Developer of the Original Code is Equivalence Pty. Ltd.
00023  *
00024  * Portions are Copyright (C) 1993 Free Software Foundation, Inc.
00025  * All Rights Reserved.
00026  *
00027  * Contributor(s): ______________________________________.
00028  *
00029  * $Log: config.h,v $
00030  * Revision 1.26  2004/01/06 21:16:38  csoutheren
00031  * Added "virtual" keyword to methods to allow descendant classes.
00032  * Thanks to Cristian Bullokles for pointing out this issue
00033  *
00034  * Revision 1.25  2003/09/17 05:41:58  csoutheren
00035  * Removed recursive includes
00036  *
00037  * Revision 1.24  2003/09/17 01:18:02  csoutheren
00038  * Removed recursive include file system and removed all references
00039  * to deprecated coooperative threading support
00040  *
00041  * Revision 1.23  2002/09/16 01:08:59  robertj
00042  * Added #define so can select if #pragma interface/implementation is used on
00043  *   platform basis (eg MacOS) rather than compiler, thanks Robert Monaghan.
00044  *
00045  * Revision 1.22  2001/05/22 12:49:32  robertj
00046  * Did some seriously wierd rewrite of platform headers to eliminate the
00047  *   stupid GNU compiler warning about braces not matching.
00048  *
00049  * Revision 1.21  2000/05/25 11:07:26  robertj
00050  * Added PConfig::HasKey() function to determine if value actually set.
00051  *
00052  * Revision 1.20  1999/03/09 02:59:49  robertj
00053  * Changed comments to doc++ compatible documentation.
00054  *
00055  * Revision 1.19  1999/02/16 08:07:11  robertj
00056  * MSVC 6.0 compatibility changes.
00057  *
00058  * Revision 1.18  1998/10/30 12:23:55  robertj
00059  * Added ability to get all key values as a dictionary.
00060  *
00061  * Revision 1.17  1998/09/23 06:20:21  robertj
00062  * Added open source copyright license.
00063  *
00064  * Revision 1.16  1998/01/26 00:29:26  robertj
00065  * Added functions to get/set 64bit integers from a PConfig.
00066  *
00067  * Revision 1.15  1997/08/07 11:58:01  robertj
00068  * Added ability to get registry data from other applications and anywhere in system registry.
00069  *
00070  * Revision 1.14  1996/02/25 02:50:33  robertj
00071  * Added consts to all GetXxxx functions.
00072  *
00073  * Revision 1.13  1996/01/28 14:10:10  robertj
00074  * Added time functions to PConfig.
00075  *
00076  * Revision 1.12  1995/12/10 11:54:30  robertj
00077  * Added WIN32 registry support for PConfig objects.
00078  *
00079  * Revision 1.11  1995/03/14 12:41:12  robertj
00080  * Updated documentation to use HTML codes.
00081  *
00082  * Revision 1.10  1995/01/27  11:06:20  robertj
00083  * Changed single string default constructor to be section name not file name.
00084  *
00085  * Revision 1.9  1994/12/12  10:11:59  robertj
00086  * Documentation.
00087  *
00088  * Revision 1.8  1994/08/23  11:32:52  robertj
00089  * Oops
00090  *
00091  * Revision 1.7  1994/08/22  00:46:48  robertj
00092  * Added pragma fro GNU C++ compiler.
00093  *
00094  * Revision 1.6  1994/08/21  23:43:02  robertj
00095  * Removed default argument when of PString type (MSC crashes).
00096  *
00097  * Revision 1.5  1994/07/27  05:58:07  robertj
00098  * Synchronisation.
00099  *
00100  * Revision 1.4  1994/06/25  11:55:15  robertj
00101  * Unix version synchronisation.
00102  *
00103  * Revision 1.3  1994/01/03  04:42:23  robertj
00104  * Mass changes to common container classes and interactors etc etc etc.
00105  *
00106  * Revision 1.2  1993/07/14  12:49:16  robertj
00107  * Fixed RCS keywords.
00108  *
00109  */
00110 
00111 
00112 #ifndef _PCONFIG
00113 #define _PCONFIG
00114 
00115 #ifdef P_USE_PRAGMA
00116 #pragma interface
00117 #endif
00118 
00119 class PXConfig;
00120 
00141 class PConfig : public PObject
00142 {
00143   PCLASSINFO(PConfig, PObject);
00144 
00145   public:
00150     enum Source {
00155       Environment,
00161       System,
00170       Application,
00171       NumSources
00172     };
00173 
00179     PConfig(
00180       Source src = Application  
00181     );
00183     PConfig(
00184       Source src,               
00185       const PString & appname   
00186     );
00188     PConfig(
00189       Source src,               
00190       const PString & appname,  
00191       const PString & manuf     
00192     );
00194     PConfig(
00195       const PString & section,  
00196       Source src = Application  
00197     );
00199     PConfig(
00200       const PString & section,  
00201       Source src,               
00202       const PString & appname   
00203     );
00205     PConfig(
00206       const PString & section,  
00207       Source src,               
00208       const PString & appname,  
00209       const PString & manuf     
00210     );
00212     PConfig(
00213       const PFilePath & filename, 
00214       const PString & section     
00215     );
00217 
00227     virtual void SetDefaultSection(
00228       const PString & section  
00229     );
00230 
00240     virtual PString GetDefaultSection() const;
00241 
00250     virtual PStringList GetSections() const;
00251 
00257     virtual PStringList GetKeys() const;
00259     virtual PStringList GetKeys(
00260       const PString & section   
00261     ) const;
00262 
00268     virtual PStringToString GetAllKeyValues() const;
00270     virtual PStringToString GetAllKeyValues(
00271       const PString & section   
00272     ) const;
00273 
00274 
00281     virtual void DeleteSection();
00283     virtual void DeleteSection(
00284       const PString & section   
00285     );
00286 
00295     virtual void DeleteKey(
00296       const PString & key       
00297     );
00299     virtual void DeleteKey(
00300       const PString & section,  
00301       const PString & key       
00302     );
00303 
00312     virtual BOOL HasKey(
00313       const PString & key       
00314     ) const;
00316     virtual BOOL HasKey(
00317       const PString & section,  
00318       const PString & key       
00319     ) const;
00321 
00334     virtual PString GetString(
00335       const PString & key       
00336     ) const;
00338     virtual PString GetString(
00339       const PString & key,      
00340       const PString & dflt      
00341     ) const;
00343     virtual PString GetString(
00344       const PString & section,  
00345       const PString & key,      
00346       const PString & dflt      
00347     ) const;
00348 
00352     virtual void SetString(
00353       const PString & key,      
00354       const PString & value     
00355     );
00357     virtual void SetString(
00358       const PString & section,  
00359       const PString & key,      
00360       const PString & value     
00361     );
00362 
00363 
00380     virtual BOOL GetBoolean(
00381       const PString & key,      
00382       BOOL dflt = FALSE         
00383     ) const;
00385     virtual BOOL GetBoolean(
00386       const PString & section,  
00387       const PString & key,      
00388       BOOL dflt = FALSE         
00389     ) const;
00390 
00397     virtual void SetBoolean(
00398       const PString & key,      
00399       BOOL value                
00400     );
00402     virtual void SetBoolean(
00403       const PString & section,  
00404       const PString & key,      
00405       BOOL value                
00406     );
00407 
00408 
00409     /* Get an integer variable determined by the key in the section. If the
00410        section name is not specified then the default section is used.
00411 
00412        If the key is not present the value returned is the that provided by
00413        the #dlft# parameter. Note that this is different from the
00414        key being present but having no value, in which case zero is returned.
00415 
00416        @return integer value of the variable.
00417      */
00418     virtual long GetInteger(
00419       const PString & key,      
00420       long dflt = 0             
00421     ) const;
00422     /* Get an integer variable determined by the key in the section. */
00423     virtual long GetInteger(
00424       const PString & section,  
00425       const PString & key,      
00426       long dflt = 0             
00427     ) const;
00428 
00435     virtual void SetInteger(
00436       const PString & key,      
00437       long value                
00438     );
00440     virtual void SetInteger(
00441       const PString & section,  
00442       const PString & key,      
00443       long value                
00444     );
00445 
00446 
00456     virtual PInt64 GetInt64(
00457       const PString & key,      
00458       PInt64 dflt = 0           
00459     ) const;
00461     virtual PInt64 GetInt64(
00462       const PString & section,  
00463       const PString & key,      
00464       PInt64 dflt = 0           
00465     ) const;
00466 
00473     virtual void SetInt64(
00474       const PString & key,      
00475       PInt64 value              
00476     );
00478     virtual void SetInt64(
00479       const PString & section,  
00480       const PString & key,      
00481       PInt64 value              
00482     );
00483 
00484 
00494     virtual double GetReal(
00495       const PString & key,      
00496       double dflt = 0           
00497     ) const;
00499     virtual double GetReal(
00500       const PString & section,  
00501       const PString & key,      
00502       double dflt = 0           
00503     ) const;
00504 
00512     virtual void SetReal(
00513       const PString & key,      
00514       double value              
00515     );
00517     virtual void SetReal(
00518       const PString & section,  
00519       const PString & key,      
00520       double value              
00521     );
00522 
00532     virtual PTime GetTime(
00533       const PString & key       
00534     ) const;
00536     virtual PTime GetTime(
00537       const PString & key,      
00538       const PTime & dflt        
00539     ) const;
00541     virtual PTime GetTime(
00542       const PString & section,  
00543       const PString & key       
00544     ) const;
00546     virtual PTime GetTime(
00547       const PString & section,  
00548       const PString & key,      
00549       const PTime & dflt        
00550     ) const;
00551 
00555     virtual void SetTime(
00556       const PString & key,      
00557       const PTime & value       
00558     );
00560     virtual void SetTime(
00561       const PString & section,  
00562       const PString & key,      
00563       const PTime & value       
00564     );
00566 
00567 
00568   protected:
00569     // Member variables
00571     PString defaultSection;
00572 
00573 
00574   private:
00575     // Do common construction code.
00576     void Construct(
00577       Source src,               
00578       const PString & appname,  
00579       const PString & manuf     
00580     );
00581     void Construct(
00582       const PFilePath & filename  
00583     );
00584 
00585 
00586 // Include platform dependent part of class
00587 #ifdef _WIN32
00588 #include "msos/ptlib/config.h"
00589 #else
00590 #include "unix/ptlib/config.h"
00591 #endif
00592 };
00593 
00594 #endif
00595 
00596 // End Of File ///////////////////////////////////////////////////////////////

Generated on Sat Dec 22 16:46:50 2007 for PWLib by  doxygen 1.4.2