src/CLIParser.h
branchv_0
changeset 3 62ced7c41c67
parent 2 1a0fbd17db13
equal deleted inserted replaced
2:1a0fbd17db13 3:62ced7c41c67
    39 
    39 
    40 public:
    40 public:
    41 
    41 
    42 	static const relpipe::common::type::StringX OPTION_RELATION;
    42 	static const relpipe::common::type::StringX OPTION_RELATION;
    43 	static const relpipe::common::type::StringX OPTION_STREAM;
    43 	static const relpipe::common::type::StringX OPTION_STREAM;
       
    44 	static const relpipe::common::type::StringX OPTION_CONNECTION_STRING;
       
    45 	static const relpipe::common::type::StringX OPTION_CONNECTION_OPTION;
    44 
    46 
    45 	Configuration parse(const std::vector<relpipe::common::type::StringX>& arguments) {
    47 	Configuration parse(const std::vector<relpipe::common::type::StringX>& arguments) {
    46 		Configuration c;
    48 		Configuration c;
    47 
    49 
    48 		for (int i = 0; i < arguments.size();) {
    50 		for (int i = 0; i < arguments.size();) {
    50 
    52 
    51 			if (option == OPTION_RELATION) {
    53 			if (option == OPTION_RELATION) {
    52 				c.relation = readNext(arguments, i);
    54 				c.relation = readNext(arguments, i);
    53 			} else if (option == OPTION_STREAM) {
    55 			} else if (option == OPTION_STREAM) {
    54 				c.stream = readNext(arguments, i);
    56 				c.stream = readNext(arguments, i);
       
    57 			} else if (option == OPTION_CONNECTION_STRING) {
       
    58 				c.connectionString = readNext(arguments, i);
       
    59 			} else if (option == OPTION_CONNECTION_OPTION) {
       
    60 				auto name = readNext(arguments, i);
       
    61 				auto value = readNext(arguments, i);
       
    62 				c.connectionOptions.push_back({name, value});
    55 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    63 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    56 		}
    64 		}
    57 
    65 
    58 		return c;
    66 		return c;
    59 	}
    67 	}
    62 	}
    70 	}
    63 };
    71 };
    64 
    72 
    65 const relpipe::common::type::StringX CLIParser::OPTION_RELATION = L"--relation";
    73 const relpipe::common::type::StringX CLIParser::OPTION_RELATION = L"--relation";
    66 const relpipe::common::type::StringX CLIParser::OPTION_STREAM = L"--stream";
    74 const relpipe::common::type::StringX CLIParser::OPTION_STREAM = L"--stream";
       
    75 const relpipe::common::type::StringX CLIParser::OPTION_CONNECTION_STRING = L"--connection-string";
       
    76 const relpipe::common::type::StringX CLIParser::OPTION_CONNECTION_OPTION = L"--connection-option";
    67 
    77 
    68 }
    78 }
    69 }
    79 }
    70 }
    80 }