/*--------------------------------------------------------------- Routine : GetFloatField Purpose : Reads the next float field from the file. If no field exists, or EOF is encountered, then Success will be returned FALSE, else returns a pointer to the float and Success will be returned TRUE. Leaves the file pointer at the beginning of the next field (i.e., skips all delimiters). ---------------------------------------------------------------*/ float GetFloatField( FILE *FromFile, BOOL *Success ) { char *str; float theFloat; str = GetStringField( FromFile ); if ( str == NULL ) { theFloat = FLT_MAX; *Success = FALSE; return theFloat; } if ( !sscanf( str, "%g", &theFloat ) ) { theFloat = FLT_MAX; *Success = FALSE; } FreeMemory(str); *Success = TRUE; return theFloat; } /* GetFloatField */
// Generate a struct field getter, conditioned on its child type(s). static void GenStructAccessor(const StructDef &struct_def, const FieldDef &field, std::string *code_ptr) { GenComment(field.doc_comment, code_ptr, nullptr, ""); if (IsScalar(field.value.type.base_type)) { if (struct_def.fixed) { GetScalarFieldOfStruct(struct_def, field, code_ptr); } else { GetScalarFieldOfTable(struct_def, field, code_ptr); } } else { switch (field.value.type.base_type) { case BASE_TYPE_STRUCT: if (struct_def.fixed) { GetStructFieldOfStruct(struct_def, field, code_ptr); } else { GetStructFieldOfTable(struct_def, field, code_ptr); } break; case BASE_TYPE_STRING: GetStringField(struct_def, field, code_ptr); break; case BASE_TYPE_VECTOR: { auto vectortype = field.value.type.VectorType(); if (vectortype.base_type == BASE_TYPE_STRUCT) { GetMemberOfVectorOfStruct(struct_def, field, code_ptr); } else { GetMemberOfVectorOfNonStruct(struct_def, field, code_ptr); } break; } case BASE_TYPE_UNION: GetUnionField(struct_def, field, code_ptr); break; default: assert(0); } } if (field.value.type.base_type == BASE_TYPE_VECTOR) { GetVectorLen(struct_def, field, code_ptr); if (field.value.type.element == BASE_TYPE_UCHAR) { GetUByteSlice(struct_def, field, code_ptr); } } }
/*! */ char * xbDbf::GetStringField( const char * FieldName ) { return GetStringField(GetFieldNo(FieldName)); }