move CLI.h to a common header-only library v_0
authorFrantišek Kučera <franta-hg@frantovo.cz>
Sun, 12 Aug 2018 12:52:19 +0200
branchv_0
changeset 4 0afc596749a1
parent 3 e8be873f1eab
child 5 549a40d276c3
move CLI.h to a common header-only library
CLI.h
nbproject/Makefile-Debug.mk
nbproject/Makefile-Release.mk
nbproject/configurations.xml
nbproject/project.xml
relpipe-in-fstab.cpp
--- a/CLI.h	Sun Aug 12 11:46:03 2018 +0200
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-#pragma once
-
-#include <locale.h>
-#include <string>
-#include <vector>
-#include <sstream>
-#include <locale>
-#include <codecvt>
-
-using namespace std;
-
-namespace relpipe {
-namespace cli {
-
-/**
- * TODO: move to relpipe-lib-cli (a common header-only library)
- */
-class CLI {
-public:
-
-	CLI(int argc, char* argv[]) {
-		setlocale(LC_ALL, "");
-
-		this->argc = &argc;
-		this->argv = &argv;
-
-		program = convertor.from_bytes(argv[0]);
-
-		for (int i = 1; i < argc; i++) {
-			args.insert(args.end(), convertor.from_bytes(argv[i]));
-		}
-
-	}
-
-	CLI(const CLI& orig) {
-	}
-
-	virtual ~CLI() {
-	}
-
-	const wstring programName() {
-		return (const wstring) program;
-	}
-
-	const vector<wstring> arguments() {
-		return (const vector<wstring>)args;
-	}
-
-	static const int EXIT_CODE_SUCCESS = 0;
-	static const int EXIT_CODE_UNEXPECTED_ERROR = 1;
-	static const int EXIT_CODE_BAD_SYNTAX = 3;
-	static const int EXIT_CODE_UNKNOWN_COMMAND = 4;
-	static const int EXIT_CODE_DATA_ERROR = 5;
-
-private:
-	int* argc;
-	char*** argv;
-	wstring program;
-	vector<wstring> args;
-	wstring_convert<codecvt_utf8<wchar_t>> convertor; // TODO: support also other encodings.
-};
-
-}
-}
--- a/nbproject/Makefile-Debug.mk	Sun Aug 12 11:46:03 2018 +0200
+++ b/nbproject/Makefile-Debug.mk	Sun Aug 12 12:52:19 2018 +0200
@@ -52,7 +52,7 @@
 ASFLAGS=
 
 # Link Libraries and Options
-LDLIBSOPTIONS=`pkg-config --libs relpipe-lib-writer.cpp`  
+LDLIBSOPTIONS=`pkg-config --libs relpipe-lib-writer.cpp` `pkg-config --libs relpipe-lib-cli.cpp`  
 
 # Build Targets
 .build-conf: ${BUILD_SUBPROJECTS}
@@ -65,7 +65,7 @@
 ${OBJECTDIR}/relpipe-in-fstab.o: relpipe-in-fstab.cpp
 	${MKDIR} -p ${OBJECTDIR}
 	${RM} "$@.d"
-	$(COMPILE.cc) -g `pkg-config --cflags relpipe-lib-writer.cpp` -std=c++14  -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/relpipe-in-fstab.o relpipe-in-fstab.cpp
+	$(COMPILE.cc) -g `pkg-config --cflags relpipe-lib-writer.cpp` `pkg-config --cflags relpipe-lib-cli.cpp` -std=c++14  -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/relpipe-in-fstab.o relpipe-in-fstab.cpp
 
 # Subprojects
 .build-subprojects:
--- a/nbproject/Makefile-Release.mk	Sun Aug 12 11:46:03 2018 +0200
+++ b/nbproject/Makefile-Release.mk	Sun Aug 12 12:52:19 2018 +0200
@@ -52,7 +52,7 @@
 ASFLAGS=
 
 # Link Libraries and Options
