void ArgumentList::add(const std::string& ArgumentName, const ArgumentList& values) { CellMatrix cellValues(values.AllData()); addList(ArgumentName,cellValues); }
std::vector<ArgumentList> FileConversion(const std::vector<char>& inputFile, unsigned long gapSize) { std::vector<char>::const_iterator it = inputFile.begin(); std::vector<std::vector<std::string> > Cells; Cells.resize(1); std::string currentCell; while (it != inputFile.end()) { char c = *it; ++it; switch (c) { case ',' : // end of cell but not line { (*Cells.rbegin()).push_back(currentCell); currentCell = ""; break; } case '\n' : // new line so move on; { Cells.push_back(std::vector<std::string>()); if (currentCell != "") { (*Cells.rbegin()).push_back(currentCell); currentCell = ""; } break; } default: { currentCell.push_back(c); } } } std::vector<std::vector<CellValue> > cellValues(Cells.size()); for (unsigned long i=0; i < Cells.size(); ++i) { cellValues[i].reserve(Cells[i].size()); for (unsigned long j=0; j < Cells[i].size(); ++j) cellValues[i].push_back( CellFromString(Cells[i][j])); } size_t rows =cellValues.size(); std::vector<CellMatrix> cellMatrices; size_t currentRow=0; // now divide into CellMatrices while (currentRow < rows) { while( currentRow < rows && cellValues[currentRow].size() == 0) ++currentRow; size_t startRow = currentRow; if (currentRow < rows) { size_t firstEmpty; bool endNotFound = true; do { while( currentRow < rows && cellValues[currentRow].size() != 0) ++currentRow; if (currentRow < rows) { firstEmpty = currentRow; while( currentRow < rows && cellValues[currentRow].size() == 0) ++currentRow; if (currentRow == rows || (currentRow - firstEmpty) >=gapSize) endNotFound = false; } else endNotFound=false; } while (endNotFound); if (currentRow == rows) firstEmpty = rows; if (startRow < firstEmpty) { size_t maxColSize=0; for (size_t j=startRow; j < firstEmpty; ++j) maxColSize = std::max<size_t>(maxColSize, cellValues.size()); CellMatrix thisOne(firstEmpty-startRow,maxColSize); for (size_t i=startRow; i < firstEmpty; ++i) for (size_t j=0; j < cellValues[i].size(); ++j) thisOne(i-startRow,j) = cellValues[i][j]; cellMatrices.push_back(thisOne); } } } std::vector<ArgumentList> args; for (unsigned long i=0; i < cellMatrices.size(); ++i) args.push_back(ArgumentList(cellMatrices[i],"clw")); return args; }