MCPcopy Create free account
hub / github.com/CyanogenMod/android_frameworks_base / printXMLBlock

Function printXMLBlock

tools/aapt/XMLNode.cpp:416–521  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

414}
415
416void 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 }

Callers 4

doListFunction · 0.85
doDumpFunction · 0.85
compileXmlFileFunction · 0.85
parseXMLResourceFunction · 0.85

Calls 15

make_prefixFunction · 0.85
build_namespaceFunction · 0.85
getElementNamespaceMethod · 0.80
stringMethod · 0.80
getElementNameMethod · 0.80
getAttributeNameResIDMethod · 0.80
restartMethod · 0.65
getAttributeCountMethod · 0.65
getAttributeNameMethod · 0.65
getAttributeValueMethod · 0.65
nextMethod · 0.45

Tested by

no test coverage detected