Browse code

A complete refactor/rewrite of the original seqbias code. This should behave more or less identically, but is much more coherent.

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/seqbias@57223 bc3139a8-67e5-0310-9ffc-ced21a209358

Daniel Jones authored on 04/08/2011 07:36:48
Showing1 changed files
... ...
@@ -1,8 +1,10 @@
1
-#pragma once
2
-
3 1
 #ifndef REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66
4 2
 #define REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66
5 3
 
4
+#if !defined(__GNUC__) || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) || (__GNUC__ >= 4) // GCC supports "pragma once" correctly since 3.4
5
+#pragma once
6
+#endif
7
+
6 8
 
7 9
 #include <vector>
8 10
 #include <string>
Browse code

Added the seqbias package to the repository.

git-svn-id: file:///home/git/hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/seqbias@52013 bc3139a8-67e5-0310-9ffc-ced21a209358

Chao-Jen Wong authored on 22/01/2011 00:26:36
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,65 @@
1
+#pragma once
2
+
3
+#ifndef REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66
4
+#define REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66
5
+
6
+
7
+#include <vector>
8
+#include <string>
9
+
10
+namespace YAML
11
+{
12
+	class Stream;
13
+
14
+	enum REGEX_OP { REGEX_EMPTY, REGEX_MATCH, REGEX_RANGE, REGEX_OR, REGEX_AND, REGEX_NOT, REGEX_SEQ };
15
+
16
+	// simplified regular expressions
17
+	// . Only straightforward matches (no repeated characters)
18
+	// . Only matches from start of string
19
+	class RegEx
20
+	{
21
+	public:
22
+		RegEx();
23
+		RegEx(char ch);
24
+		RegEx(char a, char z);
25
+		RegEx(const std::string& str, REGEX_OP op = REGEX_SEQ);
26
+		~RegEx() {}
27
+
28
+		friend RegEx operator ! (const RegEx& ex);
29
+		friend RegEx operator || (const RegEx& ex1, const RegEx& ex2);
30
+		friend RegEx operator && (const RegEx& ex1, const RegEx& ex2);
31
+		friend RegEx operator + (const RegEx& ex1, const RegEx& ex2);
32
+		
33
+		bool Matches(char ch) const;
34
+		bool Matches(const std::string& str) const;
35
+		bool Matches(const Stream& in) const;
36
+		template <typename Source> bool Matches(const Source& source) const;
37
+
38
+		int Match(const std::string& str) const;
39
+		int Match(const Stream& in) const;
40
+		template <typename Source> int Match(const Source& source) const;
41
+
42
+	private:
43
+		RegEx(REGEX_OP op);
44
+		
45
+		template <typename Source> bool IsValidSource(const Source& source) const;
46
+		template <typename Source> int MatchUnchecked(const Source& source) const;
47
+
48
+		template <typename Source> int MatchOpEmpty(const Source& source) const;
49
+		template <typename Source> int MatchOpMatch(const Source& source) const;
50
+		template <typename Source> int MatchOpRange(const Source& source) const;
51
+		template <typename Source> int MatchOpOr(const Source& source) const;
52
+		template <typename Source> int MatchOpAnd(const Source& source) const;
53
+		template <typename Source> int MatchOpNot(const Source& source) const;
54
+		template <typename Source> int MatchOpSeq(const Source& source) const;
55
+
56
+	private:
57
+		REGEX_OP m_op;
58
+		char m_a, m_z;
59
+		std::vector <RegEx> m_params;
60
+	};
61
+}
62
+
63
+#include "regeximpl.h"
64
+
65
+#endif // REGEX_H_62B23520_7C8E_11DE_8A39_0800200C9A66