config.h
Go to the documentation of this file.
/*
* config.h
*
* Application/System configuration access class.
*
* Portable Windows Library
*
* Copyright (c) 1993-1998 Equivalence Pty. Ltd.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
* the License for the specific language governing rights and limitations
* under the License.
*
* The Original Code is Portable Windows Library.
*
* The Initial Developer of the Original Code is Equivalence Pty. Ltd.
*
* Portions are Copyright (C) 1993 Free Software Foundation, Inc.
* All Rights Reserved.
*
* Contributor(s): ______________________________________.
*
* $Revision: 24177 $
* $Author: rjongbloed $
* $Date: 2010-04-05 06:52:04 -0500 (Mon, 05 Apr 2010) $
*/
#ifndef PTLIB_CONFIG_H
#define PTLIB_CONFIG_H
#ifdef P_USE_PRAGMA
#pragma interface
#endif
#include "ptbuildopts.h"
#ifdef P_CONFIG_FILE
class PXConfig;
class PConfig : public PObject
{
PCLASSINFO(PConfig, PObject);
public:
enum Source {
Environment,
System,
Application,
NumSources
};
PConfig(
Source src = Application
);
PConfig(
Source src,
const PString & appname
);
PConfig(
Source src,
const PString & appname,
const PString & manuf
);
PConfig(
const PString & section,
Source src = Application
);
PConfig(
const PString & section,
Source src,
const PString & appname
);
PConfig(
const PString & section,
Source src,
const PString & appname,
const PString & manuf
);
PConfig(
const PFilePath & filename,
const PString & section
);
virtual void SetDefaultSection(
const PString & section
);
virtual PString GetDefaultSection() const;
virtual PStringArray GetSections() const;
virtual PStringArray GetKeys() const;
virtual PStringArray GetKeys(
const PString & section
) const;
virtual PStringToString GetAllKeyValues() const;
virtual PStringToString GetAllKeyValues(
const PString & section
) const;
virtual void DeleteSection();
virtual void DeleteSection(
const PString & section
);
virtual void DeleteKey(
const PString & key
);
virtual void DeleteKey(
const PString & section,
const PString & key
);
virtual PBoolean HasKey(
const PString & key
) const;
virtual PBoolean HasKey(
const PString & section,
const PString & key
) const;
virtual PString GetString(
const PString & key
) const;
virtual PString GetString(
const PString & key,
const PString & dflt
) const;
virtual PString GetString(
const PString & section,
const PString & key,
const PString & dflt
) const;
virtual void SetString(
const PString & key,
const PString & value
);
virtual void SetString(
const PString & section,
const PString & key,
const PString & value
);
virtual PBoolean GetBoolean(
const PString & key,
PBoolean dflt = false
) const;
virtual PBoolean GetBoolean(
const PString & section,
const PString & key,
PBoolean dflt = false
) const;
virtual void SetBoolean(
const PString & key,
PBoolean value
);
virtual void SetBoolean(
const PString & section,
const PString & key,
PBoolean value
);
/* Get an integer variable determined by the key in the section. If the
section name is not specified then the default section is used.
If the key is not present the value returned is the that provided by
the <code>dlft</code> parameter. Note that this is different from the
key being present but having no value, in which case zero is returned.
@return integer value of the variable.
*/
virtual long GetInteger(
const PString & key,
long dflt = 0
) const;
/* Get an integer variable determined by the key in the section. */
virtual long GetInteger(
const PString & section,
const PString & key,
long dflt = 0
) const;
virtual void SetInteger(
const PString & key,
long value
);
virtual void SetInteger(
const PString & section,
const PString & key,
long value
);
virtual PInt64 GetInt64(
const PString & key,
PInt64 dflt = 0
) const;
virtual PInt64 GetInt64(
const PString & section,
const PString & key,
PInt64 dflt = 0
) const;
virtual void SetInt64(
const PString & key,
PInt64 value
);
virtual void SetInt64(
const PString & section,
const PString & key,
PInt64 value
);
virtual double GetReal(
const PString & key,
double dflt = 0
) const;
virtual double GetReal(
const PString & section,
const PString & key,
double dflt = 0
) const;
virtual void SetReal(
const PString & key,
double value
);
virtual void SetReal(
const PString & section,
const PString & key,
double value
);
virtual PTime GetTime(
const PString & key
) const;
virtual PTime GetTime(
const PString & key,
const PTime & dflt
) const;
virtual PTime GetTime(
const PString & section,
const PString & key
) const;
virtual PTime GetTime(
const PString & section,
const PString & key,
const PTime & dflt
) const;
virtual void SetTime(
const PString & key,
const PTime & value
);
virtual void SetTime(
const PString & section,
const PString & key,
const PTime & value
);
protected:
// Member variables
PString defaultSection;
private:
// Do common construction code.
void Construct(
Source src,
const PString & appname,
const PString & manuf
);
void Construct(
const PFilePath & filename
);
// Include platform dependent part of class
#ifdef _WIN32
#include "msos/ptlib/config.h"
#else
#include "unix/ptlib/config.h"
#endif
};
#endif // P_CONFIG_FILE
#endif // PTLIB_CONFIG_H
// End Of File ///////////////////////////////////////////////////////////////
PConfig::DeleteKey
virtual void DeleteKey(const PString &key)
Delete the particular variable in the specified section.
PConfig::SetReal
virtual void SetReal(const PString &key, double value)
Set a floating point variable determined by the key in the section.
PConfig::SetString
virtual void SetString(const PString &key, const PString &value)
Set a string variable determined by the key in the section.
PTime
This class defines an absolute time and date.
Definition: ptime.h:53
PConfig
A class representing a configuration for the application.
Definition: config.h:67
PStringToString
This is a dictionary collection class of PString objects, keyed by another string.
Definition: pstring.h:2784
PFilePath
This class describes a full description for a file on the particular platform.
Definition: filepath.h:65
PConfig::SetBoolean
virtual void SetBoolean(const PString &key, PBoolean value)
Set a boolean variable determined by the key in the section.
PConfig::PConfig
PConfig(Source src=Application)
Create a new configuration object.
PConfig::GetBoolean
virtual PBoolean GetBoolean(const PString &key, PBoolean dflt=false) const
Get a boolean variable determined by the key in the section.
PConfig::SetDefaultSection
virtual void SetDefaultSection(const PString &section)
Set the default section for variable operations.
PStringArray
This is an array collection class of PString objects.
Definition: pstring.h:2024
PConfig::Application
The application specific configuration file.
Definition: config.h:96
PBoolean
BOOL PBoolean
Definition: object.h:102
PConfig::Environment
The platform specific environment.
Definition: config.h:81
PConfig::SetInteger
virtual void SetInteger(const PString &key, long value)
Set an integer variable determined by the key in the section.
PConfig::Source
Source
Description of the standard source for configuration information.
Definition: config.h:76
PConfig::NumSources
Definition: config.h:97
PConfig::SetInt64
virtual void SetInt64(const PString &key, PInt64 value)
Set a 64 bit integer variable determined by the key in the section.
PConfig::GetReal
virtual double GetReal(const PString &key, double dflt=0) const
Get a floating point variable determined by the key in the section.
PString
The character string class.
Definition: pstring.h:108
PConfig::System
The platform specific system wide configuration file.
Definition: config.h:87
PConfig::DeleteSection
virtual void DeleteSection()
Delete all variables in the specified section.
PConfig::GetInteger
virtual long GetInteger(const PString &key, long dflt=0) const
PConfig::defaultSection
PString defaultSection
The current section for variable values.
Definition: config.h:497
PConfig::SetTime
virtual void SetTime(const PString &key, const PTime &value)
Set a PTime variable determined by the key in the section.
PConfig::GetTime
virtual PTime GetTime(const PString &key) const
Get a PTime variable determined by the key in the section.
PConfig::GetAllKeyValues
virtual PStringToString GetAllKeyValues() const
Get all of the keys in the section and their values.
PConfig::GetSections
virtual PStringArray GetSections() const
Get all of the section names currently specified in the file.
PConfig::GetInt64
virtual PInt64 GetInt64(const PString &key, PInt64 dflt=0) const
Get a 64 bit integer variable determined by the key in the section.
PObject
Ultimate parent class for all objects in the class library.
Definition: object.h:1118
PConfig::HasKey
virtual PBoolean HasKey(const PString &key) const
Determine if the particular variable in the section is actually present.
PConfig::GetDefaultSection
virtual PString GetDefaultSection() const
Get the default section for variable operations.
PConfig::GetKeys
virtual PStringArray GetKeys() const
Get a list of all the keys in the section.
PConfig::GetString
virtual PString GetString(const PString &key) const
Get a string variable determined by the key in the section.