xpp {
/*
This file
demonstrates the high degree of flexibility that Superx++ has
with entity
access.
The _object()
syntax allows you to place any expression within the parentheses
as the object
being accessed.
The _member()
syntax allows you to place any expression within the parentheses
as the member
being accessed.
The _method()
syntax allows you to place any expression within the parentheses
as the method
being accessed.
The _attribute()
syntax allows you to place any expression within the parentheses
as the attribute
being accessed.
*/
/* define the entities to be accessed */
node x {
<cats upd="false"
num="0">5</cats>
<dogs>4</dogs>
};
int iVal
= 777;
/* change the entities somehow */
_object("$x/cats") = 700;
_object("$x/cats")._attribute("upd")
= "true";
/* write stuff to the output stream from
the entities */
xout("\r\n$mem/x/cats.value() =
" + _object("$mem/x/cats")._method("value") +
"...");
xout("\r\n$mem/x/cats.upd = " +
_object("$mem/x/cats")._attribute("upd") +
"...");
xout("\r\n$mem/x/cats.num = " +
_object("$mem/x/cats")._attribute("num") +
"...");
_object("$x/cats")._attribute("num")
= _object("$x/cats")._attribute("num") + 1;
xout("\r\n$mem/x/cats.num = " +
_object("$mem/x/cats")._attribute("num") +
"...");
/* add 1 to the iVal */
_object("iVal") =
_object("iVal") + 1;
/* sObj1 will contain the first half of
the name of the entity
while sObj2 will contain the second half of the name */
string sObj1
= "iV";
string sObj2
= "al";
/* access the entity now */
xout("\r\niVal = " +
_object(sObj1 + sObj2));
}