00001 #ifndef node_h
00002 #define node_h
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <myriad/bstring/bstrlib.h>
00018
00020 typedef enum NodeType {
00021 TYPE_NUMBER, TYPE_STRING, TYPE_BLOB, TYPE_FLOAT, TYPE_INVALID, TYPE_GROUP
00022 } NodeType;
00023
00024
00033 typedef struct Node {
00039 bstring name;
00040
00042 NodeType type;
00043
00046 union {
00047 unsigned long number;
00048 bstring string;
00049 double floating;
00050 } value;
00051
00053 struct Node *parent;
00054
00056 struct Node *sibling;
00057
00059 struct Node *child;
00060 } Node;
00061
00072 void Node_dump(Node *d, char sep, int follow_sibs);
00073
00074
00084 void Node_catbstr(bstring str, Node *d, char sep, int follow_sibs);
00085
00100 bstring Node_bstr(Node *d, int follow_sibs);
00101
00107 void Node_destroy(Node *root);
00108
00116 Node *Node_new_string(Node *parent, bstring data);
00117
00119 Node *Node_new_blob(Node *parent, bstring data);
00120
00122 Node *Node_new_number(Node *parent, unsigned long data);
00123
00125 Node *Node_new_float(Node *parent, double data);
00126
00128 Node *Node_new_group(Node *parent);
00129
00135 void Node_name(Node *node, bstring name);
00136
00137
00160 Node *Node_cons(const char *format, ...);
00161
00181 int Node_decons(Node *node, int copy, const char *format, ...);
00182
00186 void Node_add_child(Node *parent, Node *child);
00187
00191 void Node_add_sib(Node *sib1, Node *sib2);
00192
00193
00213 Node *Node_parse(bstring buf);
00214
00229 Node *Node_parse_seq(bstring buf, size_t *from);
00230
00231 #endif
00232