source: icGREP/icgrep-devel/icgrep/re/re_cc.cpp

Last change on this file was 5673, checked in by cameron, 6 weeks ago

Case folding property objects

File size: 1.2 KB
Line 
1/*
2 *  Copyright (c) 2014 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#include "re_cc.h"
8#include <llvm/Support/Compiler.h>
9#include <UCD/CaseFolding.h>
10#include <sstream>
11
12namespace re {
13
14CC::CC(const CC * cc1, const CC * cc2)
15: RE(ClassTypeId::CC)
16, UCD::UnicodeSet(std::move(*cc1 + *cc2)) {
17
18}
19
20CC::CC(const CC & cc)
21: RE(ClassTypeId::CC)
22, UCD::UnicodeSet(cc) {
23
24}
25
26std::string CC::canonicalName(const CC_type type) const {
27    std::stringstream name;
28    name << std::hex;
29    if ((type == ByteClass) && (max_codepoint() >= 0x80)) {
30        name << "BC";
31    } else {
32        name << "CC";
33    }
34    char separator = '_';
35    for (const interval_t i : *this) {
36        name << separator;
37        if (lo_codepoint(i) == hi_codepoint(i)) {
38            name << lo_codepoint(i);
39        }
40        else {
41            name << lo_codepoint(i) << '_' << hi_codepoint(i);
42        }
43        separator = ',';
44    }
45    return name.str();
46}
47   
48CC * caseInsensitize(const CC * cc) {
49    CC * cci = makeCC();
50    for (const interval_t i : *cc) {
51        caseInsensitiveInsertRange(cci, lo_codepoint(i), hi_codepoint(i));
52    }
53    return cci;
54}
55   
56}
Note: See TracBrowser for help on using the repository browser.