View Issue Details

IDProjectCategoryView StatusLast Update
0004358JEDI VCL00 JVCL Componentspublic2008-05-28 13:38
ReporterKiriakosAssigned Tojfudickar 
PrioritynormalSeverityfeatureReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version 
Summary0004358: Add support for TWideStringList in JvAppStrorage
DescriptionHere are the changes required:

In the interface section add:
    {$IFDEF COMPILER10_UP}
    { StringList item reader used by ReadWideStringList in the call to ReadList. }
    procedure ReadWideStringListItem(Sender: TJvCustomAppStorage; const Path: string;
      const List: TObject; const Index: Integer; const ItemName: string);
    { StringList item writer used by WriteStringList in the call to WriteList. }
    procedure WriteWideStringListItem(Sender: TJvCustomAppStorage; const Path: string;
      const List: TObject; const Index: Integer; const ItemName: string);
    { StringList item deleter used by WriteStringList in the call to WriteList. }
    procedure DeleteWideStringListItem(Sender: TJvCustomAppStorage; const Path: string;
      const List: TObject; const First, Last: Integer; const ItemName: string);
    {$ENDIF}

    {$IFDEF COMPILER10_UP}
    { Retrieves a wide string list. The string list is optionally cleared before reading starts. The
      result value is the number of items read. Uses ReadList with internally provided methods to
      do the actual reading. }
    function ReadWideStringList(const Path: string; const SL: TWideStrings;
      const ClearFirst: Boolean = True; const ItemName: string = cItem): Integer;
    { Stores a WideString list. Uses WriteList with internally provided methods to do the actual
      storing. }
    procedure WriteWideStringList(const Path: string; const SL: TWideStrings; const ItemName: string = cItem);
    {$ENDIF}

And in the implementation
{$IFDEF COMPILER10_UP}
procedure TJvCustomAppStorage.ReadWideStringListItem(Sender: TJvCustomAppStorage;
  const Path: string; const List: TObject; const Index: Integer; const ItemName: string);
begin
  if List is TWideStrings then
    TWideStrings(List).Add(Sender.ReadWideString(ConcatPaths([Path, ItemName + IntToStr(Index)])));
end;

procedure TJvCustomAppStorage.WriteWideStringListItem(Sender: TJvCustomAppStorage;
  const Path: string; const List: TObject; const Index: Integer; const ItemName: string);
begin
  if List is TWideStrings then
    Sender.WriteWideString(ConcatPaths([Path, ItemName + IntToStr(Index)]), TWideStrings(List)[Index]);
end;

procedure TJvCustomAppStorage.DeleteWideStringListItem(Sender: TJvCustomAppStorage;
  const Path: string; const List: TObject; const First, Last: Integer; const ItemName: string);
var
  I: Integer;
begin
  if List is TWideStrings then
    for I := First to Last do
      Sender.DeleteValue(ConcatPaths([Path, ItemName + IntToStr(I)]));
end;
{$ENDIF}

{$IFDEF COMPILER10_UP}
function TJvCustomAppStorage.ReadWideStringList(const Path: string; const SL: TWideStrings;
  const ClearFirst: Boolean = True; const ItemName: string = cItem): Integer;
begin
  if not ListStored(Path) and StorageOptions.DefaultIfValueNotExists then
    Result := SL.Count
  else
  begin
    SL.BeginUpdate;
    try
      if ClearFirst then
        SL.Clear;
      ReadPersistent(Path,SL,True,False);
      Result := ReadList(Path, SL, ReadWideStringListItem, ItemName);
    finally
      SL.EndUpdate;
    end;
  end;
end;

procedure TJvCustomAppStorage.WriteWideStringList(const Path: string;
  const SL: TWideStrings; const ItemName: string = cItem);
begin
  WriteList(Path, SL, SL.Count, WriteWideStringListItem, DeleteWideStringListItem, ItemName);
  WritePersistent(Path,SL);
end;
{$ENDIF}
TagsNo tags attached.

Activities

Kiriakos

2008-03-13 12:41

reporter   ~0014290

Sorry one more thing:
In the interface uses section add:

  {$IFDEF COMPILER10_UP} WideStrings,{$ENDIF}

jfudickar

2008-05-28 13:37

developer   ~0014312

Done and thanks

Issue History

Date Modified Username Field Change
2008-03-13 12:39 Kiriakos New Issue
2008-03-13 12:41 Kiriakos Note Added: 0014290
2008-05-28 02:07 jfudickar Status new => assigned
2008-05-28 02:07 jfudickar Assigned To => jfudickar
2008-05-28 02:07 jfudickar Status assigned => acknowledged
2008-05-28 13:37 jfudickar Status acknowledged => resolved
2008-05-28 13:37 jfudickar Resolution open => fixed
2008-05-28 13:37 jfudickar Note Added: 0014312