Ejemplo n.º 1
0
static void readResourceData(ResourceData* data, char** location, char* xmlStart, FlipDataFunc flipData) {
  char* curLoc;
  char* tagBegin;
  char* tagEnd;
  char* dictEnd;
  size_t strLen;
  char* buffer;
  char* encodedStart;
  
  curLoc = *location;
  
  data->name = NULL;
  data->attributes = 0;
  data->id = 0;
  data->data = NULL;
  
  curLoc = strstr(curLoc, "<dict>");
  dictEnd = strstr(curLoc, "</dict>"); /* hope there's not a dict type in this resource data! */
  while(curLoc != NULL && curLoc < dictEnd) {
    curLoc = strstr(curLoc, "<key>");
    if(!curLoc)
      break;
    curLoc += sizeof("<key>") - 1;
    
    tagEnd = strstr(curLoc, "</key>");
    
    strLen = (size_t)(tagEnd - curLoc);
    tagBegin = curLoc;
    curLoc = tagEnd + sizeof("</key>") - 1;
    
    if(strncmp(tagBegin, "Attributes", strLen) == 0) {
      buffer = getXMLString(&curLoc);
      sscanf(buffer, "0x%x", &(data->attributes));
      free(buffer);
    } else if(strncmp(tagBegin, "Data", strLen) == 0) {
        encodedStart = 0;
      data->data = getXMLData(&curLoc, &(data->dataLength), &encodedStart, &data->dataXmlSize);
      data->dataXmlOffset = encodedStart - xmlStart;
      if(flipData) {
        (*flipData)(data->data, 0);
      }
    } else if(strncmp(tagBegin, "ID", strLen) == 0) {
      buffer = getXMLString(&curLoc);
      sscanf(buffer, "%d", &(data->id));
      free(buffer);
    } else if(strncmp(tagBegin, "Name", strLen) == 0) {
      data->name = getXMLString(&curLoc);
    }
  }
  
  curLoc = dictEnd + sizeof("</dict>") - 1;
  
  *location = curLoc;
}
Ejemplo n.º 2
0
 std::string Cylinder::toXMLString(int tabs)
 {
     return getXMLString(
                "Cylinder",
                (boost::format("radius=\"%f\" height=\"%f\"") % radius % height).str(),
                tabs);
 }
Ejemplo n.º 3
0
 std::string Sphere::toXMLString(int tabs)
 {
     return getXMLString(
                "Sphere",
                (boost::format("radius=\"%f\"") % radius).str(),
                tabs);
 }
Ejemplo n.º 4
0
 //derivate functions
 std::string Box::toXMLString(int tabs)
 {
     return getXMLString(
                "Box",
                (boost::format("width=\"%f\" height=\"%f\" depth=\"%f\"") % width % height % depth).str(),
                tabs);
 }