int main ( char argc, char **argv ) { char txt[128]; int err; while( err = GetMesg( txt ) ){ printf( "Msg: er=%d, msg=%s\n", err,txt ); } }
const Profile::FIELD* Profile::GetField(const std::string& mesgName, const std::string& fieldName) { const MESG *mesg = GetMesg(mesgName); if (mesg == NULL) return NULL; FIT_UINT16 fieldIndex = GetFieldIndex(mesgName, fieldName); if (fieldIndex >= mesg->numFields) return NULL; return &(mesg->fields[fieldIndex]); }
const Profile::FIELD* Profile::GetField(const FIT_UINT16 mesgNum, const FIT_UINT8 fieldNum) { const MESG *mesg = GetMesg(mesgNum); if (mesg == NULL) return NULL; FIT_UINT16 fieldIndex = GetFieldIndex(mesgNum, fieldNum); if (fieldIndex >= mesg->numFields) return NULL; return &(mesg->fields[fieldIndex]); }
const FIT_UINT16 Profile::GetFieldIndex(const FIT_UINT16 mesgNum, const FIT_UINT8 fieldNum) { const MESG *mesg = GetMesg(mesgNum); if (mesg == NULL) return FIT_UINT16_INVALID; for (FIT_UINT16 i = 0; i < mesg->numFields; i++) { if (mesg->fields[i].num == fieldNum) return i; } return FIT_UINT16_INVALID; }
const FIT_UINT16 Profile::GetFieldIndex(const std::string& mesgName, const std::string& fieldName) { const MESG *mesg = GetMesg(mesgName); if (mesg == NULL) return FIT_UINT16_INVALID; for (FIT_UINT16 i = 0; i < mesg->numFields; i++) { if (mesg->fields[i].name == fieldName) return i; for (FIT_UINT16 j = 0; j < mesg->fields[i].numSubFields; j++) { if (mesg->fields[i].subFields[j].name == fieldName) return i; } } return FIT_UINT16_INVALID; }