summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <ralf.habacker@freenet.de>2016-09-20 10:27:50 (GMT)
committerRalf Habacker <ralf.habacker@freenet.de>2016-09-20 10:27:50 (GMT)
commited217c453aba8d14cd666ff9eba8a4dca45477ce (patch)
tree819d6ebbc6243d03de2eba02ca06d9e322a11d0a
parentc99a72821608069baf5625c2f6fd0024ea1fe279 (diff)
Add support for array types to c++ generator.
CCBUG:100338
-rw-r--r--umbrello/codegenerators/cpp/cppwriter.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/umbrello/codegenerators/cpp/cppwriter.cpp b/umbrello/codegenerators/cpp/cppwriter.cpp
index 2da9531..f54065e 100644
--- a/umbrello/codegenerators/cpp/cppwriter.cpp
+++ b/umbrello/codegenerators/cpp/cppwriter.cpp
@@ -526,6 +526,11 @@ void CppWriter::writeAttributeDecls (UMLClassifier *c, Uml::Visibility::Enum vis
QString staticValue = at->isStatic() ? QLatin1String("static ") : QString();
QString typeName = fixTypeName(at->getTypeName());
+ int i = typeName.indexOf(QLatin1Char('['));
+ if (i > -1) {
+ varName += typeName.mid(i);
+ typeName = typeName.left(i);
+ }
if (!documentation.isEmpty())
writeComment(documentation, indent(), stream);
stream << indent() << staticValue << typeName << " " << varName << ";" << m_endl;
@@ -921,6 +926,16 @@ void CppWriter::writeSingleAttributeAccessorMethods(
QString className = fixTypeName(fieldClassName);
QString fldName = Codegen_Utils::capitalizeFirstLetter(fieldName);
QString indnt = indent();
+ QString varName = QLatin1String("new_var");
+ QString fullVarName = varName;
+
+ int i = className.indexOf(QLatin1Char('['));
+ bool isArrayType = false;
+ if (i > -1) {
+ fullVarName += className.mid(i);
+ className = className.left(i);
+ isArrayType = true;
+ }
// set method
if (change == Uml::Changeability::Changeable) {
@@ -928,7 +943,7 @@ void CppWriter::writeSingleAttributeAccessorMethods(
stream << indnt << "void ";
if (!isHeaderMethod)
stream << className_ << "::";
- stream << "set" << fldName << " (" << className << " new_var)";
+ stream << "set" << fldName << " (" << className << " " << fullVarName << ")";
if (writeMethodBody) {
stream << indnt << " {" << m_endl;
@@ -937,12 +952,18 @@ void CppWriter::writeSingleAttributeAccessorMethods(
m_indentLevel--;
if (isStatic)
stream << className_ << "::";
- stream << fieldVarName << " = new_var;" << m_endl;
+ if (isArrayType) {
+ stream << "*" << fieldVarName << " = *" << varName << ";" << m_endl;
+ else
+ stream << fieldVarName << " = " << fullVarName << ";" << m_endl;
stream << indnt << "}" << m_endl;
} else
stream << ";" << m_endl;
}
+ if (i)
+ className += QLatin1String("*");
+
// get method
writeDocumentation(QLatin1String("Get the value of ") + fieldVarName, description, policyExt()->getDocToolTag() + QLatin1String("return the value of ") + fieldVarName, stream);
stream << indnt << className << " ";
@@ -1185,6 +1206,13 @@ void CppWriter::writeOperations(UMLClassifier *c, UMLOperationList &oplist, bool
UMLAttribute* at = atlIt.next();
QString typeName = fixTypeName(at->getTypeName());
QString atName = cleanName(at->name());
+ QString atNameType = atName;
+
+ int i = typeName.indexOf(QLatin1Char('['));
+ if (i > -1) {
+ atNameType += typeName.mid(i);
+ typeName = typeName.left(i);
+ }
str += typeName + QLatin1Char(' ') + atName;
const QString initVal = at->getInitialValue();
if (! initVal.isEmpty())