summaryrefslogtreecommitdiff
path: root/ace/Arg_Shifter.cpp
diff options
context:
space:
mode:
authorljb1 <ljb1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-08-27 23:51:03 +0000
committerljb1 <ljb1@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-08-27 23:51:03 +0000
commitff19d8f81db26f20dbd81e963b4f7d5c1f115724 (patch)
tree4d520cd0e451425fdc7a98d4f853bdbe2e28cdd7 /ace/Arg_Shifter.cpp
parent6f64227f8e5431bc72fcf101b40d3bb5e492e3b1 (diff)
downloadATCD-ff19d8f81db26f20dbd81e963b4f7d5c1f115724.tar.gz
Fri Aug 27 18:52:00 1999 Luther Baker <ljb1@cs.wustl.edu>
Diffstat (limited to 'ace/Arg_Shifter.cpp')
-rw-r--r--ace/Arg_Shifter.cpp67
1 files changed, 51 insertions, 16 deletions
diff --git a/ace/Arg_Shifter.cpp b/ace/Arg_Shifter.cpp
index 938ecde49dc..bc9dd315ca0 100644
--- a/ace/Arg_Shifter.cpp
+++ b/ace/Arg_Shifter.cpp
@@ -1,14 +1,14 @@
// $Id$
#define ACE_BUILD_DLL
-#include "ace/OS.h"
+// #include "ace/OS.h"
#include "ace/Arg_Shifter.h"
ACE_RCSID(ace, Arg_Shifter, "$Id$")
-ACE_Arg_Shifter::ACE_Arg_Shifter (int &argc,
- char **argv,
- char **temp)
+ACE_Arg_Shifter::ACE_Arg_Shifter (int& argc,
+ char** argv,
+ char** temp)
: argc_ (argc),
total_size_ (argc),
temp_ (temp),
@@ -20,7 +20,7 @@ ACE_Arg_Shifter::ACE_Arg_Shifter (int &argc,
// If not provided with one, allocate a temporary array.
if (this->temp_ == 0)
ACE_NEW (this->temp_,
- char *[this->total_size_]);
+ char*[this->total_size_]);
if (this->temp_ != 0)
{
@@ -46,41 +46,76 @@ ACE_Arg_Shifter::~ACE_Arg_Shifter (void)
delete [] temp_;
}
-char *
+char*
ACE_Arg_Shifter::get_current (void) const
{
- char *return_value = 0;
+ char* retval = 0;
if (this->is_anything_left ())
- return_value = this->temp_[current_index_];
+ retval = this->temp_[current_index_];
- return return_value;
+ return retval;
+}
+
+char*
+ACE_Arg_Shifter::is_or_contains_ignore_case(const char* flag)
+{
+ // Check for a current argument
+ if (this->get_current())
+ {
+ unsigned int flag_length = ACE_OS::strlen(flag);
+
+ // Check for presence of the flag
+ if (ACE_OS::strncasecmp(this->temp_[current_index_],
+ 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();
+ }
+ }
+ else
+ {
+ // return tail end of current arg
+ return temp_[current_index_] + flag_length;
+ }
+ }
+ }
+ // failure
+ return 0;
}
int
ACE_Arg_Shifter::consume_arg (int number)
{
- int return_value = 0;
+ int retval = 0;
// Stick knowns at the end of the vector (consumed).
if (this->is_anything_left() >= number)
{
for (int i = 0, j = this->back_ - (number - 1);
i < number;
- i++, j++, this->current_index_++)
+ ++i, ++j, ++this->current_index_)
this->argv_[j] = this->temp_[this->current_index_];
this->back_ -= number;
- return_value = 1;
+ retval = 1;
}
- return return_value;
+ return retval;
}
int
ACE_Arg_Shifter::ignore_arg (int number)
{
- int return_value = 0;
+ int retval = 0;
// Keep unknowns at the head of the vector.
if (this->is_anything_left () >= number)
@@ -90,11 +125,11 @@ ACE_Arg_Shifter::ignore_arg (int number)
i++, this->current_index_++, this->front_++)
this->argv_[this->front_] = this->temp_[this->current_index_];
- return_value = 1;
+ retval = 1;
this->argc_ += number;
}
- return return_value;
+ return retval;
}
int