Class TParamsFile
Unit
Declaration
type TParamsFile = class(TObject)
Description
TParamsFile work as an instance of a settings file. You can have more than one instance for more than 1 settings file.
Hierarchy
- TObject
- TParamsFile
Overview
Methods
| Protected | function getParamsFileName(ACreateFolder: boolean = False): string; |
| Protected | function getParamValue(key: string): TJSONValue; deprecated 'use GetValue<T>(key:string; Default:T):T'; |
| Protected | procedure setParamValue(key: string; Value: TJSONValue); |
| Public | constructor Create; overload; |
| Public | constructor Create(AFilePath: string); overload; |
| Public | destructor Destroy; override; |
| Public | procedure Save; |
| Public | procedure Load; |
| Public | procedure Cancel; |
| Public | procedure Delete(const ClearMemoryToo: boolean = true); |
| Public | procedure Clear; |
| Public | function getValue(key: string; default: string = ''): string; overload; |
| Public | function getValue(key: string; default: boolean = False): boolean; overload; |
| Public | function getValue(key: string; default: cardinal = 0): cardinal; overload; |
| Public | function getValue(key: string; default: integer = 0): integer; overload; |
| Public | function getValue(key: string; default: single = 0): single; overload; |
| Public | function getValue(key: string; default: TDateTime = 0): TDateTime; overload; |
| Public | function getValue(key: string; DateFormat: TDateTimeStorrageFormat; default: TDateTime = 0): TDateTime; overload; |
| Public | function getValue(key: string; default: TJSONValue = nil) : TJSONValue; overload; |
| Public | function GetValue<T>(const key: string; const Default: T): T; overload; |
| Public | procedure setValue(key, Value: string); overload; |
| Public | procedure setValue(key: string; Value: boolean); overload; |
| Public | procedure setValue(key: string; Value: cardinal); overload; |
| Public | procedure setValue(key: string; Value: integer); overload; |
| Public | procedure setValue(key: string; Value: single); overload; |
| Public | procedure setValue(key: string; Value: TDateTime; DateFormat: TDateTimeStorrageFormat = TDateTimeStorrageFormat.Delphi); overload; |
| Public | procedure setValue(key: string; Value: TJSONValue); overload; |
| Public | procedure setFolderName(AFolderName: string; AReload: boolean = true); |
| Public | procedure setFilePath(AFilePath: string; AReload: boolean = true; AExceptionIfFolderNotExist: boolean = true); |
| Public | procedure InitDefaultFileNameV2(const AEditor, ASoftware: string; AReload: boolean = true); overload; |
| Public | procedure InitDefaultFileNameV2(const AEditor, ASoftware, AFileName: string; AReload: boolean = true); overload; |
| Public | procedure MoveToFilePath(ANewFilePath: string; ASave: boolean = true; ACreateFolder: boolean = False); |
| Public | function getFilePath: string; |
| Public | function ToJSON: string; |
| Public | function AsJSONObject(AClone: boolean = true): TJSONObject; |
| Public | procedure Remove(key: string); |
| Public | function HasChanged: boolean; |
| Public | procedure BeginUpdate; |
| Public | procedure EndUpdate(const AutoSaveChanges: boolean = true); |
Properties
| Public | property onBeforeLoadEvent: TParamsLoadSaveEvent read FonBeforeLoadEvent
write SetonBeforeLoadEvent; |
| Public | property onBeforeLoadProc: TParamsLoadSaveProc read FonBeforeLoadProc
write SetonBeforeLoadProc; |
| Public | property onAfterLoadEvent: TParamsLoadSaveEvent read FonAfterLoadEvent
write SetonAfterLoadEvent; |
| Public | property onAfterLoadProc: TParamsLoadSaveProc read FonAfterLoadProc
write SetonAfterLoadProc; |
| Public | property onBeforeSaveEvent: TParamsLoadSaveEvent read FonBeforeSaveEvent
write SetonBeforeSaveEvent; |
| Public | property onBeforeSaveProc: TParamsLoadSaveProc read FonBeforeSaveProc
write SetonBeforeSaveProc; |
| Public | property onAfterSaveEvent: TParamsLoadSaveEvent read FonAfterSaveEvent
write SetonAfterSaveEvent; |
| Public | property onAfterSaveProc: TParamsLoadSaveProc read FonAfterSaveProc
write SetonAfterSaveProc; |
| Public | property onCryptEvent: TParamsCryptEvent read FonCryptEvent
write SetonCryptEvent; |
| Public | property onCryptProc: TParamsCryptProc read FonCryptProc
write SetonCryptProc; |
| Public | property onDecryptEvent: TParamsDecryptEvent read FonDecryptEvent
write SetonDecryptEvent; |
| Public | property onDecryptProc: TParamsDecryptProc read FonDecryptProc
write SetonDecryptProc; |
| Public | property PortableMode: boolean read FPortableMode write SetPortableMode; |
Description
Methods
| Protected | function getParamsFileName(ACreateFolder: boolean = False): string; |
|
This item has no description. | |
| Protected | function getParamValue(key: string): TJSONValue; deprecated 'use GetValue<T>(key:string; Default:T):T'; |
|
Warning: this symbol is deprecated: use GetValue<T>(key:string; Default:T):T This item has no description. | |
| Protected | procedure setParamValue(key: string; Value: TJSONValue); |
|
This item has no description. | |
| Public | constructor Create; overload; |
|
Class constructor wich just initialize private fields. | |
| Public | constructor Create(AFilePath: string); overload; |
|
Class constructor wich loads the parameter file specified as parameter.
Parameters
| |
| Public | destructor Destroy; override; |
|
Instance destructor | |
| Public | procedure Save; |
|
Save current parameters to actual parameter file | |
| Public | procedure Load; |
|
Load parameters from actual parameter file | |
| Public | procedure Cancel; |
|
Cancel current changes and reload previous saved values | |
| Public | procedure Delete(const ClearMemoryToo: boolean = true); |
|
Delete the file where settings are stored.
WARNING !!! No rollback. Deleting the file can't be canceled. | |
| Public | procedure Clear; |
|
Clear current parameters list | |
| Public | function getValue(key: string; default: string = ''): string; overload; |
|
Get the string value for key parameter with an empty string as default value | |
| Public | function getValue(key: string; default: boolean = False): boolean; overload; |
|
Get the boolean value for key parameter with False as default value | |
| Public | function getValue(key: string; default: cardinal = 0): cardinal; overload; |
|
Get the cardinal value for key parameter with zero as default value | |
| Public | function getValue(key: string; default: integer = 0): integer; overload; |
|
Get the integer value for key parameter with zero as default value | |
| Public | function getValue(key: string; default: single = 0): single; overload; |
|
Get the single value for key parameter with zero as default value | |
| Public | function getValue(key: string; default: TDateTime = 0): TDateTime; overload; |
|
Get the TDateTime value for key parameter with December 30th 1899 at 12:00 as default value | |
| Public | function getValue(key: string; DateFormat: TDateTimeStorrageFormat; default: TDateTime = 0): TDateTime; overload; |
|
Get the TDateTime value for key parameter with December 30th 1899 at 12:00 as default value | |
| Public | function getValue(key: string; default: TJSONValue = nil) : TJSONValue; overload; |
|
Get the JSON value for key parameter with nil as default value | |
| Public | function GetValue<T>(const key: string; const Default: T): T; overload; |
|
Try to get the value of "Key" as type T. Returns the Default value if it doesn't work.
This function use TMonitor to lock the JSON storrage and can be used in multi threaded projects. | |
| Public | procedure setValue(key, Value: string); overload; |
|
Set the value for key parameter as string | |
| Public | procedure setValue(key: string; Value: boolean); overload; |
|
Set the value for key parameter as boolean | |
| Public | procedure setValue(key: string; Value: cardinal); overload; |
|
Set the value for key parameter as cardinal | |
| Public | procedure setValue(key: string; Value: integer); overload; |
|
Set the value for key parameter as integer | |
| Public | procedure setValue(key: string; Value: single); overload; |
|
Set the value for key parameter as single | |
| Public | procedure setValue(key: string; Value: TDateTime; DateFormat: TDateTimeStorrageFormat = TDateTimeStorrageFormat.Delphi); overload; |
|
Set the value for key parameter as TDateTime | |
| Public | procedure setValue(key: string; Value: TJSONValue); overload; |
|
Set the value for key parameter as TJSONValue | |
| Public | procedure setFolderName(AFolderName: string; AReload: boolean = true); |
|
Change the folder where is the parameter file.
To change the file name, use setFilePath() instead of setFolderName(). Parameters
| |
| Public | procedure setFilePath(AFilePath: string; AReload: boolean = true; AExceptionIfFolderNotExist: boolean = true); |
|
Change the file path (folder + filename) of the parameter file.
If you only want to change the path to the parameter file, use setFolderName procedure instead of this one. Parameters
| |
| Public | procedure InitDefaultFileNameV2(const AEditor, ASoftware: string; AReload: boolean = true); overload; |
|
Initialize the folder with a new default tree: => "Documents / Editor / Software" for DEBUG and iOS => "AppData (HomePath) / Editor / Software" in RELEASE (except iOS) | |
| Public | procedure InitDefaultFileNameV2(const AEditor, ASoftware, AFileName: string; AReload: boolean = true); overload; |
|
Initialize the folder and the filename with a new default tree: => "Documents / Editor / Software" for DEBUG and iOS => "AppData (HomePath) / Editor / Software" in RELEASE (except iOS) | |
| Public | procedure MoveToFilePath(ANewFilePath: string; ASave: boolean = true; ACreateFolder: boolean = False); |
|
Move actual parameter file to the new file.
Parameters
| |
| Public | function getFilePath: string; |
|
Return the absolute path to the parameter file (drive+folder+file name+extension) | |
| Public | function ToJSON: string; |
|
Return the current parameters as a serialized JSON object. | |
| Public | function AsJSONObject(AClone: boolean = true): TJSONObject; |
|
Return the current parameters as a JSON object
Parameters
| |
| Public | procedure Remove(key: string); |
|
Retire une clé des paramètres | |
| Public | function HasChanged: boolean; |
|
Returns True if a setting has changed and not been saved. | |
| Public | procedure BeginUpdate; |
|
Allow parameters changes but delay the Save operation to the EndUpdate call.
If you call BeginUpdate you MUST call its EndUpdate. Use a try... finally... end ! | |
| Public | procedure EndUpdate(const AutoSaveChanges: boolean = true); |
|
Closes the block of code started with BeginUpdate. If you did some changes, it saves them by default.
If you call BeginUpdate you MUST call its EndUpdate. Use a try... finally... end ! | |
Properties
| Public | property onBeforeLoadEvent: TParamsLoadSaveEvent read FonBeforeLoadEvent
write SetonBeforeLoadEvent; |
|
Called before loading the settings file.
Also called for Cancel operation (which reload the file). | |
| Public | property onBeforeLoadProc: TParamsLoadSaveProc read FonBeforeLoadProc
write SetonBeforeLoadProc; |
|
This item has no description. | |
| Public | property onAfterLoadEvent: TParamsLoadSaveEvent read FonAfterLoadEvent
write SetonAfterLoadEvent; |
|
Called after loading the settings file
Also called for Cancel operation (which reload the file). | |
| Public | property onAfterLoadProc: TParamsLoadSaveProc read FonAfterLoadProc
write SetonAfterLoadProc; |
|
This item has no description. | |
| Public | property onBeforeSaveEvent: TParamsLoadSaveEvent read FonBeforeSaveEvent
write SetonBeforeSaveEvent; |
|
Called before saving the settings file | |
| Public | property onBeforeSaveProc: TParamsLoadSaveProc read FonBeforeSaveProc
write SetonBeforeSaveProc; |
|
This item has no description. | |
| Public | property onAfterSaveEvent: TParamsLoadSaveEvent read FonAfterSaveEvent
write SetonAfterSaveEvent; |
|
Called after saving the settings file | |
| Public | property onAfterSaveProc: TParamsLoadSaveProc read FonAfterSaveProc
write SetonAfterSaveProc; |
|
This item has no description. | |
| Public | property onCryptEvent: TParamsCryptEvent read FonCryptEvent
write SetonCryptEvent; |
|
Called before saving the parameters in a file (and after onBeforeSave). If crypted, the file is saved as a binary format. If uncrypted, the file is saved as a JSON text file. | |
| Public | property onCryptProc: TParamsCryptProc read FonCryptProc
write SetonCryptProc; |
|
This item has no description. | |
| Public | property onDecryptEvent: TParamsDecryptEvent read FonDecryptEvent
write SetonDecryptEvent; |
|
Called after loading the parameters from a file (and before onAfterLoad). If crypted, the file is saved as a binary format. If uncrypted, the file is saved as a JSON text file. | |
| Public | property onDecryptProc: TParamsDecryptProc read FonDecryptProc
write SetonDecryptProc; |
|
This item has no description. | |
| Public | property PortableMode: boolean read FPortableMode write SetPortableMode; |
|
Portable mode : if true nothing is saved nor loaded. Default value is false. | |
Generated by PasDoc 1.0.4.