Changeset 12546


Ignore:
Timestamp:
2006-08-24T16:19:13+12:00 (18 years ago)
Author:
kjdon
Message:

changed parse2::parse so that it returns -1 on error, 0 on success, or if allow_extra_options is specified, then on success returns the number of args left over.

Location:
trunk/gsdl/perllib
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/classify/BasClas.pm

    r11681 r12546  
    263263
    264264    # general options available to all classifiers
    265     if(!parse2::parse($args,$hashArgOptLists->{"ArgList"},$self))
     265    if(parse2::parse($args,$hashArgOptLists->{"ArgList"},$self) == -1)
    266266    {
    267267    #print out the text usage of this classifier.
  • trunk/gsdl/perllib/downloaders/BasDownload.pm

    r11783 r12546  
    3333use gsprintf 'gsprintf';
    3434use printusage;
     35use parse2;
    3536
    3637# suppress the annoying "subroutine redefined" warning that various
     
    7374    delete $self->{"info_only"};
    7475   
    75     if(!parse2::parse($args,$hashArgOptLists->{"ArgList"},$self))
     76    if(parse2::parse($args,$hashArgOptLists->{"ArgList"},$self) == -1)
    7677    {
    7778    my $classTempClass = bless $self, $class;
  • trunk/gsdl/perllib/parse2.pm

    r11650 r12546  
    185185# Parameters: 1.(Array pointer of the user given argument)
    186186#             2.(Array pointer of plugin pre-defined argument list) 
    187 #             3.(Self pointer, where we store all the argument value)
     187#             3.(Hash pointer, where we store all the argument value)
    188188# Pre-condition: Plugin gives the parameters to parse function in parse2
    189 # Post-condition: Store all the default or user given values to the $self->{$ArgumentName}.
    190 #                 Since $self is a pointer from plugin, plugin will have every values we set.
    191 # Return value: 1 is parsing successful, 0 is failed.
     189# Post-condition: Store all the default or user given values to the hash->{$ArgumentName}.
     190#                 Since hash may be a plugin $self, plugin will have every values we set.
     191#             4. Optional "allow_extra_options" argument. If this is set, then
     192#                its ok to have arguments that are not in the predefined list
     193# Return value: -1 if parsing is unsuccessful
     194#                other value for success. This will be 0 unless "allow_extra_options" is set, in which case it will be the number of extra arguments found.
    192195#-----------------------------------------
    193196sub parse
     
    239242        if(processArg($hashArg{$strOneArg},$aryptUserArguList,\%hashInputArg) == 0){
    240243            print STDERR "<BadArgumentValue a=$strOneArg>\n";
    241             return 0;}
     244            return -1;}
    242245        }
    243246       
     
    254257            print STDERR "<BadArgument a=$strOneArg>\n";
    255258            print STDERR " Error: occur in parse2.pm::parse()\n Extra Arguments: $strOneArg\n";
    256             return 0;
     259            return -1;
    257260        }
    258261        }
     
    271274        {
    272275        print STDERR " Error: occur in parse2.pm::parse()\n Invalid Argument: $strOneArg\n";
    273         return 0;
     276        return -1;
    274277        }
    275278    }
     
    294297        if(defined $hashOneArg->{"range"})
    295298        {
    296         if(checkRange($hashOneArg->{"range"},$hashInputArg{$strArgName},$strArgName) == 0){ return 0;}
     299        if(checkRange($hashOneArg->{"range"},$hashInputArg{$strArgName},$strArgName) == 0){ return -1;}
    297300        }
    298301        if(defined $hashOneArg->{"char_length"})
    299302        {
    300         if(checkCharLength($hashOneArg->{"char_length"},$hashInputArg{$strArgName},$strArgName) == 0){ return 0;}
     303        if(checkCharLength($hashOneArg->{"char_length"},$hashInputArg{$strArgName},$strArgName) == 0){ return -1;}
    301304        }
    302305        $self->{"$strArgName"} = $hashInputArg{"$strArgName"};
     
    334337    else
    335338    {
    336     return 1;
     339    return 0;
    337340    }
    338341}
  • trunk/gsdl/perllib/plugins/BasPlug.pm

    r12270 r12546  
    392392    }
    393393
    394     if(!parse2::parse($args,$hashArgOptLists->{"ArgList"},$self))
     394    if(parse2::parse($args,$hashArgOptLists->{"ArgList"},$self) == -1)
    395395    {
    396396    my $classTempClass = bless $self, $class;
  • trunk/gsdl/perllib/plugouts/BasPlugout.pm

    r12459 r12546  
    3434use gsprintf 'gsprintf';
    3535use printusage;
     36use parse2;
    3637
    3738# suppress the annoying "subroutine redefined" warning that various
     
    111112    delete $self->{"info_only"};
    112113   
    113     if(!parse2::parse($args,$hashArgOptLists->{"ArgList"},$self))
     114    if(parse2::parse($args,$hashArgOptLists->{"ArgList"},$self) == -1)
    114115    {
    115116    my $classTempClass = bless $self, $class;
Note: See TracChangeset for help on using the changeset viewer.