From 91492cad207d177b6c798997e974d0ad2f37d5e6 Mon Sep 17 00:00:00 2001 From: giomba Date: Sat, 17 Aug 2019 14:29:43 +0200 Subject: [PATCH] filesystem improvements library directory tree improved in order to better comply with unix fs hierarchy standard --- lib/CNS.h | 34 +++++++++++++++++++++++++++++----- lib/Ex.cpp | 10 ++-------- lib/Ex.h | 21 --------------------- lib/cnsparser.pro | 10 +++++----- lib/read_dati_personali_c.cpp | 2 +- lib/read_dati_personali_c.h | 16 ---------------- test/main.cpp | 2 +- 7 files changed, 38 insertions(+), 57 deletions(-) delete mode 100644 lib/Ex.h delete mode 100644 lib/read_dati_personali_c.h diff --git a/lib/CNS.h b/lib/CNS.h index b739c9f..782d551 100644 --- a/lib/CNS.h +++ b/lib/CNS.h @@ -1,5 +1,10 @@ -#ifndef CONVERT_H -#define CONVERT_H +#ifndef CNS_H +#define CNS_H + +#include +#include +#include +#include #include #include @@ -11,12 +16,31 @@ #include #include -#include "Ex.h" +// QT -- What to export +//#define CNS Q_DECL_EXPORT CNS -#include "read_dati_personali_c.h" +// PCSCLITE +// -------------------------------------------------------------------- +int read_dati_personali_c(char** output_buffer, int* len); -#define CNS Q_DECL_EXPORT CNS +// EXCEPTIONS +// -------------------------------------------------------------------- +/* `explicit` specifier forces constructors to not being implicitly called */ +class Ex { + private: + std::string msg; + public: + explicit Ex(); + explicit Ex(const char* msg); + explicit Ex(const std::string& msg); + friend std::ostream& operator<<(std::ostream&, const Ex&); +}; +/* Parent::Parent makes classes inherit their constructors from parents (C++11) */ +class ExPCSC : public Ex { using Ex::Ex; }; + +// CNS +// -------------------------------------------------------------------- enum Sex { F, M diff --git a/lib/Ex.cpp b/lib/Ex.cpp index b38d3a9..c96cfe4 100644 --- a/lib/Ex.cpp +++ b/lib/Ex.cpp @@ -1,4 +1,4 @@ -#include "Ex.h" +#include "CNS.h" Ex::Ex() { this->msg = std::string("generic exception"); @@ -12,13 +12,7 @@ Ex::Ex(const std::string& msg) { this->msg = msg; } -/* -Ex::Ex(const char* msg, int n) { - this->msg = std::string(msg) + ": " + strerror(n); -} -*/ - std::ostream& operator<<(std::ostream& os, const Ex& e) { os << e.msg; return os; -} \ No newline at end of file +} diff --git a/lib/Ex.h b/lib/Ex.h deleted file mode 100644 index 24f788d..0000000 --- a/lib/Ex.h +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef EXCEPTION_H -#define EXCEPTION_H - -#include -#include - -/* `explicit` specifier forces constructors to not being implicitly called */ -class Ex { - private: - std::string msg; - public: - explicit Ex(); - explicit Ex(const char* msg); - explicit Ex(const std::string& msg); - friend std::ostream& operator<<(std::ostream&, const Ex&); -}; - -/* Parent::Parent makes classes inherit their constructors from parents (C++11) */ -class ExPCSC : public Ex { using Ex::Ex; }; - -#endif \ No newline at end of file diff --git a/lib/cnsparser.pro b/lib/cnsparser.pro index 86bfe49..03943a6 100644 --- a/lib/cnsparser.pro +++ b/lib/cnsparser.pro @@ -28,10 +28,10 @@ SOURCES += \ read_dati_personali_c.cpp HEADERS += \ - CNS.h \ - Ex.h \ - read_dati_personali_c.h - -INSTALLS += target + CNS.h target.path = /usr/lib +headers.path = /usr/include +headers.files += $$HEADERS + +INSTALLS += target headers diff --git a/lib/read_dati_personali_c.cpp b/lib/read_dati_personali_c.cpp index 56a5794..131486b 100644 --- a/lib/read_dati_personali_c.cpp +++ b/lib/read_dati_personali_c.cpp @@ -1,4 +1,4 @@ -#include "read_dati_personali_c.h" +#include "CNS.h" /* `` diff --git a/lib/read_dati_personali_c.h b/lib/read_dati_personali_c.h deleted file mode 100644 index 9437b64..0000000 --- a/lib/read_dati_personali_c.h +++ /dev/null @@ -1,16 +0,0 @@ -#ifndef READ_DATI_PERSONALI_H -#define READ_DATI_PERSONALI_H - -#include -#include -#include - -#include - -#include - -#include "Ex.h" - -int read_dati_personali_c(char** output_buffer, int* len); - -#endif \ No newline at end of file diff --git a/test/main.cpp b/test/main.cpp index 0078ace..c014807 100644 --- a/test/main.cpp +++ b/test/main.cpp @@ -2,7 +2,7 @@ #include -#include "../lib/CNS.h" +#include int main(void) { CNS cns;