![]() |
Anstelle auf Festplatte in den Arbeitsspeicher schreiben
ich verwende bisher eine Funktion
Delphi-Quellcode:
procedure Savedata2IniFile (aFilename : String; aData : TmyData );
var fIni: TIniFile; begin if aFilename <> '' then begin try fIni := TIniFile.Create(aFilename); ..... end; Anstelle jetzt die Daten auf meiner Festplatte abzuspeichern möchte ich direkt eine StringListe meiner Datei zurückbekommen also
Delphi-Quellcode:
procedure MyNewSavedata2IniFile ( aList : TStringlist; aData : TmyData );
begin aFilename :='save to a new Objecttype ???? ' Savedata2IniFile (aFilename : String; aData ); LoadFromVirtualIniFile ( ......, aList ); end; Gibt es hier eine Lösung da ich nicht alle Funktionen zum lesen und schreiben der Ini File 2 x implementieren will .... |
AW: anstelle auf Festplatte in den Arbeostspeicher schreiben
Da müßte etwas hier zu finden sein. Such mal TMeminifile. Wenn ich mich recht erinnere ging es damals um die Schnelligkeit des TInifiles und seine Beschränkungen. (64KB?)
Gruß K-H P.S. ich find's nicht mehr TP7-Hilfe: Zitat:
|
AW: anstelle auf Festplatte in den Arbeostspeicher schreiben
Über die WinAPI (TIniFile) wird es mit "vielen" Einträgen langsamer.
Auch Multiplatform kann man mit dr WinAPI nicht. Aber die 64K wurden schon vor paar Jahren seitens Mikrosoft behoben. |
AW: anstelle auf Festplatte in den Arbeostspeicher schreiben
versuche jetzt hier weiter zu machen ....
Delphi-Quellcode:
besserer Ansatz ?
TMemoryIniFile = Class(TStringList)
private function getSectionIndex(aSection: String): Integer; public procedure WriteString(section: String; ident, value: String); End; function TMemoryIniFile.getSectionIndex(aSection: String): Integer; var i: Integer; SectionStr: String; begin SectionStr := '[' + aSection + ']'; i := self.IndexOf(SectionStr); if (i < 0) then begin self.Add(SectionStr); end; result := self.IndexOf(SectionStr); end; procedure TMemoryIniFile.WriteString(section, ident, value: String); begin self.Insert(getSectionIndex(section), ident + '=' + value); end; |
AW: anstelle auf Festplatte in den Arbeostspeicher schreiben
Zitat:
Delphi-Quellcode:
TMemIniFile = class(TCustomIniFile)
private FSections: TStringList; function AddSection(const Section: string): TStrings; function GetCaseSensitive: Boolean; procedure LoadValues; procedure SetCaseSensitive(Value: Boolean); public constructor Create(const FileName: string); destructor Destroy; override; procedure Clear; procedure DeleteKey(const Section, Ident: String); override; procedure EraseSection(const Section: string); override; procedure GetStrings(List: TStrings); procedure ReadSection(const Section: string; Strings: TStrings); override; procedure ReadSections(Strings: TStrings); override; procedure ReadSectionValues(const Section: string; Strings: TStrings); override; function ReadString(const Section, Ident, Default: string): string; override; procedure Rename(const FileName: string; Reload: Boolean); procedure SetStrings(List: TStrings); procedure UpdateFile; override; procedure WriteString(const Section, Ident, Value: String); override; property CaseSensitive: Boolean read GetCaseSensitive write SetCaseSensitive; end; |
AW: anstelle auf Festplatte in den Arbeostspeicher schreiben
Ich verwende ziemlich exzessiv das Inifileformat. Ich habe deshalb vor Jahren mal eine Klasse TIniData. Ist auf Geschwindigkeit ausgelegt. Soll ich die mal anhängen?
Delphi-Quellcode:
TIniData = class
private FUtils: TIniUtils; FSections: TIniSections; FDecimalSeparator: char; function IniFloatToStr(const Value: double): string; function IniStrToFloat(const S: string): double; function IniSection(const S: string): boolean; function IniLine(var S: string): boolean; function ExtractSection(const S: string): string; function ExtractIdent(const S: string; const Index: integer): string; function ExtractValue(const S: string; const Index: integer): string; procedure ExtractIniLine(const Line: string; var Section, Ident, Value: string); function SectionFound(const Section: string; var SectionIndex: integer): boolean; function KeyFound(const Ident: string; const SectionIndex: integer; var KeyIndex: integer): boolean; function Read(const Section, Ident: string; var StrValue: string): boolean; procedure Write(const Section, Ident, StrValue: string); public procedure LoadFromFile(const FileName: string); procedure SaveToFile(const FileName: string); function SectionExists(const Section: string): boolean; function IdentExists(const Section, Ident: string): boolean; function ValueExists(const Section, Ident: string): boolean; function ReadString(const Section, Ident, Default: string): string; function ReadChar(const Section, Ident: string; const Default: char): char; function ReadInteger(const Section, Ident: string; const Default: integer): integer; function ReadBool(const Section, Ident: string; const Default: boolean): boolean; function ReadFloat(const Section, Ident: string; const Default: double): double; function ReadDateTime(const Section, Ident: string; const Default: TDateTime): TDateTime; function ReadTime(const Section, Ident: string; const Default: TDateTime): TDateTime; function ReadDate(const Section, Ident: string; const Default: TDateTime): TDateTime; function ReadInt64(const Section, Ident: string; const Default: int64): int64; function ReadColor(const Section, Ident: string; const Default: TColor): TColor; function ReadBrushStyle(const Section, Ident: string; const Default: TBrushStyle): TBrushStyle; function ReadFontStyles(const Section, Ident: string; const Default: TFontStyles): TFontStyles; function ReadPenStyle(const Section, Ident: string; const Default: TPenStyle): TPenStyle; function ReadBinaryStream(const Section, Ident: string; Value: TStream): integer; function ReadGraphic(const Section, Ident: string; Value: TGraphic): integer; procedure WriteString(const Section, Ident, Value: string); procedure WriteChar(const Section, Ident: string; const Value: char); procedure WriteInteger(const Section, Ident: string; const Value: integer); procedure WriteBool(const Section, Ident: string; const Value: boolean); procedure WriteFloat(const Section, Ident: string; const Value: double); procedure WriteDateTime(const Section, Ident: string; const Value: TDateTime); procedure WriteTime(const Section, Ident: string; const Value: TDateTime); procedure WriteDate(const Section, Ident: string; const Value: TDateTime); procedure WriteInt64(const Section, Ident: string; const Value: int64); procedure WriteColor(const Section, Ident: string; const Value: TColor); procedure WriteBrushStyle(const Section, Ident: string; const Value: TBrushStyle); procedure WriteFontStyles(const Section, Ident: string; const Value: TFontStyles); procedure WritePenStyle(const Section, Ident: string; const Value: TPenStyle); procedure WriteBinaryStream(const Section, Ident: string; Value: TStream); procedure WriteGraphic(const Section, Ident: string; Value: TGraphic); procedure EraseSection(const Section: string); procedure DeleteKey(const Section, Ident: string); procedure ReadSections(Strings: TStrings); procedure ReadIdents(const Section: string; Strings: TStrings); procedure ReadValues(const Section: string; Strings: TStrings); procedure Clear; procedure Assign(Value: TIniData); function Compare(Value: TIniData): boolean; property DecimalSeparator: char read FDecimalSeparator write FDecimalSeparator; constructor Create; destructor Destroy; override; end; |
AW: Anstelle auf Festplatte in den Arbeitsspeicher schreiben
Ja, bitte Bjoerk.
Das sieht sehr interessant aus. Danke Dir! |
AW: Anstelle auf Festplatte in den Arbeitsspeicher schreiben
Liste der Anhänge anzeigen (Anzahl: 1)
Also, ist kein Wunderding. Ist eine ganze normale Klasse mit Methoden Assign, Clear, LoadFromFile und SaveToFile. Die Einträge selbst werden über die verschiedenen Reads und Writes angesprochen. Mich hat gewundert, daß diese Klasse nur mit Bordmitteln doch teilweise schneller ist als TMemInifile, insbesondere bei SaveToFile. Ich hab auch ein paar Methoden eingebaut, die bei mir oft vorkommen z.B. Read/WriteFontStyles oder Read/WriteGraphic. Über Sinn und Unsinn eines beinahe TMemIniFile Clons kann man sicherlich streiten. Anyway, here we go:
|
AW: Anstelle auf Festplatte in den Arbeitsspeicher schreiben
@Bjoerk
Kann deine Klasse mit SubSections umgehen?
Delphi-Quellcode:
kann das und das macht wohl dann auch einen Teil der Langsamkeit aus.
TMemIniFile
Solche Klassen leite ich eigentlich immer von
Delphi-Quellcode:
ab und implementiere
TInterfacedPersistent
Delphi-Quellcode:
. Das
IStreamPersist
Delphi-Quellcode:
und
LoadFromFile
Delphi-Quellcode:
erstellt einfach nur den FileStream und nimmt die Stream-Methoden.
SaveToFile
|
AW: Anstelle auf Festplatte in den Arbeitsspeicher schreiben
Zitat:
|
Alle Zeitangaben in WEZ +1. Es ist jetzt 12:44 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz