VTK
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vtkParseString.h
Go to the documentation of this file.
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 
41 typedef struct _StringCache
42 {
43  unsigned long NumberOfChunks;
44  char **Chunks;
45  size_t ChunkSize;
46  size_t Position;
47 } StringCache;
48 
53 
58 char *vtkParse_NewString(StringCache *cache, size_t n);
59 
66 const char *vtkParse_CacheString(StringCache *cache, const char *cp, size_t n);
67 
73 
74 #ifdef __cplusplus
75 } /* extern "C" */
76 #endif
77 
78 #endif
struct _StringCache StringCache
StringCache provides a simple way of allocating strings centrally.
unsigned long NumberOfChunks
const char * vtkParse_CacheString(StringCache *cache, const char *cp, size_t n)
Cache a string so that it can then be used in the vtkParse data structures.
char ** Chunks
void vtkParse_FreeStringCache(StringCache *cache)
Free all strings that were created with vtkParse_NewString() or with vtkParse_CacheString().
char * vtkParse_NewString(StringCache *cache, size_t n)
Alocate a new string from the cache.
void vtkParse_InitStringCache(StringCache *cache)
Initialize the string cache.
StringCache provides a simple way of allocating strings centrally.
size_t ChunkSize