;
63 stringcontent(
"\n");
68content +=
" "+
i->GetName();
95 booloneLineComment =
i->GetComments().OneLine();
96 if( !oneLineComment )
101 if( oneLineComment ) {
117 out<<
"V,"<<
i->GetSourceLine() <<
',';
137 out<<
i->GetValue();
139 out<<
"\""<<
i->GetName() <<
"\"";
145[](ostream& ostm,
const TValue& e) {
146ostm << e.GetValue();
150[](ostream& ostm,
const TValue& e) {
151ostm <<
"\""<< e.GetName() <<
"\"";
158required.push_back(mem->
GetName());
169 stringuse(
"required");
170 string value(
"value");
172 boolinAttlist=
false;
174list<string> opentag, closetag;
192form =
" form=\"qualified\"";
195 if(!inAttlist && !isGlobalType) {
197 string tmp=
"<xs:element name=\""+
tag+
"\"";
199 tmp+=
" minOccurs=\"0\"";
204 #if _DATATOOL_USE_SCHEMA_STYLE_COMMENTS 211 opentag.push_back(tmp + ">"); 213 closetag.push_front("</xs:element>"); 214 if (IsASNDataSpec()) { 215 opentag.push_back("<xs:complexType>"); 216 closetag.push_front("</xs:complexType>"); 218 opentag.push_back("<xs:simpleContent>"); 219 closetag.push_front("</xs:simpleContent>"); 220 opentag.push_back("<xs:extension base=\"xs:integer\">"); 221 closetag.push_front("</xs:extension>"); 226 if (IsASNDataSpec() || inAttlist) { 227 string tmp = "<xs:attribute name=\"" + value + "\" use=\"" + use + "\"" + form; 228 const CDataMember* mem = GetDataMember(); 230 if (mem && mem->Optional() && mem->GetDefault()) { 231 tmp += " default=\"" + GetXmlValueName(mem->GetDefault()->GetXmlString()) + "\""; 234 opentag.push_back(tmp + ">"); 235 closetag.push_front("</xs:attribute>"); 238 string tmp = "<xs:simpleType name=\"" + tag + "\">"; 239 opentag.push_back(tmp); 241 opentag.push_back("<xs:simpleType>"); 243 closetag.push_front("</xs:simpleType>"); 244 if (IsASNDataSpec() || !IsInteger()) { 245 opentag.push_back("<xs:restriction base=\"xs:string\">"); 247 opentag.push_back("<xs:restriction base=\"xs:integer\">"); 249 closetag.push_front("</xs:restriction>"); 251 ITERATE ( list<string>, s, opentag ) { 252 PrintASNNewLine(out, indent++) << *s; 254 bool haveComments = false; 255 ITERATE ( TValues, i, m_Values ) { 256 if ( !i->GetComments().Empty() ) { 261 if ( haveComments ) { 262 #if _DATATOOL_USE_SCHEMA_STYLE_COMMENTS 263 PrintASNNewLine(out, indent) << "<xs:annotation><xs:documentation>"; 264 ITERATE ( TValues, i, m_Values ) { 265 if ( !i->GetComments().Empty() ) { 266 i->GetComments().Print(out, "\n "+i->GetName()+"\t- ", 270 PrintASNNewLine(out, indent) << "</xs:documentation></xs:annotation>"; 273 ITERATE ( TValues, i, m_Values ) { 274 if ( !i->GetComments().Empty() ) { 275 i->GetComments().Print(out, "\n "+i->GetName()+"\t- ", 282 ITERATE ( TValues, i, m_Values ) { 283 PrintASNNewLine(out, indent) << 284 "<xs:enumeration value=\"" << i->GetName() << "\""; 285 if (IsASNDataSpec() && IsInteger()) { 286 out << " ncbi:intvalue=\"" << i->GetValue() << "\""; 290 ITERATE ( list<string>, s, closetag ) { 291 PrintASNNewLine(out, --indent) << *s; 293 m_LastComments.PrintDTD(out, CComments::eMultiline); 296 void CEnumDataType::PrintDTDElement(CNcbiOstream& out, bool /*contents_only*/) const 298 string tag(XmlTagName()); 299 string content(GetXMLContents()); 300 if (GetParentType() && 301 GetParentType()->GetDataMember() && 302 GetParentType()->GetDataMember()->Attlist()) { 303 const CDataMember* mem = GetDataMember(); 304 out << "\n " << tag << " (" << content << ") "; 305 if (mem->GetDefault()) { 306 out << "\"" << GetXmlValueName(mem->GetDefault()->GetXmlString()) << "\""; 308 if (mem->Optional()) { 316 "\n<!ELEMENT " << tag << " "; 318 if (DTDEntitiesEnabled()) { 319 out << "(%INTEGER;)>"; 324 if (DTDEntitiesEnabled()) { 333 void CEnumDataType::PrintDTDExtra(CNcbiOstream& out) const 335 bool haveComments = false; 336 ITERATE ( TValues, i, m_Values ) { 337 if ( !i->GetComments().Empty() ) { 342 if ( haveComments ) { 344 ITERATE ( TValues, i, m_Values ) { 345 if ( !i->GetComments().Empty() ) { 346 i->GetComments().Print(out, " "+i->GetName()+"\t- ", 353 "\n<!ATTLIST "<<XmlTagName()<<" value (\n"; 354 ITERATE ( TValues, i, m_Values ) { 355 if ( i != m_Values.begin() ) 357 out << " " << i->GetName(); 365 m_LastComments.PrintDTD(out, CComments::eMultiline); 368 bool CEnumDataType::CheckValue(const CDataValue& value) const 370 const CIdDataValue* id = dynamic_cast<const CIdDataValue*>(&value); 372 ITERATE ( TValues, i, m_Values ) { 373 if ( i->GetName() == id->GetValue() ) 376 value.Warning("illegal ENUMERATED value: " + id->GetValue(), 12); 380 const CIntDataValue* intValue = 381 dynamic_cast<const CIntDataValue*>(&value); 383 value.Warning("ENUMERATED or INTEGER value expected", 13); 387 if ( !IsInteger() ) { 388 ITERATE ( TValues, i, m_Values ) { 389 if ( i->GetValue() == intValue->GetValue() ) 392 value.Warning("illegal INTEGER value: " + NStr::NumericToString(intValue->GetValue()), 14); 399 TObjectPtr CEnumDataType::CreateDefault(const CDataValue& value) const 401 const CIdDataValue* id = dynamic_cast<const CIdDataValue*>(&value); 403 return new TEnumValueType((TEnumValueType)dynamic_cast<const CIntDataValue&>(value).GetValue()); 405 ITERATE ( TValues, i, m_Values ) { 406 if ( i->GetName() == id->GetValue() ) 407 return new TEnumValueType(i->GetValue()); 409 value.Warning("illegal ENUMERATED value: " + id->GetValue(), 15); 413 string CEnumDataType::GetDefaultString(const CDataValue& value) const 415 CTypeStrings::EKind kind = GetFullCType()->GetKind(); 416 const CIdDataValue* id = dynamic_cast<const CIdDataValue*>(&value); 417 if (kind == CTypeStrings::eKindEnum) { 419 return GetEnumCInfo().valuePrefix + Identifier(id->GetValue(), false); 422 const CIntDataValue* intValue = 423 dynamic_cast<const CIntDataValue*>(&value); 424 return NStr::Int8ToString(intValue->GetValue()); 429 val = id->GetValue(); 432 const CIntDataValue* intValue = 433 dynamic_cast<const CIntDataValue*>(&value); 434 val = NStr::Int8ToString(intValue->GetValue()); 436 if (kind == CTypeStrings::eKindString) { 437 return string("\"") + val + "\""; 442 string CEnumDataType::GetXmlValueName(const string& value) const 447 CTypeInfo* CEnumDataType::CreateTypeInfo(void) 449 NCBI_LSAN_DISABLE_GUARD; 450 AutoPtr<CEnumeratedTypeValues> 451 info(new CEnumeratedTypeValues(GlobalName(), IsInteger())); 452 ITERATE ( TValues, i, m_Values ) { 453 info->AddValue(i->GetName(), i->GetValue()); 455 if ( HaveModuleName() ) 456 info->SetModuleName(GetModule()->GetName()); 457 return new CEnumeratedTypeInfo(sizeof(TEnumValueType), info.release()); 460 string CEnumDataType::DefaultEnumName(void) const 462 // generate enum name from ASN type or field name 463 if ( !GetParentType() ) { 465 return 'E' + Identifier(IdName()); 469 return 'E' + Identifier(GetKeyPrefix()); 473 CEnumDataType::SEnumCInfo CEnumDataType::GetEnumCInfo(void) const 475 string typeName = GetAndVerifyVar("_type"); 477 if ( !typeName.empty() && typeName[0] == 'E' ) { 481 // make C++ type name 482 enumName = DefaultEnumName(); 483 if ( typeName.empty() ) { 490 string prefix = GetVar("_prefix"); 491 if ( prefix.empty() ) { 492 prefix = char(tolower((unsigned char) enumName[0])) + enumName.substr(1) + '_'; 494 return SEnumCInfo(enumName, typeName, prefix); 497 AutoPtr<CTypeStrings> CEnumDataType::GetRefCType(void) const 499 SEnumCInfo enumInfo = GetEnumCInfo(); 500 return AutoPtr<CTypeStrings>(new CEnumRefTypeStrings(enumInfo.enumName, 507 AutoPtr<CTypeStrings> CEnumDataType::GetFullCType(void) const 509 ITERATE ( TValues, i, m_Values ) { 510 string id(Identifier( i->GetEnumId(), false )); 512 value = GetVar(id + "._hidename", false); 513 if (!value.empty()) { 514 if (NStr::StringToBool(value)) { 515 i->SetFlag(CEnumDataTypeValue::eHideName); 518 value = GetVar( id, false); 519 if (!value.empty()) { 523 // in case client wants std type instead of enum. 524 // I must be accurate here to not to mess with GetEnumCInfo() 525 string type = GetAndVerifyVar("_type"); 527 if (NStr::EndsWith(type, "string")) { 528 return AutoPtr<CTypeStrings>( 529 new CStringTypeStrings("NCBI_NS_STD::string",Comments(),true)); 530 } else if (NStr::EndsWith(type, "CStringUTF8")) { 531 return AutoPtr<CTypeStrings>( 532 new CStringTypeStrings("NCBI_NS_NCBI::CStringUTF8",Comments(),true)); 533 } else if (type == "double") { 534 return AutoPtr<CTypeStrings>( 535 new CStdTypeStrings(type,Comments(),true)); 539 SEnumCInfo enumInfo = GetEnumCInfo(); 540 AutoPtr<CEnumTypeStrings> 541 e(new CEnumTypeStrings(GlobalName(), enumInfo.enumName, 542 GetVar("_packedtype"), 543 enumInfo.cType, IsInteger(), 544 m_Values, enumInfo.valuePrefix, 545 GetNamespaceName(), this, Comments())); 547 string extra = GetVar("_type_extra"); 548 if (NStr::CompareNocase(extra, "bitset") == 0) { 551 return AutoPtr<CTypeStrings>(e.release()); 554 AutoPtr<CTypeStrings> CEnumDataType::GenerateCode(void) const 556 return GetFullCType(); 559 const char* CIntEnumDataType::GetASNKeyword(void) const 564 const char* CIntEnumDataType::GetDEFKeyword(void) const 566 return "_INTEGER_ENUM_"; 569 bool CIntEnumDataType::IsInteger(void) const 574 string CIntEnumDataType::GetXmlValueName(const string& value) const 577 // in case of named integers, value can be a name, not an integer 578 TEnumValueType d = (TEnumValueType)NStr::StringToInt(value); 579 ITERATE(TValues, v, GetValues()) { 580 if (v->GetValue() == d) { 589 const char* CBigIntEnumDataType::GetASNKeyword(void) const 594 const char* CBigIntEnumDataType::GetDEFKeyword(void) const 596 return "_BigInt_ENUM_";bool Optional(void) const
const string & GetName(void) const
const CDataValue * GetDefault(void) const
static string ToAsnId(const string &name)
EGlobalType GetGlobalType(void) const
const CDataMember * GetDataMember(void) const
CNcbiOstream & PrintASNTag(CNcbiOstream &out) const
CComments & Comments(void)
string GetFullName(void) const
const CDataType * GetParentType(void) const
static bool GetEnforcedStdXml(void)
ENsQualifiedMode IsNsQualified(void) const
string XmlTagName(void) const
virtual string GetXmlString(void) const =0
virtual string GetXmlValueName(const string &value) const
virtual void PrintASN(CNcbiOstream &out, int indent) const override
CEnumDataTypeValue TValue
virtual const char * GetDEFKeyword(void) const override
virtual void PrintXMLSchema(CNcbiOstream &out, int indent, bool contents_only=false) const override
TValue & AddValue(const string &name, TEnumValueType value)
virtual string GetXMLContents(void) const
virtual void PrintJSONSchema(CNcbiOstream &out, int indent, list< string > &required, bool contents_only=false) const override
virtual void PrintSpecDumpExtra(CNcbiOstream &out, int indent) const override
virtual const char * GetASNKeyword(void) const override
virtual bool IsInteger(void) const
container_type::const_iterator const_iterator
std::ofstream out("events_result.xml")
main entry point for tests
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
const GenericPointer< typename T::ValueType > T2 value
Common macro to detect used sanitizers and suppress memory leaks if run under LeakSanitizer.
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
CNcbiOstream & PrintASNNewLine(CNcbiOstream &out, int indent)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4