|
|
| version 1.148, 2003/09/26 06:53:27 | version 1.151, 2003/10/21 05:11:00 |
|---|---|
| Line 298 public: | Line 298 public: |
| size_t pos(const Body substr, size_t offset=0) const { | size_t pos(const Body substr, size_t offset=0) const { |
| if(!substr.length()) | if(!substr.length()) |
| return STRING_NOT_FOUND; // in this case CORD_str returns 0 [parser users got used to -1] | return STRING_NOT_FOUND; // in this case CORD_str returns 0 [parser users got used to -1] |
| // CORD_str checks for bad offset [CORD_chr does not] | |
| return CORD_str(body, offset, substr.body); | return CORD_str(body, offset, substr.body); |
| } | } |
| size_t pos(char c, | size_t pos(char c, |
| size_t offset=0) const { | size_t offset=0) const { |
| if(offset>=length()) // CORD_chr does not check that [and ABORT's in that case] | |
| return STRING_NOT_FOUND; | |
| return CORD_chr(body, offset, c); | return CORD_chr(body, offset, c); |
| } | } |
| template<typename I> void for_each(int (*callback)(const char* s, I), I info) const { | template<typename I> void for_each( |
| CORD_iter5(body, 0, 0, (CORD_batched_iter_fn)callback, info); | int (*f1)(char c, I), |
| int (*f2)(const char* s, I), | |
| I info) const { | |
| CORD_iter5(body, 0, (CORD_iter_fn)f1, (CORD_batched_iter_fn)f2, info); | |
| } | } |
| void set_pos(CORD_pos& pos, size_t index) const { CORD_set_pos(pos, body, index); } | void set_pos(CORD_pos& pos, size_t index) const { CORD_set_pos(pos, body, index); } |
| Line 342 private: | Line 350 private: |
| public: | public: |
| static const String Empty; | |
| explicit String(const char* cstr=0, size_t helper_length=0, bool tainted=false); | explicit String(const char* cstr=0, size_t helper_length=0, bool tainted=false); |
| explicit String(const C cstr, bool tainted=false); | explicit String(const C cstr, bool tainted=false); |
| String(Body abody, Language alang): body(abody), langs(alang) { | String(Body abody, Language alang): body(abody), langs(alang) { |