I have overloaded a class with various <<
operators
inline QString operator<<(bool boolean) {
return (boolean ? QString("true") : QString("false"));
}
inline QString operator<<(char const *string) {
return QString(string);
}
inline QString operator<<(int number) {
return QString::number(number);
}
Basically what I want to do, is write a debug output that captures the expression, like so:
#define DEBUG(...)
DEBUG(QString("foobar"), someObject.toInt());
// Expression 1: """QString("foobar")"""
// Expression 2: """someObject.toInt()"""
And combines it with its evaluation:
#define DEBUG(...)
DEBUG(QString("foobar"), someObject.toInt());
// Evaluation 1: "foobar"
// Evaluation 2: "1234"
Prepending all with
__FILE__;
QString::number(__LINE__);
__PRETTY_FUNCTION__;
And it should output something like this:
#define DEBUG(...)
DEBUG(QString("foobar"), someObject.toInt());
///////////////// Output /////////////////
File: /home/akiva/Programming/MyApp/source.cpp
Line: 123
Func: void doSomething();
QString("foobar")
"foobar"
someObject.toInt()
"1234"
I am having trouble doing this, as doing recursive variadic macros is not exactly legal. I am also having some additional difficulty, as my previous method of using variadic templates coupled with std::forward
, is not working in web assembly as far as I can tell. Ideally the solution once tested will also be compatible with Wasm.
Thanks.