diff -r b72c6db6890b -r 5dc02b23752f src/gui/styles/qstylehelper_p.h --- a/src/gui/styles/qstylehelper_p.h Wed Jun 23 19:07:03 2010 +0300 +++ b/src/gui/styles/qstylehelper_p.h Tue Jul 06 15:10:48 2010 +0300 @@ -41,7 +41,9 @@ #include #include +#include #include +#include #ifndef QSTYLEHELPER_P_H #define QSTYLEHELPER_P_H @@ -79,6 +81,37 @@ int bottom = 0); } +// internal helper. Converts an integer value to an unique string token +template + struct HexString +{ + inline HexString(const T t) + : val(t) + {} + + inline void write(QChar *&dest) const + { + const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; + const char *c = reinterpret_cast(&val); + for (uint i = 0; i < sizeof(T); ++i) { + *dest++ = hexChars[*c & 0xf]; + *dest++ = hexChars[(*c & 0xf0) >> 4]; + ++c; + } + } + const T val; +}; + +// specialization to enable fast concatenating of our string tokens to a string +template + struct QConcatenable > +{ + typedef HexString type; + enum { ExactSize = true }; + static int size(const HexString &str) { return sizeof(str.val) * 2; } + static inline void appendTo(const HexString &str, QChar *&out) { str.write(out); } +}; + QT_END_NAMESPACE #endif // QSTYLEHELPER_P_H