MCPcopy Create free account
hub / github.com/Tablecruncher/tablecruncher / moveColumns

Method moveColumns

src/csvdatastorage.cpp:376–406  ·  view source on GitHub ↗

moveColumns(long colFrom, long colTo, bool right) Move columns. 0 1 2 3 4 | A | B | C | D | E | */

Source from the content-addressed store, hash-verified

374 | A | B | C | D | E |
375 */
376void CsvDataStorage::moveColumns(table_index_t colFrom, table_index_t colTo, bool right) {
377 table_index_t R = rows();
378 table_index_t C = columns();
379 std::string buffer = "";
380
381 if( right ) {
382 if( colTo < C - 1 && colFrom >= 0 ) {
383 for( table_index_t r = 0; r < R; ++r ) {
384 std::vector<std::string> row = splitString(tableData.at(r));
385 buffer = row.at(colTo + 1);
386 for( int c = colTo; c >= colFrom; --c ) {
387 row.at(c + 1) = row.at(c);
388 }
389 row.at(colFrom) = buffer;
390 tableData.at(r) = mergeString(row);
391 }
392 }
393 } else {
394 if( colFrom > 0 && colTo < C ) {
395 for( table_index_t r = 0; r < R; ++r ) {
396 std::vector<std::string> row = splitString(tableData.at(r));
397 buffer = row.at(colFrom - 1);
398 for( int c = colFrom; c <= colTo; ++c ) {
399 row.at(c - 1) = row.at(c);
400 }
401 row.at(colTo) = buffer;
402 tableData.at(r) = mergeString(row);
403 }
404 }
405 }
406}
407
408
409bool CsvDataStorage::cellContainsLineBreak(table_index_t R, table_index_t C) {

Callers 1

moveColsMethod · 0.80

Calls 1

atMethod · 0.80

Tested by

no test coverage detected