www.digitalmars.com         C & C++   DMDScript  

D - String class

reply Ant <Ant_member pathlink.com> writes:
I believe once I saw a String class submited on
this group to be added to phobos
(seems that it never made it - I think it was from Burton Radons).

(A standard String class should be available)

Any one has that String class (or another that can be shared)
or remember how to get it?

Thanks

Ant
Nov 01 2003
next sibling parent reply Ant <Ant_member pathlink.com> writes:
In article <bo0s52$cqn$1 digitaldaemon.com>, Ant says...
I believe once I saw a String class submited on
this group to be added to phobos
(seems that it never made it - I think it was from Burton Radons).

(A standard String class should be available)
Probably what I saw was http://www.digitalmars.com/drn-bin/wwwnews?D/6204 (seems nothing from there got into phobos) anybody has a String class to share with us? Ant
Nov 01 2003
next sibling parent reply "Sean L. Palmer" <palmer.sean verizon.net> writes:
I think it would be super great if char[] were powerful enough that we don't
need any string class.

Most of the basics of C strings, such as strcpy, strcat, strlen, are already
handled by char[] and slices of char[], and array concatenation ~.  Many
other basic string functions are actually useful on other kinds of arrays as
well.  Array search, array comparison.  So there's no need to make such
functions specific to char[] only.

There are plenty of issues regarding Unicode encoding that just don't fit
well with char[].  case-sensitive or locale-specific comparisons, "indexing"
of UTF-8 encoded strings, etc.  And we do need some place to hang functions
that work on strings, something that hopefully will eliminate the need for
"str" prefixes on the function names.

Sean

"Ant" <Ant_member pathlink.com> wrote in message
news:bo0tas$ej4$1 digitaldaemon.com...
 In article <bo0s52$cqn$1 digitaldaemon.com>, Ant says...
I believe once I saw a String class submited on
this group to be added to phobos
(seems that it never made it - I think it was from Burton Radons).

(A standard String class should be available)
Probably what I saw was http://www.digitalmars.com/drn-bin/wwwnews?D/6204 (seems nothing from there got into phobos) anybody has a String class to share with us? Ant
Nov 01 2003
parent Ant <Ant_member pathlink.com> writes:
In article <bo178s$s3p$1 digitaldaemon.com>, Sean L. Palmer says...
I think it would be super great if char[] were powerful enough that we don't
need any string class.
The main problem is that char[] is not an object.
There are plenty of issues regarding Unicode encoding that just don't fit
well with char[].  case-sensitive or locale-specific comparisons, "indexing"
of UTF-8 encoded strings, etc.  And we do need some place to hang functions
that work on strings,
How about a String class? ;) Ant
Nov 02 2003
prev sibling parent Ant <Ant_member pathlink.com> writes:
anybody has a String class to share with us?
I just looked at STL. (I used C++ on DOS, not even on windows 3.0) it seems that it contains a string thing so I guess we are all waiting for the big D lib, ok, let's wait. Ant
Nov 03 2003
prev sibling parent reply "Vathix" <vathix dprogramming.com> writes:
I made this a few weeks ago.




begin 666 stringclass.d


M="!T:&EN92!O=VX <FES:PT*+R\ 02!L;W0 ;V8 8V]D92!I<R!T86ME;B!F
M<F]M('1H92!O<FEG:6]N86P <W1R:6YG+F0 =W)I='1E;B!B>2!786QT97( 



M=F%T92!A;&EA<R!T;U-T<FEN9WH 7W1O4W1R:6YG>CL-" ES8VAA<BH =&]3

M('-C+FQE;F=T:#L-" D):68H(2IP*0T*"0D)<F5T=7)N('-C.PT*"0D-" D)

M"7)E<W5L=%LP("XN('-C+FQE;F=T:%T /2!S8SL-" D)<F5T=7)N(')E<W5L
M=#L-

M;G5L;"UT97)M:6YA=&5D('-T<FEN9PT*"7L-" D):68H(7-C>BD-" D)"7)E



M+W1O(&$ <W1R:6YG(&]F(&UE;6]R>0T*"7L-" D)<V-H87);=6EN="YS:7IE
M("H ,UT 8G5F9F5R.PT*"0EI;G0 ;F1I9VET<SL-" D)<V-H87( 8SL-" D)

