src/CLIParser.h
branchv_0
changeset 3 610783d70ae9
parent 2 0799eaf338b9
--- a/src/CLIParser.h	Sun May 08 21:42:14 2022 +0200
+++ b/src/CLIParser.h	Sun Jun 05 22:51:45 2022 +0200
@@ -19,7 +19,7 @@
 #include <vector>
 #include <iostream>
 
-#include <relpipe/writer/typedefs.h>
+#include <relpipe/common/type/typedefs.h>
 #include <relpipe/cli/CLI.h>
 #include <relpipe/cli/RelpipeCLIException.h>
 
@@ -32,27 +32,35 @@
 class CLIParser {
 private:
 
-	relpipe::writer::string_t readNext(const std::vector<relpipe::writer::string_t>& arguments, int& i) {
+	relpipe::common::type::StringX readNext(const std::vector<relpipe::common::type::StringX>& arguments, int& i) {
 		if (i < arguments.size()) return arguments[i++];
 		else throw relpipe::cli::RelpipeCLIException(L"Missing CLI argument" + (i > 0 ? (L" after " + arguments[i - 1]) : L""), relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
 	}
 
 public:
 
-	static const relpipe::writer::string_t OPTION_RELATION;
-	static const relpipe::writer::string_t OPTION_STREAM;
-	static const relpipe::writer::string_t OPTION_MESSAGE_COUNT;
+	static const relpipe::common::type::StringX OPTION_RELATION;
+	static const relpipe::common::type::StringX OPTION_STREAM;
+	static const relpipe::common::type::StringX OPTION_CONNECTION_STRING;
+	static const relpipe::common::type::StringX OPTION_CONNECTION_OPTION;
+	static const relpipe::common::type::StringX OPTION_MESSAGE_COUNT;
 
-	Configuration parse(const std::vector<relpipe::writer::string_t>& arguments) {
+	Configuration parse(const std::vector<relpipe::common::type::StringX>& arguments) {
 		Configuration c;
 
 		for (int i = 0; i < arguments.size();) {
-			relpipe::writer::string_t option = readNext(arguments, i);
+			relpipe::common::type::StringX option = readNext(arguments, i);
 
 			if (option == OPTION_RELATION) {
 				c.relation = readNext(arguments, i);
 			} else if (option == OPTION_STREAM) {
 				c.stream = readNext(arguments, i);
+			} else if (option == OPTION_CONNECTION_STRING) {
+				c.connectionString = readNext(arguments, i);
+			} else if (option == OPTION_CONNECTION_OPTION) {
+				auto name = readNext(arguments, i);
+				auto value = readNext(arguments, i);
+				c.connectionOptions.push_back({name, value});
 			} else if (option == OPTION_MESSAGE_COUNT) {
 				c.messageCount = std::stoull(readNext(arguments, i));
 			} else throw relpipe::cli::RelpipeCLIException(L"Unsupported CLI option: " + option, relpipe::cli::CLI::EXIT_CODE_BAD_CLI_ARGUMENTS);
@@ -65,9 +73,11 @@
 	}
 };
 
-const relpipe::writer::string_t CLIParser::OPTION_RELATION = L"--relation";
-const relpipe::writer::string_t CLIParser::OPTION_STREAM = L"--stream";
-const relpipe::writer::string_t CLIParser::OPTION_MESSAGE_COUNT = L"--message-count";
+const relpipe::common::type::StringX CLIParser::OPTION_RELATION = L"--relation";
+const relpipe::common::type::StringX CLIParser::OPTION_STREAM = L"--stream";
+const relpipe::common::type::StringX CLIParser::OPTION_CONNECTION_STRING = L"--connection-string";
+const relpipe::common::type::StringX CLIParser::OPTION_CONNECTION_OPTION = L"--connection-option";
+const relpipe::common::type::StringX CLIParser::OPTION_MESSAGE_COUNT = L"--message-count";
 
 }
 }