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

Method switchHeader

src/csvtable.cpp:624–656  ·  view source on GitHub ↗

* Switch header row: Default Headers (A,B,..) to Custom Headers (First Row in Data) * Returns 1 if header is activated, 0 if not */

Source from the content-addressed store, hash-verified

622 * Returns 1 if header is activated, 0 if not
623 */
624int CsvTable::switchHeader() {
625 int ret;
626
627 if( storage.rows() <= 1 && hasCustomHeaderRow == false) {
628 return 0;
629 }
630
631 if( hasCustomHeaderRow ) {
632 // Custom Headers => Default Headers
633 std::vector< std::string > newRow(storage.columns());
634 for( table_index_t c = 0; c < (table_index_t) newRow.size(); ++c ) {
635 newRow.at(c) = getHeaderCell(c);
636 }
637 storage.push_front(newRow);
638 for( table_index_t c = 0; c < (table_index_t) headerRow->size(); ++c ) {
639 headerRow->at(c) = "";
640 }
641 hasCustomHeaderRow = false;
642 moveFlags(0, 1);
643 ret = 0;
644 } else {
645 // Default Headers => Custom Headers
646 for( table_index_t c = 0; c < getNumberCols(); ++c ) {
647 headerRow->at(c) = getCell(0,c);
648 }
649 storage.deleteRows(0,0);
650 hasCustomHeaderRow = true;
651 moveFlags(0, -1);
652 ret = 1;
653 }
654 updateInternals();
655 return ret;
656}
657
658bool CsvTable::customHeaderRowShown() {
659 return hasCustomHeaderRow;

Callers 2

loadFileMethod · 0.80
switchHeaderRowCBMethod · 0.80

Calls 6

rowsMethod · 0.80
columnsMethod · 0.80
atMethod · 0.80
push_frontMethod · 0.80
deleteRowsMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected