我的输出方法有问题。如果我使用格式修饰符(SPACNG),则会在行尾添加一个空格。
Instead of this
and this
看起来像这样
I have a space
in the next line
我很难检查first
是否是QTextStream::endl
对象。有没有办法做到这一点?
template <class T>
static int out(QFile &f, QTextStream &s, Formatting opts, const T &first) {
if (f.open(QIODevice::WriteOnly | QIODevice::Append)) {
if (cur_arg == 0 && (opts & TimeStamp)) { // first parameter
s << QDateTime::currentDateTime().toString("hh:mm:ss.zzz") + ": ";
}
s << first;
// do this only if first is not endl :/
if (opts & Spacing) {
s << " ";
}
if (opts & EndLine) {
s << endl;
}
f.close();
}
return 1;
}