Documentation
Version | Link |
---|---|
1.3.2 | |
1.0.0 |
Description
A helper library allowing creation and modification of mutable TLV trees, as well as conversion from and to byte arrays
Goal and usage
How to?
Create a TLV Tree
// New, empty TlvTree tree = TlvTree.Empty(); // From a tlv byte array TlvTree tree = TlvTree.FromRaw(tlvByteArray);
Serialize to a byte array
byte[] rawTlv = tree.AsBytes();
Add a binary element
tree.AddBin(tag, new byte[] { 0x10, 0x00 });
Add an ASCII element
This is a helper over AddBin
- there are no differences on the underlying TLV content
tree.AddAscii(tag, "ascii content");
Add a child Data Object (TLV Container)
TlvTree childTree = tree.AddChild(tag);
Retrieve an element’s content
byte[] value = tree.GetElementValue(tag); String value = tree.GetElementAscii(tag);
Retrieve a child Data Object
TlvTree childTree = tree.GetChild(tag); TlvTree childTree = tree.GetOrCreateChild(tag);
Retrieve a list of child Data Objects with a given tag
TlvTree[] childTrees = tree.GetChildren(tag);