diff options
author | ljb1 <ljb1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-08-29 06:11:13 +0000 |
---|---|---|
committer | ljb1 <ljb1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-08-29 06:11:13 +0000 |
commit | 09b95e1089c22df6220f06e3190009f9cece5a6b (patch) | |
tree | b901bf77d2fdc4b76be2f8faf9f82a246f7d9bcf | |
parent | ac3ccfc64e419fdee9785e5ee59ef3f1a6c1f151 (diff) | |
download | ATCD-09b95e1089c22df6220f06e3190009f9cece5a6b.tar.gz |
ChangeLogTag: Sun Aug 29 00:14:09 1999 Luther Baker <ljb1@cs.wustle.edu>
-rw-r--r-- | ace/Arg_Shifter.cpp | 21 | ||||
-rw-r--r-- | ace/Arg_Shifter.h | 48 |
2 files changed, 29 insertions, 40 deletions
diff --git a/ace/Arg_Shifter.cpp b/ace/Arg_Shifter.cpp index ae81471f139..926477b4f68 100644 --- a/ace/Arg_Shifter.cpp +++ b/ace/Arg_Shifter.cpp @@ -58,11 +58,11 @@ ACE_Arg_Shifter::get_current (void) const return retval; } -char* -ACE_Arg_Shifter::is_or_contains_ignore_case(const char* flag) +int +ACE_Arg_Shifter::cur_arg_strncasecmp (const char* flag) { // Check for a current argument - if (this->get_current()) + if (this->is_anything_left()) { unsigned int flag_length = ACE_OS::strlen(flag); @@ -71,26 +71,21 @@ ACE_Arg_Shifter::is_or_contains_ignore_case(const char* flag) flag, flag_length) == 0) { - // Check for the 'value' parameter if (ACE_OS::strlen(temp_[current_index_]) == flag_length) { - this->consume_arg(); - if (this->is_parameter_next()) - { - // return next arg - return this->get_current(); - } + // match and lengths are equal + return 0; } else { - // return tail end of current arg - return temp_[current_index_] + flag_length; + // match but more info passed in + return flag_length; } } } // failure - return 0; + return -1; } int diff --git a/ace/Arg_Shifter.h b/ace/Arg_Shifter.h index 012adfd3c0d..30ca53a9706 100644 --- a/ace/Arg_Shifter.h +++ b/ace/Arg_Shifter.h @@ -54,40 +54,34 @@ public: char* get_current (void) const; // Get the current head of the vector. - char* is_or_contains_ignore_case(const char* flag); - // Check if the current argument matches <flag> + int cur_arg_strncasecmp(const char* flag); + // Check if the current argument matches (case insensitive) <flag> // - // An argument matches if: - // - it STARTS with <flag> - // - any character may appear after the flag including - // - digits, spaces, characters or nothing at all - // - match is case insensitive. - // - ie: "-Foobar" "-FOOBAR" "-fOobAr" "-foobarVALUE" - // - all match the <flag> "-FooBar" + // ------------------------------------------------------------ // - // If there is NOT a match, nil is returned + // Case A: Perfect Match (case insensitive) + // 0 is returned. // - // If there IS a match: - // An attempt is made to return the <flag>'s parameter (or 'value') + // ie: when current_arg = "-foobar" or "-FOOBAR" or "-fooBAR" + // this->cur_arg_strncasecmp ("-FooBar); + // will return 0 // - // Case A: value is separated from flag with a space: - // Arg_Shifter calls consume_arg() (<flag>) and advances to the next arg - // If the new current argument passes is_parameter_next() - // - we return the 'new' current argument, ('value') - // else, we return nil + // ------------------------------------------------------------ // - // Case B: value is mangled together with flag: ie: "-fooBarVALUE" - // A char* is returned - pointing to VALUE + // Case B: Perfect Match (case insensitive) but the current_arg + // is longer than the flag. Returns a number equal to the index + // in the char* indicating the start of the extra characters // - // This operation consumes the current argument if: - // - there is a match && - // - and the value for the flag is separated from the flag with a space. - // This operation does not consume the current argument if: - // - there is a match but - // - there is no space separating the value from the flag "-FooBarVALUE" + // ie: when current_arg = "-foobar98023" + // this->cur_arg_strncasecmp ("-FooBar); + // will return 7 // - // This method is safe to call without checking for a valid - // current argument. + // Notice: this number will always be > 0 + // + // ------------------------------------------------------------ + // + // Case C: If neither of Case A or B is met (no match) + // then -1 is returned int consume_arg (int number = 1); // Consume <number> argument(s) by sticking them/it on the end of |