2 * Copyright Johannes Sixt
3 * This file is licensed under the GNU General Public License Version 2.
4 * See the file COPYING in the toplevel directory of the source directory.
15 * The maximum number of sub-expressions that may appear in a single struct
18 const int typeInfoMaxExpr
= 5;
23 TypeInfo(const QString
& displayString
);
27 * The number of sub-expressions that need to be evaluated to get the
32 * This array contains the various parts which glue together the
33 * sub-expressions. The entries in this array are the parts that appear
34 * between the percent signs '%' of the display expression; hence,
35 * there is one part more than there are sub-expressions.
37 QString m_displayString
[typeInfoMaxExpr
+1];
39 * This is a list of partial expressions. Each contains one or more \%s,
40 * which will be replaced by the parent expression. The results are
41 * substituted for the percent signs in m_displayString.
43 QString m_exprStrings
[typeInfoMaxExpr
];
45 * This is a list of guard expressions. Each contains one or more \%s,
46 * which will be replaced by the parent expression, or is empty. If the
47 * evaluation of the resulting expression returns an error, the
48 * corresponding expression from m_exprStrings is not evaluated. (This
49 * is used to guard function calls.)
51 QString m_guardStrings
[typeInfoMaxExpr
];
53 * This is the type name including template arguments that contain a
54 * pattern: A single '*' as template parameter matches one template
55 * argument, except that a '*' as the last template parameter matches
56 * all remaining template argument.
58 QString m_templatePattern
;
60 * Returns a pointer to a TypeInfo that identifies wchar_t
62 static TypeInfo
* wchartType() { return &m_wchartType
; }
64 * Gets a pointer to a TypeInfo that means: "I don't know the type"
66 static TypeInfo
* unknownType() { return &m_unknownType
; }
69 static TypeInfo m_wchartType
;
70 static TypeInfo m_unknownType
;
79 typedef std::map
<QString
,TypeInfo
> TypeInfoMap
;
80 typedef std::map
<QString
,const TypeInfo
*> TypeInfoRefMap
;
83 * Load all known type libraries.
85 static void initTypeLibraries();
88 * Copy type infos to the specified dictionary.
90 void copyTypes(TypeInfoRefMap
& dict
);
93 * Returns the template types
95 const TypeInfoMap
& templates() const { return m_templates
; }
98 * Does the file name match this library?
100 bool matchFileName(const QString
& fileName
) const {
101 return m_shlibNameRE
.indexIn(fileName
) >= 0;
105 * Is the specified builtin feature enabled in this type library?
107 bool isEnabledBuiltin(const QString
& feature
) const;
110 * Returns the command to print the QString data.
112 const char* printQStringDataCmd() const { return m_printQStringDataCmd
.constData(); }
116 * Loads the structure type information from the configuration files.
118 static void loadTypeTables();
119 void loadFromFile(const QString
& fileName
);
120 void readType(const KConfigGroup
& cf
, const QString
& type
);
121 TypeInfoMap m_typeDict
;
122 TypeInfoRefMap m_aliasDict
;
123 TypeInfoMap m_templates
;
124 QString m_displayName
;
125 QRegExp m_shlibNameRE
;
126 QStringList m_enabledBuiltins
;
127 QByteArray m_printQStringDataCmd
;
132 * This table keeps only references to the global type table. It is set up
135 class ProgramTypeTable
142 * Load types belonging to the specified libraries.
144 void loadLibTypes(const QStringList
& libs
);
147 * Load types belonging to the specified type table
149 void loadTypeTable(TypeTable
* table
);
152 * Lookup a structure type.
154 * If the type is unknown, 0 is returned.
156 const TypeInfo
* lookup(QString type
);
159 * Adds a new alias for a type name.
161 void registerAlias(const QString
& name
, const TypeInfo
* type
);
164 * Tells whether we use built-in support to understand QStrings.
166 bool parseQt2QStrings() const { return m_parseQt2QStrings
; }
169 * Tells whether QChar are defined like in Qt3.
171 bool qCharIsShort() const { return m_QCharIsShort
; }
174 * Returns the command to print the QString data.
176 const char* printQStringDataCmd() const { return m_printQStringDataCmd
; }
179 TypeTable::TypeInfoRefMap m_types
;
180 TypeTable::TypeInfoRefMap m_aliasDict
;
181 struct TemplateInfo
{
182 QStringList templateArgs
;
183 const TypeInfo
* type
;
185 typedef std::multimap
<QString
, TemplateInfo
> TemplateMap
;
186 TemplateMap m_templates
; //!< one or more template patterns per template name
187 static TemplateMap::value_type
188 template2Info(const TypeTable::TypeInfoMap::value_type
& tt
);
189 static QStringList
splitTemplateArgs(const QString
& t
);
190 bool m_parseQt2QStrings
;
192 QByteArray m_printQStringDataCmd
;