-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
+#include <msp/strings/format.h>
#include "primitivetype.h"
namespace Msp {
namespace GL {
-std::istream &operator>>(std::istream &in, PrimitiveType &pt)
+void operator>>(const LexicalConverter &conv, PrimitiveType &pt)
{
- std::string str;
- in>>str;
-
- if(str=="POINTS")
+ if(conv.get()=="POINTS")
pt = POINTS;
- else if(str=="LINES")
+ else if(conv.get()=="LINES")
pt = LINES;
- else if(str=="LINE_LOOP")
+ else if(conv.get()=="LINE_LOOP")
pt = LINE_LOOP;
- else if(str=="LINE_STRIP")
+ else if(conv.get()=="LINE_STRIP")
pt = LINE_STRIP;
- else if(str=="TRIANGLES")
+ else if(conv.get()=="TRIANGLES")
pt = TRIANGLES;
- else if(str=="TRIANGLE_STRIP")
+ else if(conv.get()=="TRIANGLE_STRIP")
pt = TRIANGLE_STRIP;
- else if(str=="TRIANGLE_FAN")
+ else if(conv.get()=="TRIANGLE_FAN")
pt = TRIANGLE_FAN;
- else if(str=="QUADS")
+ else if(conv.get()=="QUADS")
pt = QUADS;
- else if(str=="QUAD_STRIP")
+ else if(conv.get()=="QUAD_STRIP")
pt = QUAD_STRIP;
- else if(str=="POLYGON")
- pt = POLYGON;
else
- in.setstate(std::ios_base::failbit);
+ throw lexical_error(format("conversion of '%s' to PrimitiveType", conv.get()));
+}
- return in;
+void require_primitive_type(PrimitiveType type)
+{
+ if(type==QUADS || type==QUAD_STRIP)
+ static Require _req(MSP_legacy_features);
}
} // namespace GL