libSBML C++ API
5.18.0
|
A Token_t token has a type
and a value
. The value
field is a union of different possible members; the member that holds the value for a given token (and thus the name of the member that is to be accessed programmatically) depends on the value of the TokenType_t
field type
. The following table lists the possible scenarios:
Value of the field type | Member within value to use |
---|---|
TT_NAME | name |
TT_INTEGER | integer |
TT_REAL | real |
TT_REAL _E | real and exponent |
Anything else | ch |
If this token encodes a real number in e-notation, type
will be TT_REAL_E
instead of TT_REAL
. The field value.real
will then contain the mantissa, and the separate field named exponent
will contain (can you guess?) the exponent. For example, if we have a pointer to a structure named t
, then the representation for "1.2e3
" will be:
t->type = TT_REAL_E; t->value.real = 1.2; t->exponent = 3;
When the type
has a value of TT_UNKNOWN
, the field ch
will contain the unrecognized character. When the type is TT_END
, the field ch
will contain '\0'
. For all others, the value.ch
will contain the corresponding character.
Public Attributes | |
long | exponent |
TokenType_t | type |
union { | |
char ch | |
long integer | |
char * name | |
double real | |
} | value |
char Token_t::ch |
Member used when the token is a character.
long Token_t::exponent |
Secondary field used when the token is a real in e-notation.
long Token_t::integer |
Member used when the token is an integer.
char* Token_t::name |
Member used when the token is a symbol.
double Token_t::real |
Member used when the token is a real.
TokenType_t Token_t::type |
This token's type.
union { ... } Token_t::value |
Value of the token.