]> SALOME platform Git repositories - modules/paravis.git/blob - src/ParaView/vtkParseExtras.h
Salome HOME
Merge from BR_PORTING_VTK6 01/03/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 "vtkParseData.h"
30 #include <stddef.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /**
37  * Skip over a sequence of characters that begin with an alphabetic
38  * character or an underscore, and include only alphanumeric
39  * characters or underscores. Return the number of characters.
40  */
41 size_t vtkParse_IdentifierLength(const char *text);
42
43 /**
44  * Skip over a name, including any namespace prefixes and
45  * any template arguments.  Return the number of characters.
46  * Examples are "name", "::name", "name<arg>", "name::name2",
47  * "::name::name2<arg1,arg2>".
48  */
49 size_t vtkParse_NameLength(const char *text);
50
51 /**
52  * Skip over a name, including any template arguments, but stopping
53  * if a '::' is encoutered.  Return the number of characters.
54  * Examples are "name" and "name<arg>"
55  */
56 size_t vtkParse_UnscopedNameLength(const char *text);
57
58 /**
59  * Skip over a literal, which may be a number, a char in single
60  * quotes, a string in double quotes, or a name, or a name followed
61  * by arguments in parentheses.
62  */
63 size_t vtkParse_LiteralLength(const char *text);
64
65 /**
66  * Get a type from a type name, and return the number of characters used.
67  * If the "classname" argument is not NULL, then it is used to return
68  * the short name for the type, e.g. "long int" becomes "long", while
69  * typedef names and class names are returned unchanged.  If "const"
70  * appears in the type name, then the const bit flag is set for the
71  * type, but "const" will not appear in the returned classname.
72  */
73 size_t vtkParse_BasicTypeFromString(
74   const char *text, unsigned int *type,
75   const char **classname, size_t *classname_len);
76
77 /**
78  * Generate a ValueInfo by parsing the type from the provided text.
79  * Only simple text strings are supported, e.g. "const T **".
80  * Returns the number of characters consumed.
81  */
82 size_t vtkParse_ValueInfoFromString(
83   ValueInfo *val, StringCache *cache, const char *text);
84
85 /**
86  * Generate a declaration string from a ValueInfo struct.  If the
87  * "nf" arg is set, the returned string must be freed.
88  * Only simple text strings are supported, e.g. "const T **".
89  * The variable or typedef name, if present, is ignored.
90  */
91 const char *vtkParse_ValueInfoToString(ValueInfo *val, int *nf);
92
93 /**
94  * Expand a typedef within a variable, parameter, or typedef declaration.
95  * The expansion is done in-place.
96  */
97 void vtkParse_ExpandTypedef(ValueInfo *valinfo, ValueInfo *typedefinfo);
98
99 /**
100  * Expand any unrecognized types within a variable, parameter, or typedef
101  * that match any of the supplied typedefs. The expansion is done in-place.
102  */
103 void vtkParse_ExpandTypedefs(
104   ValueInfo *valinfo, StringCache *cache,
105   int n, const char *name[], const char *val[],
106   ValueInfo *typedefinfo[]);
107
108 /**
109  * Wherever one of the specified names exists inside a Value or inside
110  * a Dimension size, replace it with the corresponding val string.
111  * This is used to replace constants with their values.
112  */
113 void vtkParse_ExpandValues(
114   ValueInfo *valinfo, StringCache *cache,
115   int n, const char *name[], const char *val[]);
116
117 /**
118  * Search and replace, return the initial string if no replacements
119  * occurred, else return a new string allocated with malloc. */
120 const char *vtkParse_StringReplace(
121   const char *str1, int n, const char *name[], const char *val[]);
122
123 /**
124  * Extract the class name and template args from a templated
125  * class type ID.  Returns the full number of characters that
126  * were consumed during the decomposition.
127  */
128 size_t vtkParse_DecomposeTemplatedType(
129   const char *text, const char **classname,
130   int n, const char ***args, const char *defaults[]);
131
132 /**
133  * Free the list of strings returned by ExtractTemplateArgs.
134  */
135 void vtkParse_FreeTemplateDecomposition(
136   const char *classname, int n, const char **args);
137
138 /**
139  * Instantiate a class template by substituting the provided arguments
140  * for the template parameters. If "n" is less than the number of template
141  * parameters, then default parameter values (if present) will be used.
142  * If an error occurs, the error will be printed to stderr and NULL will
143  * be returned.
144  */
145 void vtkParse_InstantiateClassTemplate(
146   ClassInfo *data, StringCache *cache, int n, const char *args[]);
147
148 /**
149  * Instantiate a function or class method template by substituting the
150  * provided arguments for the template parameters.  If "n" is less than
151  * the number of template parameters, then default parameter values
152  * (if present) will be used.  If an error occurs, the error will be
153  * printed to stderr and NULL will be returned.
154  */
155 void vtkParse_IntantiateFunctionTemplate(
156   FunctionInfo *data, int n, const char *args[]);
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