diff options
author | Marius Kintel <marius@kintel.net> | 2011-10-31 22:56:35 (GMT) |
---|---|---|
committer | Marius Kintel <marius@kintel.net> | 2011-10-31 22:56:35 (GMT) |
commit | cb56f700b1b0f4ae589da62a5fd1d4e368deb604 (patch) | |
tree | 62fe4e42ca983c3b2b8c97fdd377861c112b27cc /src | |
parent | 759446d6c3b8f10a95c6d4bf74f9b95a5821565b (diff) |
de-Qt'ified printutils
Diffstat (limited to 'src')
-rw-r--r-- | src/MainWindow.h | 4 | ||||
-rw-r--r-- | src/PolySetCache.cc | 2 | ||||
-rw-r--r-- | src/PolySetCache.h | 2 | ||||
-rw-r--r-- | src/parser.y | 2 | ||||
-rw-r--r-- | src/printutils.cc | 35 | ||||
-rw-r--r-- | src/printutils.h | 20 |
6 files changed, 33 insertions, 32 deletions
diff --git a/src/MainWindow.h b/src/MainWindow.h index a3c812b..06332b0 100644 --- a/src/MainWindow.h +++ b/src/MainWindow.h @@ -79,8 +79,8 @@ private: bool maybeSave(); bool checkModified(); QString dumpCSGTree(AbstractNode *root); - static void consoleOutput(const QString &msg, void *userdata) { - static_cast<MainWindow*>(userdata)->console->append(msg); + static void consoleOutput(const std::string &msg, void *userdata) { + static_cast<MainWindow*>(userdata)->console->append(QString::fromStdString(msg)); } void loadViewSettings(); void loadDesignSettings(); diff --git a/src/PolySetCache.cc b/src/PolySetCache.cc index 0a93642..2a2da9c 100644 --- a/src/PolySetCache.cc +++ b/src/PolySetCache.cc @@ -17,5 +17,5 @@ void PolySetCache::print() PolySetCache::cache_entry::cache_entry(const shared_ptr<PolySet> &ps) : ps(ps) { - if (print_messages_stack.size() > 0) this->msg = print_messages_stack.last(); + if (print_messages_stack.size() > 0) this->msg = print_messages_stack.back(); } diff --git a/src/PolySetCache.h b/src/PolySetCache.h index da51c5e..d1efeb7 100644 --- a/src/PolySetCache.h +++ b/src/PolySetCache.h @@ -23,7 +23,7 @@ private: struct cache_entry { shared_ptr<class PolySet> ps; - QString msg; + std::string msg; cache_entry(const shared_ptr<PolySet> &ps); ~cache_entry() { } }; diff --git a/src/parser.y b/src/parser.y index 33fbc3f..d703a81 100644 --- a/src/parser.y +++ b/src/parser.y @@ -649,7 +649,7 @@ Module *Module::compile_library(std::string filename) if (lib_mod) { libs_cache[filename].mod = lib_mod; - libs_cache[filename].msg = print_messages_stack.last().toStdString(); + libs_cache[filename].msg = print_messages_stack.back(); } else { libs_cache.erase(filename); } diff --git a/src/printutils.cc b/src/printutils.cc index a315ab3..ec41765 100644 --- a/src/printutils.cc +++ b/src/printutils.cc @@ -2,7 +2,7 @@ #include <stdio.h> #include <QDate> -QList<QString> print_messages_stack; +std::list<std::string> print_messages_stack; OutputHandlerFunc *outputhandler = NULL; void *outputhandler_data = NULL; @@ -14,37 +14,38 @@ void set_output_handler(OutputHandlerFunc *newhandler, void *userdata) void print_messages_push() { - print_messages_stack.append(QString()); + print_messages_stack.push_back(std::string()); } void print_messages_pop() { - QString msg = print_messages_stack.takeLast(); - if (print_messages_stack.size() > 0 && !msg.isNull()) { - if (!print_messages_stack.last().isEmpty()) - print_messages_stack.last() += "\n"; - print_messages_stack.last() += msg; + std::string msg = print_messages_stack.back(); + print_messages_stack.pop_back(); + if (print_messages_stack.size() > 0 && !msg.empty()) { + if (!print_messages_stack.back().empty()) { + print_messages_stack.back() += "\n"; + } + print_messages_stack.back() += msg; } } -void PRINT(const QString &msg) +void PRINT(const std::string &msg) { - if (msg.isNull()) - return; + if (msg.empty()) return; if (print_messages_stack.size() > 0) { - if (!print_messages_stack.last().isEmpty()) - print_messages_stack.last() += "\n"; - print_messages_stack.last() += msg; + if (!print_messages_stack.back().empty()) { + print_messages_stack.back() += "\n"; + } + print_messages_stack.back() += msg; } PRINT_NOCACHE(msg); } -void PRINT_NOCACHE(const QString &msg) +void PRINT_NOCACHE(const std::string &msg) { - if (msg.isNull()) - return; + if (msg.empty()) return; if (!outputhandler) { - fprintf(stderr, "%s\n", msg.toUtf8().data()); + fprintf(stderr, "%s\n", msg.c_str()); } else { outputhandler(msg, outputhandler_data); } diff --git a/src/printutils.h b/src/printutils.h index 60cd12a..761e6c8 100644 --- a/src/printutils.h +++ b/src/printutils.h @@ -1,28 +1,28 @@ #ifndef PRINTUTILS_H_ #define PRINTUTILS_H_ -#include <QString> -#include <QList> +#include <string> +#include <list> #include <iostream> #include <QFileInfo> -typedef void (OutputHandlerFunc)(const QString &msg, void *userdata); +typedef void (OutputHandlerFunc)(const std::string &msg, void *userdata); extern OutputHandlerFunc *outputhandler; extern void *outputhandler_data; void set_output_handler(OutputHandlerFunc *newhandler, void *userdata); -extern QList<QString> print_messages_stack; +extern std::list<std::string> print_messages_stack; void print_messages_push(); void print_messages_pop(); -void PRINT(const QString &msg); -#define PRINTF(_fmt, ...) do { QString _m; _m.sprintf(_fmt, ##__VA_ARGS__); PRINT(_m); } while (0) -#define PRINTA(_fmt, ...) do { QString _m = QString(_fmt).arg(__VA_ARGS__); PRINT(_m); } while (0) +void PRINT(const std::string &msg); +#define PRINTF(_fmt, ...) do { QString _m; _m.sprintf(_fmt, ##__VA_ARGS__); PRINT(_m.toStdString()); } while (0) +#define PRINTA(_fmt, ...) do { QString _m = QString(_fmt).arg(__VA_ARGS__); PRINT(_m.toStdString()); } while (0) -void PRINT_NOCACHE(const QString &msg); -#define PRINTF_NOCACHE(_fmt, ...) do { QString _m; _m.sprintf(_fmt, ##__VA_ARGS__); PRINT_NOCACHE(_m); } while (0) -#define PRINTA_NOCACHE(_fmt, ...) do { QString _m = QString(_fmt).arg(__VA_ARGS__); PRINT_NOCACHE(_m); } while (0) +void PRINT_NOCACHE(const std::string &msg); +#define PRINTF_NOCACHE(_fmt, ...) do { QString _m; _m.sprintf(_fmt, ##__VA_ARGS__); PRINT_NOCACHE(_m.toStdString()); } while (0) +#define PRINTA_NOCACHE(_fmt, ...) do { QString _m = QString(_fmt).arg(__VA_ARGS__); PRINT_NOCACHE(_m.toStdString()); } while (0) std::ostream &operator<<(std::ostream &os, const QFileInfo &fi); |