getter

Useful in class/struct declarations for DRY.

Generates a public getter, private setter, and a hidden private var.

Usage:

mixin(getter!(int, "myVar"));
mixin(getter!("protected", float, "someFloat", 2.5));
mixin(getter!(string, "str"));

Turns Into:

private int _myVar;
@property private int myVar(int _NEW_VAL_)
{
	_myVar = _NEW_VAL_;
	return _myVar;
}
@property public int myVar()
{
	return _myVar;
}

protected float _someFloat = 2.5;
@property protected float someFloat(float _NEW_VAL_)
{
	_someFloat = _NEW_VAL_;
	return _someFloat;
}
@property public float someFloat()
{
	return _someFloat;
}

private string _str;
@property private string str(string _NEW_VAL_)
{
	_str = _NEW_VAL_;
	return _str;
}
@property public string str()
{
	return _str;
}
  1. template getter(varType, string name, varType initialValue = varType.init)
    template getter (
    varType
    string name
    varType initialValue = varType.init
    ) {}
  2. template getter(string writeAccess, varType, string name, varType initialValue = varType.init)

Members

Manifest constants

getter
enum getter;
Undocumented in source.
getter
enum getter;
Undocumented in source.

Meta