MCPcopy Create free account
hub / github.com/RenderKit/embree / CommandLineParser

Class CommandLineParser

tutorials/common/tutorial/application.h:12–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

10 void waitForKeyPressedUnderWindows();
11
12 struct CommandLineParser
13 {
14 enum Verbosity {
15 NORMAL = 0,
16 SILENT
17 };
18
19 CommandLineParser(Verbosity verbosity = NORMAL) : verbosity(verbosity) {}
20
21 /* virtual interface for command line option processing */
22 struct CommandLineOption : public RefCount
23 {
24 CommandLineOption (const std::string& description)
25 : description(description) {}
26
27 virtual void parse(Ref<ParseStream> cin, const FileName& path) = 0;
28
29 std::string description;
30 };
31
32 /* helper class to provide parsing function via lambda function */
33 template<typename F>
34 struct CommandLineOptionClosure : public CommandLineOption
35 {
36 CommandLineOptionClosure (std::string description, const F& f)
37 : CommandLineOption(description), f(f) {}
38
39 virtual void parse(Ref<ParseStream> cin, const FileName& path) {
40 f(cin,path);
41 }
42
43 F f;
44 };
45
46 /* registers a command line option */
47 template<typename F>
48 void registerOption(const std::string& name, const F& f, const std::string& description)
49 {
50 Ref<CommandLineOption> closure = new CommandLineOptionClosure<F>(description,f);
51 commandLineOptionList.push_back(closure);
52 commandLineOptionMap[name] = closure;
53 }
54
55 /* registers an alias for a command line option */
56 void registerOptionAlias(const std::string& name, const std::string& alternativeName);
57
58 /* command line parsing */
59 void parseCommandLine(int argc, char** argv);
60 void parseCommandLine(Ref<ParseStream> cin, const FileName& path);
61
62 /* prints help for all supported command line options */
63 void printCommandLineHelp();
64
65 /* command line options database */
66 std::vector< Ref<CommandLineOption> > commandLineOptionList;
67 std::map<std::string,Ref<CommandLineOption> > commandLineOptionMap;
68
69 Verbosity verbosity;

Callers 1

TutorialBenchmarkMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected