]> git.tdb.fi Git - libs/gl.git/blob - source/core/predicate.cpp
Use a streaming buffer for ProgramData only when needed
[libs/gl.git] / source / core / predicate.cpp
1 #include <msp/strings/format.h>
2 #include "predicate.h"
3
4 using namespace std;
5
6 namespace Msp {
7 namespace GL {
8
9 void operator>>(const LexicalConverter &conv, Predicate &pred)
10 {
11         const string &str = conv.get();
12         if(str=="NEVER")
13                 pred = NEVER;
14         else if(str=="ALWAYS")
15                 pred = ALWAYS;
16         else if(str=="LESS")
17                 pred = LESS;
18         else if(str=="LEQUAL")
19                 pred = LEQUAL;
20         else if(str=="EQUAL")
21                 pred = EQUAL;
22         else if(str=="GREATER")
23                 pred = GREATER;
24         else if(str=="GEQUAL")
25                 pred = GEQUAL;
26         else if(str=="NOTEQUAL")
27                 pred = NOTEQUAL;
28         else
29                 throw lexical_error(format("conversion of '%s' to Predicate", str));
30 }
31
32 void operator<<(LexicalConverter &conv, Predicate pred)
33 {
34         switch(pred)
35         {
36         case NEVER: conv.result("NEVER"); break;
37         case ALWAYS: conv.result("ALWAYS"); break;
38         case LESS: conv.result("LESS"); break;
39         case LEQUAL: conv.result("LEQUAL"); break;
40         case EQUAL: conv.result("EQUAL"); break;
41         case GREATER: conv.result("GREATER"); break;
42         case GEQUAL: conv.result("GEQUAL"); break;
43         case NOTEQUAL: conv.result("NOTEQUAL"); break;
44         default: conv.result(format("Predicate(%#x)", static_cast<int>(pred))); break;
45         }
46 }
47
48 } // namespace GL
49 } // namespace Msp