]> git.tdb.fi Git - poefilter.git/blob - source/iconshape.cpp
Add support for the new visual indicators
[poefilter.git] / source / iconshape.cpp
1 #include <msp/strings/format.h>
2 #include "iconshape.h"
3
4 using namespace std;
5 using namespace Msp;
6
7 void operator>>(const LexicalConverter &conv, IconShape &shape)
8 {
9         const string &str = conv.get();
10         if(str=="Circle")
11                 shape = CIRCLE;
12         else if(str=="Triangle")
13                 shape = TRIANGLE;
14         else if(str=="Square")
15                 shape = SQUARE;
16         else if(str=="Diamond")
17                 shape = DIAMOND;
18         else if(str=="Hexagon")
19                 shape = HEXAGON;
20         else if(str=="Star")
21                 shape = STAR;
22         else
23                 throw lexical_error(format("Conversion of %s to IconShape", str));
24 }
25
26 void operator<<(LexicalConverter &conv, IconShape shape)
27 {
28         switch(shape)
29         {
30         case CIRCLE: conv.result("Circle"); return;
31         case TRIANGLE: conv.result("Triangle"); return;
32         case SQUARE: conv.result("Square"); return;
33         case DIAMOND: conv.result("Diamond"); return;
34         case HEXAGON: conv.result("Hexagon"); return;
35         case STAR: conv.result("Star"); return;
36         default: conv.result(format("IconShape(%d)", static_cast<int>(shape))); return;
37         }
38 }