src/CLIParser.h
branchv_0
changeset 47 428c278af4be
parent 37 3de41719d7eb
child 54 bc6e11cccdf4
equal deleted inserted replaced
46:85e6dc1853ee 47:428c278af4be
    51 	static const string_t OPTION_TYPE_CAST;
    51 	static const string_t OPTION_TYPE_CAST;
    52 	static const string_t OPTION_PARAMETER;
    52 	static const string_t OPTION_PARAMETER;
    53 	static const string_t OPTION_COPY;
    53 	static const string_t OPTION_COPY;
    54 	static const string_t OPTION_COPY_RENAMED;
    54 	static const string_t OPTION_COPY_RENAMED;
    55 	static const string_t OPTION_DATA_SOURCE_NAME;
    55 	static const string_t OPTION_DATA_SOURCE_NAME;
    56 	static const string_t OPTION_DATA_SOURCE_URL;
    56 	static const string_t OPTION_DATA_SOURCE_STRING;
    57 	static const string_t OPTION_LIST_DATA_SOURCES;
    57 	static const string_t OPTION_LIST_DATA_SOURCES;
    58 
    58 
    59 	Configuration parse(const std::vector<string_t>& arguments) {
    59 	Configuration parse(const std::vector<string_t>& arguments) {
    60 		Configuration c;
    60 		Configuration c;
    61 		Statement currentQuery;
    61 		Statement currentQuery;
    80 				c.copyRelations.push_back({readNext(arguments, i), L"", false});
    80 				c.copyRelations.push_back({readNext(arguments, i), L"", false});
    81 			} else if (option == OPTION_COPY_RENAMED) {
    81 			} else if (option == OPTION_COPY_RENAMED) {
    82 				c.copyRelations.push_back({readNext(arguments, i), readNext(arguments, i), true});
    82 				c.copyRelations.push_back({readNext(arguments, i), readNext(arguments, i), true});
    83 			} else if (option == OPTION_DATA_SOURCE_NAME) {
    83 			} else if (option == OPTION_DATA_SOURCE_NAME) {
    84 				c.dataSourceName = readNext(arguments, i);
    84 				c.dataSourceName = readNext(arguments, i);
    85 			} else if (option == OPTION_DATA_SOURCE_URL) {
    85 			} else if (option == OPTION_DATA_SOURCE_STRING) {
    86 				c.dataSourceURL = readNext(arguments, i);
    86 				c.dataSourceString = readNext(arguments, i);
    87 			} else if (option == OPTION_LIST_DATA_SOURCES) {
    87 			} else if (option == OPTION_LIST_DATA_SOURCES) {
    88 				c.listDataSources = true;
    88 				c.listDataSources = true;
    89 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    89 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    90 		}
    90 		}
    91 		addQuery(c, currentQuery); // last relation
    91 		addQuery(c, currentQuery); // last relation
    92 
    92 
    93 		if (c.dataSourceName.size() && c.dataSourceURL.size()) throw relpipe::cli::RelpipeCLIException(L"Specify data source name or data source URL, not both.", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    93 		if (c.dataSourceName.size() && c.dataSourceString.size()) throw relpipe::cli::RelpipeCLIException(L"Specify data source name or data source string, not both.", relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
    94 
    94 
    95 		return c;
    95 		return c;
    96 	}
    96 	}
    97 
    97 
    98 	virtual ~CLIParser() {
    98 	virtual ~CLIParser() {
   108 const string_t CLIParser::OPTION_PARAMETER = L"--parameter";
   108 const string_t CLIParser::OPTION_PARAMETER = L"--parameter";
   109 const string_t CLIParser::OPTION_COPY = L"--copy";
   109 const string_t CLIParser::OPTION_COPY = L"--copy";
   110 const string_t CLIParser::OPTION_COPY_RENAMED = L"--copy-renamed";
   110 const string_t CLIParser::OPTION_COPY_RENAMED = L"--copy-renamed";
   111 const string_t CLIParser::OPTION_LIST_DATA_SOURCES = L"--list-data-sources";
   111 const string_t CLIParser::OPTION_LIST_DATA_SOURCES = L"--list-data-sources";
   112 const string_t CLIParser::OPTION_DATA_SOURCE_NAME = L"--data-source-name";
   112 const string_t CLIParser::OPTION_DATA_SOURCE_NAME = L"--data-source-name";
   113 const string_t CLIParser::OPTION_DATA_SOURCE_URL = L"--data-source-url";
   113 const string_t CLIParser::OPTION_DATA_SOURCE_STRING = L"--data-source-string";
   114 
   114 
   115 }
   115 }
   116 }
   116 }
   117 }
   117 }