| 414 | } |
| 415 | |
| 416 | void printXMLBlock(ResXMLTree* block) |
| 417 | { |
| 418 | block->restart(); |
| 419 | |
| 420 | Vector<namespace_entry> namespaces; |
| 421 | |
| 422 | ResXMLTree::event_code_t code; |
| 423 | int depth = 0; |
| 424 | while ((code=block->next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) { |
| 425 | String8 prefix = make_prefix(depth); |
| 426 | int i; |
| 427 | if (code == ResXMLTree::START_TAG) { |
| 428 | size_t len; |
| 429 | const uint16_t* ns16 = block->getElementNamespace(&len); |
| 430 | String8 elemNs = build_namespace(namespaces, ns16); |
| 431 | const uint16_t* com16 = block->getComment(&len); |
| 432 | if (com16) { |
| 433 | printf("%s <!-- %s -->\n", prefix.string(), String8(com16).string()); |
| 434 | } |
| 435 | printf("%sE: %s%s (line=%d)\n", prefix.string(), elemNs.string(), |
| 436 | String8(block->getElementName(&len)).string(), |
| 437 | block->getLineNumber()); |
| 438 | int N = block->getAttributeCount(); |
| 439 | depth++; |
| 440 | prefix = make_prefix(depth); |
| 441 | for (i=0; i<N; i++) { |
| 442 | uint32_t res = block->getAttributeNameResID(i); |
| 443 | ns16 = block->getAttributeNamespace(i, &len); |
| 444 | String8 ns = build_namespace(namespaces, ns16); |
| 445 | String8 name(block->getAttributeName(i, &len)); |
| 446 | printf("%sA: ", prefix.string()); |
| 447 | if (res) { |
| 448 | printf("%s%s(0x%08x)", ns.string(), name.string(), res); |
| 449 | } else { |
| 450 | printf("%s%s", ns.string(), name.string()); |
| 451 | } |
| 452 | Res_value value; |
| 453 | block->getAttributeValue(i, &value); |
| 454 | if (value.dataType == Res_value::TYPE_NULL) { |
| 455 | printf("=(null)"); |
| 456 | } else if (value.dataType == Res_value::TYPE_REFERENCE) { |
| 457 | printf("=@0x%x", (int)value.data); |
| 458 | } else if (value.dataType == Res_value::TYPE_ATTRIBUTE) { |
| 459 | printf("=?0x%x", (int)value.data); |
| 460 | } else if (value.dataType == Res_value::TYPE_STRING) { |
| 461 | printf("=\"%s\"", |
| 462 | ResTable::normalizeForOutput(String8(block->getAttributeStringValue(i, |
| 463 | &len)).string()).string()); |
| 464 | } else { |
| 465 | printf("=(type 0x%x)0x%x", (int)value.dataType, (int)value.data); |
| 466 | } |
| 467 | const char16_t* val = block->getAttributeStringValue(i, &len); |
| 468 | if (val != NULL) { |
| 469 | printf(" (Raw: \"%s\")", ResTable::normalizeForOutput(String8(val).string()). |
| 470 | string()); |
| 471 | } |
| 472 | printf("\n"); |
| 473 | } |
no test coverage detected