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.
|
:: with the application, such as the version number or executable path.
|
||||||
:: It is part of the X2Utils suite.
|
:: It is part of the X2Utils suite.
|
||||||
::
|
::
|
||||||
:: Subversion repository available at:
|
|
||||||
:: $URL$
|
|
||||||
::
|
|
||||||
:: Last changed: $Date$
|
:: Last changed: $Date$
|
||||||
:: Revision: $Rev$
|
:: Revision: $Rev$
|
||||||
:: Author: $Author$
|
:: 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;
|
unit X2UtApp;
|
||||||
|
|
||||||
|
@ -5,38 +5,9 @@
|
|||||||
:: Including this unit in your project will automatically replace the
|
:: Including this unit in your project will automatically replace the
|
||||||
:: hand cursor, no further actions are necessary.
|
:: hand cursor, no further actions are necessary.
|
||||||
::
|
::
|
||||||
:: Subversion repository available at:
|
|
||||||
:: $URL$
|
|
||||||
::
|
|
||||||
:: Last changed: $Date$
|
:: Last changed: $Date$
|
||||||
:: Revision: $Rev$
|
:: Revision: $Rev$
|
||||||
:: Author: $Author$
|
:: 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;
|
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
|
:: X2UtMisc is a collection of functions not fitting into any of the other
|
||||||
:: categories.
|
:: categories.
|
||||||
::
|
::
|
||||||
:: Subversion repository available at:
|
|
||||||
:: $URL$
|
|
||||||
::
|
|
||||||
:: Last changed: $Date$
|
:: Last changed: $Date$
|
||||||
:: Revision: $Rev$
|
:: Revision: $Rev$
|
||||||
:: Author: $Author$
|
:: 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;
|
unit X2UtMisc;
|
||||||
|
|
||||||
|
29
X2UtOS.pas
29
X2UtOS.pas
@ -3,38 +3,9 @@
|
|||||||
:: with the Operating System, such as the version number.
|
:: with the Operating System, such as the version number.
|
||||||
:: It is part of the X2Utils suite.
|
:: It is part of the X2Utils suite.
|
||||||
::
|
::
|
||||||
:: Subversion repository available at:
|
|
||||||
:: $URL$
|
|
||||||
::
|
|
||||||
:: Last changed: $Date$
|
:: Last changed: $Date$
|
||||||
:: Revision: $Rev$
|
:: Revision: $Rev$
|
||||||
:: Author: $Author$
|
:: 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;
|
unit X2UtOS;
|
||||||
|
|
||||||
|
192
X2UtSettings.pas
192
X2UtSettings.pas
@ -3,83 +3,122 @@
|
|||||||
:: Include one of the extensions (X2UtSettingsINI, X2UtSettingsRegistry) for
|
:: Include one of the extensions (X2UtSettingsINI, X2UtSettingsRegistry) for
|
||||||
:: an implementation.
|
:: an implementation.
|
||||||
::
|
::
|
||||||
:: Subversion repository available at:
|
|
||||||
:: $URL$
|
|
||||||
::
|
|
||||||
:: Last changed: $Date$
|
:: Last changed: $Date$
|
||||||
:: Revision: $Rev$
|
:: Revision: $Rev$
|
||||||
:: Author: $Author$
|
:: 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;
|
unit X2UtSettings;
|
||||||
|
|
||||||
interface
|
interface
|
||||||
uses
|
uses
|
||||||
Classes;
|
Classes,
|
||||||
|
SysUtils,
|
||||||
|
Variants;
|
||||||
|
|
||||||
type
|
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.
|
:: Provides access to the settings regardless of the storage backend.
|
||||||
}
|
}
|
||||||
TX2Settings = class(TObject)
|
TX2Settings = class(TObject)
|
||||||
public
|
private
|
||||||
function ReadBool(const AName: String; const ADefault: Boolean = False): Boolean; virtual; abstract;
|
FFactory: TX2SettingsFactory;
|
||||||
function ReadFloat(const AName: String; const ADefault: Double = 0.0): Double; virtual; abstract;
|
FSection: String;
|
||||||
function ReadInteger(const AName: String; const ADefault: Integer = 0): Integer; virtual; abstract;
|
protected
|
||||||
function ReadString(const AName: String; const ADefault: String = ''): String; virtual; abstract;
|
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;
|
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;
|
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;
|
procedure WriteInteger(const AName: String; AValue: Integer); virtual; abstract;
|
||||||
|
|
||||||
|
//:$ Writes a string value to the settings.
|
||||||
procedure WriteString(const AName, AValue: String); virtual; abstract;
|
procedure WriteString(const AName, AValue: String); virtual; abstract;
|
||||||
|
|
||||||
|
//:$ Checks if the specified setting exists.
|
||||||
function ValueExists(const AName: String): Boolean; virtual; abstract;
|
function ValueExists(const AName: String): Boolean; virtual; abstract;
|
||||||
|
|
||||||
|
//:$ Retrieves the list of sub-sections for this section.
|
||||||
procedure GetSectionNames(const ADest: TStrings); virtual; abstract;
|
procedure GetSectionNames(const ADest: TStrings); virtual; abstract;
|
||||||
|
|
||||||
|
//:$ Retrieves the list of values for this section.
|
||||||
procedure GetValueNames(const ADest: TStrings); virtual; abstract;
|
procedure GetValueNames(const ADest: TStrings); virtual; abstract;
|
||||||
|
|
||||||
|
//:$ Deletes this section.
|
||||||
procedure DeleteSection(); virtual; abstract;
|
procedure DeleteSection(); virtual; abstract;
|
||||||
|
|
||||||
|
//:$ Deletes the specified value.
|
||||||
procedure DeleteValue(const AName: String); virtual; abstract;
|
procedure DeleteValue(const AName: String); virtual; abstract;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{
|
{
|
||||||
:$ Settings factory
|
:$ Settings factory.
|
||||||
|
|
||||||
:: Extensions must implement a factory descendant which an application can
|
:: Extensions must implement a factory descendant which an application can
|
||||||
:: create to provide application-wide access to the same settings.
|
:: create to provide application-wide access to the same settings.
|
||||||
}
|
}
|
||||||
TX2SettingsFactory = class(TObject)
|
TX2SettingsFactory = class(TObject)
|
||||||
protected
|
protected
|
||||||
function GetSection(const ASection: String): TX2Settings; virtual; abstract;
|
function GetSection(const ASection: String): TX2Settings; virtual; abstract;
|
||||||
public
|
public
|
||||||
//:$ Load a section from the settings
|
//:$ Loads a section from the settings.
|
||||||
//:: Sub-sections are indicated by seperating the sections with a dot ('.')
|
//:: Sub-sections are indicated by seperating the sections with a dot ('.')
|
||||||
//:: characters, ex: Sub.Section. The underlying extension will translate
|
//:: characters, ex: Sub.Section. The underlying extension will translate
|
||||||
//:: this into a compatible section.
|
//:: this into a compatible section.
|
||||||
@ -89,5 +128,76 @@ type
|
|||||||
|
|
||||||
|
|
||||||
implementation
|
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.
|
end.
|
||||||
|
@ -1,38 +1,9 @@
|
|||||||
{
|
{
|
||||||
:: X2UtSettingsForm provides functions to read and write form settings.
|
:: X2UtSettingsForm provides functions to read and write form settings.
|
||||||
::
|
::
|
||||||
:: Subversion repository available at:
|
|
||||||
:: $URL$
|
|
||||||
::
|
|
||||||
:: Last changed: $Date$
|
:: Last changed: $Date$
|
||||||
:: Revision: $Rev$
|
:: Revision: $Rev$
|
||||||
:: Author: $Author$
|
:: 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;
|
unit X2UtSettingsForm;
|
||||||
|
|
||||||
|
@ -1,38 +1,9 @@
|
|||||||
{
|
{
|
||||||
:: X2UtSettingsINI extends X2UtSettings with INI reading/writing.
|
:: X2UtSettingsINI extends X2UtSettings with INI reading/writing.
|
||||||
::
|
::
|
||||||
:: Subversion repository available at:
|
|
||||||
:: $URL$
|
|
||||||
::
|
|
||||||
:: Last changed: $Date$
|
:: Last changed: $Date$
|
||||||
:: Revision: $Rev$
|
:: Revision: $Rev$
|
||||||
:: Author: $Author$
|
:: 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;
|
unit X2UtSettingsINI;
|
||||||
|
|
||||||
@ -53,13 +24,12 @@ type
|
|||||||
private
|
private
|
||||||
FData: TMemIniFile;
|
FData: TMemIniFile;
|
||||||
FSection: String;
|
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
|
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 WriteBool(const AName: String; AValue: Boolean); override;
|
||||||
procedure WriteFloat(const AName: String; AValue: Double); override;
|
procedure WriteFloat(const AName: String; AValue: Double); override;
|
||||||
procedure WriteInteger(const AName: String; AValue: Integer); override;
|
procedure WriteInteger(const AName: String; AValue: Integer); override;
|
||||||
@ -73,7 +43,8 @@ type
|
|||||||
procedure DeleteSection(); override;
|
procedure DeleteSection(); override;
|
||||||
procedure DeleteValue(const AName: String); override;
|
procedure DeleteValue(const AName: String); override;
|
||||||
public
|
public
|
||||||
constructor Create(const AFilename, ASection: String);
|
constructor CreateInit(const AFactory: TX2SettingsFactory;
|
||||||
|
const ASection, AFilename: String);
|
||||||
destructor Destroy(); override;
|
destructor Destroy(); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -101,16 +72,16 @@ uses
|
|||||||
========================================}
|
========================================}
|
||||||
function TX2INISettingsFactory.GetSection;
|
function TX2INISettingsFactory.GetSection;
|
||||||
begin
|
begin
|
||||||
Result := TX2INISettings.Create(FFilename, ASection);
|
Result := TX2INISettings.CreateInit(Self, ASection, FFilename);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{========================= TX2INISettings
|
{========================= TX2INISettings
|
||||||
Initialization
|
Initialization
|
||||||
========================================}
|
========================================}
|
||||||
constructor TX2INISettings.Create;
|
constructor TX2INISettings.CreateInit;
|
||||||
begin
|
begin
|
||||||
inherited Create();
|
inherited Create(AFactory, ASection);
|
||||||
|
|
||||||
FData := TMemIniFile.Create(AFilename);
|
FData := TMemIniFile.Create(AFilename);
|
||||||
FSection := ASection;
|
FSection := ASection;
|
||||||
@ -128,24 +99,28 @@ end;
|
|||||||
{========================= TX2INISettings
|
{========================= TX2INISettings
|
||||||
Read
|
Read
|
||||||
========================================}
|
========================================}
|
||||||
function TX2INISettings.ReadBool;
|
function TX2INISettings.InternalReadBool;
|
||||||
begin
|
begin
|
||||||
Result := FData.ReadBool(FSection, AName, ADefault);
|
AValue := FData.ReadBool(FSection, AName, False);
|
||||||
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TX2INISettings.ReadFloat;
|
function TX2INISettings.InternalReadFloat;
|
||||||
begin
|
begin
|
||||||
Result := FData.ReadFloat(FSection, AName, ADefault);
|
AValue := FData.ReadFloat(FSection, AName, 0);
|
||||||
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TX2INISettings.ReadInteger;
|
function TX2INISettings.InternalReadInteger;
|
||||||
begin
|
begin
|
||||||
Result := FData.ReadInteger(FSection, AName, ADefault);
|
AValue := FData.ReadInteger(FSection, AName, 0);
|
||||||
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TX2INISettings.ReadString;
|
function TX2INISettings.InternalReadString;
|
||||||
begin
|
begin
|
||||||
Result := FData.ReadString(FSection, AName, ADefault);
|
AValue := FData.ReadString(FSection, AName, '');
|
||||||
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -59,13 +59,12 @@ type
|
|||||||
|
|
||||||
function OpenRead(): Boolean;
|
function OpenRead(): Boolean;
|
||||||
function OpenWrite(): 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
|
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 WriteBool(const AName: String; AValue: Boolean); override;
|
||||||
procedure WriteFloat(const AName: String; AValue: Double); override;
|
procedure WriteFloat(const AName: String; AValue: Double); override;
|
||||||
procedure WriteInteger(const AName: String; AValue: Integer); override;
|
procedure WriteInteger(const AName: String; AValue: Integer); override;
|
||||||
@ -79,7 +78,9 @@ type
|
|||||||
procedure DeleteSection(); override;
|
procedure DeleteSection(); override;
|
||||||
procedure DeleteValue(const AName: String); override;
|
procedure DeleteValue(const AName: String); override;
|
||||||
public
|
public
|
||||||
constructor Create(const ARoot: Cardinal; const AKey: String);
|
constructor CreateInit(const AFactory: TX2SettingsFactory;
|
||||||
|
const ASection: String;
|
||||||
|
const ARoot: Cardinal);
|
||||||
destructor Destroy(); override;
|
destructor Destroy(); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -110,26 +111,23 @@ uses
|
|||||||
Section
|
Section
|
||||||
========================================}
|
========================================}
|
||||||
function TX2RegistrySettingsFactory.GetSection;
|
function TX2RegistrySettingsFactory.GetSection;
|
||||||
var
|
|
||||||
sKey: String;
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
sKey := IncludeTrailingPathDelimiter(FKey) +
|
Result := TX2RegistrySettings.CreateInit(Self, ASection, FRoot);
|
||||||
StringReplace(ASection, '.', '\', [rfReplaceAll]);
|
|
||||||
Result := TX2RegistrySettings.Create(FRoot, sKey);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
{==================== TX2RegistrySettings
|
{==================== TX2RegistrySettings
|
||||||
Initialization
|
Initialization
|
||||||
========================================}
|
========================================}
|
||||||
constructor TX2RegistrySettings.Create;
|
constructor TX2RegistrySettings.CreateInit;
|
||||||
begin
|
begin
|
||||||
inherited Create();
|
inherited Create(AFactory, ASection);
|
||||||
|
|
||||||
FData := TRegistry.Create();
|
FData := TRegistry.Create();
|
||||||
FData.RootKey := ARoot;
|
FData.RootKey := ARoot;
|
||||||
FKey := AKey;
|
|
||||||
|
FKey := IncludeTrailingPathDelimiter(FKey) +
|
||||||
|
StringReplace(ASection, '.', '\', [rfReplaceAll]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
destructor TX2RegistrySettings.Destroy;
|
destructor TX2RegistrySettings.Destroy;
|
||||||
@ -169,50 +167,48 @@ end;
|
|||||||
{==================== TX2RegistrySettings
|
{==================== TX2RegistrySettings
|
||||||
Read
|
Read
|
||||||
========================================}
|
========================================}
|
||||||
function TX2RegistrySettings.ReadBool;
|
function TX2RegistrySettings.InternalReadBool;
|
||||||
begin
|
begin
|
||||||
Result := ADefault;
|
Result := False;
|
||||||
|
|
||||||
if (OpenRead()) and (FData.ValueExists(AName)) then
|
if OpenRead() then
|
||||||
try
|
begin
|
||||||
Result := FData.ReadBool(AName)
|
AValue := FData.ReadBool(AName);
|
||||||
except
|
Result := True;
|
||||||
// Silently ignore exceptions so the
|
end;
|
||||||
// default value gets returned
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TX2RegistrySettings.ReadFloat;
|
function TX2RegistrySettings.InternalReadFloat;
|
||||||
begin
|
begin
|
||||||
Result := ADefault;
|
Result := False;
|
||||||
|
|
||||||
if (OpenRead()) and (FData.ValueExists(AName)) then
|
if OpenRead() then
|
||||||
try
|
begin
|
||||||
Result := FData.ReadFloat(AName)
|
AValue := FData.ReadFloat(AName);
|
||||||
except
|
Result := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TX2RegistrySettings.ReadInteger;
|
function TX2RegistrySettings.InternalReadInteger;
|
||||||
begin
|
begin
|
||||||
Result := ADefault;
|
Result := False;
|
||||||
|
|
||||||
if (OpenRead()) and (FData.ValueExists(AName)) then
|
if OpenRead() then
|
||||||
try
|
begin
|
||||||
Result := FData.ReadInteger(AName)
|
AValue := FData.ReadInteger(AName);
|
||||||
except
|
Result := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TX2RegistrySettings.ReadString;
|
function TX2RegistrySettings.InternalReadString;
|
||||||
begin
|
begin
|
||||||
Result := ADefault;
|
Result := False;
|
||||||
|
|
||||||
if (OpenRead()) and (FData.ValueExists(AName)) then
|
if OpenRead() then
|
||||||
try
|
begin
|
||||||
Result := FData.ReadString(AName)
|
AValue := FData.ReadString(AName);
|
||||||
except
|
Result := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -2,38 +2,9 @@
|
|||||||
:: X2UtSingleInstance provides functions to detect previous instances of an
|
:: X2UtSingleInstance provides functions to detect previous instances of an
|
||||||
:: application and pass it the new command-line parameters.
|
:: application and pass it the new command-line parameters.
|
||||||
::
|
::
|
||||||
:: Subversion repository available at:
|
|
||||||
:: $URL$
|
|
||||||
::
|
|
||||||
:: Last changed: $Date$
|
:: Last changed: $Date$
|
||||||
:: Revision: $Rev$
|
:: Revision: $Rev$
|
||||||
:: Author: $Author$
|
:: 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;
|
unit X2UtSingleInstance;
|
||||||
|
|
||||||
|
@ -1,38 +1,9 @@
|
|||||||
{
|
{
|
||||||
:: X2UtStrings provides various string-related functions.
|
:: X2UtStrings provides various string-related functions.
|
||||||
::
|
::
|
||||||
:: Subversion repository available at:
|
|
||||||
:: $URL$
|
|
||||||
::
|
|
||||||
:: Last changed: $Date$
|
:: Last changed: $Date$
|
||||||
:: Revision: $Rev$
|
:: Revision: $Rev$
|
||||||
:: Author: $Author$
|
:: 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;
|
unit X2UtStrings;
|
||||||
|
|
||||||
|
@ -2,38 +2,9 @@
|
|||||||
:: X2UtVirtualTree provides a set of functions commonly used with
|
:: X2UtVirtualTree provides a set of functions commonly used with
|
||||||
:: TVirtualTree (http://www.delphi-gems.com/).
|
:: TVirtualTree (http://www.delphi-gems.com/).
|
||||||
::
|
::
|
||||||
:: Subversion repository available at:
|
|
||||||
:: $URL$
|
|
||||||
::
|
|
||||||
:: Last changed: $Date$
|
:: Last changed: $Date$
|
||||||
:: Revision: $Rev$
|
:: Revision: $Rev$
|
||||||
:: Author: $Author$
|
:: 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;
|
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