[Uml-devel] branches/KDE/3.5/kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Sat Feb 17 22:37:32 UTC 2007


SVN commit 634657 by okellogg:

parseAttribute(): Add an optional return argument, vis.
If vis is non-NULL and the input string starts with a mnemonic visibility
indicator then the corresponding Uml::Visibility is returned in vis.


 M  +21 -1     model_utils.cpp  
 M  +10 -1     model_utils.h  


--- branches/KDE/3.5/kdesdk/umbrello/umbrello/model_utils.cpp #634656:634657
@@ -429,7 +429,8 @@
     return PS_OK;
 }
 
-Parse_Status parseAttribute(QString a, NameAndType& nmTp, UMLClassifier *owningScope) {
+Parse_Status parseAttribute(QString a, NameAndType& nmTp, UMLClassifier *owningScope,
+                            Uml::Visibility *vis /* = 0 */) {
     UMLDoc *pDoc = UMLApp::app()->getDocument();
 
     a = a.simplifyWhiteSpace();
@@ -442,6 +443,25 @@
         return PS_OK;
     }
     QString name = a.left(colonPos).stripWhiteSpace();
+    if (vis) {
+        QRegExp mnemonicVis("^([\\+\\#\\-\\~] *)");
+        int pos = mnemonicVis.search(name);
+        if (pos == -1) {
+            *vis = Uml::Visibility::Private;  // default value
+        } else {
+            QString caption = mnemonicVis.cap(1);
+            QString strVis = caption.left(1);
+            if (strVis == "+")
+                *vis = Uml::Visibility::Public;
+            else if (strVis == "#")
+                *vis = Uml::Visibility::Protected;
+            else if (strVis == "-")
+                *vis = Uml::Visibility::Private;
+            else
+                *vis = Uml::Visibility::Implementation;
+        }
+        name.remove(mnemonicVis);
+    }
     Uml::Parameter_Direction pd = Uml::pd_In;
     if (name.startsWith("in ")) {
         pd = Uml::pd_In;
--- branches/KDE/3.5/kdesdk/umbrello/umbrello/model_utils.h #634656:634657
@@ -293,9 +293,18 @@
  *                      Example:  argname : argtype
  * @param nmTp          NameAndType returned by this method.
  * @param owningScope   Pointer to the owning scope of the attribute.
+ * @param vis           Optional pointer to visibility (return value.)
+ *                      The visibility may be given at the beginning of the
+ *                      attribute text in mnemonic form as follows:
+ *                      "+"  stands for public
+ *                      "#"  stands for protected
+ *                      "-"  stands for private
+ *                      "~"  stands for implementation level visibility
+ *
  * @return      Error status of the parse, PS_OK for success.
  */
-Parse_Status parseAttribute(QString a, NameAndType& nmTp, UMLClassifier *owningScope);
+Parse_Status parseAttribute(QString a, NameAndType& nmTp, UMLClassifier *owningScope,
+                            Uml::Visibility *vis = 0);
 
 /**
  * Parses an operation given in UML syntax.




More information about the umbrello-devel mailing list