//++ ------------------------------------------------------------------------------------ // Details: Retrieve the corresponding text assigned to the resource ID. // Type: Method. // Args: vResourceId - (R) MI resource ID. // Return: CMIUtilString - Resource text. // Throws: None. //-- CMIUtilString CMICmnResources::GetString(const MIuint vResourceId) const { CMIUtilString str; const bool bFound = GetStringFromResource(vResourceId, str); MIunused(bFound); assert(bFound); return str; }
//++ ------------------------------------------------------------------------------------ // Details: Determine the MI resource ID existings. // Type: Method. // Args: vResourceId - (R) MI resource ID. // Return: True - Exists. // False - Not found. // Throws: None. //-- bool CMICmnResources::HasString(const MIuint vResourceId) const { CMIUtilString str; return GetStringFromResource(vResourceId, str); }
void write_resources(char *fname) { list_type c, l; resource_type r; int num_resources, i, temp; class_type cl; FILE *f; char *str; /* Count resources and compute length */ num_resources = 0; for (c = st.classes; c != NULL; c = c->next) { cl = (class_type) c->data; if (cl->is_new) { for (l = cl->resources; l != NULL; l = l->next) { r = (resource_type)(l->data); for (int j = 0; j < MAX_LANGUAGE_ID; j++) { if (r->resource[j]) { num_resources++; } } } } } /* If no resources, do nothing */ if (num_resources == 0) return; f = fopen(fname, "wb"); if (f == NULL) { simple_error("Unable to open resource file %s!", fname); return; } /* Write out header information */ for (i=0; i < 4; i++) fwrite(&rsc_magic[i], 1, 1, f); temp = RSC_VERSION; fwrite(&temp, 4, 1, f); fwrite(&num_resources, 4, 1, f); /* Loop through classes in this source file, and then their resources */ for (c = st.classes; c != NULL; c = c->next) { cl = (class_type) c->data; if (cl->is_new) for (l = cl->resources; l != NULL; l = l->next) { r = (resource_type) (l->data); // For each language string present, // write out language data and string. for (int j = 0; j < MAX_LANGUAGE_ID; j++) { if (r->resource[j]) { // Write out id # fwrite(&r->lhs->idnum, 4, 1, f); fwrite(&j, 4, 1, f); str = GetStringFromResource(r, j); fwrite(str, strlen(str) + 1, 1, f); } } } } fclose(f); }