src/Command.h
branchv_0
changeset 26 aadef824dc93
parent 24 c31fdd965028
child 37 27f0ffa712d9
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/Command.h	Sun Dec 09 18:33:20 2018 +0100
@@ -0,0 +1,49 @@
+/**
+ * Relational pipes
+ * Copyright © 2018 František Kučera (Frantovo.cz, GlobalCode.info)
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#pragma once
+
+#include <cstdlib>
+#include <iostream>
+#include <string>
+#include <vector>
+#include <algorithm>
+
+
+namespace relpipe {
+namespace in {
+namespace cli {
+
+class Command {
+public:
+	virtual ~Command() = default;
+
+	/**
+	 * Processes the inputs (stream + arguments) and generates output in the relational pipes format.
+	 * 
+	 * @param input usually STDIN, may not be used if all data are passed as CLI arguments
+	 * @param output usually STDOUT, relational data is passed here
+	 * @param command command name, usualy not needed, may be significant if the same Command instance is used for several commands
+	 * @param arguments CLI arguments containing data or parameters (format is specific to each command)
+	 */
+	virtual void process(std::istream& input, std::ostream& output, const relpipe::writer::string_t& command, const std::vector<relpipe::writer::string_t> &arguments) = 0;
+
+};
+
+}
+}
+}