Qt 4.8
Functions
qdeclarativestringconverters.cpp File Reference
#include "private/qdeclarativestringconverters_p.h"
#include <QtGui/qcolor.h>
#include <QtGui/qvector3d.h>
#include <QtCore/qpoint.h>
#include <QtCore/qrect.h>
#include <QtCore/qsize.h>
#include <QtCore/qvariant.h>
#include <QtCore/qdatetime.h>

Go to the source code of this file.

Functions

static uchar fromHex (const uchar c, const uchar c2)
 
static uchar fromHex (const QString &s, int idx)
 

Function Documentation

◆ fromHex() [1/2]

static uchar fromHex ( const uchar  c,
const uchar  c2 
)
static

Definition at line 54 of file qdeclarativestringconverters.cpp.

Referenced by QDeclarativeStringConverters::colorFromString(), fromHex(), and QByteArray::isSharedWith().

55 {
56  uchar rv = 0;
57  if (c >= '0' && c <= '9')
58  rv += (c - '0') * 16;
59  else if (c >= 'A' && c <= 'F')
60  rv += (c - 'A' + 10) * 16;
61  else if (c >= 'a' && c <= 'f')
62  rv += (c - 'a' + 10) * 16;
63 
64  if (c2 >= '0' && c2 <= '9')
65  rv += (c2 - '0');
66  else if (c2 >= 'A' && c2 <= 'F')
67  rv += (c2 - 'A' + 10);
68  else if (c2 >= 'a' && c2 <= 'f')
69  rv += (c2 - 'a' + 10);
70 
71  return rv;
72 }
unsigned char c[8]
Definition: qnumeric_p.h:62
unsigned char uchar
Definition: qglobal.h:994

◆ fromHex() [2/2]

static uchar fromHex ( const QString s,
int  idx 
)
static

Definition at line 74 of file qdeclarativestringconverters.cpp.

75 {
76  uchar c = s.at(idx).toAscii();
77  uchar c2 = s.at(idx + 1).toAscii();
78  return fromHex(c, c2);
79 }
unsigned char c[8]
Definition: qnumeric_p.h:62
const QChar at(int i) const
Returns the character at the given index position in the string.
Definition: qstring.h:698
unsigned char uchar
Definition: qglobal.h:994
char toAscii() const
Returns the character value of the QChar obtained using the current codec used to read C strings...
Definition: qchar.cpp:1490
static uchar fromHex(const uchar c, const uchar c2)