00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #include <ncbi_pch.hpp>
00033 #include "exceptions.hpp"
00034 #include "statictype.hpp"
00035 #include "stdstr.hpp"
00036 #include "stlstr.hpp"
00037 #include "value.hpp"
00038 #include "blocktype.hpp"
00039 #include "srcutil.hpp"
00040 #include <serial/impl/stdtypes.hpp>
00041 #include <serial/impl/stltypes.hpp>
00042 #include <serial/impl/autoptrinfo.hpp>
00043 #include <typeinfo>
00044 #include <vector>
00045
00046 BEGIN_NCBI_SCOPE
00047
00048 TObjectPtr CStaticDataType::CreateDefault(const CDataValue& ) const
00049 {
00050 NCBI_THROW(CDatatoolException, eNotImplemented,
00051 GetASNKeyword() + string(" default not implemented"));
00052 }
00053
00054 void CStaticDataType::PrintASN(CNcbiOstream& out, int ) const
00055 {
00056 out << GetASNKeyword();
00057 }
00058
00059
00060
00061
00062 void CStaticDataType::PrintXMLSchema(CNcbiOstream& out,
00063 int indent, bool contents_only) const
00064 {
00065 string tag( XmlTagName());
00066 string xsdk("element"), use;
00067 const CDataMember* mem = GetDataMember();
00068 bool optional = mem ? mem->Optional() : false;
00069
00070 if (GetParentType() && GetParentType()->GetDataMember()) {
00071 if (GetParentType()->GetDataMember()->Attlist()) {
00072 xsdk = "attribute";
00073 if (optional) {
00074 use = "optional";
00075 if (mem->GetDefault()) {
00076 use += "\" default=\"" + mem->GetDefault()->GetXmlString();
00077 }
00078 } else {
00079 use = "required";
00080 }
00081 }
00082 }
00083 PrintASNNewLine(out, indent) << "<xs:" << xsdk << " name=\"" << tag << "\"";
00084 string type = GetSchemaTypeString();
00085 if (!type.empty()) {
00086 out << " type=\"" << type << "\"";
00087 }
00088 if (!use.empty()) {
00089 out << " use=\"" << use << "\"";
00090 } else {
00091 if (GetXmlSourceSpec()) {
00092 if (optional) {
00093 out << " minOccurs=\"0\"";
00094 }
00095 if (mem && mem->GetDefault()) {
00096 out << " default=\"" << mem->GetDefault()->GetXmlString() << "\"";
00097 }
00098 } else {
00099 const CBoolDataType* bt = dynamic_cast<const CBoolDataType*>(this);
00100 if (mem && optional) {
00101 if (bt) {
00102 out << " minOccurs=\"0\"";
00103 } else {
00104 if (mem->GetDefault()) {
00105 out << " default=\"" << mem->GetDefault()->GetXmlString() << "\"";
00106 } else {
00107 out << " minOccurs=\"0\"";
00108 }
00109 }
00110 }
00111 }
00112 }
00113 if (type.empty() && PrintXMLSchemaContents(out,indent+1)) {
00114 PrintASNNewLine(out, indent) << "</xs:" << xsdk << ">";
00115 } else {
00116 out << "/>";
00117 }
00118 }
00119
00120 bool CStaticDataType::PrintXMLSchemaContents(CNcbiOstream& out, int indent) const
00121 {
00122 return false;
00123 }
00124
00125 void CStaticDataType::PrintDTDElement(CNcbiOstream& out, bool contents_only) const
00126 {
00127 string tag(XmlTagName());
00128 string content(GetXMLContents());
00129 if (GetParentType() &&
00130 GetParentType()->GetDataMember() &&
00131 GetParentType()->GetDataMember()->Attlist()) {
00132 const CDataMember* mem = GetDataMember();
00133 out << "\n " << tag;
00134 const CBoolDataType* bt = dynamic_cast<const CBoolDataType*>(this);
00135 if (bt) {
00136 out << " ( true | false ) ";
00137 } else {
00138 out << " CDATA ";
00139 }
00140 if (mem->GetDefault()) {
00141 out << "\"" << mem->GetDefault()->GetXmlString() << "\"";
00142 } else {
00143 if (mem->Optional()) {
00144 out << "#IMPLIED";
00145 } else {
00146 out << "#REQUIRED";
00147 }
00148 }
00149 } else {
00150 string open("("), close(")");
00151 if (content == "EMPTY") {
00152 open.erase();
00153 close.erase();
00154 }
00155 if (!contents_only) {
00156 out << "\n<!ELEMENT " << tag << ' ' << open;
00157 }
00158 out << content;
00159 if (!contents_only) {
00160 out << close << ">";
00161 }
00162 }
00163 }
00164
00165 AutoPtr<CTypeStrings> CStaticDataType::GetFullCType(void) const
00166 {
00167 string type = GetAndVerifyVar("_type");
00168 if ( type.empty() )
00169 type = GetDefaultCType();
00170 return AutoPtr<CTypeStrings>(new CStdTypeStrings(type,Comments()));
00171 }
00172
00173 const char* CNullDataType::GetASNKeyword(void) const
00174 {
00175 return "NULL";
00176 }
00177
00178 const char* CNullDataType::GetDEFKeyword(void) const
00179 {
00180 return "_NULL_";
00181 }
00182
00183 const char* CNullDataType::GetXMLContents(void) const
00184 {
00185 return "EMPTY";
00186 }
00187
00188 bool CNullDataType::PrintXMLSchemaContents(CNcbiOstream& out, int indent) const
00189 {
00190 out << ">";
00191 PrintASNNewLine(out, indent) << "<xs:complexType/>";
00192 return true;
00193 }
00194
00195 bool CNullDataType::CheckValue(const CDataValue& value) const
00196 {
00197 CheckValueType(value, CNullDataValue, "NULL");
00198 return true;
00199 }
00200
00201 TObjectPtr CNullDataType::CreateDefault(const CDataValue& ) const
00202 {
00203 NCBI_THROW(CDatatoolException, eNotImplemented,
00204 "NULL cannot have DEFAULT");
00205 }
00206
00207 CTypeRef CNullDataType::GetTypeInfo(void)
00208 {
00209 if ( HaveModuleName() )
00210 return UpdateModuleName(CStdTypeInfo<bool>::CreateTypeInfoNullBool());
00211 return &CStdTypeInfo<bool>::GetTypeInfoNullBool;
00212 }
00213
00214 AutoPtr<CTypeStrings> CNullDataType::GetFullCType(void) const
00215 {
00216 return AutoPtr<CTypeStrings>(new CNullTypeStrings(Comments()));
00217 }
00218
00219 const char* CNullDataType::GetDefaultCType(void) const
00220 {
00221 return "bool";
00222 }
00223
00224 const char* CBoolDataType::GetASNKeyword(void) const
00225 {
00226 return "BOOLEAN";
00227 }
00228
00229 const char* CBoolDataType::GetDEFKeyword(void) const
00230 {
00231 return "_BOOLEAN_";
00232 }
00233
00234 const char* CBoolDataType::GetXMLContents(void) const
00235 {
00236
00237 return "EMPTY";
00238 }
00239
00240 string CBoolDataType::GetSchemaTypeString(void) const
00241 {
00242 if (GetXmlSourceSpec()) {
00243 return "xs:boolean";
00244 }
00245 if (GetParentType() &&
00246 GetParentType()->GetDataMember() &&
00247 GetParentType()->GetDataMember()->Attlist()) {
00248 return "xs:boolean";
00249 }
00250 return kEmptyStr;
00251 }
00252
00253 bool CBoolDataType::PrintXMLSchemaContents(CNcbiOstream& out, int indent) const
00254 {
00255 if (GetParentType() &&
00256 GetParentType()->GetDataMember() &&
00257 GetParentType()->GetDataMember()->Attlist()) {
00258 return false;
00259 }
00260 out << ">";
00261 const CBoolDataValue *val = GetDataMember() ?
00262 dynamic_cast<const CBoolDataValue*>(GetDataMember()->GetDefault()) : 0;
00263
00264 PrintASNNewLine(out,indent++) << "<xs:complexType>";
00265 PrintASNNewLine(out,indent++) << "<xs:attribute name=\"value\" use=";
00266 if (val) {
00267 out << "\"optional\" default=";
00268 if (val->GetValue()) {
00269 out << "\"true\"";
00270 } else {
00271 out << "\"false\"";
00272 }
00273 } else {
00274 out << "\"required\"";
00275 }
00276 out << ">";
00277 PrintASNNewLine(out,indent++) << "<xs:simpleType>";
00278 PrintASNNewLine(out,indent++) << "<xs:restriction base=\"xs:string\">";
00279 PrintASNNewLine(out,indent) << "<xs:enumeration value=\"true\"/>";
00280 PrintASNNewLine(out,indent) << "<xs:enumeration value=\"false\"/>";
00281 PrintASNNewLine(out,--indent) << "</xs:restriction>";
00282 PrintASNNewLine(out,--indent) << "</xs:simpleType>";
00283 PrintASNNewLine(out,--indent) << "</xs:attribute>";
00284 PrintASNNewLine(out,--indent) << "</xs:complexType>";
00285 return true;
00286 }
00287
00288 void CBoolDataType::PrintDTDExtra(CNcbiOstream& out) const
00289 {
00290 const char *attr;
00291 const CBoolDataValue *val = GetDataMember() ?
00292 dynamic_cast<const CBoolDataValue*>(GetDataMember()->GetDefault()) : 0;
00293
00294 if(val) {
00295 attr = val->GetValue() ? "\"true\"" : "\"false\"";
00296 }
00297 else {
00298 attr = "#REQUIRED";
00299 }
00300
00301 out <<
00302 "\n<!ATTLIST "<<XmlTagName()<<" value ( true | false ) "
00303 << attr << " >\n";
00304 }
00305
00306 bool CBoolDataType::CheckValue(const CDataValue& value) const
00307 {
00308 CheckValueType(value, CBoolDataValue, "BOOLEAN");
00309 return true;
00310 }
00311
00312 TObjectPtr CBoolDataType::CreateDefault(const CDataValue& value) const
00313 {
00314 return new bool(dynamic_cast<const CBoolDataValue&>(value).GetValue());
00315 }
00316
00317 string CBoolDataType::GetDefaultString(const CDataValue& value) const
00318 {
00319 return (dynamic_cast<const CBoolDataValue&>(value).GetValue()?
00320 "true": "false");
00321 }
00322
00323 CTypeRef CBoolDataType::GetTypeInfo(void)
00324 {
00325 if ( HaveModuleName() )
00326 return UpdateModuleName(CStdTypeInfo<bool>::CreateTypeInfo());
00327 return &CStdTypeInfo<bool>::GetTypeInfo;
00328 }
00329
00330 const char* CBoolDataType::GetDefaultCType(void) const
00331 {
00332 return "bool";
00333 }
00334
00335 CRealDataType::CRealDataType(void)
00336 {
00337 ForbidVar("_type", "string");
00338 }
00339
00340 const char* CRealDataType::GetASNKeyword(void) const
00341 {
00342 return "REAL";
00343 }
00344
00345 const char* CRealDataType::GetDEFKeyword(void) const
00346 {
00347 return "_REAL_";
00348 }
00349
00350 const char* CRealDataType::GetXMLContents(void) const
00351 {
00352 return DTDEntitiesEnabled() ? "%REAL;" : "#PCDATA";
00353 }
00354
00355 string CRealDataType::GetSchemaTypeString(void) const
00356 {
00357 return "xs:double";
00358 }
00359
00360 bool CRealDataType::CheckValue(const CDataValue& value) const
00361 {
00362 const CBlockDataValue* block = dynamic_cast<const CBlockDataValue*>(&value);
00363 if ( !block ) {
00364 return dynamic_cast<const CDoubleDataValue*>(&value) != 0 ||
00365 dynamic_cast<const CIntDataValue*>(&value) != 0;
00366 }
00367 if ( block->GetValues().size() != 3 ) {
00368 value.Warning("wrong number of elements in REAL value", 16);
00369 return false;
00370 }
00371 for ( CBlockDataValue::TValues::const_iterator i = block->GetValues().begin();
00372 i != block->GetValues().end(); ++i ) {
00373 CheckValueType(**i, CIntDataValue, "INTEGER");
00374 }
00375 return true;
00376 }
00377
00378 TObjectPtr CRealDataType::CreateDefault(const CDataValue& value) const
00379 {
00380 double d=0.;
00381 const CDoubleDataValue* dbl = dynamic_cast<const CDoubleDataValue*>(&value);
00382 if (dbl) {
00383 d = dbl->GetValue();
00384 } else {
00385 const CIntDataValue* i = dynamic_cast<const CIntDataValue*>(&value);
00386 if (i) {
00387 d = (double)(i->GetValue());
00388 }
00389 }
00390 return new double(d);
00391 }
00392
00393 string CRealDataType::GetDefaultString(const CDataValue& value) const
00394 {
00395 const CDoubleDataValue* dbl = dynamic_cast<const CDoubleDataValue*>(&value);
00396 if (dbl) {
00397 return NStr::DoubleToString(dbl->GetValue());
00398 } else {
00399 const CIntDataValue* i = dynamic_cast<const CIntDataValue*>(&value);
00400 if (i) {
00401 return NStr::DoubleToString((double)(i->GetValue()));
00402 }
00403 }
00404 value.Warning("REAL value expected", 17);
00405 return kEmptyStr;
00406 }
00407
00408 TTypeInfo CRealDataType::GetRealTypeInfo(void)
00409 {
00410 if ( HaveModuleName() )
00411 return UpdateModuleName(CStdTypeInfo<double>::CreateTypeInfo());
00412 return CStdTypeInfo<double>::GetTypeInfo();
00413 }
00414
00415 const char* CRealDataType::GetDefaultCType(void) const
00416 {
00417 return "double";
00418 }
00419
00420 CStringDataType::CStringDataType(EType type)
00421 : m_Type(type)
00422 {
00423 ForbidVar("_type", "short");
00424 ForbidVar("_type", "int");
00425 ForbidVar("_type", "long");
00426 ForbidVar("_type", "unsigned");
00427 ForbidVar("_type", "unsigned short");
00428 ForbidVar("_type", "unsigned int");
00429 ForbidVar("_type", "unsigned long");
00430 }
00431
00432 const char* CStringDataType::GetASNKeyword(void) const
00433 {
00434 if (m_Type == eStringTypeUTF8) {
00435 return "UTF8String";
00436 }
00437 return "VisibleString";
00438 }
00439
00440 const char* CStringDataType::GetDEFKeyword(void) const
00441 {
00442 if (m_Type == eStringTypeUTF8) {
00443 return "_UTF8String_";
00444 }
00445 return "_VisibleString_";
00446 }
00447
00448 const char* CStringDataType::GetXMLContents(void) const
00449 {
00450 return "#PCDATA";
00451 }
00452
00453 string CStringDataType::GetSchemaTypeString(void) const
00454 {
00455 return "xs:string";
00456 }
00457
00458 bool CStringDataType::CheckValue(const CDataValue& value) const
00459 {
00460 CheckValueType(value, CStringDataValue, "string");
00461 return true;
00462 }
00463
00464 TObjectPtr CStringDataType::CreateDefault(const CDataValue& value) const
00465 {
00466 if (m_Type == eStringTypeUTF8) {
00467 return new (CStringUTF8*)(new CStringUTF8(dynamic_cast<const CStringDataValue&>(value).GetValue()));
00468 }
00469 return new (string*)(new string(dynamic_cast<const CStringDataValue&>(value).GetValue()));
00470 }
00471
00472 string CStringDataType::GetDefaultString(const CDataValue& value) const
00473 {
00474 string s;
00475 s += '\"';
00476 const string& v = dynamic_cast<const CStringDataValue&>(value).GetValue();
00477 for ( string::const_iterator i = v.begin(); i != v.end(); ++i ) {
00478 switch ( *i ) {
00479 case '\r':
00480 s += "\\r";
00481 break;
00482 case '\n':
00483 s += "\\n";
00484 break;
00485 case '\"':
00486 s += "\\\"";
00487 break;
00488 case '\\':
00489 s += "\\\\";
00490 break;
00491 default:
00492 s += *i;
00493 }
00494 }
00495 return s + '\"';
00496 }
00497
00498 TTypeInfo CStringDataType::GetRealTypeInfo(void)
00499 {
00500 if ( HaveModuleName() )
00501 return UpdateModuleName(CStdTypeInfo<string>::CreateTypeInfo());
00502 return CStdTypeInfo<string>::GetTypeInfo();
00503 }
00504
00505 bool CStringDataType::NeedAutoPointer(TTypeInfo ) const
00506 {
00507 return true;
00508 }
00509
00510 AutoPtr<CTypeStrings> CStringDataType::GetFullCType(void) const
00511 {
00512 string type = GetAndVerifyVar("_type");
00513 if ( type.empty() )
00514 type = GetDefaultCType();
00515 return AutoPtr<CTypeStrings>(new CStringTypeStrings(type,Comments()));
00516 }
00517
00518 const char* CStringDataType::GetDefaultCType(void) const
00519 {
00520 if (m_Type == eStringTypeUTF8) {
00521 return "ncbi::CStringUTF8";
00522 }
00523 return "NCBI_NS_STD::string";
00524 }
00525
00526 CStringStoreDataType::CStringStoreDataType(void)
00527 {
00528 }
00529
00530 const char* CStringStoreDataType::GetASNKeyword(void) const
00531 {
00532 return "StringStore";
00533 }
00534
00535 const char* CStringStoreDataType::GetDEFKeyword(void) const
00536 {
00537 return "_StringStore_";
00538 }
00539
00540 TTypeInfo CStringStoreDataType::GetRealTypeInfo(void)
00541 {
00542 return CStdTypeInfo<string>::GetTypeInfoStringStore();
00543 }
00544
00545 bool CStringStoreDataType::NeedAutoPointer(TTypeInfo ) const
00546 {
00547 return true;
00548 }
00549
00550 AutoPtr<CTypeStrings> CStringStoreDataType::GetFullCType(void) const
00551 {
00552 string type = GetAndVerifyVar("_type");
00553 if ( type.empty() )
00554 type = GetDefaultCType();
00555 return AutoPtr<CTypeStrings>(new CStringStoreTypeStrings(type,Comments()));
00556 }
00557
00558 const char* CBitStringDataType::GetASNKeyword(void) const
00559 {
00560 return "BIT STRING";
00561 }
00562
00563 const char* CBitStringDataType::GetDEFKeyword(void) const
00564 {
00565 return "_BIT_STRING_";
00566 }
00567
00568 bool CBitStringDataType::CheckValue(const CDataValue& value) const
00569 {
00570 CheckValueType(value, CBitStringDataValue, "BIT STRING");
00571 return true;
00572 }
00573
00574 TTypeInfo CBitStringDataType::GetRealTypeInfo(void)
00575 {
00576 if ( HaveModuleName() )
00577 return UpdateModuleName(CStdTypeInfo<CBitString>::CreateTypeInfo());
00578 return CStdTypeInfo<CBitString>::GetTypeInfo();
00579 }
00580
00581 bool CBitStringDataType::NeedAutoPointer(TTypeInfo ) const
00582 {
00583 return true;
00584 }
00585
00586 AutoPtr<CTypeStrings> CBitStringDataType::GetFullCType(void) const
00587 {
00588 return AutoPtr<CTypeStrings>(new CBitStringTypeStrings( GetDefaultCType(), Comments() ));
00589 }
00590
00591 const char* CBitStringDataType::GetDefaultCType(void) const
00592 {
00593 return "ncbi::CBitString";
00594 }
00595
00596 const char* CBitStringDataType::GetXMLContents(void) const
00597 {
00598 return DTDEntitiesEnabled() ? "%BITS;" : "#PCDATA";
00599 }
00600
00601 bool CBitStringDataType::PrintXMLSchemaContents(CNcbiOstream& out, int indent) const
00602 {
00603 out << ">";
00604 PrintASNNewLine(out,indent++) << "<xs:simpleType>";
00605 PrintASNNewLine(out,indent++) << "<xs:restriction base=\"xs:string\">";
00606 PrintASNNewLine(out,indent) << "<xs:pattern value=\"([0-1])*\"/>";
00607 PrintASNNewLine(out,--indent) << "</xs:restriction>";
00608 PrintASNNewLine(out,--indent) << "</xs:simpleType>";
00609 return true;
00610 }
00611
00612 const char* COctetStringDataType::GetASNKeyword(void) const
00613 {
00614 return "OCTET STRING";
00615 }
00616
00617 const char* COctetStringDataType::GetDEFKeyword(void) const
00618 {
00619 return "_OCTET_STRING_";
00620 }
00621
00622 const char* COctetStringDataType::GetDefaultCType(void) const
00623 {
00624 if (x_AsBitString()) {
00625 return CBitStringDataType::GetDefaultCType();
00626 }
00627 return "NCBI_NS_STD::vector<char>";
00628 }
00629
00630 const char* COctetStringDataType::GetXMLContents(void) const
00631 {
00632 return DTDEntitiesEnabled() ? "%OCTETS;" : "#PCDATA";
00633 }
00634
00635 string COctetStringDataType::GetSchemaTypeString(void) const
00636 {
00637 return "xs:hexBinary";
00638 }
00639
00640 bool COctetStringDataType::CheckValue(const CDataValue& value) const
00641 {
00642 CheckValueType(value, COctetStringDataType, "OCTET STRING");
00643 return true;
00644 }
00645
00646 TTypeInfo COctetStringDataType::GetRealTypeInfo(void)
00647 {
00648 if (x_AsBitString()) {
00649 return CBitStringDataType::GetRealTypeInfo();
00650 }
00651 if ( HaveModuleName() )
00652 return UpdateModuleName(CStdTypeInfo<vector<char> >::CreateTypeInfo());
00653 return CStdTypeInfo< vector<char> >::GetTypeInfo();
00654 }
00655
00656 bool COctetStringDataType::NeedAutoPointer(TTypeInfo ) const
00657 {
00658 return true;
00659 }
00660
00661 AutoPtr<CTypeStrings> COctetStringDataType::GetFullCType(void) const
00662 {
00663 if (x_AsBitString()) {
00664 return CBitStringDataType::GetFullCType();
00665 }
00666 string charType = GetVar("_char");
00667 if ( charType.empty() )
00668 charType = "char";
00669 return AutoPtr<CTypeStrings>(new CVectorTypeStrings(charType, GetNamespaceName(), Comments()));
00670 }
00671
00672 bool COctetStringDataType::IsCompressed(void) const
00673 {
00674 return x_AsBitString();
00675 }
00676
00677 bool COctetStringDataType::x_AsBitString(void) const
00678 {
00679 string type = GetVar("_type");
00680 return NStr::FindNoCase(type, "CBitString") != NPOS;
00681 }
00682
00683 string CBase64BinaryDataType::GetSchemaTypeString(void) const
00684 {
00685 return "xs:base64Binary";
00686 }
00687
00688 bool CBase64BinaryDataType::IsCompressed(void) const
00689 {
00690 return true;
00691 }
00692
00693 bool CBase64BinaryDataType::x_AsBitString(void) const
00694 {
00695 return false;
00696 }
00697
00698 CIntDataType::CIntDataType(void)
00699 {
00700 ForbidVar("_type", "string");
00701 }
00702
00703 const char* CIntDataType::GetASNKeyword(void) const
00704 {
00705 return "INTEGER";
00706 }
00707
00708 const char* CIntDataType::GetDEFKeyword(void) const
00709 {
00710 return "_INTEGER_";
00711 }
00712
00713 const char* CIntDataType::GetXMLContents(void) const
00714 {
00715 return DTDEntitiesEnabled() ? "%INTEGER;" : "#PCDATA";
00716 }
00717
00718 string CIntDataType::GetSchemaTypeString(void) const
00719 {
00720 return "xs:integer";
00721 }
00722
00723 bool CIntDataType::CheckValue(const CDataValue& value) const
00724 {
00725 CheckValueType(value, CIntDataValue, "INTEGER");
00726 return true;
00727 }
00728
00729 TObjectPtr CIntDataType::CreateDefault(const CDataValue& value) const
00730 {
00731 return new Int4(dynamic_cast<const CIntDataValue&>(value).GetValue());
00732 }
00733
00734 string CIntDataType::GetDefaultString(const CDataValue& value) const
00735 {
00736 return NStr::IntToString(dynamic_cast<const CIntDataValue&>(value).GetValue());
00737 }
00738
00739 CTypeRef CIntDataType::GetTypeInfo(void)
00740 {
00741 if ( HaveModuleName() )
00742 return UpdateModuleName(CStdTypeInfo<Int4>::CreateTypeInfo());
00743 return &CStdTypeInfo<Int4>::GetTypeInfo;
00744 }
00745
00746 const char* CIntDataType::GetDefaultCType(void) const
00747 {
00748 return "int";
00749 }
00750
00751 const char* CBigIntDataType::GetASNKeyword(void) const
00752 {
00753 return "BigInt";
00754 }
00755
00756 const char* CBigIntDataType::GetDEFKeyword(void) const
00757 {
00758 return "_BigInt_";
00759 }
00760
00761 const char* CBigIntDataType::GetXMLContents(void) const
00762 {
00763 return DTDEntitiesEnabled() ? "%INTEGER;" : "#PCDATA";
00764 }
00765
00766 string CBigIntDataType::GetSchemaTypeString(void) const
00767 {
00768 return "xs:long";
00769 }
00770
00771 bool CBigIntDataType::CheckValue(const CDataValue& value) const
00772 {
00773 CheckValueType(value, CIntDataValue, "BigInt");
00774 return true;
00775 }
00776
00777 TObjectPtr CBigIntDataType::CreateDefault(const CDataValue& value) const
00778 {
00779 return new Int8(dynamic_cast<const CIntDataValue&>(value).GetValue());
00780 }
00781
00782 string CBigIntDataType::GetDefaultString(const CDataValue& value) const
00783 {
00784 return NStr::IntToString(dynamic_cast<const CIntDataValue&>(value).GetValue());
00785 }
00786
00787 CTypeRef CBigIntDataType::GetTypeInfo(void)
00788 {
00789 if ( HaveModuleName() )
00790 return UpdateModuleName(CStdTypeInfo<Int8>::CreateTypeInfo());
00791 return &CStdTypeInfo<Int8>::GetTypeInfo;
00792 }
00793
00794 const char* CBigIntDataType::GetDefaultCType(void) const
00795 {
00796 return "Int8";
00797 }
00798
00799
00800 bool CAnyContentDataType::CheckValue(const CDataValue& ) const
00801 {
00802 return true;
00803 }
00804
00805 void CAnyContentDataType::PrintASN(CNcbiOstream& out, int ) const
00806 {
00807 out << GetASNKeyword();
00808 }
00809
00810 void CAnyContentDataType::PrintXMLSchema(CNcbiOstream& out, int indent, bool contents_only) const
00811 {
00812 const CDataMember* mem = GetDataMember();
00813 if (mem) {
00814 PrintASNNewLine(out,indent) << "<xs:any processContents=\"lax\"";
00815 const string& ns = GetNamespaceName();
00816 if (!ns.empty()) {
00817 out << " namespace=\"" << ns << "\"";
00818 }
00819 if (mem->Optional()) {
00820 out << " minOccurs=\"0\"";
00821 }
00822 out << "/>";
00823 } else {
00824 if (!contents_only) {
00825 PrintASNNewLine(out,indent++) <<
00826 "<xs:element name=\"" << XmlTagName() << "\">";
00827 }
00828 PrintASNNewLine(out,indent++) << "<xs:complexType>";
00829 PrintASNNewLine(out,indent++) << "<xs:sequence>";
00830 PrintASNNewLine(out,indent) << "<xs:any processContents=\"lax\"/>";
00831 PrintASNNewLine(out,--indent) << "</xs:sequence>";
00832 PrintASNNewLine(out,--indent) << "</xs:complexType>";
00833 if (!contents_only) {
00834 PrintASNNewLine(out,--indent) << "</xs:element>";
00835 }
00836 }
00837 }
00838
00839 void CAnyContentDataType::PrintDTDElement(CNcbiOstream& out, bool contents_only) const
00840 {
00841 if (!contents_only) {
00842 out << "\n<!ELEMENT " << XmlTagName() << " ";
00843 }
00844 out << GetXMLContents();
00845 if (!contents_only) {
00846 out << ">";
00847 }
00848 }
00849
00850 TObjectPtr CAnyContentDataType::CreateDefault(const CDataValue& value) const
00851 {
00852 return new (string*)(new string(dynamic_cast<const CStringDataValue&>(value).GetValue()));
00853 }
00854
00855 AutoPtr<CTypeStrings> CAnyContentDataType::GetFullCType(void) const
00856 {
00857
00858 string type = GetAndVerifyVar("_type");
00859 if ( type.empty() )
00860 type = GetDefaultCType();
00861 return AutoPtr<CTypeStrings>(new CAnyContentTypeStrings(type,Comments()));
00862 }
00863
00864 const char* CAnyContentDataType::GetDefaultCType(void) const
00865 {
00866 return "ncbi::CAnyContentObject";
00867 }
00868
00869 const char* CAnyContentDataType::GetASNKeyword(void) const
00870 {
00871
00872
00873 return "VisibleString";
00874 }
00875
00876 const char* CAnyContentDataType::GetDEFKeyword(void) const
00877 {
00878 return "_AnyContent_";
00879 }
00880
00881 const char* CAnyContentDataType::GetXMLContents(void) const
00882 {
00883 return "ANY";
00884 }
00885
00886 END_NCBI_SCOPE
00887
00888