2014-12-30 19:11:01 +01:00
|
|
|
import dothersideinterface;
|
|
|
|
import qobject;
|
|
|
|
import std.string;
|
|
|
|
|
|
|
|
class QVariant
|
|
|
|
{
|
2015-04-27 19:58:18 +02:00
|
|
|
public this()
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_create(this.vptr);
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
2014-12-30 19:11:01 +01:00
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
public this(int value)
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_create_int(this.vptr, value);
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
2014-12-30 19:11:01 +01:00
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
public this(bool value)
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_create_bool(this.vptr, value);
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
2014-12-30 19:11:01 +01:00
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
public this(string value)
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_create_string(this.vptr, value.toStringz());
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public this(float value)
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_create_float(this.vptr, value);
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
2015-04-25 18:34:27 +02:00
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
public this(double value)
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_create_double(this.vptr, value);
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public this(QObject value)
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_create_qobject(this.vptr, value.voidPointer());
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
2015-05-01 18:54:32 +02:00
|
|
|
public this(void* vptr, bool hasOwnership = false)
|
2015-04-27 19:58:18 +02:00
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
this.vptr = vptr;
|
2015-04-27 19:58:18 +02:00
|
|
|
this.hasOwnership = hasOwnership;
|
|
|
|
}
|
|
|
|
|
|
|
|
~this()
|
|
|
|
{
|
|
|
|
if (this.hasOwnership)
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_delete(this.vptr);
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
2015-05-01 18:54:32 +02:00
|
|
|
public void* voidPointer()
|
2015-04-27 19:58:18 +02:00
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
return this.vptr;
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setValue(int value)
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_setInt(this.vptr, value);
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setValue(bool value)
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_setBool(this.vptr, value);
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setValue(string value)
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_setString(this.vptr, value.toStringz());
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
2015-03-02 23:56:43 +01:00
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
public void setValue(QObject value)
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_setQObject(this.vptr, value.voidPointer());
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setValue(float value)
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_setFloat(this.vptr, value);
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setValue(double value)
|
|
|
|
{
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_setDouble(this.vptr, value);
|
2015-04-27 19:58:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public void getValue(ref int value)
|
|
|
|
{
|
|
|
|
value = toInt();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void getValue(ref bool value)
|
|
|
|
{
|
|
|
|
value = toBool();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void getValue(ref string value)
|
|
|
|
{
|
|
|
|
value = toString();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void getValue(ref float value)
|
|
|
|
{
|
|
|
|
value = toFloat();
|
|
|
|
}
|
2014-12-30 19:11:01 +01:00
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
public void getValue(ref double value)
|
|
|
|
{
|
|
|
|
value = toDouble();
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool isNull()
|
|
|
|
{
|
|
|
|
bool result;
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_isnull(this.vptr, result);
|
2015-04-27 19:58:18 +02:00
|
|
|
return result;
|
|
|
|
}
|
2014-12-30 19:11:01 +01:00
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
public bool toBool()
|
|
|
|
{
|
|
|
|
bool result;
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_toBool(this.vptr, result);
|
2015-04-27 19:58:18 +02:00
|
|
|
return result;
|
|
|
|
}
|
2014-12-30 19:11:01 +01:00
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
public int toInt()
|
|
|
|
{
|
|
|
|
int result;
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_toInt(this.vptr, result);
|
2015-04-27 19:58:18 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public float toFloat()
|
|
|
|
{
|
|
|
|
float result;
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_toFloat(this.vptr, result);
|
2015-04-27 19:58:18 +02:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public double toDouble()
|
|
|
|
{
|
|
|
|
double result;
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_toDouble(this.vptr, result);
|
2015-04-27 19:58:18 +02:00
|
|
|
return result;
|
|
|
|
}
|
2014-12-30 19:11:01 +01:00
|
|
|
|
2015-04-27 19:58:18 +02:00
|
|
|
public override string toString()
|
|
|
|
{
|
|
|
|
char* array;
|
2015-05-01 18:54:32 +02:00
|
|
|
dos_qvariant_toString(this.vptr, array);
|
2015-04-27 19:58:18 +02:00
|
|
|
string result = fromStringz(array).dup;
|
|
|
|
dos_chararray_delete(array);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2015-05-01 18:54:32 +02:00
|
|
|
private void* vptr = null;
|
2015-04-27 19:58:18 +02:00
|
|
|
private bool hasOwnership = true;
|
2014-12-30 19:11:01 +01:00
|
|
|
}
|