Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

tokenize.h File Reference


Typedefs

typedef enum etok_type_ etok_type

Enumerations

enum  etok_type_ {
  ETOK_SUCCESS, ETOK_REGCOMP, ETOK_MEMORY, ETOK_NOMATCH,
  ETOK_ESPACE
}

Functions

etok_type tokenize (const char *pattern, const char *a_string, size_t *ntokens, char ***ptokens)
void free_tokens (size_t ntokens, char **tokens)

Typedef Documentation

typedef enum etok_type_ etok_type
 

enumeration of tokenize return codes


Enumeration Type Documentation

enum etok_type_
 

enumeration of tokenize return codes

Enumeration values:
ETOK_SUCCESS  tokenize call was successfull, a_string matched the regexp 'pattern'
ETOK_REGCOMP  tokenize call failed on the compilation of the regexp 'pattern' (maybe 'pattern' is not a valid regexp)
ETOK_MEMORY  tokenize call failed on an internal calloc call
ETOK_NOMATCH  tokenize call failed, a_string did not match the regexp 'pattern'
ETOK_ESPACE  tokenize call failed on an internal regexec call


Function Documentation

void free_tokens size_t  ntokens,
char **  tokens
 

frees the array of tokens allocated and filled by tokenize

etok_type tokenize const char *  pattern,
const char *  a_string,
size_t *  ntokens,
char ***  ptokens
 

a low-level function to parse 'a_string' using the regexp 'pattern', into an array of tokens (see below); essentially called by parse_argument

Parameters:
pattern (input) the regexp to be matched by 'a_string'
a_string (input) the string to parse
ntokens (output) a pointer to the number of tokens returned by the parsing
ptokens (output) a pointer to the array of tokens returned by the parsing (is allocated by tokenize and must be freed by the caller with free_tokens);
A example will help to explain what this function actually does :
  • size_t ntokens;
  • char **tokens;
  • tokenize(pattern, a_string, &ntokens, &tokens);

After this call :

  • tokens[0] will contain the entire string 'a_string' if it matched the regexp 'pattern';
  • if the regexp 'pattern' contains sub-regexp (between parenthesis), tokens[i] will contain the substring of 'a_string' matching the i-th sub-regexp

See also:
parse_argument


Generated on Wed Apr 19 17:05:06 2006 for Remap by  doxygen 1.3.9.1