Browse code

add Cytostreambuf

mikejiang authored on 20/07/2021 19:24:53
Showing 3 changed files

... ...
@@ -66,8 +66,8 @@ open_flowjo_xml <- function(file,options = 0, sample_names_from = "keyword", ...
66 66
 }
67 67
 
68 68
 set_log_level <- function(level = "none"){
69
-  if(.Platform$OS.type != "windows")
70
-    stop("Please call 'flowWorkspace::set_log_level' for non-windows platforms!")
69
+  # if(.Platform$OS.type != "windows")
70
+    # stop("Please call 'flowWorkspace::set_log_level' for non-windows platforms!")
71 71
   valid_levels <- c("none", "GatingSet", "GatingHierarchy", "Population", "Gate")
72 72
   level <- match.arg(level, valid_levels)
73 73
   setLogLevel( as.integer(match(level, valid_levels) - 1))
... ...
@@ -21,6 +21,8 @@ extern WS_VERSION_TYPE_MAP ws_ver_type_map; //declare global var
21 21
 												{"1.8", WS_TYPE::WS_VX},\
22 22
 												{"20.0", WS_TYPE::WS_VX}\
23 23
 												};\
24
+		CytoML::CytoStream  cytocout;
25
+
24 26
 
25 27
 namespace CytoML
26 28
 {
... ...
@@ -13,7 +13,54 @@
13 13
 #include "cytolib/nodeProperties.hpp"
14 14
 using namespace std;
15 15
 
16
+#include <cstdio>
17
+#include <streambuf>
18
+
19
+namespace CytoML {
20
+
21
+    class Cytostreambuf : public std::streambuf {
22
+    public:
23
+        Cytostreambuf(){}
24
+
25
+    protected:
26
+        std::streamsize xsputn(const char *s, std::streamsize n) {
27
+        Rprintf("%.*s", n, s);
28
+        return n;
29
+    }
30
+
31
+        int overflow(int c = traits_type::eof()) {
32
+        if (c != traits_type::eof()) {
33
+            char_type ch = traits_type::to_char_type(c);
34
+            return xsputn(&ch, 1) == 1 ? c : traits_type::eof();
35
+        }
36
+        return c;
37
+    }
38
+
39
+
40
+       
41
+    };
42
+
43
+    class CytoStream : public std::ostream {
44
+        Cytostreambuf  cytobuf;
45
+    public:
46
+        CytoStream() : std::ostream(&cytobuf){}
47
+    };
48
+    
49
+
50
+}
51
+
52
+
53
+    
54
+extern CytoML::CytoStream  cytocout;
55
+
56
+#ifdef ROUT
57
+#define COUT cytocout
58
+#endif
59
+
60
+
61
+#ifndef ROUT
16 62
 #define COUT cout
63
+#endif
17 64
 
18 65
 
19 66
 namespace CytoML