Line data Source code
1 :
2 : #include "match_factory.hpp"
3 : #include "../match_mode.hpp"
4 :
5 : #include "full_match.hpp"
6 : #include "prefix_match.hpp"
7 : #include "regex_match.hpp"
8 :
9 : namespace wfc{ namespace jsonrpc{
10 :
11 56 : match_factory::match_factory(int mode)
12 56 : : _mode(mode)
13 56 : {}
14 :
15 112 : std::shared_ptr<imatcher> match_factory::create_name()
16 : {
17 112 : if ( _mode & match_mode::FullMatchName )
18 : {
19 97 : return std::make_shared<full_match>();
20 : }
21 :
22 15 : if ( _mode & match_mode::PrefixMatchName )
23 : {
24 3 : return std::make_shared<prefix_match>();
25 : }
26 :
27 12 : if ( _mode & match_mode::RegexMatchName )
28 : {
29 12 : return std::make_shared<regex_match>();
30 : }
31 0 : return nullptr;
32 : }
33 :
34 127 : std::shared_ptr<imatcher> match_factory::create_value()
35 : {
36 127 : if ( _mode & match_mode::FullMatchValue )
37 : {
38 51 : return std::make_shared<full_match>();
39 : }
40 :
41 76 : if ( _mode & match_mode::PrefixMatch )
42 : {
43 7 : return std::make_shared<prefix_match>();
44 : }
45 :
46 69 : if ( _mode & match_mode::RegexMatch )
47 : {
48 69 : return std::make_shared<regex_match>();
49 : }
50 0 : return nullptr;
51 : }
52 :
53 3 : }}
|