droption.h File Reference

Options parsing support. More...

#include <string>
#include <vector>
#include <string.h>
#include <stdlib.h>
#include <sstream>
#include <iomanip>
#include <limits.h>
#include <stdint.h>
#include <errno.h>

Data Structures

class  bytesize_t
 
class  droption_parser_t
 
class  droption_t< T >
 

Typedefs

typedef std::pair< std::string, std::string > twostring_t
 

Enumerations

enum  droption_scope_t {
  DROPTION_SCOPE_CLIENT = 0x0001,
  DROPTION_SCOPE_FRONTEND = 0x0002,
  DROPTION_SCOPE_ALL = (DROPTION_SCOPE_CLIENT | DROPTION_SCOPE_FRONTEND)
}
 
enum  droption_flags_t {
  DROPTION_FLAG_ACCUMULATE = 0x0001,
  DROPTION_FLAG_SWEEP = 0x0002,
  DROPTION_FLAG_INTERNAL = 0x0004
}
 

Functions

static bool dr_parse_options (client_id_t client_id, std::string *error_msg, int *last_index)
 

Detailed Description

Options parsing support.

Typedef Documentation

◆ twostring_t

typedef std::pair<std::string, std::string> twostring_t

A convenience typedef for options that take in pairs of values.

Enumeration Type Documentation

◆ droption_flags_t

These bitfield flags further specify the behavior of an option.

Enumerator
DROPTION_FLAG_ACCUMULATE 

By default, if an option is specified multiple times on the command line, only the last value is honored. If this flag is set, repeated options accumulate, appending to the prior value (separating each appended value with a space by default or with a user-specified accumulated value separator if it was supplied to the droption_t constructor). This is supported for options of type std::string only.

DROPTION_FLAG_SWEEP 

By default, an option that does not match a known name and the current scope results in an error. If a string option exists with this flag set, however, all unknown options in the current scope that are known in another scope are passed to the last option with this flag set (which will typically also set DROPTION_FLAG_ACCUMULATE). Additionally, options that are specified and that have DROPTION_SCOPE_ALL are swept as well. The scope of an option with this flag is ignored.

DROPTION_FLAG_INTERNAL 

Indicates that this is an internal option and should be excluded from usage messages and documentation.

◆ droption_scope_t

These bitfield values specify whether an option is intended for use by a client for a tool frontend, or both.

Enumerator
DROPTION_SCOPE_CLIENT 

Acted on by the client only.

DROPTION_SCOPE_FRONTEND 

Acted on by the frontend only.

DROPTION_SCOPE_ALL 

Acted on by both client and frontend.

Function Documentation

◆ dr_parse_options()

static bool dr_parse_options ( client_id_t  client_id,
std::string *  error_msg,
int *  last_index 
)
inlinestatic

Parses the options for client client_id and fills in any registered droption_t class fields. On success, returns true, with the index of the start of the remaining unparsed options, if any, returned in last_index (typically this will be options separated by "--"). On failure, returns false, and if error_msg != NULL, stores a string describing the error there. On failure, last_index is set to the index of the problematic option or option value.

Deprecated:
This routine is not needed with the new dr_client_main() where droption_parser_t::parse_argv() can be invoked directly.