Moved: license is now in external file
Changed: preparations for new X2UtSettings feature; definitions
This commit is contained in:
parent
dcbdb9edd5
commit
451903597f
29
X2UtApp.pas
29
X2UtApp.pas
@ -3,38 +3,9 @@
|
||||
:: with the application, such as the version number or executable path.
|
||||
:: It is part of the X2Utils suite.
|
||||
::
|
||||
:: Subversion repository available at:
|
||||
:: $URL$
|
||||
::
|
||||
:: Last changed: $Date$
|
||||
:: Revision: $Rev$
|
||||
:: Author: $Author$
|
||||
|
||||
:$
|
||||
:$
|
||||
:$ X2Utils is released under the zlib/libpng OSI-approved license.
|
||||
:$ For more information: http://www.opensource.org/
|
||||
:$ /n/n
|
||||
:$ /n/n
|
||||
:$ Copyright (c) 2003 X2Software
|
||||
:$ /n/n
|
||||
:$ This software is provided 'as-is', without any express or implied warranty.
|
||||
:$ In no event will the authors be held liable for any damages arising from
|
||||
:$ the use of this software.
|
||||
:$ /n/n
|
||||
:$ Permission is granted to anyone to use this software for any purpose,
|
||||
:$ including commercial applications, and to alter it and redistribute it
|
||||
:$ freely, subject to the following restrictions:
|
||||
:$ /n/n
|
||||
:$ 1. The origin of this software must not be misrepresented; you must not
|
||||
:$ claim that you wrote the original software. If you use this software in a
|
||||
:$ product, an acknowledgment in the product documentation would be
|
||||
:$ appreciated but is not required.
|
||||
:$ /n/n
|
||||
:$ 2. Altered source versions must be plainly marked as such, and must not be
|
||||
:$ misrepresented as being the original software.
|
||||
:$ /n/n
|
||||
:$ 3. This notice may not be removed or altered from any source distribution.
|
||||
}
|
||||
unit X2UtApp;
|
||||
|
||||
|
@ -5,38 +5,9 @@
|
||||
:: Including this unit in your project will automatically replace the
|
||||
:: hand cursor, no further actions are necessary.
|
||||
::
|
||||
:: Subversion repository available at:
|
||||
:: $URL$
|
||||
::
|
||||
:: Last changed: $Date$
|
||||
:: Revision: $Rev$
|
||||
:: Author: $Author$
|
||||
|
||||
:$
|
||||
:$
|
||||
:$ X2Utils is released under the zlib/libpng OSI-approved license.
|
||||
:$ For more information: http://www.opensource.org/
|
||||
:$ /n/n
|
||||
:$ /n/n
|
||||
:$ Copyright (c) 2003 X2Software
|
||||
:$ /n/n
|
||||
:$ This software is provided 'as-is', without any express or implied warranty.
|
||||
:$ In no event will the authors be held liable for any damages arising from
|
||||
:$ the use of this software.
|
||||
:$ /n/n
|
||||
:$ Permission is granted to anyone to use this software for any purpose,
|
||||
:$ including commercial applications, and to alter it and redistribute it
|
||||
:$ freely, subject to the following restrictions:
|
||||
:$ /n/n
|
||||
:$ 1. The origin of this software must not be misrepresented; you must not
|
||||
:$ claim that you wrote the original software. If you use this software in a
|
||||
:$ product, an acknowledgment in the product documentation would be
|
||||
:$ appreciated but is not required.
|
||||
:$ /n/n
|
||||
:$ 2. Altered source versions must be plainly marked as such, and must not be
|
||||
:$ misrepresented as being the original software.
|
||||
:$ /n/n
|
||||
:$ 3. This notice may not be removed or altered from any source distribution.
|
||||
}
|
||||
unit X2UtHandCursor;
|
||||
|
||||
|
29
X2UtMisc.pas
29
X2UtMisc.pas
@ -2,38 +2,9 @@
|
||||
:: X2UtMisc is a collection of functions not fitting into any of the other
|
||||
:: categories.
|
||||
::
|
||||
:: Subversion repository available at:
|
||||
:: $URL$
|
||||
::
|
||||
:: Last changed: $Date$
|
||||
:: Revision: $Rev$
|
||||
:: Author: $Author$
|
||||
|
||||
:$
|
||||
:$
|
||||
:$ X2Utils is released under the zlib/libpng OSI-approved license.
|
||||
:$ For more information: http://www.opensource.org/
|
||||
:$ /n/n
|
||||
:$ /n/n
|
||||
:$ Copyright (c) 2003 X2Software
|
||||
:$ /n/n
|
||||
:$ This software is provided 'as-is', without any express or implied warranty.
|
||||
:$ In no event will the authors be held liable for any damages arising from
|
||||
:$ the use of this software.
|
||||
:$ /n/n
|
||||
:$ Permission is granted to anyone to use this software for any purpose,
|
||||
:$ including commercial applications, and to alter it and redistribute it
|
||||
:$ freely, subject to the following restrictions:
|
||||
:$ /n/n
|
||||
:$ 1. The origin of this software must not be misrepresented; you must not
|
||||
:$ claim that you wrote the original software. If you use this software in a
|
||||
:$ product, an acknowledgment in the product documentation would be
|
||||
:$ appreciated but is not required.
|
||||
:$ /n/n
|
||||
:$ 2. Altered source versions must be plainly marked as such, and must not be
|
||||
:$ misrepresented as being the original software.
|
||||
:$ /n/n
|
||||
:$ 3. This notice may not be removed or altered from any source distribution.
|
||||
}
|
||||
unit X2UtMisc;
|
||||
|
||||
|
29
X2UtOS.pas
29
X2UtOS.pas
@ -3,38 +3,9 @@
|
||||
:: with the Operating System, such as the version number.
|
||||
:: It is part of the X2Utils suite.
|
||||
::
|
||||
:: Subversion repository available at:
|
||||
:: $URL$
|
||||
::
|
||||
:: Last changed: $Date$
|
||||
:: Revision: $Rev$
|
||||
:: Author: $Author$
|
||||
|
||||
:$
|
||||
:$
|
||||
:$ X2Utils is released under the zlib/libpng OSI-approved license.
|
||||
:$ For more information: http://www.opensource.org/
|
||||
:$ /n/n
|
||||
:$ /n/n
|
||||
:$ Copyright (c) 2003 X2Software
|
||||
:$ /n/n
|
||||
:$ This software is provided 'as-is', without any express or implied warranty.
|
||||
:$ In no event will the authors be held liable for any damages arising from
|
||||
:$ the use of this software.
|
||||
:$ /n/n
|
||||
:$ Permission is granted to anyone to use this software for any purpose,
|
||||
:$ including commercial applications, and to alter it and redistribute it
|
||||
:$ freely, subject to the following restrictions:
|
||||
:$ /n/n
|
||||
:$ 1. The origin of this software must not be misrepresented; you must not
|
||||
:$ claim that you wrote the original software. If you use this software in a
|
||||
:$ product, an acknowledgment in the product documentation would be
|
||||
:$ appreciated but is not required.
|
||||
:$ /n/n
|
||||
:$ 2. Altered source versions must be plainly marked as such, and must not be
|
||||
:$ misrepresented as being the original software.
|
||||
:$ /n/n
|
||||
:$ 3. This notice may not be removed or altered from any source distribution.
|
||||
}
|
||||
unit X2UtOS;
|
||||
|
||||
|
186
X2UtSettings.pas
186
X2UtSettings.pas
@ -3,74 +3,113 @@
|
||||
:: Include one of the extensions (X2UtSettingsINI, X2UtSettingsRegistry) for
|
||||
:: an implementation.
|
||||
::
|
||||
:: Subversion repository available at:
|
||||
:: $URL$
|
||||
::
|
||||
:: Last changed: $Date$
|
||||
:: Revision: $Rev$
|
||||
:: Author: $Author$
|
||||
|
||||
:$
|
||||
:$
|
||||
:$ X2Utils is released under the zlib/libpng OSI-approved license.
|
||||
:$ For more information: http://www.opensource.org/
|
||||
:$ /n/n
|
||||
:$ /n/n
|
||||
:$ Copyright (c) 2003 X2Software
|
||||
:$ /n/n
|
||||
:$ This software is provided 'as-is', without any express or implied warranty.
|
||||
:$ In no event will the authors be held liable for any damages arising from
|
||||
:$ the use of this software.
|
||||
:$ /n/n
|
||||
:$ Permission is granted to anyone to use this software for any purpose,
|
||||
:$ including commercial applications, and to alter it and redistribute it
|
||||
:$ freely, subject to the following restrictions:
|
||||
:$ /n/n
|
||||
:$ 1. The origin of this software must not be misrepresented; you must not
|
||||
:$ claim that you wrote the original software. If you use this software in a
|
||||
:$ product, an acknowledgment in the product documentation would be
|
||||
:$ appreciated but is not required.
|
||||
:$ /n/n
|
||||
:$ 2. Altered source versions must be plainly marked as such, and must not be
|
||||
:$ misrepresented as being the original software.
|
||||
:$ /n/n
|
||||
:$ 3. This notice may not be removed or altered from any source distribution.
|
||||
}
|
||||
unit X2UtSettings;
|
||||
|
||||
interface
|
||||
uses
|
||||
Classes;
|
||||
Classes,
|
||||
SysUtils,
|
||||
Variants;
|
||||
|
||||
type
|
||||
//:$ Raised when an unregistered setting is requested without providing a
|
||||
//:$ default value.
|
||||
EX2SettingsUndefined = class(Exception);
|
||||
|
||||
//:$ Raised when trying to read a registered setting as a different type than
|
||||
//:$ it was registered with.
|
||||
EX2SettingsType = class(Exception);
|
||||
|
||||
//:$ Raised when the specified range is invalid.
|
||||
EX2SettingsRange = class(Exception);
|
||||
|
||||
|
||||
// Forward declaration
|
||||
TX2SettingsFactory = class;
|
||||
|
||||
{
|
||||
:$ Abstract settings object
|
||||
:$ Abstract settings object.
|
||||
|
||||
:: Provides access to the settings regardless of the storage backend.
|
||||
}
|
||||
TX2Settings = class(TObject)
|
||||
public
|
||||
function ReadBool(const AName: String; const ADefault: Boolean = False): Boolean; virtual; abstract;
|
||||
function ReadFloat(const AName: String; const ADefault: Double = 0.0): Double; virtual; abstract;
|
||||
function ReadInteger(const AName: String; const ADefault: Integer = 0): Integer; virtual; abstract;
|
||||
function ReadString(const AName: String; const ADefault: String = ''): String; virtual; abstract;
|
||||
private
|
||||
FFactory: TX2SettingsFactory;
|
||||
FSection: String;
|
||||
protected
|
||||
function InternalReadBool(const AName: String; out AValue: Boolean): Boolean; virtual; abstract;
|
||||
function InternalReadFloat(const AName: String; out AValue: Double): Boolean; virtual; abstract;
|
||||
function InternalReadInteger(const AName: String; out AValue: Integer): Boolean; virtual; abstract;
|
||||
function InternalReadString(const AName: String; out AValue: String): Boolean; virtual; abstract;
|
||||
|
||||
property Factory: TX2SettingsFactory read FFactory;
|
||||
property Section: String read FSection;
|
||||
public
|
||||
constructor Create(const AFactory: TX2SettingsFactory;
|
||||
const ASection: String); virtual;
|
||||
|
||||
//:$ Reads a boolean value from the settings.
|
||||
//:: If the ADefault parameter is used, that value will be returned if the
|
||||
//:: setting could not be found. Otherwise the setting must have been
|
||||
//:: registered with the factory's Register() method.
|
||||
function ReadBool(const AName: String): Boolean; overload; virtual;
|
||||
function ReadBool(const AName: String; const ADefault: Boolean): Boolean; overload; virtual;
|
||||
|
||||
//:$ Reads a floating point value from the settings.
|
||||
//:: If the ADefault parameter is used, that value will be returned if the
|
||||
//:: setting could not be found. Otherwise the setting must have been
|
||||
//:: registered with the factory's Register() method.
|
||||
function ReadFloat(const AName: String): Double; overload; virtual;
|
||||
function ReadFloat(const AName: String; const ADefault: Double): Double; overload; virtual;
|
||||
|
||||
//:$ Reads an integer value from the settings.
|
||||
//:: If the ADefault parameter is used, that value will be returned if the
|
||||
//:: setting could not be found. Otherwise the setting must have been
|
||||
//:: registered with the factory's Register() method.
|
||||
function ReadInteger(const AName: String): Integer; overload; virtual;
|
||||
function ReadInteger(const AName: String; const ADefault: Integer): Integer; overload; virtual;
|
||||
|
||||
//:$ Reads a string value from the settings.
|
||||
//:: If the ADefault parameter is used, that value will be returned if the
|
||||
//:: setting could not be found. Otherwise the setting must have been
|
||||
//:: registered with the factory's Register() method.
|
||||
function ReadString(const AName: String): String; overload; virtual;
|
||||
function ReadString(const AName, ADefault: String): String; overload; virtual;
|
||||
|
||||
//:$ Writes a boolean value to the settings.
|
||||
procedure WriteBool(const AName: String; AValue: Boolean); virtual; abstract;
|
||||
|
||||
//:$ Writes a floating point value to the settings.
|
||||
procedure WriteFloat(const AName: String; AValue: Double); virtual; abstract;
|
||||
|
||||
//:$ Writes an integer value to the settings.
|
||||
procedure WriteInteger(const AName: String; AValue: Integer); virtual; abstract;
|
||||
|
||||
//:$ Writes a string value to the settings.
|
||||
procedure WriteString(const AName, AValue: String); virtual; abstract;
|
||||
|
||||
//:$ Checks if the specified setting exists.
|
||||
function ValueExists(const AName: String): Boolean; virtual; abstract;
|
||||
|
||||
//:$ Retrieves the list of sub-sections for this section.
|
||||
procedure GetSectionNames(const ADest: TStrings); virtual; abstract;
|
||||
|
||||
//:$ Retrieves the list of values for this section.
|
||||
procedure GetValueNames(const ADest: TStrings); virtual; abstract;
|
||||
|
||||
//:$ Deletes this section.
|
||||
procedure DeleteSection(); virtual; abstract;
|
||||
|
||||
//:$ Deletes the specified value.
|
||||
procedure DeleteValue(const AName: String); virtual; abstract;
|
||||
end;
|
||||
|
||||
{
|
||||
:$ Settings factory
|
||||
:$ Settings factory.
|
||||
|
||||
:: Extensions must implement a factory descendant which an application can
|
||||
:: create to provide application-wide access to the same settings.
|
||||
@ -79,7 +118,7 @@ type
|
||||
protected
|
||||
function GetSection(const ASection: String): TX2Settings; virtual; abstract;
|
||||
public
|
||||
//:$ Load a section from the settings
|
||||
//:$ Loads a section from the settings.
|
||||
//:: Sub-sections are indicated by seperating the sections with a dot ('.')
|
||||
//:: characters, ex: Sub.Section. The underlying extension will translate
|
||||
//:: this into a compatible section.
|
||||
@ -89,5 +128,76 @@ type
|
||||
|
||||
|
||||
implementation
|
||||
resourcestring
|
||||
RSInvalidRange = 'Invalid range';
|
||||
RSInvalidType = 'Invalid type';
|
||||
RSUndefined = 'Undefined setting: %s';
|
||||
|
||||
|
||||
{============================ TX2Settings
|
||||
Initialization
|
||||
========================================}
|
||||
constructor TX2Settings.Create;
|
||||
begin
|
||||
inherited Create();
|
||||
|
||||
FFactory := AFactory;
|
||||
FSection := ASection;
|
||||
end;
|
||||
|
||||
|
||||
{============================ TX2Settings
|
||||
Read
|
||||
========================================}
|
||||
function TX2Settings.ReadBool(const AName: String): Boolean;
|
||||
begin
|
||||
if not (ValueExists(AName) and InternalReadBool(AName, Result)) then
|
||||
raise EX2SettingsUndefined.CreateFmt(RSUndefined, [AName]);
|
||||
end;
|
||||
|
||||
function TX2Settings.ReadBool(const AName: String;
|
||||
const ADefault: Boolean): Boolean;
|
||||
begin
|
||||
if not (ValueExists(AName) and InternalReadBool(AName, Result)) then
|
||||
Result := ADefault;
|
||||
end;
|
||||
|
||||
function TX2Settings.ReadFloat(const AName: String): Double;
|
||||
begin
|
||||
if not (ValueExists(AName) and InternalReadFloat(AName, Result)) then
|
||||
raise EX2SettingsUndefined.CreateFmt(RSUndefined, [AName]);
|
||||
end;
|
||||
|
||||
function TX2Settings.ReadFloat(const AName: String;
|
||||
const ADefault: Double): Double;
|
||||
begin
|
||||
if not (ValueExists(AName) and InternalReadFloat(AName, Result)) then
|
||||
Result := ADefault;
|
||||
end;
|
||||
|
||||
function TX2Settings.ReadInteger(const AName: String): Integer;
|
||||
begin
|
||||
if not (ValueExists(AName) and InternalReadInteger(AName, Result)) then
|
||||
raise EX2SettingsUndefined.CreateFmt(RSUndefined, [AName]);
|
||||
end;
|
||||
|
||||
function TX2Settings.ReadInteger(const AName: String;
|
||||
const ADefault: Integer): Integer;
|
||||
begin
|
||||
if not (ValueExists(AName) and InternalReadInteger(AName, Result)) then
|
||||
Result := ADefault;
|
||||
end;
|
||||
|
||||
function TX2Settings.ReadString(const AName: String): String;
|
||||
begin
|
||||
if not (ValueExists(AName) and InternalReadString(AName, Result)) then
|
||||
raise EX2SettingsUndefined.CreateFmt(RSUndefined, [AName]);
|
||||
end;
|
||||
|
||||
function TX2Settings.ReadString(const AName, ADefault: String): String;
|
||||
begin
|
||||
if not (ValueExists(AName) and InternalReadString(AName, Result)) then
|
||||
Result := ADefault;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
@ -1,38 +1,9 @@
|
||||
{
|
||||
:: X2UtSettingsForm provides functions to read and write form settings.
|
||||
::
|
||||
:: Subversion repository available at:
|
||||
:: $URL$
|
||||
::
|
||||
:: Last changed: $Date$
|
||||
:: Revision: $Rev$
|
||||
:: Author: $Author$
|
||||
|
||||
:$
|
||||
:$
|
||||
:$ X2Utils is released under the zlib/libpng OSI-approved license.
|
||||
:$ For more information: http://www.opensource.org/
|
||||
:$ /n/n
|
||||
:$ /n/n
|
||||
:$ Copyright (c) 2003 X2Software
|
||||
:$ /n/n
|
||||
:$ This software is provided 'as-is', without any express or implied warranty.
|
||||
:$ In no event will the authors be held liable for any damages arising from
|
||||
:$ the use of this software.
|
||||
:$ /n/n
|
||||
:$ Permission is granted to anyone to use this software for any purpose,
|
||||
:$ including commercial applications, and to alter it and redistribute it
|
||||
:$ freely, subject to the following restrictions:
|
||||
:$ /n/n
|
||||
:$ 1. The origin of this software must not be misrepresented; you must not
|
||||
:$ claim that you wrote the original software. If you use this software in a
|
||||
:$ product, an acknowledgment in the product documentation would be
|
||||
:$ appreciated but is not required.
|
||||
:$ /n/n
|
||||
:$ 2. Altered source versions must be plainly marked as such, and must not be
|
||||
:$ misrepresented as being the original software.
|
||||
:$ /n/n
|
||||
:$ 3. This notice may not be removed or altered from any source distribution.
|
||||
}
|
||||
unit X2UtSettingsForm;
|
||||
|
||||
|
@ -1,38 +1,9 @@
|
||||
{
|
||||
:: X2UtSettingsINI extends X2UtSettings with INI reading/writing.
|
||||
::
|
||||
:: Subversion repository available at:
|
||||
:: $URL$
|
||||
::
|
||||
:: Last changed: $Date$
|
||||
:: Revision: $Rev$
|
||||
:: Author: $Author$
|
||||
|
||||
:$
|
||||
:$
|
||||
:$ X2Utils is released under the zlib/libpng OSI-approved license.
|
||||
:$ For more information: http://www.opensource.org/
|
||||
:$ /n/n
|
||||
:$ /n/n
|
||||
:$ Copyright (c) 2003 X2Software
|
||||
:$ /n/n
|
||||
:$ This software is provided 'as-is', without any express or implied warranty.
|
||||
:$ In no event will the authors be held liable for any damages arising from
|
||||
:$ the use of this software.
|
||||
:$ /n/n
|
||||
:$ Permission is granted to anyone to use this software for any purpose,
|
||||
:$ including commercial applications, and to alter it and redistribute it
|
||||
:$ freely, subject to the following restrictions:
|
||||
:$ /n/n
|
||||
:$ 1. The origin of this software must not be misrepresented; you must not
|
||||
:$ claim that you wrote the original software. If you use this software in a
|
||||
:$ product, an acknowledgment in the product documentation would be
|
||||
:$ appreciated but is not required.
|
||||
:$ /n/n
|
||||
:$ 2. Altered source versions must be plainly marked as such, and must not be
|
||||
:$ misrepresented as being the original software.
|
||||
:$ /n/n
|
||||
:$ 3. This notice may not be removed or altered from any source distribution.
|
||||
}
|
||||
unit X2UtSettingsINI;
|
||||
|
||||
@ -53,13 +24,12 @@ type
|
||||
private
|
||||
FData: TMemIniFile;
|
||||
FSection: String;
|
||||
protected
|
||||
function InternalReadBool(const AName: String; out AValue: Boolean): Boolean; override;
|
||||
function InternalReadFloat(const AName: String; out AValue: Double): Boolean; override;
|
||||
function InternalReadInteger(const AName: String; out AValue: Integer): Boolean; override;
|
||||
function InternalReadString(const AName: String; out AValue: String): Boolean; override;
|
||||
public
|
||||
// IX2Settings implementation
|
||||
function ReadBool(const AName: String; const ADefault: Boolean = False): Boolean; override;
|
||||
function ReadFloat(const AName: String; const ADefault: Double = 0.0): Double; override;
|
||||
function ReadInteger(const AName: String; const ADefault: Integer = 0): Integer; override;
|
||||
function ReadString(const AName: String; const ADefault: String = ''): String; override;
|
||||
|
||||
procedure WriteBool(const AName: String; AValue: Boolean); override;
|
||||
procedure WriteFloat(const AName: String; AValue: Double); override;
|
||||
procedure WriteInteger(const AName: String; AValue: Integer); override;
|
||||
@ -73,7 +43,8 @@ type
|
||||
procedure DeleteSection(); override;
|
||||
procedure DeleteValue(const AName: String); override;
|
||||
public
|
||||
constructor Create(const AFilename, ASection: String);
|
||||
constructor CreateInit(const AFactory: TX2SettingsFactory;
|
||||
const ASection, AFilename: String);
|
||||
destructor Destroy(); override;
|
||||
end;
|
||||
|
||||
@ -101,16 +72,16 @@ uses
|
||||
========================================}
|
||||
function TX2INISettingsFactory.GetSection;
|
||||
begin
|
||||
Result := TX2INISettings.Create(FFilename, ASection);
|
||||
Result := TX2INISettings.CreateInit(Self, ASection, FFilename);
|
||||
end;
|
||||
|
||||
|
||||
{========================= TX2INISettings
|
||||
Initialization
|
||||
========================================}
|
||||
constructor TX2INISettings.Create;
|
||||
constructor TX2INISettings.CreateInit;
|
||||
begin
|
||||
inherited Create();
|
||||
inherited Create(AFactory, ASection);
|
||||
|
||||
FData := TMemIniFile.Create(AFilename);
|
||||
FSection := ASection;
|
||||
@ -128,24 +99,28 @@ end;
|
||||
{========================= TX2INISettings
|
||||
Read
|
||||
========================================}
|
||||
function TX2INISettings.ReadBool;
|
||||
function TX2INISettings.InternalReadBool;
|
||||
begin
|
||||
Result := FData.ReadBool(FSection, AName, ADefault);
|
||||
AValue := FData.ReadBool(FSection, AName, False);
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function TX2INISettings.ReadFloat;
|
||||
function TX2INISettings.InternalReadFloat;
|
||||
begin
|
||||
Result := FData.ReadFloat(FSection, AName, ADefault);
|
||||
AValue := FData.ReadFloat(FSection, AName, 0);
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function TX2INISettings.ReadInteger;
|
||||
function TX2INISettings.InternalReadInteger;
|
||||
begin
|
||||
Result := FData.ReadInteger(FSection, AName, ADefault);
|
||||
AValue := FData.ReadInteger(FSection, AName, 0);
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function TX2INISettings.ReadString;
|
||||
function TX2INISettings.InternalReadString;
|
||||
begin
|
||||
Result := FData.ReadString(FSection, AName, ADefault);
|
||||
AValue := FData.ReadString(FSection, AName, '');
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
|
||||
|
@ -59,13 +59,12 @@ type
|
||||
|
||||
function OpenRead(): Boolean;
|
||||
function OpenWrite(): Boolean;
|
||||
protected
|
||||
function InternalReadBool(const AName: String; out AValue: Boolean): Boolean; override;
|
||||
function InternalReadFloat(const AName: String; out AValue: Double): Boolean; override;
|
||||
function InternalReadInteger(const AName: String; out AValue: Integer): Boolean; override;
|
||||
function InternalReadString(const AName: String; out AValue: String): Boolean; override;
|
||||
public
|
||||
// IX2Settings implementation
|
||||
function ReadBool(const AName: String; const ADefault: Boolean = False): Boolean; override;
|
||||
function ReadFloat(const AName: String; const ADefault: Double = 0.0): Double; override;
|
||||
function ReadInteger(const AName: String; const ADefault: Integer = 0): Integer; override;
|
||||
function ReadString(const AName: String; const ADefault: String = ''): String; override;
|
||||
|
||||
procedure WriteBool(const AName: String; AValue: Boolean); override;
|
||||
procedure WriteFloat(const AName: String; AValue: Double); override;
|
||||
procedure WriteInteger(const AName: String; AValue: Integer); override;
|
||||
@ -79,7 +78,9 @@ type
|
||||
procedure DeleteSection(); override;
|
||||
procedure DeleteValue(const AName: String); override;
|
||||
public
|
||||
constructor Create(const ARoot: Cardinal; const AKey: String);
|
||||
constructor CreateInit(const AFactory: TX2SettingsFactory;
|
||||
const ASection: String;
|
||||
const ARoot: Cardinal);
|
||||
destructor Destroy(); override;
|
||||
end;
|
||||
|
||||
@ -110,26 +111,23 @@ uses
|
||||
Section
|
||||
========================================}
|
||||
function TX2RegistrySettingsFactory.GetSection;
|
||||
var
|
||||
sKey: String;
|
||||
|
||||
begin
|
||||
sKey := IncludeTrailingPathDelimiter(FKey) +
|
||||
StringReplace(ASection, '.', '\', [rfReplaceAll]);
|
||||
Result := TX2RegistrySettings.Create(FRoot, sKey);
|
||||
Result := TX2RegistrySettings.CreateInit(Self, ASection, FRoot);
|
||||
end;
|
||||
|
||||
|
||||
{==================== TX2RegistrySettings
|
||||
Initialization
|
||||
========================================}
|
||||
constructor TX2RegistrySettings.Create;
|
||||
constructor TX2RegistrySettings.CreateInit;
|
||||
begin
|
||||
inherited Create();
|
||||
inherited Create(AFactory, ASection);
|
||||
|
||||
FData := TRegistry.Create();
|
||||
FData.RootKey := ARoot;
|
||||
FKey := AKey;
|
||||
|
||||
FKey := IncludeTrailingPathDelimiter(FKey) +
|
||||
StringReplace(ASection, '.', '\', [rfReplaceAll]);
|
||||
end;
|
||||
|
||||
destructor TX2RegistrySettings.Destroy;
|
||||
@ -169,49 +167,47 @@ end;
|
||||
{==================== TX2RegistrySettings
|
||||
Read
|
||||
========================================}
|
||||
function TX2RegistrySettings.ReadBool;
|
||||
function TX2RegistrySettings.InternalReadBool;
|
||||
begin
|
||||
Result := ADefault;
|
||||
Result := False;
|
||||
|
||||
if (OpenRead()) and (FData.ValueExists(AName)) then
|
||||
try
|
||||
Result := FData.ReadBool(AName)
|
||||
except
|
||||
// Silently ignore exceptions so the
|
||||
// default value gets returned
|
||||
end;
|
||||
end;
|
||||
|
||||
function TX2RegistrySettings.ReadFloat;
|
||||
if OpenRead() then
|
||||
begin
|
||||
Result := ADefault;
|
||||
|
||||
if (OpenRead()) and (FData.ValueExists(AName)) then
|
||||
try
|
||||
Result := FData.ReadFloat(AName)
|
||||
except
|
||||
AValue := FData.ReadBool(AName);
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TX2RegistrySettings.ReadInteger;
|
||||
function TX2RegistrySettings.InternalReadFloat;
|
||||
begin
|
||||
Result := ADefault;
|
||||
Result := False;
|
||||
|
||||
if (OpenRead()) and (FData.ValueExists(AName)) then
|
||||
try
|
||||
Result := FData.ReadInteger(AName)
|
||||
except
|
||||
end;
|
||||
end;
|
||||
|
||||
function TX2RegistrySettings.ReadString;
|
||||
if OpenRead() then
|
||||
begin
|
||||
Result := ADefault;
|
||||
AValue := FData.ReadFloat(AName);
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
if (OpenRead()) and (FData.ValueExists(AName)) then
|
||||
try
|
||||
Result := FData.ReadString(AName)
|
||||
except
|
||||
function TX2RegistrySettings.InternalReadInteger;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
if OpenRead() then
|
||||
begin
|
||||
AValue := FData.ReadInteger(AName);
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TX2RegistrySettings.InternalReadString;
|
||||
begin
|
||||
Result := False;
|
||||
|
||||
if OpenRead() then
|
||||
begin
|
||||
AValue := FData.ReadString(AName);
|
||||
Result := True;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -2,38 +2,9 @@
|
||||
:: X2UtSingleInstance provides functions to detect previous instances of an
|
||||
:: application and pass it the new command-line parameters.
|
||||
::
|
||||
:: Subversion repository available at:
|
||||
:: $URL$
|
||||
::
|
||||
:: Last changed: $Date$
|
||||
:: Revision: $Rev$
|
||||
:: Author: $Author$
|
||||
|
||||
:$
|
||||
:$
|
||||
:$ X2Utils is released under the zlib/libpng OSI-approved license.
|
||||
:$ For more information: http://www.opensource.org/
|
||||
:$ /n/n
|
||||
:$ /n/n
|
||||
:$ Copyright (c) 2003 X2Software
|
||||
:$ /n/n
|
||||
:$ This software is provided 'as-is', without any express or implied warranty.
|
||||
:$ In no event will the authors be held liable for any damages arising from
|
||||
:$ the use of this software.
|
||||
:$ /n/n
|
||||
:$ Permission is granted to anyone to use this software for any purpose,
|
||||
:$ including commercial applications, and to alter it and redistribute it
|
||||
:$ freely, subject to the following restrictions:
|
||||
:$ /n/n
|
||||
:$ 1. The origin of this software must not be misrepresented; you must not
|
||||
:$ claim that you wrote the original software. If you use this software in a
|
||||
:$ product, an acknowledgment in the product documentation would be
|
||||
:$ appreciated but is not required.
|
||||
:$ /n/n
|
||||
:$ 2. Altered source versions must be plainly marked as such, and must not be
|
||||
:$ misrepresented as being the original software.
|
||||
:$ /n/n
|
||||
:$ 3. This notice may not be removed or altered from any source distribution.
|
||||
}
|
||||
unit X2UtSingleInstance;
|
||||
|
||||
|
@ -1,38 +1,9 @@
|
||||
{
|
||||
:: X2UtStrings provides various string-related functions.
|
||||
::
|
||||
:: Subversion repository available at:
|
||||
:: $URL$
|
||||
::
|
||||
:: Last changed: $Date$
|
||||
:: Revision: $Rev$
|
||||
:: Author: $Author$
|
||||
|
||||
:$
|
||||
:$
|
||||
:$ X2Utils is released under the zlib/libpng OSI-approved license.
|
||||
:$ For more information: http://www.opensource.org/
|
||||
:$ /n/n
|
||||
:$ /n/n
|
||||
:$ Copyright (c) 2003 X2Software
|
||||
:$ /n/n
|
||||
:$ This software is provided 'as-is', without any express or implied warranty.
|
||||
:$ In no event will the authors be held liable for any damages arising from
|
||||
:$ the use of this software.
|
||||
:$ /n/n
|
||||
:$ Permission is granted to anyone to use this software for any purpose,
|
||||
:$ including commercial applications, and to alter it and redistribute it
|
||||
:$ freely, subject to the following restrictions:
|
||||
:$ /n/n
|
||||
:$ 1. The origin of this software must not be misrepresented; you must not
|
||||
:$ claim that you wrote the original software. If you use this software in a
|
||||
:$ product, an acknowledgment in the product documentation would be
|
||||
:$ appreciated but is not required.
|
||||
:$ /n/n
|
||||
:$ 2. Altered source versions must be plainly marked as such, and must not be
|
||||
:$ misrepresented as being the original software.
|
||||
:$ /n/n
|
||||
:$ 3. This notice may not be removed or altered from any source distribution.
|
||||
}
|
||||
unit X2UtStrings;
|
||||
|
||||
|
@ -2,38 +2,9 @@
|
||||
:: X2UtVirtualTree provides a set of functions commonly used with
|
||||
:: TVirtualTree (http://www.delphi-gems.com/).
|
||||
::
|
||||
:: Subversion repository available at:
|
||||
:: $URL$
|
||||
::
|
||||
:: Last changed: $Date$
|
||||
:: Revision: $Rev$
|
||||
:: Author: $Author$
|
||||
|
||||
:$
|
||||
:$
|
||||
:$ X2Utils is released under the zlib/libpng OSI-approved license.
|
||||
:$ For more information: http://www.opensource.org/
|
||||
:$ /n/n
|
||||
:$ /n/n
|
||||
:$ Copyright (c) 2003 X2Software
|
||||
:$ /n/n
|
||||
:$ This software is provided 'as-is', without any express or implied warranty.
|
||||
:$ In no event will the authors be held liable for any damages arising from
|
||||
:$ the use of this software.
|
||||
:$ /n/n
|
||||
:$ Permission is granted to anyone to use this software for any purpose,
|
||||
:$ including commercial applications, and to alter it and redistribute it
|
||||
:$ freely, subject to the following restrictions:
|
||||
:$ /n/n
|
||||
:$ 1. The origin of this software must not be misrepresented; you must not
|
||||
:$ claim that you wrote the original software. If you use this software in a
|
||||
:$ product, an acknowledgment in the product documentation would be
|
||||
:$ appreciated but is not required.
|
||||
:$ /n/n
|
||||
:$ 2. Altered source versions must be plainly marked as such, and must not be
|
||||
:$ misrepresented as being the original software.
|
||||
:$ /n/n
|
||||
:$ 3. This notice may not be removed or altered from any source distribution.
|
||||
}
|
||||
unit X2UtVirtualTree;
|
||||
|
||||
|
23
license.txt
Normal file
23
license.txt
Normal file
@ -0,0 +1,23 @@
|
||||
X2Utils is released under the zlib/libpng OSI-approved license.
|
||||
For more information: http://www.opensource.org/
|
||||
|
||||
Copyright (c) 2003 X2Software
|
||||
http://www.x2software.net/
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising from
|
||||
the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software in a
|
||||
product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
Loading…
Reference in New Issue
Block a user