Using the Variant (Setting it's memory location)
Era Scarecrow
rtcvb32 at yahoo.com
Sun Feb 5 12:20:57 PST 2012
I've been working and building a struct called 'AllTypes' which
I've come to the conclusion is already available as a variant.
However as I look at the documentation I don't see any
methods/constructors to use where I can specify where I want the
data to be access from.
The data I will be accessing has dozens of different structures
of records which I keep the formatting and types saved in an
array. I see the problem where although variant can handle what I
need, but I don't see a way to specify a specific memory
range/access in order to use it.
ubyte[] buffer;
//buffer is loaded at some point with data so length > 0;
buffer.length = 2;
//0 is the offset from the buffer rather than making a range.
Variant v(buffer, int8, 0);
v = 10;
assert(buffer[0] == 10);
v = Variant(buffer, int8, 1);
v = 25;
assert(buffer[0] == 10);
assert(buffer[1] == 25);
More information about the Digitalmars-d-learn
mailing list