diff --git a/components/rx/trunk/rxmemds.pas b/components/rx/trunk/rxmemds.pas index 59b103cf7..9e77f4364 100644 --- a/components/rx/trunk/rxmemds.pas +++ b/components/rx/trunk/rxmemds.pas @@ -1,6 +1,6 @@ { rxmemds unit - Copyright (C) 2005-2010 Lagunov Aleksey alexs@yandex.ru and Lazarus team + Copyright (C) 2005-2014 Lagunov Aleksey alexs@hotbox.ru and Lazarus team original conception from rx library for Delphi (c) This library is free software; you can redistribute it and/or modify it @@ -91,8 +91,8 @@ type procedure SetOnFilterRecordEx(const AValue: TFilterRecordEvent); procedure Sort; function CalcRecordSize: Integer; -// function FindFieldData(Buffer: Pointer; Field: TField): Pointer;overload; - function FindFieldData(Buffer: Pointer; FieldNo:Integer): Pointer; //overload; + function FindFieldData(Buffer: Pointer; Field: TField): Pointer;overload; + function FindFieldData(Buffer: Pointer; FieldNo:Integer): Pointer;overload; function GetMemoryRecord(Index: Integer): TMemoryRecord; function GetCapacity: Integer; function RecordFilter: Boolean; @@ -612,17 +612,21 @@ begin end; end; -{ function TRxMemoryData.FindFieldData(Buffer: Pointer; Field: TField): Pointer; var Index: Integer; begin +{.$IFDEF TEST_RXMDS} Index := FieldDefs.IndexOf(Field.FieldName); +// if Index <> Field.FieldNo - 1 then - raise exception.Create('Index <> Field.FieldNo - 1'); + raise exception.Create('Index <> Field.FieldNo - 1'); +{.$ENDIF} +// Index := Field.FieldNo - 1; +// Result:=FindFieldData(Buffer, Index); end; -} + function TRxMemoryData.FindFieldData(Buffer: Pointer; FieldNo: Integer): Pointer; begin Result := nil; @@ -876,8 +880,7 @@ begin if Field.FieldNo > 0 then {$ENDIF} begin - Data := FindFieldData(RecBuf, Field.FieldNo-1); -// Data := FindFieldData(RecBuf, Field); + Data := FindFieldData(RecBuf, Field); if Data <> nil then begin Result := Boolean(Data[0]); Inc(Data); @@ -892,7 +895,6 @@ begin else Move(Data^, Buffer^, CalcFieldLen(Field.DataType, Field.Size)); end; - Result := true; end else begin @@ -928,8 +930,7 @@ begin Validate(Buffer); if FieldKind <> fkInternalCalc then begin -// Data := FindFieldData(RecBuf, Field); - Data := FindFieldData(RecBuf, Field.FieldNo-1); + Data := FindFieldData(RecBuf, Field); if Data <> nil then begin if DataType = ftVariant then @@ -1194,8 +1195,7 @@ begin if (Fields[I].FieldKind in fkStoredFields) and (Fields[I].DataType = ftAutoInc) then begin -// Data := FindFieldData(Buffer, Fields[I]); - Data := FindFieldData(Buffer, Fields[I].FieldNo-1); + Data := FindFieldData(Buffer, Fields[I]); if Data <> nil then begin Boolean(Data[0]) := True; Inc(Data); @@ -1339,8 +1339,7 @@ var Item:TMemoryRecord; begin Item:=Records[SrcRecNo]; -// Data1 := FindFieldData(Item.Data, AField); - Data1 := FindFieldData(Item.Data, AField.FieldNo-1); + Data1 := FindFieldData(Item.Data, AField); Inc(Data1); //Skip null flag case AField.DataType of @@ -1669,7 +1668,7 @@ end; procedure TRxMemoryData.SortOnFieldsEx(const FieldNames: string; CaseInsensitive: Boolean; Asc: array of boolean); begin - { TODO -oalexs : Необходимо написать сортировку по массиву } + end; procedure TRxMemoryData.Sort; @@ -1739,21 +1738,14 @@ var I: Integer; begin Result := 0; - if FIndexList <> nil then - begin - for I := 0 to FIndexList.Count - 1 do - begin + if FIndexList <> nil then begin + for I := 0 to FIndexList.Count - 1 do begin F := TField(FIndexList[I]); -// Data1 := FindFieldData(Item1.Data, F); - Data1 := FindFieldData(Item1.Data, F.FieldNo-1); - if Data1 <> nil then - begin -// Data2 := FindFieldData(Item2.Data, F); - Data2 := FindFieldData(Item2.Data, F.FieldNo-1); - if Data2 <> nil then - begin - if Boolean(Data1[0]) and Boolean(Data2[0]) then - begin + Data1 := FindFieldData(Item1.Data, F); + if Data1 <> nil then begin + Data2 := FindFieldData(Item2.Data, F); + if Data2 <> nil then begin + if Boolean(Data1[0]) and Boolean(Data2[0]) then begin Inc(Data1); Inc(Data2); Result := CompareFields(Data1, Data2, F.DataType,