Qt 4.8
Macros | Functions
quuid.cpp File Reference
#include "quuid.h"
#include "qdatastream.h"
#include "qendian.h"
#include "qdatetime.h"
#include "qfile.h"
#include "qthreadstorage.h"
#include <stdlib.h>

Go to the source code of this file.

Macros

#define ISLESS(f1, f2)   if (f1!=f2) return (f1<f2);
 
#define ISMORE(f1, f2)   if (f1!=f2) return (f1>f2);
 

Functions

template<class Char , class Integral >
bool _q_fromHex (const Char *&src, Integral &value)
 
template<class Char , class Integral >
void _q_toHex (Char *&dst, Integral value)
 
template<class Char >
bool _q_uuidFromHex (const Char *&src, uint &d1, ushort &d2, ushort &d3, uchar(&d4)[8])
 
template<class Char >
void _q_uuidToHex (Char *&dst, const uint &d1, const ushort &d2, const ushort &d3, const uchar(&d4)[8])
 
 Q_GLOBAL_STATIC (QThreadStorage< QFile *>, devUrandomStorage)
 

Macro Definition Documentation

◆ ISLESS

#define ISLESS (   f1,
  f2 
)    if (f1!=f2) return (f1<f2);

Definition at line 806 of file quuid.cpp.

Referenced by QUuid::operator<().

◆ ISMORE

#define ISMORE (   f1,
  f2 
)    if (f1!=f2) return (f1>f2);

Definition at line 835 of file quuid.cpp.

Referenced by QUuid::operator>().

Function Documentation

◆ _q_fromHex()

template<class Char , class Integral >
bool _q_fromHex ( const Char *&  src,
Integral &  value 
)

Definition at line 68 of file quuid.cpp.

Referenced by _q_uuidFromHex().

69 {
70  value = 0;
71 
72  for (uint i = 0; i < sizeof(Integral) * 2; ++i) {
73  int ch = *src++;
74  int tmp;
75  if (ch >= '0' && ch <= '9')
76  tmp = ch - '0';
77  else if (ch >= 'a' && ch <= 'f')
78  tmp = ch - 'a' + 10;
79  else if (ch >= 'A' && ch <= 'F')
80  tmp = ch - 'A' + 10;
81  else
82  return false;
83 
84  value = value * 16 + tmp;
85  }
86 
87  return true;
88 }
unsigned int uint
Definition: qglobal.h:996

◆ _q_toHex()

template<class Char , class Integral >
void _q_toHex ( Char *&  dst,
Integral  value 
)

Definition at line 51 of file quuid.cpp.

Referenced by _q_uuidToHex().

52 {
53  static const char digits[] = "0123456789abcdef";
54 
55  value = qToBigEndian(value);
56 
57  const char* p = reinterpret_cast<const char*>(&value);
58 
59  for (uint i = 0; i < sizeof(Integral); ++i, dst += 2) {
60  uint j = (p[i] >> 4) & 0xf;
61  dst[0] = Char(digits[j]);
62  j = p[i] & 0xf;
63  dst[1] = Char(digits[j]);
64  }
65 }
T qToBigEndian(T source)
Definition: qendian.h:337
unsigned int uint
Definition: qglobal.h:996
ushort Char

◆ _q_uuidFromHex()

template<class Char >
bool _q_uuidFromHex ( const Char *&  src,
uint d1,
ushort d2,
ushort d3,
uchar(&)  d4[8] 
)

Definition at line 109 of file quuid.cpp.

Referenced by QUuid::QUuid().

110 {
111  if (*src == Char('{'))
112  src++;
113  if (!_q_fromHex(src, d1)
114  || *src++ != Char('-')
115  || !_q_fromHex(src, d2)
116  || *src++ != Char('-')
117  || !_q_fromHex(src, d3)
118  || *src++ != Char('-')
119  || !_q_fromHex(src, d4[0])
120  || !_q_fromHex(src, d4[1])
121  || *src++ != Char('-')
122  || !_q_fromHex(src, d4[2])
123  || !_q_fromHex(src, d4[3])
124  || !_q_fromHex(src, d4[4])
125  || !_q_fromHex(src, d4[5])
126  || !_q_fromHex(src, d4[6])
127  || !_q_fromHex(src, d4[7])) {
128  return false;
129  }
130 
131  return true;
132 }
bool _q_fromHex(const Char *&src, Integral &value)
Definition: quuid.cpp:68
ushort Char

◆ _q_uuidToHex()

template<class Char >
void _q_uuidToHex ( Char *&  dst,
const uint d1,
const ushort d2,
const ushort d3,
const uchar(&)  d4[8] 
)

Definition at line 91 of file quuid.cpp.

Referenced by QUuid::toByteArray(), and QUuid::toString().

92 {
93  *dst++ = Char('{');
94  _q_toHex(dst, d1);
95  *dst++ = Char('-');
96  _q_toHex(dst, d2);
97  *dst++ = Char('-');
98  _q_toHex(dst, d3);
99  *dst++ = Char('-');
100  for (int i = 0; i < 2; i++)
101  _q_toHex(dst, d4[i]);
102  *dst++ = Char('-');
103  for (int i = 2; i < 8; i++)
104  _q_toHex(dst, d4[i]);
105  *dst = Char('}');
106 }
ushort Char
void _q_toHex(Char *&dst, Integral value)
Definition: quuid.cpp:51

◆ Q_GLOBAL_STATIC()

Q_GLOBAL_STATIC ( QThreadStorage< QFile *>  ,
devUrandomStorage   
)

Referenced by QUuid::operator>().