oasys::OptParser Class Reference

#include <OptParser.h>

List of all members.


Detailed Description

Definition at line 30 of file OptParser.h.


Public Member Functions

virtual ~OptParser ()
 Destructor, which also deletes any bound Opt classes.
void addopt (Opt *opt)
 Register a new option binding.
bool parse (const char *args, const char **invalidp=NULL)
 Parse the given argument string, processing all registered opts.
bool parse (int argc, const char *const argv[], const char **invalidp=NULL)
 Parse the given argument vector, processing all registered opts.
int parse_and_shift (int argc, const char *argv[], const char **invalidp=NULL)
 Parse any matching options from the given argument vector, shifting any non-matching ones to be contiguous at the start of the argv.
bool parse (const std::vector< std::string > &args, const char **invalidp=NULL)
 Parse the given argument vector, processing all registered opts.
bool parse_opt (const char *opt, size_t len, bool *invalid_value=NULL)
 Parse a single option (or option=value) string.

Protected Types

typedef std::vector
< Opt * > 
OptList

Protected Attributes

OptList allopts_

Member Typedef Documentation

typedef std::vector<Opt*> oasys::OptParser::OptList [protected]

Definition at line 94 of file OptParser.h.


Constructor & Destructor Documentation

oasys::OptParser::~OptParser (  )  [virtual]

Destructor, which also deletes any bound Opt classes.

Definition at line 22 of file OptParser.cc.

References allopts_.


Member Function Documentation

void oasys::OptParser::addopt ( Opt opt  ) 

Register a new option binding.

This assumes ownership of the object and will call delete on it when the parser is destroyed.

Definition at line 33 of file OptParser.cc.

References allopts_.

Referenced by dtn::IPDiscovery::configure(), dtn::IPAnnounce::configure(), dtn::BluetoothDiscovery::configure(), dtn::BluetoothAnnounce::configure(), DTNOpenCommand::DTNOpenCommand(), DTNRecvCommand::DTNRecvCommand(), DTNRegisterCommand::DTNRegisterCommand(), DTNSendCommand::DTNSendCommand(), dtn::ProphetCommand::exec(), dtnsim::TrAgent::init(), dtnsim::SimConvergenceLayer::init_link(), dtn::TCPConvergenceLayer::interface_up(), dtn::BluetoothConvergenceLayer::interface_up(), dtn::Link::parse_args(), dtn::BundleCommand::parse_inject_options(), dtn::TCPConvergenceLayer::parse_link_params(), dtn::StreamConvergenceLayer::parse_link_params(), dtn::ConnectionConvergenceLayer::parse_link_params(), dtn::BluetoothConvergenceLayer::parse_link_params(), dtn::RouteEntry::parse_options(), dtn::CustodyTimerSpec::parse_options(), dtnsim::ConnState::parse_options(), and dtn::UDPConvergenceLayer::parse_params().

bool oasys::OptParser::parse ( const char *  args,
const char **  invalidp = NULL 
)

Parse the given argument string, processing all registered opts.

Returns:
true if the argument string was successfully parsed, false otherwise. If non-null, invalidp is set to point to the invalid option string.

Definition at line 96 of file OptParser.cc.

References parse_opt().

Referenced by dtn::IPDiscovery::configure(), dtn::IPAnnounce::configure(), dtn::BluetoothDiscovery::configure(), dtn::BluetoothAnnounce::configure(), dtn::ProphetCommand::exec(), DTNRecvCommand::exec(), DTNSendCommand::exec(), DTNRegisterCommand::exec(), DTNOpenCommand::exec(), dtnsim::TrAgent::init(), dtnsim::SimConvergenceLayer::init_link(), dtn::TCPConvergenceLayer::interface_up(), dtn::BluetoothConvergenceLayer::interface_up(), dtn::ConnectionConvergenceLayer::parse_link_params(), dtnsim::ConnState::parse_options(), and dtn::UDPConvergenceLayer::parse_params().

bool oasys::OptParser::parse ( int  argc,
const char *const   argv[],
const char **  invalidp = NULL 
)

Parse the given argument vector, processing all registered opts.

Returns:
true if the argument string was successfully parsed, false otherwise. If non-null, invalidp is set to point to the invalid option string.

Definition at line 121 of file OptParser.cc.

References parse_opt().

int oasys::OptParser::parse_and_shift ( int  argc,
const char *  argv[],
const char **  invalidp = NULL 
)

Parse any matching options from the given argument vector, shifting any non-matching ones to be contiguous at the start of the argv.

If there is a matching option with an invalid value, return -1 and set invalidp to point to the bogus argument.

Returns:
the number of parsed options

Definition at line 135 of file OptParser.cc.

References parse_opt().

Referenced by dtn::Link::parse_args(), dtn::TCPConvergenceLayer::parse_link_params(), dtn::StreamConvergenceLayer::parse_link_params(), dtn::BluetoothConvergenceLayer::parse_link_params(), dtn::RouteEntry::parse_options(), and dtn::CustodyTimerSpec::parse_options().

bool oasys::OptParser::parse ( const std::vector< std::string > &  args,
const char **  invalidp = NULL 
)

Parse the given argument vector, processing all registered opts.

Returns:
true if the argument string was successfully parsed, false otherwise. If non-null, invalidp is set to point to the invalid option string.

Definition at line 164 of file OptParser.cc.

References parse_opt().

bool oasys::OptParser::parse_opt ( const char *  opt,
size_t  len,
bool invalid_value = NULL 
)

Parse a single option (or option=value) string.

Returns:
true if valid, false otherwise

Definition at line 40 of file OptParser.cc.

References allopts_, oasys::Opt::longopt_, oasys::Opt::needval_, and oasys::Opt::set().

Referenced by parse(), parse_and_shift(), and dtn::BundleCommand::parse_inject_options().


Member Data Documentation

OptList oasys::OptParser::allopts_ [protected]

Definition at line 95 of file OptParser.h.

Referenced by addopt(), parse_opt(), and ~OptParser().


The documentation for this class was generated from the following files:
Generated on Sat Sep 8 08:36:26 2007 for DTN Reference Implementation by  doxygen 1.5.3