-LDLIBSOPTIONS=`pkg-config --libs relpipe-lib-writer.cpp`  
+LDLIBSOPTIONS=`pkg-config --libs relpipe-lib-writer.cpp` `pkg-config --libs relpipe-lib-cli.cpp`  
 
 # Build Targets
 .build-conf: ${BUILD_SUBPROJECTS}
@@ -65,7 +65,7 @@
 ${OBJECTDIR}/relpipe-in-fstab.o: relpipe-in-fstab.cpp
 	${MKDIR} -p ${OBJECTDIR}
 	${RM} "$@.d"
-	$(COMPILE.cc) -O2 `pkg-config --cflags relpipe-lib-writer.cpp`   -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/relpipe-in-fstab.o relpipe-in-fstab.cpp
+	$(COMPILE.cc) -O2 `pkg-config --cflags relpipe-lib-writer.cpp` `pkg-config --cflags relpipe-lib-cli.cpp`   -MMD -MP -MF "$@.d" -o ${OBJECTDIR}/relpipe-in-fstab.o relpipe-in-fstab.cpp
 
 # Subprojects
 .build-subprojects:
--- a/nbproject/configurations.xml	Sun Aug 12 11:46:03 2018 +0200
+++ b/nbproject/configurations.xml	Sun Aug 12 12:52:19 2018 +0200
@@ -4,7 +4,6 @@
     <logicalFolder name="HeaderFiles"
                    displayName="Header Files"
                    projectFiles="true">
-      <itemPath>CLI.h</itemPath>
     </logicalFolder>
     <logicalFolder name="ResourceFiles"
                    displayName="Resource Files"
@@ -43,11 +42,10 @@
         <linkerTool>
           <linkerLibItems>
             <linkerOptionItem>`pkg-config --libs relpipe-lib-writer.cpp`</linkerOptionItem>
+            <linkerOptionItem>`pkg-config --libs relpipe-lib-cli.cpp`</linkerOptionItem>
           </linkerLibItems>
         </linkerTool>
       </compileType>
-      <item path="CLI.h" ex="false" tool="3" flavor2="0">
-      </item>
       <item path="relpipe-in-fstab.cpp" ex="false" tool="1" flavor2="0">
       </item>
     </conf>
@@ -73,11 +71,10 @@
         <linkerTool>
           <linkerLibItems>
             <linkerOptionItem>`pkg-config --libs relpipe-lib-writer.cpp`</linkerOptionItem>
+            <linkerOptionItem>`pkg-config --libs relpipe-lib-cli.cpp`</linkerOptionItem>
           </linkerLibItems>
         </linkerTool>
       </compileType>
-      <item path="CLI.h" ex="false" tool="3" flavor2="0">
-      </item>
       <item path="relpipe-in-fstab.cpp" ex="false" tool="1" flavor2="0">
       </item>
     </conf>
--- a/nbproject/project.xml	Sun Aug 12 11:46:03 2018 +0200
+++ b/nbproject/project.xml	Sun Aug 12 12:52:19 2018 +0200
@@ -6,7 +6,7 @@
             <name>relpipe-in-fstab.cpp</name>
             <c-extensions/>
             <cpp-extensions>cpp</cpp-extensions>
-            <header-extensions>h</header-extensions>
+            <header-extensions/>
             <sourceEncoding>UTF-8</sourceEncoding>
             <make-dep-projects/>
             <sourceRootList/>
--- a/relpipe-in-fstab.cpp	Sun Aug 12 11:46:03 2018 +0200
+++ b/relpipe-in-fstab.cpp	Sun Aug 12 12:52:19 2018 +0200
@@ -10,7 +10,7 @@
 #include <Factory.h>
 #include <TypeId.h>
 
-#include "CLI.h"
+#include <relpipe/cli/CLI.h>
 
 using namespace relpipe::cli;
 using namespace relpipe::writer;