本文整理汇总了C++中CodeGenerationPolicy::getAutoGenerateConstructors方法的典型用法代码示例。如果您正苦于以下问题:C++ CodeGenerationPolicy::getAutoGenerateConstructors方法的具体用法?C++ CodeGenerationPolicy::getAutoGenerateConstructors怎么用?C++ CodeGenerationPolicy::getAutoGenerateConstructors使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGenerationPolicy
的用法示例。
在下文中一共展示了CodeGenerationPolicy::getAutoGenerateConstructors方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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 );
}
示例2: 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());
*/
}
示例3: updateContent
//.........这里部分代码省略.........
bool forceDoc = pol->getCodeVerboseDocumentComments();
// set conditions for showing this comment
if (!forceDoc && !hasClassFields() && !hasOperationMethods)
pubMethodsComment->setWriteOutText(false);
else
pubMethodsComment->setWriteOutText(true);
// protected methods
HierarchicalCodeBlock * protMethodsBlock = protectedBlock->getHierarchicalCodeBlock(QLatin1String("protMethodsBlock"), QString(), 1);
CodeComment * protMethodsComment = protMethodsBlock->getComment();
// set conditions for showing this comment
if (!forceDoc && !hasClassFields() && !hasOperationMethods)
protMethodsComment->setWriteOutText(false);
else
protMethodsComment->setWriteOutText(true);
// private methods
HierarchicalCodeBlock * privMethodsBlock = privateBlock->getHierarchicalCodeBlock(QLatin1String("privMethodsBlock"), QString(), 1);
CodeComment * privMethodsComment = privMethodsBlock->getComment();
// set conditions for showing this comment
if (!forceDoc && !hasClassFields() && !hasOperationMethods)
privMethodsComment->setWriteOutText(false);
else
privMethodsComment->setWriteOutText(true);
// METHODS sub-section : constructor methods
//
// public
pubConstructorBlock = pubMethodsBlock->getHierarchicalCodeBlock(QLatin1String("constructionMethods"), QLatin1String("Constructors"), 1);
// special condiions for showing comment: only when autogenerateding empty constructors
// Although, we *should* check for other constructor methods too
CodeComment * pubConstComment = pubConstructorBlock->getComment();
if (!forceDoc && (isInterface || !pol->getAutoGenerateConstructors()))
pubConstComment->setWriteOutText(false);
else
pubConstComment->setWriteOutText(true);
// protected
protConstructorBlock = protMethodsBlock->getHierarchicalCodeBlock(QLatin1String("constructionMethods"), QLatin1String("Constructors"), 1);
// special condiions for showing comment: only when autogenerateding empty constructors
// Although, we *should* check for other constructor methods too
CodeComment * protConstComment = protConstructorBlock->getComment();
if (!forceDoc && (isInterface || !pol->getAutoGenerateConstructors()))
protConstComment->setWriteOutText(false);
else
protConstComment->setWriteOutText(true);
// private
privConstructorBlock = privMethodsBlock->getHierarchicalCodeBlock(QLatin1String("constructionMethods"), QLatin1String("Constructors"), 1);
// special condiions for showing comment: only when autogenerateding empty constructors
// Although, we *should* check for other constructor methods too
CodeComment * privConstComment = privConstructorBlock->getComment();
if (!forceDoc && (isInterface || !pol->getAutoGenerateConstructors()))
privConstComment->setWriteOutText(false);
else
privConstComment->setWriteOutText(true);
// get/create the accessor codeblock
// public
HierarchicalCodeBlock * pubAccessorBlock = pubMethodsBlock->getHierarchicalCodeBlock(QLatin1String("accessorMethods"), QLatin1String("Accessor Methods"), 1);
// set conditions for showing section comment
CodeComment * pubAccessComment = pubAccessorBlock->getComment();
if (!forceDoc && !hasClassFields())
pubAccessComment->setWriteOutText(false);
else
示例4: updateContent
//.........这里部分代码省略.........
else
pubMethodsComment->setWriteOutText(true);
// protected methods
HierarchicalCodeBlock * protMethodsBlock = protectedBlock->getHierarchicalCodeBlock("protMethodsBlock", "", 1);
CodeComment * protMethodsComment = protMethodsBlock->getComment();
// set conditions for showing this comment
if (!forcedoc && !hasclassFields && !hasOperationMethods)
protMethodsComment->setWriteOutText(false);
else
protMethodsComment->setWriteOutText(true);
// private methods
HierarchicalCodeBlock * privMethodsBlock = privateBlock->getHierarchicalCodeBlock("privMethodsBlock", "", 1);
CodeComment * privMethodsComment = privMethodsBlock->getComment();
// set conditions for showing this comment
if (!forcedoc && !hasclassFields && !hasOperationMethods)
privMethodsComment->setWriteOutText(false);
else
privMethodsComment->setWriteOutText(true);
// METHODS sub-section : constructor methods
//
CodeGenerationPolicy *pol = UMLApp::app()->getCommonPolicy();
// setup/get/create the constructor codeblocks
// public
pubConstructorBlock = pubMethodsBlock->getHierarchicalCodeBlock("constructionMethods", "Constructors", 1);
// special condiions for showing comment: only when autogenerateding empty constructors
// Although, we *should* check for other constructor methods too
CodeComment * pubConstComment = pubConstructorBlock->getComment();
if (!forcedoc && (isInterface || !pol->getAutoGenerateConstructors()))
pubConstComment->setWriteOutText(false);
else
pubConstComment->setWriteOutText(true);
// protected
protConstructorBlock = protMethodsBlock->getHierarchicalCodeBlock("constructionMethods", "Constructors", 1);
// special condiions for showing comment: only when autogenerateding empty constructors
// Although, we *should* check for other constructor methods too
CodeComment * protConstComment = protConstructorBlock->getComment();
if (!forcedoc && (isInterface || !pol->getAutoGenerateConstructors()))
protConstComment->setWriteOutText(false);
else
protConstComment->setWriteOutText(true);
// private
privConstructorBlock = privMethodsBlock->getHierarchicalCodeBlock("constructionMethods", "Constructors", 1);
// special condiions for showing comment: only when autogenerateding empty constructors
// Although, we *should* check for other constructor methods too
CodeComment * privConstComment = privConstructorBlock->getComment();
if (!forcedoc && (isInterface || !pol->getAutoGenerateConstructors()))
privConstComment->setWriteOutText(false);
else
privConstComment->setWriteOutText(true);
// add/get the empty constructor. I guess since there is no
// meta-data to state what the scope of this method is, we will make it
// "public" as a default. This might present problems if the user wants
// to move the block into the "private" or "protected" blocks.
QString emptyConstStatement = cppClassName + " ( ) { }";
// search for this first in the entire document. IF not present, put
// it in the public constructor method block
示例5: updateContent
//.........这里部分代码省略.........
HierarchicalCodeBlock * fieldDeclBlock = myClassDeclCodeBlock->getHierarchicalCodeBlock(QLatin1String("fieldsDecl"), QLatin1String("Fields"), 1);
// Update the comment: we only set comment to appear under the following conditions
CodeComment * fcomment = fieldDeclBlock->getComment();
if (isInterface || (!forceDoc() && !hasClassFields()))
fcomment->setWriteOutText(false);
else
fcomment->setWriteOutText(true);
// now actually declare the fields within the appropriate HCodeBlock
declareClassFields(staticAttribClassFields, fieldDeclBlock);
declareClassFields(attribClassFields, fieldDeclBlock);
declareClassFields(plainAssocClassFields, fieldDeclBlock);
declareClassFields(aggregationClassFields, fieldDeclBlock);
declareClassFields(compositionClassFields, fieldDeclBlock);
//
// METHODS section
//
// get/create the method codeblock
HierarchicalCodeBlock * methodsBlock = myClassDeclCodeBlock->getHierarchicalCodeBlock(QLatin1String("methodsBlock"), QLatin1String("Methods"), 1);
// Update the section comment
CodeComment * methodsComment = methodsBlock->getComment();
// set conditions for showing this comment
if (!forceDoc() && !hasClassFields() && !hasOperationMethods)
methodsComment->setWriteOutText(false);
else
methodsComment->setWriteOutText(true);
// METHODS sub-section : constructor methods
//
// get/create the constructor codeblock
HierarchicalCodeBlock * constBlock = methodsBlock->getHierarchicalCodeBlock(QLatin1String("constructorMethods"), QLatin1String("Constructors"), 1);
constructorBlock = constBlock; // record this codeblock for later, when operations are updated
// special condiions for showing comment: only when autogenerateding empty constructors
// Although, we *should* check for other constructor methods too
CodeComment * constComment = constBlock->getComment();
CodeGenerationPolicy *pol = UMLApp::app()->commonPolicy();
if (!forceDoc() && (isInterface || !pol->getAutoGenerateConstructors()))
constComment->setWriteOutText(false);
else
constComment->setWriteOutText(true);
// add/get the empty constructor
QString DClassName = getDClassName(c->name());
QString emptyConstStatement = QLatin1String("public ")+DClassName+QLatin1String(" () { }");
CodeBlockWithComments * emptyConstBlock =
constBlock->addOrUpdateTaggedCodeBlockWithComments(QLatin1String("emptyconstructor"), emptyConstStatement, QLatin1String("Empty Constructor"), 1, false);
// Now, as an additional condition we only show the empty constructor block
// IF it was desired to be shown
if (parentIsClass() && pol->getAutoGenerateConstructors())
emptyConstBlock->setWriteOutText(true);
else
emptyConstBlock->setWriteOutText(false);
// METHODS subsection : ACCESSOR METHODS
//
// get/create the accessor codeblock
HierarchicalCodeBlock * accessorBlock = methodsBlock->getHierarchicalCodeBlock(QLatin1String("accessorMethods"), QLatin1String("Accessor Methods"), 1);
// set conditions for showing section comment
CodeComment * accessComment = accessorBlock->getComment();
if (!forceDoc() && !hasClassFields())
accessComment->setWriteOutText(false);
else
accessComment->setWriteOutText(true);
// now, 2 sub-sub sections in accessor block
// add/update accessor methods for attributes
HierarchicalCodeBlock * staticAccessors = accessorBlock->getHierarchicalCodeBlock(QLatin1String("staticAccessorMethods"), QString(), 1);
staticAccessors->getComment()->setWriteOutText(false); // never write block comment
staticAccessors->addCodeClassFieldMethods(staticAttribClassFields);
staticAccessors->addCodeClassFieldMethods(attribClassFields);
// add/update accessor methods for associations
HierarchicalCodeBlock * regularAccessors = accessorBlock->getHierarchicalCodeBlock(QLatin1String("regularAccessorMethods"), QString(), 1);
regularAccessors->getComment()->setWriteOutText(false); // never write block comment
regularAccessors->addCodeClassFieldMethods(plainAssocClassFields);
regularAccessors->addCodeClassFieldMethods(aggregationClassFields);
regularAccessors->addCodeClassFieldMethods(compositionClassFields);
// METHODS subsection : Operation methods (which arent constructors)
//
// get/create the operations codeblock
operationsBlock = methodsBlock->getHierarchicalCodeBlock(QLatin1String("operationMethods"), QLatin1String("Operations"), 1);
// set conditions for showing section comment
CodeComment * ocomment = operationsBlock->getComment();
if (!forceDoc() && !hasOperationMethods)
ocomment->setWriteOutText(false);
else
ocomment->setWriteOutText(true);
}