Browse code

Use CXX17 flag, reformat

Greg Finak authored on 22/12/2021 17:21:48
Showing 2 changed files

... ...
@@ -1,74 +1,73 @@
1 1
 #ifndef WSTYPE_HPP_
2 2
 #define WSTYPE_HPP_
3 3
 
4
-#include "wsNode.hpp"
5 4
 #include <cytolib/global.hpp>
6 5
 
7
-using namespace cytolib;
6
+#include "wsNode.hpp"
8 7
 
8
+using namespace cytolib;
9 9
 
10
-enum class WS_TYPE {WS_WIN, WS_MAC, WS_MAC_3, WS_VX}; //can't put it into cytoml namespace since ws_ver_type_map need to refer it
10
+enum class WS_TYPE {
11
+  WS_WIN,
12
+  WS_MAC,
13
+  WS_MAC_3,
14
+  WS_VX
15
+};  // can't put it into cytoml namespace since ws_ver_type_map need to refer it
11 16
 
12 17
 typedef unordered_map<string, WS_TYPE> WS_VERSION_TYPE_MAP;
13 18
 
14
-extern WS_VERSION_TYPE_MAP ws_ver_type_map; //declare global var
15
-#define WS_INIT() \
16
-		WS_VERSION_TYPE_MAP ws_ver_type_map = {\
17
-												{"1.61", WS_TYPE::WS_WIN},\
18
-												{"1.6", WS_TYPE::WS_WIN},\
19
-												{"2.0", WS_TYPE::WS_MAC},\
20
-												{"3.0", WS_TYPE::WS_MAC_3},\
21
-												{"1.8", WS_TYPE::WS_VX},\
22
-												{"20.0", WS_TYPE::WS_VX}\
23
-												};\
24
-
25
-namespace CytoML
26
-{
27
-
28
-	enum class SAMPLE_NAME_LOCATION {KEY_WORD = 1, SAMPLE_NODE = 2};
29
-
30
-	inline void print_supported_workspace_version()
31
-	{
32
-		vector<string> s_ws_type = {"WS_WIN", "WS_MAC", "WS_MAC_3", "WS_VX"};
33
-		PRINT("Workspace versions vs types:");
34
-		for(auto & it : ws_ver_type_map)
35
-			PRINT(it.first + ": " + s_ws_type[static_cast<int>(it.second)] + "\n");
36
-	}
37
-
38
-	inline void add_workspace_version(const string & version, WS_TYPE ws_type)
39
-	{
40
-		ws_ver_type_map["version"] = ws_type;
41
-	}
42
-
43
-	inline WS_TYPE get_workspace_type(xmlDocPtr doc)
44
-	{
45
-		wsNode root(doc->children);
46
-		xmlXPathObjectPtr res = root.xpath("/Workspace");
47
-		wsNode curNode(res->nodesetval->nodeTab[0]);
48
-		xmlXPathFreeObject(res);
49
-		string version=curNode.getProperty("version");
50
-
51
-		auto it = ws_ver_type_map.find(version);
52
-		if(it==ws_ver_type_map.end())
53
-			throw(domain_error("Unrecognized workspace version: " + version \
54
-									+ "\n Please use 'print_supported_workspace_version()' to list the supported version." \
55
-									+ "\n Or use 'add_workspace_version' to add the new version number into the list (if you are sure it is compatible to the existing workspace type)" \
56
-									));
57
-
58
-		return it->second;
59
-	}
60
-
61
-	inline vector<string> list_files(const string & data_dir, const string & ext)
62
-	{
63
-		vector<string> paths;
64
-
65
-        for(const fs::directory_entry & i: fs::recursive_directory_iterator(fs::path(data_dir), fs::symlink_option::recurse))
66
-        {
67
-        	if(i.path().extension().string() == ext)
68
-        		paths.push_back(i.path().string());
69
-        }
70
-		return paths;
71
-	}
72
-};
19
+extern WS_VERSION_TYPE_MAP ws_ver_type_map;  // declare global var
20
+#define WS_INIT()                                            \
21
+  WS_VERSION_TYPE_MAP ws_ver_type_map = {                    \
22
+      {"1.61", WS_TYPE::WS_WIN}, {"1.6", WS_TYPE::WS_WIN},   \
23
+      {"2.0", WS_TYPE::WS_MAC},  {"3.0", WS_TYPE::WS_MAC_3}, \
24
+      {"1.8", WS_TYPE::WS_VX},   {"20.0", WS_TYPE::WS_VX}};
25
+
26
+namespace CytoML {
27
+
28
+enum class SAMPLE_NAME_LOCATION { KEY_WORD = 1, SAMPLE_NODE = 2 };
29
+
30
+inline void print_supported_workspace_version() {
31
+  vector<string> s_ws_type = {"WS_WIN", "WS_MAC", "WS_MAC_3", "WS_VX"};
32
+  PRINT("Workspace versions vs types:");
33
+  for (auto& it : ws_ver_type_map)
34
+    PRINT(it.first + ": " + s_ws_type[static_cast<int>(it.second)] + "\n");
35
+}
36
+
37
+inline void add_workspace_version(const string& version, WS_TYPE ws_type) {
38
+  ws_ver_type_map["version"] = ws_type;
39
+}
40
+
41
+inline WS_TYPE get_workspace_type(xmlDocPtr doc) {
42
+  wsNode root(doc->children);
43
+  xmlXPathObjectPtr res = root.xpath("/Workspace");
44
+  wsNode curNode(res->nodesetval->nodeTab[0]);
45
+  xmlXPathFreeObject(res);
46
+  string version = curNode.getProperty("version");
47
+
48
+  auto it = ws_ver_type_map.find(version);
49
+  if (it == ws_ver_type_map.end())
50
+    throw(domain_error("Unrecognized workspace version: " + version +
51
+                       "\n Please use 'print_supported_workspace_version()' to "
52
+                       "list the supported version." +
53
+                       "\n Or use 'add_workspace_version' to add the new "
54
+                       "version number into the list (if you are sure it is "
55
+                       "compatible to the existing workspace type)"));
56
+
57
+  return it->second;
58
+}
59
+
60
+inline vector<string> list_files(const string& data_dir, const string& ext) {
61
+  vector<string> paths;
62
+
63
+  for (const fs::directory_entry& i : fs::recursive_directory_iterator(
64
+           fs::path(data_dir),
65
+           fs::directory_options::follow_directory_symlink)) {
66
+    if (i.path().extension().string() == ext)
67
+      paths.push_back(i.path().string());
68
+  }
69
+  return paths;
70
+}
71
+};  // namespace CytoML
73 72
 
74 73
 #endif
... ...
@@ -6,7 +6,7 @@ ifneq (,)
6 6
 This makefile requires GNU Make.
7 7
 endif
8 8
 	
9
-CXX_STD = CXX11
9
+CXX_STD = CXX17
10 10
 
11 11
 PKG_CPPFLAGS =-DROUT -I../inst/include/ @PKG_CPPFLAGS@ -DBOOST_NO_AUTO_PTR 
12 12