IScalarRecord
This commit is contained in:
+17
-17
@@ -9,7 +9,8 @@ uses
|
||||
Myc.Utils,
|
||||
Myc.Data.Scalar,
|
||||
Myc.Data.Series,
|
||||
Myc.Data.Keyword;
|
||||
Myc.Data.Keyword,
|
||||
Myc.Trade.DataFeed;
|
||||
|
||||
type
|
||||
TDataValueKind = (
|
||||
@@ -18,7 +19,7 @@ type
|
||||
vkText,
|
||||
vkSeries,
|
||||
vkRecordSeries,
|
||||
vkRecord,
|
||||
vkScalarRecord,
|
||||
vkGenericRecord,
|
||||
vkManagedObject,
|
||||
vkMethod,
|
||||
@@ -78,7 +79,7 @@ type
|
||||
class function Map(const SourceSeries: ISeries; const MapperFunc: TFunc): ISeries; static;
|
||||
|
||||
class function FromRecordSeries(const AValue: IRecordSeries): TDataValue; static; inline;
|
||||
class function FromRecord(const [ref] AValue: TScalarRecord): TDataValue; static; inline;
|
||||
class function FromScalarRecord(const AValue: IScalarRecord): TDataValue; static; inline;
|
||||
class function FromGenericRecord(const AValue: IKeywordMapping<TDataValue>): TDataValue; static; inline;
|
||||
class function FromSeries(const AValue: ISeries): TDataValue; static; inline;
|
||||
|
||||
@@ -86,7 +87,7 @@ type
|
||||
function AsMethod: TFunc; inline;
|
||||
function AsText: String; inline;
|
||||
function AsRecordSeries: IRecordSeries; inline;
|
||||
function AsRecord: TScalarRecord; inline;
|
||||
function AsScalarRecord: IScalarRecord; inline;
|
||||
function AsGenericRecord: IKeywordMapping<TDataValue>; inline;
|
||||
function AsSeries: ISeries; inline;
|
||||
function AsObject: TObject; overload; inline;
|
||||
@@ -190,11 +191,11 @@ begin
|
||||
Result := Pointer(FScalar.Value.AsInt64);
|
||||
end;
|
||||
|
||||
function TDataValue.AsRecord: TScalarRecord;
|
||||
function TDataValue.AsScalarRecord: IScalarRecord;
|
||||
begin
|
||||
if (FKind <> vkRecord) then
|
||||
if (FKind <> vkScalarRecord) then
|
||||
raise EInvalidCast.Create('Cannot read value as Record.');
|
||||
Result := (FInterface as TVal<TScalarRecord>).Value;
|
||||
Result := IScalarRecord(FInterface);
|
||||
end;
|
||||
|
||||
function TDataValue.AsGenericRecord: IKeywordMapping<TDataValue>;
|
||||
@@ -253,10 +254,10 @@ begin
|
||||
Result.FInterface := AValue;
|
||||
end;
|
||||
|
||||
class function TDataValue.FromRecord(const [ref] AValue: TScalarRecord): TDataValue;
|
||||
class function TDataValue.FromScalarRecord(const AValue: IScalarRecord): TDataValue;
|
||||
begin
|
||||
Result.FKind := vkRecord;
|
||||
Result.FInterface := TVal<TScalarRecord>.Create(AValue);
|
||||
Result.FKind := vkScalarRecord;
|
||||
Result.FInterface := AValue;
|
||||
end;
|
||||
|
||||
class function TDataValue.FromGenericRecord(const AValue: IKeywordMapping<TDataValue>): TDataValue;
|
||||
@@ -333,24 +334,23 @@ begin
|
||||
sb.Free;
|
||||
end;
|
||||
end;
|
||||
vkRecord:
|
||||
vkScalarRecord:
|
||||
begin
|
||||
var rec := AsRecord;
|
||||
var rec := AsScalarRecord;
|
||||
sb := TStringBuilder.Create;
|
||||
try
|
||||
sb.Append('{');
|
||||
first := True;
|
||||
for i := 0 to rec.Def.Count - 1 do
|
||||
for i := 0 to rec.Count - 1 do
|
||||
begin
|
||||
if not first then
|
||||
sb.Append(',');
|
||||
field := rec.Def[i];
|
||||
sb.Append(field.Key.Name);
|
||||
sb.Append(rec[i].Key.Name);
|
||||
first := False;
|
||||
end;
|
||||
sb.Append('}');
|
||||
// Add field names for records
|
||||
Result := Format('<record%s>', [sb.ToString]);
|
||||
Result := Format('<scalar_record%s>', [sb.ToString]);
|
||||
finally
|
||||
sb.Free;
|
||||
end;
|
||||
@@ -434,7 +434,7 @@ begin
|
||||
vkText: Result := 'Text';
|
||||
vkSeries: Result := 'Series';
|
||||
vkRecordSeries: Result := 'RecordSeries';
|
||||
vkRecord: Result := 'Record';
|
||||
vkScalarRecord: Result := 'ScalarRecord';
|
||||
vkGenericRecord: Result := 'GenericRecord';
|
||||
vkMethod: Result := 'Method';
|
||||
vkInterface: Result := 'Interface';
|
||||
|
||||
Reference in New Issue
Block a user