+#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;
+ }
+}