本文整理汇总了C++中UMLAttribute::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ UMLAttribute::getName方法的具体用法?C++ UMLAttribute::getName怎么用?C++ UMLAttribute::getName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UMLAttribute
的用法示例。
在下文中一共展示了UMLAttribute::getName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
}
}
示例2: 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
}
示例3: writeAttributes
void CSharpWriter::writeAttributes(UMLAttributeList &atList, QTextStream &cs) {
for (UMLAttribute *at = atList.first(); at ; at = atList.next()) {
bool asProperty = true;
if (at->getVisibility() == Uml::Visibility::Private) {
asProperty = false;
}
writeAttribute(at->getDoc(), at->getVisibility(), at->getStatic(),
makeLocalTypeName(at), at->getName(), at->getInitialValue(), asProperty, cs);
cs << m_endl;
} // end for
return;
}
示例4: getFieldName
QString CPPCodeClassField::getFieldName() {
if (parentIsAttribute())
{
UMLAttribute * at = (UMLAttribute*) getParentObject();
return cleanName(at->getName());
}
else
{
UMLRole * role = (UMLRole*) getParentObject();
QString roleName = role->getName();
if(fieldIsSingleValue()) {
return roleName.replace(0, 1, roleName.left(1).lower());
} else {
return roleName.lower() + "Vector";
}
}
}
示例5: 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;
}
示例6: updateContent
/**
* 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);
}
示例7: 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;
}
//.........这里部分代码省略.........
示例8: 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(objects); (obj = it.current()) != NULL; ++it) {
obj->setID(doc->assignNewID(obj->getID()));
switch(obj->getBaseType()) {
case Uml::ot_Attribute :
{
UMLObject *exist = parent->findChildObject(obj->getName(), Uml::ot_Attribute);
if (exist) {
QString newName = parent->uniqChildName(Uml::ot_Attribute, obj->getName());
obj->setName(newName);
}
UMLAttribute *att = static_cast<UMLAttribute*>(obj);
if (parent->addAttribute(att, idchanges)) {
result = true;
} else {
kError() << "UMLClipboard::pasteClip5: " << parent->getName()
<< "->addAttribute(" << att->getName() << ") failed" << endl;
}
break;
}
case Uml::ot_Operation :
{
UMLOperation *op = static_cast<UMLOperation*>(obj);
UMLOperation *exist = parent->checkOperationSignature(op->getName(), op->getParmList());
if (exist) {
QString newName = parent->uniqChildName(Uml::ot_Operation, obj->getName());
op->setName(newName);
}
if (parent->addOperation(op, idchanges)) {
result = true;
} else {
kError() << "UMLClipboard::pasteClip5: " << parent->getName()
<< "->addOperation(" << op->getName() << ") failed" << endl;
}
break;
}
default :
kWarning() << "pasting unknown children type in clip type 5" << endl;
return false;
}
}
return result;
}
示例9: writeClass
void JSWriter::writeClass(UMLClassifier *c)
{
if(!c)
{
kDebug()<<"Cannot write class of NULL concept!" << endl;
return;
}
QString classname = cleanName(c->getName());
QString fileName = c->getName().lower();
//find an appropriate name for our file
fileName = findFileName(c,".js");
if (fileName.isEmpty())
{
emit codeGenerated(c, false);
return;
}
QFile filejs;
if(!openFile(filejs, fileName))
{
emit codeGenerated(c, false);
return;
}
QTextStream js(&filejs);
//////////////////////////////
//Start generating the code!!
/////////////////////////////
//try to find a heading file (license, coments, etc)
QString str;
str = getHeadingFile(".js");
if(!str.isEmpty())
{
str.replace(QRegExp("%filename%"),fileName);
str.replace(QRegExp("%filepath%"),filejs.name());
js << str << m_endl;
}
//write includes
UMLPackageList includes;
findObjectsRelated(c,includes);
for (UMLPackage *conc = includes.first(); conc; conc = includes.next())
{
QString headerName = findFileName(conc, ".js");
if ( !headerName.isEmpty() )
{
js << "#include \"" << headerName << "\"" << m_endl;
}
}
js << m_endl;
//Write class Documentation if there is somthing or if force option
if(forceDoc() || !c->getDoc().isEmpty())
{
js << m_endl << "/**" << m_endl;
js << " * class " << classname << m_endl;
js << formatDoc(c->getDoc()," * ");
js << " */" << m_endl << m_endl;
}
//check if class is abstract and / or has abstract methods
if(c->getAbstract() && !hasAbstractOps(c))
js << "/******************************* Abstract Class ****************************" << m_endl << " "
<< classname << " does not have any pure virtual methods, but its author" << m_endl
<< " defined it as an abstract class, so you should not use it directly." << m_endl
<< " Inherit from it instead and create only objects from the derived classes" << m_endl
<< "*****************************************************************************/" << m_endl << m_endl;
js << classname << " = function ()" << m_endl;
js << "{" << m_endl;
js << m_indentation << "this._init ();" << m_endl;
js << "}" << m_endl;
js << m_endl;
UMLClassifierList superclasses = c->getSuperClasses();
for (UMLClassifier *obj = superclasses.first();
obj; obj = superclasses.next()) {
js << classname << ".prototype = new " << cleanName(obj->getName()) << " ();" << m_endl;
}
js << m_endl;
if (! c->isInterface()) {
UMLAttributeList atl = c->getAttributeList();
js << "/**" << m_endl;
QString temp = "_init sets all " + classname + " attributes to their default value."
" Make sure to call this method within your class constructor";
js << formatDoc(temp, " * ");
js << " */" << m_endl;
js << classname << ".prototype._init = function ()" << m_endl;
js << "{" << m_endl;
for(UMLAttribute *at = atl.first(); at ; at = atl.next())
{
//.........这里部分代码省略.........
示例10: setupDialog
void UMLOperationDialog::setupDialog() {
int margin = fontMetrics().height();
QVBoxLayout * topLayout = new QVBoxLayout( plainPage() );
m_pGenGB = new QGroupBox(i18n("General Properties"), plainPage() );
QGridLayout * genLayout = new QGridLayout(m_pGenGB, 3, 4 );
genLayout -> setColStretch(1, 1);
genLayout -> setColStretch(3, 1);
genLayout -> addColSpacing(1, 200);
genLayout -> addColSpacing(3, 200);
genLayout -> setMargin(margin);
genLayout -> setSpacing(10);
Dialog_Utils::makeLabeledEditField( m_pGenGB, genLayout, 0,
m_pNameL, i18n("&Name:"),
m_pNameLE, m_pOperation->getName() );
m_pRtypeL = new QLabel(i18n("&Type:"), m_pGenGB );
genLayout -> addWidget(m_pRtypeL, 0, 2);
m_pRtypeCB = new KComboBox(true, m_pGenGB );
genLayout -> addWidget(m_pRtypeCB, 0, 3);
m_pRtypeL->setBuddy(m_pRtypeCB);
m_pStereoTypeL = new QLabel( i18n("Stereotype name:"), m_pGenGB );
genLayout -> addWidget(m_pStereoTypeL, 1, 0);
m_pStereoTypeCB = new KComboBox(true, m_pGenGB );
genLayout -> addWidget(m_pStereoTypeCB, 1, 1);
m_pAbstractCB = new QCheckBox( i18n("&Abstract operation"), m_pGenGB );
m_pAbstractCB -> setChecked( m_pOperation->getAbstract() );
genLayout -> addWidget( m_pAbstractCB, 2, 0 );
m_pStaticCB = new QCheckBox( i18n("Classifier &scope (\"static\")"), m_pGenGB );
m_pStaticCB -> setChecked( m_pOperation->getStatic() );
genLayout -> addWidget( m_pStaticCB, 2, 1 );
m_pQueryCB = new QCheckBox( i18n("&Query (\"const\")"), m_pGenGB );
m_pQueryCB -> setChecked( m_pOperation->getConst() );
genLayout -> addWidget( m_pQueryCB, 2, 2 );
topLayout -> addWidget( m_pGenGB );
m_pScopeBG = new QButtonGroup(i18n("Visibility"), plainPage() );
QHBoxLayout * scopeLayout = new QHBoxLayout(m_pScopeBG);
scopeLayout -> setMargin(margin);
m_pPublicRB = new QRadioButton(i18n("P&ublic"), m_pScopeBG);
scopeLayout -> addWidget(m_pPublicRB);
m_pPrivateRB = new QRadioButton(i18n("P&rivate"), m_pScopeBG);
scopeLayout -> addWidget(m_pPrivateRB);
m_pProtectedRB = new QRadioButton(i18n("Prot&ected"), m_pScopeBG);
scopeLayout -> addWidget(m_pProtectedRB);
m_pImplementationRB = new QRadioButton(i18n("I&mplementation"), m_pScopeBG);
scopeLayout -> addWidget(m_pImplementationRB);
topLayout -> addWidget(m_pScopeBG);
m_pParmsGB = new QGroupBox(i18n("Parameters"), plainPage() );
QVBoxLayout* parmsLayout = new QVBoxLayout(m_pParmsGB);
parmsLayout->setMargin(margin);
parmsLayout->setSpacing(10);
//horizontal box contains the list box and the move up/down buttons
QHBoxLayout* parmsHBoxLayout = new QHBoxLayout(parmsLayout);
m_pParmsLB = new QListBox(m_pParmsGB);
parmsHBoxLayout->addWidget(m_pParmsLB);
//the move up/down buttons (another vertical box)
QVBoxLayout* buttonLayout = new QVBoxLayout( parmsHBoxLayout );
m_pUpButton = new KArrowButton( m_pParmsGB );
m_pUpButton->setEnabled( false );
buttonLayout->addWidget( m_pUpButton );
m_pDownButton = new KArrowButton( m_pParmsGB, Qt::DownArrow );
m_pDownButton->setEnabled( false );
buttonLayout->addWidget( m_pDownButton );
KButtonBox* buttonBox = new KButtonBox(m_pParmsGB);
buttonBox->addButton( i18n("Ne&w Parameter..."), this, SLOT(slotNewParameter()) );
m_pDeleteButton = buttonBox->addButton( i18n("&Delete"), this, SLOT(slotDeleteParameter()) );
m_pPropertiesButton = buttonBox->addButton( i18n("&Properties"), this,
SLOT(slotParameterProperties()) );
parmsLayout->addWidget(buttonBox);
topLayout -> addWidget(m_pParmsGB);
m_pDeleteButton->setEnabled(false);
m_pPropertiesButton->setEnabled(false);
m_pUpButton->setEnabled(false);
m_pDownButton->setEnabled(false);
// Add "void". We use this for denoting "no return type" independent
// of the programming language.
// For example, the Ada generator would interpret the return type
// "void" as an instruction to generate a procedure instead of a
// function.
//.........这里部分代码省略.........
示例11: updateMethodDeclaration
// 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));
//.........这里部分代码省略.........