• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ UMLAttribute类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中UMLAttribute的典型用法代码示例。如果您正苦于以下问题:C++ UMLAttribute类的具体用法?C++ UMLAttribute怎么用?C++ UMLAttribute使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了UMLAttribute类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: attributeAdded

void RefactoringAssistant::attributeAdded( UMLClassifierListItem *a )
{
    UMLAttribute *att = static_cast<UMLAttribute*>(a);
    UMLClassifier *c = dynamic_cast<UMLClassifier*>(att->parent());
    if(!c)
    {
        kWarning() << "RefactoringAssistant::attributeAdded(" << att->getName()
            << ") - Parent is not a class!" << endl;
        return;
    }
    QListViewItem *item = findListViewItem( c );
    if( !item )
    {
        return;
    }
    for( QListViewItem *folder = item->firstChild(); folder; folder = folder->nextSibling() )
    {
        if( folder->text(1) == "attributes" )
        {
            item = new KListViewItem( folder, att->getName() );
            m_umlObjectMap[item] = att;
            connect( att, SIGNAL( modified() ), this, SLOT( umlObjectModified() ) );
            setVisibilityIcon( item, att );
            break;
        }
    }
}
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:27,代码来源:refactoringassistant.cpp


示例2: getParentObject

QString CPPCodeClassField::getInitialValue() {

    if (parentIsAttribute())
    {
        UMLAttribute * at = dynamic_cast<UMLAttribute*>( getParentObject() );
        if (at) {
            return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
        } else {
            kError() << "CPPCodeClassField::getInitialValue: parent object is not a UMLAttribute"
            << endl;
            return "";
        }
    }
    else
    {
        if(fieldIsSingleValue()) {
            // FIX : IF the multiplicity is "1" then we should init a new object here, if its 0 or 1,
            //       then we can just return 'empty' string (minor problem).
            return "";
        } else {
            return " new "+getListFieldClassName()+"( )";
        }
    }

}
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:25,代码来源:cppcodeclassfield.cpp


示例3: umlObject

/**
 * Returns the signature of items that are operations.
 * @return signature of an operation item, else an empty string
 */
QString UMLListViewItem::toolTip()
{
    UMLObject *obj = umlObject();
    if (obj) {
        switch (obj->baseType()) {
            case UMLObject::ot_Class:
                return obj->doc();
            case UMLObject::ot_Operation:
            {
                UMLOperation *op = static_cast<UMLOperation*>(obj);
                return op->toString(Uml::SignatureType::ShowSig);
            }
            case UMLObject::ot_Attribute:
            {
                UMLAttribute *at = static_cast<UMLAttribute*>(obj);
                return at->toString(Uml::SignatureType::ShowSig);
            }
            default:
                return QString();
        }
    }
    else {
        return QString();
    }
}
开发者ID:Nephos,项目名称:umbrello,代码行数:29,代码来源:umllistviewitem.cpp


示例4: advance

/**
 * Parse assignments in the form <identifier> '=' <value>
 * Instance variables are identified by a prefixed 'self.'.
 * @return success status of parsing
 */
bool PythonImport::parseAssignmentStmt(const QString keyword)
{
    QString variable = keyword;
    advance();
    QString value = advance();
    if (value == QLatin1String("-"))
        value.append(advance());

    bool isStatic = true;
    if (variable.startsWith(QLatin1String("self."))) {
        variable.remove(0,5);
        isStatic = false;
    }
    Uml::Visibility::Enum visibility = Uml::Visibility::Public;
    if (variable.startsWith(QLatin1String("__"))) {
        visibility = Uml::Visibility::Private;
        variable.remove(0, 2);
    } else if (variable.startsWith(QLatin1String("_"))) {
        visibility = Uml::Visibility::Protected;
        variable.remove(0, 1);
    }
    QString type;
    if (value == QLatin1String("[")) {
        if (lookAhead() == QLatin1String("]")) {
            advance();
            type = QLatin1String("list");
            value = QLatin1String("");
        }
    } else if (value == QLatin1String("{")) {
        if (lookAhead() == QLatin1String("}")) {
            advance();
            type = QLatin1String("dict");
            value = QLatin1String("");
        }
    } else if (value.startsWith(QLatin1String("\""))) {
        type = QLatin1String("string");
    } else if (value == QLatin1String("True") || value == QLatin1String("False")) {
        type = QLatin1String("bool");
    } else if (value.contains(QRegExp(QLatin1String("-?\\d+\\.\\d*")))) {
        type = QLatin1String("float");
    } else if (value.contains(QRegExp(QLatin1String("-?\\d+")))) {
        type = QLatin1String("int");
    } else if (!value.isEmpty()) {
        type = QLatin1String("object");
    }

    UMLObject* o = Import_Utils::insertAttribute(m_klass, visibility, variable,
                                                 type, m_comment, false);
    UMLAttribute* a = o->asUMLAttribute();
    a->setInitialValue(value);
    a->setStatic(isStatic);
    return true;
}
开发者ID:KDE,项目名称:umbrello,代码行数:58,代码来源:pythonimport.cpp


