Contains a component that stores Form Session Properties in INI format.

In this unit you can find an implementation of a name/value pair storage container in INI format. This container will get the Form's Session Properties that you setup in TForm.SessionProperties and read/write them on the file you specify in TIniPropStorage.IniFileName.

inipropstorage.pas is part of the Lazarus Component Library (LCL).

Class of TCustomIniFile. Implements the base class for storage of form session properties in an INI file.

TCustomIniPropStorage is a TFormPropertyStorage descendant which defines a class used to store form session properties to a file using the INI format. It introduces properties and methods needed to access the INI file used as the storage mechanism for the class.

Use the SessionPropperties property in the TForm or a TFrame instance which owns the class to define the components and property names stored using the storage mechanism.

Use IniFileName to specify the path and file name where session properties are stored in IniFile.

Use IniSection to specify the name for a section where session properties are stored. When omitted, session properties stored at the root level in IniFile.

Use Active to enable or disable read/write access to the INI file storage for the class instance.

Use the event handlers in the class to perform actions needed before or during save and restore operations using the session properties.

TForm.SessionProperties TFormPropertyStorage TJSONPropStorage TXMLPropStorage
Returns the TIniFile class type. The class TIniFile. Gets the value for the IniFileName property. Value for the IniFileName property. Returns the name of the INI section where values are stored.

RootSection is an overridden String function in TCustomIniPropStorage. It ensures that the value in IniSection property is used as the root section (when assigned). If IniSection has not been assigned, the inherited method is called to build the section name using the Name or Class name for the Root component in the class instance.

TCustomPropertyStorage.RootSection TCustomPropertyStorage.Root
The value for the RootSection identifier. Provides access to the TCustomIniFile instance for the class.

IniFile is a read-only TCustomIniFile property which provides access to properties and methods in the underlying INI file used to store values for session properties. The property is used in the implementation of methods which read or write values using the section, identifier, and value for the session properties.

IniFile is (re)allocated (as needed) at run-time in the StorageNeeded method. It is not (re)created at design-time. IniFile is freed (when needed) in the FreeStorage method.

Use IniFileName to specify the qualified path including file name for the INI file.

TCustomIniFile
Creates or recreates the underlying INI file storage for the class instance.

StorageNeeded is an overridden Boolean function in TCustomIniPropStorage. It ensures that the IniFile property is created or recreated when the method is called. The value in the ReadOnly argument is assigned to an internal member in the class instance; IniFile is recreated if the value in the member has been changed since the class was created.

IniFile is not created or stored in the class instance at design-time.

StorageNeeded is called from methods in ancestor classes when the Active property is enabled, including: Save, Restore, SaveProperties, RestoreProperties, ReadString, WriteString, ReadInteger, WriteInteger, and EraseSection.

See FreeStorage for the actions performed when the storage for the class instance is no longer needed.

Use Active to control whether access using the INI file storage is enabled.

Use IniFileName to specify the qualified path including file name for the INI file storage.

TCustomPropertyStorage.Active
True if the INI file allows read-only access. Frees the underlying INI file storage object for the class instance.

FreeStorage is an overridden method in TCustomIniPropStorage. It reimplements the virtual method from the TCustomPropertyStorage ancestor. FreeStorage ensures that resources allocated to the IniFile property (in StorageNeeded) are freed when the storage object is no longer needed.

FreeStorage is called from methods that include: Save, Restore, SaveProperties, RestoreProperties, ReadString, WriteString, ReadInteger, WriteInteger, and EraseSection.

Use IniFile to access properties and methods in the INI storage mechanism.

Use IniFileName to specify the qualified path including file name for the INI file storage.

Use Active to control whether access using the IniFile storage object is enabled.

TCustomPropertyStorage.Active TCustomPropertyStorage.FreeStorage
Performs actions needed to reading the specified value from the INI storage as a string type.

DoReadString is an overridden String function in TCustomIniPropStorage. It implements the abstract virtual method defined in the TCustomPropertyStorage ancestor.

Section contains the name for the section where the requested value is stored in IniFile.

Ident contains the name for the identifier read from the specified Section.

Default contains the default value returned in the method if the section or identifier is not found in IniFile.

DoReadString calls the ReadString method in IniFile to get the return value for the method.

TCustomPropertyStorage.DoReadString TIniFile.ReadString
The value for the requested section and identifier. The section name with the value read in the method. The name for the identifier with the value read in the method. Default value returned if the section or identifier is not found in the INI storage. Performs actions needed to write the specified value to the INI storage using a string type.

DoWriteString is an overridden method in TCustomIniPropStorage. It implements the abstract virtual method defined in the TCustomPropertyStorage ancestor.

Section contains the name for the section where the specified value is stored in IniFile.

Ident contains the name for the identifier written to the specified Section.

Value contains the string value stored in IniFile in the method.

DoWriteString calls the WriteString method in IniFile using the arguments passed to the method.

TCustomPropertyStorage.DoWriteString TIniFile.WriteString
The section name where the specified value is stored in the method. The name for the identifier where the specified value is stored in the method. Contains the value for the identifier stored in the specified section. Performs actions needed to remove the section section and its subsections from the underlying INI storage.

DoEraseSections is an overridden String function in TCustomIniPropStorage. It implements the abstract virtual method defined in the TCustomPropertyStorage ancestor.

ARootSection contains the name of the section in IniFile removed in the method.

DoEraseSections gets a list of section names found in the INI file, and calls IniFile.EraseSection to remove the section along with its identifiers and values. Other child sections which have ARootSection as a prefix are removed as well.

DoEraseSections is used in the SaveProperties method, and is assigned as the OnEraseSetion event handler for the RTTI TPropsStorage instance used in the method.

TCustomPropertyStorage.DoEraseSections TCustomPropertyStorage.OnSaveProperties TCustomPropertyStorage.SaveProperties
The path to the section that will be erased. Name of the INI file where the session properties are saved in INI format.

IniFileName is a String property with the qualified path and file name for the IniFile where session properties are stored in the class instance. Its value is used in the StorageNeeded method to determine the file name used when the TIniFile class instance is created and assigned to the IniFile property.

When omitted, a default value is assigned to the property which uses the path and base name for the application executable. For the Windows platform, the generated value in IniFileName has a '.INI' file extension. For UNIX-like platforms, the file is created as a config file in the home directory for the current user with a '.' prefix and no file extension.

Name of the section in the INI file where values for session properties are stored.

IniSection is a String property which contains the name of the section in IniFile where the form session properties are stored. The property value is used in the overridden RootSection function to set section name used when an IniSection property value has not been assigned. When omitted, the value from the inherited method is used; this is normally the full path to the Root component name or class name and any preceding owner components.

TCustomPropertyStorage.Root
Implements a class used to store session properties in an INI file.

TIniPropStorage is a TCustomIniPropStorage descendant which implements the class used to store form session properties to a file using the INI format. It sets the visibility for properties and methods introduced in ancestor classes.

Use the SessionPropperties property in the TForm or a TFrame instance which owns the class to define the components and property names stored using the storage mechanism.

Use IniFileName to specify the path and file name where session properties are stored in IniFile.

Use IniSection to specify the name for a section where session properties are stored. When omitted, session properties are stored at the root section level in IniFile.

Use Active to enable or disable read/write access to the INI file storage for the class instance.

Use the event handlers in the class to perform actions needed before or during save and restore operations using the session properties.

TForm.SessionProperties TJSONPropStorage TXMLPropStorage
Registers the TIniPropStorage component on the 'Misc' tab for the component palette.