TipcStrToFt convert a string to a message field type
str
field type string to convert
ft_return
storage for field type
TRUE
if the string was successfully converted to a field type, FALSE
otherwise.
If TipcStrToFt fails, it returns FALSE
and sets the global SmartSockets error number to one of:
TipcStrToFt converts a string (such as REAL8
) to a message field type (such as T_IPC_FT_REAL8
). The string can be in any case. (For example, str_array
, STR_ARRAY
, and Str_Array
are all get converted to T_IPC_FT_STR_ARRAY.
)
If TipcStrToFt returns FALSE
, it does not store a value in ft_return
.
This example reads a string from a file, converts it to a field type, reads a field value from the file, then appends the field to a message:
void read_field(file, msg) FILE *file; T_IPC_MSG msg; { T_CHAR str[80]; T_IPC_FT type; T_REAL8 real8; if (fgets(str, sizeof(str), file) == NULL) {return
; /* error */
} if (strlen(str) > 0) { str[strlen(str) - 1] = ’\0’;/* strip off newline */
} if (!TipcStrToFt(str, &type)) {return
; /* error */
} switch (type) {/* read value from file and append to message */
case T_IPC_FT_REAL8: if (fscanf(file, "%lf", &real8) != 1) {
return
; /* error */
} if (!TipcMsgAppendReal8(msg, real8)) {return
; /* error */
} break;/* other field types go here */
}/* switch */
}/* read_field */
TIBCO SmartSockets™ Application Programming Interface Software Release 6.8, July 2006 Copyright © TIBCO Software Inc. All rights reserved www.tibco.com |