Go to the documentation of this file. 44 #define DRWN_STANDARD_OPTIONS_USAGE \ 45 " -help :: display application usage\n" \ 46 " -config <xml> :: configure Darwin from XML file\n" \ 47 " -set <m> <n> <v> :: set (configuration) <m>::<n> to value <v>\n" \ 48 " -profile :: profile code\n" \ 49 " -quiet :: only show warnings and errors\n" \ 50 " -verbose :: show verbose messages\n" \ 51 " -debug :: show debug messages\n" \ 52 " -log <filename> :: log filename\n" \ 53 " -threads <max> :: set maximum number of threads\n" \ 54 " -randseed <n> :: seed random number generators rand and drand48\n" 56 #define DRWN_PROCESS_STANDARD_OPTIONS(ARGS, ARGC) \ 57 if (!strcmp(*ARGS, "-config")) { \ 59 drwnConfigurationManager::get().showRegistry(true); \ 62 drwnConfigurationManager::get().configure(*(++ARGS)); \ 64 } else if (!strcmp(*ARGS, "-set")) { \ 66 drwnConfigurationManager::get().showRegistry(false); \ 70 drwnConfigurationManager::get().showModuleUsage(ARGS[1]); \ 73 DRWN_ASSERT_MSG(ARGC > 3, "not enough arguments for -set"); \ 74 drwnConfigurationManager::get().configure(ARGS[1], ARGS[2], ARGS[3]); \ 75 ARGC -= 3; ARGS += 3; \ 76 } else if (!strcmp(*ARGS, "-profile")) { \ 77 drwnCodeProfiler::enabled = true; \ 78 } else if (!strcmp(*ARGS, "-quiet")) { \ 79 drwnLogger::setLogLevel(DRWN_LL_WARNING); \ 80 } else if (!strcmp(*ARGS, "-verbose") || !strcmp(*ARGS, "-v")) { \ 81 if (drwnLogger::getLogLevel() < DRWN_LL_VERBOSE) \ 82 drwnLogger::setLogLevel(DRWN_LL_VERBOSE); \ 83 } else if (!strcmp(*ARGS, "-debug")) { \ 84 drwnLogger::setLogLevel(DRWN_LL_DEBUG); \ 85 } else if (!strcmp(*ARGS, "-log")) { \ 86 drwnLogger::initialize(*(++ARGS)); \ 88 } else if (!strcmp(*ARGS, "-threads")) { \ 89 drwnThreadPool::MAX_THREADS = atoi(*(++ARGS)); \ 91 } else if (!strcmp(*ARGS, "-randseed")) { \ 92 const unsigned n = atoi(*(++ARGS)); \ 93 srand(n); srand48(n); \ 97 #define DRWN_BEGIN_CMDLINE_PROCESSING(ARGC, ARGV) \ 98 drwnLogger::cacheCommandLine(ARGC, ARGV); \ 99 char **_drwn_args = ARGV + 1; \ 100 int _drwn_argc = ARGC; \ 101 while (--_drwn_argc > 0) { \ 102 DRWN_LOG_DEBUG("processing cmdline arg " << *_drwn_args << " (" << _drwn_argc << ")"); \ 103 DRWN_PROCESS_STANDARD_OPTIONS(_drwn_args, _drwn_argc) \ 105 #define DRWN_CMDLINE_STR_OPTION(OPTSTR, VAR) \ 106 else if (!strcmp(*_drwn_args, OPTSTR)) { \ 107 VAR = *(++_drwn_args); _drwn_argc -= 1; } 109 #define DRWN_CMDLINE_INT_OPTION(OPTSTR, VAR) \ 110 else if (!strcmp(*_drwn_args, OPTSTR)) { \ 111 VAR = atoi(*(++_drwn_args)); _drwn_argc -= 1; } 113 #define DRWN_CMDLINE_REAL_OPTION(OPTSTR, VAR) \ 114 else if (!strcmp(*_drwn_args, OPTSTR)) { \ 115 VAR = atof(*(++_drwn_args)); _drwn_argc -= 1; } 117 #define DRWN_CMDLINE_BOOL_OPTION(OPTSTR, VAR) \ 118 else if (!strcmp(*_drwn_args, OPTSTR)) { VAR = true; } 120 #define DRWN_CMDLINE_BOOL_TOGGLE_OPTION(OPTSTR, VAR) \ 121 else if (!strcmp(*_drwn_args, OPTSTR)) { VAR = !VAR; } 123 #define DRWN_CMDLINE_VEC_OPTION(OPTSTR, VAR) \ 124 else if (!strcmp(*_drwn_args, OPTSTR)) { \ 125 VAR.push_back(*(++_drwn_args)); _drwn_argc -= 1; } 127 #define DRWN_CMDLINE_OPTION_BEGIN(OPTSTR, PTR) \ 128 else if (!strcmp(*_drwn_args, OPTSTR)) { \ 129 const char **PTR = (const char **)(_drwn_args + 1); 131 #define DRWN_CMDLINE_OPTION_END(N) \ 132 _drwn_args += (N); _drwn_argc -= (N); } 134 #define DRWN_CMDLINE_FLAG_BEGIN(OPTSTR) \ 135 else if (!strcmp(*_drwn_args, OPTSTR)) { 137 #define DRWN_CMDLINE_FLAG_END } 139 #define DRWN_END_CMDLINE_PROCESSING(USAGE) \ 140 else if (!strcmp(*_drwn_args, "-help")) { \ 143 } else if ((*_drwn_args)[0] == '-') { \ 145 DRWN_LOG_ERROR("unrecognized option " << *_drwn_args); \ 148 DRWN_LOG_DEBUG(_drwn_argc << " commandline arguments remaining"); \ 154 #define DRWN_CMDLINE_ARGV _drwn_args 155 #define DRWN_CMDLINE_ARGC _drwn_argc