Crazy Eddie's GUI System  0.8.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
XMLEnumHelper.h
1 /***********************************************************************
2  filename: CEGUIXMLEnumHelper.h
3  created: Mon Jul 18 2005
4  author: Paul D Turner <paul@cegui.org.uk>
5 *************************************************************************/
6 /***************************************************************************
7  * Copyright (C) 2004 - 2012 Paul D Turner & The CEGUI Development Team
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining
10  * a copy of this software and associated documentation files (the
11  * "Software"), to deal in the Software without restriction, including
12  * without limitation the rights to use, copy, modify, merge, publish,
13  * distribute, sublicense, and/or sell copies of the Software, and to
14  * permit persons to whom the Software is furnished to do so, subject to
15  * the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be
18  * included in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
23  * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26  * OTHER DEALINGS IN THE SOFTWARE.
27  ***************************************************************************/
28 #ifndef _CEGUIFalXMLEnumHelper_h_
29 #define _CEGUIFalXMLEnumHelper_h_
30 
31 #include "../String.h"
32 #include "../Window.h"
33 #include "CEGUI/falagard/Enums.h"
34 
35 namespace CEGUI
36 {
37 template<typename T>
39 
40 template<>
42 {
43 public:
46 
47  static String toString(pass_type val)
48  {
49  switch (val)
50  {
51  case VF_BOTTOM_ALIGNED:
52  return String("BottomAligned");
53 
54  case VF_CENTRE_ALIGNED:
55  return String("CentreAligned");
56 
57  case VF_TILED:
58  return String("Tiled");
59 
60  case VF_STRETCHED:
61  return String("Stretched");
62 
63  default:
64  return String("TopAligned");
65  }
66  }
67 
68  static return_type fromString(const String& str)
69  {
70  if (str == "CentreAligned")
71  return VF_CENTRE_ALIGNED;
72 
73  else if (str == "BottomAligned")
74  return VF_BOTTOM_ALIGNED;
75 
76  else if (str == "Tiled")
77  return VF_TILED;
78 
79  else if (str == "Stretched")
80  return VF_STRETCHED;
81 
82  else
83  return VF_TOP_ALIGNED;
84  }
85 };
86 
87 template<>
89 {
90 public:
93 
94  static String toString(pass_type val)
95  {
96  switch (val)
97  {
98  case HF_RIGHT_ALIGNED:
99  return String("RightAligned");
100 
101  case HF_CENTRE_ALIGNED:
102  return String("CentreAligned");
103 
104  case HF_TILED:
105  return String("Tiled");
106 
107  case HF_STRETCHED:
108  return String("Stretched");
109 
110  default:
111  return String("LeftAligned");
112  }
113  }
114 
115  static return_type fromString(const String& str)
116  {
117  if (str == "CentreAligned")
118  return HF_CENTRE_ALIGNED;
119 
120  else if (str == "RightAligned")
121  return HF_RIGHT_ALIGNED;
122 
123  else if (str == "Tiled")
124  return HF_TILED;
125 
126  else if (str == "Stretched")
127  return HF_STRETCHED;
128 
129  else
130  return HF_LEFT_ALIGNED;
131  }
132 };
133 
134 template<>
136 {
137 public:
140 
141  static String toString(pass_type val)
142  {
143  switch (val)
144  {
145  case VA_BOTTOM:
146  return String("BottomAligned");
147 
148  case VA_CENTRE:
149  return String("CentreAligned");
150 
151  default:
152  return String("TopAligned");
153  }
154  }
155 
156  static return_type fromString(const String& str)
157  {
158  if (str == "CentreAligned")
159  return VA_CENTRE;
160 
161  else if (str == "BottomAligned")
162  return VA_BOTTOM;
163 
164  else
165  return VA_TOP;
166  }
167 };
168 
169 template<>
171 {
172 public:
175 
176  static String toString(pass_type val)
177  {
178  switch (val)
179  {
180  case HA_RIGHT:
181  return String("RightAligned");
182 
183  case HA_CENTRE:
184  return String("CentreAligned");
185 
186  default:
187  return String("LeftAligned");
188  }
189  }
190 
191  static return_type fromString(const String& str)
192  {
193  if (str == "CentreAligned")
194  return HA_CENTRE;
195 
196  else if (str == "RightAligned")
197  return HA_RIGHT;
198 
199  else
200  return HA_LEFT;
201  }
202 };
203 
204 template<>
206 {
207 public:
208  typedef DimensionType return_type;
209  typedef DimensionType pass_type;
210 
211  static String toString(pass_type val)
212  {
213  switch (val)
214  {
215  case DT_LEFT_EDGE:
216  return String("LeftEdge");
217 
218  case DT_X_POSITION:
219  return String("XPosition");
220 
221  case DT_TOP_EDGE:
222  return String("TopEdge");
223 
224  case DT_Y_POSITION:
225  return String("YPosition");
226 
227  case DT_RIGHT_EDGE:
228  return String("RightEdge");
229 
230  case DT_BOTTOM_EDGE:
231  return String("BottomEdge");
232 
233  case DT_WIDTH:
234  return String("Width");
235 
236  case DT_HEIGHT:
237  return String("Height");
238 
239  case DT_X_OFFSET:
240  return String("XOffset");
241 
242  case DT_Y_OFFSET:
243  return String("YOffset");
244 
245  default:
246  return String("Invalid");
247  }
248  }
249 
250  static return_type fromString(const String& str)
251  {
252  if (str == "LeftEdge")
253  return DT_LEFT_EDGE;
254 
255  else if (str == "XPosition")
256  return DT_X_POSITION;
257 
258  else if (str == "TopEdge")
259  return DT_TOP_EDGE;
260 
261  else if (str == "YPosition")
262  return DT_Y_POSITION;
263 
264  else if (str == "RightEdge")
265  return DT_RIGHT_EDGE;
266 
267  else if (str == "BottomEdge")
268  return DT_BOTTOM_EDGE;
269 
270  else if (str == "Width")
271  return DT_WIDTH;
272 
273  else if (str == "Height")
274  return DT_HEIGHT;
275 
276  else if (str == "XOffset")
277  return DT_X_OFFSET;
278 
279  else if (str == "YOffset")
280  return DT_Y_OFFSET;
281 
282  else
283  return DT_INVALID;
284  }
285 };
286 
287 template<>
289 {
290 public:
293 
294  static String toString(pass_type val)
295  {
296  switch (val)
297  {
298  case VTF_BOTTOM_ALIGNED:
299  return String("BottomAligned");
300 
301  case VTF_CENTRE_ALIGNED:
302  return String("CentreAligned");
303 
304  default:
305  return String("TopAligned");
306  }
307  }
308 
309  static return_type fromString(const String& str)
310  {
311  if (str == "CentreAligned")
312  return VTF_CENTRE_ALIGNED;
313 
314  else if (str == "BottomAligned")
315  return VTF_BOTTOM_ALIGNED;
316 
317  else
318  return VTF_TOP_ALIGNED;
319  }
320 };
321 
322 template<>
324 {
325 public:
328 
329  static String toString(pass_type val)
330  {
331  switch (val)
332  {
333  case HTF_RIGHT_ALIGNED:
334  return String("RightAligned");
335 
336  case HTF_CENTRE_ALIGNED:
337  return String("CentreAligned");
338 
339  case HTF_JUSTIFIED:
340  return String("Justified");
341 
343  return String("WordWrapLeftAligned");
344 
346  return String("WordWrapRightAligned");
347 
349  return String("WordWrapCentreAligned");
350 
352  return String("WordWrapJustified");
353 
354  default:
355  return String("LeftAligned");
356  }
357  }
358 
359  static return_type fromString(const String& str)
360  {
361  if (str == "CentreAligned")
362  return HTF_CENTRE_ALIGNED;
363 
364  else if (str == "RightAligned")
365  return HTF_RIGHT_ALIGNED;
366 
367  else if (str == "Justified")
368  return HTF_JUSTIFIED;
369 
370  else if (str == "WordWrapLeftAligned")
372 
373  else if (str == "WordWrapCentreAligned")
375 
376  else if (str == "WordWrapRightAligned")
378 
379  else if (str == "WordWrapJustified")
380  return HTF_WORDWRAP_JUSTIFIED;
381 
382  else
383  return HTF_LEFT_ALIGNED;
384  }
385 };
386 
387 template<>
389 {
390 public:
391  typedef FontMetricType return_type;
392  typedef FontMetricType pass_type;
393 
394  static String toString(pass_type val)
395  {
396  switch (val)
397  {
398  case FMT_BASELINE:
399  return String("Baseline");
400 
401  case FMT_HORZ_EXTENT:
402  return String("HorzExtent");
403 
404  default:
405  return String("LineSpacing");
406  }
407  }
408 
409  static return_type fromString(const String& str)
410  {
411  if (str == "LineSpacing")
412  return FMT_LINE_SPACING;
413 
414  else if (str == "Baseline")
415  return FMT_BASELINE;
416 
417  else
418  return FMT_HORZ_EXTENT;
419  }
420 };
421 
422 template<>
424 {
425 public:
428 
429  static String toString(pass_type val)
430  {
431  switch (val)
432  {
433  case DOP_ADD:
434  return String("Add");
435 
436  case DOP_SUBTRACT:
437  return String("Subtract");
438 
439  case DOP_MULTIPLY:
440  return String("Multiply");
441 
442  case DOP_DIVIDE:
443  return String("Divide");
444 
445  default:
446  return String("Noop");
447  }
448  }
449 
450  static return_type fromString(const String& str)
451  {
452  if (str == "Add")
453  return DOP_ADD;
454 
455  else if (str == "Subtract")
456  return DOP_SUBTRACT;
457 
458  else if (str == "Multiply")
459  return DOP_MULTIPLY;
460 
461  else if (str == "Divide")
462  return DOP_DIVIDE;
463 
464  else
465  return DOP_NOOP;
466  }
467 };
468 
469 template<>
471 {
472 public:
475 
476  static String toString(pass_type val)
477  {
478  switch (val)
479  {
480  case FIC_TOP_LEFT_CORNER:
481  return String("TopLeftCorner");
482 
484  return String("TopRightCorner");
485 
487  return String("BottomLeftCorner");
488 
490  return String("BottomRightCorner");
491 
492  case FIC_LEFT_EDGE:
493  return String("LeftEdge");
494 
495  case FIC_RIGHT_EDGE:
496  return String("RightEdge");
497 
498  case FIC_TOP_EDGE:
499  return String("TopEdge");
500 
501  case FIC_BOTTOM_EDGE:
502  return String("BottomEdge");
503 
504  default:
505  return String("Background");
506  }
507  }
508 
509  static return_type fromString(const String& str)
510  {
511  if (str == "TopLeftCorner")
512  return FIC_TOP_LEFT_CORNER;
513 
514  if (str == "TopRightCorner")
515  return FIC_TOP_RIGHT_CORNER;
516 
517  if (str == "BottomLeftCorner")
518  return FIC_BOTTOM_LEFT_CORNER;
519 
520  if (str == "BottomRightCorner")
522 
523  if (str == "LeftEdge")
524  return FIC_LEFT_EDGE;
525 
526  if (str == "RightEdge")
527  return FIC_RIGHT_EDGE;
528 
529  if (str == "TopEdge")
530  return FIC_TOP_EDGE;
531 
532  if (str == "BottomEdge")
533  return FIC_BOTTOM_EDGE;
534 
535  else
536  return FIC_BACKGROUND;
537  }
538 };
539 
540 template<>
542 {
543 public:
545  typedef ChildEventAction pass_type;
546 
547  static String toString(pass_type val)
548  {
549  switch (val)
550  {
551  case CEA_REDRAW:
552  return String("Redraw");
553 
554  case CEA_LAYOUT:
555  return String("Layout");
556 
557  default:
558  CEGUI_THROW(InvalidRequestException(
559  "Invalid enumeration value given."));
560  }
561  }
562 
563  static return_type fromString(const String& str)
564  {
565  if (str == "Redraw")
566  return CEA_REDRAW;
567 
568  if (str == "Layout")
569  return CEA_LAYOUT;
570 
571  CEGUI_THROW(InvalidRequestException(
572  "'" + str +
573  "' does not represent a ChildEventAction enumerated value."));
574  }
575 };
576 
579 //
580 // PropertyHelper specialisations
581 //
584 
585 template<>
587 {
588 public:
592  typedef String string_return_type;
593 
594  static const String& getDataTypeName()
595  {
596  static String type("VerticalFormatting");
597 
598  return type;
599  }
600 
601  static return_type fromString(const String& str)
602  {
604  }
605 
606  static string_return_type toString(pass_type val)
607  {
609  }
610 };
611 
612 template<>
614 {
615 public:
619  typedef String string_return_type;
620 
621  static const String& getDataTypeName()
622  {
623  static String type("HorizontalFormatting");
624 
625  return type;
626  }
627 
628  static return_type fromString(const String& str)
629  {
631  }
632 
633  static string_return_type toString(pass_type val)
634  {
636  }
637 };
638 
639 template<>
641 {
642 public:
646  typedef String string_return_type;
647 
648  static const String& getDataTypeName()
649  {
650  static String type("VerticalTextFormatting");
651 
652  return type;
653  }
654 
655  static return_type fromString(const String& str)
656  {
658  }
659 
660  static string_return_type toString(pass_type val)
661  {
663  }
664 };
665 
666 template<>
668 {
669 public:
673  typedef String string_return_type;
674 
675  static const String& getDataTypeName()
676  {
677  static String type("HorizontalTextFormatting");
678 
679  return type;
680  }
681 
682  static return_type fromString(const String& str)
683  {
685  }
686 
687  static string_return_type toString(pass_type val)
688  {
690  }
691 };
692 
693 }
694 
695 
696 #endif