diff options
author | Hugo Parente Lima <hugo.pl@gmail.com> | 2010-10-27 18:15:16 -0200 |
---|---|---|
committer | Hugo Parente Lima <hugo.pl@gmail.com> | 2012-03-09 19:10:12 -0300 |
commit | 59d60a65b22acf21f62314dd5ab6a047509bb7e4 (patch) | |
tree | a8cefdbad2b2803982162266deeee313b046659c /typesystem.cpp | |
parent | e5ecbe66d2f1ccfe8c80d58e3e66f4344f3e5505 (diff) |
Add helper method TypeEntry::isCppPrimitive.
Returns true is the type is a primitive C++ type.
Reviewer: Luciano Wolf <luciano.wolf@openbossa.org>
Renato Araújo <renato.filho@openbossa.org>
Diffstat (limited to 'typesystem.cpp')
-rw-r--r-- | typesystem.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/typesystem.cpp b/typesystem.cpp index b407f2e0b..3c09524a3 100644 --- a/typesystem.cpp +++ b/typesystem.cpp @@ -2001,6 +2001,22 @@ QString ContainerTypeEntry::typeName() const } } +static bool strLess(const char* a, const char* b) +{ + return ::strcmp(a, b) < 0; +} + +bool TypeEntry::isCppPrimitive() const +{ + if (m_name.contains(' ')) + return true; + // Keep this sorted!! + static const char* cppTypes[] = { "bool", "char", "double", "float", "int", "long", "short", "wchar_t"}; + const int N = sizeof(cppTypes)/sizeof(char*); + + const char** res = qBinaryFind(&cppTypes[0], &cppTypes[N], m_name.toAscii().constData(), strLess); + return res != &cppTypes[N]; +} /* static void injectCode(ComplexTypeEntry *e, |