Loading...
Searching...
No Matches
option.h File Reference

Basic type and macros for handling command-line options. More...

#include "scope.h"
+ Include dependency graph for option.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  ledger::option_error
 
class  ledger::option_t< T >
 

Namespaces

namespace  ledger
 

Macros

#define BEGIN(type, name)    struct name ## option_t : public option_t<type>
 
#define COPY_OPT(name, other)   name ## handler(other.name ## handler)
 
#define CTOR(type, name)    name ## option_t() : option_t<type>(#name)
 
#define CTOR_(type, name, base)    name ## option_t() : option_t<type>(#name), base
 
#define DECL1(type, name, vartype, var, value)
 
#define DO()   virtual void handler_thunk(const optional<string>& whence)
 
#define DO_(var)
 
#define END(name)   name ## handler
 
#define HANDLED(name)   HANDLER(name)
 
#define HANDLER(name)   name ## handler
 
#define MAKE_OPT_FUNCTOR(type, x)    expr_t::op_t::wrap_functor(bind(&option_t<type>::operator(), x, _1))
 
#define MAKE_OPT_HANDLER(type, x)    expr_t::op_t::wrap_functor(bind(&option_t<type>::handler, x, _1))
 
#define OPT(name)
 
#define OPT_(name)
 
#define OPT_ALT(name, alt)
 
#define OPT_CH(name)
 
#define OPTION(type, name)
 
#define OPTION_(type, name, body)
 
#define OPTION__(type, name, body)
 
#define OTHER(name)
 

Functions

bool ledger::is_eq (const char *p, const char *n)
 
strings_list ledger::process_arguments (strings_list args, scope_t &scope)
 
void ledger::process_environment (const char **envp, const string &tag, scope_t &scope)
 
bool ledger::process_option (const string &whence, const string &name, scope_t &scope, const char *arg, const string &varname)
 

Detailed Description

Basic type and macros for handling command-line options.

Author
John Wiegley

Definition in file option.h.

Macro Definition Documentation

◆ BEGIN

#define BEGIN ( type,
name )    struct name ## option_t : public option_t<type>

Definition at line 207 of file option.h.

◆ COPY_OPT

#define COPY_OPT ( name,
other )   name ## handler(other.name ## handler)

Definition at line 224 of file option.h.

◆ CTOR

#define CTOR ( type,
name )    name ## option_t() : option_t<type>(#name)

Definition at line 210 of file option.h.

◆ CTOR_

#define CTOR_ ( type,
name,
base )    name ## option_t() : option_t<type>(#name), base

Definition at line 212 of file option.h.

◆ DECL1

#define DECL1 ( type,
name,
vartype,
var,
value )
Value:
vartype var ; \
name ## option_t() : option_t<type>(#name), var value

Definition at line 214 of file option.h.

◆ DO

#define DO ( )    virtual void handler_thunk(const optional<string>& whence)

Definition at line 218 of file option.h.

◆ DO_

#define DO_ ( var)
Value:
virtual void handler_thunk(const optional<string>& whence, \
const string& var)

Definition at line 219 of file option.h.

◆ END

#define END ( name)    name ## handler

Definition at line 222 of file option.h.

◆ HANDLED

#define HANDLED ( name)    HANDLER(name)

Definition at line 264 of file option.h.

Referenced by ledger::report_t::report_format(), and ledger::report_t::what_to_keep().

◆ HANDLER

#define HANDLER ( name)    name ## handler

◆ MAKE_OPT_FUNCTOR

#define MAKE_OPT_FUNCTOR ( type,
x )    expr_t::op_t::wrap_functor(bind(&option_t<type>::operator(), x, _1))

Definition at line 229 of file option.h.

◆ MAKE_OPT_HANDLER

#define MAKE_OPT_HANDLER ( type,
x )    expr_t::op_t::wrap_functor(bind(&option_t<type>::handler, x, _1))

Definition at line 226 of file option.h.

◆ OPT

#define OPT ( name)
Value:
if (is_eq(p, #name)) \
return ((name ## handler).parent = this, &(name ## handler))

Definition at line 242 of file option.h.

◆ OPT_

#define OPT_ ( name)
Value:
if (! *(p + 1) || \
((name ## handler).wants_arg && \
*(p + 1) == '_' && ! *(p + 2)) || \
is_eq(p, #name)) \
return ((name ## handler).parent = this, &(name ## handler))

Definition at line 250 of file option.h.

◆ OPT_ALT

#define OPT_ALT ( name,
alt )
Value:
if (is_eq(p, #name) || is_eq(p, #alt)) \
return ((name ## handler).parent = this, &(name ## handler))

Definition at line 246 of file option.h.

◆ OPT_CH

#define OPT_CH ( name)
Value:
if (! *(p + 1) || \
((name ## handler).wants_arg && \
*(p + 1) == '_' && ! *(p + 2))) \
return ((name ## handler).parent = this, &(name ## handler))

Definition at line 257 of file option.h.

◆ OPTION

#define OPTION ( type,
name )
Value:
BEGIN(type, name) \
{ \
CTOR(type, name) {} \
} \
END(name)
#define BEGIN(type, name)
Definition option.h:207

Definition at line 266 of file option.h.

◆ OPTION_

#define OPTION_ ( type,
name,
body )
Value:
BEGIN(type, name) \
{ \
CTOR(type, name) {} \
body \
} \
END(name)

Definition at line 273 of file option.h.

◆ OPTION__

#define OPTION__ ( type,
name,
body )
Value:
BEGIN(type, name) \
{ \
body \
} \
END(name)

Definition at line 281 of file option.h.

◆ OTHER

#define OTHER ( name)
Value:
parent->HANDLER(name).parent = parent; \
parent->HANDLER(name)

Definition at line 288 of file option.h.