int _getClass(const int argc, const char **argv) { CIMClass cldef; try { cldef = _c.getClass( PEGASUS_NAMESPACENAME_INTEROP, argv[0] ); } catch (Exception& e) { cerr << /* "getClass: " << */ e.getMessage() << endl; return 1; } // Display the class definition // without qualifiers, for the moment // First the class name and superclass cout << "class " << cldef.getClassName().getString() << " : " << cldef.getSuperClassName().getString() << endl; cout << "{" << endl; // Now the properties // No qualifiers except [key], but specify type, array for (int i=0; i<cldef.getPropertyCount(); i++) { CIMProperty p = cldef.getProperty(i); cout << " "; // output key, if required if (_isKey(p)) cout << "[ Key ] "; // prepare to output type, but // first, if type is "reference", find target class if (p.getType() == CIMTYPE_REFERENCE) cout << p.getReferenceClassName().getString() << " REF "; // output type else cout << cimTypeToString(p.getType()) << " "; // output name cout << p.getName().getString(); // output array, if required if (p.isArray()) cout << "[]"; // final eol cout << ";" << endl; } // need to do methods for (int i=0; i<cldef.getMethodCount(); i++) { CIMMethod m = cldef.getMethod(i); // output type cout << " " << cimTypeToString(m.getType()) << " "; // output name cout << m.getName().getString() << "("; // output parameters // new line if there are any parameters for (int j=0; j<m.getParameterCount(); j++) { CIMParameter p = m.getParameter(j); // output IN/OUT qualifiers on a fresh line cout << endl << " [ "; // loop through qualifiers looking for IN, OUT for (int k=0; k<p.getQualifierCount(); k++) { // when one found, output its value CIMQualifier q = p.getQualifier(k); if (q.getName().equal("in") || q.getName().equal("out")) { cout << q.getName().getString() << " "; } } // Now the type cout << "] " << cimTypeToString(p.getType()) << " "; // finally the name cout << p.getName().getString(); // array brackets if (p.isArray()) cout << "[]"; // closing , on parameter if not last if (j != m.getParameterCount()-1) cout << ","; } // after last param, indent before closing paren // close paren cout << ")"; // if (m.isArray()) cout << "[]"; // finish output cout << ";" << endl; } // final brace and done cout << "};" << endl; return 0; }
void CIMtoXML(CIMParameter const& cp, ostream& ostr) { if (cp.getName().empty()) { OW_THROWCIMMSG(CIMException::INVALID_PARAMETER, "parameter must have a name"); } if (!cp.getType()) { OW_THROWCIMMSG(CIMException::INVALID_PARAMETER, "parameter must have a valid data type"); } bool isArray = cp.getType().isArrayType(); if (cp.getType().isReferenceType()) { // // Data type is a reference // String classref = cp.getType().getRefClassName(); if (!classref.empty()) { classref = "REFERENCECLASS=\"" + classref + "\""; } if (isArray) { if (cp.getType().getSize() == -1) { ostr << "<PARAMETER.REFARRAY " << classref << " NAME=\"" << cp.getName() << "\">"; qualifierXML(cp, ostr); ostr << "</PARAMETER.REFARRAY>"; } else { ostr << "<PARAMETER.REFARRAY " << classref << " NAME=\"" << cp.getName() << "\"" << " ARRAYSIZE=\"" << cp.getType().getSize() << "\">"; qualifierXML(cp, ostr); ostr << "</PARAMETER.REFARRAY>"; } } else { ostr << "<PARAMETER.REFERENCE " << classref << " NAME=\"" << cp.getName() << "\">"; qualifierXML(cp, ostr); ostr << "</PARAMETER.REFERENCE>"; } } else { // Data type is not a ref if (isArray) { ostr << "<PARAMETER.ARRAY TYPE=\""; CIMtoXML(cp.getType(), ostr); ostr << "\" NAME=\"" << cp.getName(); if (cp.getType().getSize() != -1) { ostr << "\" ARRAYSIZE=\"" << cp.getType().getSize(); } ostr << "\">"; qualifierXML(cp, ostr); ostr << "</PARAMETER.ARRAY>"; } else { ostr << "<PARAMETER TYPE=\""; CIMtoXML(cp.getType(), ostr); ostr << "\" NAME=\"" << cp.getName() << "\">"; qualifierXML(cp, ostr); ostr << "</PARAMETER>"; } } }