⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 _stregex.pas

📁 条码控件: 一维条码控件 二维条码控件 PDF417Barcode MaxiCodeBarcode
💻 PAS
📖 第 1 页 / 共 2 页
字号:

function TStRegEx.Get_OutLineTerminitor: Integer;
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  Result := TStLineTerminator(FStRegEx.OutLineTerminator);
end;

function TStRegEx.Get_OutputOptions: TStOutputOption;
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  Result := 0;
  if (StRegEx.ooUnSelected in FStRegEx.OutputOptions) then
    Result := Result + ooUnSelected;

  if (StRegEx.ooModified in FStRegEx.OutputOptions) then
    Result := Result + ooModified;

  if (StRegEx.ooUnSelected in FStRegEx.OutputOptions) then
    Result := Result + ooCountOnly;
end;

function TStRegEx.Get_ReplacePattern: IStStringList;
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  Result := FReplacePattern;
end;

function TStRegEx.Get_SelAvoidPattern: IStStringList;
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  Result := FSelAvoidPattern;
end;

function TStRegEx.Get_Stream: OleVariant;
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  Result := StStreamToOleVariant(FStRegEx.OutputStream);
end;

{ ********** TStRegExp Properties *** (Set) ********************************************** }
procedure TStRegEx.Set_Avoid(Value: WordBool);
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  FStRegEx.Avoid := Value;
end;

procedure TStRegEx.Set_IgnoreCase(Value: WordBool);
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  FStRegEx.IgnoreCase := Value;
end;

procedure TStRegEx.Set_InFixedLineLength(Value: Integer);
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  FStRegEx.InFixedLineLength := Value;
end;

procedure TStRegEx.Set_InLineTermChar(const Value: WideString);
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  FStRegEx.InLineTermChar := Char(Value[1]);
end;

procedure TStRegEx.Set_InLineTerminator(Value: TStLineTerminator);
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  FStRegEx.InLineTerminator := StStrms.TStLineTerminator(Value);
end;

procedure TStRegEx.Set_LineNumbers(Value: WordBool);
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  FStRegEx.LineNumbers := Value;
end;

procedure TStRegEx.Set_MatchPattern(const Value: IStStringList);
var
  MS : TStream;
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  MS := nil;
  try
    MS := StOleVariantToStream(Value.Stream, True);
    FStRegEx.MatchPattern.LoadFromStream(MS);
  finally
    MS.Free;
  end;
end;

procedure TStRegEx.Set_OutFixedLineLength(Value: Integer);
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  FStRegEx.OutFixedLineLength := Value;
end;

procedure TStRegEx.Set_OutLineTermChar(const Value: WideString);
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  FStRegEx.OutLineTermChar := Char(Value[1]);
end;

procedure TStRegEx.Set_OutLineTerminitor(Value: Integer);
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  FStRegEx.OutLineTerminator := StStrms.TStLineTerminator(Value);
end;

procedure TStRegEx.Set_OutputOptions(Value: TStOutputOption);
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  FStRegEx.OutputOptions := [];
  if FlagIsSet(ooUnSelected, Value) then
    FStRegEx.OutputOptions := FStRegEx.OutputOptions + [StRegEx.ooUnselected];

  if FlagIsSet(ooModified, Value) then
    FStRegEx.OutputOptions := FStRegEx.OutputOptions + [StRegEx.ooModified];

  if FlagIsSet(ooCountOnly, Value) then
    FStRegEx.OutputOptions := FStRegEx.OutputOptions + [StRegEx.ooCountOnly];
end;

procedure TStRegEx.Set_ReplacePattern(const Value: IStStringList);
var
  MS : TStream;
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  MS := nil;
  try
    MS := StOleVariantToStream(Value.Stream, True);
    FStRegEx.ReplacePattern.LoadFromStream(MS);
  finally
    MS.Free;
  end;
end;

procedure TStRegEx.Set_SelAvoidPattern(const Value: IStStringList);
var
  MS : TStream;
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  MS := nil;
  try
    MS := StOleVariantToStream(Value.Stream, True);
    FStRegEx.SelAvoidPattern.LoadFromStream(MS);
  finally
    MS.Free;
  end;
end;

procedure TStRegEx.Set_Stream(Value: OleVariant);
var
  MS : TStream;
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  MS := nil;
  try
    MS := StOleVariantToStream(Value, True);
    FStRegEx.InputStream.CopyFrom(MS, 0);
    FStRegEx.InputStream.Position := 0;
  finally
    MS.Free;
  end;
end;

{ ********** TStRegExp Methods *********************************************************** }
function TStRegEx.CheckString(const S: WideString; var StartPos, EndPos,
  Length: Integer): WordBool;
var
  MP : TMatchPosition;
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  MP.StartPos := StartPos;
  MP.EndPos   := EndPos;
  MP.Length   := Length;
  Result := FStRegEx.CheckString(S, MP);
  StartPos := MP.StartPos;
  EndPos   := MP.EndPos;
  Length   := MP.Length;
end;

function TStRegEx.DOSMaskToRegEx(const Masks: WideString): WordBool;
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  Result := FStRegEx.DOSMasksToRegEx(Masks);
end;

function TStRegEx.Execute: WordBool;
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  Result := FStRegEx.Execute;
end;

procedure TStRegEx.LoadFromFile(const FileName: WideString);
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  TMemoryStream(FStRegEx.InputStream).LoadFromFile(FileName);
end;

procedure TStRegEx.SaveToFile(const FileName: WideString);
begin
  {$IFDEF LICENSE}
   if (not FIsLicensed) or (not COMHasBeenLicensed) then
     OleError(CLASS_E_NOTLICENSED);
  {$ENDIF}
  TMemoryStream(FStRegEx.OutputStream).SaveToFile(FileName);
end;


function TStRegEx.License(const Key: WideString): WordBool;
begin
  {$IFDEF LICENSE}
  Result := COMIsValidKey(Key);

  { License the objects used in this class }
  FMatchPattern.License(Key);
  FSelAvoidPattern.License(Key);
  FReplacePattern.License(Key);

  {$ELSE}
  Result := True;
  {$ENDIF}
  FIsLicensed := Result;
end;

initialization
  TAutoObjectFactory.Create(ComServer, TStRegEx, Class_StRegEx, ciMultiInstance, tmBoth);
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -