DataType

used to store data types for data at compile time

Constructors

this
this(DataType.Type dataType, uinteger arrayDimension, bool isReference)

constructor.

this
this(string dataType, uinteger arrayDimension, bool isReference)

constructor.

this
this(string sType)

constructor.

this
this(Token data)

constructor.

Members

Enums

Type
enum Type

enum defining all data types. These are all lowercase of what they're written here

Functions

fromData
void fromData(Token data)

identifies the data type from the actual data. Only works for base types, and with only 1 token. So arrays dont work. keep in mind, this won't be able to identify if the data type is a reference or not

fromString
void fromString(string s)

reads DataType from a string, works for base types and custom types

toString
string toString()

Properties

isArray
bool isArray [@property getter]
isCustom
bool isCustom [@property getter]
isNumerical
bool isNumerical [@property getter]
name
string name [@property getter]
name
string name [@property setter]

Just calls fromString()

typeName
string typeName [@property getter]

Variables

arrayDimensionCount
uinteger arrayDimensionCount;

stores if it's an array. If type is int, it will be 0, if int[] it will be 1, if int[][], then 2 ...

customLength
uinteger customLength;

stores length in case of Type.Custom

isRef
bool isRef;

stores if it's a reference to a type

type
Type type;

the actual data type

Examples

st{
	assert(DataType("int") == DataType(DataType.Type.Int, 0));
	assert(DataType("char[][]") == DataType(DataType.Type.Char, 2));
	assert(DataType("double[][]") == DataType(DataType.Type.Double, 2));
	assert(DataType("void") == DataType(DataType.Type.Void, 0));
	// unittests for `fromData`
	DataType dType;
	dType.fromData(Token("\"bla bla\""));
	assert(dType == DataType("char[]"));
	dType.fromData(Token("20"));
	assert(dType == DataType("int"), dType.name);
	dType.fromData(Token("2.5"));
	assert(dType == DataType("double"));
	// unittests for `.name()`
	assert(DataType("potatoType[][]").name == "potatoType[][]");
	assert(DataType("double[]").name == "double[]")

Meta