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

Sharan Rao sharanrao at gmail.com
Fri Jun 22 09:34:06 UTC 2007


SVN commit 678779 by sharan:

Fixes for EBN Krazy #6 ( single character strings )



 M  +4 -4      codeclassfield.cpp  
 M  +1 -1      codegenerationpolicy.cpp  
 M  +3 -3      codegenerators/cppwriter.cpp  
 M  +33 -33    codegenerators/dwriter.cpp  
 M  +4 -4      codegenerators/javawriter.cpp  
 M  +1 -1      codegenerators/rubycodeoperation.cpp  
 M  +1 -1      codegenerators/rubywriter.cpp  
 M  +2 -2      codegenerators/xmlschemawriter.cpp  
 M  +1 -1      codeimport/idlimport.cpp  
 M  +2 -2      codeimport/javaimport.cpp  
 M  +3 -3      codeimport/nativeimportbase.cpp  
 M  +1 -1      codeimport/pythonimport.cpp  
 M  +2 -2      import_rose.cpp  
 M  +6 -6      model_utils.cpp  
 M  +1 -1      operation.cpp  


--- trunk/KDE/kdesdk/umbrello/umbrello/codeclassfield.cpp #678778:678779
@@ -367,10 +367,10 @@
 {
     // check for strings only
     if (!value.isEmpty() && type == "String") {
-        if (!value.startsWith("\""))
-            value.prepend("\"");
-        if (!value.endsWith("\""))
-            value.append("\"");
+        if (!value.startsWith('\"'))
+            value.prepend('\"');
+        if (!value.endsWith('\"'))
+            value.append('\"');
     }
     return value;
 }
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerationpolicy.cpp #678778:678779
@@ -522,7 +522,7 @@
     // heading.[extension]. If there is no such file, we try to
     // get any file with the same extension
     QString filename;
-    if(str.startsWith(".")) {
+    if(str.startsWith('.')) {
         if(QFile::exists(m_headingFiles.absoluteFilePath("heading"+str)))
             filename = m_headingFiles.absoluteFilePath("heading"+str);
         else {
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/cppwriter.cpp #678778:678779
@@ -1236,9 +1236,9 @@
     // check for strings only
     if (!val.isEmpty() && type == policyExt()->getStringClassName()) {
         if (!val.startsWith("\""))
-            val.prepend("\"");
-        if (!val.endsWith("\""))
-            val.append("\"");
+            val.prepend('\"');
+        if (!val.endsWith('\"'))
+            val.append('\"');
     }
     return val;
 }
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/dwriter.cpp #678778:678779
@@ -191,7 +191,7 @@
             }
         }
     }
-    
+
     // another preparation, determine what we have
     UMLAssociationList associations = c->getSpecificAssocs(Uml::at_Association); // BAD! only way to get "general" associations.
     UMLAssociationList uniAssociations = c->getUniAssociationToBeImplemented();
@@ -270,7 +270,7 @@
     }
 
     writeOperations(c, d);
-    
+
     d << "}" << m_endl; // end class
 
     file.close();
@@ -349,18 +349,18 @@
         // (f) base classes
         for (UMLClassifier * concept= superclasses.first(); concept; concept = superclasses.next()) {
             d << cleanName(concept->getName());
-    
+
             count--;
-    
+
             if (count>0) d << ", ";
         }
-    
+
         // (g) interfaces
         for (UMLClassifier * concept= superinterfaces.first(); concept; concept = superinterfaces.next()) {
             d << cleanName(concept->getName());
-    
+
             count--;
-    
+
             if (count>0) d << ", ";
         }
     }
@@ -391,7 +391,7 @@
 
         // TODO: find out whether this class has accessors or not
         bool hasAccessorMethods = true;
