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

📄 module.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 2 页
字号:
        out <<            "<!-- Elements referenced from other modules:\n";        ITERATE ( TImports, i, m_Imports ) {            if ( i != m_Imports.begin() )                out << ",\n";            const Import* imp = i->get();            ITERATE ( list<string>, t, imp->types ) {                if ( t != imp->types.begin() )                    out << ",\n";                out <<                    "          " << *t;            }            out << " FROM "<< imp->moduleName;        }        out << " -->\n\n";    }    if ( !m_Exports.empty() || !m_Imports.empty() ) {        out <<            "<!-- ============================================ -->\n";    }    out << "\n";    ITERATE ( TDefinitions, i, m_Definitions ) {        out <<            "<!-- Definition of "<<i->first<<" -->\n"            "\n";        i->second->PrintDTD(out);        out <<            "\n"            "\n"            "\n";    }    m_LastComments.PrintDTD(out, CComments::eMultiline);    out <<        "\n"        "\n"        "\n"        "\n";}// XML schema generator submitted by// Marc Dumontier, Blueprint initiative, dumontier@mshri.on.cavoid CDataTypeModule::PrintXMLSchema(CNcbiOstream& out) const{    out <<        "<!-- ============================================ -->\n"        "<!-- This section is mapped from module \"" << GetName() << "\"\n"        "================================================= -->\n";                                                                                                                                        m_Comments.PrintDTD(out, CComments::eMultiline);    if ( !m_Exports.empty() ) {        out <<            "<!-- Elements used by other modules:\n";        ITERATE ( TExports, i, m_Exports ) {            if ( i != m_Exports.begin() )                out << ",\n";            out << "          " << *i;        }        out << " -->\n\n";    }    if ( !m_Imports.empty() ) {        out <<            "<!-- Elements referenced from other modules:\n";        ITERATE ( TImports, i, m_Imports ) {            if ( i != m_Imports.begin() )                out << ",\n";            const Import* imp = i->get();            ITERATE ( list<string>, t, imp->types ) {                if ( t != imp->types.begin() )                    out << ",\n";                out <<                    "          " << *t;            }            out << " FROM "<< imp->moduleName;        }        out << " -->\n\n";    }    if ( !m_Exports.empty() || !m_Imports.empty() ) {        out <<            "<!-- ============================================ -->\n";    }    out << "\n";    ITERATE ( TDefinitions, i, m_Definitions ) {        i->second->PrintXMLSchema(out);    }    m_LastComments.PrintDTD(out, CComments::eMultiline);}staticstring DTDFileNameBase(const string& name){    string res;    ITERATE ( string, i, name ) {        char c = *i;        if ( c == '-' )            res += '_';        else            res += c;    }    return res;}staticstring DTDPublicModuleName(const string& name){    string res;    ITERATE ( string, i, name ) {        char c = *i;        if ( !isalnum(c) )            res += ' ';        else            res += c;    }    return res;}string CDataTypeModule::GetDTDPublicName(void) const{    return DTDPublicModuleName(GetName());}string CDataTypeModule::GetDTDFileNameBase(void) const{    return DTDFileNameBase(GetName());}staticvoid PrintModularDTDModuleReference(CNcbiOstream& out, const string name){    string fileName = DTDFileNameBase(name);    string pubName = DTDPublicModuleName(name);    out <<        "\n"        "<!ENTITY % "<<fileName<<"_module PUBLIC \"-//NCBI//"<<pubName<<" Module//EN\" \""<<fileName<<".mod\">\n"        "%"<<fileName<<"_module;\n";}void CDataTypeModule::PrintDTDModular(CNcbiOstream& out) const{    out <<        "<!-- "<<DTDFileNameBase(GetName())<<".dtd\n"        "  This file is built from a series of basic modules.\n"        "  The actual ELEMENT and ENTITY declarations are in the modules.\n"        "  This file is used to put them together.\n"        "-->\n";    PrintModularDTDModuleReference(out, "NCBI-Entity");    PrintModularDTDModuleReference(out, GetName());    ITERATE ( TImports, i, m_Imports ) {        PrintModularDTDModuleReference(out, (*i)->moduleName);    }}bool CDataTypeModule::Check(){    bool ok = true;    ITERATE ( TDefinitions, d, m_Definitions ) {        if ( !d->second->Check() )            ok = false;    }    return ok;}bool CDataTypeModule::CheckNames(){    bool ok = true;    ITERATE ( TExports, e, m_Exports ) {        const string& name = *e;        TTypesByName::iterator it = m_LocalTypes.find(name);        if ( it == m_LocalTypes.end() ) {            ERR_POST(Warning << "undefined export type: " << name);            ok = false;        }        else {            m_ExportedTypes[name] = it->second;        }    }    ITERATE ( TImports, i, m_Imports ) {        const Import& imp = **i;        const string& module = imp.moduleName;        ITERATE ( list<string>, t, imp.types ) {            const string& name = *t;            if ( m_LocalTypes.find(name) != m_LocalTypes.end() ) {                ERR_POST(Warning <<                         "import conflicts with local definition: " << name);                ok = false;                continue;            }            pair<TImportsByName::iterator, bool> ins =                m_ImportedTypes.insert(TImportsByName::value_type(name, module));            if ( !ins.second ) {                ERR_POST(Warning << "duplicated import: " << name);                ok = false;                continue;            }        }    }    return ok;}CDataType* CDataTypeModule::ExternalResolve(const string& typeName,                                            bool allowInternal) const{    const TTypesByName& types = allowInternal? m_LocalTypes: m_ExportedTypes;    TTypesByName::const_iterator t = types.find(typeName);    if ( t != types.end() )        return t->second;    if ( !allowInternal &&         m_LocalTypes.find(typeName) != m_LocalTypes.end() ) {        NCBI_THROW(CNotFoundException,eType, "not exported type: "+typeName);    }    NCBI_THROW(CNotFoundException,eType, "undefined type: "+typeName);}CDataType* CDataTypeModule::Resolve(const string& typeName) const{    TTypesByName::const_iterator t = m_LocalTypes.find(typeName);    if ( t != m_LocalTypes.end() )        return t->second;    TImportsByName::const_iterator i = m_ImportedTypes.find(typeName);    if ( i != m_ImportedTypes.end() )        return GetModuleContainer().InternalResolve(i->second, typeName);    NCBI_THROW(CNotFoundException,eType, "undefined type: "+typeName);}string CDataTypeModule::GetFileNamePrefix(void) const{    _TRACE("module " << m_Name << ": " << GetModuleContainer().GetFileNamePrefixSource());    if ( MakeFileNamePrefixFromModuleName() ) {        if ( m_PrefixFromName.empty() )            m_PrefixFromName = Identifier(m_Name);        _TRACE("module " << m_Name << ": \"" << m_PrefixFromName << "\"");        if ( UseAllFileNamePrefixes() ) {            return Path(GetModuleContainer().GetFileNamePrefix(),                        m_PrefixFromName);        }        else {            return m_PrefixFromName;        }    }    return GetModuleContainer().GetFileNamePrefix();}const string CDataTypeModule::GetVar(const string& typeName,                                      const string& varName) const{    _ASSERT(!typeName.empty());    _ASSERT(!varName.empty());    const CNcbiRegistry& registry = GetConfig();    {        const string& s = registry.Get(GetName() + '.' + typeName, varName);        if ( !s.empty() )            return s;    }    {        const string& s = registry.Get(typeName, varName);        if ( !s.empty() )            return s;    }    {        const string& s = registry.Get(GetName(), varName);        if ( !s.empty() )            return s;    }    // default section    return registry.Get("-", varName);}END_NCBI_SCOPE

⌨️ 快捷键说明

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