From 5d1154c24e2475ed2b7ac248de27ab7b501a1e5e Mon Sep 17 00:00:00 2001 From: Tannin Date: Sat, 16 Feb 2013 19:09:57 +0100 Subject: - hooks for CreateHardLink - createprocess hook will now reroute the cwd (fixes SUM, may break other tools?) - profile code moved to separate file - executables can now be linked to toolbar - category filters are now represented as a tree - csv export of mod list - ModInfoDialog is now "window modal" instead of "application modal" - nexus dialog now updates the mod-id field while browsing - right-click in nexus browser allows to open in external browser - ini viewer is no longer modal - bugfix: another attempt to fix processing of invalid header lines in fomod xmls (bom now handled) - bugfix: integrated fomod installer will no longer overwrite detected mod name by the one from the xml - bugfix: "hide file" from conflicted files list now updates that list - bugfix: conflicted files list no longer offers to hide files in BSAs - bugfix: pressing delete on the mod list with multiplie files selected offered to delete the wrong files - regression: mod name guessing with the old regular expression was less likely to lead to an empty mod name. Now both are tried --- src/csvbuilder.h | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 src/csvbuilder.h (limited to 'src/csvbuilder.h') diff --git a/src/csvbuilder.h b/src/csvbuilder.h new file mode 100644 index 00000000..f2e0e987 --- /dev/null +++ b/src/csvbuilder.h @@ -0,0 +1,93 @@ +#ifndef CSVBUILDER_H +#define CSVBUILDER_H + + +#include +#include +#include +#include + + +class CSVException : public std::exception { + +public: + CSVException(const QString &text) + : std::exception(), m_Message(text.toLocal8Bit()) {} + + virtual const char* what() const throw() + { return m_Message.constData(); } +private: + QByteArray m_Message; + +}; + + +class CSVBuilder +{ + +public: + + enum EFieldType { + TYPE_INTEGER, + TYPE_STRING, + TYPE_FLOAT + }; + + enum EQuoteMode { + QUOTE_NEVER, + QUOTE_ONDEMAND, + QUOTE_ALWAYS + }; + + enum ELineBreak { + BREAK_LF, + BREAK_CRLF, + BREAK_CR + }; + +public: + + CSVBuilder(QIODevice *target); + ~CSVBuilder(); + + void setFieldSeparator(char sep); + void setLineBreak(ELineBreak lineBreak); + void setEscapeMode(EFieldType type, EQuoteMode mode); + void setFields(const std::vector > &fields); + void setDefault(const QString &field, const QVariant &value); + + void writeHeader(); + + void setRowField(const QString &field, const QVariant &value); + void writeRow(); + + void addRow(const std::map &data); + +private: + + const char *lineBreak(); + const char separator(); + + void fieldValid(); + void checkFields(const std::vector &fields); + void checkValue(const QString &field, const QVariant &value); + void writeData(const std::map &data, bool check); + + void quoteInsert(QTextStream &stream, int value); + void quoteInsert(QTextStream &stream, float value); + void quoteInsert(QTextStream &stream, const QString &value); + +private: + + QTextStream m_Out; + char m_Separator; + ELineBreak m_LineBreak; + std::map m_QuoteMode; + std::vector m_Fields; + std::map m_FieldTypes; + std::map m_Defaults; + std::map m_RowBuffer; + +}; + +#endif // CSVBUILDER_H -- cgit v1.3.1