I thought I had read about this in the forum before, but I just can't find it.
I would love to be able to use wxString in a some of my base classes I use for all projects, including non-GUI projects or those that can't have a wxWidgets libary dependency for some reason. Today I typedef wxString it to std::string and do not use many of the advanced functions in those base classes, e.g. Format() (not using C++20).
I had a look at the sources for wxString. Its quite entangled with so many other include files of the wxWidgets build that its surely not easy to single out that class to a set of stand-alone header and cpp files. Maybe its possible to shrink down the number of dependencies when external requirements are cut down, e.g. not supporting WinCE or ceratin OS/compilers etc. Biggest challenge probably is the really impressive Macro Magic used for the vararg functions.
Does anything like that exist already? Or did someone try that before and shared lessons learned?
Separate wxString class
-
- Earned some good credits
- Posts: 123
- Joined: Sat Oct 07, 2006 1:56 pm
Separate wxString class
System config: Xubuntu22.04, wxWidgets 3.0.5,gcc, C::B
Re: Separate wxString class
FWIW, even wxWidgets maintainers strongly recommend avoiding wxString unless required. From the official docs:
I do agree that wxString has few rather handy methods not easily available otherwise, but I don't think it's worth doing changes in wxWidgets source.
If you link just to wxBase, I don't think many dependencies are pulled in, particularly when linking statically.
BTW, there is no Windows CE support in wxWidgets, even its vestiges were removed long time ago.
wxString and others (e.g., MFC's CString or Qt's QString) are relics of the past, when standard string class was not (widely) available.While the use of wxString is unavoidable in wxWidgets programs, you are encouraged to use the standard string classes std::string or std::wstring in your applications and convert them to and from wxString only when interacting with wxWidgets.
I do agree that wxString has few rather handy methods not easily available otherwise, but I don't think it's worth doing changes in wxWidgets source.
If you link just to wxBase, I don't think many dependencies are pulled in, particularly when linking statically.
BTW, there is no Windows CE support in wxWidgets, even its vestiges were removed long time ago.
-
- Earned some good credits
- Posts: 123
- Joined: Sat Oct 07, 2006 1:56 pm
Re: Separate wxString class
No idea if still supported, just came across leftovers in 3.05. sources. But I know from experience how hard it is to really clean out all traces of old stuff.
System config: Xubuntu22.04, wxWidgets 3.0.5,gcc, C::B