MCPcopy Create free account
hub / github.com/KDE/labplot / initDataContainer

Method initDataContainer

src/backend/core/column/ColumnPrivate.cpp:812–865  ·  view source on GitHub ↗

! * initializes the interal vector for data. This is where the actual allocation on the heap is happening. * If \c resize is set to \false, the vector is not resized after its creation. This should be used * if there is already a vector created somewhere and the content of the column is going to be replaced * with the existing content where the memory was already allocated. */

Source from the content-addressed store, hash-verified

810 * with the existing content where the memory was already allocated.
811 */
812bool ColumnPrivate::initDataContainer(bool resize) {
813 switch (m_columnMode) {
814 case AbstractColumn::ColumnMode::Double: {
815 auto* vec = new QVector<double>();
816 try {
817 if (resize)
818 vec->resize(m_rowCount);
819 } catch (std::bad_alloc&) { return false; }
820 vec->fill(std::numeric_limits<double>::quiet_NaN());
821 m_data = vec;
822 break;
823 }
824 case AbstractColumn::ColumnMode::Integer: {
825 auto* vec = new QVector<int>();
826 try {
827 if (resize)
828 vec->resize(m_rowCount);
829 } catch (std::bad_alloc&) { return false; }
830 m_data = vec;
831 break;
832 }
833 case AbstractColumn::ColumnMode::BigInt: {
834 auto* vec = new QVector<qint64>();
835 try {
836 if (resize)
837 vec->resize(m_rowCount);
838 } catch (std::bad_alloc&) { return false; }
839 m_data = vec;
840 break;
841 }
842 case AbstractColumn::ColumnMode::Text: {
843 auto* vec = new QVector<QString>();
844 try {
845 if (resize)
846 vec->resize(m_rowCount);
847 } catch (std::bad_alloc&) { return false; }
848 m_data = vec;
849 break;
850 }
851 case AbstractColumn::ColumnMode::DateTime:
852 case AbstractColumn::ColumnMode::Month:
853 case AbstractColumn::ColumnMode::Day: {
854 auto* vec = new QVector<QDateTime>();
855 try {
856 if (resize)
857 vec->resize(m_rowCount);
858 } catch (std::bad_alloc&) { return false; }
859 m_data = vec;
860 break;
861 }
862 }
863
864 return true;
865}
866
867void ColumnPrivate::initIOFilters() {
868 const auto numberLocale = QLocale();

Callers 1

dataMethod · 0.80

Calls 1

resizeMethod · 0.45

Tested by

no test coverage detected