|
TNet 3
3.0.8
|
Data Node is a hierarchical data type containing a name and a value, as well as a variable number of children. Data Nodes can be serialized to and from IO data streams. Think of it as an alternative to having to include a huge 1 MB+ XML parsing library in your project. More...
Public Types | |
| enum | SaveType { SaveType.Text, SaveType.Binary, SaveType.Compressed } |
Public Member Functions | |
| DataNode () | |
| DataNode (string name) | |
| DataNode (string name, object value) | |
| void | Clear () |
| Clear the value and the list of children. More... | |
| object | Get (Type type) |
| Get the node's value cast into the specified type. More... | |
| T | Get< T > () |
| Retrieve the value cast into the appropriate type. More... | |
| T | Get< T > (T defaultVal) |
| Retrieve the value cast into the appropriate type. More... | |
| DataNode | AddChild () |
| Convenience function to add a new child node. More... | |
| DataNode | AddChild (string name) |
| Add a new child node without checking to see if another child with the same name already exists. More... | |
| DataNode | AddChild (string name, object value) |
| Add a new child node without checking to see if another child with the same name already exists. More... | |
| DataNode | AddMissingChild (string name, object value) |
| Add a new child node after checking to see if it already exists. If it does, the existing value is returned. More... | |
| DataNode | ReplaceChild (DataNode child) |
| Set the specified child, replacing an existing one if one already exists with the same name. More... | |
| DataNode | SetChild (string name, object value) |
| Set a child value. Will add a new child if a child with the same name is not already present. More... | |
| DataNode | FindChild (string name, string path=null) |
| Find a child with the specified name starting at the chosen path. More... | |
| DataNode | GetHierarchy (string path) |
| Retrieve a child by its path. More... | |
| T | GetHierarchy< T > (string path) |
| Retrieve a child by its path. More... | |
| T | GetHierarchy< T > (string path, T defaultValue) |
| Retrieve a child by its path. More... | |
| DataNode | SetHierarchy (string path, object obj) |
| Set a node's value given its hierarchical path. More... | |
| DataNode | RemoveHierarchy (string path) |
| Remove the specified child from the list. Returns the parent node of the removed node if successful. More... | |
| DataNode | GetChild (string name, bool createIfMissing=false) |
| Retrieve a child by name, optionally creating a new one if the child doesn't already exist. More... | |
| T | GetChild< T > (string name) |
| Get the value of the existing child. More... | |
| T | GetChild< T > (string name, T defaultValue) |
| Get the value of the existing child or the default value if the child is not present. More... | |
| bool | RemoveChild (string name) |
| Remove the specified child from the list. More... | |
| DataNode | Clone () |
| Clone the DataNode, creating a copy. More... | |
| bool | Write (string path, SaveType type=SaveType.Text, bool allowConfigAccess=false) |
| Write the node hierarchy to the specified filename. More... | |
| bool | Write (string path, bool binary) |
| Write the node hierarchy to the specified filename. More... | |
| void | Write (BinaryWriter writer, bool compressed=false) |
| Just here for consistency. More... | |
| void | Write (StreamWriter writer, int tab=0) |
| Write the node hierarchy to the stream reader, saving it in text format. More... | |
| bool | Merge (DataNode other, bool replaceExisting=true) |
| Merge the current data with the specified. Returns whether some node's value was replaced. More... | |
| override string | ToString () |
| Convenience function for easy debugging – convert the entire data into the string representation form. More... | |
| byte[] | ToArray (SaveType type=SaveType.Binary) |
| Convert the DataNode into a binary array of specified type. More... | |
| bool | ResolveValue (Type type=null) |
| Process the string values, converting them to proper objects. Returns whether child nodes should be processed in turn. More... | |
Static Public Member Functions | |
| static DataNode | Read (string path, bool allowConfigAccess=false) |
| Read the node hierarchy from the specified file. More... | |
| static SaveType | GetSaveType (byte[] data) |
| Attempt to determine the saved data's format – binary, compressed or text. More... | |
| static DataNode | Read (byte[] data) |
| Read the node hierarchy from the specified buffer. More... | |
| static DataNode | Read (byte[] bytes, bool binary) |
| Read the node hierarchy from the specified buffer. Kept for backwards compatibility. In most cases you will want to use the Read(bytes) function instead. More... | |
| static DataNode | Read (byte[] bytes, SaveType type) |
| Read the node hierarchy from the specified buffer. More... | |
| static DataNode | Read (TextReader reader) |
| Read the node hierarchy from the stream reader containing data in text format. More... | |
Public Attributes | |
| string | name |
| Data node's name. More... | |
| List< DataNode > | children = new List<DataNode>() |
| List of child nodes. More... | |
Properties | |
| object | value [get, set] |
| Data node's value. More... | |
| bool | isSerializable [get] |
| Whether this node is serializable or not. A node must have a value or children for it to be serialized. Otherwise there isn't much point in doing so. More... | |
| Type | type [get] |
| Type the value is currently in. More... | |
Data Node is a hierarchical data type containing a name and a value, as well as a variable number of children. Data Nodes can be serialized to and from IO data streams. Think of it as an alternative to having to include a huge 1 MB+ XML parsing library in your project.
Basic Usage: To create a new node: new DataNode (name, value). To add a new child node: dataNode.AddChild("Scale", Vector3.one). To retrieve a Vector3 value: dataNode.GetChild<Vector3>("Scale").
| TNet.DataNode.DataNode | ( | ) |
| TNet.DataNode.DataNode | ( | string | name | ) |
| TNet.DataNode.DataNode | ( | string | name, |
| object | value | ||
| ) |
| DataNode TNet.DataNode.AddChild | ( | ) |
Convenience function to add a new child node.
| DataNode TNet.DataNode.AddChild | ( | string | name | ) |
Add a new child node without checking to see if another child with the same name already exists.
| DataNode TNet.DataNode.AddChild | ( | string | name, |
| object | value | ||
| ) |
Add a new child node without checking to see if another child with the same name already exists.
| DataNode TNet.DataNode.AddMissingChild | ( | string | name, |
| object | value | ||
| ) |
Add a new child node after checking to see if it already exists. If it does, the existing value is returned.
| void TNet.DataNode.Clear | ( | ) |
Clear the value and the list of children.
| DataNode TNet.DataNode.FindChild | ( | string | name, |
| string | path = null |
||
| ) |
Find a child with the specified name starting at the chosen path.
| object TNet.DataNode.Get | ( | Type | type | ) |
Get the node's value cast into the specified type.
| T TNet.DataNode.Get< T > | ( | ) |
Retrieve the value cast into the appropriate type.
| T TNet.DataNode.Get< T > | ( | T | defaultVal | ) |
Retrieve the value cast into the appropriate type.
| DataNode TNet.DataNode.GetChild | ( | string | name, |
| bool | createIfMissing = false |
||
| ) |
Retrieve a child by name, optionally creating a new one if the child doesn't already exist.
| T TNet.DataNode.GetChild< T > | ( | string | name | ) |
Get the value of the existing child.
| T TNet.DataNode.GetChild< T > | ( | string | name, |
| T | defaultValue | ||
| ) |
Get the value of the existing child or the default value if the child is not present.
| DataNode TNet.DataNode.GetHierarchy | ( | string | path | ) |
Retrieve a child by its path.
| T TNet.DataNode.GetHierarchy< T > | ( | string | path | ) |
Retrieve a child by its path.
| T TNet.DataNode.GetHierarchy< T > | ( | string | path, |
| T | defaultValue | ||
| ) |
Retrieve a child by its path.
|
static |
Attempt to determine the saved data's format – binary, compressed or text.
| bool TNet.DataNode.Merge | ( | DataNode | other, |
| bool | replaceExisting = true |
||
| ) |
Merge the current data with the specified. Returns whether some node's value was replaced.
|
static |
Read the node hierarchy from the specified file.
|
static |
Read the node hierarchy from the specified buffer.
|
static |
Read the node hierarchy from the specified buffer. Kept for backwards compatibility. In most cases you will want to use the Read(bytes) function instead.
Read the node hierarchy from the specified buffer.
|
static |
Read the node hierarchy from the stream reader containing data in text format.
| bool TNet.DataNode.RemoveChild | ( | string | name | ) |
Remove the specified child from the list.
| DataNode TNet.DataNode.RemoveHierarchy | ( | string | path | ) |
Remove the specified child from the list. Returns the parent node of the removed node if successful.
Set the specified child, replacing an existing one if one already exists with the same name.
| bool TNet.DataNode.ResolveValue | ( | Type | type = null | ) |
Process the string values, converting them to proper objects. Returns whether child nodes should be processed in turn.
| DataNode TNet.DataNode.SetChild | ( | string | name, |
| object | value | ||
| ) |
Set a child value. Will add a new child if a child with the same name is not already present.
| DataNode TNet.DataNode.SetHierarchy | ( | string | path, |
| object | obj | ||
| ) |
Set a node's value given its hierarchical path.
| byte [] TNet.DataNode.ToArray | ( | SaveType | type = SaveType.Binary | ) |
Convert the DataNode into a binary array of specified type.
| override string TNet.DataNode.ToString | ( | ) |
Convenience function for easy debugging – convert the entire data into the string representation form.
| bool TNet.DataNode.Write | ( | string | path, |
| SaveType | type = SaveType.Text, |
||
| bool | allowConfigAccess = false |
||
| ) |
Write the node hierarchy to the specified filename.
| bool TNet.DataNode.Write | ( | string | path, |
| bool | binary | ||
| ) |
Write the node hierarchy to the specified filename.
| void TNet.DataNode.Write | ( | BinaryWriter | writer, |
| bool | compressed = false |
||
| ) |
Just here for consistency.
| void TNet.DataNode.Write | ( | StreamWriter | writer, |
| int | tab = 0 |
||
| ) |
Write the node hierarchy to the stream reader, saving it in text format.
| string TNet.DataNode.name |
Data node's name.
|
get |
Whether this node is serializable or not. A node must have a value or children for it to be serialized. Otherwise there isn't much point in doing so.
|
get |
Type the value is currently in.
|
getset |
Data node's value.