3 ms·
The only thing worse than no good string data type is 5 different string data types in one application. std::string, OString, QString, char*, QByteArray OStri
by ajuc 7y ago
The only thing worse than no good string data type is 5 different string data types in one application.
std::string, OString, QString, char*, QByteArray
OString was our wrapper around database library strings.
And there were automatic cast between SOME of these. I especially liked the helpful automatic cast to bool from OString (true if it wasn't empty if you're wondering). It meant that doing OString("password") == OString("wrong password") returned true because it converted both to bool.
- adrianN 7y agoFive different string datatypes are actually a good idea in many scenarios, but you have to be very careful with automatic conversions.
- klodolph 7y agoI think five different string datatypes are reasonable if they’re types like String, HTMLFragment, JavaScriptFragment, etc. If you’re just dealing with interop with char*, std::string, Qt, LibICU, etc. it’s a nightmare.