I have an MFC source file that I need to compile under Qt. This file uses MFC/ATL CString. Specifically it uses a CString as an argument to iostream::open(). I have written a CString class that inherits from QString so that I can use most of QStrings' functionality.
My main concern is that I cannot get my CString implementation to work where iostream::open() is called:
Here is a bit of my class declaration:
class CString : public QString {
public:
CString() : QString() {}
CString(const QString& other) : QString(other) {}
CString(const CString& other) : QString(other) {}
CString(_In_opt_z_ const XCHAR* pszSrc) : QString( pszSrc ) { *this = pszSrc; }
CString(const char* pszSrc) : QString( pszSrc ) {}
...
}
And, here is a portion of code to use the CString:
ofstream outfile;
CString Path("dump.txt");
outfile.open(Path);
The error is:
no matching function for call to 'std::basic_ofstream >::open(CString&)'
Under 'normal' circumstances, I would simply do something like:
outfile.open(Path.toStdString().c_str());
However, that is not an option. No modification of the original code is authorized. :(
Is there a way to do this, or am I going to have to rebuild the class using the same, rather more complex and lengthy code, that Microsoft uses in cstringt.h?
Thanks