Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/xtend/CppIncludeUtil.xtend')
-rw-r--r--extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/xtend/CppIncludeUtil.xtend75
1 files changed, 75 insertions, 0 deletions
diff --git a/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/xtend/CppIncludeUtil.xtend b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/xtend/CppIncludeUtil.xtend
new file mode 100644
index 00000000000..f7cc8621673
--- /dev/null
+++ b/extraplugins/codegen/org.eclipse.papyrus.cpp.codegen/src/org/eclipse/papyrus/cpp/codegen/xtend/CppIncludeUtil.xtend
@@ -0,0 +1,75 @@
+package org.eclipse.papyrus.cpp.codegen.xtend
+
+import org.eclipse.uml2.uml.NamedElement
+import org.eclipse.papyrus.acceleo.GenUtils
+import org.eclipse.papyrus.C_Cpp.Include
+import org.eclipse.uml2.uml.util.UMLUtil
+
+/**
+ * @author Önder GÜRCAN (onder.gurcan@cea.fr)
+ */
+class CppIncludeUtil {
+ static def includeDirective(String path) {
+ if ((path != null) && (path.length > 0))
+ return '''#include ''' + '"' + path + '"'
+ }
+
+ static def CppIncludeHeader(NamedElement ne) {
+ if (GenUtils.hasStereotype(ne, Include)) {
+ UMLUtil.getStereotypeApplication(ne, Include)
+ var header = UMLUtil.getStereotypeApplication(ne, Include).header
+ if ((header != null) && (header.length > 0)) {
+ var includeHeader = constIncludeHeaderStart + GenUtils.cleanCR(header) + '\n' +
+ constIncludeHeaderEnd
+ return includeHeader
+ }
+ }
+ }
+
+ static def constIncludeHeaderStart() '''
+ // Include from Include stereotype (header)
+ '''
+
+ static def constIncludeHeaderEnd() '''
+ // End of Include stereotype (header)
+ '''
+
+ static def CppIncludePreBody(NamedElement ne) {
+ if (GenUtils.hasStereotype(ne, Include)) {
+ var String preBody = UMLUtil.getStereotypeApplication(ne, Include).preBody
+ if ((preBody != null) && (preBody.length > 0)) {
+ var includePreBody = constIncludePreBodyStart + GenUtils.cleanCR(preBody) + '\n' +
+ constIncludePreBodyEnd
+ return includePreBody
+ }
+ }
+ }
+
+ static def constIncludePreBodyStart() '''
+ // Include from Include stereotype (pre-body)
+ '''
+
+ static def constIncludePreBodyEnd() '''
+ // End of Include stereotype (pre-body)
+ '''
+
+ static def CppIncludeBody(NamedElement ne) {
+ if (GenUtils.hasStereotype(ne, Include)) {
+ var String body = UMLUtil.getStereotypeApplication(ne, Include).body
+ if ((body != null) && (body.length > 0)) {
+ var includeBody = constIncludeBodyStart + GenUtils.cleanCR(body) + '\n' +
+ constIncludeBodyEnd
+ return includeBody
+ }
+ }
+ }
+
+ static def constIncludeBodyStart() '''
+ // Include from Include declaration (body)
+ '''
+
+ static def constIncludeBodyEnd() '''
+ // End of Include declaration (body)
+ '''
+
+}

Back to the top