Qt 4.8
Classes | Enumerations | Functions
qmetaobject_p.h File Reference
#include <QtCore/qglobal.h>
#include <QtCore/qobjectdefs.h>

Go to the source code of this file.

Classes

struct  QMetaObjectPrivate
 

Enumerations

enum  MetaObjectFlags { DynamicMetaObject = 0x01 }
 
enum  MethodFlags {
  AccessPrivate = 0x00, AccessProtected = 0x01, AccessPublic = 0x02, AccessMask = 0x03,
  MethodMethod = 0x00, MethodSignal = 0x04, MethodSlot = 0x08, MethodConstructor = 0x0c,
  MethodTypeMask = 0x0c, MethodCompatibility = 0x10, MethodCloned = 0x20, MethodScriptable = 0x40,
  MethodRevisioned = 0x80, AccessPrivate = 0x00, AccessProtected = 0x01, AccessPublic = 0x02,
  AccessMask = 0x03, MethodMethod = 0x00, MethodSignal = 0x04, MethodSlot = 0x08,
  MethodConstructor = 0x0c, MethodTypeMask = 0x0c, MethodCompatibility = 0x10, MethodCloned = 0x20,
  MethodScriptable = 0x40, MethodRevisioned = 0x80
}
 
enum  PropertyFlags {
  Invalid = 0x00000000, Readable = 0x00000001, Writable = 0x00000002, Resettable = 0x00000004,
  EnumOrFlag = 0x00000008, StdCppSet = 0x00000100, Constant = 0x00000400, Final = 0x00000800,
  Designable = 0x00001000, ResolveDesignable = 0x00002000, Scriptable = 0x00004000, ResolveScriptable = 0x00008000,
  Stored = 0x00010000, ResolveStored = 0x00020000, Editable = 0x00040000, ResolveEditable = 0x00080000,
  User = 0x00100000, ResolveUser = 0x00200000, Notify = 0x00400000, Revisioned = 0x00800000,
  Invalid = 0x00000000, Readable = 0x00000001, Writable = 0x00000002, Resettable = 0x00000004,
  EnumOrFlag = 0x00000008, StdCppSet = 0x00000100, Constant = 0x00000400, Final = 0x00000800,
  Designable = 0x00001000, ResolveDesignable = 0x00002000, Scriptable = 0x00004000, ResolveScriptable = 0x00008000,
  Stored = 0x00010000, ResolveStored = 0x00020000, Editable = 0x00040000, ResolveEditable = 0x00080000,
  User = 0x00100000, ResolveUser = 0x00200000, Notify = 0x00400000, Revisioned = 0x00800000
}
 

Functions

static bool is_ident_char (char s)
 
static bool is_space (char s)
 
static QByteArray normalizeTypeInternal (const char *t, const char *e, bool fixScope=false, bool adjustConst=true)
 

Enumeration Type Documentation

◆ MetaObjectFlags

Enumerator
DynamicMetaObject 

Definition at line 103 of file qmetaobject_p.h.

103  {
104  DynamicMetaObject = 0x01
105 };

◆ MethodFlags

Enumerator
AccessPrivate 
AccessProtected 
AccessPublic 
AccessMask 
MethodMethod 
MethodSignal 
MethodSlot 
MethodConstructor 
MethodTypeMask 
MethodCompatibility 
MethodCloned 
MethodScriptable 
MethodRevisioned 
AccessPrivate 
AccessProtected 
AccessPublic 
AccessMask 
MethodMethod 
MethodSignal 
MethodSlot 
MethodConstructor 
MethodTypeMask 
MethodCompatibility 
MethodCloned 
MethodScriptable 
MethodRevisioned 

Definition at line 85 of file qmetaobject_p.h.

◆ PropertyFlags

