Index: ossp-pkg/val/val.pod RCS File: /v/ossp/cvs/ossp-pkg/val/val.pod,v rcsdiff -q -kk '-r1.5' '-r1.6' -u '/v/ossp/cvs/ossp-pkg/val/val.pod,v' 2>/dev/null --- val.pod 2002/01/17 09:22:18 1.5 +++ val.pod 2002/01/17 11:50:06 1.6 @@ -232,6 +232,56 @@ OSSP var. +=head1 EXAMPLES + +=over 4 + +=item simple create, reg, get, destroy + + #include + #include "val.h" + + int main(void) + { + val_rc_t rc; + val_t *v; + int example; + int pullout; + + if ((rc = val_create(&v)) != VAL_OK) exit(-1); + if ((rc = val_reg(v, "foo", VAL_TYPE_INT, "foo variable", (void *)&example)) != VAL_OK) exit(-1); + example = 123; + if ((rc = val_get(v, "foo", &pullout)) != VAL_OK) exit(-1); + printf("pulled example and got %d\n", pullout); + if ((rc = val_destroy(v)) != VAL_OK) exit(-1); + return 0; + } + +=item reg inline data, structured name, set + + #include + #include "val.h" + + int main(void) + { + val_rc_t rc; + val_t *v1, *v2; + int pullout; + + if ((rc = val_create(&v1)) != VAL_OK) exit(-1); + if ((rc = val_create(&v2)) != VAL_OK) exit(-1); + if ((rc = val_reg(v1, "bar", VAL_TYPE_VAL, "child", (void *)&v2)) != VAL_OK) exit(-1); + if ((rc = val_reg(v1, "bar.foo", VAL_TYPE_INT, "foo variable", NULL)) != VAL_OK) exit(-1); + if ((rc = val_set(v2, "foo", 456)) != VAL_OK) exit(-1); + if ((rc = val_get(v1, "bar.foo", &pullout)) != VAL_OK) exit(-1); + printf("pulled example and got %d\n", pullout); + if ((rc = val_destroy(v2)) != VAL_OK) exit(-1); + if ((rc = val_destroy(v1)) != VAL_OK) exit(-1); + return 0; + } + +=back + =head1 HISTORY B was invented in January 2002 by Thomas Lotterer and Ralf S.