- if(t!=UNSIGNED_BYTE && t!=UNSIGNED_SHORT && t!=UNSIGNED_INT)
- throw InvalidParameterValue("Batch data type must be an unsigned integer");
- if(t==UNSIGNED_BYTE && max_index>0xFE)
- throw InvalidState("UNSIGNED_BYTE can't hold all indices in Batch");
- else if(t==UNSIGNED_SHORT && max_index>0xFFFE)
- throw InvalidState("UNSIGNED_SHORT can't hold all indices in Batch");
-
- if(data_type==UNSIGNED_BYTE && t==UNSIGNED_SHORT)
- expand_data<unsigned char, unsigned short>();
- else if(data_type==UNSIGNED_BYTE && t==UNSIGNED_INT)
- expand_data<unsigned char, unsigned>();
- else if(data_type==UNSIGNED_SHORT && t==UNSIGNED_INT)
- expand_data<unsigned short, unsigned>();
- else if(data_type==UNSIGNED_INT && t==UNSIGNED_BYTE)
- shrink_data<unsigned, unsigned char>();
- else if(data_type==UNSIGNED_INT && t==UNSIGNED_SHORT)
- shrink_data<unsigned, unsigned short>();
- else if(data_type==UNSIGNED_SHORT && t==UNSIGNED_BYTE)
- shrink_data<unsigned short, unsigned char>();
-
- data_type = t;
- update_ibuf_offsets();
+ if(t!=UNSIGNED_SHORT && t!=UNSIGNED_INT)
+ throw invalid_argument("Batch::set_data_type");
+ if(t==UNSIGNED_SHORT && max_index>0xFFFE)
+ throw invalid_operation("Batch::set_data_type");
+
+ if(index_type==UNSIGNED_SHORT && t==UNSIGNED_INT)
+ expand<UInt16, UInt32>(data);
+ else if(index_type==UNSIGNED_INT && t==UNSIGNED_SHORT)
+ shrink<UInt32, UInt16>(data);
+
+ index_type = t;
+ update_offset();