Enumerator
Invalid 
Readable 
Writable 
Resettable 
EnumOrFlag 
StdCppSet 
Constant 
Final 
Designable 
ResolveDesignable 
Scriptable 
ResolveScriptable 
Stored 
ResolveStored 
Editable 
ResolveEditable 
User 
ResolveUser 
Notify 
Revisioned 
Invalid 
Readable 
Writable 
Resettable 
EnumOrFlag 
StdCppSet 
Constant 
Final 
Designable 
ResolveDesignable 
Scriptable 
ResolveScriptable 
Stored 
ResolveStored 
Editable 
ResolveEditable 
User 
ResolveUser 
Notify 
Revisioned 

Definition at line 61 of file qmetaobject_p.h.

61  {
62  Invalid = 0x00000000,
63  Readable = 0x00000001,
64  Writable = 0x00000002,
65  Resettable = 0x00000004,
66  EnumOrFlag = 0x00000008,
67  StdCppSet = 0x00000100,
68 // Override = 0x00000200,
69  Constant = 0x00000400,
70  Final = 0x00000800,
71  Designable = 0x00001000,
72  ResolveDesignable = 0x00002000,
73  Scriptable = 0x00004000,
74  ResolveScriptable = 0x00008000,
75  Stored = 0x00010000,
76  ResolveStored = 0x00020000,
77  Editable = 0x00040000,
78  ResolveEditable = 0x00080000,
79  User = 0x00100000,
80  ResolveUser = 0x00200000,
81  Notify = 0x00400000,
82  Revisioned = 0x00800000
83 };

Function Documentation

◆ is_ident_char()

static bool is_ident_char ( char  s)
inlinestatic

Definition at line 154 of file qmetaobject_p.h.

Referenced by normalizeTypeInternal(), and qRemoveWhitespace().

155 {
156  return ((s >= 'a' && s <= 'z')
157  || (s >= 'A' && s <= 'Z')
158  || (s >= '0' && s <= '9')
159  || s == '_'
160  );
161 }

◆ is_space()

static bool is_space ( char  s)
inlinestatic

Definition at line 163 of file qmetaobject_p.h.

Referenced by normalizeTypeInternal(), and qRemoveWhitespace().

164 {
165  return (s == ' ' || s == '\t');
166 }

◆ normalizeTypeInternal()

static QByteArray normalizeTypeInternal ( const char *  t,
const char *  e,
bool  fixScope = false,
bool  adjustConst = true 
)
static

Definition at line 170 of file qmetaobject_p.h.

Referenced by qNormalizeType().

