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

Last change on this file since 5789 was 5781, checked in by cameron, 14 months ago

Small fixes

File size: 1.7 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 <sstream>
10
11namespace re {
12
13std::string CC::canonicalName(const CC_type type) const {
14    std::stringstream name;
15    name << std::hex;
16    if ((type == CC_type::ByteClass) && (max_codepoint() >= 0x80)) {
17        name << "BC";
18    } else {
19        name << "CC";
20    }
21    char separator = '_';
22    for (const interval_t i : *this) {
23        name << separator;
24        if (lo_codepoint(i) == hi_codepoint(i)) {
25            name << lo_codepoint(i);
26        }
27        else {
28            name << lo_codepoint(i) << '_' << hi_codepoint(i);
29        }
30        separator = ',';
31    }
32    return name.str();
33}
34   
35CC::CC()
36: RE(ClassTypeId::CC)
37, UnicodeSet() {
38
39}
40
41CC::CC(const CC & cc)
42: RE(ClassTypeId::CC)
43, UCD::UnicodeSet(cc) {
44
45}
46
47CC::CC(const codepoint_t codepoint)
48: RE(ClassTypeId::CC)
49, UCD::UnicodeSet(codepoint) {
50
51}
52
53CC::CC(const codepoint_t lo_codepoint, const codepoint_t hi_codepoint)
54: RE(ClassTypeId::CC)
55, UCD::UnicodeSet(lo_codepoint, hi_codepoint) {
56
57}
58
59CC::CC(const CC * cc1, const CC * cc2)
60: RE(ClassTypeId::CC)
61, UCD::UnicodeSet(std::move(*cc1 + *cc2)) {
62
63}
64
65CC::CC(const UCD::UnicodeSet && set)
66: RE(ClassTypeId::CC)
67, UCD::UnicodeSet(std::move(set)) {
68
69}
70
71CC::CC(std::initializer_list<interval_t>::iterator begin, std::initializer_list<interval_t>::iterator end)
72: RE(ClassTypeId::CC)
73, UCD::UnicodeSet(begin, end)
74{
75
76}
77
78CC::CC(const std::vector<interval_t>::iterator begin, const std::vector<interval_t>::iterator end)
79: RE(ClassTypeId::CC)
80, UCD::UnicodeSet(begin, end)
81{
82
83}
84
85}
Note: See TracBrowser for help on using the repository browser.