Changeset 468 for Common


Ignore:
Timestamp:
Dec 4, 2014, 5:22:21 PM (10 years ago)
Author:
chronos
Message:
  • Added: Licence property for ApplicationInfo.
  • Added: Simpler function to load/store values to XML node.
Location:
Common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Common/UApplicationInfo.pas

    r463 r468  
    1515  private
    1616    FIdentification: Byte;
     17    FLicense: string;
    1718    FVersionMajor: Byte;
    1819    FVersionMinor: Byte;
     
    4748    property RegistryKey: string read FRegistryKey write FRegistryKey;
    4849    property RegistryRoot: TRegistryRoot read FRegistryRoot write FRegistryRoot;
     50    property License: string read FLicense write FLicense;
    4951  end;
    5052
  • Common/UXMLUtils.pas

    r378 r468  
    77uses
    88  {$IFDEF WINDOWS}Windows,{$ENDIF}
    9   Classes, SysUtils, DateUtils;
     9  Classes, SysUtils, DateUtils, XMLRead, XMLWrite, DOM;
    1010
    1111function XMLTimeToDateTime(XMLDateTime: string): TDateTime;
    1212function DateTimeToXMLTime(Value: TDateTime; ApplyLocalBias: Boolean = True): WideString;
     13procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer);
     14procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean);
     15procedure WriteString(Node: TDOMNode; Name: string; Value: string);
     16function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer;
     17function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean;
     18function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string;
    1319
    1420
     
    123129end;
    124130
     131procedure WriteInteger(Node: TDOMNode; Name: string; Value: Integer);
     132var
     133  NewNode: TDOMNode;
     134begin
     135  NewNode := Node.OwnerDocument.CreateElement(Name);
     136  NewNode.TextContent := IntToStr(Value);
     137  Node.AppendChild(NewNode);
     138end;
     139
     140procedure WriteBoolean(Node: TDOMNode; Name: string; Value: Boolean);
     141var
     142  NewNode: TDOMNode;
     143begin
     144  NewNode := Node.OwnerDocument.CreateElement(Name);
     145  NewNode.TextContent := BoolToStr(Value);
     146  Node.AppendChild(NewNode);
     147end;
     148
     149procedure WriteString(Node: TDOMNode; Name: string; Value: string);
     150var
     151  NewNode: TDOMNode;
     152begin
     153  NewNode := Node.OwnerDocument.CreateElement(Name);
     154  NewNode.TextContent := Value;
     155  Node.AppendChild(NewNode);
     156end;
     157
     158function ReadInteger(Node: TDOMNode; Name: string; DefaultValue: Integer): Integer;
     159var
     160  NewNode: TDOMNode;
     161begin
     162  Result := DefaultValue;
     163  NewNode := Node.FindNode(Name);
     164  if Assigned(NewNode) then
     165    Result := StrToInt(NewNode.TextContent);
     166end;
     167
     168function ReadBoolean(Node: TDOMNode; Name: string; DefaultValue: Boolean): Boolean;
     169var
     170  NewNode: TDOMNode;
     171begin
     172  Result := DefaultValue;
     173  NewNode := Node.FindNode(Name);
     174  if Assigned(NewNode) then
     175    Result := StrToBool(NewNode.TextContent);
     176end;
     177
     178function ReadString(Node: TDOMNode; Name: string; DefaultValue: string): string;
     179var
     180  NewNode: TDOMNode;
     181begin
     182  Result := DefaultValue;
     183  NewNode := Node.FindNode(Name);
     184  if Assigned(NewNode) then
     185    Result := NewNode.TextContent;
     186end;
     187
    125188end.
    126189
Note: See TracChangeset for help on using the changeset viewer.