Exemple #1
0
void showSimple()
{
    Variant arr;

    // Create an array in this variant

    arr.createArray();

    // Push some items.  You can also add using append() or insert()

    arr.push(10);
    arr.push(21);
    arr.push(50);
    arr.push(3022);
    arr.push(44);

    arr[1] = 234.00f;
    arr[2] = "Hello world";

    // Iterate over all of the array items (note: unusual syntax).  One can also
    // use length() and [] to iterate over the array.

    for (Iter<Variant> i; arr.forEach(i); )
    {
        printf("%d %s\n", i.pos(), i->toString().c_str());
    }

    // pop() all elements from the array

    Variant p;
    while (!(p = arr.pop()).isNull())
    {
        printf("Pop %s\n", p.toString().c_str());
    }
}