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

Last change on this file since 5202 was 4829, checked in by nmedfort, 4 years ago

Back-up check in

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