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 exactly one \%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 exactly one \%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 * Returns a pointer to a TypeInfo that identifies wchar_t
56 static TypeInfo
* wchartType() { return &m_wchartType
; }
58 * Gets a pointer to a TypeInfo that means: "I don't know the type"
60 static TypeInfo
* unknownType() { return &m_unknownType
; }
63 static TypeInfo m_wchartType
;
64 static TypeInfo m_unknownType
;
74 * Load all known type libraries.
76 static void initTypeLibraries();
79 * Copy type infos to the specified dictionary.
81 void copyTypes(QDict
<TypeInfo
>& dict
);
84 * Does the file name match this library?
86 bool matchFileName(const char* fileName
) {
87 return m_shlibNameRE
.match(fileName
) >= 0;
91 * Is the specified builtin feature enabled in this type library?
93 bool isEnabledBuiltin(const QString
& feature
) const;
96 * Returns the command to print the QString data.
98 const char* printQStringDataCmd() const { return m_printQStringDataCmd
; }
102 * Loads the structure type information from the configuration files.
104 static void loadTypeTables();
105 void loadFromFile(const QString
& fileName
);
106 void readType(KConfigBase
& cf
, const QString
& type
);
107 QDict
<TypeInfo
> m_typeDict
;
108 QDict
<TypeInfo
> m_aliasDict
;
109 QString m_displayName
;
110 QRegExp m_shlibNameRE
;
111 QStringList m_enabledBuiltins
;
112 char* m_printQStringDataCmd
;
117 * This table keeps only references to the global type table. It is set up
120 class ProgramTypeTable
127 * Load types belonging to the specified libraries.
129 void loadLibTypes(const QStrList
& libs
);
132 * Load types belonging to the specified type table
134 void loadTypeTable(TypeTable
* table
);
137 * Clears that types and starts over (e.g. for a new program).
142 * Lookup a structure type.
144 * If the type is unknown, 0 is returned.
146 TypeInfo
* lookup(const QString
& type
);
149 * Adds a new alias for a type name.
151 void registerAlias(const QString
& name
, TypeInfo
* type
);
154 * Tells whether we use built-in support to understand QStrings.
156 bool parseQt2QStrings() const { return m_parseQt2QStrings
; }
159 * Tells whether QChar are defined like in Qt3.
161 bool qCharIsShort() const { return m_QCharIsShort
; }
164 * Returns the command to print the QString data.
166 const char* printQStringDataCmd() const { return m_printQStringDataCmd
; }
169 QDict
<TypeInfo
> m_types
;
170 QDict
<TypeInfo
> m_aliasDict
;
171 bool m_parseQt2QStrings
;
173 const char* m_printQStringDataCmd
;