source: icGREP/icgrep-devel/icgrep/re/re_assertion.h @ 4415

Last change on this file since 4415 was 4407, checked in by cameron, 4 years ago

Assertion header check-in

File size: 1.3 KB
Line 
1/*
2 *  Copyright (c) 2015 International Characters.
3 *  This software is licensed to the public under the Open Software License 3.0.
4 *  icgrep is a trademark of International Characters.
5 */
6
7#ifndef RE_ASSERTION_H
8#define RE_ASSERTION_H
9
10#include <re/re_re.h>
11
12namespace re {
13
14class Assertion : public RE {
15public:
16    static inline bool classof(const RE * re) {
17        return re->getClassTypeId() == ClassTypeId::Assertion;
18    }
19    static inline bool classof(const void *) {
20        return false;
21    }
22    enum class Kind {Lookbehind, Lookahead};
23    enum class Sense {Positive, Negative};
24
25    RE * getAsserted() const {return mAsserted;}
26    Assertion::Kind getKind() const {return mKind;}
27    Assertion::Sense getSense() const {return mSense;}
28    void setAsserted(RE * r) {mAsserted = r;}
29
30
31protected:
32    friend Assertion * makeAssertion(RE * asserted, Kind k, Sense s);
33    void* operator new (std::size_t size) noexcept {
34        return mAllocator.allocate(size);
35    }
36    Assertion(RE * r, Kind k, Sense s) : RE(ClassTypeId::Assertion), mAsserted(r), mKind(k), mSense(s) {}
37    virtual ~Assertion() {}
38
39private:
40    RE * mAsserted;
41    Kind mKind;
42    Sense mSense;
43};
44
45inline Assertion * makeAssertion(RE * asserted, Assertion::Kind k, Assertion::Sense s) {
46    return new Assertion(asserted, k, s);
47}
48
49}
50
51#endif // RE_ASSERTION_H
52
Note: See TracBrowser for help on using the repository browser.