ACE
6.3.1
|
Builds a counted argument vector (ala argc/argv) from either a string or a set of separate tokens. This class preserves whitespace within tokens only if the whitespace-containing token is enclosed in either single (') or double (") quotes. This is consistent with the expected behavior if an argument vector obtained using this class is passed to, for example, ACE_Get_Opt. More...
#include <ARGV.h>
Public Member Functions | |
ACE_ARGV_T (const CHAR_TYPE buf[], bool substitute_env_args=true) | |
ACE_ARGV_T (int argc, CHAR_TYPE *argv[], bool substitute_env_args=true, bool quote_args=false) | |
ACE_ARGV_T (CHAR_TYPE *argv[], bool substitute_env_args=true, bool quote_args=false) | |
ACE_ARGV_T (CHAR_TYPE *first_argv[], CHAR_TYPE *second_argv[], bool substitute_env_args=true, bool quote_args=false) | |
ACE_ARGV_T (bool substitute_env_args=true) | |
~ACE_ARGV_T (void) | |
Destructor. More... | |
void | dump (void) const |
Dump the state of this object. More... | |
int | add (const CHAR_TYPE *next_arg, bool quote_arg=false) |
int | add (CHAR_TYPE *argv[], bool quote_args=false) |
Accessor methods | |
These methods access the argument vector contained in this object. | |
const CHAR_TYPE * | operator[] (size_t index) |
CHAR_TYPE ** | argv (void) |
int | argc (void) const |
Returns the current number of arguments. More... | |
const CHAR_TYPE * | buf (void) |
Public Attributes | |
ACE_ALLOC_HOOK_DECLARE | |
Private Member Functions | |
ACE_ARGV_T (const ACE_ARGV_T< CHAR_TYPE > &) | |
Copy constructor not implemented. More... | |
ACE_ARGV_T | operator= (const ACE_ARGV_T< CHAR_TYPE > &) |
Assignment operator not implemented. More... | |
int | create_buf_from_queue (void) |
Creates buf_ from the queue of added args, deletes previous buf_. More... | |
int | string_to_argv (void) |
Converts buf_ into the CHAR_TYPE *argv[] format. More... | |
Private Attributes | |
bool | substitute_env_args_ |
Replace args with environment variable values? More... | |
bool | iterative_ |
int | argc_ |
Number of arguments in the ARGV array. More... | |
CHAR_TYPE ** | argv_ |
The array of string arguments. More... | |
CHAR_TYPE * | buf_ |
Buffer containing the <argv> contents. More... | |
size_t | length_ |
ACE_Unbounded_Queue < ACE_ARGV_Queue_Entry_T < CHAR_TYPE > > | queue_ |
Builds a counted argument vector (ala argc/argv) from either a string or a set of separate tokens. This class preserves whitespace within tokens only if the whitespace-containing token is enclosed in either single (') or double (") quotes. This is consistent with the expected behavior if an argument vector obtained using this class is passed to, for example, ACE_Get_Opt.
This class can substitute environment variable values for tokens that are environment variable references (e.g., $VAR
). This only works if the token is an environment variable reference and nothing else; it doesn't substitute environment variable references within a token. For example, $HOME/file
will not substitute the value of the HOME environment variable.
|
explicit |
Splits the specified string into an argument vector. Arguments in the string are delimited by whitespace. Whitespace-containing arguments must be enclosed in quotes, either single (') or double (").
buf | A nul-terminated CHAR_TYPE array to split into arguments for the vector. |
substitute_env_args | If non-zero, any token that is an environment variable reference (e.g., $VAR ) will have its environment variable value in the resultant vector in place of the environment variable name. |
|
explicit |
Initializes the argument vector from a set of arguments. Any environment variable references are translated (if applicable) during execution of this method. In contrast with ACE_ARGV_T(CHAR_TYPE *[], bool, bool), this ctor does not require argv to be 0-terminated as the number of arguments is provided explicitely.
argc | The number of arguments in the argv array. |
argv | An array of tokens to initialize the object with. All needed data is copied from argv during this call; the pointers in argv are not needed after this call, and the memory referred to by argv is not referenced by this object. |
substitute_env_args | If non-zero, any element of argv that is an environment variable reference (e.g., $VAR ) will have its environment variable value in the resultant vector in place of the environment variable name. |
quote_args | If non-zero each argument argv[i] needs to be enclosed in double quotes ('"'). |
|
explicit |
Initializes the argument vector from a set of arguments. Any environment variable references are translated (if applicable) during execution of this method.
argv | An array of tokens to initialize the object with. The array must be terminated with a 0 pointer. All needed data is copied from argv during this call; the pointers in argv are not needed after this call, and the memory referred to by argv is not referenced by this object. |
substitute_env_args | If non-zero, any element of argv that is an environment variable reference (e.g., $VAR ) will have its environment variable value in the resultant vector in place of the environment variable name. |
quote_args | If non-zero each argument argv[i] needs to be enclosed in double quotes ('"'). |
ACE_ARGV_T< CHAR_TYPE >::ACE_ARGV_T | ( | CHAR_TYPE * | first_argv[], |
CHAR_TYPE * | second_argv[], | ||
bool | substitute_env_args = true , |
||
bool | quote_args = false |
||
) |
Initializes the argument vector from two combined argument vectors.
first_argv | An array of tokens to initialize the object with. The array must be terminated with a 0 pointer. |
second_argv | An array of tokens that is concatenated with the the tokens in first_argv. The array must be terminated with a 0 pointer. |
substitute_env_args | If non-zero, any element of first_argv or second_argv that is an environment variable reference (e.g., $VAR ) will have its environment variable value in the resultant vector in place of the environment variable name. |
quote_args | If non-zero each arguments first_argv[i] and second_argv[i] needs to be enclosed in double quotes ('"'). |
|
explicit |
Initialize this object so arguments can be added later using one of the add methods. This is referred to as the iterative method of adding arguments to this object.
ACE_ARGV_T< CHAR_TYPE >::~ACE_ARGV_T | ( | void | ) |
Destructor.
|
private |
Copy constructor not implemented.
int ACE_ARGV_T< CHAR_TYPE >::add | ( | const CHAR_TYPE * | next_arg, |
bool | quote_arg = false |
||
) |
Add another argument. This only works in the iterative mode.
next_arg | Pointer to the next argument to add to the vector. |
quote_arg | The argument next_arg need to be quoted while adding to the vector. |
0 | on success; -1 on failure. Most likely errno values are:
|
int ACE_ARGV_T< CHAR_TYPE >::add | ( | CHAR_TYPE * | argv[], |
bool | quote_args = false |
||
) |
Add an array of arguments. This only works in the iterative mode.
argv | Pointers to the arguments to add to the vector. argv must be terminated by a 0 pointer. |
quote_args | If non-zero each argument argv[i] needs to be enclosed in double quotes ('"'). |
0 | on success; -1 on failure. Most likely errno values are:
|
|
inline |
Returns the current number of arguments.
|
inline |
Returns the current argument vector. The returned pointers are to data maintained internally to this class. Do not change or delete either the pointers or the memory to which they refer.
|
inline |
Returns a single string form of the current arguments. The returned pointer refers to memory maintained internally to this class. Do not change or delete it.
|
private |
Creates buf_ from the queue of added args, deletes previous buf_.
void ACE_ARGV_T< CHAR_TYPE >::dump | ( | void | ) | const |
Dump the state of this object.
|
private |
Assignment operator not implemented.
|
inline |
Returns the specified element of the current argument vector.
index | Index to the desired element. |
Pointer | to the indexed string. |
0 | if index is out of bounds. |
|
private |
Converts buf_ into the CHAR_TYPE *argv[] format.
ACE_ARGV_T< CHAR_TYPE >::ACE_ALLOC_HOOK_DECLARE |
|
private |
Number of arguments in the ARGV array.
|
private |
The array of string arguments.
|
private |
Buffer containing the <argv> contents.
|
private |
|
private |
Total length of the arguments in the queue, not counting separating spaces
|
private |
Queue which keeps user supplied arguments. This is only active in the "iterative" mode.
|
private |
Replace args with environment variable values?