mirror of
https://github.com/jkriege2/JKQtPlotter.git
synced 2024-12-25 10:01:38 +08:00
JKQTPDatastore: added functions to check for existence of a column and to retreive the data of a column as a QVector<double>
This commit is contained in:
parent
baab796541
commit
9e4210c823
@ -315,6 +315,12 @@ JKQTPDatastore::~JKQTPDatastore() {
|
||||
clear();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
bool JKQTPDatastore::hasColumn(size_t i) const
|
||||
{
|
||||
return columns.find(i)!=columns.end();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
JKQTPDatastore::ColumnIterator JKQTPDatastore::begin()
|
||||
{
|
||||
@ -1159,6 +1165,17 @@ QList<QVector<double> > JKQTPDatastore::getData(QStringList *columnNames, const
|
||||
return res;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
QVector<double> JKQTPDatastore::getData(size_t column, QString *columnName) const
|
||||
{
|
||||
QVector<double> res;
|
||||
if (hasColumn(column)) {
|
||||
if (columnName) *columnName=columns.value(column).getName();
|
||||
columns.value(column).copyData(res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void JKQTPDatastore::saveDIF(const QString& filename, const QSet<int>& userColumns, const QString& floatformat) const {
|
||||
|
@ -387,6 +387,9 @@ class JKQTP_LIB_EXPORT JKQTPDatastore{
|
||||
/** \brief class destructor, destroys all subordered JKQTPDatastoreItem objects */
|
||||
~JKQTPDatastore();
|
||||
|
||||
/** \brief determines whether a column with the given ID exists */
|
||||
bool hasColumn(size_t i) const;
|
||||
|
||||
/** \brief returns an iterator to the first data entry in the \a i -th column in the JKQTPDatastore \see JKQTPColumn::iterator */
|
||||
JKQTPColumnIterator begin(int i);
|
||||
/** \brief returns an iterator behind the last data entry data in the \a i -th column in the JKQTPDatastore \see JKQTPColumn::iterator */
|
||||
@ -1326,6 +1329,13 @@ class JKQTP_LIB_EXPORT JKQTPDatastore{
|
||||
*/
|
||||
QList<QVector<double> > getData(QStringList* columnNames=nullptr, const QSet<int>& userColumns=QSet<int>()) const;
|
||||
|
||||
/** \brief return contents of a given column as QVector<double>
|
||||
*
|
||||
* \param column column to copy
|
||||
* \param columnName if \c !=nullptr this will afterwards conatin the column title
|
||||
*/
|
||||
QVector<double> getData(size_t column, QString* columnName=nullptr) const;
|
||||
|
||||
/** \brief save contents of datastore as <a href="http://www.fileformat.info/format/dif/egff.htm">DIF file (data interchange format)</a>
|
||||
*
|
||||
* \param filename the file to create
|
||||
|
Loading…
Reference in New Issue
Block a user