summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHugo Parente Lima <hugo.pl@gmail.com>2011-02-10 18:57:40 -0200
committerHugo Parente Lima <hugo.pl@gmail.com>2011-02-10 20:51:16 -0200
commit2fa3a9485d45cfa27593848fbcee1b21ed1bfa57 (patch)
treeba3e3fdd444740dc885767368fd84df0f821897b
parentc306628bd2b06ec5a9a734e33a8d948be1811649 (diff)
Add function getClassTargetFullName to get what AbstractMetaClass.fullName would return.
-rw-r--r--generator.cpp26
-rw-r--r--generator.h3
2 files changed, 29 insertions, 0 deletions
diff --git a/generator.cpp b/generator.cpp
index f11eed77..376f5605 100644
--- a/generator.cpp
+++ b/generator.cpp
@@ -335,3 +335,29 @@ QString Generator::subDirectoryForPackage(QString packageName) const
return QString(packageName).replace(".", QDir::separator());
}
+template<typename T>
+static QString getClassTargetFullName_(const T* t, bool includePackageName)
+{
+ QString name = t->name();
+ const AbstractMetaClass* context = t->enclosingClass();
+ while (context) {
+ name.prepend('.');
+ name.prepend(context->name());
+ context = context->enclosingClass();
+ }
+ if (includePackageName) {
+ name.prepend('.');
+ name.prepend(t->package());
+ }
+ return name;
+}
+
+QString getClassTargetFullName(const AbstractMetaClass* metaClass, bool includePackageName)
+{
+ return getClassTargetFullName_(metaClass, includePackageName);
+}
+
+QString getClassTargetFullName(const AbstractMetaEnum* metaEnum, bool includePackageName)
+{
+ return getClassTargetFullName_(metaEnum, includePackageName);
+}
diff --git a/generator.h b/generator.h
index c4589010..0ebe1b55 100644
--- a/generator.h
+++ b/generator.h
@@ -45,6 +45,9 @@ QTextStream& formatCode(QTextStream &s, const QString& code, Indentor &indentor)
GENRUNNER_API
void verifyDirectoryFor(const QFile &file);
+GENRUNNER_API QString getClassTargetFullName(const AbstractMetaClass* metaClass, bool includePackageName = true);
+GENRUNNER_API QString getClassTargetFullName(const AbstractMetaEnum* metaEnum, bool includePackageName = true);
+
/**
* Base class for all generators. The default implementations does nothing,
* you must subclass this to create your own generators.