M=2D-" D)>PT*"0D)8R ]("AU("4 ,3 I("L )S G.PT*"0D)=2 O/2 Q,#L-
M" D)"6YD:6=I=',K*SL-" D)"6)U9F9E<EMB=69F97(N;&5N9W1H("T ;F1I

M73L-" D)<F5S=6QT6UT /2!B=69F97);8G5F9F5R+FQE;F=T:" M(&YD:6=I


M<EM=(',Q+"!S8VAA<EM=(',R*0T*"7L-" D)=6EN="!L(#T <S$N;&5N9W1H
M.PT*"0EI;G0 <F5S=6QT.PT*"0D-" D):68H<S(N;&5N9W1H(#P ;"D-" D)

M*B!S8VAA<BYS:7IE*3L-" D):68H<F5S=6QT(#T


M<"!?:6-M<#L-" EI;G0 :6-M<"AS8VAA<EM=(',Q+"!S8VAA<EM=(',R*0T*




M" D)"0ES8VAA<B!C,B ](',R6VE=.PT*"0D)"0T*"0D)"6EF*&,Q(#X](&-A
M<W0H<V-H87(I)T$G("8F(&,Q(#P](&-A<W0H<V-H87(I)UHG*0T*"0D)"0EC
M,2 K/2 H:6YT*2=A)R M("AI;G0I)T$G.PT*"0D)"6EF*&,R(#X]("=!)R F


M=6QT*0T*"0D)"0EB<F5A:SL-" D)"7T-" D)?0T*"0EI9BAR97-U;'0 /3T 
M,"D-" D)"7)E<W5L=" ](&-A<W0H:6YT*7,Q+FQE;F=T:" M(&-A<W0H:6YT
M*7,R+FQE;F=T:#L-" D)<F5T=7)N(')E<W5L=#L-
M=F%T92!A;&EA<R!T;VQO=V5R(%]T;VQO=V5R.PT*"7-C:&%R6UT =&]L;W=E


M:#L
M*'-C:&%R*2=!)R \/2!C("8F(&, /#T

M97< <V-H87);<V,N;&5N9W1H73L-" D)"0D)<EM=(#T
M(#T
M8R K("AC87-T*'-C:&%R*2=A)R M(&-A<W0H<V-H87(I)T$G*3L-" D)"7T-

M=&]U<'!E<B!?=&]U<'!E<CL-" ES8VAA<EM=('1O=7!P97(H<V-H87);72!S

M960 /2 P.PT*"0EF;W( *&D /2 P.R!I(#P
M"7L-" D)"7-C:&%R(&, /2!S8UMI73L-" D)"6EF("AC87-T*'-C:&%R*2=A
M)R \/2!C("8F(&, /#T
M*"%C:&%N9V5D*0T*"0D)"7L-" D)"0D)<V-H87);72!R(#T ;F5W('-C:&%R

M"0D)"6-H86YG960 /2 Q.PT*"0D)"7T-" D)"0ES8UMI72 ](&, +2 H8V%S

M<F5T=7)N('-C.PT*"7T-" D-" D-" EP<FEV871E(&%L:6%S(&9I;F0 7V9I

M;G0 :3L-" D)9F]R*&D /2 P.R!I("$]('-C+FQE;F=T:#L :2LK*0T*"0E[








M8VAA<B!C(#T <W5B6S!=.PT*"0EI9BAS=6)L96YG=&  /3T ,2D-" D)"7)E



M" D)9F]R*&EN="!I(#T ,#L :2 \(&EM87 [(&DK*RD-" D)>PT*"0D)9F]R
M*#L :2 \(&EM87 [(&DK*RD-" D)"7L-" D)"0EI9BAS8UMI72 ]/2!C*0T*

M"69O=6YD7V-H. T*"0D):6YT(&H /2!I("L ,3L-" D)"6EF*'-U8ELQ("XN



M<B!C.PT*"0D-" D):68H<W5B+FQE;F=T:" ]/2 P*0T*"0D)<F5T=7)N('-C
M+FQE;F=T:#L-" D)8R ]('-U8ELP73L-" D)9F]R("AI;G0 :2 ]('-C+FQE
M;F=T:" M('-U8BYL96YG=& [(&D /CT ,#L



M" D-" D-" EP<FEV871E(&%L:6%S(&-O=6YT(%]C;W5N=#L-" EI;G0 8V]U


M(#P
M(#T
M("TQ*0T*"0D)"6)R96%K.PT*"0D)8V]U;G0K*SL-" D)?0T*"0ER971U<FX 

M;&%C93L-" ES8VAA<EM=(')E<&QA8V4H<V-H87);72!S8RP <V-H87);72!F
M<F]M+"!S8VAA<EM=('1O*0T*"7L-" D)<V-H87);72!P.PT*"0EI;G0 :3L-
M" D):6YT(&ES=&%R=#L-
M=&%R=" \('-C+FQE;F=T:"D-" D)>PT*"0D):2 ](&9I;F0H<V-;:7-T87)T
M("XN('-C+FQE;F=T:%TL(&9R;VTI.PT*"0D):68H:2 ]/2 M,2D-" D)"7L-
M" D)"0EP('X]('-C6VES=&%R=" N+B!S8RYL96YG=&A=.PT*"0D)"6)R96%K

