X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Ficonshape.cpp;fp=source%2Ficonshape.cpp;h=e16eeea147684c873e2d5772accde6241b98c0f3;hb=24829179be6aae41a189ba0d9a1feddf46c50d1d;hp=0000000000000000000000000000000000000000;hpb=22768283de4f618ab482c22fb5ada46d8a4e913a;p=poefilter.git diff --git a/source/iconshape.cpp b/source/iconshape.cpp new file mode 100644 index 0000000..e16eeea --- /dev/null +++ b/source/iconshape.cpp @@ -0,0 +1,38 @@ +#include +#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(shape))); return; + } +}