Object | +---DValue
The value class implements an union of basic data types. The class stores the current type of the storage and the value. This class also implements type conversion between the different types of storage.
#include <stdio.h> #include "ofc/DValue.h" int main(int argc, char *argv[]) { DValue *value = [DValue new]; DText *str = [DText new]; printf("Initial the value %s empty.\n", ([value isEmpty] ? "is" : "is not")); [value setInt :7]; // Set the value to integer 7 printf("Type of value:%s\n", [value typeString]); [str set :"0.07"]; // Set the value to DText:0.07 [value setObject :str]; printf("Type of value:%s\n", [value typeString]); printf("Double of value:%f\n", [value toDouble]); // Convert the value to a double printf("Type of value:%s\n", [value typeString]); [value free]; // Cleanup [str free]; return 0; }