twPrimitive Structure
The twPrimitive structure is a form of a variant that can represent any of the base types supported in ThingWorx Platform. The structure is defined in src/messaging/twBaseTypes.h as follows:
typedef struct twPrimitive {
enum BaseType type;
enum BaseType typeFamily;
uint32_t length;
union {
int32_t integer;
double number;
DATETIME datetime;
twLocation location;
char boolean;
struct {
char * data;
uint32_t len;
} bytes;
struct twInfoTable * infotable;
struct twPrimitive * variant;
} val;
} twPrimitive;
The key fields are the type enumeration and the val union. The fields typeFamily and length are for internal API use and are typically not used by an application.
There are many helper functions for creating twPrimitive structures from base types in the ThingWorx C SDK, so that you will rarely have to create one manually. These function definitions can be found in src/messaging/twBaseTypes.h.
Was this helpful?