source: icGREP/icgrep-devel/icgrep/re_cc.h @ 3935

Last change on this file since 3935 was 3935, checked in by daled, 5 years ago

The parser is now able to parse unicode categories.

File size: 1.5 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#ifndef RE_CC_H
8#define RE_CC_H
9
10#include "re_re.h"
11
12#include <iostream>
13#include <string>
14#include <sstream>
15#include <utility>
16#include <vector>
17
18#define INT2STRING(i) static_cast<std::ostringstream*>(&(std::ostringstream() << i))->str()
19
20struct CharSetItem{
21    int lo_codepoint;
22    int hi_codepoint;
23};
24
25class CC : public RE
26{
27public:
28    CC();
29    CC(int codepoint);
30    CC(int lo_codepoint, int hi_codepoint);
31    CC(CC* cc1, CC* cc2);
32    ~CC();
33    std::vector<CharSetItem> getItems();
34    std::string getName();
35    std::string getId();
36    bool is_member(int codepoint);
37    void insert1(int codepoint);
38    void insert_range(int lo_codepoint,int hi_codepoint);
39    void negate_class();
40    void remove1(int codepoint);
41    void remove_range(int lo_codepoint,int hi_codepoint);
42
43protected:
44    static int msCSIidx;
45private:
46    static const int mUnicodeMax = 0x10FFFF;
47
48    void gensym_name();
49    bool is_member_helper(int codepoint, int idx);
50    void joinCharSets(std::vector<CharSetItem> items1);
51    void joinCharSets_helper(std::vector<CharSetItem> items1, int idx);
52    void insert_range_helper(int lo_codepoint, int hi_codepoint, int idx);
53    void negate_class_helper(int idx, int b);
54    void remove_range_helper(int lo_codepoint, int hi_codepoint, int idx);
55
56    std::vector<CharSetItem> mSparceCharSet;
57    std::string mId;
58};
59
60#endif // RE_CC_H
Note: See TracBrowser for help on using the repository browser.