M"0EP('X]('1O.PT*"0D):7-T87)T("L](&D *R!F<F]M+FQE;F=T:#L-" D)
M?0T*"0ER971U<FX <#L-
M86-E4VQI8V4 7W)E<&QA8V53;&EC93L-" ES8VAA<EM=(')E<&QA8V53;&EC
M92AS8VAA<EM=('-T<FEN9RP <V-H87);72!S;&EC92P <V-H87);72!R97!L
M86-E;65N="D-" EI; T*"7L-" D)+R\ 5F5R:69Y('1H870 <VQI8V5;72!R
M96%L;'D :7, 82!S;&EC92!O9B!S=')I;F=;70T*"0EI;G0 <V\ /2 H<V-H

M*3L-" D)87-S97)T*'-T<FEN9RYL96YG=&  /CT <V\ *R!S;&EC92YL96YG

M('-O(#T *'-C:&%R*BES;&EC92 M("AS8VAA<BHI<W1R:6YG.PT*"0D-" D)
M<F5S=6QT+FQE;F=T:" ]('-T<FEN9RYL96YG=&  +2!S;&EC92YL96YG=&  


M8V5M96YT+FQE;F=T:%T /2!R97!L86-E;65N=#L-" D)<F5S=6QT6W-O("L 
M<F5P;&%C96UE;G0N;&5N9W1H("XN(')E<W5L="YL96YG=&A=(#T <W1R:6YG
M6W-O("L <VQI8V4N;&5N9W1H("XN('-T<FEN9RYL96YG=&A=.PT*"0D-" D)
M<F5T=7)N(')E<W5L=#L-
M<G0 7VEN<V5R=#L-" ES8VAA<EM=(&EN<V5R="AS8VAA<EM=('-C+"!I;G0 


M"0EI9BAS=6(N;&5N9W1H(#T

M;F5W;&5N9W1H(#T <V,N;&5N9W1H("L <W5B+FQE;F=T:#L-" D)<V-H87);

M=%LP("XN(&EN9&5X72 ]('-C6S  +BX :6YD97A=.PT*"0ER97-U;'1;:6YD
M97  +BX :6YD97  *R!S=6(N;&5N9W1H72 ]('-U8CL-" D)<F5S=6QT6VEN
M9&5X("L <W5B+FQE;F=T:" N+B!N97=L96YG=&A=(#T <V-;:6YD97  +BX 
M<V,N;&5N9W1H73L-" D)<F5T=7)N(')E<W5L=#L-



M/2 P.PT*"0EF;W( *&D /2 P.R!I(#P
M" D)"7-W:71C:"AS8UMI72D-" D)"7L-" D)"0EC87-E("< )SH-" D)"0EC




M"0D)9&5F875L=#H-" D)"0D):68H(6EN=V]R9"D-" D)"0D)>PT*"0D)"0D)
M:7-T87)T(#T


M"7!R:79A=&4 86QI87, <VUE;6-H<B!?<VUE;6-H<CL-" ES8VAA<BH <VUE

M"7-C:&%R*B!E;F0 /2!S;65M("L ;&5N.PT*"0EW:&EL92AS;65M("$](&5N
M9"D-" D)>PT*"0D):68H*G-M96T /3T 8VAR*0T*"0D)"7)E='5R;B!S;65M

M" ES8VAA<EM=6UT <W!L:70H<V-H87);72!S8RP <V-H87);72!D96QI;2D-



M:68H9&5L:6TN;&5N9W1H(#T

M)G-C6S!=.PT*"0D)"7-C:&%R("IP96YD(#T <" K('-C+FQE;F=T:#L-" D)

M"0D)"7  /2!S;65M8VAR*' L(&,L('!E;F0 +2!P*3L-" D)"0D):68H(7 I







M"0D)?0T*"0D)"0EJ(#T <" M("9S8ULP73L-" D)"0D)=V]R9'-;=V]R9&E=
M(#T <V-;:2 N+B!J73L-" D)"0D)=V]R9&DK*SL-" D)"0D):2 ](&H *R Q
M.PT*"0D)"0EI9BAI(#T]('-C+FQE;F=T:"D-" D)"0D)>PT*"0D)"0D)=V]R
M9'-;=V]R9&E=(#T
M" D)"0EA<W-E<G0H=V]R9&D *R Q(#T




M.PT*"0D)"0EI9BAI(#T]('-C+FQE;F=T:"D-" D)"0D)>PT*"0D)"0D);G=O


M<SL-" D)"0D-" D)"0EI;G0 =V]R9&D /2 P.PT*"0D)"6D /2 P.PT*"0D)

M+FQE;F=T:%TL(&1E;&EM*3L-" D)"0D):68H:B ]/2 M,2D-" D)"0D)>PT*
M"0D)"0D)=V]R9'-;=V]R9&E=(#T <V-;:2 N+B!S8RYL96YG=&A=.PT*"0D)


M+FQE;F=T:#L-

M" D)"0D)87-S97)T*&D /"!S8RYL96YG=& I.PT*"0D)"7T-" D)"0EA<W-E
M<G0H=V]R9&D *R Q(#T
M('=O<F1S.PT*"7T-" D-" D-" EP<FEV871E(&%L:6%S('-P;&ET;&EN97, 



M"0EF;W( *&D /2 P.R!I(#P

M?"!C(#T
M(#T
M9W1H("8F('-C6VD *R Q72 ]/2 G7&XG*0T*"0D)"7L-" D)"0D):2LK.PT*


M6UU;;FQI;F5S73L-" D);FQI;F5S(#T ,#L-" D):7-T87)T(#T ,#L-" D)
M9F]R*&D /2 P.R!I(#P

M(#T
M=" N+B!I73L-" D)"0EN;&EN97,K*SL-" D)"0EI<W1A<G0 /2!I("L ,3L-
M" D)"0EI9BAC(#T

M="LK.PT*"0D)"7T-" D)"7T-" D)?0T*"0EI9BAI<W1A<G0 (3T :2D-" D)
M>PT*"0D);&EN97-;;FQI;F5S72 ]('-C6VES=&%R=" N+B!I73L-" D)"6YL


