/*---------------------------------------------------------------------------*/ CHAR_DESC ReadCharDescription(FILE *File) { /* ** Parameters: ** File open text file to read character description from ** Globals: none ** Operation: Read a character description from File, and return ** a data structure containing this information. The data ** is formatted as follows: ** NumberOfSets ** ShortNameForSet1 Set1 ** ShortNameForSet2 Set2 ** ... ** Return: Character description read from File. ** Exceptions: ILLEGAL_NUM_SETS ** History: Wed May 23 17:32:48 1990, DSJ, Created. */ int NumSetsToRead; char ShortName[FEAT_NAME_SIZE]; CHAR_DESC CharDesc; int Type; if (fscanf (File, "%d", &NumSetsToRead) != 1 || NumSetsToRead < 0 || NumSetsToRead > NumFeaturesDefined ()) DoError (ILLEGAL_NUM_SETS, "Illegal number of feature sets"); CharDesc = NewCharDescription (); for (; NumSetsToRead > 0; NumSetsToRead--) { fscanf (File, "%s", ShortName); Type = ShortNameToFeatureType (ShortName); FeaturesOfType (CharDesc, Type) = ReadFeatureSet (File, DefinitionOf (Type)); } return (CharDesc); } // ReadCharDescription
/** * Read a character description from File, and return * a data structure containing this information. The data * is formatted as follows: * @verbatim NumberOfSets ShortNameForSet1 Set1 ShortNameForSet2 Set2 ... @endverbatim * * Globals: * - none * * @param FeatureDefs definitions of feature types/extractors * @param File open text file to read character description from * @return Character description read from File. * @note Exceptions: * - ILLEGAL_NUM_SETS * @note History: Wed May 23 17:32:48 1990, DSJ, Created. */ CHAR_DESC ReadCharDescription(const FEATURE_DEFS_STRUCT &FeatureDefs, FILE *File) { int NumSetsToRead; char ShortName[FEAT_NAME_SIZE]; CHAR_DESC CharDesc; int Type; if (fscanf (File, "%d", &NumSetsToRead) != 1 || NumSetsToRead < 0 || NumSetsToRead > FeatureDefs.NumFeatureTypes) DoError (ILLEGAL_NUM_SETS, "Illegal number of feature sets"); CharDesc = NewCharDescription(FeatureDefs); for (; NumSetsToRead > 0; NumSetsToRead--) { fscanf (File, "%s", ShortName); Type = ShortNameToFeatureType(FeatureDefs, ShortName); CharDesc->FeatureSets[Type] = ReadFeatureSet (File, FeatureDefs.FeatureDesc[Type]); } return (CharDesc); } // ReadCharDescription