Used by Exporter to write a file. More...
#include <exporter.h>
Classes | |
class | TemporaryTextFile |
Used by Writer as a device for writing. More... | |
Public Member Functions | |
Writer () | |
Writer (const Writer &original) | |
template<class T > | |
Writer & | operator<< (const T &t) |
Writer & | operator<< (const QVariant &v) |
Writer & | operator<< (const QDateTime &dt) |
const QDateTime & | min () |
const QDateTime & | max () |
QString | filePath () const |
Used by Exporter to write a file.
Writer::Writer | ( | ) |
: m_file(new TemporaryTextFile()), m_stream(new QTextStream()) { if (!GlobalConst::TEMP_DIR.exists()) if (!GlobalConst::TEMP_DIR.mkpath(GlobalConst::TEMP_DIR.absolutePath())) Q_ASSERT(false); m_file->setFileTemplate(GlobalConst::TEMP_DIR.path() + QDir::separator() + "tmp_writer"); if (!m_file->open()) qCritical() << "Cannot create the file " << m_file->fileName(); m_stream->setDevice(m_file.data()); }
Writer::Writer | ( | const Writer & | original | ) |
{ m_file = original.m_file; m_stream = original.m_stream; m_min = original.m_min; m_max = original.m_max; }
const QDateTime & Writer::max | ( | ) |
{
return m_max;
}
const QDateTime & Writer::min | ( | ) |
{
return m_min;
}
{ if (v.isNull()){ QVariant::Type type = v.type(); if (type > QVariant::Invalid && type <= QVariant::Double) { // Volgens de enum QVariant::Type betekent dan dat type een built-in numeric is. // Daar de QVaraint null is, is de numeric "not a number" // Note: QVariant kan hierbij isValid() zijn en een 0 bij conversie outputten, maar toch isNull() zijn! *m_stream.data() << "NaN"; } else Q_ASSERT_X(false, "problem in Writer", QString("Type ").append(QString::number(type)).append(" unhandled. Contact admin.").toAscii().data()); } else *m_stream.data() << v.toString(); return *this; }
Writer & Writer::operator<< | ( | const T & | t | ) | [inline] |
The non-template function takes precedence in overload resolution. (c.f. http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlcpp8l.doc/language/ref/overloading_function_templates.htm)
{ *m_stream.data() << t; return *this; }