VTK
|
#include <stddef.h>
Go to the source code of this file.
Classes | |
struct | _StringTokenizer |
A struct for going through a string one token at a time. More... | |
struct | _StringCache |
StringCache provides a simple way of allocating strings centrally. More... | |
Defines | |
#define | vtkParse_CharType(c, bits) ((parse_charbits[(unsigned char)(c)] & (bits)) != 0) |
Macro to check if a char is of a certain type. | |
Typedefs | |
typedef enum _parse_char_type | parse_char_type |
This file provides string handling routines. | |
typedef enum _parse_space_t | parse_space_t |
Whitespace types that can be used with the tokenizer. | |
typedef enum _preproc_token_t | preproc_token_t |
Preprocessor tokens for C++. | |
typedef struct _StringTokenizer | StringTokenizer |
A struct for going through a string one token at a time. | |
typedef struct _StringCache | StringCache |
StringCache provides a simple way of allocating strings centrally. | |
Enumerations | |
enum | _parse_char_type { CPRE_ID = 0x01, CPRE_DIGIT = 0x02, CPRE_IDGIT = 0x03, CPRE_HEX = 0x04, CPRE_EXP = 0x08, CPRE_SIGN = 0x10, CPRE_QUOTE = 0x20, CPRE_HSPACE = 0x40, CPRE_VSPACE = 0x80, CPRE_WHITE = 0xC0 } |
This file provides string handling routines. More... | |
enum | _parse_space_t { WS_DEFAULT = CPRE_WHITE, WS_PREPROC = CPRE_HSPACE, WS_COMMENT = (CPRE_WHITE | 0x100) } |
Whitespace types that can be used with the tokenizer. More... | |
enum | _preproc_token_t { TOK_OTHER = 257, TOK_ID, TOK_CHAR, TOK_STRING, TOK_NUMBER, TOK_COMMENT, TOK_DBLHASH, TOK_SCOPE, TOK_INCR, TOK_DECR, TOK_RSHIFT, TOK_LSHIFT, TOK_AND, TOK_OR, TOK_EQ, TOK_NE, TOK_GE, TOK_LE, TOK_ADD_EQ, TOK_SUB_EQ, TOK_MUL_EQ, TOK_DIV_EQ, TOK_MOD_EQ, TOK_AND_EQ, TOK_OR_EQ, TOK_XOR_EQ, TOK_ARROW, TOK_DOT_STAR, TOK_ARROW_STAR, TOK_RSHIFT_EQ, TOK_LSHIFT_EQ, TOK_ELLIPSIS } |
Preprocessor tokens for C++. More... | |
Functions | |
void | vtkParse_InitTokenizer (StringTokenizer *tokens, const char *text, parse_space_t wstype) |
Initialize the tokenizer and get the first token. | |
int | vtkParse_NextToken (StringTokenizer *tokens) |
Return the next preprocessor token, or '0' if none left. | |
size_t | vtkParse_SkipWhitespace (const char *cp, parse_space_t spacetype) |
Skip over whitespace. | |
size_t | vtkParse_SkipComment (const char *cp) |
Skip over a comment, C style or C++ style. | |
size_t | vtkParse_SkipQuotes (const char *cp) |
Skip over a string in double or single quotes. | |
size_t | vtkParse_SkipNumber (const char *cp) |
Skip over a number. | |
size_t | vtkParse_SkipId (const char *cp) |
Skip over an identifier. | |
unsigned int | vtkParse_HashId (const char *cp) |
Compute the hash for a id, for use in hash table lookups. | |
void | vtkParse_InitStringCache (StringCache *cache) |
Initialize the string cache. | |
char * | vtkParse_NewString (StringCache *cache, size_t n) |
Alocate a new string from the cache. | |
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. | |
void | vtkParse_FreeStringCache (StringCache *cache) |
Free all strings that were created with vtkParse_NewString() or with vtkParse_CacheString(). | |
Variables | |
unsigned char | parse_charbits [256] |
Character type lookup table. |
#define vtkParse_CharType | ( | c, | |
bits | |||
) | ((parse_charbits[(unsigned char)(c)] & (bits)) != 0) |
Macro to check if a char is of a certain type.
Definition at line 77 of file vtkParseString.h.
typedef enum _parse_char_type parse_char_type |
This file provides string handling routines.
The two important jobs done by these routines are string tokenization and string cacheing.
Tokenization is done as per the rules of a C++ preprocessor, and breaks the strings into ids, literals, and operators. Any string is a valid input for the tokenizer, and it is up to the parser to decide if the resulting tokens are valid within the grammar. The two primary tokenization functions are vtkParse_InitTokenizer() and vtkParse_NextToken().
Cacheing refers to how string memory management is done. The parser uses "const char *" for all strings, and expects all strings to be persistent and constant. These conditions are automatically met by static strings, but dynamically-generated strings must be cached until the parse is complete. The primary cacheing functions are vtkParse_CacheString() and vtkParse_FreeStringCache(). Various important char types for tokenization
typedef enum _parse_space_t parse_space_t |
Whitespace types that can be used with the tokenizer.
typedef enum _preproc_token_t preproc_token_t |
Preprocessor tokens for C++.
typedef struct _StringTokenizer StringTokenizer |
A struct for going through a string one token at a time.
If ws is set to WS_PREPROC, then tokenization stops when a newline or null is encountered. If ws is set to WS_DEFAULT, then tokenization only stops when a null is encountered. If ws is set to WS_COMMENT, then tokenization stops only when a null is encountered, and comments are returned as tokens instead of being skipped as whitespace.
typedef struct _StringCache StringCache |
StringCache provides a simple way of allocating strings centrally.
It eliminates the need to allocate and free each individual string, which makes the code simpler and more efficient.
enum _parse_char_type |
This file provides string handling routines.
The two important jobs done by these routines are string tokenization and string cacheing.
Tokenization is done as per the rules of a C++ preprocessor, and breaks the strings into ids, literals, and operators. Any string is a valid input for the tokenizer, and it is up to the parser to decide if the resulting tokens are valid within the grammar. The two primary tokenization functions are vtkParse_InitTokenizer() and vtkParse_NextToken().
Cacheing refers to how string memory management is done. The parser uses "const char *" for all strings, and expects all strings to be persistent and constant. These conditions are automatically met by static strings, but dynamically-generated strings must be cached until the parse is complete. The primary cacheing functions are vtkParse_CacheString() and vtkParse_FreeStringCache(). Various important char types for tokenization
CPRE_ID | |
CPRE_DIGIT | |
CPRE_IDGIT | |
CPRE_HEX | |
CPRE_EXP | |
CPRE_SIGN | |
CPRE_QUOTE | |
CPRE_HSPACE | |
CPRE_VSPACE | |
CPRE_WHITE |
Definition at line 55 of file vtkParseString.h.
enum _parse_space_t |
Whitespace types that can be used with the tokenizer.
Definition at line 86 of file vtkParseString.h.
enum _preproc_token_t |
Preprocessor tokens for C++.
Definition at line 96 of file vtkParseString.h.
void vtkParse_InitTokenizer | ( | StringTokenizer * | tokens, |
const char * | text, | ||
parse_space_t | wstype | ||
) |
Initialize the tokenizer and get the first token.
int vtkParse_NextToken | ( | StringTokenizer * | tokens | ) |
Return the next preprocessor token, or '0' if none left.
size_t vtkParse_SkipWhitespace | ( | const char * | cp, |
parse_space_t | spacetype | ||
) |
Skip over whitespace.
Return the number of chars until the first non-whitespace token. Set spacetype to WS_DEFAULT, WS_PREPROC, or WS_COMMENT.
size_t vtkParse_SkipComment | ( | const char * | cp | ) |
Skip over a comment, C style or C++ style.
Return the number of chars until the end of the comment.
size_t vtkParse_SkipQuotes | ( | const char * | cp | ) |
Skip over a string in double or single quotes.
Return the number of chars until the end of the quotes.
size_t vtkParse_SkipNumber | ( | const char * | cp | ) |
Skip over a number.
Uses preprocessor semantics. Return the number of chars until the end of the number.
size_t vtkParse_SkipId | ( | const char * | cp | ) |
Skip over an identifier.
Return the number of chars until the end of the identifier.
unsigned int vtkParse_HashId | ( | const char * | cp | ) |
Compute the hash for a id, for use in hash table lookups.
This stops at the first non-Id character, so it is safe to use on a string that is not null-terminated as long as there is either whitespace or an operator character before the end of the string. It can be used on null-terminated strings as well, of course.
void vtkParse_InitStringCache | ( | StringCache * | cache | ) |
Initialize the string cache.
char* vtkParse_NewString | ( | StringCache * | cache, |
size_t | n | ||
) |
Alocate a new string from the cache.
A total of n+1 bytes will be allocated, to leave room for null.
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.
The string will last until the application exits. At most 'n' chars will be copied, and the string will be terminated. If a null pointer is provided, then a null pointer will be returned.
void vtkParse_FreeStringCache | ( | StringCache * | cache | ) |
Free all strings that were created with vtkParse_NewString() or with vtkParse_CacheString().
unsigned char parse_charbits[256] |
Character type lookup table.