Ignore:
Timestamp:
Dec 21, 2017, 3:22:41 PM (13 months ago)
Author:
cameron
Message:

Adding Alphabet to CCs: initial check-in

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/re/re_cc.h

    r5781 r5795  
    1010#include "re_re.h"
    1111#include <UCD/unicode_set.h>
     12#include <cc/alphabet.h>
    1213
    1314namespace re {
     
    2829    }
    2930
     31    const cc::Alphabet * getAlphabet() const { return mAlphabet;}
    3032
    3133    std::string canonicalName(const CC_type type) const;
     
    4244
    4345protected:
    44     friend CC * makeCC();
    45     friend CC * makeCC(const codepoint_t codepoint);
    46     friend CC * makeCC(const codepoint_t lo, const codepoint_t hi);
     46    friend CC * makeCC(const cc::Alphabet * alphabet);
     47    friend CC * makeCC(const codepoint_t codepoint, const cc::Alphabet * alphabet);
     48    friend CC * makeCC(const codepoint_t lo, const codepoint_t hi, const cc::Alphabet * alphabet);
    4749    friend CC * makeCC(const CC * cc1, const CC * cc2);
    48     friend CC * makeCC(std::initializer_list<interval_t> list);
    49     friend CC * makeCC(std::vector<interval_t> && list);
    50     friend CC * makeCC(UCD::UnicodeSet && set);
     50    friend CC * makeCC(std::initializer_list<interval_t> list, const cc::Alphabet * alphabet);
     51    friend CC * makeCC(std::vector<interval_t> && list, const cc::Alphabet * alphabet);
     52    friend CC * makeCC(UCD::UnicodeSet && set, const cc::Alphabet * alphabet);
    5153    friend CC * subtractCC(const CC * a, const CC * b);
    5254    friend CC * intersectCC(const CC * a, const CC * b);
    5355
    54     CC();
     56    CC(const cc::Alphabet * alphabet);
    5557
    5658    CC(const CC & cc);
    5759
    58     CC(const codepoint_t codepoint);
     60    CC(const codepoint_t codepoint, const cc::Alphabet * alphabet);
    5961
    60     explicit CC(const codepoint_t lo_codepoint, const codepoint_t hi_codepoint);
     62    explicit CC(const codepoint_t lo_codepoint, const codepoint_t hi_codepoint, const cc::Alphabet * alphabet);
    6163
    6264    explicit CC(const CC * cc1, const CC * cc2);
    6365
    64     CC(const UCD::UnicodeSet && set);
     66    CC(const UCD::UnicodeSet && set, const cc::Alphabet * alphabet);
    6567
    66     CC(std::initializer_list<interval_t>::iterator begin, std::initializer_list<interval_t>::iterator end);
     68    CC(std::initializer_list<interval_t>::iterator begin, std::initializer_list<interval_t>::iterator end, const cc::Alphabet * alphabet);
    6769
    68     CC(const std::vector<interval_t>::iterator begin, const std::vector<interval_t>::iterator end);
     70    CC(const std::vector<interval_t>::iterator begin, const std::vector<interval_t>::iterator end, const cc::Alphabet * alphabet);
     71private:
     72    const cc::Alphabet * mAlphabet;
     73   
    6974
    7075};
     
    100105 */
    101106
    102 inline CC * makeCC() {
    103     return new CC();
     107inline CC * makeCC(const cc::Alphabet * alphabet = &cc::Unicode) {
     108    return new CC(alphabet);
    104109}
    105110
    106 inline CC * makeCC(const codepoint_t codepoint) {
    107     return new CC(codepoint);
     111    inline CC * makeCC(const codepoint_t codepoint, const cc::Alphabet * alphabet = &cc::Unicode) {
     112    return new CC(codepoint, alphabet);
    108113}
    109114
    110 inline CC * makeCC(const codepoint_t lo, const codepoint_t hi) {
    111     return new CC(lo, hi);
     115inline CC * makeCC(const codepoint_t lo, const codepoint_t hi, const cc::Alphabet * alphabet = &cc::Unicode) {
     116    return new CC(lo, hi, alphabet);
    112117}
    113118
     
    116121}
    117122
    118 inline CC * makeCC(std::initializer_list<interval_t> list) {
    119     return new CC(list.begin(), list.end());
     123inline CC * makeCC(std::initializer_list<interval_t> list, const cc::Alphabet * alphabet = &cc::Unicode) {
     124    return new CC(list.begin(), list.end(), alphabet);
    120125}
    121126
    122 inline CC * makeCC(std::vector<interval_t> && list) {
    123     return new CC(list.begin(), list.end());
     127inline CC * makeCC(std::vector<interval_t> && list, const cc::Alphabet * alphabet = &cc::Unicode) {
     128    return new CC(list.begin(), list.end(), alphabet);
    124129}
    125130
    126 inline CC * makeCC(UCD::UnicodeSet && set) {
    127     return new CC(std::move(set));
     131inline CC * makeCC(UCD::UnicodeSet && set, const cc::Alphabet * alphabet = &cc::Unicode) {
     132    return new CC(std::move(set), alphabet);
    128133}
    129134
    130135inline CC * subtractCC(const CC * a, const CC * b) {
    131     return new CC(*a - *b);
     136    //assert (a->getAlphabet() == b->getAlphabet());
     137    return new CC(*a - *b, a->getAlphabet());
    132138}
    133139
    134140inline CC * intersectCC(const CC * a, const CC * b) {
    135     return new CC(*a & *b);
     141    //assert (a->getAlphabet() == b->getAlphabet());
     142    return new CC(*a & *b, a->getAlphabet());
    136143}
    137144
Note: See TracChangeset for help on using the changeset viewer.