Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/gui/styles/qstylehelper_p.h

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    4242#include <QtCore/qglobal.h>
    4343#include <QtCore/qpoint.h>
     44#include <QtCore/qstring.h>
    4445#include <QtGui/qpolygon.h>
     46#include <QtCore/qstringbuilder.h>
    4547
    4648#ifndef QSTYLEHELPER_P_H
     
    8082}
    8183
     84// internal helper. Converts an integer value to an unique string token
     85template <typename T>
     86        struct HexString
     87{
     88    inline HexString(const T t)
     89        : val(t)
     90    {}
     91
     92    inline void write(QChar *&dest) const
     93    {
     94        const ushort hexChars[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' };
     95        const char *c = reinterpret_cast<const char *>(&val);
     96        for (uint i = 0; i < sizeof(T); ++i) {
     97            *dest++ = hexChars[*c & 0xf];
     98            *dest++ = hexChars[(*c & 0xf0) >> 4];
     99            ++c;
     100        }
     101    }
     102    const T val;
     103};
     104
     105// specialization to enable fast concatenating of our string tokens to a string
     106template <typename T>
     107        struct QConcatenable<HexString<T> >
     108{
     109    typedef HexString<T> type;
     110    enum { ExactSize = true };
     111    static int size(const HexString<T> &) { return sizeof(T) * 2; }
     112    static inline void appendTo(const HexString<T> &str, QChar *&out) { str.write(out); }
     113};
     114
    82115QT_END_NAMESPACE
    83116
Note: See TracChangeset for help on using the changeset viewer.