示例5: writeAttributes

void CSharpWriter::writeAttributes(UMLClassifier *c, QTextStream &cs) {

    UMLAttributeList  atpub, atprot, atpriv, atdefval;
    atpub.setAutoDelete(false);
    atprot.setAutoDelete(false);
    atpriv.setAutoDelete(false);
    atdefval.setAutoDelete(false);

    //sort attributes by scope and see if they have a default value
    UMLAttributeList atl = c->getAttributeList();
    UMLAttribute *at;

    for (at = atl.first(); at ; at = atl.next()) {
        if (!at->getInitialValue().isEmpty())
            atdefval.append(at);
        switch (at->getVisibility()) {
          case Uml::Visibility::Public:
            atpub.append(at);
            break;
          case Uml::Visibility::Protected:
            atprot.append(at);
            break;
          case Uml::Visibility::Private:
            atpriv.append(at);
            break;
          default:
            break;
        }
    }

    if (forceSections() || atl.count())
        cs << m_endl << m_container_indent << m_indentation << "#region Attributes" << m_endl << m_endl;

    // write public attributes
    if (forceSections() || atpub.count()) {
        writeAttributes(atpub,cs);
    }

    // write protected attributes
    if (forceSections() || atprot.count()) {
        writeAttributes(atprot,cs);
    }

    // write private attributes
    if (forceSections() || atpriv.count()) {
        writeAttributes(atpriv,cs);
    }

    if (forceSections() || atl.count())
        cs << m_endl << m_container_indent << m_indentation << "#endregion" << m_endl << m_endl;

}
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:52,代码来源:csharpwriter.cpp


示例6: attributeRemoved

/**
 * Slot for removing an attribute from the tree.
 * @param listItem   the attribute to be removed
 */
void RefactoringAssistant::attributeRemoved(UMLClassifierListItem *listItem)
{
    UMLAttribute *att = static_cast<UMLAttribute*>(listItem);
    DEBUG(DBG_SRC) << "attribute = " << att->name();  //:TODO:
    QTreeWidgetItem *item = findListViewItem(att);
    if (!item) {
        uWarning() << "Attribute is not in tree!";
        return;
    }
    disconnect(att, SIGNAL(modified()), this, SLOT(objectModified()));
    m_umlObjectMap.remove(item);
    delete item;
    DEBUG(DBG_SRC) << "attribute = " << att->name() << " deleted!";  //:TODO:
}
开发者ID:Salmista-94,项目名称:umbrello,代码行数:18,代码来源:refactoringassistant.cpp


示例7: UMLAttributeList

void UMLAttributeList::copyInto(UMLAttributeList *rhs) const {
    // Don't copy yourself.
    if (rhs == this) return;

    rhs->clear();

    // Suffering from const; we shall not modify our object.
    UMLAttributeList *tmp = new UMLAttributeList(*this);

    UMLAttribute *item;
    for (item = tmp->first(); item; item = tmp->next() )
    {
        rhs->append((UMLAttribute*)item->clone());
    }
    delete tmp;
}
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:16,代码来源:umlattributelist.cpp


示例8: getParentObject

QString RubyCodeClassField::getFieldName()
{
    if (parentIsAttribute())
    {
        UMLAttribute * at = (UMLAttribute*) getParentObject();
        return cleanName(at->name());
    }
    else
    {
        UMLRole * role = (UMLRole*) getParentObject();
        QString roleName = role->name();
        if(fieldIsSingleValue()) {
            return roleName.replace(0, 1, roleName.left(1).toLower());
        } else {
            return roleName.toLower() + QLatin1String("Array");
        }
    }
}
开发者ID:KDE,项目名称:umbrello,代码行数:18,代码来源:rubycodeclassfield.cpp


