class string

Discussion in 'C++' started by cmk128@hotmail.com, Aug 27, 2005.

  1. Guest

    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 ()
     
    , Aug 27, 2005
    #1
    1. Advertising

  2. Alipha Guest

    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 ()


    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.
     
    Alipha, Aug 27, 2005
    #2
    1. Advertising

  3. "Alipha" <> wrote in message
    news:...
    >
    > 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 ()

    >
    > 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
     
    Alexei A. Frounze, Aug 27, 2005
    #3
  4. <> wrote in message
    news:...
    > 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
     
    Ivan Vecerina, Aug 27, 2005
    #4
  5. sap.liu Guest

    if you handle unicode text string, you should use class template of
    basic_string<>, which can be adaptable for every special multi-bytes
    string.
     
    sap.liu, Aug 27, 2005
    #5
  6. "Alexei A. Frounze" <> wrote in message
    news:...
    > "Alipha" <> wrote in message
    > news:...
    >>
    >> 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 ()

    >>
    >> 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
     
    Ivan Vecerina, Aug 27, 2005
    #6
  7. "Ivan Vecerina" <> wrote in message
    news:dep35b$o3q$...
    > "Alexei A. Frounze" <> 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
     
    Alexei A. Frounze, Aug 27, 2005
    #7
  8. j Guest

    "Alexei A. Frounze" <> wrote in message
    news:...
    > "Ivan Vecerina" <> wrote in

    message
    > news:dep35b$o3q$...
    > > "Alexei A. Frounze" <> 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...
     
    j, Aug 27, 2005
    #8
  9. "Alexei A. Frounze" <> wrote in message
    news:...
    > "Ivan Vecerina" <> wrote in
    > message
    > news:dep35b$o3q$...
    >> "Alexei A. Frounze" <> 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
     
    Ivan Vecerina, Aug 27, 2005
    #9
  10. "j" <> wrote in message
    news:43108432$0$7626$...
    ....
    > 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
     
    Alexei A. Frounze, Aug 27, 2005
    #10
  11. "Ivan Vecerina" <> 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
     
    Alexei A. Frounze, Aug 27, 2005
    #11
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Mladen Adamovic
    Replies:
    0
    Views:
    741
    Mladen Adamovic
    Dec 4, 2003
  2. Purush
    Replies:
    4
    Views:
    1,664
    Purush Rudrakshala
    Apr 13, 2005
  3. E11
    Replies:
    1
    Views:
    4,788
    Thomas Weidenfeller
    Oct 12, 2005
  4. christopher diggins
    Replies:
    16
    Views:
    756
    Pete Becker
    May 4, 2005
  5. Joseph Turian
    Replies:
    5
    Views:
    597
Loading...

Share This Page