feat: add SimplePrefixMatcher
Signed-off-by: Sefa Eyeoglu <contact@scrumplex.net>
This commit is contained in:
		| @@ -97,6 +97,7 @@ set(PATHMATCHER_SOURCES | |||||||
|     pathmatcher/IPathMatcher.h |     pathmatcher/IPathMatcher.h | ||||||
|     pathmatcher/MultiMatcher.h |     pathmatcher/MultiMatcher.h | ||||||
|     pathmatcher/RegexpMatcher.h |     pathmatcher/RegexpMatcher.h | ||||||
|  |     pathmatcher/SimplePrefixMatcher.h | ||||||
| ) | ) | ||||||
|  |  | ||||||
| set(NET_SOURCES | set(NET_SOURCES | ||||||
|   | |||||||
							
								
								
									
										21
									
								
								launcher/pathmatcher/SimplePrefixMatcher.h
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										21
									
								
								launcher/pathmatcher/SimplePrefixMatcher.h
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,21 @@ | |||||||
|  | #include <QRegularExpression> | ||||||
|  | #include "IPathMatcher.h" | ||||||
|  |  | ||||||
|  | class SimplePrefixMatcher : public IPathMatcher { | ||||||
|  |    public: | ||||||
|  |     virtual ~SimplePrefixMatcher(){}; | ||||||
|  |     SimplePrefixMatcher(const QString& prefix) | ||||||
|  |     { | ||||||
|  |         m_prefix = prefix; | ||||||
|  |         m_isPrefix = prefix.endsWith('/'); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     virtual bool matches(const QString& string) const override | ||||||
|  |     { | ||||||
|  |         if (m_isPrefix) | ||||||
|  |             return string.startsWith(m_prefix); | ||||||
|  |         return string == m_prefix; | ||||||
|  |     } | ||||||
|  |     QString m_prefix; | ||||||
|  |     bool m_isPrefix = false; | ||||||
|  | }; | ||||||
		Reference in New Issue
	
	Block a user
	 Sefa Eyeoglu
					Sefa Eyeoglu