示例9: attributeAdded

/**
 * Slot for adding an attribute to the tree.
 * @param listItem   the new attribute to add
 */
void RefactoringAssistant::attributeAdded(UMLClassifierListItem *listItem)
{
    UMLAttribute *att = static_cast<UMLAttribute*>(listItem);
    DEBUG(DBG_SRC) << "attribute = " << att->name();  //:TODO:
    UMLClassifier *parent = dynamic_cast<UMLClassifier*>(att->parent());
    if (!parent) {
        uWarning() << att->name() << " - Parent of attribute is not a classifier!";
        return;
    }
    QTreeWidgetItem *item = findListViewItem(parent);
    if (!item) {
        uWarning() << "Parent is not in tree!";
        return;
    }
    for (int i = 0; i < item->childCount(); ++i) {
        QTreeWidgetItem *folder = item->child(i);
        if (folder->text(1) == QLatin1String("attributes")) {
            item = new QTreeWidgetItem(folder, QStringList(att->name()));
            m_umlObjectMap[item] = att;
            connect(att, SIGNAL(modified()), this, SLOT(objectModified()));
            setVisibilityIcon(item, att);
            DEBUG(DBG_SRC) << "attribute = " << att->name() << " added!";  //:TODO:
            break;
        }
    }
}
开发者ID:Salmista-94,项目名称:umbrello,代码行数:30,代码来源:refactoringassistant.cpp


示例10: fixInitialStringDeclValue

QString JavaCodeClassField::getInitialValue()
{
    if (parentIsAttribute())
    {
        UMLAttribute * at = dynamic_cast<UMLAttribute*>(getParentObject());
        if (at) {
            return fixInitialStringDeclValue(at->getInitialValue(), getTypeName());
        } else {
            uError() << "parent object is not a UMLAttribute";
            return QString();
        }
    }
    else
    {
        if(fieldIsSingleValue()) {
            // FIX : IF the multiplicity is "1" then we should init a new object here, if its 0 or 1,
            //       then we can just return 'empty' string (minor problem).
            return QString();
        } else {
            return QLatin1String(" new ") + JavaCodeGenerator::getListFieldClassName() + QLatin1String("()");
        }
    }
}
开发者ID:Nephos,项目名称:umbrello,代码行数:23,代码来源:javacodeclassfield.cpp


示例11: getNewLineEndingChars

/**
 * update the start and end text for this ownedhierarchicalcodeblock.
 */
void XMLElementCodeBlock::updateContent ( )
{

    QString endLine = getNewLineEndingChars();

    QString nodeName = getNodeName();

    // Now update START/ENDING Text
    QString startText = '<' + nodeName;
    QString endText = "";

    UMLAttributeList * alist = getAttributeList();
    for (UMLAttribute *at = alist->first(); at; at=alist->next())
    {
        if(at->getInitialValue().isEmpty())
            kWarning()<<" XMLElementCodeBlock : cant print out attribute that lacks an initial value"<<endl;
        else {
            startText.append(" " +at->getName()+"=\"");
            startText.append(at->getInitialValue()+"\"");
        }
    }

    // now set close of starting/ending node, the style depending on whether we have child text or not
    if(getTextBlockList()->count())
    {
        startText.append(">");
        endText = "</" + nodeName + '>';
    } else {
        startText.append("/>");
        endText = "";
    }

    setStartText(startText);
    setEndText(endText);

}
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:39,代码来源:xmlelementcodeblock.cpp


示例12: writeOperations

