ZEDA  1.6.18
Macros | Functions
tokenization.

Macros

#define zIsWS(c)   ( (c) == ' ' || (c) == '\t' )
 check if a charactor is the whitespace. More...
 
#define zIsQuotation(c)   ( (c) == '\'' || (c) == '\"' )
 check if a charactor is a quotation mark. More...
 
#define ZDEFAULT_COMMENT_IDENT   '%'
 

Functions

void zSetDelimiter (char s[])
 specify a delimiter set. More...
 
void zResetDelimiter (void)
 reset a delimiter set. More...
 
void zSetOperator (char s[])
 specify an operator set. More...
 
void zResetOperator (void)
 reset an operator set. More...
 
bool zIsIncludedChar (char c, char *s)
 check if a charactor is included in a specified set. More...
 
bool zIsDelimiter (char c)
 check if a charactor is a delimiter. More...
 
bool zIsOperator (char c)
 check if a charactor is an operator. More...
 
bool zStrIsHex (char *str)
 check if a string represents a hexadecimal number. More...
 
char zFSkipWS (FILE *fp)
 skip whitespaces in a file. More...
 
char * zSSkipWS (char *str)
 skip whitespaces in a string. More...
 
char zFSkipIncludedChar (FILE *fp, char *s)
 skip a certain charactors in a stream. More...
 
char * zSSkipIncludedChar (char *str, char *s)
 skip a certain charactors in a string. More...
 
char zFSkipDelimiter (FILE *fp)
 skip delimiter in a file. More...
 
char * zSSkipDelimiter (char *str)
 skip delimiter in a string. More...
 
void zSetCommentIdent (char ident)
 specify the comment identifier. More...
 
void zResetCommentIdent (void)
 reset the comment identifier. More...
 
char zFSkipComment (FILE *fp)
 skip comments. More...
 
char * zFToken (FILE *fp, char *tkn, size_t size)
 tokenize a file. More...
 
char * zSTokenSkim (char *str, char *tkn, size_t size)
 tokenize a string. More...
 
char * zSToken (char *str, char *tkn, size_t size)
 
char * zFIntToken (FILE *fp, char *tkn, size_t size)
 tokenize an integer value in a file. More...
 
char * zFNumToken (FILE *fp, char *tkn, size_t size)
 tokenize a real number in a file. More...
 
char * zSIntToken (char *str, char *tkn, size_t size)
 tokenize an integer value in a string. More...
 
char * zSNumToken (char *str, char *tkn, size_t size)
 tokenize a real number in a string. More...
 
char * zFInt (FILE *fp, int *val)
 get an integer value from file. More...
 
char * zSInt (char *str, int *val)
 get an integer value from a string. More...
 
char * zFDouble (FILE *fp, double *val)
 get a d-float value in a file. More...
 
char * zSDouble (char *str, double *val)
 get a d-float value in a string. More...
 

Detailed Description

Macro Definition Documentation

◆ zIsWS

#define zIsWS (   c)    ( (c) == ' ' || (c) == '\t' )

check if a charactor is the whitespace.

zIsWS() is a boolean. It is the true value if a charactor c is either the whitespace or the tab charactor.

◆ zIsQuotation

#define zIsQuotation (   c)    ( (c) == '\'' || (c) == '\"' )

check if a charactor is a quotation mark.

zIsQuotation() is a boolean. It is the true value if c is either ' or ".

◆ ZDEFAULT_COMMENT_IDENT

#define ZDEFAULT_COMMENT_IDENT   '%'

Function Documentation

◆ zSetDelimiter()

void zSetDelimiter ( char  s[])

specify a delimiter set.

zSetDelimiter() specifies a delimiter set for s. It works for tokenization functions. To reset the delimiter set, call zResetDelimiter().

See also
zResetDelimiter, zIsDelimiter, zFSkipDelimiter, zSSkipDelimiter

◆ zResetDelimiter()

void zResetDelimiter ( void  )

reset a delimiter set.

zResetDelimiter() resets a delimiter set. The default delimiter set includes: whitespace, tab \t, new line \n, carriage return \r, comma, colon :, semi-colon ;, vertical bar |, parenthesis (), brace {}, null character \0 and end of file EOF.

They work for tokenization functions.

See also
zSetDelimiter, zIsDelimiter, zFSkipDelimiter, zSSkipDelimiter

◆ zSetOperator()

void zSetOperator ( char  s[])

specify an operator set.

