Changeset 122 for pjproject/trunk/pjlib/include/pj++/scanner.hpp
- Timestamp:
- Jan 18, 2006 11:32:27 PM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj++/scanner.hpp
r65 r122 23 23 #include <pj++/string.hpp> 24 24 25 class Pj_Char_Spec 25 class Pj_Cis; 26 class Pj_Cis_Buffer; 27 class Pj_Scanner; 28 29 class Pj_Cis_Buffer 26 30 { 31 friend class Pj_Cis; 32 27 33 public: 28 Pj_Char_Spec() { pj_cs_init(cs__); } 29 30 void set(int c) { pj_cs_set(cs__, c); } 31 void add_range(int begin, int end) { pj_cs_add_range(cs__, begin, end); } 32 void add_alpha() { pj_cs_add_alpha(cs__); } 33 void add_num() { pj_cs_add_num(cs__); } 34 void add_str(const char *str) { pj_cs_add_str(cs__, str); } 35 void del_range(int begin, int end) { pj_cs_del_range(cs__, begin, end); } 36 void del_str(const char *str) { pj_cs_del_str(cs__, str); } 37 void invert() { pj_cs_invert(cs__); } 38 int match(int c) { return pj_cs_match(cs__, c); } 39 40 pj_char_spec_element_t *cs_() 41 { 42 return cs__; 43 } 44 45 const pj_char_spec_element_t *cs_() const 46 { 47 return cs__; 34 Pj_Cis_Buffer() 35 { 36 pj_cis_buf_init(&buf_); 48 37 } 49 38 50 39 private: 51 pj_c har_spec cs__;40 pj_cis_buf_t buf_; 52 41 }; 42 43 44 class Pj_Cis 45 { 46 friend class Pj_Scanner; 47 48 public: 49 Pj_Cis(Pj_Cis_Buffer *buf) 50 { 51 pj_cis_init(&buf->buf_, &cis_); 52 } 53 54 Pj_Cis(const Pj_Cis &rhs) 55 { 56 pj_cis_dup(&cis_, (pj_cis_t*)&rhs.cis_); 57 } 58 59 void add_range(int start, int end) 60 { 61 pj_cis_add_range(&cis_, start, end); 62 } 63 64 void add_alpha() 65 { 66 pj_cis_add_alpha(&cis_); 67 } 68 69 void add_num() 70 { 71 pj_cis_add_num(&cis_); 72 } 73 74 void add_str(const char *str) 75 { 76 pj_cis_add_str(&cis_, str); 77 } 78 79 void add_cis(const Pj_Cis &rhs) 80 { 81 pj_cis_add_cis(&cis_, &rhs.cis_); 82 } 83 84 void del_range(int start, int end) 85 { 86 pj_cis_del_range(&cis_, start, end); 87 } 88 89 void del_str(const char *str) 90 { 91 pj_cis_del_str(&cis_, str); 92 } 93 94 void invert() 95 { 96 pj_cis_invert(&cis_); 97 } 98 99 bool match(int c) const 100 { 101 return pj_cis_match(&cis_, c) != 0; 102 } 103 104 private: 105 pj_cis_t cis_; 106 }; 107 108 53 109 54 110 class Pj_Scanner … … 86 142 } 87 143 88 int peek(const Pj_C har_Spec *cs, Pj_String *out)89 { 90 return pj_scan_peek(&scanner_, cs->cs_(), out);144 int peek(const Pj_Cis *cis, Pj_String *out) 145 { 146 return pj_scan_peek(&scanner_, &cis->cis_, out); 91 147 } 92 148 … … 96 152 } 97 153 98 int peek_until(const Pj_C har_Spec *cs, Pj_String *out)99 { 100 return pj_scan_peek_until(&scanner_, cs->cs_(), out);101 } 102 103 void get(const Pj_C har_Spec *cs, Pj_String *out)104 { 105 pj_scan_get(&scanner_, cs->cs_(), out);154 int peek_until(const Pj_Cis *cis, Pj_String *out) 155 { 156 return pj_scan_peek_until(&scanner_, &cis->cis_, out); 157 } 158 159 void get(const Pj_Cis *cis, Pj_String *out) 160 { 161 pj_scan_get(&scanner_, &cis->cis_, out); 106 162 } 107 163 … … 126 182 } 127 183 128 void get_until(const Pj_C har_Spec *cs, Pj_String *out)129 { 130 pj_scan_get_until(&scanner_, cs->cs_(), out);184 void get_until(const Pj_Cis *cis, Pj_String *out) 185 { 186 pj_scan_get_until(&scanner_, &cis->cis_, out); 131 187 } 132 188 … … 161 217 } 162 218 163 void save_state(State *state) 219 void save_state(State *state) const 164 220 { 165 221 pj_scan_save_state(&scanner_, state); … … 178 234 int get_pos_col() const 179 235 { 180 return scanner_.col;236 return pj_scan_get_col(&scanner_); 181 237 } 182 238
Note: See TracChangeset
for help on using the changeset viewer.