M;&EA<R!J;VEN(%]J;VEN.PT*"7-C:&%R6UT :F]I;BAS8VAA<EM=6UT =V]R





M9W1H.PT*"0D);&5N("L]("AW;W)D<RYL96YG=&  +2 Q*2 J('-E<&QE;CL-
M" D)"0T*"0D)<F5S=6QT(#T
M/2 P.PT*"0D)=VAI;&4H=')U92D-" D)"7L-" D)"0EU:6YT('=L96X /2!W

M96Y=(#T
M"0EI9BAI(#X




M:3L-" D)9F]R*&D /2 P.R!I(#P
M"6EF*"%I<W=H:71E*'-C6VE=*2D-" D)"0EB<F5A:SL-" D)?0T*"0ER971U
M<FX <V-;:2 N+B!S8RYL96YG=&A=.PT*"7T-" D-" EP<FEV871E(&%L:6%S
M('-T<FEP<B!?<W1R:7!R.PT*"7-C:&%R6UT <W1R:7!R*'-C:&%R6UT <V,I



M871E(&%L:6%S('-T<FEP(%]S=')I<#L-" ES8VAA<EM=('-T<FEP*'-C:&%R

M" D-" D-" EP<FEV871E(&%L:6%S(&5X<&%N9'1A8G, 7V5X<&%N9'1A8G,[

M*0T*"7L-" D)<V-H87);72!R.PT*"0EI;G0 :3L-" D):6YT(&ES=&%R=#L-
M" D):6YT(&-O;#L-" D)+R]S=&%T:6, <V-H87);.%T <W!A8V5S(#T (B  
M("  ("  (CL +R]E<G)O<CH 8V%N;F]T(&EM<&QI8VET;'D 8V]N=F5R="!C



M/2!S8UMI73L-" D)"6EF*&, /3T )UQT)RD-" D)"7L ( T*"0D)"6EN="!T
M86)S=&]P.PT*"0D)"0T*"0D)"7( ?CT <V-;:7-T87)T("XN(&E=.PT*"0D)
M"6ES=&%R=" ](&D *R Q.PT*"0D)"0T*"0D)"71A8G-T;W  /2!C;VP *R!T

M"0D)=VAI;&4H8V]L(#P
M=&%B<W1O<" M(&-O;#L-" D)"0D):68 *&X /B!S<&%C97,N;&5N9W1H*0T*
M"0D)"0EN(#T <W!A8V5S+FQE;F=T:#L-" D)"0D)<B!^/2!S<&%C97-;," N








M" D-" D-" EP<FEV871E(&%L:6%S(')J=7-T:69Y(%]R:G5S=&EF>3L-" ES

M"6EF*'-C+FQE;F=T:" ^/2!W:61T:"D-" D)"7)E='5R;B!S8SL-" D)<V-H
M87);72!R(#T ;F5W('-C:&%R6W=I9'1H73L-" D)<ELP("XN('=I9'1H("T 

M=&  +BX =VED=&A=(#T
M871E(&%L:6%S(&-E;G1E<B!?8V5N=&5R.PT*"7-C:&%R6UT 8V5N=&5R*'-C

M:61T:"D-" D)"7)E='5R;B!S8SL-" D)<V-H87);72!R(#T ;F5W('-C:&%R
M6W=I9'1H73L-" D):6YT(&QE9G0 /2 H=VED=&  +2!S8RYL96YG=& I("\ 
M,CL-" D)<ELP("XN(&QE9G1=(#T *'-C:&%R*2< )SL-" D)<EML969T("XN
M(&QE9G0 *R!S8RYL96YG=&A=(#T





M/2 H<V-H87(I)S G.PT*"0ER6W=I9'1H("T <V,N;&5N9W1H("XN('=I9'1H

M<R!C87!I=&%L:7IE(%]C87!I=&%L:7IE.PT*"7-C:&%R6UT 8V%P:71A;&EZ

M8VAA<B!C(#T
M" D)"7L-" D)"0ES8VAA<EM=('( /2!N97< <V-H87);<V,N;&5N9W1H73L-

M*&-A<W0H<V-H87(I)V$G("T )T$G*3L-" D)"7T-" D)?0T*"0ER971U<FX 


M:&%R6UT <CL-" D):6YT(&EN=V]R9#L-

M*&D /2 P.R!I(#P

M"0D)8V%S92 G7&8G. T*"0D)"6-A<V4 )UQR)SH-" D)"0EC87-E("=<;B<Z

M"0D)"7( ?CT <V-;:7-T87)T("XN(&E=.PT*"0D)"0D):6YW;W)D(#T ,#L-
M" D)"0D)?0T*"0D)"0EB<F5A:SL-" D)"0D-" D)"0ED969A=6QT. T*"0D)





M92!W;W)D<PT*"0EI;G=O<F0 /2 P.PT*"0EF;W( *&D /2 P.R!I(#P <BYL

M"6EF*&, /CT )T$G("8F(&, /#T )UHG*0T*"0D)>PT*"0D)"6EN=V]R9" ]

M"0D)>PT*"0D)"6EF*&EN=V]R9" ]/2 P*0T*"0D)"7L-" D)"0D)8R M/2 H
M<V-H87(I)V$G("T )T$G.PT*"0D)"0ER6VE=(#T
M:6YW;W)D(#T


M>PT*"0ER971U<FX <W1R8W)C,S(H8V%S="AC:&%R6UTI<V,I.PT*"7T-" D-





M871A.PT*"0D);&5N(#T
M=')I;F< 9'5P*"D +R]G971T97(-" D)>PT*"0D)<F5T=7)N(&YE=R!3=')I


M"0T*"0EV;VED(&QE;F=T:"AU:6YT(&YE=TQE;BD +R]S971T97(-" D)>PT*
M"0D):68H;F5W3&5N(#X

M96QS90T*"0D)>PT*"0D)"6QE;B ](&YE=TQE;CL-" D)"7T-" D)?0T*"0D-

M;B!D871A+FQE;F=T:#L-
M:6YT(&QE;F=T:"D +R]S971T97(-" D)>PT*"0D):68H;&5N9W1H(#X](&QE
M;BD-" D)"0ED871A+FQE;F=T:" ](&QE;F=T:#L-
M"2\O<V5T<R!T:&4 9&%T80T*"0DO+VUA:V4 <W5R92!T:&4 ;F5W(&1A=&$ 

M<W1R=6-T(&$ ;F5W(&]B:F5C= T*"0DO+W1H:7, :7, =&\ 8V]N=&EN=64 
M=7-I;F< =&AE('-A;64 ;65M;W)Y(&%N9"!S86UE(')E<V5R=F4 *&EF('!O

M"6EF*'-C+FQE;F=T:" \/2!D871A+FQE;F=T:"D-" D)"7L-" D)"0ED871A
M6S  +BX <V,N;&5N9W1H72 ]('-C.PT*"0D)"6QE;B ]('-C+FQE;F=T:#L-
M" D)"7T-" D)"65L<V4-" D)"7L-" D)"0ED871A(#T <V,N9'5P.PT*"0D)
M"6QE;B ]('-C+FQE;F=T:#L-" D)"7T-" D)"7)E='5R;B!T:&ES.PT*"0E]


