The MFC CString class, has some really nice string manipulation routines.
However, if you are trying to avoid the MFC for size/deployment issues, and having to do string manipulation
of BSTRs I'm sure that you will be finding the _bstr_t class frustratingly basic.
After doing a great deal of frustrated hair-pulling I finally got around to implementing this class, CBstr.
It is a C++ class derived from the MS VC++ _bstr_t COM support class with the added benefit of
a barrow-load of string manipulation methods. The original idea came after seeing Alex Stockton's
NoMFC::CString class at www.WorldofATL.com. This class was used
as the template for the public interface.
(continued)
The class uses the same public "interface" as the NoMFC::CString Class with a couple of minor
differences and as a result has all the functionality of the "real" (MFC) CString class with a few
extra's. And because it is derived from _bstr_t
Because the class is derived from _bstr_t it is very easy to use instead of that class,
especially where string manipulation of any kind is required. If you are not planning on
using the string-manipulation functionality I would suggest sticking with the _bstr_t class
for reduced class size.
To use the class simply #include the CBstrImpl.h header file supplied in the Zip, and have
this and CBStr.h in your include path.
A demo program (and my test rig) follows and is included in the zip file. This exercises
all of the functionality of of the class, but for more information I would suggest looking
at the documentation of the MFC CString class - it doesn't seem woth copying it out ;-)
This code has been tested with Visual C++ 5.0 Service Pack 3, it has not been tested
with Visual C++ 6.0
Example code