Changeset 4819 for trunk/psLib/src/xml/psXML.c
- Timestamp:
- Aug 18, 2005, 2:31:42 PM (21 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/xml/psXML.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/xml/psXML.c
r4786 r4819 10 10 * @author David Robbins, MHPCC 11 11 * 12 * @version $Revision: 1.3 6$ $Name: not supported by cvs2svn $13 * @date $Date: 2005-08-1 6 20:13:20$12 * @version $Revision: 1.37 $ $Name: not supported by cvs2svn $ 13 * @date $Date: 2005-08-19 00:31:42 $ 14 14 * 15 15 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 61 61 if( root == NULL ) { 62 62 *XML = xmlNewDoc((const xmlChar*)"1.0"); 63 root = xmlNewDocNode(*XML, NULL, (const xmlChar*)"metadata", "\n");63 root = xmlNewDocNode(*XML, NULL, (const xmlChar*)"metadata", (const xmlChar*)"\n"); 64 64 xmlDocSetRootElement(*XML, root); 65 65 } … … 75 75 switch (type) { 76 76 case PS_DATA_BOOL: 77 cur_node = xmlNewChild(root, NULL, "item","\n");78 prop = xmlNewProp(cur_node, "name",item->name);79 prop = xmlNewProp(cur_node, "psType","BOOL");77 cur_node = xmlNewChild(root, NULL, (const xmlChar*)"item", (const xmlChar*)"\n"); 78 prop = xmlNewProp(cur_node, (const xmlChar*)"name", (const xmlChar*)item->name); 79 prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"BOOL"); 80 80 if ( item->data.B ) 81 81 strncpy(content, "TRUE", MAXSTR); 82 82 else 83 83 strncpy(content, "FALSE", MAXSTR); 84 prop = xmlNewProp(cur_node, "value",content);84 prop = xmlNewProp(cur_node, (const xmlChar*)"value", (const xmlChar*)content); 85 85 break; 86 86 case PS_DATA_S32: 87 87 snprintf(content, MAXSTR, "%d", item->data.S32); 88 cur_node = xmlNewChild(root, NULL, "item","\n");89 prop = xmlNewProp(cur_node, "name",item->name);90 prop = xmlNewProp(cur_node, "psType","S32");91 prop = xmlNewProp(cur_node, "value",content);88 cur_node = xmlNewChild(root, NULL, (const xmlChar*)"item", (const xmlChar*)"\n"); 89 prop = xmlNewProp(cur_node, (const xmlChar*)"name", (const xmlChar*)item->name); 90 prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"S32"); 91 prop = xmlNewProp(cur_node, (const xmlChar*)"value", (const xmlChar*)content); 92 92 break; 93 93 case PS_DATA_F32: 94 94 snprintf(content, MAXSTR, "%f", item->data.F32); 95 cur_node = xmlNewChild(root, NULL, "item","\n");96 prop = xmlNewProp(cur_node, "name",item->name);97 prop = xmlNewProp(cur_node, "psType","F32");98 prop = xmlNewProp(cur_node, "value",content);95 cur_node = xmlNewChild(root, NULL, (const xmlChar*)"item", (const xmlChar*)"\n"); 96 prop = xmlNewProp(cur_node, (const xmlChar*)"name", (const xmlChar*)item->name); 97 prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"F32"); 98 prop = xmlNewProp(cur_node, (const xmlChar*)"value", (const xmlChar*)content); 99 99 break; 100 100 case PS_DATA_F64: 101 101 snprintf(content, MAXSTR, "%lf", item->data.F64); 102 cur_node = xmlNewChild(root, NULL, "item","\n");103 prop = xmlNewProp(cur_node, "name",item->name);104 prop = xmlNewProp(cur_node, "psType","F64");105 prop = xmlNewProp(cur_node, "value",content);102 cur_node = xmlNewChild(root, NULL, (const xmlChar*)"item", (const xmlChar*)"\n"); 103 prop = xmlNewProp(cur_node, (const xmlChar*)"name", (const xmlChar*)item->name); 104 prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"F64"); 105 prop = xmlNewProp(cur_node, (const xmlChar*)"value", (const xmlChar*)content); 106 106 break; 107 107 case PS_DATA_STRING: 108 cur_node = xmlNewChild(root, NULL, "item","\n");109 prop = xmlNewProp(cur_node, "name",item->name);110 prop = xmlNewProp(cur_node, "psType","STR");108 cur_node = xmlNewChild(root, NULL, (const xmlChar*)"item", (const xmlChar*)"\n"); 109 prop = xmlNewProp(cur_node, (const xmlChar*)"name", (const xmlChar*)item->name); 110 prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"STR"); 111 111 strncpy(content, ((char *)(item->data.V)), MAXSTR); 112 prop = xmlNewProp(cur_node, "value",content);112 prop = xmlNewProp(cur_node, (const xmlChar*)"value", (const xmlChar*)content); 113 113 break; 114 114 case PS_DATA_METADATA: … … 119 119 newDoc = psMetadataToXMLDoc(item->data.md); 120 120 new_root = xmlDocGetRootElement(*newDoc); 121 prop = xmlNewProp(new_root, "name",item->name);122 prop = xmlNewProp(new_root, "psType","METADATA");121 prop = xmlNewProp(new_root, (const xmlChar*)"name", (const xmlChar*)item->name); 122 prop = xmlNewProp(new_root, (const xmlChar*)"psType", (const xmlChar*)"METADATA"); 123 123 new_node = xmlAddSibling(cur_node, new_root); 124 124 psFree(newDoc); 125 125 break; 126 126 case PS_DATA_VECTOR: 127 cur_node = xmlNewChild(root, NULL, "vector","\n");128 prop = xmlNewProp(cur_node, "name",item->name);127 cur_node = xmlNewChild(root, NULL, (const xmlChar*)"vector", (const xmlChar*)"\n"); 128 prop = xmlNewProp(cur_node, (const xmlChar*)"name", (const xmlChar*)item->name); 129 129 type = ((psVector*)(item->data.V))->type.type; 130 130 strncpy(vec, "", MAXSTR); 131 131 switch (type) { 132 132 case PS_DATA_S32: 133 prop = xmlNewProp(cur_node, "psType","S32");133 prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"S32"); 134 134 for (i = 0; ((psVector*)(item->data.V))->data.S32[i] != 0; i++) { 135 135 snprintf(content, MAXSTR, "%d", … … 143 143 break; 144 144 case PS_DATA_F32: 145 prop = xmlNewProp(cur_node, "psType","F32");145 prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"F32"); 146 146 for (i = 0; ((psVector*)(item->data.V))->data.F32[i] != 0; i++) { 147 147 snprintf(content, MAXSTR, "%f", … … 154 154 break; 155 155 case PS_DATA_F64: 156 prop = xmlNewProp(cur_node, "psType","F64");156 prop = xmlNewProp(cur_node, (const xmlChar*)"psType", (const xmlChar*)"F64"); 157 157 for (i = 0; ((psVector*)(item->data.V))->data.F64[i] != 0; i++) { 158 158 snprintf(content, MAXSTR, "%lf", … … 172 172 return NULL; 173 173 } 174 prop = xmlNewProp(cur_node, "value",vec);174 prop = xmlNewProp(cur_node, (const xmlChar*)"value", (const xmlChar*)vec); 175 175 break; 176 176 case PS_DATA_UNKNOWN: … … 271 271 //NEED TO CHECK CONTENTS OF EACH ITEM/NODE // 272 272 //if item then, 273 if(!strncmp( node->name, "item", MAXSTR) || !strncmp(node->name, "ITEM", MAXSTR)) {273 if(!strncmp((const char*)node->name, "item", MAXSTR) || !strncmp((const char*)node->name, "ITEM", MAXSTR)) { 274 274 if (node->properties != NULL && node->properties->name != NULL 275 275 && node->properties->next != NULL && node->properties->next->name != NULL 276 276 && node->properties->next->next != NULL 277 277 && node->properties->next->next->name != NULL) { 278 psDataType type = getType( node->properties->next->children->content);278 psDataType type = getType((const char*)node->properties->next->children->content); 279 279 return type; 280 280 } else { … … 285 285 } 286 286 //if vector then, 287 if(!strncmp( node->name, "vector", MAXSTR) || !strncmp(node->name, "VECTOR", MAXSTR)) {287 if(!strncmp((const char*)node->name, "vector", MAXSTR) || !strncmp((const char*)node->name, "VECTOR", MAXSTR)) { 288 288 if (node->properties != NULL && node->properties->name != NULL 289 289 && node->properties->next != NULL && node->properties->next->name != NULL … … 299 299 } 300 300 //if metadata then, 301 if(!strncmp( node->name, "metadata", MAXSTR)) {301 if(!strncmp((const char*)node->name, "metadata", MAXSTR)) { 302 302 if (node->properties != NULL && node->properties->name 303 303 && node->properties->next != NULL && node->properties->next->name != NULL) { … … 331 331 if ( cur_node->type == XML_ELEMENT_NODE ) { 332 332 //if the root node isn't a metadata// 333 if ( nodeNum == 0 && strncmp( cur_node->name, "metadata", MAXSTR) ) {333 if ( nodeNum == 0 && strncmp((const char*)cur_node->name, "metadata", MAXSTR) ) { 334 334 psError(PS_ERR_BAD_PARAMETER_VALUE, true, 335 335 PS_ERRORTEXT_psXML_INVALID_CONTENT); … … 351 351 break; 352 352 case PS_DATA_F32: 353 strncpy(name, cur_node->properties->children->content, MAXSTR);353 strncpy(name, (const char*)cur_node->properties->children->content, MAXSTR); 354 354 strncpy(content, 355 cur_node->properties->next->next->children->content, MAXSTR);355 (const char*)cur_node->properties->next->next->children->content, MAXSTR); 356 356 psMetadataAddF32(meta, PS_LIST_TAIL, name, "", strtof(content, NULL)); 357 357 break; 358 358 case PS_DATA_F64: 359 strncpy(name, cur_node->properties->children->content, MAXSTR);359 strncpy(name, (const char*)cur_node->properties->children->content, MAXSTR); 360 360 strncpy(content, 361 cur_node->properties->next->next->children->content, MAXSTR);361 (const char*)cur_node->properties->next->next->children->content, MAXSTR); 362 362 psMetadataAddF64(meta, PS_LIST_TAIL, name, "", strtod(content, NULL)); 363 363 break; 364 364 case PS_DATA_STRING: 365 strncpy(name, cur_node->properties->children->content, MAXSTR);365 strncpy(name, (const char*)cur_node->properties->children->content, MAXSTR); 366 366 psMetadataAddStr(meta, PS_LIST_TAIL, name, "", 367 cur_node->properties->next->next->children->content);367 (const char*)cur_node->properties->next->next->children->content); 368 368 break; 369 369 case PS_DATA_VECTOR: 370 strncpy(name, cur_node->properties->children->content, MAXSTR);370 strncpy(name, (const char*)cur_node->properties->children->content, MAXSTR); 371 371 strncpy(content, 372 cur_node->properties->next->next->children->content, MAXSTR);373 elemType = getType( cur_node->properties->next->children->content);372 (const char*)cur_node->properties->next->next->children->content, MAXSTR); 373 elemType = getType((const char*)cur_node->properties->next->children->content); 374 374 if (elemType == PS_DATA_UNKNOWN || elemType == PS_DATA_STRING 375 375 || elemType == PS_DATA_BOOL) { … … 386 386 break; 387 387 case PS_DATA_METADATA: 388 strncpy(name, cur_node->properties->children->content, MAXSTR);388 strncpy(name, (const char*)cur_node->properties->children->content, MAXSTR); 389 389 // psMetadata *temp = psMetadataAlloc(); 390 390 psMetadata *temp = NULL; … … 394 394 break; 395 395 case PS_DATA_BOOL: 396 strncpy(name, cur_node->properties->children->content, MAXSTR);396 strncpy(name, (const char*)cur_node->properties->children->content, MAXSTR); 397 397 strncpy(content, 398 cur_node->properties->next->next->children->content, MAXSTR);398 (const char*)cur_node->properties->next->next->children->content, MAXSTR); 399 399 if ( !strncmp(content, "true", MAXSTR) || 400 400 !strncmp(content, "TRUE", MAXSTR) || … … 504 504 return false; 505 505 } 506 strncpy(buffer, buff, MAXVEC);506 strncpy(buffer, (const char*)buff, MAXVEC); 507 507 xmlFree(buff); 508 508
Note:
See TracChangeset
for help on using the changeset viewer.
