1 /*=========================================================================
3 Program: Visualization Toolkit
4 Module: vtkParseHierarchy.h
6 Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
8 See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
10 This software is distributed WITHOUT ANY WARRANTY; without even
11 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
12 PURPOSE. See the above copyright notice for more information.
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16 Copyright (c) 2010 David Gobbi.
18 Contributed to the VisualizationToolkit by the author in June 2010
19 under the terms of the Visualization Toolkit 2008 copyright.
20 --------------------------------------------------------------------------*/
23 This file contains utility functions for loading and parsing
24 a VTK hierarchy file. The file contains entries like the
25 following (one per line in the file):
27 classname [ : superclass ] ; header.h ; vtkKit [; flags]
29 For each typedef, the output file will have a line like this:
31 name = &[2][3]* const type ; header.h ; vtkKit [; flags]
33 For each enum, the output file will have:
35 enumname : enum ; header.h ; vtkKit [; flags]
39 #ifndef VTK_PARSE_HIERARCHY_H
40 #define VTK_PARSE_HIERARCHY_H
42 /* Need the ValueInfo struct for typedefs */
46 * One entry from the hierarchy file.
47 * It contains a class name, the superclasses, and the header file.
49 typedef struct _HierarchyEntry
51 const char *Name; /* the class or type name */
52 const char *HeaderFile; /* header file the class is defined in */
53 const char *Module; /* library the class is defined in */
54 int NumberOfTemplateArgs; /* number of template arguments */
55 const char **TemplateArgs;
56 const char **TemplateArgDefaults;
57 int NumberOfProperties; /* number of properties */
58 const char **Properties;
59 int NumberOfSuperClasses; /* number of superclasses */
60 const char **SuperClasses;
61 int *SuperClassIndex; /* for internal use only */
62 ValueInfo *Typedef; /* for typedefs */
63 int IsEnum; /* this entry is for an enum type */
64 int IsTypedef; /* this entry is for a typedef */
68 * All the entries from a hierarchy file.
70 typedef struct _HierarchyInfo
73 HierarchyEntry *Entries;
81 * Read a hierarchy file into a HeirarchyInfo struct, or return NULL
83 HierarchyInfo *vtkParseHierarchy_ReadFile(const char *filename);
86 * Free a HierarchyInfo struct
88 void vtkParseHierarchy_Free(HierarchyInfo *info);
91 * Return the entry for a class or type, or null if not found
93 HierarchyEntry *vtkParseHierarchy_FindEntry(
94 const HierarchyInfo *info, const char *classname);
97 * Get properties for the class. Returns NULL if the property
98 * is not set, and returns either an empty string or a value string
99 * if the property is set. The properties supported are as follows:
100 * "WRAP_EXCLUDE", "WRAP_SPECIAL", and "ABSTRACT"
102 const char *vtkParseHierarchy_GetProperty(
103 const HierarchyEntry *entry, const char *property);
106 * Check whether class is derived from baseclass.
108 int vtkParseHierarchy_IsTypeOf(const HierarchyInfo *info,
109 const HierarchyEntry *entry, const char *baseclass);
112 * Check whether class is derived from baseclass. You must supply
113 * the entry for the class (returned by FindEntry) as well as the
114 * classname. The classname can include template args in angle brackets.
115 * The baseclass_with_args parameter, if not set to NULL, will be used
116 * to return the name of base class with the template args in angle
117 * brackets that classname was derived from. If not set to NULL,
118 * this should be freed with free() to avoid a memory leak.
120 int vtkParseHierarchy_IsTypeOfTemplated(const HierarchyInfo *info,
121 const HierarchyEntry *entry, const char *classname,
122 const char *baseclass, const char **baseclass_with_args);
125 * Free the template args returned by IsTypeOfTemplated
127 void vtkParseHierarchy_FreeTemplateArgs(int n, const char *args[]);
130 * Given a classname with template parameters, get the superclass name
131 * with corresponding template parameters. Returns null if 'i' is out
132 * of range, i.e. greater than or equal to the number of superclasses.
133 * The returned classname must be freed with "free()".
135 const char *vtkParseHierarchy_TemplatedSuperClass(
136 const HierarchyEntry *entry, const char *classname, int i);
139 * Expand all unrecognized types in a ValueInfo struct by
140 * using the typedefs in the HierarchyInfo struct.
142 int vtkParseHierarchy_ExpandTypedefsInValue(
143 const HierarchyInfo *info, ValueInfo *data, const char *scope);
146 * Expand typedefs found in a name stored as a string. The value
147 * of "text" will be returned if no expansion occurred, else a new
148 * string is returned that must be freed with "free()".
150 const char *vtkParseHierarchy_ExpandTypedefsInName(
151 const HierarchyInfo *info, const char *text, const char *scope);