on master help sign in
Expose more details of node, meaning no need for accessor functions
commitc1824fb72ca395f204054baade93c13920060fb8 authorNeil Mitchell <ndmitchell@gmail.com> dateTue 29 Nov 2016, 09:40 (10 years ago) parent8f7b578
2 files changed+9−17
cbits/hexml.c−12 cbits/hexml.h+9−5
cbits/hexml.c−12
@@ -34,16 +34,6 @@ typedef struct
3434 attr* alloc; // what to call free on
3535} attr_buffer;
3636
37−
38−struct node
39−{
40− str name; // tag name, e.g. <[foo]>
41− str outer; // outer text, [<foo>bar</foo>]
42− str inner; // inner text, <foo>[bar]</foo>
43− str attrs; // all the attributes, in the attribute buffer
44− str nodes; // all the nodes, in the node buffer
45−};
46−
4737typedef struct
4838{
4939 // have a cursor at the front, which is all the stuff I have written out, final
@@ -178,8 +168,6 @@ int document_render(document* d, char* buffer, int length)
178168
179169char* document_error(document* d){return d->error_message;}
180170node* document_node(document* d){return &d->nodes.nodes[0];}
181−str node_inner(node* n){return n->inner;}
182−str node_outer(node* n){return n->outer;}
183171
184172void document_free(document* d)
185173{
cbits/hexml.h+9−5
@@ -2,7 +2,6 @@
22#include <stdint.h>
33
44typedef struct document document;
5−typedef struct node node;
65
76// Pair of indexes into the input string
87typedef struct
@@ -17,6 +16,15 @@ typedef struct
1716 str value;
1817} attr;
1918
19+typedef struct
20+{
21+ str name; // tag name, e.g. <[foo]>
22+ str inner; // inner text, <foo>[bar]</foo>
23+ str outer; // outer text, [<foo>bar</foo>]
24+ str attrs; // all the attributes, in the attribute buffer (not usable)
25+ str nodes; // all the nodes, in the node buffer (not usable)
26+} node;
27+
2028// Convention: if slen can be -1 for nul-terminated, or given explicitly
2129
2230// Parse a document, returns a potentially invalid document - use document_error to check
@@ -36,10 +44,6 @@ char* document_error(document* d);
3644// return the root node of the document - imagine the document is wrapped in <>$DOC</> tags
3745node* document_node(document* d);
3846
39−// Get the span of a node
40−str node_inner(node* n);
41−str node_outer(node* n);
42−
4347// List all items within a node
4448node* node_children(document* d, node* n, int* res);
4549attr* node_attributes(document* d, node* n, int* res);