void JSWriter::writeOperations(QString classname, UMLOperationList *opList, QTextStream &js)
{
    UMLOperation *op;
    UMLAttribute *at;

    for(op = opList->first(); op; op = opList->next())
    {
        UMLAttributeList atl = op->getParmList();
        //write method doc if we have doc || if at least one of the params has doc
        bool writeDoc = forceDoc() || !op->getDoc().isEmpty();
        for (at = atl.first(); at; at = atl.next())
            writeDoc |= !at->getDoc().isEmpty();

        if( writeDoc )  //write method documentation
        {
            js << "/**" << m_endl << formatDoc(op->getDoc()," * ");

            for (at = atl.first(); at; at = atl.next())  //write parameter documentation
            {
                if(forceDoc() || !at->getDoc().isEmpty())
                {
                    js << " * @param " + cleanName(at->getName())<<m_endl;
                    js << formatDoc(at->getDoc(),"    *      ");
                }
            }//end for : write parameter documentation
            js << " */" << m_endl;
        }//end if : write method documentation

        js << classname << ".prototype." << cleanName(op->getName()) << " = function " << "(";

        int i = atl.count();
        int j=0;
        for (at = atl.first(); at ;at = atl.next(),j++)
        {
            js << cleanName(at->getName())
            << (!(at->getInitialValue().isEmpty()) ? (QString(" = ")+at->getInitialValue()) : QString(""))
            << ((j < i-1)?", ":"");
        }
        js << ")" << m_endl << "{" << m_endl <<
        m_indentation << m_endl << "}" << m_endl;
        js << m_endl << m_endl;
    }//end for
}
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:43,代码来源:jswriter.cpp


示例13: UMLAttribute

void UMLOperationDialog::slotNewParameter() {
    int result = 0;
    UMLAttribute* pAtt = 0;

    QString currentName = m_pOperation->getUniqueParameterName();
    UMLAttribute* newAttribute = new UMLAttribute(m_pOperation, currentName, Uml::id_Reserved);

    ParmPropDlg dlg(this, m_doc, newAttribute);
    result = dlg.exec();
    QString name = dlg.getName();
    pAtt = m_pOperation -> findParm( name );
    if( result ) {
        if( name.length() == 0 ) {
            KMessageBox::error(this, i18n("You have entered an invalid parameter name."),
                               i18n("Parameter Name Invalid"), false);
            delete newAttribute;
            return;
        }
        if( !pAtt ) {
            newAttribute->setID( UniqueID::gen() );
            newAttribute->setName( name );
            newAttribute->setTypeName( dlg.getTypeName() );
            newAttribute->setInitialValue( dlg.getInitialValue() );
            newAttribute->setDoc( dlg.getDoc() );
            newAttribute->setParmKind( dlg.getParmKind() );
            m_pOperation->addParm( newAttribute );
            m_pParmsLB -> insertItem( name );
            m_doc -> setModified( true );
        } else {
            KMessageBox::sorry(this, i18n("The parameter name you have chosen\nis already being used in this operation."),
                               i18n("Parameter Name Not Unique"), false);
            delete newAttribute;
        }
    } else {
        delete newAttribute;
    }
}
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:37,代码来源:umloperationdialog.cpp


示例14: printAttributes

void SQLWriter::printAttributes(QTextStream& sql, UMLAttributeList attributeList, bool first) {
    QString attrDoc = "";
    UMLAttribute* at;

    for (at=attributeList.first();at;at=attributeList.next())
    {
        // print , after attribute
        if (first == false) {
            sql <<",";
        } else {
            first = false;
        }

        // print documentation/comment of last attribute at end of line
        if (attrDoc.isEmpty() == false)
        {
            sql << " -- " << attrDoc << m_endl;
        } else {
            sql << m_endl;
        }

        // write the attribute
        sql << m_indentation << cleanName(at->getName()) << " " << at->getTypeName() << " "
        << (at->getInitialValue().isEmpty()?QString(""):QString(" DEFAULT ")+at->getInitialValue());

        // now get documentation/comment of current attribute
        attrDoc = at->getDoc();
    }

    // print documentation/comment at end of line
    if (attrDoc.isEmpty() == false)
    {
        sql << " -- " << attrDoc << m_endl;
    } else {
        sql << m_endl;
    }

    return;
}
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:39,代码来源:sqlwriter.cpp


示例15: while


