int main(int argc, char *argv[]) { RangeList rl; rl.addRangeFile("RangeList_test_input"); std::string range; for (unsigned int i = 0; i < rl.size(); i++) { rl.obtainRange(i, &range); printf("%s\n", range.c_str()); } std::string s = "a b\"MID\" c d"; std::vector<std::string> result; unsigned int ret = stringTokenize(s, ' ', &result); printf("ret = %d\n", ret); dumpStringVector(result); ret = stringTokenize(s, "\" ", &result); printf("ret = %d\n", ret); dumpStringVector(result); s = ""; ret = stringTokenize(s, " ", &result); printf("ret = %d\n", ret); dumpStringVector(result); return 0; }
void TestDef_fr::testStringInput() { struct data { string in; string out; string o_dmy; Field beg; Field end; } t[] = { { "18Vent\303\264se7", "18 Vent\303\264se 7", "18 Vent 7", 2378198, 2378198 }, { "Frim6", "Frimaire 6", "Frim 6", 2377726, 2377755 }, { "7", "7", "7", 2378031, 2378396 }, { "trav8", "F\303\252te du Travail 8", "3 Comp 8", 2378759, 2378759 }, }; size_t count = sizeof(t) / sizeof(data); m_cal->set_input_format( m_sid, "cdmy" ); m_cal->set_output_format( m_sid, "cdmy" ); for( size_t i = 0 ; i < count ; i++ ) { RangeList rl = m_cal->str_to_rangelist( m_sid, t[i].in ); string str = m_cal->rangelist_to_str( m_sid, rl ); CPPUNIT_ASSERT_EQUAL( t[i].out, str ); if( rl.size() ) { CPPUNIT_ASSERT_EQUAL( t[i].beg, rl[0].jdn1 ); size_t j = rl.size() - 1; CPPUNIT_ASSERT_EQUAL( t[i].end, rl[j].jdn2 ); } } m_cal->set_input_format( m_sid, "dmy" ); m_cal->set_output_format( m_sid, "dmy" ); for( size_t i = 0 ; i < count ; i++ ) { RangeList rl = m_cal->str_to_rangelist( m_sid, t[i].in ); string str = m_cal->rangelist_to_str( m_sid, rl ); CPPUNIT_ASSERT_EQUAL( t[i].o_dmy, str ); if( rl.size() ) { CPPUNIT_ASSERT_EQUAL( t[i].beg, rl[0].jdn1 ); size_t j = rl.size() - 1; CPPUNIT_ASSERT_EQUAL( t[i].end, rl[j].jdn2 ); } } }
int bytesRangesToIndices(RangeList& ranges,GLESpointer* p,GLushort* indices) { int attribSize = p->getSize() * 4; //4 is the sizeof GLfixed or GLfloat in bytes int stride = p->getStride()?p->getStride():attribSize; int offset = p->getBufferOffset(); int n = 0; for(int i=0;i<ranges.size();i++) { int startIndex = (ranges[i].getStart() - offset) / stride; int nElements = ranges[i].getSize()/attribSize; for(int j=0;j<nElements;j++) { indices[n++] = startIndex+j; } } return n; }
void GLEScontext::convertIndirectVBO(GLESConversionArrays& cArrs,GLsizei count,GLenum indices_type,const GLvoid* indices,GLenum array_id,GLESpointer* p) { RangeList ranges; RangeList conversions; GLushort* conversionIndices = NULL; int attribSize = p->getSize(); int stride = p->getStride()?p->getStride():sizeof(GLfixed)*attribSize; char* data = static_cast<char*>(p->getBufferData()); if(p->bufferNeedConversion()) { indirectToBytesRanges(indices,indices_type,count,p,ranges); //converting indices range to buffer bytes ranges by offset p->getBufferConversions(ranges,conversions); // getting from the buffer the relevant ranges that still needs to be converted if(conversions.size()) { // there are some elements to convert conversionIndices = new GLushort[count]; int nIndices = bytesRangesToIndices(conversions,p,conversionIndices); //converting bytes ranges by offset to indices in this array convertFixedIndirectLoop(data,stride,data,nIndices,GL_UNSIGNED_SHORT,conversionIndices,stride,attribSize); } } if(conversionIndices) delete[] conversionIndices; cArrs.setArr(data,p->getStride(),GL_FLOAT); }
unsigned int NSequences(void) const { return ranges.size(); }
// resize - add new (empty) rows at end void AddRows(unsigned int nNewRows) { ranges.resize(ranges.size() + nNewRows); }