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

📄 classstr.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
            if (!x_IsNullType(i)) {                code.ClassPublic() <<                    "    typedef "<<cType<<" "<<i->tName<<";\n";            }        }        code.ClassPublic() <<             "\n";    }    string ncbiNamespace =        code.GetNamespace().GetNamespaceRef(CNamespace::KNCBINamespace);    CNcbiOstream& methods = code.Methods();    CNcbiOstream& inlineMethods = code.InlineMethods();    if ( wrapperClass ) {        const SMemberInfo& info = m_Members.front();        if ( info.type->CanBeCopied() ) {            string cType = info.type->GetCType(code.GetNamespace());            code.ClassPublic() <<                "    /// Data copy constructor.\n"                "    "<<code.GetClassNameDT()<<"(const "<<cType<<"& value);\n"                "\n"                "    /// Data assignment operator.\n"                "    void operator=(const "<<cType<<"& value);\n"                "\n";            inlineMethods <<                "inline\n"<<                methodPrefix<<code.GetClassNameDT()<<"(const "<<info.tName<<"& value)\n"                "    : "<<info.mName<<"(value)\n"                "{\n"                "}\n"                "\n"                "inline\n"                "void "<<methodPrefix<<"operator=(const "<<info.tName<<"& value)\n"                "{\n"                "    "<<info.mName<<" = value;\n"                "}\n"                "\n";        }    }    // generate member getters & setters    {        code.ClassPublic() <<            "    // getters\n";        setters <<            "    // setters\n\n";        size_t member_index = (size_t)-1;        size_t set_index;        size_t set_offset;        Uint4  set_mask, set_mask_maybe;        bool isNull, isNullWithAtt;        ITERATE ( TMembers, i, m_Members ) {            // generate IsSet... method            ++member_index;            set_index  = (2*member_index)/(8*sizeof(Uint4));            set_offset = (2*member_index)%(8*sizeof(Uint4));            set_mask   = (0x03 << set_offset);            set_mask_maybe = (0x01 << set_offset);            {                isNull = x_IsNullType(i);                isNullWithAtt = x_IsNullWithAttlist(i);// IsSetX                if (CClassCode::GetDoxygenComments()) {                    code.ClassPublic() <<                        "\n"                        "    /// Check if a value has been assigned to "<<i->cName<<" data member.\n"                        "    ///\n"                        "    /// Data member "<<i->cName<<" is ";                } else {                    code.ClassPublic() <<                        "    /// ";                }// comment: what is it                if (i->optional) {                    if (i->defaultValue.empty()) {                        code.ClassPublic() << "optional";                    } else {                        code.ClassPublic() << "mandatory with default";                    }                } else {                    code.ClassPublic() << "mandatory";                }// comment: typedef                if (!isNull) {                    if (CClassCode::GetDoxygenComments()) {                        code.ClassPublic()                            <<";\n    /// its type is defined as \'typedef "                            << i->type->GetCType(code.GetNamespace())                            <<" "<<i->tName<<"\'\n";                    } else {                        code.ClassPublic()                            << "\n    /// typedef "                            << i->type->GetCType(code.GetNamespace())                            <<" "<<i->tName<<"\n";                    }                } else {                    code.ClassPublic() << "\n";                }                if (CClassCode::GetDoxygenComments()) {                    code.ClassPublic() <<                        "    /// @return\n"                        "    ///   - true, if a value has been assigned.\n"                        "    ///   - false, otherwise.\n";                }                code.ClassPublic() <<                    "    bool IsSet" << i->cName<<"(void) const;\n";                inlineMethods <<                    "inline\n"                    "bool "<<methodPrefix<<"IsSet"<<i->cName<<"(void) const\n"                    "{\n";                if ( i->haveFlag ) {                    // use special boolean flag                    inlineMethods <<                        "    return (("SET_PREFIX"["<<set_index<<"] & 0x"<<                            hex<<set_mask<<dec<<") != 0);\n";                }                else {                    if ( i->delayed ) {                        inlineMethods <<                            "    if ( "DELAY_PREFIX<<i->cName<<" )\n"                            "        return true;\n";                    }                    if ( i->ref ) {                        // CRef                        if (isNullWithAtt) {                            inlineMethods <<                                "    return "<<i->mName<<"->IsSet"<<i->cName<<"();\n";                        } else {                            inlineMethods <<                                "    return "<<i->mName<<";\n";                        }                    }                    else {                        // doesn't need set flag -> use special code                        inlineMethods <<                            "    return "<<i->type->GetIsSetCode(i->mName)<<";\n";                    }                }                inlineMethods <<                    "}\n"                    "\n";// CanGetX                if (CClassCode::GetDoxygenComments()) {                    if (isNull || isNullWithAtt) {                        code.ClassPublic() <<                            "\n"                            "    /// Check if value of "<<i->cName<<" member is getatable.\n"                            "    ///\n"                            "    /// @return\n"                            "    ///   - false; the data member of type \'NULL\' has no value.\n";                    } else {                        code.ClassPublic() <<                            "\n"                            "    /// Check if it is safe to call Get"<<i->cName<<" method.\n"                            "    ///\n"                            "    /// @return\n"                            "    ///   - true, if the data member is getatable.\n"                            "    ///   - false, otherwise.\n";                    }                }                code.ClassPublic() <<                    "    bool CanGet" << i->cName<<"(void) const;\n";                inlineMethods <<                    "inline\n"                    "bool "<<methodPrefix<<"CanGet"<<i->cName<<"(void) const\n"                    "{\n";                if (!i->defaultValue.empty() || i->type->GetKind() == eKindContainer) {                    inlineMethods <<"    return true;\n";                } else {                    if (isNull || isNullWithAtt) {                        inlineMethods <<"    return false;\n";                    } else {                        inlineMethods <<"    return IsSet"<<i->cName<<"();\n";                    }                }                inlineMethods <<                    "}\n"                    "\n";            }                        // generate Reset... method            string destructionCode = i->type->GetDestructionCode(i->valueName);            string assignValue = i->defaultValue;            string resetCode;            if ( assignValue.empty() && !i->ref ) {                resetCode = i->type->GetResetCode(i->valueName);                if ( resetCode.empty() )                    assignValue = i->type->GetInitializer();            }            if (CClassCode::GetDoxygenComments()) {                setters <<                    "\n"                    "    /// Reset "<<i->cName<<" data member.\n";            }            setters <<                "    void Reset"<<i->cName<<"(void);\n";            // inline only when non reference and doesn't have reset code            bool inl = !i->ref && resetCode.empty();            code.MethodStart(inl) <<                "void "<<methodPrefix<<"Reset"<<i->cName<<"(void)\n"                "{\n";            if ( i->delayed ) {                code.Methods(inl) <<                    "    "DELAY_PREFIX<<i->cName<<".Forget();\n";            }            WriteTabbed(code.Methods(inl), destructionCode);            if ( i->ref ) {                if ( !i->optional ) {                    // just reset value                    resetCode = i->type->GetResetCode(i->valueName);                    if ( !resetCode.empty() ) {                        WriteTabbed(code.Methods(inl), resetCode);                    }                    else {                        code.Methods(inl) <<                            "    "<<i->valueName<<" = "<<i->type->GetInitializer()<<";\n";                    }                }                else if ( assignValue.empty() ) {                    // plain OPTIONAL                    code.Methods(inl) <<                        "    "<<i->mName<<".Reset();\n";                }                else {                    if ( assignValue.empty() )                        assignValue = i->type->GetInitializer();                    // assign default value                    code.Methods(inl) <<                        "    "<<i->mName<<".Reset(new "<<i->tName<<"("<<assignValue<<"));\n";                }            }            else {                if ( !assignValue.empty() ) {                    // assign default value                    if (!isNull) {                        code.Methods(inl) <<                            "    "<<i->mName<<" = "<<assignValue<<";\n";                    }                }                else {                    // no default value                    WriteTabbed(code.Methods(inl), resetCode);                }            }            if ( i->haveFlag ) {                code.Methods(inl) <<                    "    "SET_PREFIX"["<<set_index<<"] &= ~0x"<<hex<<set_mask<<dec<<";\n";            }            code.Methods(inl) <<                "}\n"                "\n";            string cType = i->type->GetCType(code.GetNamespace());            string rType = i->type->GetPrefixedCType(code.GetNamespace(),methodPrefix);            CTypeStrings::EKind kind = i->type->GetKind();            // generate getter            inl = true;//!i->ref;            if (!isNull) {                if (i->dataType && i->dataType->IsPrimitive()) {                    if (CClassCode::GetDoxygenComments()) {                        code.ClassPublic() <<                            "\n"                            "    /// Get the "<<i->cName<<" member data.\n"                            "    ///\n"                            "    /// @return\n"                            "    ///   Copy of the member data.\n";                    }                    code.ClassPublic() <<                        "    "<<i->tName<<" Get"<<i->cName<<"(void) const;\n";                    code.MethodStart(inl) <<                        ""<<rType<<" "<<methodPrefix<<"Get"<<i->cName<<"(void) const\n"                        "{\n";                } else {                    if (CClassCode::GetDoxygenComments()) {                        code.ClassPublic() <<                            "\n"                            "    /// Get the "<<i->cName<<" member data.\n"                            "    ///\n"                            "    /// @return\n"                            "    ///   Reference to the member data.\n";                    }                    code.ClassPublic() <<                        "    const "<<i->tName<<"& Get"<<i->cName<<"(void) const;\n";                    code.MethodStart(inl) <<                        "const "<<rType<<"& "<<methodPrefix<<"Get"<<i->cName<<"(void) const\n"                        "{\n";                }                if ( i->delayed ) {                    code.Methods(inl) <<                        "    "DELAY_PREFIX<<i->cName<<".Update();\n";                }                if (i->defaultValue.empty() &&                    i->type->GetKind() != eKindContainer && !isNullWithAtt) {                    code.Methods(inl) <<                        "    if (!CanGet"<< i->cName<<"()) {\n"                        "        ThrowUnassigned("<<member_index<<");\n"                        "    }\n";                }                code.Methods(inl) <<                    "    return "<<i->valueName<<";\n"                    "}\n"                    "\n";            }            // generate setter            if ( i->ref ) {                if (!isNullWithAtt) {                    // generate reference setter                    if (CClassCode::GetDoxygenComments()) {                        setters <<                            "\n"                            "    /// Assign a value to "<<i->cName<<" data member.\n"                            "    ///\n"                            "    /// @param value\n"                            "    ///   Reference to value.\n";                    }                    setters <<                        "    void Set"<<i->cName<<"("<<i->tName<<"& value);\n";                    methods <<                        "void "<<methodPrefix<<"Set"<<i->cName<<"("<<rType<<"& value)\n"                        "{\n";                    if ( i->delayed ) {                        methods <<                            "    "DELAY_PREFIX<<i->cName<<".Forget();\n";                    }                    methods <<                        "    "<<i->mName<<".Reset(&value);\n";                    if ( i->haveFlag ) {                        methods <<                            "    "SET_PREFIX"["<<set_index<<"] |= 0x"<<hex<<set_mask<<dec<<";\n";                    }                    methods <<                        "}\n"                        "\n";                }                if (CClassCode::GetDoxygenComments()) {                    setters <<

⌨️ 快捷键说明

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