src/CLIParser.h
branchv_0
changeset 23 d2ad84dcf249
parent 15 b3239e4ad328
equal deleted inserted replaced
22:eebc16b7c3e4 23:d2ad84dcf249
    46 		else throw relpipe::cli::RelpipeCLIException(L"Unable to parse boolean value: " + value + L" (expecting true or false)", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    46 		else throw relpipe::cli::RelpipeCLIException(L"Unable to parse boolean value: " + value + L" (expecting true or false)", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    47 	}
    47 	}
    48 
    48 
    49 public:
    49 public:
    50 
    50 
    51 	static const relpipe::common::type::StringX OPTION_JACK_CLIENT_NAME;
    51 	static const relpipe::common::type::StringX OPTION_CLIENT;
    52 	static const relpipe::common::type::StringX OPTION_JACK_CONNECT_TO_PORT;
    52 	static const relpipe::common::type::StringX OPTION_PORT;
    53 	static const relpipe::common::type::StringX OPTION_REQUIRED_JACK_CONNECTIONS;
    53 	static const relpipe::common::type::StringX OPTION_CONNECT_TO;
       
    54 	static const relpipe::common::type::StringX OPTION_REQUIRED_CONNECTIONS;
    54 
    55 
    55 	Configuration parse(const std::vector<relpipe::common::type::StringX>& arguments) {
    56 	Configuration parse(const std::vector<relpipe::common::type::StringX>& arguments) {
    56 		Configuration c;
    57 		Configuration c;
    57 
    58 
    58 		for (int i = 0; i < arguments.size();) {
    59 		for (int i = 0; i < arguments.size();) {
    59 			relpipe::common::type::StringX option = readNext(arguments, i);
    60 			relpipe::common::type::StringX option = readNext(arguments, i);
    60 
    61 
    61 			if (option == OPTION_JACK_CLIENT_NAME) {
    62 			if (option == OPTION_CLIENT) {
    62 				c.jackClientName = readNext(arguments, i);
    63 				c.client = readNext(arguments, i);
    63 			} else if (option == OPTION_JACK_CONNECT_TO_PORT) {
    64 			} else if (option == OPTION_PORT) {
    64 				c.portsToConnect.push_back(readNext(arguments, i));
    65 				c.port = readNext(arguments, i);
    65 			} else if (option == OPTION_REQUIRED_JACK_CONNECTIONS) {
    66 			} else if (option == OPTION_CONNECT_TO) {
    66 				c.requiredJackConnections = std::stoi(readNext(arguments, i));
    67 				c.connectTo.push_back(readNext(arguments, i));
       
    68 			} else if (option == OPTION_REQUIRED_CONNECTIONS) {
       
    69 				c.requiredConnections = std::stoi(readNext(arguments, i));
    67 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    70 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    68 		}
    71 		}
    69 
    72 
    70 		return c;
    73 		return c;
    71 	}
    74 	}
    72 
    75 
    73 	virtual ~CLIParser() {
    76 	virtual ~CLIParser() {
    74 	}
    77 	}
    75 };
    78 };
    76 
    79 
    77 const relpipe::common::type::StringX CLIParser::OPTION_JACK_CLIENT_NAME = L"--jack-client-name";
    80 const relpipe::common::type::StringX CLIParser::OPTION_CLIENT = L"--client";
    78 const relpipe::common::type::StringX CLIParser::OPTION_JACK_CONNECT_TO_PORT = L"--jack-connect-to-port";
    81 const relpipe::common::type::StringX CLIParser::OPTION_PORT = L"--port";
    79 const relpipe::common::type::StringX CLIParser::OPTION_REQUIRED_JACK_CONNECTIONS = L"--required-jack-connections";
    82 const relpipe::common::type::StringX CLIParser::OPTION_CONNECT_TO = L"--connect-to";
       
    83 const relpipe::common::type::StringX CLIParser::OPTION_REQUIRED_CONNECTIONS = L"--required-connections";
    80 
    84 
    81 }
    85 }
    82 }
    86 }
    83 }
    87 }