git-svn-id: trunk@5585 -
This commit is contained in:
michael 2006-12-13 19:58:09 +00:00
parent ce60903bad
commit 387d19aa3f

View File

@ -32,7 +32,7 @@
* the SectionList object structure) * the SectionList object structure)
* - ReadInteger supports '0x' type hex formats * - ReadInteger supports '0x' type hex formats
* - Comment support (this isn't standard in ini files) * - Comment support (this isn't standard in ini files)
* - EscapeLineFeeds property * - EscapeLineFeeds creation parameter
* *
* Since the SectionList object structure is very different from the * Since the SectionList object structure is very different from the
* way Delphi 5 accesses ini files (Delphi mostly uses Windows calls * way Delphi 5 accesses ini files (Delphi mostly uses Windows calls
@ -71,8 +71,7 @@ type
function KeyByName(AName: string; CaseSensitive : Boolean): TIniFileKey; function KeyByName(AName: string; CaseSensitive : Boolean): TIniFileKey;
public public
destructor Destroy; override; destructor Destroy; override;
procedure Clear; procedure Clear; override;
override;
property Items[Index: integer]: TIniFileKey read GetItem; default; property Items[Index: integer]: TIniFileKey read GetItem; default;
end; end;
@ -103,7 +102,7 @@ override;
FEscapeLineFeeds: boolean; FEscapeLineFeeds: boolean;
FCaseSensitive : Boolean; FCaseSensitive : Boolean;
public public
constructor Create(const AFileName: string); virtual; constructor Create(const AFileName: string; AEscapeLineFeeds : Boolean = False); virtual;
destructor Destroy; override; destructor Destroy; override;
function SectionExists(const Section: string): Boolean; virtual; function SectionExists(const Section: string): Boolean; virtual;
function ReadString(const Section, Ident, Default: string): string; virtual; abstract; function ReadString(const Section, Ident, Default: string): string; virtual; abstract;
@ -128,7 +127,7 @@ override;
procedure UpdateFile; virtual; abstract; procedure UpdateFile; virtual; abstract;
function ValueExists(const Section, Ident: string): Boolean; virtual; function ValueExists(const Section, Ident: string): Boolean; virtual;
property FileName: string read FFileName; property FileName: string read FFileName;
property EscapeLineFeeds: boolean read FEscapeLineFeeds write FEscapeLineFeeds; property EscapeLineFeeds: boolean read FEscapeLineFeeds;
Property CaseSensitive : Boolean Read FCaseSensitive Write FCaseSensitive; Property CaseSensitive : Boolean Read FCaseSensitive Write FCaseSensitive;
end; end;
@ -144,8 +143,8 @@ override;
procedure MaybeUpdateFile; procedure MaybeUpdateFile;
property Dirty : Boolean Read FDirty; property Dirty : Boolean Read FDirty;
public public
constructor Create(const AFileName: string); override; constructor Create(const AFileName: string; AEscapeLineFeeds : Boolean = False); override;
constructor Create(AStream: TStream); constructor Create(AStream: TStream; AEscapeLineFeeds : Boolean = False);
destructor Destroy; override; destructor Destroy; override;
function ReadString(const Section, Ident, Default: string): string; override; function ReadString(const Section, Ident, Default: string): string; override;
procedure WriteString(const Section, Ident, Value: String); override; procedure WriteString(const Section, Ident, Value: String); override;
@ -162,7 +161,7 @@ override;
TMemIniFile = class(TIniFile) TMemIniFile = class(TIniFile)
public public
constructor Create(const AFileName: string); override; constructor Create(const AFileName: string; AEscapeLineFeeds : Boolean = False); override;
procedure Clear; procedure Clear;
procedure GetStrings(List: TStrings); procedure GetStrings(List: TStrings);
procedure Rename(const AFileName: string; Reload: Boolean); procedure Rename(const AFileName: string; Reload: Boolean);
@ -315,11 +314,11 @@ end;
{ TCustomIniFile } { TCustomIniFile }
constructor TCustomIniFile.Create(const AFileName: string); constructor TCustomIniFile.Create(const AFileName: string; AEscapeLineFeeds : Boolean = False);
begin begin
FFileName := AFileName; FFileName := AFileName;
FSectionList := TIniFileSectionList.Create; FSectionList := TIniFileSectionList.Create;
FEscapeLineFeeds := False; FEscapeLineFeeds := AEscapeLineFeeds;
end; end;
destructor TCustomIniFile.Destroy; destructor TCustomIniFile.Destroy;
@ -458,11 +457,11 @@ end;
{ TIniFile } { TIniFile }
constructor TIniFile.Create(const AFileName: string); constructor TIniFile.Create(const AFileName: string; AEscapeLineFeeds : Boolean = False);
var var
slLines: TStringList; slLines: TStringList;
begin begin
inherited Create(AFileName); inherited Create(AFileName,AEscapeLineFeeds);
FStream := nil; FStream := nil;
slLines := TStringList.Create; slLines := TStringList.Create;
try try
@ -478,11 +477,11 @@ begin
end; end;
end; end;
constructor TIniFile.Create(AStream: TStream); constructor TIniFile.Create(AStream: TStream; AEscapeLineFeeds : Boolean = False);
var var
slLines: TStringList; slLines: TStringList;
begin begin
inherited Create(''); inherited Create('',AEscapeLineFeeds);
FStream := AStream; FStream := AStream;
slLines := TStringList.Create; slLines := TStringList.Create;
try try
@ -509,31 +508,23 @@ var
procedure RemoveBackslashes; procedure RemoveBackslashes;
var var
i: integer; i,l: integer;
s: string; s: string;
bAppendNextLine, bAppended: boolean; bAppendNextLine, bAppended: boolean;
begin begin
AStrings.BeginUpdate; AStrings.BeginUpdate;
try try
i := 0; For I:=AStrings.Count-2 downto 0 do
bAppendNextLine := False; begin
while i < AStrings.Count do begin S:=AStrings[i];
s := AStrings[i]; L:=Length(S);
bAppended := False; If (I<AStrings.Count-1) and (L>0) and (S[L]=LF_Escape) then
if bAppendNextLine then begin begin
// add line to previous line S:=Copy(S,1,L-1)+AStrings[I+1];
AStrings[i-1] := AStrings[i-1] + Trim(s); AStrings.Delete(I+1);
AStrings.Delete(i); AStrings[i]:=S;
s := AStrings[i-1]; end;
bAppended := True;
end; end;
bAppendNextLine := (Copy(s, Length(s), 1) = LF_Escape);
if bAppendNextLine then
// remove backslash
AStrings[i] := Copy(s, 1, Length(s) - 1);
if not bAppended then
Inc(i);
end;
finally finally
AStrings.EndUpdate; AStrings.EndUpdate;
end; end;
@ -782,7 +773,7 @@ end;
{ TMemIniFile } { TMemIniFile }
constructor TMemIniFile.Create(const AFileName: string); constructor TMemIniFile.Create(const AFileName: string; AEscapeLineFeeds : Boolean = False);
begin begin
Inherited; Inherited;