Pipes and test scripts
This commit is contained in:
@@ -9,6 +9,7 @@ uses
|
||||
Myc.Utils,
|
||||
Myc.Data.Scalar,
|
||||
Myc.Data.Series,
|
||||
Myc.Data.Stream,
|
||||
Myc.Data.Keyword;
|
||||
|
||||
type
|
||||
@@ -24,6 +25,7 @@ type
|
||||
vkMethod,
|
||||
vkInterface,
|
||||
vkPointer,
|
||||
vkStream,
|
||||
vkGeneric
|
||||
);
|
||||
|
||||
@@ -86,6 +88,9 @@ type
|
||||
class function FromGenericRecord(const AValue: IKeywordMapping<TDataValue>): TDataValue; static; inline;
|
||||
class function FromSeries(const AValue: ISeries): TDataValue; static; inline;
|
||||
|
||||
// New Factory for Streams
|
||||
class function FromStream(const AStream: IStream): TDataValue; static; inline;
|
||||
|
||||
// --- Existing Accessors ---
|
||||
function AsScalar: TScalar; inline;
|
||||
function AsMethod: TFunc; inline;
|
||||
@@ -96,6 +101,9 @@ type
|
||||
function AsSeries: ISeries; inline;
|
||||
function AsObject: TObject; overload; inline;
|
||||
|
||||
// New Accessor for Streams
|
||||
function AsStream: IStream; inline;
|
||||
|
||||
function ToString: String;
|
||||
property IsVoid: Boolean read GetIsVoid;
|
||||
property Kind: TDataValueKind read FKind;
|
||||
@@ -141,6 +149,7 @@ begin
|
||||
vkInterface: Result := 'Interface';
|
||||
vkPointer: Result := 'Pointer';
|
||||
vkGeneric: Result := 'Generic';
|
||||
vkStream: Result := 'Stream';
|
||||
else
|
||||
Result := 'Unknown';
|
||||
end;
|
||||
@@ -273,6 +282,12 @@ begin
|
||||
Result.FInterface := AValue;
|
||||
end;
|
||||
|
||||
class function TDataValue.FromStream(const AStream: IStream): TDataValue;
|
||||
begin
|
||||
Result.FKind := vkStream;
|
||||
Result.FInterface := AStream;
|
||||
end;
|
||||
|
||||
class function TDataValue.Map(const SourceSeries: ISeries; const MapperFunc: TFunc): ISeries;
|
||||
begin
|
||||
Result := TMapSeries.Create(SourceSeries, MapperFunc);
|
||||
@@ -285,6 +300,13 @@ begin
|
||||
Result := ISeries(FInterface);
|
||||
end;
|
||||
|
||||
function TDataValue.AsStream: IStream;
|
||||
begin
|
||||
if (FKind <> vkStream) then
|
||||
raise EInvalidCast.Create('Cannot read value as Stream.');
|
||||
Result := IStream(FInterface);
|
||||
end;
|
||||
|
||||
function TDataValue.AsMethod: TFunc;
|
||||
begin
|
||||
if (FKind <> vkMethod) then
|
||||
@@ -443,6 +465,7 @@ begin
|
||||
sb.Free;
|
||||
end;
|
||||
end;
|
||||
vkStream: Result := '<stream>';
|
||||
vkVoid: Result := '<void>';
|
||||
vkMethod: Result := '<method>';
|
||||
vkGeneric: Result := '<generic>';
|
||||
|
||||
Reference in New Issue
Block a user