Salome HOME
Minor: removing annoying print message
[modules/paravis.git] / src / VTKWrapping / ParaView / vtkParseString.h
1 /*=========================================================================
2
3   Program:   Visualization Toolkit
4   Module:    vtkParseString.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 /*
17   String allocation routines used by vtkParse.
18
19   The parser uses "const char *" as its string object type, and expects
20   all string objects to persist and be constant for the entire lifetime
21   of the data generated by the parse (usually this means until the parser
22   executable has exited).  All strings that are stored in the parser's
23   data objects should either be statically allocated, or allocated with
24   the vtkParse_NewString() or vtkParse_CacheString() methods declared here.
25 */
26
27 #ifndef VTK_PARSE_STRING_H
28 #define VTK_PARSE_STRING_H
29
30 #include <stddef.h>
31
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
35
36 /**
37  * StringCache provides a simple way of allocating strings centrally.
38  * It eliminates the need to allocate and free each individual strings,
39  * which makes the code simpler and more efficient.
40  */
41 typedef struct _StringCache
42 {
43   unsigned long  NumberOfChunks;
44   char         **Chunks;
45   size_t         ChunkSize;
46   size_t         Position;
47 } StringCache;
48
49 /**
50  * Initialize the string cache.
51  */
52 void vtkParse_InitStringCache(StringCache *cache);
53
54 /**
55  * Alocate a new string from the cache.
56  * A total of n+1 bytes will be allocated, to leave room for null.
57  */
58 char *vtkParse_NewString(StringCache *cache, size_t n);
59
60 /**
61  * Cache a string so that it can then be used in the vtkParse data
62  * structures.  The string will last until the application exits.
63  * At most 'n' chars will be copied, and the string will be terminated.
64  * If a null pointer is provided, then a null pointer will be returned.
65  */
66 const char *vtkParse_CacheString(StringCache *cache, const char *cp, size_t n);
67
68 /**
69  * Free all strings that were created with vtkParse_NewString() or
70  * with vtkParse_CacheString().
71  */
72 void vtkParse_FreeStringCache(StringCache *cache);
73
74 #ifdef __cplusplus
75 } /* extern "C" */
76 #endif
77
78 #endif