- Access to the member of an XPE structure
- by name
- by position
- Performing operations on groups of members of an XPE structure
- simple non-optimised access
- optimised access
- Determining the number of members in a structure
- Printing the names and values of all the members in a structure
- Creating a new structure
- an anonymous structure
- a named structure
accessing members of an XPE structure
- simple access to the member 'jack' of an XPE structure called 'fred'
XPE::VARIABLE member; member = XPE::get_variable("fred").get_member("jack");the contents of the member can now be accessed in a manor similar to any other XPE variable
- simple access to the first member of an XPE structure called 'fred'
(this is access by position and not by name)XPE::VARIABLE member; member = XPE::get_variable("fred").get_member(0);the contents of the member can now be accessed in a manor similar to any other XPE variable
Performing operations on groups of members of an XPE structure
- simple non-optimised access to an XPE structure called 'fred'
int x1, y1, x2, y2; x1 = XPE::get_variable("fred").get_member("x1").get_int(); y1 = XPE::get_variable("fred").get_member("y1").get_int(); x2 = XPE::get_variable("fred").get_member("x2").get_int(); y2 = XPE::get_variable("fred").get_member("y2").get_int();
- optimised access to an XPE structure called 'fred'
XPE::STRUCTURE xstruct; int x1, y1, x2, y2; xstruct = XPE::get_variable("fred").get_struct(); x1 = xstruct.get_member("x1").get_int(); y1 = xstruct.get_member("y1").get_int(); x2 = xstruct.get_member("x2").get_int(); y2 = xstruct.get_member("y2").get_int();
determining the number of members in a structure
int number_of_members; number_of_members = XPE::get_variable("fred").get_struct().get_len();
printing the names and values of all the members in a structure
XPE::STRUCTURE xstruct; XPE::VARIABLE member; int len; const char *name, *xstr; xstruct = XPE::get_variable("fred").get_struct(); len = xstruct.get_len(); for (int j=0; j<len; j++) { member = xstruct.get_member(j); name = member.get_name(); xstr = member.get_str(); printf("%d: '%s' = '%s'\n", j, name, xstr); }
creating a new structure
- an anonymous structure
XPE::STRUCTURE xstruct; xstruct.get_member("a") = (long)0; xstruct.get_member("b") = (long)0; xstruct.get_member("c") = (long)0;
- a named structure
XPE::get_variable("fred") = XPE::STRUCTURE(); XPE::get_variable("fred").get_member("a") = (long)0; XPE::get_variable("fred").get_member("b") = (long)0; XPE::get_variable("fred").get_member("c") = (long)0;