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.
10 #include <qstringlist.h>
16 * The maximum number of sub-expressions that may appear in a single struct
19 const int typeInfoMaxExpr
= 5;
24 TypeInfo(const QString
& displayString
);
28 * The number of sub-expressions that need to be evaluated to get the
33 * This array contains the various parts which glue together the
34 * sub-expressions. The entries in this array are the parts that appear
35 * between the percent signs '%' of the display expression; hence,
36 * there is one part more than there are sub-expressions.
38 QString m_displayString
[typeInfoMaxExpr
+1];
40 * This is a list of partial expressions. Each contains one or more \%s,
41 * which will be replaced by the parent expression. The results are
42 * substituted for the percent signs in m_displayString.
44 QString m_exprStrings
[typeInfoMaxExpr
];
46 * This is a list of guard expressions. Each contains one or more \%s,
47 * which will be replaced by the parent expression, or is empty. If the
48 * evaluation of the resulting expression returns an error, the
49 * corresponding expression from m_exprStrings is not evaluated. (This
50 * is used to guard function calls.)
52 QString m_guardStrings
[typeInfoMaxExpr
];
54 * This is the type name including template arguments that contain a
55 * pattern: A single '*' as template parameter matches one template
56 * argument, except that a '*' as the last template parameter matches
57 * all remaining template argument.
59 QString m_templatePattern
;
61 * Returns a pointer to a TypeInfo that identifies wchar_t
63 static TypeInfo
* wchartType() { return &m_wchartType
; }
65 * Gets a pointer to a TypeInfo that means: "I don't know the type"
67 static TypeInfo
* unknownType() { return &m_unknownType
; }
70 static TypeInfo m_wchartType
;
71 static TypeInfo m_unknownType
;
80 typedef std::map
<QString
,TypeInfo
*> TypeMap
;
83 * Load all known type libraries.
85 static void initTypeLibraries();
88 * Copy type infos to the specified dictionary.
90 void copyTypes(QDict
<TypeInfo
>& dict
);
93 * Returns the template types
95 const TypeMap
& templates() const { return m_templates
; }
98 * Does the file name match this library?
100 bool matchFileName(const char* fileName
) {
101 return m_shlibNameRE
.match(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
; }
116 * Loads the structure type information from the configuration files.
118 static void loadTypeTables();
119 void loadFromFile(const QString
& fileName
);
120 void readType(KConfigBase
& cf
, const QString
& type
);
121 QDict
<TypeInfo
> m_typeDict
;
122 QDict
<TypeInfo
> m_aliasDict
;
124 QString m_displayName
;
125 QRegExp m_shlibNameRE
;
126 QStringList m_enabledBuiltins
;
127 char* 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 TypeInfo
* lookup(QString type
);
159 * Adds a new alias for a type name.
161 void registerAlias(const QString
& name
, 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 QDict
<TypeInfo
> m_types
;
180 QDict
<TypeInfo
> m_aliasDict
;
181 struct TemplateInfo
{
182 QStringList templateArgs
;
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::TypeMap::value_type
& tt
);
189 static QStringList
splitTemplateArgs(const QString
& t
);
190 bool m_parseQt2QStrings
;
192 const char* m_printQStringDataCmd
;