this is music to the ears of those who work with more or less advanced frameworks, but what about those who prefer (or are compelled) to stick to low-level c++ com development? they can still use the standard library conversion function, which the framework macros themselves rely on ultimately, such as mbstowcs() and wcstombs(). unfortunately such functions are not aware of bstrs and olechars, so heavy use of conditional compilation would be required to deal with the various combinations possible, and this is evil from a readability perspective. power developers who program com at the raw c++ level will probably find out naturally at a certain point in their learning curve and experience how to write a set of conversion macros by themselves. if you are lazy and prefer to use a precooked set of macros, you can freely use don box's yacl (the acronym stands for "yet another com library") which is extremely efficient and does much more than just string conversion in pure c++ com. the url for the download is http://www.develop.com/dbox/yacl.htm.
conclusion
after some study and direct experimentation, the various string types in com prove to be much less cryptic and problematic than at first they seemed. fundamentally, it all boils down to recognizing and memorizing a handful of new data types which may behave differently on different platforms, and getting used to the framework of handy conversion functions provided by atl, mfc, or the direct to com visual c++ extension. regardless of which of the mentioned tasks you are going to tackle, i hope this article will serve as a valuable aid in saving precious time working with strings.
|
copyright © 1999 - visual c++ developers journal |