// XML schema generator submitted by // Marc Dumontier, Blueprint initiative, [email protected] // modified by Andrei Gourianov, gouriano@ncbi void CReferenceDataType::PrintXMLSchema(CNcbiOstream& out, int indent, bool contents_only) const { string tag(XmlTagName()); string userType(UserTypeXmlTagName()); if (tag == userType || (GetEnforcedStdXml() && contents_only)) { if (IsRefToParent()) { const CDataType* par = GetParentType(); while ( par->GetParentType() ) { par = par->GetParentType(); } PrintASNNewLine(out,indent) << "<xs:element name=\"" << userType << "\"" << " type=\"" << par->GetMemberName() << userType << "_Type\""; if (GetDataMember()) { if (GetDataMember()->Optional()) { out << " minOccurs=\"0\""; } if (GetDataMember()->GetDefault()) { out << " default=\"" << GetDataMember()->GetDefault()->GetXmlString() << "\""; } } out << "/>"; return; } PrintASNNewLine(out,indent) << "<xs:element ref=\"" << userType << "\""; if (GetDataMember()) { if (GetDataMember()->Optional()) { out << " minOccurs=\"0\""; } if (GetDataMember()->GetDefault()) { out << " default=\"" << GetDataMember()->GetDefault()->GetXmlString() << "\""; } } out << "/>"; } else { if (!contents_only) { PrintASNNewLine(out,indent++) << "<xs:element name=\"" << tag << "\""; if (GetDataMember() && GetDataMember()->Optional()) { out << " minOccurs=\"0\""; } out << ">"; PrintASNNewLine(out,indent++) << "<xs:complexType>"; PrintASNNewLine(out,indent++) << "<xs:sequence>"; } PrintASNNewLine(out,indent) << "<xs:element ref=\"" << userType << "\"/>"; if (!contents_only) { PrintASNNewLine(out,--indent) << "</xs:sequence>"; PrintASNNewLine(out,--indent) << "</xs:complexType>"; PrintASNNewLine(out,--indent) << "</xs:element>"; } } }
void CReferenceDataType::PrintDTDExtra(CNcbiOstream& out) const { string tag(XmlTagName()); string userType(UserTypeXmlTagName()); const CUniSequenceDataType* uniType = dynamic_cast<const CUniSequenceDataType*>(GetParentType()); if (tag == userType || (GetEnforcedStdXml() && uniType)) { const CDataType* realType = ResolveOrNull(); if (realType) { realType->PrintDTDExtra(out); } } }
TEST(MangleTest, addressSpaceAndUserDefTy) { // "myf(__constant mta*)" const char* s = "_Z3myfPU3AS23mta"; FunctionDescriptor fd; RefParamType userType(new UserDefinedType("mta")); PointerType* userTypePtr(new PointerType(userType)); userTypePtr->setAddressSpace(ATTR_CONSTANT); RefParamType userTypePtrRef(userTypePtr); fd.name = "myf"; fd.parameters.push_back(userTypePtrRef); std::string mangled = mangle(fd); ASSERT_STREQ(s, mangled.c_str()); }
void CReferenceDataType::PrintDTDElement(CNcbiOstream& out, bool contents_only) const { string tag(XmlTagName()); string userType(UserTypeXmlTagName()); const CUniSequenceDataType* uniType = dynamic_cast<const CUniSequenceDataType*>(GetParentType()); if (tag == userType || (GetEnforcedStdXml() && uniType)) { const CDataType* realType = ResolveOrNull(); if (realType) { realType->PrintDTDElement(out, contents_only); } return; } out << "\n<!ELEMENT "<<XmlTagName()<<" ("<<UserTypeXmlTagName()<<")>"; }
void getUserNameLine(char* userLine) { userLine[0]='\0'; struct passwd *psw; psw = getpwuid(getuid()); strcat(userLine, psw->pw_name); strcat(userLine, "@"); char hostName[MAXLINE]; char wd[MAXLINE]; getwd(wd); if(gethostname(hostName, sizeof(hostName))) return; else strcat(userLine, hostName); strcat(userLine, ":"); strcat(userLine, wd); userType(); }