Class TCastleConfig

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TCastleConfig = class(TXMLConfig)

Description

Store configuration in XML format.

This is a descendant of TXMLConfig that adds various small extensions: float types (GetFloat, SetFloat, SetDeleteFloat), vector types, key (TKey) types, PathElement utility.

Hierarchy

  • TXMLConfig
  • TCastleConfig

Overview

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public function GetFloat(const APath: string; const ADefaultValue: Float): Float;
Public procedure SetFloat(const APath: string; const AValue: Float);
Public procedure SetDeleteFloat(const APath: string; const AValue, ADefaultValue: Float);
Public function GetValue(const APath: string; const ADefaultValue: TVector3Single): TVector3Single; overload;
Public procedure SetValue(const APath: string; const AValue: TVector3Single); overload;
Public procedure SetDeleteValue(const APath: string; const AValue, ADefaultValue: TVector3Single); overload;
Public function GetValue(const APath: string; const ADefaultValue: TVector4Single): TVector4Single; overload;
Public procedure SetValue(const APath: string; const AValue: TVector4Single); overload;
Public procedure SetDeleteValue(const APath: string; const AValue, ADefaultValue: TVector4Single); overload;
Public function GetValue(const APath: string; const ADefaultValue: TKey): TKey; overload;
Public procedure SetValue(const APath: string; const AValue: TKey); overload;
Public procedure SetDeleteValue(const APath: string; const AValue, ADefaultValue: TKey); overload;
Public function PathElement(const APath: string): TDOMElement;
Public function GetFileName(const APath: string; const EmptyIfNoAttribute: boolean = false): string;
Public function GetNonEmptyValue(const APath: string): string;
Public procedure NotModified;
Public procedure Load(const AFileName: string);
Public procedure Load;
Public procedure Save;

Properties

Public property OnLoad: TCastleConfigEventList read FOnLoad;
Public property OnSave: TCastleConfigEventList read FOnSave;

Description

Methods

Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public function GetFloat(const APath: string; const ADefaultValue: Float): Float;
 
Public procedure SetFloat(const APath: string; const AValue: Float);
 
Public procedure SetDeleteFloat(const APath: string; const AValue, ADefaultValue: Float);
 
Public function GetValue(const APath: string; const ADefaultValue: TVector3Single): TVector3Single; overload;
 
Public procedure SetValue(const APath: string; const AValue: TVector3Single); overload;
 
Public procedure SetDeleteValue(const APath: string; const AValue, ADefaultValue: TVector3Single); overload;
 
Public function GetValue(const APath: string; const ADefaultValue: TVector4Single): TVector4Single; overload;
 
Public procedure SetValue(const APath: string; const AValue: TVector4Single); overload;
 
Public procedure SetDeleteValue(const APath: string; const AValue, ADefaultValue: TVector4Single); overload;
 
Public function GetValue(const APath: string; const ADefaultValue: TKey): TKey; overload;
 
Public procedure SetValue(const APath: string; const AValue: TKey); overload;
 
Public procedure SetDeleteValue(const APath: string; const AValue, ADefaultValue: TKey); overload;
 
Public function PathElement(const APath: string): TDOMElement;

For a given path, return corresponding DOM element of XML tree. This is useful if you want to mix XMLConfig style operations on the file and then use some real DOM functions to more directly operate/read on XML document.

Note that for paths that you pass to various SetValue versions, the last path component is the attribute name. You do not pass this here. Path passed here should end with the name of final element.

Path passed here may but doesn't have to be terminated by a final slash. In fact, for now the path is just splitted using slash character as a separator, so a path like /some////path/ is equivalent to a path like (some/path). But don't depend on this behavior.

Returns nil if there is no such element.

Remember that XMLConfig idea of XML document is limited. That's intentional (XMLConfig is supposed to offer only a simple limited XML access), and this means that some XML trees may confuse XMLConfig. For example, if there are two elements with the same TagName as a children of the same element: XMLConfig will (probably ?) just always ignore the second one. Which means that if you use this method to change some XML content, you should be careful when accessing this content from regular XMLConfig Get/SetValue methods.

Public function GetFileName(const APath: string; const EmptyIfNoAttribute: boolean = false): string;

Read a file name from an XML attribute. The attribute in an XML file may be absolute or relative to this XML file's path (we will look at own TXMLConfig.FileName directory to resolve relative filenames). The returned filename is always an absolute filename.

If EmptyIfNoAttribute, then this will just set FileName to '' if appropriate XML attribute not found. Otherwise (when EmptyIfNoAttribute = False, this is default), error will be raised.

Exceptions raised
EMissingAttribute
If EmptyIfNoAttribute = False and no such attribute.
Public function GetNonEmptyValue(const APath: string): string;

Get a value, as a string. Value must exist and cannot be empty in XML file.

Exceptions raised
EMissingAttribute
If value doesn't exist or is empty in XML file.
Public procedure NotModified;
 
Public procedure Load(const AFileName: string);

Load the current configuration of the engine components. Sets FileName, loading the appropriate file to our properties, and then calls the OnLoad callbacks to allow all engine components read their settings.

The overloaded version without AFileName chooses a suitable filename for storing per-program user preferences. It uses ApplicationName to pick a filename that is unique to your application (usually you want to assign OnGetApplicationName callback to set your name, unless you're fine with default determination that looks at stuff like ParamStr(0)). See FPC OnGetApplicationName docs. It uses UserConfigFile to determine location of this file.

Public procedure Load;
 
Public procedure Save;

Save the configuration of all engine components. Calls the OnSave callbacks to allow all engine components to store their settings in our properties, and then flushes them to disk (using FileName property) by inherited Flush method.

Properties

Public property OnLoad: TCastleConfigEventList read FOnLoad;

Called at Load.

Public property OnSave: TCastleConfigEventList read FOnSave;

Called at Save.


Generated by PasDoc 0.12.1 on 2013-02-04 20:26:53