TipcStrToFt


Name

TipcStrToFt — convert a string to a message field type

Synopsis

T_BOOL TipcStrToFt(str, ft_return) 
T_STR str; 
T_IPC_FT *ft_return; 

Arguments

str — field type string to convert

ft_return — storage for field type

Return Values

TRUE if the string was successfully converted to a field type, FALSE otherwise.

Diagnostics

If TipcStrToFt fails, it returns FALSE and sets the global SmartSockets error number to one of:

Description

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.)

Caution

If TipcStrToFt returns FALSE, it does not store a value in ft_return.

See Also

TipcFtToStr

Examples

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