bool Skim_File::Create_Fields (void) { Clear_Fields (); Matrix_File::Create_Fields (); if (time_flag) { Add_Field ("TIME", DB_TIME, 4, Time_Format (), true); } else { if (mode == WAIT_MODE) { Add_Field ("WAIT", DB_TIME, 2, Time_Format (), true); } else if (mode == BIKE_MODE || mode == OTHER_MODE) { Add_Field ("OTHER", DB_TIME, 2, Time_Format (), true); } else { Add_Field ("WALK", DB_TIME, 2, Time_Format (), true); if (mode != WALK_MODE) { if (mode != RIDE_MODE && mode != TRANSIT_MODE && mode != TAXI_MODE) { Add_Field ("DRIVE", DB_TIME, 4, Time_Format (), true); } if (mode != DRIVE_MODE) { if (mode != RIDE_MODE && mode != TAXI_MODE) { Add_Field ("TRANSIT", DB_TIME, 4, Time_Format (), true); } Add_Field ("WAIT", DB_TIME, 2, Time_Format (), true); } Add_Field ("OTHER", DB_TIME, 2, Time_Format (), true); } } } if (Length_Format () == MILES || Length_Format () == KILOMETERS) { Add_Field ("LENGTH", DB_DOUBLE, 4.2, Length_Format (), true); } else { Add_Field ("LENGTH", DB_INTEGER, 4, Length_Format (), true); } if (len_flag) { Db_Field *fld = Field ("LENGTH"); if (fld->Units () != Length_Format ()) { fld->Units (Length_Format ()); } } Add_Field ("COST", DB_INTEGER, 2, CENTS, true); Add_Field ("IMPEDANCE", DB_INTEGER, 4, IMPEDANCE, true); return (Set_Field_Numbers ()); }
/* "within_struct_flag" is TRUE if the enclosing format is "{...}" */ static FORMAT_PTR Parse(Format_Parse_Ptr parser, int32 within_struct_flag, BOOLEAN *error) { TokenPtr Token; FORMAT_PTR ReturnForm=NULL; Token = NextToken(parser); switch(Token->Type) { case LBRACE_TOK: Token = NextToken(parser); if (Token->Type == STR_TOK && !strcmp(Token->value.str, "enum")) { ReturnForm = Enum_Format(parser, error); } else { UngetToken(parser, Token); ReturnForm = Struct_Format(parser, error); } Token = NextToken(parser); if (Token->Type != RBRACE_TOK) { ParserError(Token, parser, "'}'"); *error = TRUE; return NULL; } break; case LBRACK_TOK: ReturnForm = Fixed_Array_Format(parser, error); break; case LT_TOK: if (!within_struct_flag) { ParserError(Token, parser, "var array format '<..>' not embedded within a structure '{..}'"); *error = TRUE; return NULL; } else { ReturnForm = Var_Array_Format(parser, error); } break; case STAR_TOK: if (parser->TokenList->Type == BANG_TOK) { Token = NextToken(parser); /* eat BANG_TOK */ if (!within_struct_flag) { ParserError(Token, parser, "self pointer '*!' embedded within a structure '{..}'"); *error = TRUE; return NULL; } else { ReturnForm = SelfPtr_Format(); } } else ReturnForm = Ptr_Format(parser, error); break; case INT_TOK: ReturnForm = Length_Format(Token); break; case STR_TOK: ReturnForm = Named_Format(parser, Token); if (ReturnForm->type == BadFormatFMT) { *error = TRUE; return NULL; } break; case PRIMITIVE_TOK: ReturnForm = Primitive_Format(parser, Token); if (ReturnForm->type == BadFormatFMT) { *error = TRUE; return NULL; } break; case EOS_TOK: ParserError(Token, parser, "additional tokens; premature end of string encountered"); *error = TRUE; return NULL; break; default: ParserError(Token, parser, "a different token type"); *error = TRUE; return NULL; } cacheFormatterAttributes(ReturnForm); return ReturnForm; }