unit ufDebug;
{$INCLUDE 'Filters.inc'}

interface

uses
  SysUtils, Classes,
  uXml,
  uFilter, uMessages;

type
  TFilterDebug = class(TFilter)
  public
    class function ID: string; override;
    class function Name: string; override;
    class function Priority: TFilter.TPriority; override;
    procedure Clear; override;
    function Execute(const FileName, Content: string): string; override;
  end;

implementation

{ TFilterDebug }

procedure TFilterDebug.Clear;
begin
  inherited;
  Description := 'Debug filter - toggle case';
end;

function TFilterDebug.Execute(const FileName, Content: string): string;
var
  i: Integer;
begin
  Result := Content;
  for i := 1 to Length(Result) do
  begin
    if CharInSet(Result[i], ['a'..'z']) then
      Result[i] := UpCase(Result[i])
    else if CharInSet(Result[i], ['A'..'Z']) then
      Result[i] := Chr(Ord(Result[i]) + 32);
  end;
end;

class function TFilterDebug.ID: string;
begin
  Result := 'debug';
end;

class function TFilterDebug.Name: string;
begin
  Result := 'Debug filter';
end;

class function TFilterDebug.Priority: TFilter.TPriority;
begin
  Result := prLow;
end;

initialization
  {$IFDEF DEBUG}
  TRegisteredFilters.Add(TFilterDebug);
  {$ENDIF}

end.
