]> git.tdb.fi Git - poefilter.git/blobdiff - source/iconshape.cpp
Add support for the new visual indicators
[poefilter.git] / source / iconshape.cpp
diff --git a/source/iconshape.cpp b/source/iconshape.cpp
new file mode 100644 (file)
index 0000000..e16eeea
--- /dev/null
@@ -0,0 +1,38 @@
+#include <msp/strings/format.h>
+#include "iconshape.h"
+
+using namespace std;
+using namespace Msp;
+
+void operator>>(const LexicalConverter &conv, IconShape &shape)
+{
+       const string &str = conv.get();
+       if(str=="Circle")
+               shape = CIRCLE;
+       else if(str=="Triangle")
+               shape = TRIANGLE;
+       else if(str=="Square")
+               shape = SQUARE;
+       else if(str=="Diamond")
+               shape = DIAMOND;
+       else if(str=="Hexagon")
+               shape = HEXAGON;
+       else if(str=="Star")
+               shape = STAR;
+       else
+               throw lexical_error(format("Conversion of %s to IconShape", str));
+}
+
+void operator<<(LexicalConverter &conv, IconShape shape)
+{
+       switch(shape)
+       {
+       case CIRCLE: conv.result("Circle"); return;
+       case TRIANGLE: conv.result("Triangle"); return;
+       case SQUARE: conv.result("Square"); return;
+       case DIAMOND: conv.result("Diamond"); return;
+       case HEXAGON: conv.result("Hexagon"); return;
+       case STAR: conv.result("Star"); return;
+       default: conv.result(format("IconShape(%d)", static_cast<int>(shape))); return;
+       }
+}