M:61E('5I;G0 =&](87-H*"D-" D)>PT*"0D)<F5T=7)N(%]T;TAA<V H;W!3



M+G-I>F4 /3T =V-H87(N<VEZ92D-" D)"0EW<')I;G1F*"(E+BIS7&XB+"!O
M<%-L:6-E*"DI.PT*"0D)96QS90T*"0D)"7!R:6YT9B B4W1R:6YG("5P7&XB

M<FEN9R I("\O=&\ 82!S=')I;F< ;V8 ;65M;W)Y+"!N;W0 4W1R:6YG(&-L
M87-S(#HI

M87);72!R97-U;'0 /2!N97< 8VAA<EML96Y=.PT*"0D)=6EN="!I.PT*"0D)
M9F]R*&D /2 P.R!I("$](&QE;CL :2LK*0T*"0D)>PT*"0D)"6EF*&1A=&%;
M:5T /B!C:&%R+FUA>"D-" D)"0D)<F5S=6QT6VE=(#T )S\G.R O+VUI9VAT
M(&YO="!B92!T:&ES(&-H87)A8W1E< T*"0D)"65L<V4-" D)"0D)<F5S=6QT
M6VE=(#T

M+R]M;W)E(&5F9FEC:65N="!U<V5D('=I=&  =&AI<R!3=')I;F< 8VQA<W, 



M9&%T85ML96Y=(#T ,#L-" D)"7T-" D)"65L<V4-" D)"7L-" D)"0DO+VEF
M*&1A=&%;;&5N72D +R]A(&AA<FUL97-S(&%S<VEG;FUE;G0 :7, ;6]R92!E

M(#T ,#L-
M"0T*"0D-" D)<V-H87);72!O<%-L:6-E*"D-" D)>PT*"0D)<F5T=7)N(&1A


M+BX >5T[("\O<V\ :6YD97AI;F< =&AE(')E<V5R=F4 :7, ;W5T(&]F(&)O

M"7L-" D)"7)E='5R;B!O<%-L:6-E*"E;:5T[("\O<V\ :6YD97AI;F< =&AE



M72!S8RD-" D)>PT*"0D):68H9&%T82YL96YG=&  /"!S8RYL96YG=&  *R!L

M871A6VQE;B N+B!L96X *R!S8RYL96YG=&A=(#T





M>PT*"0D)<F5T=7)N(&YE=R!3=')I;F<H;W!3;&EC92 I('X <W1R6UTI.PT*




M8VAA<B!C:"D-" D)>PT*"0D)<F5T=7)N(&YE=R!3=')I;F<H;W!3;&EC92 I

M7W(H4W1R:6YG('-T<BD-" D)>PT*"0D)<F5T=7)N(&YE=R!3=')I;F<H<W1R



M<B!C:"D-" D)>PT*"0D)<F5T=7)N(&YE=R!3=')I;F<H*"9C:"E;," N+B Q








M:61E(&EN="!C;7 H3V)J96-T('-T<BD-" D)>PT*"0D)87-S97)T*&-A<W0H









M8VAA<EM=('-C(#T 7W1O;&]W97(H;W!3;&EC92 I*3L-" D)"7)E='5R;B H
M)G-C6S!=(#T]("9D871A6S!=*2 _('1H:7, .B!N97< 4W1R:6YG*'-C*3L-


M(#T 7W1O=7!P97(H;W!3;&EC92 I*3L-" D)"7)E='5R;B H)G-C6S!=(#T]
M("9D871A6S!=*2 _('1H:7, .B!N97< 4W1R:6YG*'-C*3L-" D)?0T*"0D-




M>PT*"0D)<F5T=7)N(%]F:6YD*&]P4VQI8V4H*2P <W5B*3L-" D)?0T*"0D-


M('-U8BD-" D)>PT*"0D)<F5T=7)N(%]R9FEN9"AO<%-L:6-E*"DL('-U8BD[


M;W5N="AS8VAA<EM=('-U8BD-" D)>PT*"0D)<F5T=7)N(%]C;W5N="AO<%-L

M('-U8BD-" D)>PT*"0D)<F5T=7)N(&-O=6YT*'-U8EM=*3L-" D)?0T*"0D-

M;RD-" D)>PT*"0D)<F5T=7)N(&YE=R!3=')I;F<H7W)E<&QA8V4H;W!3;&EC

M8V4H4W1R:6YG(&9R;VTL(%-T<FEN9R!T;RD-" D)>PT*"0D)<F5T=7)N(')E

M97!L86-E4VQI8V4H<V-H87);72!S;&EC92P <V-H87);72!R97!L86-E;65N
M="D-" D)>PT*"0D)<F5T=7)N(&YE=R!3=')I;F<H7W)E<&QA8V53;&EC92AO

M" D)4W1R:6YG(')E<&QA8V53;&EC92AS8VAA<EM=('-L:6-E+"!3=')I;F< 



M;F5W(%-T<FEN9RA?:6YS97)T*&]P4VQI8V4H*2P :6YD97 L('-U8BDI.PT*




M<FEN9UM=(')E<W5L=#L-

M="!I.PT*"0D)9F]R*&D /2 P.R!I("$](')E<W5L="YL96YG=& [(&DK*RD-








M72!S<&QI=&QI;F5S*"D-" D)>PT*"0D)<F5T=7)N(&-O;G9E<G0H7W-P;&ET

M:7!L*"D-" D)>PT*"0D)<V-H87);72!S8R ](%]S=')I<&PH;W!3;&EC92 I
M*3L-" D)"7)E='5R;B H<V,N;&5N9W1H(#T](&QE;BD /R!T:&ES(#H ;F5W

M" D)>PT*"0D)<V-H87);72!S8R ](%]S=')I<'(H;W!3;&EC92 I*3L-" D)
M"7)E='5R;B H<V,N;&5N9W1H(#T](&QE;BD /R!T:&ES(#H ;F5W(%-T<FEN

M"0ES8VAA<EM=('-C(#T




M:69Y*&EN="!W:61T:"D-" D)>PT*"0D)<V-H87);72!S8R ](%]L:G5S=&EF
M>2AO<%-L:6-E*"DL('=I9'1H*3L-" D)"7)E='5R;B H<V,N;&5N9W1H(#T]
M(&QE;BD /R!T:&ES(#H

M('-C(#T 7W)J=7-T:69Y*&]P4VQI8V4H*2P =VED=& I.PT*"0D)<F5T=7)N
M("AS8RYL96YG=&  /3T ;&5N*2 _('1H:7, .B!N97< 4W1R:6YG*'-C*3L-


M" D)"7)E='5R;B H<V,N;&5N9W1H(#T](&QE;BD /R!T:&ES(#H ;F5W(%-T


M=VED=& I.PT*"0D)<F5T=7)N("AS8RYL96YG=&  /3T ;&5N*2 _('1H:7, 

M=&%L:7IE*"D-" D)>PT*"0D)<V-H87);72!S8R ](%]C87!I=&%L:7IE*&]P

M:&ES(#H


M(&IO:6XH<V-H87);75M=('=O<F1S+"!S8VAA<EM=('-E<"D-" D)>PT*"0D)

M"0T*"0D-" D)<W1A=&EC(%-T<FEN9R!J;VEN*%-T<FEN9UM=('=O<F1S+"!3

M="!I="!I<R!B971T97( =&AA;B!D=7!L:6-A=&EN9R!J;VEN)W, 8V]D93\-
M" D)"7-C:&%R6UU;72!S8W, /2!N97< <V-H87);75MW;W)D<RYL96YG=&A=
M.PT*"0D)=6EN="!I.PT*"0D)9F]R*&D /2 P.R!I("$]('=O<F1S+FQE;F=T
M:#L


M;G-T86YC93L-"FEN<W1A;F-E(%-T<FEN9W,H=V-H87(I(%=3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*'=S='(N9FEN9" B5U-T<FEN9R(I("$]("TQ*3L-" D-" EA<W-E<G0H=W-T
M<BYR9FEN9" G="<I("$]("TQ*3L-" EA<W-E<G0H=W-T<BYR9FEN9" G5R<I
M("$]("TQ*3L-" EA<W-E<G0H=W-T<BYR9FEN9" G6B<I(#T]("TQ*3L-" EA
M<W-E<G0H=W-T<BYR9FEN9" B:7, :7, 82(I(#T
M<W1R+G)F:6YD*")T97-T8F%D(BD /3T +3$I.PT*"6%S<V5R="AW<W1R+G)F



M" ES='(H(E1H:7, :7, 82!F;V\ 9F]O(&QI<W0B*3L-" EA<W-E<G0H<W1R

M(")S:6QL>2(I.PT*"6%S<V5R="AS='( /3T (E1H:7, :7, 82!S:6QL>2!S


M8V4L(")B87(B*3L-" EA<W-E<G0H<W1R(#T](")H96)A<F\B*3L-" D-" EA
M<W-E<G0H=W-T<B B86)C9"(I+FEN<V5R=" P+" B92(I(#T](")E86)C9"(I

M;F<H*2 ]/2!C87-T*&-H87);72DB=&]3=')I;F<B*3L-" D-" ES='(H(B!P
M971E<B!P875L7'1J97)R>2 B*3L-" E3=')I;F=;72!S=')S.PT*"7-T<G, 


M/3T (G!A=6PB*3L-" EA<W-E<G0H<W1R<ULR72 ]/2 B:F5R<GDB*3L-" D-
M" E$4W1R:6YG(&1S='( /2!N97< 1%-T<FEN9R B+'!E=&5R+'!A=6PL:F5R


M(#T
M97)T*&1S=')S6S)=(#T

M*")<<G!E=&5R7&Y<<G!A=6Q<<EQN:F5R<GE<;B(I.PT*"7-T<G, /2!S='(N
M<W!L:71L:6YE<R I.PT*"6%S<V5R="AS=')S+FQE;F=T:" ]/2 U*3L-" EA


M"6%S<V5R="AS=')S6S-=(#T

M:7 H*2 ]/3T <W1R*3L-" ES='(H(B!<=%QR(&AI7&XB*3L-" EA<W-E<G0H

M82!F;V9O9EQT;V8 ;&ES="(I.PT*"6%S<V5R="AD<W1R+F5X<&%N9'1A8G,H
M."D /3T (E1H:7, ("  :7, ("  ("  82!F;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T<FEN9TEN<W1A;F-E
M+G)F:6YD(')F:6YD.PT*86QI87, 4W1R:6YG26YS=&%N8V4N=&]L;W=E<B!T
M;VQO=V5R.PT*86QI87, 4W1R:6YG26YS=&%N8V4N=&]U<'!E<B!T;W5P<&5R
M.PT*86QI87, 4W1R:6YG26YS=&%N8V4N8V%P:71A;&EZ92!C87!I=&%L:7IE


M;G-T86YC92YS<&QI="!S<&QI=#L-"F%L:6%S(%-T<FEN9TEN<W1A;F-E+G-P
M;&ET;&EN97, <W!L:71L:6YE<SL-"F%L:6%S(%-T<FEN9TEN<W1A;F-E+G-T

M:7!R.PT*86QI87, 4W1R:6YG26YS=&%N8V4N8V5N=&5R(&-E;G1E<CL-"F%L
M:6%S(%-T<FEN9TEN<W1A;F-E+GIF:6QL('IF:6QL.PT*86QI87, 4W1R:6YG
M26YS=&%N8V4N<F5P;&%C92!R97!L86-E.PT*86QI87, 4W1R:6YG26YS=&%N
M8V4N<F5P;&%C95-L:6-E(')E<&QA8V53;&EC93L-"F%L:6%S(%-T<FEN9TEN

M;W5N="!C;W5N=#L-"F%L:6%S(%-T<FEN9TEN<W1A;F-E+F5X<&%N9'1A8G, 
M97AP86YD=&%B<SL-"F%L:6%S(%-T<FEN9TEN<W1A;F-E+G1O4W1R:6YG('1O
M4W1R:6YG.PT*86QI87, 4W1R:6YG26YS=&%N8V4N=&]3=')I;F=Z('1O4W1R

`
end
Nov 03 2003
next sibling parent Ant <Ant_member pathlink.com> writes:
In article <bo6a9k$1vag$1 digitaldaemon.com>, Vathix says...
I made this a few weeks ago.
Looks great! thank you. Ant
Nov 03 2003
prev sibling parent reply "Ben Hinkle" <bhinkle4 juno.com> writes:
Looks interesting. If I started using this in my own code what advantages
would it have over using string.d and schar[] where schar is char, wchar or
dchar? I haven't been following the pros and cons of String vs char[] aside
from the UTF-n indexing problem.
thanks,
-Ben


"Vathix" <vathix dprogramming.com> wrote in message
news:bo6a9k$1vag$1 digitaldaemon.com...
 I made this a few weeks ago.
Nov 03 2003
parent "Vathix" <vathix dprogramming.com> writes:
The String class has a few advantages like the reserve member to reserve so
many bytes to avoid reallocations. You can append another String, char[],
char or even int to it. The silce operator (with or without parameters)
returns a char[] so it can be easily used with other char[] string
functions. The toStringz member adds the null byte to the reserve so calling
it several times won't hurt any.
There are a few bad things, like the functions that return several new
String objects such as split(), but I don't really think it's any worse than
other languages' String classes.
I wrote this code just for something to do, since people have been wanting a
String and it didn't look like anyone was actually making it. I still like
char[], I think slices are really cool.


"Ben Hinkle" <bhinkle4 juno.com> wrote in message
news:bo6osb$2kf3$1 digitaldaemon.com...
 Looks interesting. If I started using this in my own code what advantages
 would it have over using string.d and schar[] where schar is char, wchar
or
 dchar? I haven't been following the pros and cons of String vs char[]
aside
 from the UTF-n indexing problem.
 thanks,
 -Ben


 "Vathix" <vathix dprogramming.com> wrote in message
 news:bo6a9k$1vag$1 digitaldaemon.com...
 I made this a few weeks ago.
Nov 03 2003