monotone

monotone Mtn Source Tree

Root/options.hh

1// Copyright 2006 Timothy Brownawell <tbrownaw@gmail.com>
2// This is made available under the GNU GPL v2 or later.
3
4#ifndef __OPTIONS_HH__
5#define __OPTIONS_HH__
6
7/*
8 * This defines 'struct options', which includes the variables and options
9 * defined in options_list.hh as members. Options and optsets are available
10 * statically as options::opts::<name>, and option variables are available
11 * as options::<name>.
12 */
13
14#include <list>
15
16#include "option.hh"
17#include "paths.hh"
18#include "dates.hh"
19
20struct options
21{
22 options();
23
24 typedef boost::function<void()> reset_function;
25 typedef option::option<options> option_type;
26 typedef option::option_set<options> options_type;
27 typedef options_type const & (*static_options_fun)();
28
29 static std::map<static_options_fun, std::set<static_options_fun> > &children();
30 static std::map<static_options_fun, std::list<void(options::*)()> > &var_membership();
31
32 void reset_optset(static_options_fun opt);
33
34 struct opts
35 {
36 static options_type const & none ();
37 static options_type const & all_options ();
38# define OPTSET(name) \
39 static options_type const & name ();
40
41# define OPTVAR(optset, type, name, default_)
42
43#define OPTION(optset, name, hasarg, optstring, description) \
44 static options_type const & name ();
45
46# define OPTSET_REL(parent, child)
47
48# include "options_list.hh"
49
50# undef OPTSET
51# undef OPTVAR
52# undef OPTION
53# undef OPTSET_REL
54 };
55
56# define OPTSET(name)\
57 private:\
58 void reset_optset_ ## name ();
59
60# define OPTVAR(optset, type, name, default_)\
61 public:\
62 type name;\
63 void reset_ ## name ();
64
65#define OPTION(optset, name, hasarg, optstring, description) \
66 public: \
67 bool name ## _given; \
68private: \
69 void set_ ## name (std::string arg); \
70 void real_set_ ## name (std::string arg); \
71 void reset_opt_ ## name ();
72
73# define OPTSET_REL(parent, child)
74
75# include "options_list.hh"
76
77# undef OPTSET
78# undef OPTVAR
79# undef OPTION
80# undef OPTSET_REL
81};
82
83option::option_set<options>
84operator | (option::option_set<options> const & opts,
85 option::option_set<options> const & (*fun)());
86
87#endif
88
89// Local Variables:
90// mode: C++
91// fill-column: 76
92// c-file-style: "gnu"
93// indent-tabs-mode: nil
94// End:
95// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status