[Uml-devel] kdesdk/umbrello/umbrello

Oliver Kellogg okellogg at users.sourceforge.net
Fri Feb 4 14:21:38 UTC 2005


CVS commit by okellogg: 

stringToDirection(): New.


  M +18 -0     model_utils.cpp   1.20
  M +10 -0     model_utils.h   1.13


--- kdesdk/umbrello/umbrello/model_utils.cpp  #1.19:1.20
@@ -235,4 +235,22 @@ QString scopeToString(Uml::Scope scope, 
 }
 
+int stringToDirection(QString input, Uml::Parameter_Direction & result) {
+        QRegExp dirx("^(in|out|inout)");
+        int pos = dirx.search(input);
+        if (pos == -1)
+                return 0;
+        const QString& dirStr = dirx.capturedTexts().first();
+        uint dirLen = dirStr.length();
+        if (input.length() > dirLen && !input[dirLen].isSpace())
+                return 0;       // no match after all.
+        if (dirStr == "out")
+                result = Uml::pd_Out;
+        else if (dirStr == "inout")
+                result = Uml::pd_InOut;
+        else
+                result = Uml::pd_In;
+        return dirLen;
+}
+
 Parse_Status parseTemplate(QString t, NameAndType& nmTpPair, UMLClassifier *owningScope) {
 

--- kdesdk/umbrello/umbrello/model_utils.h  #1.12:1.13
@@ -91,4 +91,14 @@ namespace Umbrello {
         QString scopeToString(Uml::Scope scope, bool mnemonic = true);
 
+        /**
+         * Parse a direction string into the Uml::Parameter_Direction.
+         *
+         * @param input         The string to parse: "in", "out", or "inout"
+         *                      optionally followed by whitespace.
+         * @param result        The corresponding Uml::Parameter_Direction.
+         * @return      Length of the string matched, excluding the optional
+         *              whitespace.
+         */
+        int stringToDirection(QString input, Uml::Parameter_Direction & result);
 
         /**






More information about the umbrello-devel mailing list