hl7parse
|
primary storage type of a delimited element More...
#include <node.h>
Public Attributes | |
node_type_t | type |
int | id |
struct node_t * | parent |
struct node_t ** | children |
int | num_children |
int | _num_children_allocated |
unsigned char * | data |
size_t | length |
int | pos |
primary storage type of a delimited element
Every hl7 element (regardless of place in the hirarchy) is represented by a node_t. The node_t.type defines where in the hirarchy the node is. Every node_t has a parent
node.
The top level node of a parsed HL7 message is always of type message_t. The Hirarchy looks like this:
node_t.type
== SEGMENT
this is the segment nodenode_t.type
== FIELDLIST
array of elements between |
, always one, may have multiple children delimited by ~
node_t.type
== FIELD
array of fields delimited by ~
, always at least onenode_t.type
== COMP
optional components delimited by ^
node_t.type
== SUBCOMP
optional sub components delimited by &
The delimiters shown above are the standard delimiters. The HL7 file may define different delimiters which are read and accounted for by the parser.
Every node has potential children indicated by node_t.num_children (0 means none) and has a parent (special case is message_t which is always the root of the structure and is the partent of node_type_t SEGMENT).
This also means, that some node types (node_t.type) need to be treated specially.
To create a valid node_t you need to know it's data and length.
Example:
node_t takes owenship of the pointer pointing to data
. be aware of the fact that when you free a node then all children and it's data will get freed.
Example:
You should use the api to manage relationships between children and parents. this will make sure you don't get any dangling nodes in your structure.
Example:
message_t has a very similar structure (lacking data but having file metadata). when accessing the parent of a SEGMENT
, then the parent should be casted into message_t*
.
int node_t::_num_children_allocated |
number of allocated elements in children
struct node_t** node_t::children |
array of child nodes
unsigned char* node_t::data |
byte array of raw data, should be NULL if there is no data and "\0" when empty
int node_t::id |
unique id of the node
size_t node_t::length |
number of bytes in data
int node_t::num_children |
number of elements in children
struct node_t* node_t::parent |
pointer to parent node, should never be NULL
int node_t::pos |
element position from the beginning of the segment in bytes, this might go away
node_type_t node_t::type |
the type of the node