------------------------------------------------------------------------------
| 1176 | |
| 1177 | //------------------------------------------------------------------------------ |
| 1178 | bool vtkMatplotlibMathTextUtilities::ParseString( |
| 1179 | const char* str, GridOfStrings& strGrid, std::size_t& maxNumberOfCells) |
| 1180 | { |
| 1181 | // First, change all occurrence of escaped pipe ("\|") |
| 1182 | // Into a special character and recover them after splitting |
| 1183 | std::string stdStr = std::string(str); |
| 1184 | this->FindAndReplaceInString(stdStr, "\\|", vtkMatplotlibMathTextUtilities::PipeProtectString); |
| 1185 | |
| 1186 | maxNumberOfCells = 0; |
| 1187 | std::stringstream ss(stdStr); |
| 1188 | std::string line; |
| 1189 | strGrid.clear(); |
| 1190 | |
| 1191 | // Split lines |
| 1192 | while (std::getline(ss, line)) |
| 1193 | { |
| 1194 | std::size_t numberOfCells = 0; |
| 1195 | std::vector<std::string> lineStrVec; |
| 1196 | |
| 1197 | // A cell is defined by a pipe '|' |
| 1198 | std::stringstream ssCell(line); |
| 1199 | std::string cell; |
| 1200 | while (std::getline(ssCell, cell, '|')) |
| 1201 | { |
| 1202 | // Recover the escaped pipe |
| 1203 | this->FindAndReplaceInString(cell, vtkMatplotlibMathTextUtilities::PipeProtectString, "\\|"); |
| 1204 | lineStrVec.push_back(std::move(cell)); |
| 1205 | numberOfCells++; |
| 1206 | } |
| 1207 | strGrid.push_back(lineStrVec); |
| 1208 | maxNumberOfCells = std::max(maxNumberOfCells, numberOfCells); |
| 1209 | } |
| 1210 | |
| 1211 | // Initialize number of interior borders |
| 1212 | this->VerticalLinesPosition.resize(maxNumberOfCells - 1); |
| 1213 | this->HorizontalLinesPosition.resize(strGrid.size() - 1); |
| 1214 | |
| 1215 | return true; |
| 1216 | } |
| 1217 | |
| 1218 | //------------------------------------------------------------------------------ |
| 1219 | bool vtkMatplotlibMathTextUtilities::RenderString( |