⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 type.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
string CDataType::InheritFromClass(void) const{    return GetVar("_parent_class");}const CDataType* CDataType::InheritFromType(void) const{    const string& parentName = GetVar("_parent_type");    if ( !parentName.empty() )        return ResolveGlobal(parentName);    return 0;}CDataType* CDataType::Resolve(void){    return this;}const CDataType* CDataType::Resolve(void) const{    return this;}CDataType* CDataType::ResolveLocal(const string& name) const{    return GetModule()->Resolve(name);}CDataType* CDataType::ResolveGlobal(const string& name) const{    SIZE_TYPE dot = name.find('.');    if ( dot == NPOS ) {        // no module specified        return GetModule()->Resolve(name);    }    else {        // resolve by module        string moduleName = name.substr(0, dot);        string typeName = name.substr(dot + 1);        return GetModule()->GetModuleContainer().InternalResolve(moduleName,                                                                 typeName);    }}CTypeRef CDataType::GetTypeInfo(void){    if ( !m_TypeRef )        m_TypeRef = CTypeRef(new CAnyTypeSource(this));    return m_TypeRef;}TTypeInfo CDataType::GetAnyTypeInfo(void){    TTypeInfo typeInfo = m_AnyTypeInfo.get();    if ( !typeInfo ) {        typeInfo = GetRealTypeInfo();        if ( NeedAutoPointer(typeInfo) ) {            m_AnyTypeInfo.reset(new CAutoPointerTypeInfo(typeInfo));            typeInfo = m_AnyTypeInfo.get();        }    }    return typeInfo;}bool CDataType::NeedAutoPointer(TTypeInfo typeInfo) const{    return typeInfo->GetSize() > sizeof(AnyType);}TTypeInfo CDataType::GetRealTypeInfo(void){    TTypeInfo typeInfo = m_RealTypeInfo.get();    if ( !typeInfo ) {        m_RealTypeInfo.reset(CreateTypeInfo());        typeInfo = m_RealTypeInfo.get();    }    return typeInfo;}CTypeInfo* CDataType::CreateTypeInfo(void){    NCBI_THROW(CDatatoolException,eIllegalCall,        "cannot create type info of "+IdName());}CTypeInfo* CDataType::UpdateModuleName(CTypeInfo* typeInfo) const{    if ( HaveModuleName() )        typeInfo->SetModuleName(GetModule()->GetName());    return typeInfo;}AutoPtr<CTypeStrings> CDataType::GenerateCode(void) const{    if ( !IsAlias() ) {        AutoPtr<CClassTypeStrings> code(new CClassTypeStrings(GlobalName(),                                                              ClassName()));        AutoPtr<CTypeStrings> dType = GetFullCType();        bool nonempty = false, noprefix = false;        const CUniSequenceDataType* uniseq =            dynamic_cast<const CUniSequenceDataType*>(this);        if (uniseq) {            nonempty = uniseq->IsNonEmpty();            noprefix = uniseq->IsNoPrefix();        }        code->AddMember(dType, GetTag(), nonempty, noprefix);        SetParentClassTo(*code);        return AutoPtr<CTypeStrings>(code.release());    }    else {        AutoPtr<CTypeStrings> dType = GetFullCType();        AutoPtr<CAliasTypeStrings> code(new CAliasTypeStrings(GlobalName(),                                                              ClassName(),                                                              *dType.release()));        return AutoPtr<CTypeStrings>(code.release());    }}void CDataType::SetParentClassTo(CClassTypeStrings& code) const{    const CDataType* parent = InheritFromType();    if ( parent ) {        code.SetParentClass(parent->ClassName(),                            parent->Namespace(),                            parent->FileName());    }    else {        string parentClassName = InheritFromClass();        if ( !parentClassName.empty() ) {            SIZE_TYPE pos = parentClassName.rfind("::");            if ( pos != NPOS ) {                code.SetParentClass(parentClassName.substr(pos + 2),                                    CNamespace(parentClassName.substr(0, pos)),                                    NcbiEmptyString);            }            else {                code.SetParentClass(parentClassName,                                    CNamespace::KEmptyNamespace,                                    NcbiEmptyString);            }        }    }}AutoPtr<CTypeStrings> CDataType::GetRefCType(void) const{    if ( !IsAlias() ) {        return AutoPtr<CTypeStrings>(new CClassRefTypeStrings(ClassName(),                                                              Namespace(),                                                              FileName()));    }    else {        AutoPtr<CTypeStrings> dType = GetFullCType();        AutoPtr<CAliasRefTypeStrings> code(new CAliasRefTypeStrings(ClassName(),                                                                    Namespace(),                                                                    FileName(),                                                                    *dType.release()));        return AutoPtr<CTypeStrings>(code.release());    }}AutoPtr<CTypeStrings> CDataType::GetFullCType(void) const{    NCBI_THROW(CDatatoolException,eInvalidData,        LocationString() + ": C++ type undefined");}string CDataType::GetDefaultString(const CDataValue& ) const{    Warning("Default is not supported by this type");    return "...";}bool CDataType::IsPrimitive(void) const{    const CStaticDataType* st = dynamic_cast<const CStaticDataType*>(this);    if (st) {        const CBoolDataType* b = dynamic_cast<const CBoolDataType*>(this);        if (b) {            return true;        }        const CIntDataType* i = dynamic_cast<const CIntDataType*>(this);        if (i) {            return true;        }        const CRealDataType* r = dynamic_cast<const CRealDataType*>(this);        if (r) {            return true;        }    }    const CEnumDataType* e = dynamic_cast<const CEnumDataType*>(this);    if (e) {        return true;    }    return false;}bool CDataType::IsStdType(void) const{    // Primitive (except enums) or string    const CStaticDataType* st = dynamic_cast<const CStaticDataType*>(this);    if (st) {        const CBoolDataType* b = dynamic_cast<const CBoolDataType*>(this);        if (b) {            return true;        }        const CIntDataType* i = dynamic_cast<const CIntDataType*>(this);        if (i) {            return true;        }        const CRealDataType* r = dynamic_cast<const CRealDataType*>(this);        if (r) {            return true;        }        const COctetStringDataType* o =            dynamic_cast<const COctetStringDataType*>(this);        if (o) {            return true;        }        const CStringDataType* s = dynamic_cast<const CStringDataType*>(this);        if (s) {            return true;        }    }    return false;}bool CDataType::IsReference(void) const{    return dynamic_cast<const CReferenceDataType*>(this) != 0;}bool CDataType::x_IsSavedName(const string& name){    return sm_EnforcedStdXml &&        sm_SavedNames.find(name) != sm_SavedNames.end();}void CDataType::x_AddSavedName(const string& name){    if (sm_EnforcedStdXml) {        sm_SavedNames.insert(name);    }}END_NCBI_SCOPE/** ===========================================================================** $Log: type.cpp,v $* Revision 1000.2  2004/06/01 19:43:54  gouriano* PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.80** Revision 1.80  2004/05/19 17:24:18  gouriano* Corrected generation of C++ code by DTD for containers** Revision 1.79  2004/05/17 21:03:14  gorelenk* Added include of PCH ncbi_pch.hpp** Revision 1.78  2004/05/12 21:02:49  ucko* ForbidVar: Make sure to use exactly the right type of pair, since* WorkShop won't interconvert.** Revision 1.77  2004/05/12 18:33:01  gouriano* Added type conversion check (when using _type DEF file directive)** Revision 1.76  2004/03/25 21:55:41  ucko* CDataType::FileName: if we have a parent, (recursively) defer to it,* since internal classes don't have their own files.* Move CVS log to end at long last.** Revision 1.75  2003/10/21 13:48:51  grichenk* Redesigned type aliases in serialization library.* Fixed the code (removed CRef-s, added explicit* initializers etc.)** Revision 1.74  2003/10/02 19:40:14  gouriano* properly handle invalid enumeration values in ASN spec** Revision 1.73  2003/06/24 20:55:42  gouriano* corrected code generation and serialization of non-empty unnamed containers (XML)** Revision 1.72  2003/06/16 14:41:05  gouriano* added possibility to convert DTD to XML schema** Revision 1.71  2003/05/14 14:42:22  gouriano* added generation of XML schema** Revision 1.70  2003/04/29 18:31:09  gouriano* object data member initialization verification** Revision 1.69  2003/03/10 18:55:19  gouriano* use new structured exceptions (based on CException)** Revision 1.68  2003/02/12 21:39:51  gouriano* corrected code generator so primitive data types (bool,int,etc)* are returned by value, not by reference** Revision 1.67  2003/02/10 17:56:14  gouriano* make it possible to disable scope prefixes when reading and writing objects generated from ASN specification in XML format, or when converting an ASN spec into DTD.** Revision 1.66  2002/11/19 19:48:29  gouriano* added support of XML attributes of choice variants** Revision 1.65  2002/11/14 21:04:02  gouriano* added support of XML attribute lists** Revision 1.64  2002/01/24 23:30:16  vakatov* Note for ourselves that the bug workaround "BW_010" is not needed* anymore, and we should get rid of it in about half a year** Revision 1.63  2001/10/15 19:48:27  vakatov* Use two #if's instead of "#if ... && ..." as KAI cannot handle #if x == y** Revision 1.62  2001/09/04 17:04:03  vakatov* Extended workaround for the SUN Forte 6 Update 1 compiler internal bug* to all higher versions of the compiler, as Update 2 also has this the* same bug!** Revision 1.61  2001/08/20 20:23:20  vakatov* Workaround for the SUN Forte 6 Update 1 compiler internal bug.** Revision 1.60  2001/06/11 14:35:02  grichenk* Added support for numeric tags in ASN.1 specifications and data streams.** Revision 1.59  2001/05/17 15:07:12  lavr* Typos corrected** Revision 1.58  2001/02/15 21:39:14  kholodov* Modified: pointer to parent CDataMember added to CDataType class.* Modified: default value for BOOLEAN type in DTD is copied from ASN.1 spec.** Revision 1.57  2000/11/29 17:42:45  vasilche* Added CComment class for storing/printing ASN.1/XML module comments.* Added srcutil.hpp file to reduce file dependency.** Revision 1.56  2000/11/20 17:26:33  vasilche* Fixed warnings on 64 bit platforms.* Updated names of config variables.** Revision 1.55  2000/11/15 20:34:56  vasilche* Added user comments to ENUMERATED types.* Added storing of user comments to ASN.1 module definition.** Revision 1.54  2000/11/14 21:41:26  vasilche* Added preserving of ASN.1 definition comments.** Revision 1.53  2000/11/07 17:26:26  vasilche* Added module names to CTypeInfo and CEnumeratedTypeValues* Added possibility to set include directory for whole module** Revision 1.52  2000/09/26 17:38:27  vasilche* Fixed incomplete choiceptr implementation.* Removed temporary comments.** Revision 1.51  2000/08/25 15:59:24  vasilche* Renamed directory tool -> datatool.** Revision 1.50  2000/07/03 20:47:28  vasilche* Removed unused variables/functions.** Revision 1.49  2000/06/27 16:34:47  vasilche* Fixed generated comments.* Fixed class names conflict. Now internal classes' names begin with "C_".** Revision 1.48  2000/05/24 20:09:30  vasilche* Implemented DTD generation.** Revision 1.47  2000/05/03 14:38:18  vasilche* SERIAL: added support for delayed reading to generated classes.* DATATOOL: added code generation for delayed reading.** Revision 1.46  2000/04/17 19:11:09  vasilche* Fixed failed assertion.* Removed redundant namespace specifications.** Revision 1.45  2000/04/12 15:36:52  vasilche* Added -on <namespace> argument to datatool.* Removed unnecessary namespace specifications in generated files.** Revision 1.44  2000/04/07 19:26:35  vasilche* Added namespace support to datatool.* By default with argument -oR datatool will generate objects in namespace* NCBI_NS_NCBI::objects (aka ncbi::objects).* Datatool's classes also moved to NCBI namespace.** Revision 1.43  2000/03/29 15:52:27  vasilche* Generated files names limited to 31 symbols due to limitations of Mac.* Removed unions with only one member.** Revision 1.42  2000/03/07 14:06:33  vasilche* Added generation of reference counted objects.** Revision 1.41  2000/02/17 20:05:07  vasilche* Inline methods now will be generated in *_Base.inl files.* Fixed processing of StringStore.* Renamed in choices: Selected() -> Which(), E_choice -> E_Choice.* Enumerated values now will preserve case as in ASN.1 definition.** Revision 1.40  2000/02/01 21:48:07  vasilche* Added CGeneratedChoiceTypeInfo for generated choice classes.* Removed CMemberInfo subclasses.* Added support for DEFAULT/OPTIONAL members.* Changed class generation.* Moved datatool headers to include/internal/serial/tool.** Revision 1.39  2000/01/10 19:46:46  vasilche* Fixed encoding/decoding of REAL type.* Fixed encoding/decoding of StringStore.* Fixed encoding/decoding of NULL type.* Fixed error reporting.* Reduced object map (only classes).** Revision 1.38  1999/12/29 16:01:51  vasilche* Added explicit virtual destructors.* Resolved overloading of InternalResolve.** Revision 1.37  1999/12/28 18:56:00  vasilche* Reduced size of compiled object files:* 1. avoid inline or implicit virtual methods (especially destructors).* 2. avoid std::string's methods usage in inline methods.* 3. avoid string literals ("xxx") in inline methods.** Revision 1.36  1999/12/21 17:18:37  vasilche* Added CDelayedFostream class which rewrites file only if contents is changed.** Revision 1.35  1999/12/20 21:00:19  vasilche* Added generation of sources in different directories.** Revision 1.34  1999/12/08 19:06:24  vasilche* Fixed uninitialized variable.** Revision 1.33  1999/12/03 21:42:13  vasilche* Fixed conflict of enums in choices.** Revision 1.32  1999/12/01 17:36:27  vasilche* Fixed CHOICE processing.** Revision 1.31  1999/11/16 15:41:17  vasilche* Added plain pointer choice.* By default we use C pointer instead of auto_ptr.* Start adding initializers.** Revision 1.30  1999/11/15 19:36:19  vasilche* Fixed warnings on GCC** ===========================================================================*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -