variables_map parse_command_line(int ac, char** av, const options_description & desc) { variables_map variables; option_description const * option = nullptr; for (int i = 1; i < ac; ++i) { char const * arg = av[i]; if (option) { if (!option->value().parse(arg)) { throw invalid_option_value(*option, arg); } variables.ref_descriptions.push_back(*option); option = nullptr; } else if (arg[0] == '-') { if (arg[1] == '-') { option = &get_option_description(desc, arg + 2); if (!option->has_value()) { variables.ref_descriptions.push_back(*option); option = nullptr; } } else { ++arg; do { option = &get_option_description(desc, arg[0]); if (option->has_value()) { if (arg[1]) { if (!option->value().parse(arg+1)) { throw invalid_option_value(*option, arg); } variables.ref_descriptions.push_back(*option); option = nullptr; } break; } variables.ref_descriptions.push_back(*option); ++arg; option = nullptr; } while (*arg); } } else { throw invalid_command_line_syntax(); } } if (option) { throw invalid_command_line_syntax(*option); } return variables; }
// handle context menu options // int Hud_Timer::cm_handler(window_info *win, int option) { switch (option) { case CMHT_MODE: toggle_mode(); break; case CMHT_RUNSTATE: toggle_running(); break; case CMHT_SETTIME: { if (!input) input = new INPUT_POPUP; else close_ipu(input); init_ipu(input, win->window_id, 220, -1, 4, 1, 0, set_timer_time); input->x = -230; input->y = last_base_y_start; display_popup_win(input, hud_timer_popup_title_str); } break; case CMHT_RESET: reset(); break; case CMHT_HELP: { const char *desc = get_option_description("view_hud_timer", INI_FILE_VAR); if (desc && (strlen(desc) > 0)) LOG_TO_CONSOLE(c_green1, desc); } break; case CMHT_KEEPSTATE: break; default: return 0; } return 1; }
const char * rs_get_device_option_description(rs_device * device, rs_option option, rs_error ** error) try { VALIDATE_NOT_NULL(device); VALIDATE_ENUM(option); return device->get_option_description(option); }