zSetOperator() specifies an operator set for s. It works for tokenization functions. To reset the operator set, call zResetOperator().

See also
zResetOperator, zIsOperator

◆ zResetOperator()

void zResetOperator ( void  )

reset an operator set.

zResetOperator() resets an operator set. The default operator set includes: exclamation !, percent %, ampasand &, asterisk *, plus +, minus -, slash /, more than <, equal =, less than >, question ?, at-mark @, back slash \, carat ^ and tilde ~

They work for tokenization functions.

See also
zSetOperator, zIsOperator

◆ zIsIncludedChar()

bool zIsIncludedChar ( char  c,
char *  s 
)

check if a charactor is included in a specified set.

zIsIncludedChar() checks if a charactor c is included in a charactor set s.

Returns
if c is included in s, the true value is returned. Otherwise, the false value is returned.
Note
The charactor set s must be terminated by the null charactor '\0'. Also, note that s is automatically terminated by the null charactor if it is a string.

◆ zIsDelimiter()

bool zIsDelimiter ( char  c)

check if a charactor is a delimiter.

zIsDelimiter() checks if a charactor c is a delimiter, namely, if c is included in the delimiter set defined by zSetDelimiter().

Returns
if c is a delimiter, the true value is returned. Otherwise, the false value is returned.
See also
zSetDelimiter, zResetDelimiter

◆ zIsOperator()

bool zIsOperator ( char  c)

check if a charactor is an operator.

zIsOperator() checks if a charactor c is an operator, namely, if c is included in the operator set defined by zSetOperator().

Returns
if c is an operator, the true value is returned. Otherwise, the false value is returned.
See also
zSetOperator, zResetOperator

◆ zStrIsHex()

bool zStrIsHex ( char *  str)

check if a string represents a hexadecimal number.

zStrIsHex() checks if a string pointed by str represents a hexadecimal number, namely, if str consists only of numbers and a-f alphabets.

Returns
the result is returned as a boolean.
Note
zStrIsHex() does not recognize a signed value in hex-style. Namely, a string beginning with a sign such as -ffff is not regarded as a number.

◆ zFSkipWS()

char zFSkipWS ( FILE *  fp)

skip whitespaces in a file.

zFSkipWS() skips whitespaces in a file fp from the current position.

Returns
zFSkipWS() returns the first charactor which is not a whitespace appeared in fp. If the file reaches EOF, the null charactor '\0' is returned.

◆ zSSkipWS()

char* zSSkipWS ( char *  str)

skip whitespaces in a string.

zSSkipWS() skips whitespaces in a string str from the current position.

Returns
zSSkipWS() returns a pointer to the first charactor which is not a whitespace appeared in str. If all the rest charactors of str are whitespaces, the null pointer is returned.

◆ zFSkipIncludedChar()

char zFSkipIncludedChar ( FILE *  fp,
char *  s 
)

skip a certain charactors in a stream.

zFSkipIncludedChar() skips charactors in a specified set s from the current position of a file referred by fp.

Returns
zFSkipIncludedChar() returns the first charactor which is not included s. If the file reaches EOF, the null charactor '\0' is returned.

◆ zSSkipIncludedChar()

char* zSSkipIncludedChar ( char *  str,
char *  s 
)

skip a certain charactors in a string.

zSSkipIncludedChar() skips charactors in a specified set s from the current position of a string str.

Returns
zSSkipIncludedChar() returns a pointer to the first charactor which is not included in s. If all the rest charactors of str are whitespaces, the null pointer is returned.

◆ zFSkipDelimiter()

char zFSkipDelimiter ( FILE *  fp)

skip delimiter in a file.

zFSkipDelimiter() skips delimiters in a file fp from the current position.

Returns
zFSkipDelimiter() returns the first charactor which is not a delimiter appeared in fp. If the file reaches EOF, the null charactor '\0' is returned.

◆ zSSkipDelimiter()

char* zSSkipDelimiter ( char *  str)

skip delimiter in a string.

zSSkipDelimiter() skips delimiters in a string str from the current position.

Returns
zSSkipDelimiter() returns a pointer to the first charactor which is not a delimiter appeared in str. If all the rest charactors of str are whitespaces, the null pointer is returned.

◆ zSetCommentIdent()

void zSetCommentIdent ( char  ident)

specify the comment identifier.

◆ zResetCommentIdent()

void zResetCommentIdent ( void  )

reset the comment identifier.

◆ zFSkipComment()

