Re: C++ Standard Library

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Joseph M. Newcomer (newcomer_at_flounder.com)
Date: 04/11/04


Date: Sat, 10 Apr 2004 23:49:12 -0400

Surprisingly, not only does my customer base not want STL, they don't usually want
istreams or ostreams. They see no advantage to these. While I don't entirely agree with
this view, it is the set of rules I typically have to live with.

Check out my essay on CStrings on my MVP Tips site. If you'd like to contribute to that,
I'll put a section in on std::string under your byline. You can show examples of using
8-bit and 16-bit characters under std::string, and how to move them in and out of CString.
This would put a lot of string knowledge in one place.
                                joe

On Sat, 10 Apr 2004 16:34:48 +0100, Daniel James <wastebasket@nospam.aaisp.org> wrote:

>In article news:<qhaf7097nt7fdfvsqtmb158l9p6f3pl3t9@4ax.com>, Joseph M.
>Newcomer wrote:
>> The last time I looked at STL ...
>
>We're not really talking about "STL", which was a novel and innovative
>3rd-party library from a guy named Stepanov at HP, mostly to do with
>templated container classes and algorithms that operated on them, and
>which worked well only on C++ compilers with rather better template
>support than Visual C++ 5 could offer at the time.
>
>We're talking about the standard C++ runtime library as documented in
>ISO/IEC 14882. Standard C++ compilers *have* to support this library in
>a standard way (and Visual C++ 7.1 (or whatever it's officially called)
>does it quite well).
>
>It's no longer something any C++ programmer can afford not to
>intimately acquianted with, IMHO.
>
>> ... it seemed mired in 8-bit characters.
>
>The standard library handles 8-bit characters well, and it handles
>16-bit wide characters well. std::string is a narrow string,
>std::wstring is a wide string. The standard library also provides
>automatic mechanisms through the IOStream classes for conversion
>between external UTF-8 characters and internal wide chars as characters
>are read and written.
>
>What it doesn't do is support 32-bit Unicode (UCS4) characters, or
>provide character and string types which can be compiled as either wide
>or narrow (though you can use std::basic_string <TCHAR> if you want).
>
>> Note that one of the significant changes in CString in VS7 is that
>> you can have a mix of Unicode CStrings and 8-bit CStrings, ...
>
>The standard library has always supported this (at least since the
>published ISO standard).
>
>> ... my customer base doesn't want STL.
>
>If they want standard C++ they get the Standard Library. End of story.
>
>I write all back-end modules in standard C++ (so that they're portable
>to other platforms, should the need arise), but in MFC apps (which
>aren't portable anyway) I use CString in GUI classes because so much of
>the encapsulation of the Windows API makes heavy use of it. I convert
>between std:string and CString when passing text data between the
>back-end and the GUI. This conversion sometimes involves copying of
>string data, but that's seldom a (performance) problem, as the
>operation of the GUI isn't time-critical anyway.
>
>Cheers,
> Daniel.
>
>

Joseph M. Newcomer [MVP]
email: newcomer@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm



Relevant Pages

  • Re: replacing unsigned char * with CString
    ... Or unsigned char *. ... Note that CString does not "automatically expand" anything in the example you gave. ... 16-bit characters at the drop of a preprocessor symbol. ... imageFile.Read(tempImage, radarMapSize); ...
    (microsoft.public.vc.mfc)
  • Re: CString and UTF-8
    ... CString will try to understand the multibyte characters as its ... CString treats the UTF-8 characters as ...
    (microsoft.public.vc.mfc)
  • Re: CFileDialog GetFileName()
    ... I read somewhere that there was a problem with GetFileName() on files longer than 64 chars, but I haven't been able to reproduce the problem and I can't seem to find anything else on the problem. ... This may be what you are seeing since, as Joe pointed out, you are getting 63 characters. ... CString GetFileOnly ... >Introduzca los datos necesarios para realizar la búsqueda del f ...
    (microsoft.public.vc.mfc)
  • Re: Please help with this.
    ... returns a CString. ... it also seems possible you will drop characters by ... >>> void CPSMDlg::OnOnCommMscomm1 ... >> // causes the OnComm event to NOT fire when a character is detected ...
    (microsoft.public.vc.mfc)
  • Re: getline and CR, LF, CR/LF, VS/Linux
    ... additional work on your part in binary mode is necessary. ... >>characters with lines terminated by a LF, ... the original STL - none at all. ... Streams was originally created by Jerry Schwarz. ...
    (microsoft.public.vc.stl)