static void dumpAttributes(MDICOMWrapper& w, tagVector& v, const char* outputFile) { if (outputFile != 0) { ofstream f(outputFile); if (f == 0) { cerr << "Could not open attribute file: " << outputFile << endl; ::exit(1); } dumpAttributes(w, v, f); } else { dumpAttributes(w, v, cout); } }
int main(int argc, char **argv) { char* attributeFile = 0; char* outputFile = 0; while (--argc > 0 && (*++argv)[0] == '-') { switch (*(argv[0] + 1)) { case 'a': argc--; argv++; if (argc <= 0) usage(); attributeFile = *argv; break; case 'f': argc--; argv++; if (argc <= 0) usage(); outputFile = *argv; break; default: break; } } if (argc < 1) usage(); tagVector v; readTags(attributeFile, v); MDICOMWrapper w(*argv); dumpAttributes(w, v, outputFile); return 0; }
void ProvisioningAttrList::dumpAttributes(const UtlContainable* pAttribute) { static UtlString* pMemberName; UtlContainable* pMemberValue; if (UtlString(pAttribute->getContainableType()) == "UtlHashMap") { UtlHashMapIterator structureIterator(*dynamic_cast<const UtlHashMap*>(pAttribute)); while ((pMemberName = dynamic_cast<UtlString*>(structureIterator())) != NULL) { pMemberValue = dynamic_cast<const UtlHashMap*>(pAttribute)->findValue(pMemberName); if (UtlString(pMemberValue->getContainableType()) == "UtlHashMap" || UtlString(pMemberValue->getContainableType()) == "UtlSList") { dumpAttributes(pMemberValue); } if (UtlString(pMemberValue->getContainableType()) == "UtlBool") { osPrintf("{%s} = (BOOL) %s\n", pMemberName->data(), (dynamic_cast<UtlBool*>(pMemberValue)->getValue() ? "TRUE" : "FALSE")); } else if (UtlString(pMemberValue->getContainableType()) == "UtlInt") { osPrintf("{%s} = (INT) %d\n", pMemberName->data(), dynamic_cast<UtlInt*>(pMemberValue)->getValue()); } else if (UtlString(pMemberValue->getContainableType()) == "UtlString") { osPrintf("{%s} = (STRING) \"%s\"\n", pMemberName->data(), dynamic_cast<UtlString*>(pMemberValue)->data()); } } } else if (UtlString(pAttribute->getContainableType()) == "UtlSList") { UtlSListIterator arrayIterator(*dynamic_cast<const UtlSList*>(pAttribute)); int arrayIndex = 0; while ((pMemberValue = arrayIterator()) != NULL) { if (UtlString(pMemberValue->getContainableType()) == "UtlHashMap" || UtlString(pMemberValue->getContainableType()) == "UtlSList") { dumpAttributes(pMemberValue); } if (UtlString(pMemberValue->getContainableType()) == "UtlBool") { osPrintf("{%s}[%d] = (BOOL) %s\n", pMemberName->data(), arrayIndex++, (dynamic_cast<UtlBool*>(pMemberValue)->getValue() ? "TRUE" : "FALSE")); } else if (UtlString(pMemberValue->getContainableType()) == "UtlInt") { osPrintf("{%s}[%d] = (INT) %d\n", pMemberName->data(), arrayIndex++, dynamic_cast<UtlInt*>(pMemberValue)->getValue()); } else if (UtlString(pMemberValue->getContainableType()) == "UtlString") { osPrintf("{%s}[%d] = (STRING) \"%s\"\n", pMemberName->data(), arrayIndex++, dynamic_cast<UtlString*>(pMemberValue)->data()); } } } }
void ProvisioningAttrList::dumpAttributes(void) { dumpAttributes(dynamic_cast<UtlContainable*>(mpData)); }