cmdargs Class Reference
[System Library]

#include <stlsoft/system/cmdargs.hpp>

List of all members.


Detailed Description

Facade class that presents argc+argv command line parameters as two separate sequences of options (those arguments with - or -- prefixes and, optionally, separated from an option value by a =) and values (those without any leading hyphens).

Note:
The cmdargs instance maintains views onto the actual arguments in the argv array. Therefore, the behaviour is undefined if any code modifies the strings pointed to by the elements in the argv array, or repoints any of the argv elements to different strings.

Public Types

enum  {
  singleDash = 1,
  doubleDash = 2,
  tripleDash = 3
}
typedef simple_string string_type
typedef basic_string_view< charstring_view_type
typedef option options_value_type
typedef value values_value_type
typedef std::vector
< options_value_type
options_type
typedef std::vector
< values_value_type
values_type
typedef
options_type::const_iterator 
const_options_iterator
typedef values_type::const_iterator const_values_iterator
typedef size_t size_type
typedef bool bool_type

Public Member Functions

Construction
 cmdargs (int argc, char **argv)
 Constructs from argc/argv.
 ~cmdargs () throw ()
 Releases any resources.
Attributes
options_type const & options () const
 non-mutating reference to the options
values_type const & values () const
 non-mutating reference to the values
const_options_iterator options_begin () const
const_options_iterator options_end () const
const_values_iterator values_begin () const
const_values_iterator values_end () const
size_type options_size () const
 The number of options.
size_type values_size () const
 The number of values.
size_type size () const
 The numbers options and values.
bool_type empty () const
 Indicates whether there are any options and/or values.
template<typename S>
bool_type has_option (S const &optionName, int type=-1) const
 Determines whether the options collection contains an option of the given name.
template<typename S>
bool_type has_option (S const &optionName, int type, option &opt) const
 Determines whether the options collection contains an option of the given name, and copies the found option's details into a caller-supplied instance.
template<typename S>
bool_type has_value (S const &valueName) const
template<typename S>
bool_type has_value (S const &valueName, value &val) const

Classes

struct  option
 Represents a command-line option. More...
struct  value
 Represents a command-line value. More...

Constructor & Destructor Documentation

cmdargs ( int  argc,
char **  argv 
)

Constructs from argc/argv.

~cmdargs (  )  throw ()

Releases any resources.


Member Function Documentation

options_type const& options (  )  const

non-mutating reference to the options

values_type const& values (  )  const

non-mutating reference to the values

size_type options_size (  )  const

The number of options.

size_type values_size (  )  const

The number of values.

size_type size (  )  const

The numbers options and values.

bool_type empty (  )  const

Indicates whether there are any options and/or values.

bool_type has_option ( S const &  optionName,
int  type = -1 
) const [inline]

Determines whether the options collection contains an option of the given name.

Parameters:
optionName The name of the option to search for
type The type of the option (i.e the number of hyphens). It defaults to -1, which indicates that the caller does not care.

References stlsoft::c_str_ptr().

bool_type has_option ( S const &  optionName,
int  type,
option opt 
) const [inline]

Determines whether the options collection contains an option of the given name, and copies the found option's details into a caller-supplied instance.

Parameters:
optionName The name of the option to search for
type The type of the option (i.e the number of hyphens). The caller can specify -1 to indicate that it does not care.
opt The instance into which the

References stlsoft::c_str_ptr().


The documentation for this class was generated from the following file:

Generated on Thu Jun 10 08:59:01 2010 for STLSoft by  doxygen 1.5.6