void MemberClass::ExportDefaultToken(FILE *outfile, char *recordName) { PointerList<Datum>::Walker walk(&m_datumList); Datum *dat = walk.GetObj(); if(dat->m_maxSize == k_MAX_SIZE_VARIABLE) { switch(dat->m_type) { case DATUM_INT: fprintf(outfile, " Assert(false)\n"); fprintf(outfile, " if(!CTPRecord::ParseIntInArray(lex, &m_%s, &m_num%s)) {\n", dat->m_name, dat->m_name); break; case DATUM_STRINGID: fprintf(outfile, " Assert(false)\n"); fprintf(outfile, " if(!CTPRecord::ParseStringIdInArray(lex, m_%s, &m_num%s)) {\n", dat->m_name, dat->m_name); break; case DATUM_FLOAT: fprintf(outfile, " Assert(false)\n"); fprintf(outfile, " if(!CTPRecord::ParseFloatInArray(lex, &m_%s, &m_num%s)) {\n", dat->m_name, dat->m_name); break; case DATUM_STRING: case DATUM_FILE: fprintf(outfile, " Assert(false)\n"); fprintf(outfile, " if(!CTPRecord::ParseFileInArray(lex, &m_%s, &m_num%s)) {\n", dat->m_name, dat->m_name); break; case DATUM_RECORD: fprintf(outfile, " Assert(false)\n"); fprintf(outfile, " if(!g_the%sDB->ParseRecordInArray(lex, &m_%s, &m_num%s)) {\n", dat->m_subType, dat->m_name, dat->m_name); break; case DATUM_STRUCT: fprintf(outfile, " if(!%sRecord::%s::ParseInArraySequential(lex, &m_%s, &m_num%s)) {\n", recordName, dat->m_subType, dat->m_name, dat->m_name); break; default: Assert(0); break; } fprintf(outfile, " DBERROR((\"Unknown token\"));\n"); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); } else if(dat->m_maxSize > 0) { switch(dat->m_type) { case DATUM_INT: fprintf(outfile, " Assert(false)\n"); fprintf(outfile, " if(!CTPRecord::GetIntInArray(lex, &m_%s, &m_num%s, k_MAX_%s)) {\n", dat->m_name, dat->m_name, dat->m_name); break; case DATUM_STRINGID: fprintf(outfile, " Assert(false)\n"); fprintf(outfile, " if(!CTPRecord::GetStringIdInArray(lex, &m_%s, &m_num%s, k_MAX_%s)) {\n", dat->m_name, dat->m_name, dat->m_name); break; case DATUM_FLOAT: fprintf(outfile, " Assert(false)\n"); fprintf(outfile, " if(!CTPRecord::ParseFloatInArray(lex, &m_%s, &m_num%s, k_MAX_%s)) {\n", dat->m_name, dat->m_name, dat->m_name); break; case DATUM_STRING: case DATUM_FILE: fprintf(outfile, " Assert(false)\n"); fprintf(outfile, " if(!CTPRecord::ParseFileInArray(lex, &m_%s, &m_num%s, k_MAX_%s)) {\n", dat->m_name, dat->m_name, dat->m_name); break; case DATUM_RECORD: fprintf(outfile, " Assert(false)\n"); fprintf(outfile, " if(!g_the%sDB->ParseRecordInArray(lex, &m_%s, &m_num%s, k_MAX_%s)) {\n", dat->m_subType, dat->m_name, dat->m_name, dat->m_name); break; case DATUM_STRUCT: fprintf(outfile, " if(!%sRecord::%s::ParseInArraySequential(lex, &m_%s, &m_num%s, k_MAX_%s)) {\n", recordName, dat->m_subType, dat->m_name, dat->m_name, dat->m_name); break; default: Assert(0); break; } } else if(dat->m_maxSize < 0) { switch(dat->m_type) { case DATUM_INT: fprintf(outfile, " if(!lex->GetInt(m_%s)) {\n", dat->m_name); fprintf(outfile, " DBERROR((\"Unknown token\"));\n"); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; case DATUM_STRINGID: fprintf(outfile, " if(!lex->GetStringId(m_%s)) {\n", dat->m_name); fprintf(outfile, " DBERROR((\"Unknown token\"));\n"); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; case DATUM_BIT: fprintf(outfile, " m_flags%d |= k_%s_%s_Bit;\n", dat->m_bitNum / 32, m_name, dat->m_name); break; case DATUM_BIT_PAIR: fprintf(outfile, " m_flags%d |= k_%s_%s_Bit;\n", dat->m_bitNum / 32, m_name, dat->m_name); dat->ExportBitPairDirectParse(outfile, m_name); break; case DATUM_FLOAT: fprintf(outfile, " if(!lex->GetFloat(m_%s)) {\n", dat->m_name); fprintf(outfile, " DBERROR((\"Unknown token\"));\n"); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; case DATUM_STRING: case DATUM_FILE: fprintf(outfile, " if(!lex->GetFile(m_%s)) {\n", dat->m_name); fprintf(outfile, " DBERROR((\"Unknown token\"));\n"); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; case DATUM_RECORD: fprintf(outfile, " if(!g_the%sDB->GetCurrentRecordFromLexer(lex, m_%s)) {\n", dat->m_subType, dat->m_name); fprintf(outfile, " DBERROR((\"Unknown token\"));\n"); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; case DATUM_STRUCT: fprintf(outfile, " if(!m_%s.ParseFullySequential(lex)) {\n", dat->m_name); fprintf(outfile, " DBERROR((\"Unknown token\"));\n"); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; case DATUM_BIT_GROUP: fprintf(outfile, " if(!Parse%sBit(lex)) {\n", dat->m_name); fprintf(outfile, " DBERROR((\"Unknown token\"));\n"); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; default: Assert(0); break; } } fprintf(outfile, " break;\n"); }
void MemberClass::ExportTokenCases(FILE *outfile, char *recordName) { for ( PointerList<Datum>::Walker walk(&m_datumList); walk.IsValid(); walk.Next() ) { Datum *dat = walk.GetObj(); fprintf(outfile, " case k_Token_%s_%s_%s:\n", recordName, m_name, dat->m_name); if(dat->m_akaName){ fprintf(outfile, " case k_Token_%s_%s_%s:\n", recordName, m_name, dat->m_akaName); } if(dat->m_maxSize == k_MAX_SIZE_VARIABLE) { switch(dat->m_type) { case DATUM_INT: fprintf(outfile, " if(!CTPRecord::ParseIntInArray(lex, &m_%s, &m_num%s)) {\n", dat->m_name, dat->m_name); break; case DATUM_STRINGID: fprintf(outfile, " if(!CTPRecord::ParseStringIdInArray(lex, m_%s, &m_num%s)) {\n", dat->m_name, dat->m_name); break; case DATUM_FLOAT: fprintf(outfile, " if(!CTPRecord::ParseFloatInArray(lex, &m_%s, &m_num%s)) {\n", dat->m_name, dat->m_name); break; case DATUM_STRING: case DATUM_FILE: fprintf(outfile, " if(!CTPRecord::ParseFileInArray(lex, &m_%s, &m_num%s)) {\n", dat->m_name, dat->m_name); break; case DATUM_RECORD: fprintf(outfile, " if(!g_the%sDB->ParseRecordInArray(lex, &m_%s, &m_num%s)) {\n", dat->m_subType, dat->m_name, dat->m_name); break; case DATUM_STRUCT: fprintf(outfile, " if(!%sRecord::%s::ParseInArray(lex, &m_%s, &m_num%s)) {\n", recordName, dat->m_subType, dat->m_name, dat->m_name); break; default: Assert(0); break; } fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); } else if(dat->m_maxSize > 0) { switch(dat->m_type) { case DATUM_INT: fprintf(outfile, " if(!CTPRecord::GetIntInArray(lex, &m_%s, &m_num%s, k_MAX_%s)) {\n", dat->m_name, dat->m_name, dat->m_name); break; case DATUM_STRINGID: fprintf(outfile, " if(!CTPRecord::GetStringIdInArray(lex, &m_%s, &m_num%s, k_MAX_%s)) {\n", dat->m_name, dat->m_name, dat->m_name); break; case DATUM_FLOAT: fprintf(outfile, " if(!CTPRecord::ParseFloatInArray(lex, &m_%s, &m_num%s, k_MAX_%s)) {\n", dat->m_name, dat->m_name, dat->m_name); break; case DATUM_STRING: case DATUM_FILE: fprintf(outfile, " if(!CTPRecord::ParseFileInArray(lex, &m_%s, &m_num%s, k_MAX_%s)) {\n", dat->m_name, dat->m_name, dat->m_name); break; case DATUM_RECORD: fprintf(outfile, " if (!g_the%sDB->ParseRecordInArray(lex, &m_%s, &m_num%s, k_MAX_%s)) {\n", dat->m_subType, dat->m_name, dat->m_name, dat->m_name); break; case DATUM_STRUCT: fprintf(outfile, " if(!%sRecord::%s::ParseInArray(lex, &m_%s, &m_num%s, k_MAX_%s)) {\n", recordName, dat->m_subType, dat->m_name, dat->m_name, dat->m_name); break; default: Assert(0); break; } } else if(dat->m_maxSize < 0) { switch(dat->m_type) { case DATUM_INT: fprintf(outfile, " if(!lex->GetIntAssignment(m_%s)) {\n", dat->m_name); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; case DATUM_STRINGID: fprintf(outfile, " if(!lex->GetStringIdAssignment(m_%s)) {\n", dat->m_name); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; case DATUM_BIT: fprintf(outfile, " m_flags%d |= k_%s_%s_Bit;\n", dat->m_bitNum / 32, m_name, dat->m_name); break; case DATUM_BIT_PAIR: fprintf(outfile, " m_flags%d |= k_%s_%s_Bit;\n", dat->m_bitNum / 32, m_name, dat->m_name); dat->ExportBitPairDirectParse(outfile, m_name); break; case DATUM_FLOAT: fprintf(outfile, " if(!lex->GetFloatAssignment(m_%s)) {\n", dat->m_name); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; case DATUM_STRING: case DATUM_FILE: fprintf(outfile, " if(!lex->GetFileAssignment(m_%s)) {\n", dat->m_name); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; case DATUM_RECORD: fprintf(outfile, " if (!g_the%sDB->GetRecordFromLexer(lex, m_%s)) {\n", dat->m_subType, dat->m_name); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; case DATUM_STRUCT: fprintf(outfile, " if(!m_%s.Parse(lex)) {\n", dat->m_name); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; case DATUM_BIT_GROUP: fprintf(outfile, " if(!Parse%sBit(lex)) {\n", dat->m_name); fprintf(outfile, " done = true; break;\n"); fprintf(outfile, " }\n"); break; default: Assert(0); break; } } fprintf(outfile, " break;\n"); } }