char zFSkipComment ( FILE *  fp)

skip comments.

zFSkipComment() skips comments, i.e., a one-line string which begins with a specified identifier, in a file fp. Vague lines are also skipped. The identifier can be set by zSetCommentIdent() and be reset by zResetCommentIdent().

Returns
zFSkipComment() returns the next charactor to the last comment, which is put back to the file. If the file reaches EOF, the null charactor is returned.
See also
zSetCommentIdent, zResetCommentIdent

◆ zFToken()

char* zFToken ( FILE *  fp,
char *  tkn,
size_t  size 
)

tokenize a file.

zFToken() acquires a first token in a file fp appearing from the current position, and copies it where tkn points. Token is a charactor set segmented by a delimiter, charactors enclosed in quotation marks or double quotation marks. The token size is limited up to size. If the first quotation mark does not have a corresponding closing mark, the token buffer is filled with the rest charactors in the file.

Returns
zFToken() returns a pointer tkn. If a token is not found, the null pointer is returned.
See also
zSetDelimiter, zIsDelimiter, zSToken
Note
If the size of buffer pointed by tkn is less than size, anything might happen.

◆ zSTokenSkim()

char* zSTokenSkim ( char *  str,
char *  tkn,
size_t  size 
)

tokenize a string.

zSToken() acquires the first token in a string str and copies it where tkn points. Token is a charactor set segmented by a delimiter, charactors enclosed in quotation marks or double quotation marks. The token size is limited up to size. If the first quotation mark does not have a corresponding closing mark, the token buffer is filled with the rest charactors in the string. str is overridden by the remaining string destructively.

zSTokenSkim() also acquires the first token in a string str and copies it where tkn points. The difference from zSToken() is that it returns a pointer immediately after tkn in str and does not destroy str.

Returns
zSToken() returns a pointer tkn. If a token is not found, the null pointer is returned.

zSTokenSkim() returns a pointer immediately after tkn, which corresponds to a charactor in str.

See also
zSetDelimiter, zIsDelimiter, zFToken
Note
If the size of buffer pointed by tkn is less than size, anything might happen.

◆ zSToken()

char* zSToken ( char *  str,
char *  tkn,
size_t  size 
)

◆ zFIntToken()

char* zFIntToken ( FILE *  fp,
char *  tkn,
size_t  size 
)

tokenize an integer value in a file.

zFIntToken() tokenizes an integer value in a file fp from the current position, and puts it where tkn points. size is the size of tkn. The charactors beyond size are truncated.

Returns
the pointer tkn is returned.

◆ zFNumToken()

char* zFNumToken ( FILE *  fp,
char *  tkn,
size_t  size 
)

tokenize a real number in a file.

zFNumToken() tokenizes a real number in a file fp from the current position, and puts it where tkn points. size is the size of tkn. The charactors beyond size are truncated.

Returns
the pointer tkn is returned.

◆ zSIntToken()

char* zSIntToken ( char *  str,
char *  tkn,
size_t  size 
)

tokenize an integer value in a string.

zSIntToken() tokenizes an integer value in a string str, and puts it where tkn points. size is the size of tkn. The charactors beyond size are truncated. str is overridden by the remaining string destructively.

Returns
the pointer tkn is returned.

◆ zSNumToken()

char* zSNumToken ( char *  str,
char *  tkn,
size_t  size 
)

tokenize a real number in a string.

zSNumToken() tokenizes a real number in a string str, and puts it where tkn points. size is the size of tkn. The charactors beyond size are truncated. str is overridden by the remaining string destructively.

Returns
the pointer tkn is returned.

◆ zFInt()

char* zFInt ( FILE *  fp,
int *  val 
)

get an integer value from file.

zFInt() acquires an integer value in a file fp from the current position. If no integer value is recognized at the current position, zero is returned.

◆ zSInt()

char* zSInt ( char *  str,
int *  val 
)

get an integer value from a string.

zSInt() acquires an integer value in a string str. If no integer value is recognized at the head of the string, zero is returned.

◆ zFDouble()

char* zFDouble ( FILE *  fp,
double *  val 
)

get a d-float value in a file.

zFDouble() acquires a double-precision floating-point value in a file fp from the current position. If no value is recognized at the current position, zero is returned.

◆ zSDouble()

char* zSDouble ( char *  str,
double *  val 
)

get a d-float value in a string.

zSDouble() acquires a double-precision floating-point value in a string str. If no value is recognized at the head of the string, zero is returned.