src/GuileHandler.h
branchv_0
changeset 6 4062b8436838
parent 5 17bb45570099
child 7 61fc569b77e6
--- a/src/GuileHandler.h	Sun Jan 27 17:57:03 2019 +0100
+++ b/src/GuileHandler.h	Sun Feb 03 01:44:07 2019 +0100
@@ -38,6 +38,8 @@
 
 #include <relpipe/cli/RelpipeCLIException.h>
 
+#include "Configuration.h"
+
 namespace relpipe {
 namespace tr {
 namespace guile {
@@ -51,6 +53,7 @@
 private:
 	std::wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings or use always UTF-8 between C++ and Guile
 
+	Configuration configuration;
 	shared_ptr<writer::RelationalWriter> relationalWriter;
 
 	wregex relationNameRegEx;
@@ -143,15 +146,16 @@
 
 public:
 
-	GuileHandler(ostream& output, const vector<string_t>& arguments) {
+	GuileHandler(ostream& output, Configuration& configuration, const vector<string_t>& arguments) : configuration(configuration) {
 		relationalWriter.reset(writer::Factory::create(output));
 
-		// TODO: options and parser
-		if (arguments.size() == 2) {
-			relationNameRegEx = wregex(arguments[0]);
-			guileCodeWhereCondition = arguments[1];
+		// FIXME: remove and work directly with configuration in startRelation() and attribute()
+		// i.e. support multiple relationConfigurations
+		if (configuration.relationConfigurations.size() == 1) {
+			relationNameRegEx = wregex(configuration.relationConfigurations[0].relation);
+			guileCodeWhereCondition = configuration.relationConfigurations[0].guileWhere;
 		} else {
-			throw cli::RelpipeCLIException(L"Usage: relpipe-tr-guile <relationNameRegExp> <whereConditionGuileCode>", cli::CLI::EXIT_CODE_UNKNOWN_COMMAND);
+			throw cli::RelpipeCLIException(L"FIXME: only single relationConfiguration is currently supported", cli::CLI::EXIT_CODE_UNKNOWN_COMMAND);
 		}
 	}