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 */
43 #include "vtkParseData.h"
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 NumberOfTemplateParameters; /* number of template params */
55 const char **TemplateParameters;
56 const char **TemplateDefaults;
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;
82 * Read a hierarchy file into a HeirarchyInfo struct, or return NULL
84 HierarchyInfo *vtkParseHierarchy_ReadFile(const char *filename);
87 * Free a HierarchyInfo struct
89 void vtkParseHierarchy_Free(HierarchyInfo *info);
92 * Return the entry for a class or type, or null if not found
94 HierarchyEntry *vtkParseHierarchy_FindEntry(
95 const HierarchyInfo *info, const char *classname);
98 * Get properties for the class. Returns NULL if the property
99 * is not set, and returns either an empty string or a value string
100 * if the property is set. The properties supported are as follows:
101 * "WRAP_EXCLUDE", "WRAP_SPECIAL", and "ABSTRACT"
103 const char *vtkParseHierarchy_GetProperty(
104 const HierarchyEntry *entry, const char *property);
107 * Check whether class is derived from baseclass.
109 int vtkParseHierarchy_IsTypeOf(const HierarchyInfo *info,
110 const HierarchyEntry *entry, const char *baseclass);
113 * Check whether class is derived from baseclass. You must supply
114 * the entry for the class (returned by FindEntry) as well as the
115 * classname. The classname can include template args in angle brackets.
116 * The baseclass_with_args parameter, if not set to NULL, will be used
117 * to return the name of base class with the template args in angle
118 * brackets that classname was derived from. If not set to NULL,
119 * this should be freed with free() to avoid a memory leak.
121 int vtkParseHierarchy_IsTypeOfTemplated(const HierarchyInfo *info,
122 const HierarchyEntry *entry, const char *classname,
123 const char *baseclass, const char **baseclass_with_args);
126 * Free the template args returned by IsTypeOfTemplated
128 void vtkParseHierarchy_FreeTemplateArgs(int n, const char *args[]);
131 * Given a classname with template parameters, get the superclass name
132 * with corresponding template parameters. Returns null if 'i' is out
133 * of range, i.e. greater than or equal to the number of superclasses.
134 * The returned classname must be freed with "free()".
136 const char *vtkParseHierarchy_TemplatedSuperClass(
137 const HierarchyEntry *entry, const char *classname, int i);
140 * Expand all unrecognized types in a ValueInfo struct by
141 * using the typedefs in the HierarchyInfo struct.
143 int vtkParseHierarchy_ExpandTypedefsInValue(
144 const HierarchyInfo *info, ValueInfo *data, StringCache *cache,
148 * Expand typedefs found in a name stored as a string. The value
149 * of "text" will be returned if no expansion occurred, else a new
150 * string is returned that must be freed with "free()".
152 const char *vtkParseHierarchy_ExpandTypedefsInName(
153 const HierarchyInfo *info, const char *text, const char *scope);