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

Method moveCols

src/csvtable.cpp:237–265  ·  view source on GitHub ↗

* Move columns right or left */

Source from the content-addressed store, hash-verified

235 * Move columns right or left
236 */
237void CsvTable::moveCols(table_index_t colFromStart, table_index_t colFromEnd, bool right) {
238 std::string buffer;
239 if( colFromStart > colFromEnd ) {
240 return;
241 }
242
243 // Move columns
244 storage.moveColumns(colFromStart, colFromEnd, right);
245
246 // Move header row
247 if( right ) {
248 if( colFromEnd < storage.columns() - 1 && colFromStart >= 0 ) {
249 buffer = headerRow->at(colFromEnd + 1);
250 for( table_index_t c = colFromEnd; c >= colFromStart; --c ) {
251 headerRow->at(c + 1) = headerRow->at(c);
252 }
253 headerRow->at(colFromStart) = buffer;
254 }
255 } else {
256 if( colFromStart > 0 && colFromEnd < storage.columns() ) {
257 buffer = headerRow->at(colFromStart - 1);
258 for( table_index_t c = colFromStart; c <= colFromEnd; ++c ) {
259 headerRow->at(c - 1) = headerRow->at(c);
260 }
261 headerRow->at(colFromEnd) = buffer;
262 }
263 }
264 updateInternals();
265}
266
267
268/*

Callers 1

MyMenuCallbackMethod · 0.45

Calls 3

moveColumnsMethod · 0.80
columnsMethod · 0.80
atMethod · 0.80

Tested by

no test coverage detected