void XMLWriter::writeStartElement(const XMLString& namespaceURI, const XMLString& localName, const XMLString& qname, const Attributes& attributes) { if (!_nsContextPushed) _namespaces.pushContext(); _nsContextPushed = false; ++_elementCount; writeMarkup(MARKUP_LT); if (!localName.empty() && (qname.empty() || localName == qname)) { XMLString prefix; if (!namespaceURI.empty() && !_namespaces.isMapped(namespaceURI)) { prefix = newPrefix(); _namespaces.declarePrefix(prefix, namespaceURI); } else prefix = _namespaces.getPrefix(namespaceURI); writeName(prefix, localName); } else if (namespaceURI.empty() && localName.empty() && !qname.empty()) { writeXML(qname); } else if (!localName.empty() && !qname.empty()) { XMLString local; XMLString prefix; Name::split(qname, prefix, local); if (prefix.empty()) prefix = _namespaces.getPrefix(namespaceURI); const XMLString& uri = _namespaces.getURI(prefix); if ((uri.empty() || uri != namespaceURI) && !namespaceURI.empty()) { _namespaces.declarePrefix(prefix, namespaceURI); } writeName(prefix, localName); } else throw XMLException("Tag mismatch", nameToString(localName, qname)); declareAttributeNamespaces(attributes); AttributeMap attributeMap; addNamespaceAttributes(attributeMap); addAttributes(attributeMap, attributes, namespaceURI); writeAttributes(attributeMap); _unclosedStartTag = true; }
static QString recordToDesc(const QDnsSd::Record &rec) { QString desc; if(rec.rrtype == 1) // A { quint32 *p = (quint32 *)rec.rdata.data(); desc = QHostAddress(ntohl(*p)).toString(); } else if(rec.rrtype == 28) // AAAA { desc = QHostAddress((quint8 *)rec.rdata.data()).toString(); } else if(rec.rrtype == 12) // PTR { desc = QString("[%1]").arg(nameToString(rec.rdata)); } else desc = QString("%1 bytes").arg(rec.rdata.size()); return desc; }
util::String PrintObjDecl::declToString (ObjPtr const & obj) const { String str; Linkage const & linkage = obj->getLinkage (); if (linkage.isSet ()) { appendWithSpace (str, "extern"); appendWithSpace (str, linkage.getLanguage ().c_str ()); } int flags = obj->getFlags (); if (! not_extern) { if (is_extern || hasFlag (flags, EXTERN_SPEC)) { appendWithSpace (str, "extern"); } } if (hasFlag (flags, DLL_API_SPEC)) { appendWithSpace (str, conf::getOptionValue (conf::opt_dll_api)); } if (! not_static && hasFlag (flags, STATIC_SPEC)) { appendWithSpace (str, "static"); } if (hasFlag (flags, MUTABLE_SPEC)) { appendWithSpace (str, "mutable"); } NamePtr name = obj->getName (); if (qual_name.isSet ()) { name = createQualName (qual_name, name); } String dcl_str = nameToString (name); appendWithSpace (str, obj->getCvType ().toString (dcl_str)); return str; }
util::String PrintClassDecl::declToString (ClassDeclPtr const & class_decl) const { String str; if (is_inst) { // extern only if dll_api is set if (is_inst_extern && conf::isOptionSet (conf::opt_dll_api)) { str = "extern "; } str += "template"; } else if (is_frnd) { str = "friend"; } appendWithSpace (str, classKeyToString (class_decl->getKey ())); if (class_decl->isDllApi ()) { appendWithSpace (str, conf::getOptionValue (conf::opt_dll_api)); } appendWithSpace (str, nameToString (class_decl->getName ())); return str; }