#include #include #include #include #include //From http://www.richelbilderbeek.nl/CppStringGridToVector.htm template const std::vector > StringGridToVector(const TStringGrid * const stringGrid) { assert(stringGrid!=0 && "StringGrid must not be NULL"); const int height = stringGrid->RowCount; const int width = stringGrid->ColCount; std::vector > v(height, std::vector(width)); for (int y=0; y!=height; ++y) { assert(y >=0); assert(y < static_cast(v.size()) ); std::vector& line = v[y]; //Don't have the guts to do a line-access on a TStringGrid... for (int x=0; x!=width; ++x) { assert(x >=0); assert(x < static_cast(line.size()) ); //const_cast because the VCL is not const-correct. Grumble, grumble... const std::string s = (const_cast(stringGrid)->Cells[x][y]).c_str(); const T t = boost::lexical_cast(s); vLine[x] = t; } } return v; }