Link to home
Start Free TrialLog in
Avatar of kmustang1
kmustang1

asked on

Which string class would you use?

I'm just starting the process of moving a very large C++ Builder/VCL application from C++ Builder 6 to Rad Studio 2010.

Most of the application uses Strings.  Many calls are made to external libraries that require char *'s, so there's liberal use of mystr.c_str() calls.  This is, of course, now causing a tremendous amount of work to bring up to date.  Note that DO NOT need Unicode support.  This little 3-person company will not be going international.  Ever.

So my question is, if you were going to essentially re-write string usage in your application, what would you use? So far I've found::

1. use String, and convert when needed (which is pretty much everywhere)
2. only use String when dealing with UI code, and std::string everywhere else.

I'm tempted to create my own string class so that c_str() would return the old char * pointers, a_str() to return ansi strings, and w_str() to return the new wide string that the VCL functions need (probably derived from std::string).  A little voice in the back of my head is voting no on that one.

Soooo.... what's your recommendation?
ASKER CERTIFIED SOLUTION
Avatar of Infinity08
Infinity08
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of kmustang1
kmustang1

ASKER

The code I'm updating is already written, so I haven't really dove in to it yet... (dived?  whatever :)  I've done a little test poking around, but have really only scratched the surface.  Thought I'd get all engineer-like and come up with a plan before I went in and started shredding.

Most of char*'s are const.  Where data is returned, it uses old-fashioned C array-of-char buffers.

I like the wrapper idea, but am not sure if it's worth the effort at this point. It probably is, but there are at least not-insignificant external libraries that I would have to wrap up.  I'll probably start doing that and see if I can get through it in a reasonable amount of time.

Thanks for the recommendation Infinity08!
I understand but try to understand the following:
DirectX (3D, sound, whatever) using char* to access dll's...
I know that it is NOT an easy task but I allready used the way I'm proposing and I get good(?) results...

George Tokas.
I was hoping for some more insight to the use of AnsiString vs. std::string.  Both posters did help, though, and are worthy of points.