1 using System;
 2 using System.Collections;
 3 
 4 // this file has been semiautomatically generated from 'D:/work/soulng-project/soulng/rex/Match.hpp' using cpp2cm version 1.0.0
 5 
 6 // this file has been semiautomatically generated from 'D:/work/soulng-project/soulng/rex/Match.cpp' using cpp2cm version 1.0.0
 7 
 8 namespace System.RegularExpressions
 9 {
10     public ustring MakeRegularExpressionPatternFromFilePattern(const ustring& filePattern)
11     {
12         ustring pattern;
13         for (uchar c : filePattern)
14         {
15             switch (c)
16             {
17                 case '.': pattern.Append(u"\\.");
18                 break;
19                 case '*': pattern.Append(u".*");
20                 break;
21                 case '?': pattern.Append(u".");
22                 break;
23                 default: pattern.Append(c, 1);
24                 break;
25             }
26         }
27         return pattern;
28     }
29     public bool FilePatternMatch(const ustring& filePath, const ustring& filePattern)
30     {
31         return PatternMatch(filePath, MakeRegularExpressionPatternFromFilePattern(filePattern));
32     }
33     public bool PatternMatch(const ustring& str, const ustring& regularExpressionPattern)
34     {
35         Context context;
36         Nfa nfa = CompileRegularExpressionPattern(context, regularExpressionPattern);
37         bool match = PatternMatch(str, nfa);
38         return match;
39     }
40     public Nfa CompileRegularExpressionPattern(Context& context, const ustring& regularExpressionPattern)
41     {
42         RexLexer lexer(regularExpressionPattern, "", 0);
43         return ParseRegularExpressionPattern(lexer, context);
44     }
45     public Nfa CompileFilePattern(Context& context, const ustring& filePattern)
46     {
47         return CompileRegularExpressionPattern(context, MakeRegularExpressionPatternFromFilePattern(filePattern));
48     }
49     public bool PatternMatch(const ustring& str, Nfa& nfa)
50     {
51         return Match(nfa, str);
52     }
53 } // namespace System.RegularExpressions