Ignore:
Timestamp:
Aug 1, 2006, 8:51:54 PM (19 years ago)
Author:
RBRi
Message:

refactoring for cmd line parameters handling finished

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/NewView/CmdLineParameterUnit.pas

    r23 r25  
    4747       ownerWindow : integer;
    4848       windowTitle : string;
    49        fileName : string;
    50        topic : string;
    51     {
    52     TopicParam: string;
    53     FilenamesParam: TAString;
    54     }
     49       fileNames : string;
     50       topics : string;
    5551
    5652     public
     
    6258       FUNCTION getLanguage : string;
    6359       FUNCTION getHelpManagerFlag : boolean;
     60       FUNCTION setHelpManagerFlag(aNewValue : boolean) : boolean;
    6461       FUNCTION getHelpManagerWindow : integer;
    6562       FUNCTION getWindowPositionFlag : boolean;
     
    6764       FUNCTION getOwnerWindow : integer;
    6865       FUNCTION getWindowTitle : string;
    69        FUNCTION getFileName : string;
    70        FUNCTION getTopic : string;
     66       FUNCTION getFileNames : string;
     67       FUNCTION getTopics : string;
    7168       PROCEDURE parseCmdLine(aSplittedCmdLine : TStringList);
    7269  end;
     
    7875 // returns a string containing the whole
    7976 // command line parametes
    80  FUNCTION splitCmdLineParameter(aCmdLineString : String; var aRC : Integer) : TStringList;
     77 FUNCTION splitCmdLineParameter(aCmdLineString : String; var aResult : TStringList) : integer;
    8178
    8279 // Return true if param matches the form
     
    145142
    146143
     144  FUNCTION TCmdLineParameters.setHelpManagerFlag(aNewValue : boolean) : boolean;
     145  begin
     146       helpManagerFlag := aNewValue;
     147       result := helpManagerFlag;
     148  end;
     149
     150
    147151  FUNCTION TCmdLineParameters.getHelpManagerWindow : integer;
    148152  begin
     
    175179
    176180
    177   FUNCTION TCmdLineParameters.getFileName : string;
    178   begin
    179        result := fileName;
    180   end;
    181 
    182 
    183   FUNCTION TCmdLineParameters.getTopic : string;
    184   begin
    185        result := topic;
     181  FUNCTION TCmdLineParameters.getFileNames : string;
     182  begin
     183       result := fileNames;
     184  end;
     185
     186
     187  FUNCTION TCmdLineParameters.getTopics : string;
     188  begin
     189       result := topics;
    186190  end;
    187191
     
    193197      tmpParameterValue : string;
    194198  begin
     199      ProfileEvent( 'ParseCommandLineParameters started' );
     200
    195201      // reset the whole object
    196202      showUsageFlag := false;
     
    207213      windowTitle := '';
    208214
    209       filename := '';
    210       topic := '';
     215      filenames := '';
     216      topics := '';
    211217
    212218      // start parsing
     
    273279          else
    274280          begin
    275                if length(filename) = 0 then
     281               if length(filenames) = 0 then
    276282               begin
    277283                   // filename
    278                    fileName := tmpParameter;
     284                   fileNames := tmpParameter;
    279285               end
    280286               else
    281287               begin
    282288                   // search (topic) parameter... append all remaining thingies
    283                    if topic <> '' then
     289                   if topics <> '' then
    284290                   begin
    285                        topic := topic + ' ';
     291                       topics := topics + ' ';
    286292                   end;
    287                    topic := topic + tmpParameter;
     293                   topics := topics + tmpParameter;
    288294               end;
    289295          end;
    290296      end;
     297
     298      ProfileEvent('Parameters parsed');
     299      ProfileEvent('  Filename(s): ' + fileNames);
     300      ProfileEvent('  Topic(s): ' + topics);
     301      ProfileEvent( '...done' );
    291302  end;
    292303
     
    307318
    308319
    309 FUNCTION splitCmdLineParameter(aCmdLineString : String; var aRC : Integer) : TStringList;
     320FUNCTION splitCmdLineParameter(aCmdLineString : String; var aResult : TStringList) : integer;
    310321 CONST
    311322     STATE_BEFORE = 0;
     
    319330     tmpState : INTEGER;
    320331     tmpCurrentCommand : String;
    321      tmpResult : TStringList;
    322332
    323333  BEGIN
    324      aRC := SUCCESS;
    325      tmpResult := TStringList.Create;
     334     result := SUCCESS;
     335     aResult.Clear;
     336
    326337     tmpState := 0;
    327338     tmpCurrentCommand := '';
     
    337348               STATE_INSIDE :
    338349                 begin
    339                     tmpResult.add(tmpCurrentCommand);
     350                    aResult.add(tmpCurrentCommand);
    340351                    tmpCurrentCommand := '';
    341352                    tmpState := STATE_BEFORE;
     
    343354               STATE_INSIDE_QUOTED_START_QUOTE :
    344355                 begin
    345                     tmpResult.add(tmpCurrentCommand);
     356                    aResult.add(tmpCurrentCommand);
    346357                    tmpCurrentCommand := '';
    347358                    tmpState := STATE_BEFORE;
     
    409420     STATE_INSIDE :
    410421       begin
    411           tmpResult.add(tmpCurrentCommand);
     422          aResult.add(tmpCurrentCommand);
    412423       end;
    413424     STATE_INSIDE_QUOTED_START_QUOTE :
    414425       begin
    415           tmpResult.add(tmpCurrentCommand);
     426          aResult.add(tmpCurrentCommand);
    416427       end;
    417428     ELSE
    418429       begin
    419           aRC := ERROR_UNMATCHED_QUOTE;
    420           tmpResult.add(tmpCurrentCommand);
     430          result := ERROR_UNMATCHED_QUOTE;
     431          aResult.add(tmpCurrentCommand);
    421432       end;
    422433     end;
    423      splitCmdLineParameter:= tmpResult;
    424434  END;
    425435
     
    509519end;
    510520
     521
    511522END.
Note: See TracChangeset for help on using the changeset viewer.