#include <GString.h>
Public Methods | |
| String () | |
| String (const String &x) | |
| String (const SubString &x) | |
| String (const char *t) | |
| String (const char *t, int len) | |
| String (char c) | |
| ~String () | |
| String & | operator= (const String &y) |
| String & | operator= (const char *y) |
| String & | operator= (char c) |
| String & | operator= (const SubString &y) |
| String & | operator+= (const String &y) |
| String & | operator+= (const SubString &y) |
| String & | operator+= (const char *t) |
| String & | operator+= (char c) |
| void | prepend (const String &y) |
| void | prepend (const SubString &y) |
| void | prepend (const char *t) |
| void | prepend (char c) |
| int | index (char c, int startpos=0) const |
| int | index (const String &y, int startpos=0) const |
| int | index (const SubString &y, int startpos=0) const |
| int | index (const char *t, int startpos=0) const |
| int | index (const Regex &r, int startpos=0) const |
| int | contains (char c) const |
| int | contains (const String &y) const |
| int | contains (const SubString &y) const |
| int | contains (const char *t) const |
| int | contains (const Regex &r) const |
| int | contains (char c, int pos) const |
| int | contains (const String &y, int pos) const |
| int | contains (const SubString &y, int pos) const |
| int | contains (const char *t, int pos) const |
| int | contains (const Regex &r, int pos) const |
| int | matches (char c, int pos=0) const |
| int | matches (const String &y, int pos=0) const |
| int | matches (const SubString &y, int pos=0) const |
| int | matches (const char *t, int pos=0) const |
| int | matches (const Regex &r, int pos=0) const |
| int | freq (char c) const |
| int | freq (const String &y) const |
| int | freq (const SubString &y) const |
| int | freq (const char *t) const |
| SubString | at (int pos, int len) |
| SubString | operator() (int pos, int len) |
| SubString | at (const String &x, int startpos=0) |
| SubString | at (const SubString &x, int startpos=0) |
| SubString | at (const char *t, int startpos=0) |
| SubString | at (char c, int startpos=0) |
| SubString | at (const Regex &r, int startpos=0) |
| SubString | before (int pos) |
| SubString | before (const String &x, int startpos=0) |
| SubString | before (const SubString &x, int startpos=0) |
| SubString | before (const char *t, int startpos=0) |
| SubString | before (char c, int startpos=0) |
| SubString | before (const Regex &r, int startpos=0) |
| SubString | through (int pos) |
| SubString | through (const String &x, int startpos=0) |
| SubString | through (const SubString &x, int startpos=0) |
| SubString | through (const char *t, int startpos=0) |
| SubString | through (char c, int startpos=0) |
| SubString | through (const Regex &r, int startpos=0) |
| SubString | from (int pos) |
| SubString | from (const String &x, int startpos=0) |
| SubString | from (const SubString &x, int startpos=0) |
| SubString | from (const char *t, int startpos=0) |
| SubString | from (char c, int startpos=0) |
| SubString | from (const Regex &r, int startpos=0) |
| SubString | after (int pos) |
| SubString | after (const String &x, int startpos=0) |
| SubString | after (const SubString &x, int startpos=0) |
| SubString | after (const char *t, int startpos=0) |
| SubString | after (char c, int startpos=0) |
| SubString | after (const Regex &r, int startpos=0) |
| void | del (int pos, int len) |
| void | del (const String &y, int startpos=0) |
| void | del (const SubString &y, int startpos=0) |
| void | del (const char *t, int startpos=0) |
| void | del (char c, int startpos=0) |
| void | del (const Regex &r, int startpos=0) |
| int | gsub (const String &pat, const String &repl) |
| int | gsub (const SubString &pat, const String &repl) |
| int | gsub (const char *pat, const String &repl) |
| int | gsub (const char *pat, const char *repl) |
| int | gsub (const Regex &pat, const String &repl) |
| void | reverse () |
| void | upcase () |
| void | downcase () |
| void | capitalize () |
| char & | operator[] (int i) |
| const char & | operator[] (int i) const |
| char | elem (int i) const |
| char | firstchar () const |
| char | lastchar () const |
| operator const char * () const | |
| const char * | chars () const |
| unsigned int | length () const |
| int | empty () const |
| void | alloc (int newsize) |
| int | allocation () const |
| void | error (const char *msg) const |
| int | OK () const |
Protected Methods | |
| int | search (int, int, const char *, int=-1) const |
| int | search (int, int, char) const |
| int | match (int, int, int, const char *, int=-1) const |
| int | _gsub (const char *, int, const char *,int) |
| int | _gsub (const Regex &, const char *, int) |
| SubString | _substr (int, int) |
Protected Attributes | |
| JString_t * | rep |
Friends | |
| class | SubString |
| void | cat (const String &, const String &, String &) |
| void | cat (const String &, const SubString &, String &) |
| void | cat (const String &, const char *, String &) |
| void | cat (const String &, char, String &) |
| void | cat (const SubString &, const String &, String &) |
| void | cat (const SubString &, const SubString &, String &) |
| void | cat (const SubString &, const char *, String &) |
| void | cat (const SubString &, char, String &) |
| void | cat (const char *, const String &, String &) |
| void | cat (const char *, const SubString &, String &) |
| void | cat (const char *, const char *, String &) |
| void | cat (const char *, char, String &) |
| void | cat (const String &, const String &, const String &, String &) |
| void | cat (const String &, const String &, const SubString &, String &) |
| void | cat (const String &, const String &, const char *, String &) |
| void | cat (const String &, const String &, char, String &) |
| void | cat (const String &, const SubString &, const String &, String &) |
| void | cat (const String &, const SubString &, const SubString &, String &) |
| void | cat (const String &, const SubString &, const char *, String &) |
| void | cat (const String &, const SubString &, char, String &) |
| void | cat (const String &, const char *, const String &, String &) |
| void | cat (const String &, const char *, const SubString &, String &) |
| void | cat (const String &, const char *, const char *, String &) |
| void | cat (const String &, const char *, char, String &) |
| void | cat (const char *, const String &, const String &, String &) |
| void | cat (const char *, const String &, const SubString &, String &) |
| void | cat (const char *, const String &, const char *, String &) |
| void | cat (const char *, const String &, char, String &) |
| void | cat (const char *, const SubString &, const String &, String &) |
| void | cat (const char *, const SubString &, const SubString &, String &) |
| void | cat (const char *, const SubString &, const char *, String &) |
| void | cat (const char *, const SubString &, char, String &) |
| void | cat (const char *, const char *, const String &, String &) |
| void | cat (const char *, const char *, const SubString &, String &) |
| void | cat (const char *, const char *, const char *, String &) |
| void | cat (const char *, const char *, char, String &) |
| int | split (const String &x, String res[], int maxn, const String &sep) |
| int | split (const String &x, String res[], int maxn, const Regex &sep) |
| String | common_prefix (const String &x, const String &y, int startpos=0) |
| String | common_suffix (const String &x, const String &y, int startpos=-1) |
| String | replicate (char c, int n) |
| String | replicate (const String &y, int n) |
| String | join (String src[], int n, const String &sep) |
| String | reverse (const String &x) |
| String | upcase (const String &x) |
| String | downcase (const String &x) |
| String | capitalize (const String &x) |
| ostream & | operator<< (ostream &s, const String &x) |
| ostream & | operator<< (ostream &s, const SubString &x) |
| istream & | operator>> (istream &s, String &x) |
| int | readline (istream &s, String &x, char terminator='\n', int discard_terminator=1) |
|
|
Definition at line 473 of file GString.h. 00474 : rep(&_nilStrRep) {}
|
|
|
Definition at line 475 of file GString.h. 00476 : rep(Scopy(0, x.rep)) {} |
|
|
|
|
|
|
|
||||||||||||
|
|
|
|
Definition at line 483 of file GString.h. 00484 : rep(Salloc(0, &c, 1, 1)) {} |
|
|
Definition at line 486 of file GString.h. 00486 { if (rep != &_nilStrRep) delete rep; }
|
|
|
Definition at line 1291 of file GString.cc. 01292 {
01293 if (rep == 0 // don't have a rep
01294 || rep->len > rep->sz // string oustide bounds
01295 || rep->s[rep->len] != 0) // not null-terminated
01296 error("invariant failure");
01297 return 1;
01298 }
|
|
||||||||||||||||
|
Definition at line 603 of file GString.cc. 00604 {
00605 int nmatches = 0;
00606 int sl = length();
00607 if (sl <= 0)
00608 return nmatches;
00609
00610 if (rl < 0) rl = slen(r);
00611
00612 const char* s = chars();
00613
00614 StrRep* nrep = 0;
00615 int nsz = 0;
00616
00617 char* x = 0;
00618
00619 int si = 0;
00620 int xi = 0;
00621 int remaining = sl;
00622 int pos, pl = 0; // how long is a regular expression?
00623
00624 while (remaining > 0)
00625 {
00626 pos = pat.search(s, sl, pl, si); // unlike string search, the pos returned here is absolute
00627 if (pos < 0 || pl <= 0)
00628 break;
00629 else
00630 {
00631 ++nmatches;
00632 int mustfit = xi + remaining + rl - pl;
00633 if (mustfit >= nsz)
00634 {
00635 if (nrep != 0) nrep->len = xi;
00636 nrep = Sresize(nrep, mustfit);
00637 x = nrep->s;
00638 nsz = (short) nrep->sz;
00639 }
00640 pos -= si;
00641 ncopy(&(s[si]), &(x[xi]), pos);
00642 ncopy(r, &(x[xi + pos]), rl);
00643 si += pos + pl;
00644 remaining -= pos + pl;
00645 xi += pos + rl;
00646 }
00647 }
00648
00649 if (nrep == 0)
00650 {
00651 if (nmatches == 0)
00652 return nmatches;
00653 else
00654 nrep = Sresize(nrep, xi+remaining);
00655 }
00656
00657 ncopy0(&(s[si]), &(x[xi]), remaining);
00658 nrep->len = xi + remaining;
00659
00660 if (nrep->len <= rep->sz) // fit back in if possible
00661 {
00662 rep->len = nrep->len;
00663 ncopy0(nrep->s, rep->s, rep->len);
00664 delete(nrep);
00665 }
00666 else
00667 {
00668 delete(rep);
00669 rep = nrep;
00670 }
00671 return nmatches;
00672 }
|
|
||||||||||||||||||||
|
Definition at line 533 of file GString.cc. 00534 {
00535 int nmatches = 0;
00536 if (pl < 0) pl = slen(pat);
00537 if (rl < 0) rl = slen(r);
00538 int sl = length();
00539 if (sl <= 0 || pl <= 0 || sl < pl)
00540 return nmatches;
00541
00542 const char* s = chars();
00543
00544 // prepare to make new rep
00545 StrRep* nrep = 0;
00546 int nsz = 0;
00547 char* x = 0;
00548
00549 int si = 0;
00550 int xi = 0;
00551 int remaining = sl;
00552
00553 while (remaining >= pl)
00554 {
00555 int pos = search(si, sl, pat, pl);
00556 if (pos < 0)
00557 break;
00558 else
00559 {
00560 ++nmatches;
00561 int mustfit = xi + remaining + rl - pl;
00562 if (mustfit >= nsz)
00563 {
00564 if (nrep != 0) nrep->len = xi;
00565 nrep = Sresize(nrep, mustfit);
00566 nsz = (short) nrep->sz;
00567 x = nrep->s;
00568 }
00569 pos -= si;
00570 ncopy(&(s[si]), &(x[xi]), pos);
00571 ncopy(r, &(x[xi + pos]), rl);
00572 si += pos + pl;
00573 remaining -= pos + pl;
00574 xi += pos + rl;
00575 }
00576 }
00577
00578 if (nrep == 0)
00579 {
00580 if (nmatches == 0)
00581 return nmatches;
00582 else
00583 nrep = Sresize(nrep, xi+remaining);
00584 }
00585
00586 ncopy0(&(s[si]), &(x[xi]), remaining);
00587 nrep->len = xi + remaining;
00588
00589 if (nrep->len <= rep->sz) // fit back in if possible
00590 {
00591 rep->len = nrep->len;
00592 ncopy0(nrep->s, rep->s, rep->len);
00593 delete(nrep);
00594 }
00595 else
00596 {
00597 delete(rep);
00598 rep = nrep;
00599 }
00600 return nmatches;
00601 }
|
|
||||||||||||
|
Definition at line 1335 of file GString.h. 01336 {
01337 if (first < 0 || (unsigned)(first + l) > length() )
01338 return SubString(_nilString, 0, 0) ;
01339 else
01340 return SubString(*this, first, l);
01341 }
|
|
||||||||||||
|
Definition at line 874 of file GString.cc. |
|
||||||||||||
|
Definition at line 867 of file GString.cc. |
|
||||||||||||
|
Definition at line 882 of file GString.cc. |
|
||||||||||||
|
Definition at line 860 of file GString.cc. |
|
||||||||||||
|
Definition at line 853 of file GString.cc. |
|
|
Definition at line 742 of file GString.cc. 00743 {
00744 return _substr(pos + 1, length() - (pos + 1));
00745 }
|
|
|
Definition at line 194 of file GString.cc. 00195 {
00196 unsigned short old_len = rep->len;
00197 rep = Sresize(rep, newsize);
00198 rep->len = old_len;
00199 }
|
|
|
Definition at line 464 of file GString.h. 00464 { return rep->sz; }
|
|
||||||||||||
|
Definition at line 764 of file GString.cc. |
|
||||||||||||
|
Definition at line 778 of file GString.cc. 00779 {
00780 int first = search(startpos, length(), c);
00781 return _substr(first, 1);
00782 }
|
|
||||||||||||
|
Definition at line 771 of file GString.cc. |
|
||||||||||||
|
Definition at line 758 of file GString.cc. |
|
||||||||||||
|
Definition at line 752 of file GString.cc. |
|
||||||||||||
|
Definition at line 722 of file GString.cc. 00723 {
00724 return _substr(first, len);
00725 }
|
|
||||||||||||
|
Definition at line 796 of file GString.cc. |
|
||||||||||||
|
Definition at line 803 of file GString.cc. 00804 {
00805 int last = search(startpos, length(), c);
00806 return _substr(0, last);
00807 }
|
|
||||||||||||
|
Definition at line 809 of file GString.cc. |
|
||||||||||||
|
Definition at line 790 of file GString.cc. |
|
||||||||||||
|
Definition at line 784 of file GString.cc. |
|
|
Definition at line 732 of file GString.cc. 00733 {
00734 return _substr(0, pos);
00735 }
|
|
|
Definition at line 947 of file GString.h. 00948 {
00949 rep = Scapitalize(rep, rep);
00950 }
|
|
|
Definition at line 463 of file GString.h. 00463 { return &(rep->s[0]); }
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Definition at line 1009 of file GString.h. 01010 {
01011 return search(0, length(), c) >= 0;
01012 }
|
|
||||||||||||
|
Definition at line 688 of file GString.cc. |
|
||||||||||||
|
Definition at line 712 of file GString.cc. 00713 {
00714 del(search(startpos, length(), c), 1);
00715 }
|
|
||||||||||||
|
Definition at line 695 of file GString.cc. |
|
||||||||||||
|
Definition at line 707 of file GString.cc. |
|
||||||||||||
|
Definition at line 702 of file GString.cc. |
|
||||||||||||
|
Definition at line 679 of file GString.cc. |
|
|
Definition at line 941 of file GString.h. 00942 {
00943 rep = Sdowncase(rep, rep);
00944 }
|
|
|
|
|
|
Definition at line 462 of file GString.h. 00462 { return rep->len == 0; }
|
|
|
Definition at line 34 of file GString.cc. 00035 {
00036 (*lib_error_handler)("String", msg);
00037 }
|
|
|
Definition at line 972 of file GString.h. 00973 {
00974 return elem(0);
00975 }
|
|
|
Definition at line 1274 of file GString.cc. |
|
|
Definition at line 1258 of file GString.cc. |
|
|
Definition at line 1266 of file GString.cc. |
|
|
Definition at line 1282 of file GString.cc. |
|
||||||||||||
|
Definition at line 902 of file GString.cc. |
|
||||||||||||
|
Definition at line 909 of file GString.cc. |
|
||||||||||||
|
Definition at line 915 of file GString.cc. |
|
||||||||||||
|
Definition at line 896 of file GString.cc. |
|
||||||||||||
|
Definition at line 890 of file GString.cc. |
|
|
Definition at line 747 of file GString.cc. 00748 {
00749 return _substr(pos, length() - pos);
00750 }
|
|
||||||||||||
|
|
|
||||||||||||
|
Definition at line 1138 of file GString.h. 01139 {
01140 return _gsub(pat, -1, r, -1);
01141 }
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
Definition at line 984 of file GString.h. 00985 {
00986 return search(startpos, length(), c);
00987 }
|
|
|
Definition at line 977 of file GString.h. 00978 {
00979 return elem(length() - 1);
00980 }
|
|
|
Definition at line 461 of file GString.h. 00461 { return rep->len; }
|
|
||||||||||||||||||||||||
|
Definition at line 471 of file GString.cc. 00472 {
00473 if (tl < 0) tl = slen(t);
00474
00475 if (start < 0)
00476 {
00477 start = sl + start - tl + 1;
00478 if (start < 0 || (exact && start != 0))
00479 return -1;
00480 }
00481 else if (exact && sl - start != tl)
00482 return -1;
00483
00484 if (sl == 0 || tl == 0 || sl - start < tl || start >= sl)
00485 return -1;
00486
00487 int n = tl;
00488 const char* s = &(rep->s[start]);
00489 while (--n >= 0) if (*s++ != *t++) return -1;
00490 return tl;
00491 }
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
||||||||||||
|
|
|
|
Definition at line 39 of file GString.cc. 00040 {
00041 return (const char*)chars();
00042 }
|
|
||||||||||||
|
Definition at line 727 of file GString.cc. 00728 {
00729 return _substr(first, len);
00730 }
|
|
|
Definition at line 750 of file GString.h. 00751 {
00752 cat(*this, y, *this);
00753 return *this;
00754 }
|
|
|
Definition at line 744 of file GString.h. 00745 {
00746 cat(*this, y, *this);
00747 return *this;
00748 }
|
|
|
Definition at line 738 of file GString.h. 00739 {
00740 cat(*this, y, *this);
00741 return *this;
00742 }
|
|
|
Definition at line 732 of file GString.h. 00733 {
00734 cat(*this, y, *this);
00735 return *this;
00736 }
|
|
|
|
|
|
Definition at line 515 of file GString.h. 00516 {
00517 rep = Salloc(rep, &c, 1, 1);
00518 return *this;
00519 }
|
|
|
|
|
|
Definition at line 497 of file GString.h. 00498 {
00499 rep = Scopy(rep, y.rep);
00500 return *this;
00501 }
|
|
|
|
|
|
|
|
|
Definition at line 916 of file GString.h. 00917 {
00918 rep = Sprepend(rep, &y, 1);
00919 }
|
|
|
Definition at line 911 of file GString.h. 00912 {
00913 rep = Sprepend(rep, y, -1);
00914 }
|
|
|
|
|
|
|
|
|
Definition at line 929 of file GString.h. 00930 {
00931 rep = Sreverse(rep, rep);
00932 }
|
|
||||||||||||||||
|
Definition at line 415 of file GString.cc. 00416 {
00417 const char* s = chars();
00418 if (sl > 0)
00419 {
00420 if (start >= 0)
00421 {
00422 const char* a = &(s[start]);
00423 const char* lasta = &(s[sl]);
00424 while (a < lasta) if (*a++ == c) return --a - s;
00425 }
00426 else
00427 {
00428 const char* a = &(s[sl + start + 1]);
00429 while (--a >= s) if (*a == c) return a - s;
00430 }
00431 }
00432 return -1;
00433 }
|
|
||||||||||||||||||||
|
Definition at line 435 of file GString.cc. 00436 {
00437 const char* s = chars();
00438 if (tl < 0) tl = slen(t);
00439 if (sl > 0 && tl > 0)
00440 {
00441 if (start >= 0)
00442 {
00443 const char* lasts = &(s[sl - tl]);
00444 const char* lastt = &(t[tl]);
00445 const char* p = &(s[start]);
00446
00447 while (p <= lasts)
00448 {
00449 const char* x = p++;
00450 const char* y = t;
00451 while (*x++ == *y++) if (y >= lastt) return --p - s;
00452 }
00453 }
00454 else
00455 {
00456 const char* firsts = &(s[tl - 1]);
00457 const char* lastt = &(t[tl - 1]);
00458 const char* p = &(s[sl + start + 1]);
00459
00460 while (--p >= firsts)
00461 {
00462 const char* x = p;
00463 const char* y = lastt;
00464 while (*x-- == *y--) if (y < t) return ++x - s;
00465 }
00466 }
00467 }
00468 return -1;
00469 }
|
|
||||||||||||
|
Definition at line 830 of file GString.cc. |
|
||||||||||||
|
Definition at line 838 of file GString.cc. 00839 {
00840 int last = search(startpos, length(), c);
00841 if (last >= 0) last += 1;
00842 return _substr(0, last);
00843 }
|
|
||||||||||||
|
Definition at line 845 of file GString.cc. |
|
||||||||||||
|
Definition at line 823 of file GString.cc. |
|
||||||||||||
|
Definition at line 816 of file GString.cc. |
|
|
Definition at line 737 of file GString.cc. 00738 {
00739 return _substr(0, pos+1);
00740 }
|
|
|
Definition at line 935 of file GString.h. 00936 {
00937 rep = Supcase(rep, rep);
00938 }
|
|
|
|
|
|
Definition at line 897 of file GString.h. 00898 {
00899 String r; r.rep = Scapitalize(x.rep, r.rep); return r;
00900 }
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
|
|
||||||||||||||||
|
Definition at line 1158 of file GString.cc. 01159 {
01160 String r;
01161 const char* xchars = x.chars();
01162 const char* ychars = y.chars();
01163 const char* xs = &(xchars[startpos]);
01164 const char* ss = xs;
01165 const char* topx = &(xchars[x.length()]);
01166 const char* ys = &(ychars[startpos]);
01167 const char* topy = &(ychars[y.length()]);
01168 int l;
01169 for (l = 0; xs < topx && ys < topy && *xs++ == *ys++; ++l);
01170 r.rep = Salloc(r.rep, ss, l, l);
01171 return r;
01172 }
|
|
||||||||||||||||
|
Definition at line 1174 of file GString.cc. 01175 {
01176 String r;
01177 const char* xchars = x.chars();
01178 const char* ychars = y.chars();
01179 const char* xs = &(xchars[x.length() + startpos]);
01180 const char* botx = xchars;
01181 const char* ys = &(ychars[y.length() + startpos]);
01182 const char* boty = ychars;
01183 int l;
01184 for (l = 0; xs >= botx && ys >= boty && *xs == *ys ; --xs, --ys, ++l);
01185 r.rep = Salloc(r.rep, ++xs, l, l);
01186 return r;
01187 }
|
|
|
|
|
||||||||||||||||
|
Definition at line 979 of file GString.cc. 00980 {
00981 RETURN_OBJECT(String,x)
00982 String sep = separator;
00983 int xlen = 0;
00984 int i;
00985 for (i = 0; i < n; ++i)
00986 xlen += src[i].length();
00987 xlen += (n - 1) * sep.length();
00988
00989 x.rep = Sresize (x.rep, xlen);
00990
00991 int j = 0;
00992
00993 for (i = 0; i < n - 1; ++i)
00994 {
00995 ncopy(src[i].chars(), &(x.rep->s[j]), src[i].length());
00996 j += src[i].length();
00997 ncopy(sep.chars(), &(x.rep->s[j]), sep.length());
00998 j += sep.length();
00999 }
01000 ncopy0(src[i].chars(), &(x.rep->s[j]), src[i].length());
01001 RETURN(x);
01002 }
|
|
||||||||||||
|
Definition at line 1247 of file GString.cc. |
|
||||||||||||
|
|
|
||||||||||||
|
Definition at line 1193 of file GString.cc. 01194 {
01195 if (!s.ipfx(0) || (!(s.flags() & ios::skipws) && !ws(s)))
01196 {
01197 s.clear(ios::failbit|s.rdstate()); // Redundant if using GNU iostreams.
01198 return s;
01199 }
01200 int ch;
01201 int i = 0;
01202 x.rep = Sresize(x.rep, 20);
01203 register streambuf *sb = s.rdbuf();
01204 while ((ch = sb->sbumpc()) != EOF)
01205 {
01206 if (isspace(ch))
01207 break;
01208 if (i >= x.rep->sz - 1)
01209 x.rep = Sresize(x.rep, i+1);
01210 x.rep->s[i++] = ch;
01211 }
01212 x.rep->s[i] = 0;
01213 x.rep->len = i;
01214 int new_state = s.rdstate();
01215 if (i == 0) new_state |= ios::failbit;
01216 if (ch == EOF) new_state |= ios::eofbit;
01217 s.clear(new_state);
01218 return s;
01219 }
|
|
||||||||||||||||||||
|
Definition at line 1221 of file GString.cc. 01222 {
01223 if (!s.ipfx(0))
01224 return 0;
01225 int ch;
01226 int i = 0;
01227 x.rep = Sresize(x.rep, 80);
01228 register streambuf *sb = s.rdbuf();
01229 while ((ch = sb->sbumpc()) != EOF)
01230 {
01231 if (ch != terminator || !discard)
01232 {
01233 if (i >= x.rep->sz - 1)
01234 x.rep = Sresize(x.rep, i+1);
01235 x.rep->s[i++] = ch;
01236 }
01237 if (ch == terminator)
01238 break;
01239 }
01240 x.rep->s[i] = 0;
01241 x.rep->len = i;
01242 if (ch == EOF) s.clear(ios::eofbit|s.rdstate());
01243 return i;
01244 }
|
|
||||||||||||
|
Definition at line 1143 of file GString.cc. |
|
||||||||||||
|
Definition at line 1133 of file GString.cc. |
|
|
|
|
||||||||||||||||||||
|
Definition at line 948 of file GString.cc. 00949 {
00950 String x = src;
00951 const char* s = x.chars();
00952 int sl = x.length();
00953 int i = 0;
00954 int pos = 0;
00955 int p, matchlen;
00956 while (i < n && pos < sl)
00957 {
00958 p = r.search(s, sl, matchlen, pos);
00959 if (p < 0)
00960 p = sl;
00961 results[i].rep = Salloc(results[i].rep, &(s[pos]), p - pos, p - pos);
00962 i++;
00963 pos = p + matchlen;
00964 }
00965 return i;
00966 }
|
|
||||||||||||||||||||
|
Definition at line 929 of file GString.cc. 00930 {
00931 String x = src;
00932 const char* s = x.chars();
00933 int sl = x.length();
00934 int i = 0;
00935 int pos = 0;
00936 while (i < n && pos < sl)
00937 {
00938 int p = x.search(pos, sl, sep.chars(), sep.length());
00939 if (p < 0)
00940 p = sl;
00941 results[i].rep = Salloc(results[i].rep, &(s[pos]), p - pos, p - pos);
00942 i++;
00943 pos = p + sep.length();
00944 }
00945 return i;
00946 }
|
|
|
|
|
|
|
1.2.11.1 written by Dimitri van Heesch,
© 1997-2001