The raw data object
If the class factory for a specific server type is not registered, the automatically creates an object that exposes both an ITValue interface and an ITDatum interface. To obtain a pointer to the binary data of the object, use the ITDatum::Data method. The resulting pointer can be used to access the data structure that corresponds to the object.
This approach violates the principle of information hiding. By accessing the structure through a pointer, the user of the object creates a dependency on the particular implementation of an object. If that implementation changes, the applications that use the object can cease to function. The interface approach to object encapsulation ensures that an application cannot create a dependency on a particular implementation of an object.
- Issue a query to return an array and extract the value from the
row.
ITQuery q(conn); ITRow *row = q.ExecOneRow("select byte_val from regresstab;"); // Extract the column ITValue *v; v = row->Column(0);
- Extract the ITDatum interface from the object.
ITDatum *rv; if (v->QueryInterface(ITDatumIID, (void **) &rv) == IT_QUERYINTERFACE_SUCCESS) {
- Extract the data pointer from the object into an application pointer.
char *pch = (char *)rv->Data();
- Search the data types for a match.
char match[] = "Informix"; char *found = strstr(pch, match);
- Release the ITDatum interface.
rv->Release();