umbrello API Documentation

umlnamespace.cpp

00001 /***************************************************************************
00002  *                                                                         *
00003  *   This program is free software; you can redistribute it and/or modify  *
00004  *   it under the terms of the GNU General Public License as published by  *
00005  *   the Free Software Foundation; either version 2 of the License, or     *
00006  *   (at your option) any later version.                                   *
00007  *                                                                         *
00008  *   copyright (C) 2002-2006                                               *
00009  *   Umbrello UML Modeller Authors <uml-devel@uml.sf.net>                  *
00010  ***************************************************************************/
00011 
00012 #include "umlnamespace.h"
00013 #include "qregexp.h"
00014 
00015 namespace Uml {
00016 
00017 bool tagEq (const QString& inTag, const QString& inPattern) {
00018     QString tag = inTag;
00019     QString pattern = inPattern;
00020     tag.remove( QRegExp("^\\w+:") );  // remove leading "UML:" or other
00021     int patSections = pattern.contains( '.' ) + 1;
00022     QString tagEnd = tag.section( '.', -patSections );
00023     return (tagEnd.lower() == pattern.lower());
00024 }
00025 
00026 QString Visibility::toString(Value value, bool mnemonic) {
00027     switch (value) {
00028     case Protected:
00029         return (mnemonic ? "#" : "protected");
00030         break;
00031     case Private:
00032         return (mnemonic ? "-" : "private");
00033         break;
00034     case Implementation:
00035         return (mnemonic ? "~" : "implementation");
00036         break;
00037     case Public:
00038     default:
00039         return (mnemonic ? "+" : "public");
00040         break;
00041     }
00042 }
00043 
00044 Visibility Visibility::fromString(const QString& vis) {
00045     if (vis == "public" || vis == "+")
00046         return Visibility(Public);
00047     else if (vis == "protected" || vis == "#")
00048         return Visibility(Protected);
00049     else if (vis == "private" || vis == "-")
00050         return Visibility(Private);
00051     else if (vis == "~")
00052         return Visibility(Implementation);
00053     else if (vis == "signals")
00054         return Visibility(Protected);
00055     else if (vis == "class")
00056         return Visibility(Private);
00057     else
00058         return Visibility(Public);
00059 }
00060 
00061 Visibility::Visibility(): _v(Public) {
00062 }
00063 
00064 Visibility::Visibility(Value v): _v(v) {
00065 }
00066 
00067 QString Visibility::toString(bool mnemonic) const {
00068     return toString(_v, mnemonic);
00069 }
00070 
00071 Visibility::operator Visibility::Value() const {
00072     return _v;
00073 }
00074 
00075 }  // end namespace Uml
00076 
KDE Logo
This file is part of the documentation for umbrello Version 3.1.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Jun 26 08:08:01 2007 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003