Salome HOME
Merge from V6_main 11/02/2013
[modules/paravis.git] / src / ParaView / vtkParseExtras.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    vtkParseExtras.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) 2011 David Gobbi.
17
18   Contributed to the VisualizationToolkit by the author in May 2011
19   under the terms of the Visualization Toolkit 2008 copyright.
20 -------------------------------------------------------------------------*/
21
22 /**
23  * This file contains extra utilities for parsing and wrapping.
24  */
25
26 #ifndef VTK_PARSE_EXTRAS_H
27 #define VTK_PARSE_EXTRAS_H
28
29 #include "vtkParse.h"
30
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34
35 /**
36  * Skip over a sequence of characters that begin with an alphabetic
37  * character or an underscore, and include only alphanumeric
38  * characters or underscores. Return the number of characters.
39  */
40 size_t vtkParse_IdentifierLength(const char *text);
41
42 /**
43  * Skip over a name, including any namespace prefixes and
44  * any template arguments.  Return the number of characters.
45  */
46 size_t vtkParse_NameLength(const char *text);
47
48 /**
49  * Skip over a name, including any template parameters, but stopping
50  * if a '::' is encoutered.  Return the number of characters.
51  */
52 size_t vtkParse_UnscopedNameLength(const char *text);
53
54 /**
55  * Skip over a literal, which may be a number, a char in single
56  * quotes, a string in double quotes, or a name, or a name followed
57  * by arguments in parentheses.
58  */
59 size_t vtkParse_LiteralLength(const char *text);
60
61 /**
62  * Get a type from a type name, and return the number of characters used.
63  * If the "classname" argument is not NULL, then it is used to return
64  * the short name for the type, e.g. "long int" becomes "long", while
65  * typedef names and class names are returned unchanged.  If "const"
66  * appears in the type name, then the const bit flag is set for the
67  * type, but "const" will not appear in the returned classname.
68  */
69 size_t vtkParse_BasicTypeFromString(
70   const char *text, unsigned int *type,
71   const char **classname, size_t *classname_len);
72
73 /**
74  * Generate a ValueInfo by parsing the type from the provided text.
75  * Only simple text strings are supported, e.g. "const T **".
76  */
77 void vtkParse_ValueInfoFromString(ValueInfo *val, const char *text);
78
79 /**
80  * Expand a typedef within a variable, parameter, or typedef declaration.
81  * The expansion is done in-place.
82  */
83 void vtkParse_ExpandTypedef(ValueInfo *valinfo, ValueInfo *typedefinfo);
84
85 /**
86  * Expand any unrecognized types within a variable, parameter, or typedef
87  * that match any of the supplied typedefs. The expansion is done in-place.
88  */
89 void vtkParse_ExpandTypedefs(
90   ValueInfo *valinfo, int n, const char *name[], const char *val[],
91   ValueInfo *typedefinfo[]);
92
93 /**
94  * Wherever one of the specified names exists inside a Value or inside
95  * a Dimension size, replace it with the corresponding val string.
96  * This is used to replace constants with their values.
97  */
98 void vtkParse_ExpandValues(
99   ValueInfo *valinfo, int n, const char *name[], const char *val[]);
100
101 /**
102  * Search for all occurences of "name" and replace with the corresponding
103  * "val", return the initial string if no replacements occurred, otherwise
104  * return a new string allocated with malloc.
105  */
106 const char *vtkParse_StringReplace(
107   const char *str1, int n, const char *name[], const char *val[]);
108
109 /**
110  * Extract the class name and template args from a templated
111  * class type ID.  Returns the full number of characters that
112  * were consumed during the decomposition.
113  */
114 size_t vtkParse_DecomposeTemplatedType(
115   const char *text, const char **classname,
116   int n, const char ***args, const char *defaults[]);
117
118 /**
119  * Free the list of strings returned by ExtractTemplateArgs.
120  */
121 void vtkParse_FreeTemplateDecomposition(
122   const char *classname, int n, const char **args);
123
124 /**
125  * Instantiate a class template by substituting the provided arguments
126  * for the template parameters. If "n" is less than the number of template
127  * parameters, then default parameter values (if present) will be used.
128  * If an error occurs, the error will be printed to stderr and NULL will
129  * be returned.
130  */
131 void vtkParse_InstantiateClassTemplate(
132   ClassInfo *data, int n, const char *args[]);
133
134 /**
135  * Instantiate a function or class method template by substituting the
136  * provided arguments for the template parameters.  If "n" is less than
137  * the number of template parameters, then default parameter values
138  * (if present) will be used.  If an error occurs, the error will be
139  * printed to stderr and NULL will be returned.
140  */
141 void vtkParse_IntantiateFunctionTemplate(
142   FunctionInfo *data, int n, const char *args);
143
144 /**
145  * Generate a mangled name for a type, use gcc ia64 ABI.
146  * The result is placed in new_name, which must be large enough
147  * to accept the result.
148  */
149 size_t vtkParse_MangledTypeName(const char *name, char *new_name);
150
151 /**
152  * Generate a mangled name for a literal.  Only handles decimal
153  * integer literals.  It guesses type from suffix "u", "ul",
154  * "ull", "l", "ll" so only certain types are supported.
155  */
156 size_t vtkParse_MangledLiteral(const char *name, char *new_name);
157
158 /**
159  * Get a zero-terminated array of the types in vtkTemplateMacro.
160  */
161 const char **vtkParse_GetTemplateMacroTypes();
162
163 /**
164  * Get a zero-terminated array of the types in vtkArray.
165  */
166 const char **vtkParse_GetArrayTypes();
167
168
169 #ifdef __cplusplus
170 } /* extern "C" */
171 #endif
172
173 #endif