-        
+
         // attribute name
         if (hasAccessorMethods) {
             d << "m_";
@@ -439,7 +439,7 @@
 
     for (int i = 0; i < lines.count(); ++i) {
         QString tmp = lines[i];
-        
+
         while (tmp.count() > 77) {
             int l = tmp.left(77).lastIndexOf(' ');
             if (l < 1) l = tmp.indexOf(' ', 77);
@@ -450,10 +450,10 @@
             d << myIndent << (dDocStyle ? " * " : "// ") << tmp.left(l) << m_endl;
             tmp = tmp.right(tmp.count() - l);
         }
-        
+
         d << myIndent << (dDocStyle ? " * " : "// ") << tmp << m_endl;
     }
-    
+
     if(dDocStyle) {
         d << myIndent << " */" << m_endl;
     }
@@ -522,22 +522,22 @@
     }
 
     bool hasAccessors = true;
-    
+
     // declare the association based on whether it is this a single variable
     // or a List (Vector). One day this will be done correctly with special
     // multiplicity object that we don't have to figure out what it means via regex.
     if(multi.isEmpty() || multi.contains(QRegExp("^[01]$"))) {
         d << m_indentation << fieldClassName << " ";
-        
+
         if (hasAccessors) d << "m_";
-        
+
         d << deCapitaliseFirstLetter(roleName) << ";";
     } else {
         d << m_indentation << fieldClassName << "[] ";
         //TODO: templated containers
-        
+
         if (hasAccessors) d << "m_";
-        
+
         d << pluralize(deCapitaliseFirstLetter(roleName)) << ";";
         // from here we could initialize default values, or put in an init() section
         // of the constructors
@@ -609,7 +609,7 @@
     if (changeType != Uml::chg_Frozen) {
         writeDocumentation("Adds a " + fieldNameUP + " to the list of " +
                            fieldName + '.', description, "", m_indentation, d);
-        
+
         d << m_indentation << "void add" << fieldNameUC << "(";
         d << fieldClassName << " new" << fieldNameUC << ") {";
         d << startline << m_indentation << fieldVarName << " ~= new" << fieldNameUC << ";";
@@ -638,7 +638,7 @@
     writeDocumentation("Returns the list of " + fieldName + '.',
                        description, "@return List of " + fieldName + '.',
                        m_indentation, d);
-    
+
     d << m_indentation << fieldClassName << "[] get" << fieldName << "() {";
     d << startline << m_indentation << "return " << fieldVarName << ";";
     d << startline << "}" << m_endl << m_endl;
@@ -658,7 +658,7 @@
         writeDocumentation("Sets the value of " + fieldName + '.', description,
                            "@param new" + fieldNameUC + " The new value of " + fieldName + '.',
                            m_indentation, d);
-        
+
         d << m_indentation << fieldClassName << " " << fieldName << "(";
         d << fieldClassName << " new" << fieldNameUC << ") {";
         d << startline << m_indentation << "return " << fieldVarName << " = new" << fieldNameUC << ";";
@@ -669,7 +669,7 @@
     writeDocumentation("Returns the value of " + fieldName + '.', description,
                        "@return The value of " + fieldName + '.',
                        m_indentation, d);
-    
+
     d << m_indentation << fieldClassName << " " << fieldName << "() {";
     d << startline << m_indentation << "return " << fieldVarName << ";";
     d << startline << "}" << m_endl << m_endl;
@@ -843,19 +843,19 @@
 
     if (oppub.count() > 0) {
         writeProtectionMod(Uml::Visibility::Public, d);
-    
+
         writeOperations(oppub,d);
     }
 
     if (opprot.count() > 0) {
         writeProtectionMod(Uml::Visibility::Protected, d);
-        
+
         writeOperations(opprot, d);
     }
 
     if (oppriv.count() > 0) {
         writeProtectionMod(Uml::Visibility::Private, d);
-        
+
         writeOperations(oppriv, d);
     }
 
@@ -880,7 +880,7 @@
         str = ""; // reset for next method
         if (op->getAbstract() && !isInterface) str += "abstract ";
         if (op->getStatic()) str += "static ";
-        
+
         str += methodReturnType + ' ' +cleanName(op->getName()) + '(';
 
         atl = op->getParmList();
@@ -896,7 +896,7 @@
                    + ((j < i-1)?", ":"");
             returnStr += "@param " + atName+' '+at->getDoc() + m_endl;
         }
-        
+
         str+= ')';
 
         // method only gets a body IF its not abstract
@@ -914,24 +914,24 @@
 QString DWriter::fixInitialStringDeclValue(QString value, QString type) {
     // check for strings only
     if (!value.isEmpty() && type == "String") {
-        if (!value.startsWith("\""))
-            value.prepend("\"");
-        if (!value.endsWith("\""))
-            value.append("\"");
+        if (!value.startsWith('\"'))
+            value.prepend('\"');
+        if (!value.endsWith('\"'))
+            value.append('\"');
     }
     return value;
 }
 
 QString DWriter::scopeToDDecl(Uml::Visibility scope) {
     QString scopeString;
-    
+
     switch(scope) {
         case Uml::Visibility::Public: scopeString = "public"; break;
         case Uml::Visibility::Protected: scopeString = "protected"; break;
         case Uml::Visibility::Private: scopeString = "private"; break;
         default: break; //TODO: package and export
     }
-    
+
     return scopeString;
 }
 
@@ -956,7 +956,7 @@
 
 QString DWriter::unPluralize(QString string) {
     // does not handle special cases liek datum -> data, etc.
-    
+
     if (string.count() > 2 && string.right(3) == "ses") {
         return string.left(string.count() - 2);
     }
@@ -964,7 +964,7 @@
     if (string.right(1) == "s") {
         return string.left(string.count() - 1);
     }
-    
+
     return string;
 }
 
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/javawriter.cpp #678778:678779
@@ -895,10 +895,10 @@
 {
     // check for strings only
     if (!value.isEmpty() && type == "String") {
-        if (!value.startsWith("\""))
-            value.prepend("\"");
-        if (!value.endsWith("\""))
-            value.append("\"");
+        if (!value.startsWith('\"'))
+            value.prepend('\"');
+        if (!value.endsWith('\"'))
+            value.append('\"');
     }
     return value;
 }
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/rubycodeoperation.cpp #678778:678779
@@ -74,7 +74,7 @@
 
     // Skip destructors, and operator methods which
     // can't be defined in ruby
-    if (    methodName.startsWith("~")
+    if (    methodName.startsWith('~')
             || QRegExp("operator\\s*(=|--|\\+\\+|!=)$").exactMatch(methodName) )
     {
         getComment()->setText("");
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/rubywriter.cpp #678778:678779
@@ -238,7 +238,7 @@
 
         // Skip destructors, and operator methods which
         // can't be defined in ruby
-        if (    methodName.startsWith("~")
+        if (    methodName.startsWith('~')
                 || methodName == "operator ="
                 || methodName == "operator --"
                 || methodName == "operator ++"
--- trunk/KDE/kdesdk/umbrello/umbrello/codegenerators/xmlschemawriter.cpp #678778:678779
@@ -745,9 +745,9 @@
 {
     // check for strings only
     if (!value.isEmpty() && type == "xs:string") {
-        if (!value.startsWith("\""))
+        if (!value.startsWith('\"'))
             value.remove(0,1);
-        if (!value.endsWith("\""))
+        if (!value.endsWith('\"'))
             value.remove(value.length(),1);
     }
     return value;
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/idlimport.cpp #678778:678779
@@ -50,7 +50,7 @@
 
 bool IDLImport::preprocess(QString& line) {
     // Ignore C preprocessor generated lines.
-    if (line.startsWith("#"))
+    if (line.startsWith('#'))
         return true;  // done
     return NativeImportBase::preprocess(line);
 }
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/javaimport.cpp #678778:678779
@@ -163,7 +163,7 @@
         QString import = (*pathIt);
         QStringList split = QStringList::split( '.', import );
         split.pop_back(); // remove the * or the classname
-        if ( import.endsWith( "*" ) || import.endsWith( baseClassName) ) {
+        if ( import.endsWith( '*' ) || import.endsWith( baseClassName) ) {
             // check if the file we want is in this imported package
             // convert the org.test type package into a filename
             //
@@ -390,7 +390,7 @@
     if (keyword == "import") {
         // keep track of imports so we can resolve classes we are dependent on
         QString import = advance();
-        if ( import.endsWith(".") ) {
+        if ( import.endsWith('.') ) {
             //this most likely an import that ends with a *
             //
             import = import + advance();
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/nativeimportbase.cpp #678778:678779
@@ -275,7 +275,7 @@
         Import_Utils::addIncludePath(path);
     }
     if (! QFile::exists(filename)) {
-        if (filename.startsWith("/")) {
+        if (filename.startsWith('/')) {
             kError() << msgPrefix << "cannot find file" << endl;
             return;
         }
@@ -284,8 +284,8 @@
         for (QStringList::Iterator pathIt = includePaths.begin();
                                    pathIt != includePaths.end(); ++pathIt) {
             QString path = (*pathIt);
-            if (! path.endsWith("/")) {
-                path.append("/");
+            if (! path.endsWith('/')) {
+                path.append('/');
             }
             if (QFile::exists(path + filename)) {
                 fname.prepend(path);
--- trunk/KDE/kdesdk/umbrello/umbrello/codeimport/pythonimport.cpp #678778:678779
@@ -79,7 +79,7 @@
             m_srcIndex++;
         }
     }
-    if (line.endsWith(":")) {
+    if (line.endsWith(':')) {
         line.replace( QRegExp(":$"), "{" );
         m_braceWasOpened = true;
     } else {
--- trunk/KDE/kdesdk/umbrello/umbrello/import_rose.cpp #678778:678779
@@ -170,7 +170,7 @@
     while (!(line = stream.readLine()).isNull()) {
         linum++;
         line = line.trimmed();
-        if (line.isEmpty() || line.startsWith(")"))
+        if (line.isEmpty() || line.startsWith(')'))
             break;
         if (line[0] != '|') {
             kError() << loc() << "expecting '|' at start of verbatim text" << endl;
@@ -322,7 +322,7 @@
             QString nxt = tokens.first();
             if (isImmediateValue(nxt)) {
                 value.string = extractImmediateValues(tokens);
-            } else if (nxt == "value" || nxt.startsWith("\"")) {
+            } else if (nxt == "value" || nxt.startsWith('\"')) {
                 value.string = extractValue(tokens, stream);
             } else {
                 value.node = readAttributes(tokens, stream);
--- trunk/KDE/kdesdk/umbrello/umbrello/model_utils.cpp #678778:678779
@@ -112,16 +112,16 @@
     // If we have a pointer or a reference in cpp we need to remove
     // the asterisks and ampersands in order to find the appropriate object
     if (UMLApp::app()->getActiveLanguage() == Uml::pl_Cpp) {
-        if (name.endsWith("*"))
-            name.remove("*");
-        else if (name.contains("&"))
-            name.remove("&");
+        if (name.endsWith('*'))
+            name.remove('*');
+        else if (name.contains('&'))
+            name.remove('&');
     }
 #endif
     if (name.contains("::"))
         components = QStringList::split("::", name);
-    else if (name.contains("."))
-        components = QStringList::split(".", name);
+    else if (name.contains('.'))
+        components = QStringList::split('.', name);
     QString nameWithoutFirstPrefix;
     if (components.size() > 1) {
         name = components.front();
--- trunk/KDE/kdesdk/umbrello/umbrello/operation.cpp #678778:678779
@@ -261,7 +261,7 @@
     // Special support for C++ syntax:
     // It's a destructor operation if the operation name begins
     // with "~" followed by the name of the parent classifier.
-    if (! opName.startsWith("~"))
+    if (! opName.startsWith('~'))
         return false;
     opName.remove( QRegExp("^~\\s*") );
     return (cName == opName);




More information about the umbrello-devel mailing list