171 {
172  int len = e - t;
173  /*
174  Convert 'char const *' into 'const char *'. Start at index 1,
175  not 0, because 'const char *' is already OK.
176  */
177  QByteArray constbuf;
178  for (int i = 1; i < len; i++) {
179  if ( t[i] == 'c'
180  && strncmp(t + i + 1, "onst", 4) == 0
181  && (i + 5 >= len || !is_ident_char(t[i + 5]))
182  && !is_ident_char(t[i-1])
183  ) {
184  constbuf = QByteArray(t, len);
185  if (is_space(t[i-1]))
186  constbuf.remove(i-1, 6);
187  else
188  constbuf.remove(i, 5);
189  constbuf.prepend("const ");
190  t = constbuf.data();
191  e = constbuf.data() + constbuf.length();
192  break;
193  }
194  /*
195  We musn't convert 'char * const *' into 'const char **'
196  and we must beware of 'Bar<const Bla>'.
197  */
198  if (t[i] == '&' || t[i] == '*' ||t[i] == '<')
199  break;
200  }
201  if (adjustConst && e > t + 6 && strncmp("const ", t, 6) == 0) {
202  if (*(e-1) == '&') { // treat const reference as value
203  t += 6;
204  --e;
205  } else if (is_ident_char(*(e-1)) || *(e-1) == '>') { // treat const value as value
206  t += 6;
207  }
208  }
209  QByteArray result;
210  result.reserve(len);
211 
212 #if 1
213  // consume initial 'const '
214  if (strncmp("const ", t, 6) == 0) {
215  t+= 6;
216  result += "const ";
217  }
218 #endif
219 
220  // some type substitutions for 'unsigned x'
221  if (strncmp("unsigned", t, 8) == 0) {
222  // make sure "unsigned" is an isolated word before making substitutions
223  if (!t[8] || !is_ident_char(t[8])) {
224  if (strncmp(" int", t+8, 4) == 0) {
225  t += 8+4;
226  result += "uint";
227  } else if (strncmp(" long", t+8, 5) == 0) {
228  if ((strlen(t + 8 + 5) < 4 || strncmp(t + 8 + 5, " int", 4) != 0) // preserve '[unsigned] long int'
229  && (strlen(t + 8 + 5) < 5 || strncmp(t + 8 + 5, " long", 5) != 0) // preserve '[unsigned] long long'
230  ) {
231  t += 8+5;
232  result += "ulong";
233  }
234  } else if (strncmp(" short", t+8, 6) != 0 // preserve unsigned short
235  && strncmp(" char", t+8, 5) != 0) { // preserve unsigned char
236  // treat rest (unsigned) as uint
237  t += 8;
238  result += "uint";
239  }
240  }
241  } else {
242  // discard 'struct', 'class', and 'enum'; they are optional
243  // and we don't want them in the normalized signature
244  struct {
245  const char *keyword;
246  int len;
247  } optional[] = {
248  { "struct ", 7 },
249  { "class ", 6 },
250  { "enum ", 5 },
251  { 0, 0 }
252  };
253  int i = 0;
254  do {
255  if (strncmp(optional[i].keyword, t, optional[i].len) == 0) {
256  t += optional[i].len;
257  break;
258  }
259  } while (optional[++i].keyword != 0);
260  }
261 
262  bool star = false;
263  while (t != e) {
264  char c = *t++;
265  if (fixScope && c == ':' && *t == ':' ) {
266  ++t;
267  c = *t++;
268  int i = result.size() - 1;
269  while (i >= 0 && is_ident_char(result.at(i)))
270  --i;
271  result.resize(i + 1);
272  }
273  star = star || c == '*';
274  result += c;
275  if (c == '<') {
276  //template recursion
277  const char* tt = t;
278  int templdepth = 1;
279  while (t != e) {
280  c = *t++;
281  if (c == '<')
282  ++templdepth;
283  if (c == '>')
284  --templdepth;
285  if (templdepth == 0 || (templdepth == 1 && c == ',')) {
286  result += normalizeTypeInternal(tt, t-1, fixScope, false);
287  result += c;
288  if (templdepth == 0) {
289  if (*t == '>')
290  result += ' '; // avoid >>
291  break;
292  }
293  tt = t;
294  }
295  }
296  }
297 
298  // cv qualifers can appear after the type as well
299  if (!is_ident_char(c) && t != e && (e - t >= 5 && strncmp("const", t, 5) == 0)
300  && (e - t == 5 || !is_ident_char(t[5]))) {
301  t += 5;
302  while (t != e && is_space(*t))
303  ++t;
304  if (adjustConst && t != e && *t == '&') {
305  // treat const ref as value
306  ++t;
307  } else if (adjustConst && !star) {
308  // treat const as value
309  } else if (!star) {
310  // move const to the front (but not if const comes after a *)
311  result.prepend("const ");
312  } else {
313  // keep const after a *
314  result += "const";
315  }
316  }
317  }
318 
319  return result;
320 }
unsigned char c[8]
Definition: qnumeric_p.h:62
static bool is_ident_char(char s)
char * data()
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:429
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
QByteArray & prepend(char c)
Prepends the character ch to this byte array.
static bool is_space(char s)
int length() const
Same as size().
Definition: qbytearray.h:356
static QByteArray normalizeTypeInternal(const char *t, const char *e, bool fixScope=false, bool adjustConst=true)
void resize(int size)
Sets the size of the byte array to size bytes.
int size() const
Returns the number of bytes in this byte array.
Definition: qbytearray.h:402
char at(int i) const
Returns the character at index position i in the byte array.
Definition: qbytearray.h:413
void reserve(int size)
Attempts to allocate memory for at least size bytes.
Definition: qbytearray.h:449
QByteArray & remove(int index, int len)
Removes len bytes from the array, starting at index position pos, and returns a reference to the arra...