Synopsis
OMobj_id OMfind_str_subobj (
const char * subobject_path,
int mode );
Description
OMfind_str_subobj returns the id of any subobject of ancestor . subobject_path is the object's V pathname relative to ancestor . The mode parameter indicates how the process intends to use the object.
Arguments
ancestor
The id of an ancestor (parent, grandparent, etc.) of the object you are seeking.
subobject_path
The relative V pathname of the object you are seeking, specified as a character string. This pathname string can contain the <- characters to go up in the hierarchy and can contain simple array dimension specification to go through array values.
mode
A mode indicating how the process intends to use the object:
OM_OBJ_RD -- The process intends to read but not write to the object.
OM_OBJ_RW -- The process intends to read and possibly write to the object.
Returned value
The id of the found object; or OMnull_obj on an error.
Example
Given the following group
group grp1 {
int var1;
group grp2 {
int var2;
};
};
the following are valid calls to OMfind_str_subobj. Assume grp1_id contains grp1's object id:
var1_id = OMfind_str_subobj (grp1_id, "var1", OM_OBJ_RW);
var2_id = OMfind_str_subobj (grp1_id, "grp2.var2",
OM_OBJ_RW);
You can use this call to access a subobject of an array of groups. Given the V code
group grp3 {
group arr[2] {
int a;
};
};
If you have the id of the object grp3 in variable grp3_id, you can get id of the subobject a in the 0'th element in the array using the call:
a_id = OMfind_str_subobj(grp3_id, "arr[0].a",
OM_OBJ_RW);
You can go up the hierarchy using the <- operator. Given the V code
group grp4 {
group sub_grp1 {
int a;
};
group sub_grp2 {
int b;
};
};
If you have the id of sub_grp1 in the variable sub_grp1_id, you can get the object id of the b subobject with
b_id = OMfind_str_subobj(sub_grp1_id, "<-.sub_grp2.b",
OM_OBJ_RW);