Einzelnen Beitrag anzeigen

Bjoerk

Registriert seit: 28. Feb 2011
Ort: Mannheim
1.384 Beiträge
 
Delphi 10.4 Sydney
 
#6

AW: anstelle auf Festplatte in den Arbeostspeicher schreiben

  Alt 11. Mär 2016, 08:44
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;
  Mit Zitat antworten Zitat