Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C++ > class string

Reply
Thread Tools

class string

 
 
cmk128@hotmail.com
Guest
Posts: n/a
 
      08-27-2005
Hi
I am going to implement a new string class for my os, do you have
any idea to enhance of standard c++ string class?
If compare c++ string class with CS++ CString class and java String
class, what is your opinion?
thanks
from Peter ((E-Mail Removed))

 
Reply With Quote
 
 
 
 
Alipha
Guest
Posts: n/a
 
      08-27-2005

http://www.velocityreviews.com/forums/(E-Mail Removed) wrote:
> Hi
> I am going to implement a new string class for my os, do you have
> any idea to enhance of standard c++ string class?
> If compare c++ string class with CS++ CString class and java String
> class, what is your opinion?
> thanks
> from Peter ((E-Mail Removed))


we don't need yet another string class! Use the standard string class.
I'm tired of all the bullshit of having to convert among CString,
wxString, qtString, std::string, char*, etc. Just stick with
std::string. If you want to add functionality, put free-standing
functions in a header file and include that.

 
Reply With Quote
 
 
 
 
Alexei A. Frounze
Guest
Posts: n/a
 
      08-27-2005
"Alipha" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ups.com...
>
> (E-Mail Removed) wrote:
> > Hi
> > I am going to implement a new string class for my os, do you have
> > any idea to enhance of standard c++ string class?
> > If compare c++ string class with CS++ CString class and java String
> > class, what is your opinion?
> > thanks
> > from Peter ((E-Mail Removed))

>
> we don't need yet another string class! Use the standard string class.
> I'm tired of all the bullshit of having to convert among CString,
> wxString, qtString, std::string, char*, etc. Just stick with
> std::string. If you want to add functionality, put free-standing
> functions in a header file and include that.


Shouldn't Unicode text need special string handling functions? That'll be
another class.

Alex


 
Reply With Quote
 
Ivan Vecerina
Guest
Posts: n/a
 
      08-27-2005
<(E-Mail Removed)> wrote in message
news:(E-Mail Removed) oups.com...
> I am going to implement a new string class for my os, do you have
> any idea to enhance of standard c++ string class?
> If compare c++ string class with CS++ CString class and java String
> class, what is your opinion?
> thanks

Same advice as Alipha: best is to just use std::string
(assuming a complete C++ toolchain exists for "your os").
If you see a reason not to do so, please discuss it here.


Strings are an over-researched topic. The string class
defined by the C++ Standard only has two weaknesses IMO,
and they probably aren't what you would think:

1) std::string has too many member functions
There is no end to the number of functions/transforms one
may want to apply to std::string. The right way to deal
with the situation is to implement only essential operations
as member functions, and all the rest as 'free' functions.
Most C++ experts agree that too much has already been
included as members of std::string.
(yes, other string classes have done worse...)

2) there could be a place for a non-mutable string
If the characters of an std::string instance were not
modifiable (as is the case in Java), some optimizations
could be applied. Some library writers question whether
having only a non-mutable string, or both std::const_string
and std::string, would be better that the current situation.


hth -Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form


 
Reply With Quote
 
sap.liu
Guest
Posts: n/a
 
      08-27-2005
if you handle unicode text string, you should use class template of
basic_string<>, which can be adaptable for every special multi-bytes
string.

 
Reply With Quote
 
Ivan Vecerina
Guest
Posts: n/a
 
      08-27-2005
"Alexei A. Frounze" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Alipha" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed) ups.com...
>>
>> (E-Mail Removed) wrote:
>> > Hi
>> > I am going to implement a new string class for my os, do you have
>> > any idea to enhance of standard c++ string class?
>> > If compare c++ string class with CS++ CString class and java String
>> > class, what is your opinion?
>> > thanks
>> > from Peter ((E-Mail Removed))

>>
>> we don't need yet another string class! Use the standard string class.
>> I'm tired of all the bullshit of having to convert among CString,
>> wxString, qtString, std::string, char*, etc. Just stick with
>> std::string. If you want to add functionality, put free-standing
>> functions in a header file and include that.

>
> Shouldn't Unicode text need special string handling functions? That'll
> be
> another class.

Actually not:
- Unicode text encoded as UTF-8 can be used with std::string as is.
Your platform's default wide-character (unicode) encoding
is probably supported by std::wstring already.
Other unicode encodings would be implemented with an other
character and character trait parameter to std::basic_string
(on which the std::string typedef is based).
- Any Unicode-specific operations would best be implemented
as non-member functions.


Regards, Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form


 
Reply With Quote
 
Alexei A. Frounze
Guest
Posts: n/a
 
      08-27-2005
"Ivan Vecerina" <(E-Mail Removed)> wrote in message
news:dep35b$o3q$(E-Mail Removed)...
> "Alexei A. Frounze" <(E-Mail Removed)> wrote in message

....
> > Shouldn't Unicode text need special string handling functions?

That'll
> > be
> > another class.

> Actually not:
> - Unicode text encoded as UTF-8 can be used with std::string as is.
> Your platform's default wide-character (unicode) encoding
> is probably supported by std::wstring already.
> Other unicode encodings would be implemented with an other
> character and character trait parameter to std::basic_string
> (on which the std::string typedef is based).
> - Any Unicode-specific operations would best be implemented
> as non-member functions.


Usually, if there's any text processing other than just copying the entire
text or appending text, the functions must know the internal structure of
the text and Unicode is something very rich in this aspect (consider not
just the variable length of representation of a single code point but also
the combining marks and other things). So, is there any good and well-known
implementation of text/string handling for Unicode, compliant with the
standard?

Alex


 
Reply With Quote
 
j
Guest
Posts: n/a
 
      08-27-2005

"Alexei A. Frounze" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Ivan Vecerina" <(E-Mail Removed)> wrote in

message
> news:dep35b$o3q$(E-Mail Removed)...
> > "Alexei A. Frounze" <(E-Mail Removed)> wrote in message

> ...
> > > Shouldn't Unicode text need special string handling functions?

> That'll
> > > be
> > > another class.

> > Actually not:
> > - Unicode text encoded as UTF-8 can be used with std::string as is.
> > Your platform's default wide-character (unicode) encoding
> > is probably supported by std::wstring already.
> > Other unicode encodings would be implemented with an other
> > character and character trait parameter to std::basic_string
> > (on which the std::string typedef is based).
> > - Any Unicode-specific operations would best be implemented
> > as non-member functions.

>
> Usually, if there's any text processing other than just copying the entire
> text or appending text, the functions must know the internal structure of
> the text and Unicode is something very rich in this aspect (consider not
> just the variable length of representation of a single code point but also
> the combining marks and other things). So, is there any good and

well-known
> implementation of text/string handling for Unicode, compliant with the
> standard?
>
> Alex
>
>


wstring is for utf16 or utf32 afaik..
utf8 is not generally supported...


 
Reply With Quote
 
Ivan Vecerina
Guest
Posts: n/a
 
      08-27-2005
"Alexei A. Frounze" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "Ivan Vecerina" <(E-Mail Removed)> wrote in
> message
> news:dep35b$o3q$(E-Mail Removed)...
>> "Alexei A. Frounze" <(E-Mail Removed)> wrote in message

> ...
>> > Shouldn't Unicode text need special string handling functions?

> That'll
>> > be
>> > another class.

>> Actually not:
>> - Unicode text encoded as UTF-8 can be used with std::string as is.
>> Your platform's default wide-character (unicode) encoding
>> is probably supported by std::wstring already.
>> Other unicode encodings would be implemented with an other
>> character and character trait parameter to std::basic_string
>> (on which the std::string typedef is based).
>> - Any Unicode-specific operations would best be implemented
>> as non-member functions.

>
> Usually, if there's any text processing other than just copying the entire
> text or appending text, the functions must know the internal structure of
> the text and Unicode is something very rich in this aspect (consider not
> just the variable length of representation of a single code point but also
> the combining marks and other things). So, is there any good and
> well-known
> implementation of text/string handling for Unicode, compliant with the
> standard?

std::string does not have built-in support for all possible operations on
Unicode text, or for path-manipulation operations, or for loading inter-
nationalized text from resources, or whatever processing you have in mind.

But these operations can be implemented as non-member functions, and this
is the right way to support them.

Think of C++ containers and its library of standard algorithms, which
are independent and orthogonal. A much better, lean and efficient design,
than developing an ultra-container trying to do everything.


Cheers, Ivan
--
http://ivan.vecerina.com/contact/?subject=NG_POST <- email contact form
Brainbench MVP for C++ <> http://www.brainbench.com


 
Reply With Quote
 
Alexei A. Frounze
Guest
Posts: n/a
 
      08-27-2005
"j" <(E-Mail Removed)> wrote in message
news:43108432$0$7626$(E-Mail Removed). ..
....
> wstring is for utf16 or utf32 afaik..
> utf8 is not generally supported...


Most likely utf-16, easier than utf-8 and less space waste than utf-32.
But anyway, I presume there's not much (if any) support for what Unicode is.

Alex


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Class A contains class B, class B points to class A Joseph Turian C++ 5 12-30-2005 03:24 PM
Nested Class, Member Class, Inner Class, Local Class, Anonymous Class E11 Java 1 10-12-2005 03:34 PM
A parameterized class (i.e. template class / class template) is not a class? christopher diggins C++ 16 05-04-2005 12:26 AM
Generic class literals - e.g,, Class<Map<String, Integer>>.class Purush Java 4 04-13-2005 08:40 PM
Re: String.replaceAll(String regex, String replacement) question Mladen Adamovic Java 0 12-04-2003 04:40 PM



Advertisments