namespace Msp {
namespace GL {
-istream &operator>>(istream &in, PixelFormat &fmt)
+void operator>>(const LexicalConverter &conv, PixelFormat &fmt)
{
- string word;
-
- in>>word;
- if(word=="COLOR_INDEX")
+ if(conv.get()=="COLOR_INDEX")
fmt = COLOR_INDEX;
- else if(word=="STENCIL_INDEX")
+ else if(conv.get()=="STENCIL_INDEX")
fmt = STENCIL_INDEX;
- else if(word=="DEPTH_COMPONENT")
+ else if(conv.get()=="DEPTH_COMPONENT")
fmt = DEPTH_COMPONENT;
- else if(word=="RED")
+ else if(conv.get()=="RED")
fmt = RED;
- else if(word=="GREEN")
+ else if(conv.get()=="GREEN")
fmt = GREEN;
- else if(word=="BLUE")
+ else if(conv.get()=="BLUE")
fmt = BLUE;
- else if(word=="ALPHA")
+ else if(conv.get()=="ALPHA")
fmt = ALPHA;
- else if(word=="RGB")
+ else if(conv.get()=="RGB")
fmt = RGB;
- else if(word=="RGBA")
+ else if(conv.get()=="RGBA")
fmt = RGBA;
- else if(word=="BGR")
+ else if(conv.get()=="BGR")
fmt = BGR;
- else if(word=="BGRA")
+ else if(conv.get()=="BGRA")
fmt = BGRA;
- else if(word=="LUMINANCE")
+ else if(conv.get()=="LUMINANCE")
fmt = LUMINANCE;
- else if(word=="LUMINANCE_ALPHA")
+ else if(conv.get()=="LUMINANCE_ALPHA")
fmt = LUMINANCE_ALPHA;
else
- in.setstate(ios_base::failbit);
-
- return in;
+ throw lexical_error(format("conversion of '%s' to PixelFormat", conv.get()));
}
PixelFormat pixelformat_from_graphics(Graphics::PixelFormat pf)
#ifndef MSP_GL_PIXELFORMAT_H_
#define MSP_GL_PIXELFORMAT_H_
-#include <istream>
#include <msp/graphics/pixelformat.h>
+#include <msp/strings/lexicalcast.h>
#include "gl.h"
#include <GL/glext.h>
LUMINANCE_ALPHA32F = GL_LUMINANCE_ALPHA32F_ARB,
};
-std::istream &operator>>(std::istream &, PixelFormat &);
+void operator>>(const LexicalConverter &, PixelFormat &);
PixelFormat pixelformat_from_graphics(Graphics::PixelFormat);
+#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")
+ else if(conv.get()=="POLYGON")
pt = POLYGON;
else
- in.setstate(std::ios_base::failbit);
-
- return in;
+ throw lexical_error(format("conversion of '%s' to PrimitiveType", conv.get()));
}
} // namespace GL
#ifndef MSP_GL_PRIMITIVETYPE_H_
#define MSP_GL_PRIMITIVETYPE_H_
-#include <istream>
+#include <msp/strings/lexicalcast.h>
#include "gl.h"
namespace Msp {
POLYGON = GL_POLYGON
};
-std::istream &operator>>(std::istream &in, PrimitiveType &pt);
+void operator>>(const LexicalConverter &, PrimitiveType &);
} // namespace GL
} // namespace Msp
namespace Msp {
namespace GL {
-istream &operator>>(istream &in, TextureFilter &tf)
+void operator>>(const LexicalConverter &c, TextureFilter &tf)
{
- string str;
- in>>str;
-
- if(str=="NEAREST")
+ if(c.get()=="NEAREST")
tf = NEAREST;
- else if(str=="LINEAR")
+ else if(c.get()=="LINEAR")
tf = LINEAR;
- else if(str=="NEAREST_MIPMAP_NEAREST")
+ else if(c.get()=="NEAREST_MIPMAP_NEAREST")
tf = NEAREST_MIPMAP_NEAREST;
- else if(str=="NEAREST_MIPMAP_LINEAR")
+ else if(c.get()=="NEAREST_MIPMAP_LINEAR")
tf = NEAREST_MIPMAP_LINEAR;
- else if(str=="LINEAR_MIPMAP_NEAREST")
+ else if(c.get()=="LINEAR_MIPMAP_NEAREST")
tf = LINEAR_MIPMAP_NEAREST;
- else if(str=="LINEAR_MIPMAP_LINEAR")
+ else if(c.get()=="LINEAR_MIPMAP_LINEAR")
tf = LINEAR_MIPMAP_LINEAR;
else
- in.setstate(ios_base::failbit);
-
- return in;
+ throw lexical_error(format("conversion of '%s' to TextureFilter", c.get()));
}
#ifndef MSP_GL_TEXTURE_H_
#define MSP_GL_TEXTURE_H_
-#include <istream>
#include <msp/datafile/objectloader.h>
#include "gl.h"
#include "predicate.h"
LINEAR_MIPMAP_LINEAR = GL_LINEAR_MIPMAP_LINEAR
};
-std::istream &operator>>(std::istream &, TextureFilter &);
-
enum TextureWrap
{
#ifndef MSP_GL_VERTEXFORMAT_H_
#define MSP_GL_VERTEXFORMAT_H_
-#include <istream>
+#include <msp/core/lexicalcast.h>
namespace Msp {
namespace GL {