All XPE values are tagged to indicate the type of value that they hold. (see types for a discussion on the types of values that can be stored and manipulated).
- Simple access to XPE value
- as an integer
- as a float
- as a string
- Converting a basic C value to an XPE value
- C integer to XPE integer
- C float to XPE float
- C string to XPE string
- Coercion from a basic C value to an XPE value
- C integer to XPE integer
- C float to XPE float
- C string to XPE string
- Access to XPE value depending on type
- Accessing an element from an XPE array value
- as an integer element
- as a float element
- as a string element
- as an XPE value element
- as an XPE variable element
- Accessing a member of an XPE structure value
- as an integer member
- as a float member
- as a string member
- as an XPE value member
- as an XPE variable member
simple access to XPE value
given the XPE value xval is defined as:
XPE::VALUE xvalThen access will be:
converting a basic C value to an XPE value
given the XPE value xval is defined as:
XPE::VALUE xvalThen access will be:
coercion from a basic C value to an XPE value
access to XPE value depending on type
given the XPE value xval is defined as:
Then access will be:XPE::VALUE xvalint xint; float xfloat; const char *xstr; switch (xval.get_type()) { case XPE::VALUE_INT: // using xval as an integer xint = xval.get_int(); printf("xval is an int (%d)\n", xint); break; case XPE::VALUE_FLOAT: // using xval as a float xfloat = xval.get_float(); printf("xval is a float (%f)\n", xfloat) break; case XPE::VALUE_STR: // using xval as a string xstr = xval.get_str(); printf("xval is a string (%s)\n", xstr); break; default: // do nothing printf("xval is of type %d\n", xval.get_type()); }
accessing an element from an XPE array value
given the XPE value xval is defined as:
XPE::VALUE xvalThen access will be:
- using xval as an XPE array of integers
int xint; xint = xval.get_array().get_element(n1).get_int();
- using xval as an XPE array of floats
float xfloat; xfloat = xval.get_array().get_element(n1).get_float();
- using xval as an XPE array of strings
const char *xstr; xstr = xval.get_array().get_element(n1).get_str();
- using xval as an XPE array of XPE values
xval = xval.get_array().get_element(n1).get_xvalue();The value xval can now be further accessed again as an XPE value
- using xval as an XPE array of XPE variables
XPE::VARIABLE xvar; xvar = xval.get_array().get_element(n1);The variable xvar can now be further accessed as an XPE variable
accessing a member of an XPE structure value
given the XPE value xval is defined as:
XPE::VALUE xvalThen access will be:
- using xval as an XPE structure that has integer member 'jack'
int xint; xint = xval.get_struct().get_member("jack").get_int();
- using xval as an XPE structure that has float member 'jack'
float xfloat; xfloat = xval.get_struct().get_member("jack").get_float();
- using xval as an XPE structure that has string member 'jack'
const char *xstr; xstr = xval.get_struct().get_member("jack").get_str();
- using xval as an XPE structure that has an XPE value member 'jack'
xval = xval.get_struct().get_member("jack").get_xvalue();The value xval can now be further accessed again as an XPE value
- using xval as an XPE structure that has an XPE variable member 'jack'
XPE::VARIABLE xvar; xvar = xval.get_struct().get_member("jack");The variable xvar can now be further accessed as an XPE variable