+ return -1;
+}
+
+VertexComponent make_indexed_component(VertexComponent comp, unsigned index)
+{
+ if(comp>=TEXCOORD1 && comp<=TEXCOORD4)
+ {
+ if(index>=4)
+ throw out_of_range("make_indexed_component");
+ }
+ else if(comp>=ATTRIB1 && comp<=ATTRIB4)
+ {
+ if(index>=24)
+ throw out_of_range("make_indexed_component");
+ }
+ else
+ throw invalid_argument("make_indexed_component");
+ return static_cast<VertexComponent>(comp+index*4);
+}
+
+void operator>>(const LexicalConverter &conv, VertexComponent &c)
+{
+ const string &str = conv.get();
+ if(str.size()==7 && !str.compare(0, 6, "VERTEX") && str[6]>='2' && str[6]<='4')
+ c = static_cast<VertexComponent>(VERTEX2+(str[6]-'2'));
+ else if(str=="NORMAL3")
+ c = NORMAL3;
+ else if(str.size()==12 && !str.compare(0, 5, "COLOR") && str[5]>='3' && str[5]<='4' && !str.compare(6, 6, "_FLOAT"))
+ c = static_cast<VertexComponent>(COLOR3_FLOAT+(str[5]-'3'));
+ else if(str=="COLOR4_UBYTE")
+ c = COLOR4_UBYTE;
+ else if(str.size()>=9 && !str.compare(0, 8, "TEXCOORD") && str[8]>='1' && str[8]<='4')
+ {
+ if(str.size()==9)
+ c = static_cast<VertexComponent>(TEXCOORD1+(str[8]-'1'));
+ else if(str.size()==11 && str[9]=='_' && str[10]>='0' && str[10]<='7')
+ c = static_cast<VertexComponent>(TEXCOORD1+(str[8]-'1')+(str[10]-'0')*4);
+ else
+ throw lexical_error(format("conversion of '%s' to VertexComponent", str));
+ }
+ else if(str.size()>=9 && !str.compare(0, 6, "ATTRIB") && str[6]>='1' && str[6]<='4' && str[7]=='_')
+ {
+ unsigned n;
+ try
+ {
+ n = lexical_cast<unsigned>(str.substr(8));
+ }
+ catch(const lexical_error &)