basictypes.cpp 34 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/***************************************************************************
 * Copyright (C) 2011 by Andi Fischer <andi.fischer@hispeed.ch>            *
 *                                                                         *
 * This is free software; you can redistribute it and/or modify            *
 * it under the terms of the GNU General Public License as published by    *
 * the Free Software Foundation; either version 2, or (at your option)     *
 * any later version.                                                      *
 *                                                                         *
 * This software is distributed in the hope that it will be useful,        *
 * but WITHOUT ANY WARRANTY; without even the implied warranty of          *
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           *
 * GNU General Public License for more details.                            *
 *                                                                         *
 * You should have received a copy of the GNU General Public License       *
 * along with this package; see the file COPYING.  If not, write to        *
 * the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,   *
 * Boston, MA 02110-1301, USA.                                             *
 ***************************************************************************/

#include "basictypes.h"

#include "debug_utils.h"

24
// kde includes
25
#include <KLocalizedString>
26
27
28
29
30
31
32
33
#if QT_VERSION < 0x050000
#include <KGlobalSettings>
#endif

// qt includes
#if QT_VERSION >= 0x050000
#include <QFontDatabase>
#endif
34
#include <QRegExp>
35
36
37
38

namespace Uml
{

Andi Fischer's avatar
Andi Fischer committed
39
40
41
42
namespace ModelType
{

/**
43
44
45
46
 * Convert ModelType item into QString representation.
 * @param item       item to convert
 * @return QString representation of ModelType
 */
Andi Fischer's avatar
Andi Fischer committed
47
QString toString(Enum item)
48
49
50
{
    switch (item) {
        case UseCase:
Oliver Kellogg's avatar
Oliver Kellogg committed
51
            return QString(QLatin1String("UseCase"));
52
        case Component:
Oliver Kellogg's avatar
Oliver Kellogg committed
53
            return QString(QLatin1String("Component"));
54
        case Deployment:
Oliver Kellogg's avatar
Oliver Kellogg committed
55
            return QString(QLatin1String("Deployment"));
56
        case EntityRelationship:
Oliver Kellogg's avatar
Oliver Kellogg committed
57
            return QString(QLatin1String("EntityRelationship"));
58
59
        case Logical:
        default:
Oliver Kellogg's avatar
Oliver Kellogg committed
60
            return QString(QLatin1String("Logical"));
61
62
63
64
65
66
67
68
    }
}

/**
 * Convert a string item into Model representation.
 * @param item   item to convert
 * @return Model object
 */
Andi Fischer's avatar
Andi Fischer committed
69
Enum fromString(const QString& item)
70
{
Oliver Kellogg's avatar
Oliver Kellogg committed
71
    if (item == QLatin1String("UseCase"))
Andi Fischer's avatar
Andi Fischer committed
72
        return UseCase;
Oliver Kellogg's avatar
Oliver Kellogg committed
73
    else if (item == QLatin1String("Component"))
Andi Fischer's avatar
Andi Fischer committed
74
        return Component;
Oliver Kellogg's avatar
Oliver Kellogg committed
75
    else if (item == QLatin1String("Deployment"))
Andi Fischer's avatar
Andi Fischer committed
76
        return Deployment;
Oliver Kellogg's avatar
Oliver Kellogg committed
77
    else if (item == QLatin1String("EntityRelationship"))
Andi Fischer's avatar
Andi Fischer committed
78
        return EntityRelationship;
79
    else
Andi Fischer's avatar
Andi Fischer committed
80
        return Logical;
81
82
83
}

/**
Andi Fischer's avatar
Andi Fischer committed
84
85
86
 * Convert a integer item into ModelType representation.
 * @param item   integer value to convert
 * @return ModelType enum
87
 */
Andi Fischer's avatar
Andi Fischer committed
88
Enum fromInt(int item)
89
{
Andi Fischer's avatar
Andi Fischer committed
90
    return Enum(item);
91
92
}

Andi Fischer's avatar
Andi Fischer committed
93
}  // end namespace ModelType
94
95
96

//-----------------------------------------------------------------------------

Andi Fischer's avatar
Andi Fischer committed
97
98
namespace Visibility {

99
100
101
102
103
104
105
106
/**
 * Convert Visibility item into QString representation.
 * @param item       item to convert
 * @param mnemonic   if true then return a single character:
 *              "+" for public, "-" for private,
 *              "#" for protected or "~" for implementation
 * @return QString representation of Visibility
 */
Andi Fischer's avatar
Andi Fischer committed
107
QString toString(Enum item, bool mnemonic)
108
109
110
{
    switch (item) {
        case Protected:
Oliver Kellogg's avatar
Oliver Kellogg committed
111
            return (mnemonic ? QLatin1String("#") : QLatin1String("protected"));
112
        case Private:
Oliver Kellogg's avatar
Oliver Kellogg committed
113
            return (mnemonic ? QLatin1String("-") : QLatin1String("private"));
114
        case Implementation:
Oliver Kellogg's avatar
Oliver Kellogg committed
115
            return (mnemonic ? QLatin1String("~") : QLatin1String("implementation"));
116
117
        case Public:
        default:
Oliver Kellogg's avatar
Oliver Kellogg committed
118
            return (mnemonic ? QLatin1String("+") : QLatin1String("public"));
119
120
121
122
123
124
    }
}

/**
 * Convert a string item into Visibility representation.
 * @param item   item to convert
Andi Fischer's avatar
Andi Fischer committed
125
 * @return Visibility enum
126
 */
127
Enum fromString(const QString& item, bool checkUnkown)
128
{
Oliver Kellogg's avatar
Oliver Kellogg committed
129
    if (item == QLatin1String("public") || item == QLatin1String("+"))
Andi Fischer's avatar
Andi Fischer committed
130
        return Public;
Oliver Kellogg's avatar
Oliver Kellogg committed
131
    else if (item == QLatin1String("protected") || item == QLatin1String("#"))
Andi Fischer's avatar
Andi Fischer committed
132
        return Protected;
Oliver Kellogg's avatar
Oliver Kellogg committed
133
    else if (item == QLatin1String("private") || item == QLatin1String("-"))
Andi Fischer's avatar
Andi Fischer committed
134
        return Private;
Oliver Kellogg's avatar
Oliver Kellogg committed
135
    else if (item == QLatin1String("~"))
Andi Fischer's avatar
Andi Fischer committed
136
        return Implementation;
Oliver Kellogg's avatar
Oliver Kellogg committed
137
    else if (item == QLatin1String("signals"))
Andi Fischer's avatar
Andi Fischer committed
138
        return Protected;
Oliver Kellogg's avatar
Oliver Kellogg committed
139
    else if (item == QLatin1String("class"))
Andi Fischer's avatar
Andi Fischer committed
140
        return Private;
141
142
    else if (checkUnkown)
        return Unknown;
143
    else
Andi Fischer's avatar
Andi Fischer committed
144
        return Public;
145
146
147
}

/**
Andi Fischer's avatar
Andi Fischer committed
148
149
150
 * Convert a integer item into Visibility representation.
 * @param item   integer value to convert
 * @return Visibility enum
151
 */
Andi Fischer's avatar
Andi Fischer committed
152
Enum fromInt(int item)
153
{
Andi Fischer's avatar
Andi Fischer committed
154
    return Enum(item);
155
156
}

Andi Fischer's avatar
Andi Fischer committed
157
}  // end namespace Visibility
158
159
160

//-----------------------------------------------------------------------------

Andi Fischer's avatar
Andi Fischer committed
161
162
namespace DiagramType {

163
164
/**
 * Convert DiagramType item into QString representation.
Andi Fischer's avatar
Andi Fischer committed
165
 * @param item   item to convert
166
167
 * @return QString representation of DiagramType
 */
Andi Fischer's avatar
Andi Fischer committed
168
QString toString(Enum item)
169
170
171
{
    switch (item) {
        case Undefined:
Oliver Kellogg's avatar
Oliver Kellogg committed
172
            return QLatin1String("Undefined");
173
        case Class:
Oliver Kellogg's avatar
Oliver Kellogg committed
174
            return QLatin1String("Class");
175
176
        case Object:
            return QLatin1String("Object");
177
        case UseCase:
Oliver Kellogg's avatar
Oliver Kellogg committed
178
            return QLatin1String("UseCase");
179
        case Sequence:
Oliver Kellogg's avatar
Oliver Kellogg committed
180
            return QLatin1String("Sequence");
181
        case Collaboration:
Oliver Kellogg's avatar
Oliver Kellogg committed
182
            return QLatin1String("Collaboration");
183
        case State:
Oliver Kellogg's avatar
Oliver Kellogg committed
184
            return QLatin1String("State");
185
        case Activity:
Oliver Kellogg's avatar
Oliver Kellogg committed
186
            return QLatin1String("Activity");
187
        case Component:
Oliver Kellogg's avatar
Oliver Kellogg committed
188
            return QLatin1String("Component");
189
        case Deployment:
Oliver Kellogg's avatar
Oliver Kellogg committed
190
            return QLatin1String("Deployment");
191
        case EntityRelationship:
Oliver Kellogg's avatar
Oliver Kellogg committed
192
            return QLatin1String("EntityRelationship");
193
        case N_DIAGRAMTYPES:   // must remain last
Oliver Kellogg's avatar
Oliver Kellogg committed
194
            return QLatin1String("N_DIAGRAMTYPES");
195
        default:
Oliver Kellogg's avatar
Oliver Kellogg committed
196
            return QLatin1String("? DiagramType ?");
197
198
199
200
201
202
    }
}

/**
 * Return string corresponding to DiagramType
 */
Andi Fischer's avatar
Andi Fischer committed
203
QString toStringI18n(Enum item)
204
{
Andi Fischer's avatar
Andi Fischer committed
205
    switch (item) {
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
       case Class:
           return i18n("Class Diagram");
       case UseCase:
           return i18n("Use Case Diagram");
       case Sequence:
           return i18n("Sequence Diagram");
       case Collaboration:
           return i18n("Collaboration Diagram");
       case State:
           return i18n("State Diagram");
       case Activity:
           return i18n("Activity Diagram");
       case Component:
           return i18n("Component Diagram");
       case Deployment:
           return i18n("Deployment Diagram");
       case EntityRelationship:
           return i18n("Entity Relationship Diagram");
224
225
        case Object:
            return i18n("Object Diagram");
226
227
228
229
230
231
232
233
234
235
       default:
           return i18n("No Diagram");
    }
}

/**
 * Convert a string item into DiagramType representation.
 * @param item   item to convert
 * @return DiagramType object
 */
Andi Fischer's avatar
Andi Fischer committed
236
Enum fromString(const QString& item)
237
{
Oliver Kellogg's avatar
Oliver Kellogg committed
238
    if (item == QLatin1String("Undefined"))
239
        return Undefined;
Oliver Kellogg's avatar
Oliver Kellogg committed
240
    else if (item == QLatin1String("Class"))
241
        return Class;
Oliver Kellogg's avatar
Oliver Kellogg committed
242
    else if (item == QLatin1String("UseCase"))
243
        return UseCase;
Oliver Kellogg's avatar
Oliver Kellogg committed
244
    else if (item == QLatin1String("Sequence"))
245
        return Sequence;
Oliver Kellogg's avatar
Oliver Kellogg committed
246
    else if (item == QLatin1String("Collaboration"))
247
        return Collaboration;
Oliver Kellogg's avatar
Oliver Kellogg committed
248
    else if (item == QLatin1String("State"))
249
        return State;
Oliver Kellogg's avatar
Oliver Kellogg committed
250
    else if (item == QLatin1String("Activity"))
251
        return Activity;
Oliver Kellogg's avatar
Oliver Kellogg committed
252
    else if (item == QLatin1String("Component"))
253
        return Component;
Oliver Kellogg's avatar
Oliver Kellogg committed
254
    else if (item == QLatin1String("Deployment"))
255
        return Deployment;
Oliver Kellogg's avatar
Oliver Kellogg committed
256
    else if (item == QLatin1String("EntityRelationship"))
257
258
259
260
261
262
        return EntityRelationship;
    else
        return Undefined;
}

/**
Andi Fischer's avatar
Andi Fischer committed
263
264
265
 * Convert an integer item into DiagramType representation.
 * @param item   integer value to convert
 * @return DiagramType enum
266
 */
Andi Fischer's avatar
Andi Fischer committed
267
Enum fromInt(int item)
268
{
Andi Fischer's avatar
Andi Fischer committed
269
    return Enum(item);
270
271
}

Andi Fischer's avatar
Andi Fischer committed
272
}  // end namespace DiagramType
273
274
275

//-----------------------------------------------------------------------------

276
277
namespace AssociationType {

278
279
280
281
282
/**
 * Convert AssociationType item into QString representation.
 * @param item   item to convert
 * @return QString representation of AssociationType
 */
283
QString toString(Enum item)
284
285
286
{
    switch (item) {
        case Generalization:
Oliver Kellogg's avatar
Oliver Kellogg committed
287
            return QLatin1String("Generalization");
288
        case Aggregation:
Oliver Kellogg's avatar
Oliver Kellogg committed
289
            return QLatin1String("Aggregation");
290
        case Dependency:
Oliver Kellogg's avatar
Oliver Kellogg committed
291
            return QLatin1String("Dependency");
292
        case Association:
Oliver Kellogg's avatar
Oliver Kellogg committed
293
            return QLatin1String("Association");
294
        case Association_Self:
Oliver Kellogg's avatar
Oliver Kellogg committed
295
            return QLatin1String("Association_Self");
296
        case Coll_Message_Asynchronous:
Oliver Kellogg's avatar
Oliver Kellogg committed
297
            return QLatin1String("Coll_Message_Asynchronous");
Ralf Habacker's avatar
Ralf Habacker committed
298
        case Coll_Message_Synchronous:
Oliver Kellogg's avatar
Oliver Kellogg committed
299
            return QLatin1String("Coll_Message_Synchronous");
300
        case Seq_Message:
Oliver Kellogg's avatar
Oliver Kellogg committed
301
            return QLatin1String("Seq_Message");
302
        case Coll_Message_Self:
Oliver Kellogg's avatar
Oliver Kellogg committed
303
            return QLatin1String("Coll_Message_Self");
304
        case Seq_Message_Self:
Oliver Kellogg's avatar
Oliver Kellogg committed
305
            return QLatin1String("Seq_Message_Self");
306
        case Containment:
Oliver Kellogg's avatar
Oliver Kellogg committed
307
            return QLatin1String("Containment");
308
        case Composition:
Oliver Kellogg's avatar
Oliver Kellogg committed
309
          return QLatin1String("Composition");
310
        case Realization:
Oliver Kellogg's avatar
Oliver Kellogg committed
311
          return QLatin1String("Realization");
312
        case UniAssociation:
Oliver Kellogg's avatar
Oliver Kellogg committed
313
          return QLatin1String("UniAssociation");
314
        case Anchor:
Oliver Kellogg's avatar
Oliver Kellogg committed
315
          return QLatin1String("Anchor");
316
        case State:
Oliver Kellogg's avatar
Oliver Kellogg committed
317
          return QLatin1String("State");
318
        case Activity:
Oliver Kellogg's avatar
Oliver Kellogg committed
319
          return QLatin1String("Activity");
320
        case Exception:
Oliver Kellogg's avatar
Oliver Kellogg committed
321
          return QLatin1String("Exception");
322
        case Category2Parent:
Oliver Kellogg's avatar
Oliver Kellogg committed
323
          return QLatin1String("Category2Parent");
324
        case Child2Category:
Oliver Kellogg's avatar
Oliver Kellogg committed
325
          return QLatin1String("Child2Category");
326
        case Relationship:
Oliver Kellogg's avatar
Oliver Kellogg committed
327
          return QLatin1String("Relationship");
328
        case Unknown:
Oliver Kellogg's avatar
Oliver Kellogg committed
329
            return QLatin1String("Unknown");
330
        default:
Oliver Kellogg's avatar
Oliver Kellogg committed
331
            return QLatin1String("? AssociationType ?");
332
333
334
335
336
337
338
    }
}

/**
 * Converts a AssociationType to its string representation.
 * @return  the string representation of the AssociationType
 */
339
QString toStringI18n(Enum item)
340
{
341
    switch (item) {
342
343
344
345
346
347
348
349
350
351
          case Generalization:
              return i18n("Generalization");
          case Aggregation:
              return i18n("Aggregation");
          case Dependency:
              return i18n("Dependency");
          case Association:
              return i18n("Association");
          case Association_Self:
              return i18n("Self Association");
352
          case Coll_Message_Asynchronous:
353
354
355
              return i18n("Collaboration Asynchronous Message");
          case Coll_Message_Synchronous:
              return i18n("Collaboration Synchronous Message");
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
          case Seq_Message:
              return i18n("Sequence Message");
          case Coll_Message_Self:
              return i18n("Collaboration Self Message");
          case Seq_Message_Self:
              return i18n("Sequence Self Message");
          case Containment:
              return i18n("Containment");
          case Composition:
              return i18n("Composition");
          case Realization:
              return i18n("Realization");
          case UniAssociation:
              return i18n("Uni Association");
          case Anchor:
              return i18n("Anchor");
          case State:
              return i18n("State Transition");
          case Activity:
              return i18n("Activity");
          case Exception:
              return i18n("Exception");
          case Category2Parent:
              return i18n("Category to Parent");
          case Child2Category:
              return i18n("Child to Category");
          case Relationship:
              return i18n("Relationship");
          case Unknown:
              return i18n("Unknown");
          default:
              return i18n("? AssociationType ?");
388
389
390
391
392
393
394
395
      };
}

/**
 * Convert a string item into AssociationType representation.
 * @param item   item to convert
 * @return AssociationType object
 */
396
Enum fromString(const QString& item)
397
{
Oliver Kellogg's avatar
Oliver Kellogg committed
398
    if (item == QLatin1String("Generalization"))
399
        return Generalization;
Oliver Kellogg's avatar
Oliver Kellogg committed
400
    else if (item == QLatin1String("Aggregation"))
401
        return Aggregation;
Oliver Kellogg's avatar
Oliver Kellogg committed
402
    else if (item == QLatin1String("Dependency"))
403
        return Dependency;
Oliver Kellogg's avatar
Oliver Kellogg committed
404
    else if (item == QLatin1String("Association"))
405
        return Association;
Oliver Kellogg's avatar
Oliver Kellogg committed
406
    else if (item == QLatin1String("Association_Self"))
407
        return Association_Self;
Oliver Kellogg's avatar
Oliver Kellogg committed
408
    else if (item == QLatin1String("Coll_Message_Asynchronous"))
409
        return Coll_Message_Asynchronous;
Oliver Kellogg's avatar
Oliver Kellogg committed
410
    else if (item == QLatin1String("Coll_Message_Synchronous"))
Ralf Habacker's avatar
Ralf Habacker committed
411
        return Coll_Message_Synchronous;
Oliver Kellogg's avatar
Oliver Kellogg committed
412
    else if (item == QLatin1String("Seq_Message"))
413
        return Seq_Message;
Oliver Kellogg's avatar
Oliver Kellogg committed
414
    else if (item == QLatin1String("Coll_Message_Self"))
415
        return Coll_Message_Self;
Oliver Kellogg's avatar
Oliver Kellogg committed
416
    else if (item == QLatin1String("Seq_Message_Self"))
417
        return Seq_Message_Self;
Oliver Kellogg's avatar
Oliver Kellogg committed
418
    else if (item == QLatin1String("Containment"))
419
        return Containment;
Oliver Kellogg's avatar
Oliver Kellogg committed
420
    else if (item == QLatin1String("Composition"))
421
        return Composition;
Oliver Kellogg's avatar
Oliver Kellogg committed
422
    else if (item == QLatin1String("Realization"))
423
        return Realization;
Oliver Kellogg's avatar
Oliver Kellogg committed
424
    else if (item == QLatin1String("UniAssociation"))
425
        return UniAssociation;
Oliver Kellogg's avatar
Oliver Kellogg committed
426
    else if (item == QLatin1String("Anchor"))
427
        return Anchor;
Oliver Kellogg's avatar
Oliver Kellogg committed
428
    else if (item == QLatin1String("State"))
429
        return State;
Oliver Kellogg's avatar
Oliver Kellogg committed
430
    else if (item == QLatin1String("Activity"))
431
        return Activity;
Oliver Kellogg's avatar
Oliver Kellogg committed
432
    else if (item == QLatin1String("Exception"))
433
        return Exception;
Oliver Kellogg's avatar
Oliver Kellogg committed
434
    else if (item == QLatin1String("Category2Parent"))
435
        return Category2Parent;
Oliver Kellogg's avatar
Oliver Kellogg committed
436
    else if (item == QLatin1String("Child2Category"))
437
        return Child2Category;
Oliver Kellogg's avatar
Oliver Kellogg committed
438
    else if (item == QLatin1String("Relationship"))
439
440
441
442
443
        return Relationship;
    else
        return Unknown;
}

444
445
446
447
448
/**
 * Convert a integer item into ProgrammingLanguage representation.
 * @param item   integer value to convert
 * @return AssociationType enum
 */
449
Enum fromInt(int item)
450
{
451
    return Enum(item);
452
453
454
455
456
457
458
459
}

/**
 * Returns true if the given AssociationType has a representation as a
 * UMLAssociation.
 * @param item   the AssociationType enum value to check
 * @return  boolean value
 */
460
bool hasUMLRepresentation(Enum item)
461
462
463
464
465
466
467
468
469
470
471
472
473
474
{
    return (item == Generalization   ||
            item == Realization      ||
            item == Association      ||
            item == Association_Self ||
            item == UniAssociation   ||
            item == Aggregation      ||
            item == Relationship     ||
            item == Composition      ||
            item == Dependency       ||
            item == Category2Parent  ||
            item == Child2Category);
}

475
476
}  // end namespace AssociationType

477
478
//-----------------------------------------------------------------------------

479
480
namespace SignatureType {

481
482
483
/**
 * Return string corresponding to the given SignatureType.
 */
484
QString toString(Enum item)
485
486
487
{
    switch (item) {
        case NoSig:
Oliver Kellogg's avatar
Oliver Kellogg committed
488
            return QLatin1String("NoSig");
489
        case ShowSig:
Oliver Kellogg's avatar
Oliver Kellogg committed
490
            return QLatin1String("ShowSig");
491
        case SigNoVis:
Oliver Kellogg's avatar
Oliver Kellogg committed
492
            return QLatin1String("SigNoVis");
493
        case NoSigNoVis:
Oliver Kellogg's avatar
Oliver Kellogg committed
494
            return QLatin1String("NoSigNoVis");
495
496
497
498
499
500
501
502
503
        default:
            break;
    }
    return QString();
}

/**
 * Return SignatureType corresponding to the given string.
 */
504
Enum fromString(const QString& item)
505
{
Oliver Kellogg's avatar
Oliver Kellogg committed
506
    if (item == QLatin1String("NoSig"))
507
        return NoSig;
Oliver Kellogg's avatar
Oliver Kellogg committed
508
    if (item == QLatin1String("ShowSig"))
509
        return ShowSig;
Oliver Kellogg's avatar
Oliver Kellogg committed
510
    if (item == QLatin1String("SigNoVis"))
511
        return SigNoVis;
Oliver Kellogg's avatar
Oliver Kellogg committed
512
    if (item == QLatin1String("NoSigNoVis"))
513
514
        return NoSigNoVis;
    return NoSig;
515
516
517
}

/**
518
519
 * Convert a integer item into SignatureType representation.
 * @param item   integer value to convert
520
 * @return SignatureType enum
521
 */
522
Enum fromInt(int item)
523
{
524
    return Enum(item);
525
526
}

527
}  // end namespace SignatureType
528
529
530

//-----------------------------------------------------------------------------

531
532
namespace TextRole {

533
534
535
/**
 * Return string corresponding to the given TextRole.
 */
536
QString toString(Enum item)
537
538
539
{
    switch (item) {
        case Floating:
Oliver Kellogg's avatar
Oliver Kellogg committed
540
            return QLatin1String("Floating");
541
        case MultiA:
Oliver Kellogg's avatar
Oliver Kellogg committed
542
            return QLatin1String("MultiA");
543
        case MultiB:
Oliver Kellogg's avatar
Oliver Kellogg committed
544
            return QLatin1String("MultiB");
545
        case Name:
Oliver Kellogg's avatar
Oliver Kellogg committed
546
            return QLatin1String("Name");
547
        case Seq_Message:
Oliver Kellogg's avatar
Oliver Kellogg committed
548
            return QLatin1String("Seq_Message");
549
        case Seq_Message_Self:
Oliver Kellogg's avatar
Oliver Kellogg committed
550
            return QLatin1String("Seq_Message_Self");
551
        case Coll_Message:
Oliver Kellogg's avatar
Oliver Kellogg committed
552
            return QLatin1String("Coll_Message");
553
        case Coll_Message_Self:
Oliver Kellogg's avatar
Oliver Kellogg committed
554
            return QLatin1String("Coll_Message_Self");
555
        case State:
Oliver Kellogg's avatar
Oliver Kellogg committed
556
            return QLatin1String("State");
557
        case RoleAName:
Oliver Kellogg's avatar
Oliver Kellogg committed
558
            return QLatin1String("RoleAName");
559
        case RoleBName:
Oliver Kellogg's avatar
Oliver Kellogg committed
560
            return QLatin1String("RoleBName");
561
        case ChangeA:
Oliver Kellogg's avatar
Oliver Kellogg committed
562
            return QLatin1String("ChangeA");
563
        case ChangeB:
Oliver Kellogg's avatar
Oliver Kellogg committed
564
            return QLatin1String("ChangeB");
565
566
567
        default:
            break;
    }
Oliver Kellogg's avatar
Oliver Kellogg committed
568
    return QLatin1String("? TextRole ?");
569
570
571
572
573
}

/**
 * Return TextRole corresponding to the given string.
 */
574
Enum fromString(const QString& item)
575
{
Oliver Kellogg's avatar
Oliver Kellogg committed
576
    if (item == QLatin1String("Floating"))
577
        return Floating;
Oliver Kellogg's avatar
Oliver Kellogg committed
578
    if (item == QLatin1String("MultiA"))
579
        return MultiA;
Oliver Kellogg's avatar
Oliver Kellogg committed
580
    if (item == QLatin1String("MultiB"))
581
        return MultiB;
Oliver Kellogg's avatar
Oliver Kellogg committed
582
    if (item == QLatin1String("Name"))
583
        return Name;
Oliver Kellogg's avatar
Oliver Kellogg committed
584
    if (item == QLatin1String("Seq_Message"))
585
        return Seq_Message;
Oliver Kellogg's avatar
Oliver Kellogg committed
586
    if (item == QLatin1String("Seq_Message_Self"))
587
        return Seq_Message_Self;
Oliver Kellogg's avatar
Oliver Kellogg committed
588
    if (item == QLatin1String("Coll_Message"))
589
        return Coll_Message;
Oliver Kellogg's avatar
Oliver Kellogg committed
590
    if (item == QLatin1String("Coll_Message_Self"))
591
        return Coll_Message_Self;
Oliver Kellogg's avatar
Oliver Kellogg committed
592
    if (item == QLatin1String("State"))
593
        return State;
Oliver Kellogg's avatar
Oliver Kellogg committed
594
    if (item == QLatin1String("RoleAName"))
595
        return RoleAName;
Oliver Kellogg's avatar
Oliver Kellogg committed
596
    if (item == QLatin1String("RoleBName"))
597
        return RoleBName;
Oliver Kellogg's avatar
Oliver Kellogg committed
598
    if (item == QLatin1String("ChangeA"))
599
        return ChangeA;
Oliver Kellogg's avatar
Oliver Kellogg committed
600
    if (item == QLatin1String("ChangeB"))
601
602
        return ChangeB;
    return Floating;
603
604
605
}

/**
606
607
608
 * Convert a integer item into TextRole representation.
 * @param item   integer value to convert
 * @return TextRole enum
609
 */
610
Enum fromInt(int item)
611
{
612
    return Enum(item);
613
614
}

615
}  // end namespace TextRole
616
617
618

//-----------------------------------------------------------------------------

619
620
namespace Changeability {

621
/**
622
 * Convert Changeability::Enum value into QString representation.
623
 * @param item   The Changeability enum value to convert.
624
 */
625
QString toString(Enum item)
626
627
628
{
    switch (item) {
        case Changeability::Frozen:
Oliver Kellogg's avatar
Oliver Kellogg committed
629
            return QLatin1String("frozen");
630
        case Changeability::AddOnly:
Oliver Kellogg's avatar
Oliver Kellogg committed
631
            return QLatin1String("addOnly");
632
        case Changeability::Changeable:
Oliver Kellogg's avatar
Oliver Kellogg committed
633
            return QLatin1String("changeable");
634
635
636
        default:
            break;
    }
Oliver Kellogg's avatar
Oliver Kellogg committed
637
    return QLatin1String("? Changeability ?");
638
639
640
}

/**
641
 * Return Changeability::Enum corresponding to the given string.
642
 */
643
Enum fromString(const QString& item)
644
{
Oliver Kellogg's avatar
Oliver Kellogg committed
645
    if (item == QLatin1String("frozen"))
646
        return Frozen;
Oliver Kellogg's avatar
Oliver Kellogg committed
647
    if (item == QLatin1String("addOnly"))
648
        return AddOnly;
Oliver Kellogg's avatar
Oliver Kellogg committed
649
    if (item == QLatin1String("changeable"))
650
651
        return Changeable;
    return Changeable;
652
653
654
}

/**
655
656
657
 * Convert a integer item into Changeability representation.
 * @param item   integer value to convert
 * @return Changeability enum
658
 */
659
Enum fromInt(int item)
660
{
661
    return Enum(item);
662
663
}

664
}  // end namespace Changeability
665
666
667

//-----------------------------------------------------------------------------

668
669
670
671
672
673
674
675
676
namespace SequenceMessage {

/**
 * Return string corresponding to the given SequenceMessage.
 */
QString toString(Enum item)
{
    switch (item) {
        case Synchronous:
Oliver Kellogg's avatar
Oliver Kellogg committed
677
            return QLatin1String("Synchronous");
678
        case Asynchronous:
Oliver Kellogg's avatar
Oliver Kellogg committed
679
            return QLatin1String("Asynchronous");
680
        case Creation:
Oliver Kellogg's avatar
Oliver Kellogg committed
681
            return QLatin1String("Creation");
682
        case Lost:
Oliver Kellogg's avatar
Oliver Kellogg committed
683
            return QLatin1String("Lost");
684
        case Found:
Oliver Kellogg's avatar
Oliver Kellogg committed
685
            return QLatin1String("Found");
686
687
688
        default:
            break;
    }
Oliver Kellogg's avatar
Oliver Kellogg committed
689
    return QLatin1String("? SequenceMessage ?");
690
691
692
693
694
695
696
}

/**
 * Return SequenceMessage corresponding to the given string.
 */
Enum fromString(const QString& item)
{
Oliver Kellogg's avatar
Oliver Kellogg committed
697
    if (item == QLatin1String("Synchronous"))
698
        return Synchronous;
Oliver Kellogg's avatar
Oliver Kellogg committed
699
    if (item == QLatin1String("Asynchronous"))
700
        return Asynchronous;
Oliver Kellogg's avatar
Oliver Kellogg committed
701
    if (item == QLatin1String("Creation"))
702
        return Creation;
Oliver Kellogg's avatar
Oliver Kellogg committed
703
    if (item == QLatin1String("Lost"))
704
        return Lost;
Oliver Kellogg's avatar
Oliver Kellogg committed
705
    if (item == QLatin1String("Found"))
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
        return Found;
    return Synchronous;
}

/**
 * Convert a integer item into SequenceMessage representation.
 * @param item   integer value to convert
 * @return SequenceMessage enum
 */
Enum fromInt(int item)
{
    return Enum(item);
}

}  // end namespace SequenceMessage

//-----------------------------------------------------------------------------

724
725
726
727
728
729
730
731
732
namespace RoleType {

/**
 * Return string corresponding to the given RoleType.
 */
QString toString(Enum item)
{
    switch (item) {
        case A:
Oliver Kellogg's avatar
Oliver Kellogg committed
733
            return QLatin1String("A");
734
        case B:
Oliver Kellogg's avatar
Oliver Kellogg committed
735
            return QLatin1String("B");
736
737
738
        default:
            break;
    }
Oliver Kellogg's avatar
Oliver Kellogg committed
739
    return QLatin1String("? RoleType ?");
740
741
742
743
744
745
746
}

/**
 * Return RoleType corresponding to the given string.
 */
Enum fromString(const QString& item)
{
Oliver Kellogg's avatar
Oliver Kellogg committed
747
    if (item == QLatin1String("A"))
748
        return A;
Oliver Kellogg's avatar
Oliver Kellogg committed
749
    if (item == QLatin1String("B"))
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
        return B;
    return A;
}

/**
 * Convert a integer item into RoleType representation.
 * @param item   integer value to convert
 * @return RoleType enum
 */
Enum fromInt(int item)
{
    return Enum(item);
}

}  // end namespace RoleType

//-----------------------------------------------------------------------------

768
769
770
771
772
773
774
775
776
namespace ParameterDirection {

/**
 * Return string corresponding to the given ParameterDirection.
 */
QString toString(Enum item)
{
    switch (item) {
        case In:
Oliver Kellogg's avatar
Oliver Kellogg committed
777
            return QLatin1String("In");
778
        case InOut:
Oliver Kellogg's avatar
Oliver Kellogg committed
779
            return QLatin1String("InOut");
780
        case Out:
Oliver Kellogg's avatar
Oliver Kellogg committed
781
            return QLatin1String("Out");
782
783
784
        default:
            break;
    }
Oliver Kellogg's avatar
Oliver Kellogg committed
785
    return QLatin1String("? ParameterDirection ?");
786
787
788
789
790
791
792
}

/**
 * Return ParameterDirection corresponding to the given string.
 */
Enum fromString(const QString& item)
{
Oliver Kellogg's avatar
Oliver Kellogg committed
793
    if (item == QLatin1String("In"))
794
        return In;
Oliver Kellogg's avatar
Oliver Kellogg committed
795
    if (item == QLatin1String("InOut"))
796
        return InOut;
Oliver Kellogg's avatar
Oliver Kellogg committed
797
    if (item == QLatin1String("Out"))
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
        return Out;
    return In;
}

/**
 * Convert a integer item into ParameterDirection representation.
 * @param item   integer value to convert
 * @return ParameterDirection enum
 */
Enum fromInt(int item)
{
    return Enum(item);
}

}  // end namespace ParameterDirection

//-----------------------------------------------------------------------------

816
817
818
819
820
821
822
823
824
namespace ProgrammingLanguage {

/**
 * Return string corresponding to the given ProgrammingLanguage.
 */
QString toString(Enum item)
{
    switch (item) {
        case ActionScript:
Oliver Kellogg's avatar
Oliver Kellogg committed
825
            return QLatin1String("ActionScript");
826
        case Ada:
Oliver Kellogg's avatar
Oliver Kellogg committed
827
            return QLatin1String("Ada");
828
        case Cpp:
Oliver Kellogg's avatar
Oliver Kellogg committed
829
            return QLatin1String("C++");
830
        case CSharp:
Oliver Kellogg's avatar
Oliver Kellogg committed
831
            return QLatin1String("C#");
832
        case D:
Oliver Kellogg's avatar
Oliver Kellogg committed
833
            return QLatin1String("D");
834
        case IDL:
Oliver Kellogg's avatar
Oliver Kellogg committed
835
            return QLatin1String("IDL");
836
        case Java:
Oliver Kellogg's avatar
Oliver Kellogg committed
837
            return QLatin1String("Java");
838
        case JavaScript:
Oliver Kellogg's avatar
Oliver Kellogg committed
839
            return QLatin1String("JavaScript");
840
        case MySQL:
Oliver Kellogg's avatar
Oliver Kellogg committed
841
            return QLatin1String("MySQL");
842
        case Pascal:
Oliver Kellogg's avatar
Oliver Kellogg committed
843
            return QLatin1String("Pascal");
844
        case Perl:
Oliver Kellogg's avatar
Oliver Kellogg committed
845
            return QLatin1String("Perl");
846
        case PHP:
Oliver Kellogg's avatar
Oliver Kellogg committed
847
            return QLatin1String("PHP");
848
        case PHP5:
Oliver Kellogg's avatar
Oliver Kellogg committed
849
            return QLatin1String("PHP5");
850
        case PostgreSQL:
Oliver Kellogg's avatar
Oliver Kellogg committed
851
            return QLatin1String("PostgreSQL");
852
        case Python:
Oliver Kellogg's avatar
Oliver Kellogg committed
853
            return QLatin1String("Python");
854
        case Ruby:
Oliver Kellogg's avatar
Oliver Kellogg committed
855
            return QLatin1String("Ruby");
856
        case SQL:
Oliver Kellogg's avatar
Oliver Kellogg committed
857
            return QLatin1String("SQL");
858
        case Tcl:
Oliver Kellogg's avatar
Oliver Kellogg committed
859
            return QLatin1String("Tcl");
860
        case Vala:
Oliver Kellogg's avatar
Oliver Kellogg committed
861
            return QLatin1String("Vala");
862
        case XMLSchema:
Oliver Kellogg's avatar
Oliver Kellogg committed
863
            return QLatin1String("XMLSchema");
864
865
866
867
868
869
870
871
872
873
874
        default:
            break;
    }
    return QString();
}

/**
 * Return ProgrammingLanguage corresponding to the given string.
 */
Enum fromString(const QString& item)
{
Oliver Kellogg's avatar
Oliver Kellogg committed
875
    if (item == QLatin1String("ActionScript"))
876
        return ActionScript;
Oliver Kellogg's avatar
Oliver Kellogg committed
877
    if (item == QLatin1String("Ada"))
878
        return Ada;
Oliver Kellogg's avatar
Oliver Kellogg committed
879
    if (item == QLatin1String("C++") || item == QLatin1String("Cpp"))  // "Cpp" only for bkwd compatibility
880
        return Cpp;
Oliver Kellogg's avatar
Oliver Kellogg committed
881
    if (item == QLatin1String("C#"))