本文整理汇总了C++中CodeGenerationPolicy类的典型用法代码示例。如果您正苦于以下问题:C++ CodeGenerationPolicy类的具体用法?C++ CodeGenerationPolicy怎么用?C++ CodeGenerationPolicy使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CodeGenerationPolicy类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: toString
/**
* @return QString
*/
QString JavaCodeDocumentation::toString ( )
{
QString output = "";
// simple output method
if(getWriteOutText())
{
bool useDoubleDashOutput = true;
// need to figure out output type from java policy
CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
useDoubleDashOutput = false;
QString indent = getIndentationString();
QString endLine = getNewLineEndingChars();
QString body = getText();
if(useDoubleDashOutput)
{
if(!body.isEmpty())
output.append(formatMultiLineText (body, indent +"// ", endLine));
} else {
output.append(indent+"/**"+endLine);
output.append(formatMultiLineText (body, indent +" * ", endLine));
output.append(indent+" */"+endLine);
}
}
return output;
}
示例2: apply
void CPPCodeGenerationPolicyPage::apply()
{
CodeGenerationPolicy *common = UMLApp::app()->getCommonPolicy();
// now do our cpp-specific configs
CPPCodeGenerationPolicy * parent = (CPPCodeGenerationPolicy*) m_parentPolicy;
// block signals so that we don't generate too many sync signals for child code
// documents
parent->blockSignals(true);
common->setCommentStyle((CodeGenerationPolicy::CommentStyle ) form->m_SelectCommentStyle->currentItem());
common->setAutoGenerateConstructors(form->getGenerateEmptyConstructors());
parent->setAutoGenerateAccessors(form->getGenerateAccessorMethods());
parent->setDestructorsAreVirtual(form->getVirtualDestructors());
parent->setPackageIsNamespace(form->getPackageIsANamespace());
parent->setAccessorsAreInline(form->getAccessorsAreInline());
parent->setOperationsAreInline(form->getOperationsAreInline());
parent->setAccessorsArePublic(form->getAccessorsArePublic());
parent->setStringClassName(form->m_stringClassHCombo->currentText());
parent->setStringClassNameInclude(form->m_stringIncludeFileHistoryCombo->currentText());
parent->setStringIncludeIsGlobal(form->m_globalStringCheckBox->isChecked());
parent->setVectorClassName(form->m_listClassHCombo->currentText());
parent->setVectorClassNameInclude(form->m_listIncludeFileHistoryCombo->currentText());
parent->setVectorIncludeIsGlobal(form->m_globalListCheckBox->isChecked());
parent->blockSignals(false);
// now send out modified code content signal
common->emitModifiedCodeContentSig();
}
示例3: firstEditableLine
int CPPCodeDocumentation::firstEditableLine()
{
CodeGenerationPolicy * p = UMLApp::app()->commonPolicy();
if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
return 1;
return 0;
}
示例4: CodeGenerationPolicyPage
CPPCodeGenerationPolicyPage::CPPCodeGenerationPolicyPage( QWidget *parent, const char *name, CPPCodeGenerationPolicy * policy )
: CodeGenerationPolicyPage(parent, name, policy)
{
CodeGenerationPolicy *common = UMLApp::app()->commonPolicy();
QVBoxLayout* vboxLayout = new QVBoxLayout( this );
form = new CPPCodeGenerationForm(this);
form->ui_selectCommentStyle->setCurrentIndex((int)(common->getCommentStyle()));
form->setPackageIsANamespace(policy->getPackageIsNamespace());
form->setVirtualDestructors(policy->getDestructorsAreVirtual());
form->setGenerateAccessorMethods(policy->getAutoGenerateAccessors());
form->setGenerateEmptyConstructors(common->getAutoGenerateConstructors());
form->setOperationsAreInline(policy->getOperationsAreInline());
form->setAccessorsAreInline(policy->getAccessorsAreInline());
form->setAccessorsArePublic(policy->getAccessorsArePublic());
form->setDocToolTag(policy->getDocToolTag());
form->ui_stringClassHCombo->setCurrentItem(policy->getStringClassName(),true);
form->ui_listClassHCombo->setCurrentItem(policy->getVectorClassName(),true);
form->ui_stringIncludeFileHistoryCombo->setCurrentItem(policy->getStringClassNameInclude(),true);
form->ui_listIncludeFileHistoryCombo->setCurrentItem(policy->getVectorClassNameInclude(),true);
form->ui_globalStringCheckBox->setChecked(policy->stringIncludeIsGlobal());
form->ui_globalListCheckBox->setChecked(policy->vectorIncludeIsGlobal());
vboxLayout->addWidget( form );
}
示例5: toString
QString DCodeDocumentation::toString() const
{
QString output;
// simple output method
if(getWriteOutText())
{
bool useDoubleDashOutput = true;
// need to figure out output type from d policy
CodeGenerationPolicy * p = UMLApp::app()->commonPolicy();
if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
useDoubleDashOutput = false;
QString indent = getIndentationString();
QString endLine = getNewLineEndingChars();
QString body = getText();
if(useDoubleDashOutput)
{
if(!body.isEmpty()) {
output += (formatMultiLineText (body, indent + QLatin1String("// "), endLine));
}
} else {
output += indent + QLatin1String("/**") + endLine;
output += formatMultiLineText (body, indent + QLatin1String(" * "), endLine);
output += indent + QLatin1String(" */") + endLine;
}
}
return output;
}
示例6: lastEditableLine
int JavaCodeDocumentation::lastEditableLine() {
CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
{
return -1; // very last line is NOT editable
}
return 0;
}
示例7: getNewEditorLine
QString JavaCodeDocumentation::getNewEditorLine ( int amount )
{
CodeGenerationPolicy *p = UMLApp::app()->getCommonPolicy();
if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
return getIndentationString(amount) + " * ";
else
return getIndentationString(amount) + "// ";
}
示例8: apply
void JavaCodeGenerationPolicyPage::apply()
{
CodeGenerationPolicy *commonPolicy = UMLApp::app()->commonPolicy();
JavaCodeGenerationPolicy * parent = (JavaCodeGenerationPolicy*) m_parentPolicy;
// block signals so we don't cause too many update content calls to code documents
commonPolicy->blockSignals(true);
commonPolicy->setCommentStyle((CodeGenerationPolicy::CommentStyle) form->m_SelectCommentStyle->currentIndex());
commonPolicy->setAttributeAccessorScope(Uml::Visibility::fromInt(form->m_accessorScopeCB->currentIndex()));
commonPolicy->setAssociationFieldScope(Uml::Visibility::fromInt(form->m_assocFieldScopeCB->currentIndex()));
commonPolicy->setAutoGenerateConstructors(form->m_generateConstructors->isChecked());
parent->setAutoGenerateAttribAccessors(form->m_generateAttribAccessors->isChecked());
parent->setAutoGenerateAssocAccessors(form->m_generateAssocAccessors->isChecked());
/**
* @todo unclean - CreateANTBuildFile attribute should be in java policy
CodeGenerator *codegen = UMLApp::app()->getGenerator();
JavaCodeGenerator *javacodegen = dynamic_cast<JavaCodeGenerator*>(codegen);
if (javacodegen)
javacodegen->setCreateANTBuildFile(form->m_makeANTDocumentCheckBox->isChecked());
*/
commonPolicy->blockSignals(false);
// now send out modified code content signal
commonPolicy->emitModifiedCodeContentSig();
}
示例9: apply
/**
* This function is called when leaving this wizard page.
* Saves the made settings and checks some values.
* @return the success state
*/
bool CodeGenOptionsPage::save()
{
// first save the settings to the selected generator policy
apply();
// before going on to the generation page, check that the output directory
// exists and is writable
// get the policy for the current code generator
CodeGenerationPolicy *policy = UMLApp::app()->commonPolicy();
// get the output directory path
QFileInfo info(policy->getOutputDirectory().absolutePath());
if (info.exists()) {
// directory exists... make sure we can write to it
if (!info.isWritable()) {
KMessageBox::sorry(this, i18n("The output folder exists, but it is not writable.\nPlease set the appropriate permissions or choose another folder."),
i18n("Error Writing to Output Folder"));
return false;
}
// it exits and we can write... make sure it is a directory
if (!info.isDir()) {
KMessageBox::sorry(this, i18n("%1 does not seem to be a folder. Please choose a valid folder.", info.filePath()),
i18n("Please Choose Valid Folder"));
return false;
}
}
else {
if (KMessageBox::questionYesNo(this,
i18n("The folder %1 does not exist. Do you want to create it now?", info.filePath()),
i18n("Output Folder Does Not Exist"), KGuiItem(i18n("Create Folder")), KGuiItem(i18n("Do Not Create"))) == KMessageBox::Yes)
{
QDir dir;
if (!dir.mkdir(info.filePath())) {
KMessageBox::sorry(this, i18n("The folder could not be created.\nPlease make sure you have write access to its parent folder or select another, valid, folder."),
i18n("Error Creating Folder"));
return false;
}
// else, directory created
}
else { // do not create output directory
KMessageBox::information(this, i18n("Please select a valid folder."),
i18n("Output Folder Does Not Exist"));
return false;
}
}
return true;
}
示例10: unformatText
/** UnFormat a long text string. Typically, this means removing
* the indentaion (linePrefix) and/or newline chars from each line.
*/
QString CPPCodeDocumentation::unformatText(const QString & text, const QString & indent)
{
QString mytext = TextBlock::unformatText(text, indent);
CodeGenerationPolicy * p = UMLApp::app()->commonPolicy();
// remove leading or trailing comment stuff
mytext.remove(QRegExp(QLatin1Char('^') + indent));
if(p->getCommentStyle() == CodeGenerationPolicy::MultiLine)
{
mytext.remove(QRegExp(QLatin1String("^\\/\\*\\*\\s*\n?")));
mytext.remove(QRegExp(QLatin1String("\\s*\\*\\/\\s*\n?$")));
mytext.remove(QRegExp(QLatin1String("^\\s*\\*\\s*")));
} else
mytext.remove(QRegExp(QLatin1String("^\\/\\/\\s*")));
return mytext;
}
示例11: CodeGenerationPolicyPage
JavaCodeGenerationPolicyPage::JavaCodeGenerationPolicyPage(QWidget *parent, const char *name, JavaCodeGenerationPolicy * policy)
: CodeGenerationPolicyPage(parent, name, policy)
{
CodeGenerationPolicy *commonPolicy = UMLApp::app()->commonPolicy();
form = new JavaCodeGenerationFormBase(this);
form->m_SelectCommentStyle->setCurrentIndex((int)(commonPolicy->getCommentStyle()));
form->m_generateConstructors->setChecked(commonPolicy->getAutoGenerateConstructors());
form->m_generateAttribAccessors->setChecked(policy->getAutoGenerateAttribAccessors());
form->m_generateAssocAccessors->setChecked(policy->getAutoGenerateAssocAccessors());
form->m_accessorScopeCB->setCurrentIndex(commonPolicy->getAttributeAccessorScope());
form->m_assocFieldScopeCB->setCurrentIndex(commonPolicy->getAssociationFieldScope());
/**
* @todo unclean - CreateANTBuildFile attribute should be in java policy
CodeGenerator *codegen = UMLApp::app()->getGenerator();
JavaCodeGenerator *javacodegen = dynamic_cast<JavaCodeGenerator*>(codegen);
if (javacodegen)
form->m_makeANTDocumentCheckBox->setChecked(javacodegen->getCreateANTBuildFile());
*/
}
示例12: getParentClassField
void RubyCodeClassFieldDeclarationBlock::updateContent( )
{
CodeClassField * cf = getParentClassField();
ClassifierCodeDocument * doc = cf->getParentDocument();
RubyCodeClassField * rcf = dynamic_cast<RubyCodeClassField*>(cf);
RubyClassifierCodeDocument* rdoc = dynamic_cast<RubyClassifierCodeDocument*>(doc);
CodeGenerationPolicy * p = UMLApp::app()->getCommonPolicy();
CodeGenerationPolicy::ScopePolicy scopePolicy = p->getAssociationFieldScope();
// Set the comment
QString notes = getParentObject()->getDoc();
getComment()->setText(notes);
// Set the body
QString staticValue = getParentObject()->getStatic() ? "static " : "";
QString scopeStr = rdoc->scopeToRubyDecl(getParentObject()->getVisibility());
// IF this is from an association, then scope taken as appropriate to policy
if(!rcf->parentIsAttribute())
{
switch (scopePolicy) {
case CodeGenerationPolicy::Public:
case CodeGenerationPolicy::Private:
case CodeGenerationPolicy::Protected:
scopeStr = rdoc->scopeToRubyDecl((Uml::Visibility::Value) scopePolicy);
break;
default:
case CodeGenerationPolicy::FromParent:
// do nothing here... will leave as from parent object
break;
}
}
QString typeName = rcf->getTypeName();
QString fieldName = rcf->getFieldName();
QString initialV = rcf->getInitialValue();
if (!cf->parentIsAttribute() && !cf->fieldIsSingleValue())
typeName = "Array";
QString body = staticValue+scopeStr+' '+typeName+' '+fieldName;
if (!initialV.isEmpty())
body.append(" = " + initialV);
else if (!cf->parentIsAttribute())
{
UMLRole * role = dynamic_cast<UMLRole*>(cf->getParentObject());
if (role->getObject()->getBaseType() == Uml::ot_Interface)
{
// do nothing.. can't instanciate an interface
} else {
// FIX?: IF a constructor method exists in the classifiercodedoc
// of the parent Object, then we can use that instead (if its empty).
if(cf->fieldIsSingleValue())
{
if(!typeName.isEmpty())
body.append(" = " + typeName + ".new()");
} else
body.append(" = []");
}
}
setText(body);
}
示例13: updateContent
/**
* update the start and end text for this ownedhierarchicalcodeblock.
*/
void JavaClassDeclarationBlock::updateContent ( )
{
JavaClassifierCodeDocument *parentDoc = dynamic_cast<JavaClassifierCodeDocument*>(getParentDocument());
UMLClassifier *c = parentDoc->getParentClassifier();
CodeGenerationPolicy *commonPolicy = UMLApp::app()->getCommonPolicy();
QString endLine = commonPolicy->getNewLineEndingChars();
bool isInterface = parentDoc->parentIsInterface(); // a little shortcut
QString JavaClassName = parentDoc->getJavaClassName(c->getName());
// COMMENT
if(isInterface)
getComment()->setText("Interface "+JavaClassName+endLine+c->getDoc());
else
getComment()->setText("Class "+JavaClassName+endLine+c->getDoc());
bool forceDoc = UMLApp::app()->getCommonPolicy()->getCodeVerboseDocumentComments();
if(forceDoc || !c->getDoc().isEmpty())
getComment()->setWriteOutText(true);
else
getComment()->setWriteOutText(false);
// Now set START/ENDING Text
QString startText = "";
// In Java, we need declare abstract only on classes
if (c->getAbstract() && !isInterface)
startText.append("abstract ");
if (c->getVisibility() != Uml::Visibility::Public) {
// We should probably emit a warning in here .. java doesn't like to allow
// private/protected classes. The best we can do (I believe)
// is to let these declarations default to "package visibility"
// which is a level between traditional "private" and "protected"
// scopes. To get this visibility level we just print nothing..
} else
startText.append("public ");
if(parentDoc->parentIsInterface())
startText.append("interface ");
else
startText.append("class ");
startText.append(JavaClassName);
// write inheritances out
UMLClassifierList superclasses =
c->findSuperClassConcepts(UMLClassifier::CLASS);
UMLClassifierList superinterfaces =
c->findSuperClassConcepts(UMLClassifier::INTERFACE);
int nrof_superclasses = superclasses.count();
int nrof_superinterfaces = superinterfaces.count();
// write out inheritance
int i = 0;
if(nrof_superclasses >0)
startText.append(" extends ");
for (UMLClassifier * concept= superclasses.first(); concept; concept = superclasses.next())
{
startText.append(parentDoc->cleanName(concept->getName()));
if(i != (nrof_superclasses-1))
startText.append(", ");
i++;
}
// write out what we 'implement'
i = 0;
if(nrof_superinterfaces >0)
{
// In Java interfaces "extend" other interfaces. Classes "implement" interfaces
if(isInterface)
startText.append(" extends ");
else
startText.append(" implements ");
}
for (UMLClassifier * concept= superinterfaces.first(); concept; concept = superinterfaces.next())
{
startText.append(parentDoc->cleanName(concept->getName()));
if(i != (nrof_superinterfaces-1))
startText.append(", ");
i++;
}
// Set the header and end text for the hier.codeblock
setStartText(startText+" {");
// setEndText("}"); // not needed
}
示例14: uError
void DCodeAccessorMethod::updateMethodDeclaration()
{
DCodeClassField * dfield = dynamic_cast<DCodeClassField*>(getParentClassField());
// Check for dynamic casting failure!
if (dfield == 0)
{
uError() << "dfield: invalid dynamic cast";
return;
}
CodeGenerationPolicy *commonpolicy = UMLApp::app()->commonPolicy();
// gather defs
Uml::Visibility::Enum scopePolicy = commonpolicy->getAttributeAccessorScope();
QString strVis = Uml::Visibility::toString(dfield->getVisibility());
QString fieldName = dfield->getFieldName();
QString fieldType = dfield->getTypeName();
QString objectType = dfield->getListObjectType();
if(objectType.isEmpty())
objectType = fieldName;
QString endLine = UMLApp::app()->commonPolicy()->getNewLineEndingChars();
// set scope of this accessor appropriately..if its an attribute,
// we need to be more sophisticated
if (dfield->parentIsAttribute()) {
switch (scopePolicy) {
case Uml::Visibility::Public:
case Uml::Visibility::Private:
case Uml::Visibility::Protected:
strVis = Uml::Visibility::toString(scopePolicy);
break;
default:
case Uml::Visibility::FromParent:
// do nothing..already have taken parent value
break;
}
}
// some variables we will need to populate
QString headerText;
QString methodReturnType;
QString methodName;
QString methodParams;
switch(getType()) {
case CodeAccessorMethod::ADD:
methodName = QLatin1String("add") + Codegen_Utils::capitalizeFirstLetter(fieldType);
methodReturnType = QLatin1String("void");
methodParams = objectType + QLatin1String(" value ");
headerText = QLatin1String("Add an object of type ") + objectType + QLatin1String(" to the List ") + fieldName + endLine + getParentObject()->doc() + endLine + QLatin1String("@return void");
break;
case CodeAccessorMethod::GET:
methodName = QLatin1String("get") + Codegen_Utils::capitalizeFirstLetter(fieldName);
methodReturnType = fieldType;
headerText = QLatin1String("Get the value of ") + fieldName + endLine + getParentObject()->doc() + endLine + QLatin1String("@return the value of ") + fieldName;
break;
case CodeAccessorMethod::LIST:
methodName = QLatin1String("get") + Codegen_Utils::capitalizeFirstLetter(fieldType) + QLatin1String("List");
methodReturnType = QLatin1String("List");
headerText = QLatin1String("Get the list of ") + fieldName + endLine + getParentObject()->doc() + endLine + QLatin1String("@return List of ") + fieldName;
break;
case CodeAccessorMethod::REMOVE:
methodName = QLatin1String("remove") + Codegen_Utils::capitalizeFirstLetter(fieldType);
methodReturnType = QLatin1String("void");
methodParams = objectType + QLatin1String(" value ");
headerText = QLatin1String("Remove an object of type ") + objectType + QLatin1String(" from the List ") + fieldName + endLine + getParentObject()->doc();
break;
case CodeAccessorMethod::SET:
methodName = QLatin1String("set") + Codegen_Utils::capitalizeFirstLetter(fieldName);
methodReturnType = QLatin1String("void");
methodParams = fieldType + QLatin1String(" value ");
headerText = QLatin1String("Set the value of ") + fieldName + endLine + getParentObject()->doc() + endLine;
break;
default:
// do nothing..no idea what this is
uWarning()<<"Warning: cant generate DCodeAccessorMethod for type: "<<getType();
break;
}
// set header once.
if(getComment()->getText().isEmpty())
getComment()->setText(headerText);
// set start/end method text
setStartMethodText(strVis + QLatin1Char(' ') + methodReturnType + QLatin1Char(' ') + methodName + QLatin1String(" (") + methodParams + QLatin1String(") {"));
setEndMethodText(QLatin1String("}"));
}
示例15: getIndentation
/**
* Get how much a single "level" of indentation will actually indent.
* @return the unit of indentation (for one level)
*/
QString TextBlock::getIndentation()
{
CodeGenerationPolicy* policy = UMLApp::app()->commonPolicy();
return policy->getIndentation();
}