Skip to content

Commit

Permalink
- updated docs, example: use WJECloseDocument() to delete
Browse files Browse the repository at this point in the history
  • Loading branch information
penduin committed Nov 16, 2012
1 parent ffb5928 commit a319177
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion documentation/index.html
Expand Up @@ -122,7 +122,7 @@ <h1>Contact</h1>
<li>
<a href="mailto:owens@netmail.com">
Owen Swerkstrom &lt;owens@netmail.com&gt;
</a> - community/repository front-man, primary WJElementSchema author
</a> - community/repository front-man, WJElementSchema author
</li>
<li>
<a href="mailto:migahg@netmail.com">
Expand Down
4 changes: 4 additions & 0 deletions documentation/wjelement.html
Expand Up @@ -171,6 +171,10 @@ <h2>Document/Element Management</h2>
XplBool WJECloseDocument(WJElement document);
</pre></blockquote>
</p>
<p>
WJECloseDocument is also used to delete/remove an item from a parent document:
WJECloseDocument(WJEGet(...));
</p>
<p>
<strong>WJECopyDocument</strong>
- Duplicate an existing WJElement
Expand Down
9 changes: 7 additions & 2 deletions example/example.c
Expand Up @@ -26,16 +26,18 @@ var doc = {
"job": "public relations"
"born": 2485
}
]
],
"shiny": true
};
var person = null;
for(i in doc.crew) {
for(i in doc.crew) { // note: tedious...
person = doc.crew[i];
if(person.born == 2468) {
person.born = 2486;
}
}
delete(doc.shiny);
for(i in doc.crew) {
person = doc.crew[i];
Expand Down Expand Up @@ -73,7 +75,10 @@ int main(int argc, char **argv) {
WJEString(doc, "crew[-1].job", WJE_SET, "public relations");
WJEInt64(doc, "crew[-1].born", WJE_SET, 2485);

WJEBool(doc, "shiny", WJE_SET, TRUE);

WJEInt64(doc, "crew[].born == 2468", WJE_SET, 2486); /* note: awesome! */
WJECloseDocument(WJEGet(doc, "shiny", NULL));

while((person = _WJEObject(doc, "crew[]", WJE_GET, &person))) {
printf("%s (%s) is %d\n",
Expand Down
5 changes: 5 additions & 0 deletions include/wjelement.h
Expand Up @@ -155,6 +155,11 @@ EXPORT XplBool WJEWriteDocument(WJElement document, WJWriter writer, char *name

/* Destroy a WJElement object */
EXPORT XplBool WJECloseDocument(WJElement document);
/*
WJECloseDocument is also used to delete/remove an item from a parent
document:
WJECloseDocument(WJEGet(...));
*/

/* Duplicate an existing WJElement */
EXPORT WJElement _WJECopyDocument(WJElement to, WJElement from, WJELoadCB loadcb, void *data, const char *file, const int line);
Expand Down

0 comments on commit a319177

Please sign in to comment.