//.........这里部分代码省略.........
                    m_srcIndex++;
                }
                typeName = advance();
            } else if (direction == QLatin1String("out")) {
                dir = Uml::ParameterDirection::Out;
                typeName = advance();
            } else {
                typeName = direction;  // In Ada, the default direction is "in"
            }
            typeName.remove(QLatin1String("Standard."), Qt::CaseInsensitive);
            typeName = expand(typeName);
            if (op == NULL) {
                // In Ada, the first parameter indicates the class.
                UMLObject *type = Import_Utils::createUMLObject(UMLObject::ot_Class, typeName, currentScope());
                UMLObject::ObjectType t = type->baseType();
                if ((t != UMLObject::ot_Interface &&
                     (t != UMLObject::ot_Class || type->stereotype() == QLatin1String("record"))) ||
                    !m_classesDefinedInThisScope.contains(type)) {
                    // Not an instance bound method - we cannot represent it.
                    skipStmt(QLatin1String(")"));
                    break;
                }
                klass = static_cast<UMLClassifier*>(type);
                op = Import_Utils::makeOperation(klass, name);
                // The controlling parameter is suppressed.
                parNameCount--;
                if (parNameCount) {
                    for (uint i = 0; i < parNameCount; ++i) {
                        parName[i] = parName[i + 1];
                    }
                }
            }
            for (uint i = 0; i < parNameCount; ++i) {
                UMLAttribute *att = Import_Utils::addMethodParameter(op, typeName, parName[i]);
                att->setParmKind(dir);
            }
            if (advance() != QLatin1String(";"))
                break;
        }
        if (keyword == QLatin1String("function")) {
            if (advance() != QLatin1String("return")) {
                if (klass)
                    uError() << "importAda: expecting \"return\" at function "
                        << name;
                return false;
            }
            returnType = expand(advance());
            returnType.remove(QLatin1String("Standard."), Qt::CaseInsensitive);
        }
        bool isAbstract = false;
        if (advance() == QLatin1String("is") && advance() == QLatin1String("abstract"))
            isAbstract = true;
        if (klass != NULL && op != NULL)
            Import_Utils::insertMethod(klass, op, m_currentAccess, returnType,
                                       false, isAbstract, false, false, m_comment);
        skipStmt();
        return true;
    }
    if (keyword == QLatin1String("task") || keyword == QLatin1String("protected")) {
        // Can task and protected objects/types be mapped to UML?
        QString name = advance();
        if (name == QLatin1String("type")) {
            name = advance();
        }
        QString next = advance();
        if (next == QLatin1String("(")) {
开发者ID:Nephos,项目名称:umbrello,代码行数:67,代码来源:adaimport.cpp


示例16: getParentDocument

// we basically want to update the doc and start text of this method
void RubyCodeOperation::updateMethodDeclaration()
{

    CodeDocument * doc = getParentDocument();
    RubyClassifierCodeDocument * rubydoc = dynamic_cast<RubyClassifierCodeDocument*>(doc);
    UMLClassifier *c = rubydoc->getParentClassifier();
    UMLOperation * o = getParentOperation();
    bool isInterface = rubydoc->getParentClassifier()->isInterface();
    QString endLine = getNewLineEndingChars();

    // now, the starting text.
    QString strVis = rubydoc->scopeToRubyDecl(o->getVisibility());
    // no return type for constructors
    QString fixedReturn = RubyCodeGenerator::cppToRubyType(o->getTypeName());
    QString returnType = o->isConstructorOperation() ? QString("") : (fixedReturn + QString(" "));
    QString methodName = o->getName();

    QString RubyClassName = rubydoc->getRubyClassName(c->getName());

    // Skip destructors, and operator methods which
    // can't be defined in ruby
    if (    methodName.startsWith("~")
            || QRegExp("operator\\s*(=|--|\\+\\+|!=)$").exactMatch(methodName) )
    {
        getComment()->setText("");
        return;
    }

    if (RubyClassName == methodName) {
        methodName = "initialize";
    }

    methodName.replace(QRegExp("operator\\s*"), "");
    methodName = methodName.mid(0, 1).lower() + methodName.mid(1);

    QString paramStr = QString("");
    QStringList commentedParams;

    // assemble parameters
    UMLAttributeList list = getParentOperation()->getParmList();
    int nrofParam = list.count();
    int paramNum = 0;
    for(UMLAttribute* parm = list.first(); parm; parm = list.next())
    {
        QString paramName = RubyCodeGenerator::cppToRubyName(parm->getName());
        paramStr += paramName;
        if (! parm->getInitialValue().isEmpty()) {
            paramStr += QString(" = ") + RubyCodeGenerator::cppToRubyType(parm->getInitialValue());
        }
        paramNum++;

        if (paramNum != nrofParam )
            paramStr  += ", ";
    }

    QString startText;
    if (isInterface) {
        // Assume 'isInterface' means a module in Ruby, so
        // generate module methods
        startText = "def "+ RubyClassName + '.' + methodName + '(' + paramStr +')';
    } else {
        startText = "def "+ methodName + '(' + paramStr +')';
    }

    startText += "";
    setEndMethodText("end");

    setStartMethodText(startText);

    // Lastly, for text content generation, we fix the comment on the
    // operation, IF the codeop is autogenerated & currently empty
    QString comment = o->getDoc();

    if (comment.isEmpty()) {
        if (getContentType() == CodeBlock::AutoGenerated) {
            UMLAttributeList parameters = o->getParmList();
            for(UMLAttributeListIt iterator(parameters); iterator.current(); ++iterator) {
                comment += endLine + "* _" + iterator.current()->getName() + "_ ";
                comment += (' ' + iterator.current()->getDoc().replace( QRegExp("[\\n\\r]+[\\t ]*"),
                                                                        endLine + "  " ) );
            }
            // add a returns statement too
            if(!returnType.isEmpty() && !QRegExp("^void\\s*$").exactMatch(returnType))
                comment += endLine + "* _returns_ " + returnType + ' ';
            getComment()->setText(comment);
        }
    } else {
        comment.replace(QRegExp("[\\n\\r]+ *"), endLine);
        comment.replace(QRegExp("[\\n\\r]+\\t*"), endLine);

        comment.replace(" m_", " ");
        comment.replace(QRegExp("\\s[npb](?=[A-Z])"), " ");
        QRegExp re_params("@param (\\w)(\\w*)");
        int pos = re_params.search(comment);
        while (pos != -1) {
            comment.replace( re_params.cap(0),
                            QString("@param _") + re_params.cap(1).lower() + re_params.cap(2) + '_' );
            commentedParams.append(re_params.cap(1).lower() + re_params.cap(2));

//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:101,代码来源:rubycodeoperation.cpp


示例17: while


//.........这里部分代码省略.........
                    advance();
                } else if (nextToken == "const") {
                    advance();
                } else if (nextToken == "out") {
                    dir = Uml::pd_Out;
                    advance();
                }
                QString parName[MAX_PARNAMES];
                uint parNameCount = 0;
                do {
                    if (parNameCount >= MAX_PARNAMES) {
                        uError() << "MAX_PARNAMES is exceeded at " << name;
                        break;
                    }
                    parName[parNameCount++] = advance();
                } while (advance() == ",");
                if (m_source[m_srcIndex] != ":") {
                    uError() << "importPascal: expecting ':' at " << m_source[m_srcIndex];
                    skipStmt();
                    break;
                }
                nextToken = advance();
                if (nextToken.toLower() == "array") {
                    nextToken = advance().toLower();
                    if (nextToken != "of") {
                        uError() << "importPascal(" << name << "): expecting 'array OF' at "
                                  << nextToken;
                        skipStmt();
                        return false;
                    }
                    nextToken = advance();
                }
                for (uint i = 0; i < parNameCount; ++i) {
                    UMLAttribute *att = Import_Utils::addMethodParameter(op, nextToken, parName[i]);
                    att->setParmKind(dir);
                }
                if (advance() != ";")
                    break;
            }
        }
        QString returnType;
        if (keyword == "function") {
            if (advance() != ":") {
                uError() << "importPascal: expecting \":\" at function "
                        << name;
                return false;
            }
            returnType = advance();
        } else if (keyword == "constructor" || keyword == "destructor") {
            op->setStereotype(keyword);
        }
        skipStmt();
        bool isVirtual = false;
        bool isAbstract = false;
        checkModifiers(isVirtual, isAbstract);
        Import_Utils::insertMethod(m_klass, op, m_currentAccess, returnType,
                                   !isVirtual, isAbstract, false, false, m_comment);
        return true;
    }
    if (m_section != sect_TYPE) {
        skipStmt();
        return true;
    }
    if (m_klass == NULL) {
        const QString& name = m_source[m_srcIndex];
        QString nextToken = advance();
开发者ID:Elv13,项目名称:Umbrello-ng,代码行数:67,代码来源:pascalimport.cpp


示例18: writeOperations

void CSharpWriter::writeOperations(UMLOperationList opList,
                                 QTextStream &cs, bool isInterface /* = false */,
                                 bool isOverride /* = false */,
                                 bool generateErrorStub /* = false */) {

    for (UMLOperation *op=opList.first(); op ; op=opList.next()) {
        UMLAttributeList atl = op->getParmList();
        UMLAttribute *at;

        //write method doc if we have doc || if at least one of the params has doc
        bool writeDoc = forceDoc() || !op->getDoc().isEmpty();

        for (at = atl.first(); at; at = atl.next()) {
            writeDoc |= !at->getDoc().isEmpty();
        }

        //write method documentation
        if (writeDoc && !isOverride)
        {
            cs << m_container_indent << m_indentation << "/// <summary>" << m_endl;
            cs << formatDoc(op->getDoc(), m_container_indent + m_indentation + "/// ");
            cs << m_container_indent << m_indentation << "/// </summary>" << m_endl;

            //write parameter documentation
            for (at = atl.first(); at; at = atl.next())
            {
                if (forceDoc() || !at->getDoc().isEmpty()) {
                    cs << m_container_indent << m_indentation << "/// <param name=\"" << cleanName(at->getName()) << "\">";
                    //removing newlines from parameter doc
                    cs << formatDoc(at->getDoc(), "").replace("\n", " ").remove('\r').replace(QRegExp(" $"), "");
                    cs << "</param>" << m_endl;
                }
            }

            // FIXME: "returns" should contain documentation, not type.
            cs << m_container_indent << m_indentation << "/// <returns>";
            if (! op->getTypeName().isEmpty()) {
                cs << makeLocalTypeName(op);
            }
            cs << "</returns>" << m_endl;

        }

        // method visibility
        cs << m_container_indent << m_indentation;
        if (!isInterface) {
            if (!isOverride) {
                if (op->getAbstract()) cs << "abstract ";
                cs << op->getVisibility().toString() << " ";
                if (op->getStatic()) cs << "static ";
            }
            else {
                // method overriding an abstract parent
                cs << op->getVisibility().toString() << " override ";
                if (op->getStatic()) cs << "static ";
            }
        }

        // return type (unless constructor, destructor)
        if (!op->isLifeOperation()) {
            if (op->getTypeName().isEmpty()) {
                cs << "void ";
            }
            else {
                cs << makeLocalTypeName(op) << " ";
            }
        }

        // method name
        cs << cleanName(op->getName()) << "(";

        // method parameters
        int i= atl.count();
        int j=0;
        for (at = atl.first(); at; at = atl.next(), j++) {

            cs << makeLocalTypeName(at) << " " << cleanName(at->getName());

            // no initial values in C#
            //<< (!(at->getInitialValue().isEmpty()) ?
            //    (QString(" = ")+at->getInitialValue()) :
            //    QString(""))
            cs << ((j < i-1)?", ":"");
        }
        cs << ")";

        //FIXME: how to control generation of error stub?
        if (!isInterface && (!op->getAbstract() || isOverride)) {
            cs << m_endl << m_container_indent << m_indentation << "{" << m_endl;
            if (generateErrorStub) {
                cs << m_container_indent << m_indentation << m_indentation;
                cs << "throw new Exception(\"The method or operation is not implemented.\");" << m_endl;
            }
            cs << m_container_indent << m_indentation << "}" << m_endl;
        }
        else {
            cs << ';' << m_endl;
        }
        cs << m_endl;
    }
//.........这里部分代码省略.........
开发者ID:serghei,项目名称:kde-kdesdk,代码行数:101,代码来源:csharpwriter.cpp


示例19: text

/**
 * This slot is called to finish item editing
 */
void UMLListViewItem::slotEditFinished(const QString &newText)
{
    m_label = text(0);

    DEBUG(DBG_LVI) << this << "text=" << newText;
    UMLListView* listView = static_cast<UMLListView*>(treeWidget());
    UMLDoc* doc = listView->document();
    if (newText == m_label) {
        return;
    }
    if (newText.isEmpty()) {
        cancelRenameWithMsg();
        return;
    }
    switch (m_type) {
    case lvt_UseCase:
    case lvt_Actor:
    case lvt_Class:
    case lvt_Package:
    case lvt_UseCase_Folder:
    case lvt_Logical_Folder:
    case lvt_Component_Folder:
    case lvt_Deployment_Folder:
    case lvt_EntityRelationship_Folder:
    case lvt_Interface:
    case lvt_Datatype:
    case lvt_Enum:
    case lvt_EnumLiteral:
    case lvt_Subsystem:
    case lvt_Component:
    case lvt_Port:
    case lvt_Node:
    case lvt_Category:
        if (m_object == 0 || !doc->isUnique(newText)) {
            cancelRenameWithMsg();
            return;
        }
        UMLApp::app()->executeCommand(new Uml::CmdRenameUMLObject(m_object, newText));
        doc->setModified(true);
        m_label = newText;
        break;

    case lvt_Operation: {
        if (m_object == 0) {
            cancelRenameWithMsg();
            return;
        }
        UMLOperation *op = static_cast<UMLOperation*>(m_object);
        UMLClassifier *parent = static_cast<UMLClassifier *>(op->parent());
        Model_Utils::OpDescriptor od;
        Model_Utils::Parse_Status st = Model_Utils::parseOperation(newText, od, parent);
        if (st == Model_Utils::PS_OK) {
            // TODO: Check that no operation with the exact same profile exists.
            UMLApp::app()->executeCommand(new Uml::CmdRenameUMLObject(op, od.m_name));
            op->setType(od.m_pReturnType);
            UMLAttributeList parmList = op->getParmList();
            const int newParmListCount = parmList.count();
            if (newParmListCount > od.m_args.count()) {
                // Remove parameters at end of of list that no longer exist.
                for (int i = od.m_args.count(); i < newParmListCount; i++) {
                    UMLAttribute *a = parmList.at(i);
                    op->removeParm(a, false);
                }
            }
            Model_Utils::NameAndType_ListIt lit = od.m_args.begin();
            for (int i = 0; lit != od.m_args.end(); ++lit, ++i) {
                const Model_Utils::NameAndType& nm_tp = *lit;
                UMLAttribute *a;
                if (i < newParmListCount) {
                    a = parmList.at(i);
                } else {
                    a = new UMLAttribute(op);
                    a->setID(UniqueID::gen());
                }
                UMLApp::app()->executeCommand(new Uml::CmdRenameUMLObject(a, nm_tp.m_name));
                a->setType(nm_tp.m_type);
                a->setParmKind(nm_tp.m_direction);
                a->setInitialValue(nm_tp.m_initialValue);
                if (i >= newParmListCount) {
                    op->addParm(a);
                }
            }
            m_label = op->toString(Uml::SignatureType::SigNoVis);
        } else {
            KMessageBox::error(0,
                               Model_Utils::psText(st),
                               i18n("Rename canceled"));
        }
        setText(m_label);
        break;
    }

    case lvt_Attribute:
    case lvt_EntityAttribute: {
        if (m_object == 0) {
            cancelRenameWithMsg();
            return;
//.........这里部分代码省略.........
开发者ID:Nephos,项目名称:umbrello,代码行数:101,代码来源:umllistviewitem.cpp


示例20: kError

/** If clipboard has mime type application/x-uml-clip5,
Pastes the data from the clipboard into the current Doc */
bool UMLClipboard::pasteClip5(QMimeSource* data) {
    UMLDoc *doc = UMLApp::app()->getDocument();
    UMLListView *listView = UMLApp::app()->getListView();
    UMLListViewItem* lvitem = dynamic_cast<UMLListViewItem *>( listView->currentItem() );
    if (!lvitem ||
            (lvitem->getType() != Uml::lvt_Class && lvitem->getType() != Uml::lvt_Interface)) {
        return false;
    }
    UMLClassifier *parent = dynamic_cast<UMLClassifier *>(lvitem->getUMLObject());
    if (parent == NULL) {
        kError() << "UMLClipboard::pasteClip5: parent is not a UMLClassifier"
        << endl;
        return false;
    }

    UMLObjectList objects;
    objects.setAutoDelete(false);
    IDChangeLog* idchanges = 0;
    bool result = UMLDrag::decodeClip5(data, objects, parent);

    if(!result) {
        return false;
    }

    UMLObject   *obj = 0;
    doc->setModified(true);
    idchanges = doc->getChangeLog();
    // Assume success if at least one child object could be pasted
    if (objects.count())
        result = false;

    for (UMLObjectListIt it(object 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ UMLClassifier类代码示例发布时间:2022-05-31
下一篇:
C++ ULocalPlayer类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap