473,403 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

class string

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 (cm****@hotmail.com)

Aug 27 '05 #1
10 2076

cm****@hotmail.com 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 (cm****@hotmail.com)


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.

Aug 27 '05 #2
"Alipha" <al*****@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...

cm****@hotmail.com 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 (cm****@hotmail.com)


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
Aug 27 '05 #3
<cm****@hotmail.com> wrote in message
news:11**********************@o13g2000cwo.googlegr 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
Aug 27 '05 #4
if you handle unicode text string, you should use class template of
basic_string<>, which can be adaptable for every special multi-bytes
string.

Aug 27 '05 #5
"Alexei A. Frounze" <al*****@chat.ru> wrote in message
news:3n***********@individual.net...
"Alipha" <al*****@hotmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...

cm****@hotmail.com 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 (cm****@hotmail.com)


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
Aug 27 '05 #6
"Ivan Vecerina" <IN*************************@vecerina.com> wrote in message
news:de**********@news.hispeed.ch...
"Alexei A. Frounze" <al*****@chat.ru> 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
Aug 27 '05 #7
j

"Alexei A. Frounze" <al*****@chat.ru> wrote in message
news:3n***********@individual.net...
"Ivan Vecerina" <IN*************************@vecerina.com> wrote in message news:de**********@news.hispeed.ch...
"Alexei A. Frounze" <al*****@chat.ru> 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...
Aug 27 '05 #8
"Alexei A. Frounze" <al*****@chat.ru> wrote in message
news:3n***********@individual.net...
"Ivan Vecerina" <IN*************************@vecerina.com> wrote in
message
news:de**********@news.hispeed.ch...
"Alexei A. Frounze" <al*****@chat.ru> 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
Aug 27 '05 #9
"j" <je****************@stofanet.dk> wrote in message
news:43**********************@nntp02.dk.telia.net. ..
....
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
Aug 27 '05 #10
"Ivan Vecerina" <IN*************************@vecerina.com> wrote in message
....
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.


That was the sad point. It still needs to be implemented since apart reading
and writing code points everything else is quite a big task.

Alex
Aug 27 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Oplec | last post by:
Hi, I'm learning C++ as a hobby using The C++ Programming Language : Special Edition by Bjarne Stroustrup. I'm working on chpater 13 exercises that deal with templates. Exercise 13.9 asks for me...
3
by: Vincent Cantin | last post by:
I have a class defined by a template which needs to "say" its type to the user via string. As an example, here is the class that I want to fix : template<class T> class Container : public...
27
by: djake | last post by:
In the stroustrup C++ programming language (third edition) i can find example like this: string s1= "Hello"; So I imagine string is a standard class. Furthermore the class in the example is...
5
by: Tappy Tibbons | last post by:
I have a class I am serializing, and need the resultant XML to skip/omit classes that are not initialized, or their member variables have not been set. Is this possible? Say for the following...
0
by: keith bannister via .NET 247 | last post by:
(Type your message here) -------------------------------- From: keith bannister Hi, I'm new to .net (as of last week) but here goes. I want to serialize/deserialize a file the conforms...
5
by: Keith Bannister | last post by:
I'm new to .net so here goes. I'm tying to deserialize a class that is associated with an XML schema. I created the C# class with xsd.exe as below: xsd.exe /c /n:somenamespace...
10
by: Not Available | last post by:
On the host server: namespace JCart.Common public class JCartConfiguration : IConfigurationSectionHandler private static String dbConnectionString; public static String ConnectionString { get...
16
by: tshad | last post by:
This is a little complicated to explain but I have some web services on a machine that work great. The problem is that I have run into a situation where I need to set up my program to access one...
20
by: tshad | last post by:
Using VS 2003, I am trying to take a class that I created to create new variable types to handle nulls and track changes to standard variable types. This is for use with database variables. This...
5
by: alan | last post by:
Hello world, I'm wondering if it's possible to implement some sort of class/object that can perform mapping from class types to strings? I will know the class type at compile time, like so:...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.