]> SALOME platform Git repositories - modules/paravis.git/blob - src/ParaView/vtkParseHierarchy.h
Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/paravis.git] / src / ParaView / vtkParseHierarchy.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    vtkParseHierarchy.h
5
6   Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
7   All rights reserved.
8   See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
9
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.
13
14 =========================================================================*/
15 /*-------------------------------------------------------------------------
16   Copyright (c) 2010 David Gobbi.
17
18   Contributed to the VisualizationToolkit by the author in June 2010
19   under the terms of the Visualization Toolkit 2008 copyright.
20 --------------------------------------------------------------------------*/
21
22 /**
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):
26
27  classname [ : superclass ] ; header.h ; vtkKit [; flags]
28
29  For each typedef, the output file will have a line like this:
30
31  name = &[2][3]* const type ; header.h ; vtkKit [; flags]
32
33  For each enum, the output file will have:
34
35  enumname : enum ; header.h ; vtkKit [; flags]
36
37 */
38
39 #ifndef VTK_PARSE_HIERARCHY_H
40 #define VTK_PARSE_HIERARCHY_H
41
42 /* Need the ValueInfo struct for typedefs */
43 #include "vtkParse.h"
44
45 /**
46  * One entry from the hierarchy file.
47  * It contains a class name, the superclasses, and the header file.
48  */
49 typedef struct _HierarchyEntry
50 {
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 */
65 } HierarchyEntry;
66
67 /**
68  * All the entries from a hierarchy file.
69  */
70 typedef struct _HierarchyInfo
71 {
72   int             NumberOfEntries;
73   HierarchyEntry *Entries;
74 } HierarchyInfo;
75
76 #ifdef __cplusplus
77 extern "C" {
78 #endif
79
80 /**
81  * Read a hierarchy file into a HeirarchyInfo struct, or return NULL
82  */
83 HierarchyInfo *vtkParseHierarchy_ReadFile(const char *filename);
84
85 /**
86  * Free a HierarchyInfo struct
87  */
88 void vtkParseHierarchy_Free(HierarchyInfo *info);
89
90 /**
91  * Return the entry for a class or type, or null if not found
92  */
93 HierarchyEntry *vtkParseHierarchy_FindEntry(
94   const HierarchyInfo *info, const char *classname);
95
96 /**
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"
101  */
102 const char *vtkParseHierarchy_GetProperty(
103   const HierarchyEntry *entry, const char *property);
104
105 /**
106  * Check whether class is derived from baseclass.
107  */
108 int vtkParseHierarchy_IsTypeOf(const HierarchyInfo *info,
109   const HierarchyEntry *entry, const char *baseclass);
110
111 /**
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.
119  */
120 int vtkParseHierarchy_IsTypeOfTemplated(const HierarchyInfo *info,
121   const HierarchyEntry *entry, const char *classname,
122   const char *baseclass, const char **baseclass_with_args);
123
124 /**
125  * Free the template args returned by IsTypeOfTemplated
126  */
127 void vtkParseHierarchy_FreeTemplateArgs(int n, const char *args[]);
128
129 /**
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()".
134  */
135 const char *vtkParseHierarchy_TemplatedSuperClass(
136   const HierarchyEntry *entry, const char *classname, int i);
137
138 /**
139  * Expand all unrecognized types in a ValueInfo struct by
140  * using the typedefs in the HierarchyInfo struct.
141  */
142 int vtkParseHierarchy_ExpandTypedefsInValue(
143   const HierarchyInfo *info, ValueInfo *data, const char *scope);
144
145 /**
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()".
149  */
150 const char *vtkParseHierarchy_ExpandTypedefsInName(
151   const HierarchyInfo *info, const char *text, const char *scope);
152
153 #ifdef __cplusplus
154 } /* extern "C" */
155 #endif
156
157 #endif