File: getmatchobject.cc

package info (click to toggle)
filtermail 1.06.00-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,688 kB
  • sloc: cpp: 2,487; fortran: 249; makefile: 106; ansic: 51; sh: 36
file content (44 lines) | stat: -rw-r--r-- 1,311 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//#define XERR
#include "expr.ih"

SpecBase *Expr::getMatchObject()
{
    UptrSpecBase &ptr = s_matchPtr[d_matchMode];    // the used match obj. ptr
                      
    if (not ptr.get())                              // not avail.: get it
    {
        switch (d_matchMode)
        {
            case eMatchMode::CIDR:
                ptr = unique_ptr<Cidr>{ 
                                new Cidr{ Options::instance().ip4() } 
                                      };
            break;

            case eMatchMode::STRING:
                ptr = unique_ptr<StringCase>{ new StringCase };
            break;

            case eMatchMode::STRING_NOCASE:
                ptr = unique_ptr<StringNoCase>{ new StringNoCase };
            break;

            case eMatchMode::PATTERN:
                ptr = unique_ptr<RulePattern>{ new RulePattern{ true} };
            break;

            case eMatchMode::PATTERN_NOCASE:
                ptr = unique_ptr<RulePattern>{ new RulePattern{ false } };
            break;

            case eMatchMode::SCRIPT:
                ptr = unique_ptr<Script>{ new Script };
            break;

            default:            // eMatchModeSize is never a match mode
            throw Exception{} << "internal error: " __FILE__;
        }
    }

    return ptr.get();
}