namespace DtxCS.DataTypes
{
///
/// Represents the possible types of values in a DataArray.
///
public enum DataType : int
{
///
/// Integral value.
///
INT = 0x00,
///
/// Floating point value.
///
FLOAT = 0x01,
///
/// $-prefixed variable type
///
VARIABLE = 0x02,
///
/// Symbol value.
///
SYMBOL = 0x05,
///
/// '()
///
EMPTY = 0x06,
///
/// #ifdef directive
///
IFDEF = 0x07,
///
/// #else directive
///
ELSE = 0x08,
///
/// #endif directive
///
ENDIF = 0x09,
///
/// Array.
///
ARRAY = 0x10,
///
/// {}-enclosed function call
///
COMMAND = 0x11,
///
/// ""-enclosed String value.
///
STRING = 0x12,
///
/// []-enclosed macro definition
///
MACRO = 0x13,
///
/// Color (array with 3 floats as RGB, or 4 as RGBA)
///
COLOR = 0x15,
///
/// #define directive
///
DEFINE = 0x20,
///
/// #include directive
///
INCLUDE = 0x21,
///
/// #merge directive
///
MERGE = 0x22,
///
/// #ifndef directive
///
IFNDEF = 0x23,
///
/// #autorun directive
///
AUTORUN = 0x24,
///
/// #undef directive
///
UNDEF = 0x25
};
///
/// Represents the basic element of DTA, which could be an Atom or an Array.
///
public abstract class DataNode
{
///
/// The parent of this data node. If null, this is a root node.
///
public DataArray Parent { get; set; }
///
/// The name of this data node.
///
public abstract string Name { get; }
///
/// The type of this data node.
///
public abstract DataType Type { get; }
///
/// Evaluate this node to get a value.
///
///
public abstract DataNode Evaluate();
public override bool Equals(object obj)
{
if (!(obj is DataNode)) return false;
if ((obj as DataNode).Type != this.Type) return false;
if (obj.ToString() != this.ToString()) return false;
return true;
}
public virtual string ToString(int depth) => ToString();
public override int GetHashCode()
{
return ToString().GetHashCode();
}
}
}