20#include "../utils/tools.hpp"
21#include "../ui/error.hpp"
22#include "../../kernel.hpp"
132 if (elem >=
m_data.size())
133 m_data.resize(elem+1, NAN);
155 for (
size_t i = 0; i < idx.
size(); i++)
222 for (
size_t i = 0; i < idx.
size(); i++)
224 if (idx[i] >= 0 && idx[i] < (
int)
m_data.size())
347 if (elem < 0 || elem >= (
int)
m_data.size())
350 return m_data[elem] != 0.0;
374 for (
size_t i = 0; i <
m_data.size(); i++)
386 for (
size_t i = 0; i <
m_data.size(); i++)
398 for (
size_t i = 0; i <
m_data.size(); i++)
410 for (
size_t i = 0; i <
m_data.size(); i++)
544 if (elem >=
m_data.size())
545 m_data.resize(elem+1, NAN);
547 m_data[elem] = vValue.real();
567 for (
size_t i = 0; i < idx.
size(); i++)
637 for (
size_t i = 0; i < idx.
size(); i++)
639 if (idx[i] >= 0 && idx[i] < (
int)
m_data.size())
762 if (elem < 0 || elem >= (
int)
m_data.size())
765 return m_data[elem] != 0.0;
789 for (
size_t i = 0; i <
m_data.size(); i++)
801 for (
size_t i = 0; i <
m_data.size(); i++)
813 for (
size_t i = 0; i <
m_data.size(); i++)
914 return m_data[elem] ? 1.0 : 0.0;
950 if (elem >=
m_data.size())
973 for (
size_t i = 0; i < idx.
size(); i++)
1040 for (
size_t i = 0; i < idx.
size(); i++)
1042 if (idx[i] >= 0 && idx[i] < (
int)
m_data.size())
1165 if (elem < 0 || elem >= (
int)
m_data.size())
1192 for (
size_t i = 0; i <
m_data.size(); i++)
1204 for (
size_t i = 0; i <
m_data.size(); i++)
1216 for (
size_t i = 0; i <
m_data.size(); i++)
1264 if (elem <
m_data.size())
1323 if (elem >=
m_data.size() && !sValue.length())
1326 if (elem >=
m_data.size())
1346 if (elem >=
m_data.size())
1369 for (
size_t i = 0; i < idx.
size(); i++)
1371 if (idx[i] >= 0 && idx[i] < (
int)
m_data.size())
1437 for (
size_t i = 0; i < idx.
size(); i++)
1439 if (idx[i] >= 0 && idx[i] < (
int)
m_data.size())
1527 if (caseinsensitive)
1556 if (elem >= (
int)
m_data.size() || !
m_data[elem].length())
1572 if (elem < 0 || elem >= (
int)
m_data.size())
1575 return m_data[elem].length() != 0;
1590 for (
const auto& val :
m_data)
1591 bytes += val.length() *
sizeof(char);
1593 return bytes +
m_sHeadLine.length() *
sizeof(char);
1613 for (
size_t i = 0; i <
m_data.size(); i++)
1691 for (
size_t i = 0; i <
m_data.size(); i++)
1701 std::string strval =
m_data[i];
1707 std::string strval =
m_data[i];
1814 if (elem >=
m_data.size() && !sValue.length())
1817 if (elem >=
m_data.size())
1845 if (elem >=
m_data.size())
1873 for (
size_t i = 0; i < idx.
size(); i++)
1875 if (idx[i] >= 0 && idx[i] < (
int)
m_data.size())
1945 for (
size_t i = 0; i < idx.
size(); i++)
1947 if (idx[i] >= 0 && idx[i] < (
int)
m_data.size())
2037 if (caseinsensitive)
2082 if (elem < 0 || elem >= (
int)
m_data.size())
2101 bytes += val.length() *
sizeof(char);
2103 return size() *
sizeof(int) + bytes +
m_sHeadLine.length() *
sizeof(char);
2201 for (
size_t i = 0; i <
m_data.size(); i++)
2250 for (
size_t i = 0; i < vCategories.size(); i++)
2282 if (!col || (col->m_type != type && !col->size()))
2287 sHead = col->m_sHeadLine;
2310 col->m_sHeadLine = sHead;
2327 if (!col || (!col->size() && col->m_type != type))
2333 if (col->m_type == type
2343 if (convertedCol != col.get())
2344 col.reset(convertedCol);
2363 if (!col || (!col->size() && col->m_type != type))
2369 if (col->m_type == type)
2372 std::string sHeadLine = col->m_sHeadLine;
2374 if (!sHeadLine.length())
2382 col->m_sHeadLine = sHeadLine;
2388 col->m_sHeadLine = sHeadLine;
2394 col->m_sHeadLine = sHeadLine;
2400 col->m_sHeadLine = sHeadLine;
2406 col->m_sHeadLine = sHeadLine;
std::string toLowerCase(const std::string &)
Converts uppercase to lowercase letters.
A table column containing categorical values.
virtual std::string getValueAsInternalString(size_t elem) const override
Returns the contents as an internal string (i.e. without quotation marks).
CategoricalColumn()
Default constructor. Sets only the column's type.
virtual bool asBool(int elem) const override
Interprets the value as a boolean.
virtual void assign(const TableColumn *column) override
Assign another TableColumn's contents to this table column.
virtual size_t getBytes() const override
Calculates the number of bytes occupied by this column.
virtual void removeElements(size_t pos, size_t elem)
Removes the selected number of elements from the column and moving all following items forward.
std::vector< std::string > m_categories
virtual mu::value_type getValue(size_t elem) const override
Returns always NaN, because this conversion is not possible.
virtual std::string getValueAsParserString(size_t elem) const override
Returns the contents as parser string (i.e. with quotation marks).
virtual void insertElements(size_t pos, size_t elem)
Inserts as many as the selected elements at the desired position, if the column is already larger tha...
virtual void resize(size_t elem) override
Resizes the internal array.
virtual void setValue(size_t elem, const std::string &sValue) override
Set a single string value.
void setCategories(const std::vector< std::string > &vCategories)
Replaces the internal categories with new categories.
virtual std::string getValueAsString(size_t elem) const override
Returns the selected value or an empty string, if the value does not exist.
virtual void insert(const VectorIndex &idx, const TableColumn *column) override
Insert the contents of the passed column at the specified positions.
virtual void deleteElements(const VectorIndex &idx) override
Delete the specified elements.
virtual int compare(int i, int j, bool caseinsensitive) const override
Returns 0, if both elements are equal, -1 if element i is smaller than element j and 1 otherwise.
virtual size_t size() const override
Returns the number of elements in this column (will also count invalid ones).
virtual std::string getValueAsStringLiteral(size_t elem) const override
Returns the contents as parser string (i.e. with quotation marks).
virtual bool isValid(int elem) const override
Returns true, if the selected element is a valid value.
std::vector< int > m_data
virtual TableColumn * convert(ColumnType type=TableColumn::TYPE_NONE) override
Returns the contents of this column converted to the new column type. Might even return itself.
virtual void appendElements(size_t elem)
Appends the number of elements.
A table column containing numerical values formatted as dates and times.
virtual size_t size() const override
Return the number of elements in this column (will also count invalid ones).
virtual bool isValid(int elem) const override
Returns true, if the selected element is a valid value.
virtual std::string getValueAsStringLiteral(size_t elem) const override
Returns the contents as parser string (i.e. with quotation marks).
virtual int compare(int i, int j, bool unused) const override
Returns 0, if both elements are equal, -1 if element i is smaller than element j and 1 otherwise.
virtual void setValue(size_t elem, const std::string &sValue) override
Set a single string value.
virtual bool asBool(int elem) const override
Interprets the value as a boolean.
virtual void insertElements(size_t pos, size_t elem) override
Inserts as many as the selected elements at the desired position, if the column is already larger tha...
virtual mu::value_type getValue(size_t elem) const override
Returns the selected value as a numerical type or an invalid value, if it does not exist.
virtual std::string getValueAsString(size_t elem) const override
Returns the selected value as a string or a default value, if it does not exist.
virtual TableColumn * convert(ColumnType type=TableColumn::TYPE_NONE) override
Returns the contents of this column converted to the new column type. Might even return itself.
virtual std::string getValueAsInternalString(size_t elem) const override
Returns the contents as an internal string (i.e. without quotation marks).
DateTimeColumn()
Default constructor. Sets only the column's type.
virtual void removeElements(size_t pos, size_t elem) override
Removes the selected number of elements from the column and moving all following items forward.
virtual void resize(size_t elem) override
Resizes the internal array.
std::vector< double > m_data
virtual void insert(const VectorIndex &idx, const TableColumn *column) override
Insert the contents of the passed column at the specified positions.
virtual void appendElements(size_t elem) override
Appends the number of elements.
virtual std::string getValueAsParserString(size_t elem) const override
Returns the contents as parser string (i.e. with quotation marks).
virtual void assign(const TableColumn *column) override
Assign another TableColumn's contents to this table column.
virtual void deleteElements(const VectorIndex &idx) override
Delete the specified elements.
A table column containing logical values.
virtual std::string getValueAsInternalString(size_t elem) const override
Returns the contents as an internal string (i.e. without quotation marks).
virtual mu::value_type getValue(size_t elem) const override
Returns the selected value as a numerical type or an invalid value, if it does not exist.
virtual void insert(const VectorIndex &idx, const TableColumn *column) override
Insert the contents of the passed column at the specified positions.
virtual std::string getValueAsStringLiteral(size_t elem) const override
Returns the contents as parser string (i.e. without quotation marks).
virtual void appendElements(size_t elem) override
Appends the number of elements.
virtual TableColumn * convert(ColumnType type=TableColumn::TYPE_NONE) override
Returns the contents of this column converted to the new column type. Might even return itself.
virtual void setValue(size_t elem, const std::string &sValue) override
Set a single string value.
virtual std::string getValueAsParserString(size_t elem) const override
Returns the contents as parser string (i.e. without quotation marks).
virtual void assign(const TableColumn *column) override
Assign another TableColumn's contents to this table column.
virtual bool asBool(int elem) const override
Interprets the value as a boolean.
virtual size_t size() const override
Return the number of elements in this column (will also count invalid ones).
virtual void removeElements(size_t pos, size_t elem) override
Removes the selected number of elements from the column and moving all following items forward.
virtual void insertElements(size_t pos, size_t elem) override
Inserts as many as the selected elements at the desired position, if the column is already larger tha...
virtual int compare(int i, int j, bool unused) const override
Returns 0, if both elements are equal, -1 if element i is smaller than element j and 1 otherwise.
virtual std::string getValueAsString(size_t elem) const override
Returns the selected value as a string or a default value, if it does not exist.
virtual void deleteElements(const VectorIndex &idx) override
Delete the specified elements.
virtual void resize(size_t elem) override
Resizes the internal array.
LogicalColumn()
Default constructor. Sets only the column's type.
virtual bool isValid(int elem) const override
Returns true, if the selected element is a valid value.
std::vector< LogicalValue > m_data
static NumeReKernel * getInstance()
This static member function returns a a pointer to the singleton instance of the kernel.
A table column containing only strings as values.
virtual std::string getValueAsString(size_t elem) const override
Returns the selected value or an empty string, if the value does not exist.
virtual std::string getValueAsStringLiteral(size_t elem) const override
Returns the contents as parser string (i.e. with quotation marks).
virtual bool asBool(int elem) const override
Interprets the value as a boolean.
virtual std::string getValueAsParserString(size_t elem) const override
Returns the contents as parser string (i.e. with quotation marks).
virtual void insertElements(size_t pos, size_t elem)
Inserts as many as the selected elements at the desired position, if the column is already larger tha...
virtual void deleteElements(const VectorIndex &idx) override
Delete the specified elements.
virtual size_t size() const override
Returns the number of elements in this column (will also count invalid ones).
virtual std::string getValueAsInternalString(size_t elem) const override
Returns the contents as an internal string (i.e. without quotation marks).
virtual int compare(int i, int j, bool caseinsensitive) const override
Returns 0, if both elements are equal, -1 if element i is smaller than element j and 1 otherwise.
virtual bool isValid(int elem) const override
Returns true, if the selected element is a valid value.
std::vector< std::string > m_data
StringColumn()
Default constructor. Sets only the column's type.
virtual size_t getBytes() const override
Calculates the number of bytes occupied by this column.
virtual void resize(size_t elem) override
Resizes the internal array.
virtual void appendElements(size_t elem)
Appends the number of elements.
virtual mu::value_type getValue(size_t elem) const override
Returns always NaN, because this conversion is not possible.
virtual TableColumn * convert(ColumnType type=TableColumn::TYPE_NONE) override
Returns the contents of this column converted to the new column type. Might even return itself.
virtual void setValue(size_t elem, const std::string &sValue) override
Set a single string value.
virtual void insert(const VectorIndex &idx, const TableColumn *column) override
Insert the contents of the passed column at the specified positions.
virtual void assign(const TableColumn *column) override
Assign another TableColumn's contents to this table column.
virtual void removeElements(size_t pos, size_t elem)
Removes the selected number of elements from the column and moving all following items forward.
Common exception class for all exceptions thrown in NumeRe.
@ CANNOT_ASSIGN_COLUMN_OF_DIFFERENT_TYPE
A table column containing only numerical values.
virtual bool asBool(int elem) const override
Interprets the value as a boolean.
virtual int compare(int i, int j, bool unused) const override
Returns 0, if both elements are equal, -1 if element i is smaller than element j and 1 otherwise.
virtual void deleteElements(const VectorIndex &idx) override
Delete the specified elements.
virtual void appendElements(size_t elem) override
Appends the number of elements.
virtual std::string getValueAsString(size_t elem) const override
Returns the selected value as a string or a default value, if it does not exist.
ValueColumn()
Default constructor. Sets only the type of the column.
virtual std::string getValueAsParserString(size_t elem) const override
Returns the contents as parser string (i.e. without quotation marks).
virtual TableColumn * convert(ColumnType type=TableColumn::TYPE_NONE) override
Returns the contents of this column converted to the new column type. Might even return itself.
virtual std::string getValueAsStringLiteral(size_t elem) const override
Returns the contents as parser string (i.e. without quotation marks).
std::vector< mu::value_type > m_data
virtual void setValue(size_t elem, const std::string &sValue) override
Set a single string value.
virtual void insert(const VectorIndex &idx, const TableColumn *column) override
Insert the contents of the passed column at the specified positions.
virtual void insertElements(size_t pos, size_t elem) override
Inserts as many as the selected elements at the desired position, if the column is already larger tha...
virtual mu::value_type getValue(size_t elem) const override
Returns the selected value as a numerical type or an invalid value, if it does not exist.
virtual std::string getValueAsInternalString(size_t elem) const override
Returns the contents as an internal string (i.e. without quotation marks).
virtual bool isValid(int elem) const override
Returns true, if the selected element is a valid value.
virtual size_t size() const override
Return the number of elements in this column (will also count invalid ones).
virtual void resize(size_t elem) override
Resizes the internal array.
virtual void assign(const TableColumn *column) override
Assign another TableColumn's contents to this table column.
virtual void removeElements(size_t pos, size_t elem) override
Removes the selected number of elements from the column and moving all following items forward.
This class abstracts all the index logics, i.e. the logical differences between single indices and in...
void setOpenEndIndex(int nLast) const
This member function can be used to replace the open end state with a defined index value although th...
int last() const
This member function returns the last index value, which can be reached by the values stored internal...
size_t size() const
This member function returns the size of the indices stored in this class.
bool isExpanded() const
This member function determines, whether the indices are calculated or actual vectorial indices.
int & front()
This member function returns a reference to the first index value stored internally.
MUP_BASETYPE value_type
The numeric datatype used by the parser.
bool isnan(const value_type &v)
std::vector< double > real(const std::vector< value_type > &vVec)
Abstract table column, which allows using it to compose the data table in each Memory instance.
void shrink()
Shrink the column by removing all invalid elements from the end.
std::vector< std::string > getValueAsInternalString(const VectorIndex &idx) const
Returns the table column's contents as a vector containing internal strings.
TableColumn * copy() const
Simplification wrapper around the indiced copy method to copy the whole column.
virtual TableColumn * convert(ColumnType type=TableColumn::TYPE_NONE)=0
std::vector< mu::value_type > getValue(const VectorIndex &idx) const
Return the table column's contents as a vector of numerical types.
static std::string getDefaultColumnHead(size_t colNo)
Creates a default column headline for a column, which can be used without an instance of this class.
static std::string typeToString(ColumnType type)
Converts the passed ColumnType value to a string representation.
void setValue(const VectorIndex &idx, const std::vector< std::string > &vValue)
Sets a string vector at the specified indices.
long long int intCast(const std::complex< double > &)
Casts the real part of the complex number to an integer and avoids rounding errors.
std::string toString(int)
Converts an integer to a string without the Settings bloat.
std::unique_ptr< TableColumn > TblColPtr
Typedef for simplifying the usage of a smart pointer in combination with a TableColumn instance.
void convert_for_overwrite(TblColPtr &col, size_t colNo, TableColumn::ColumnType type)
This function deletes the contents of a column, if necessary, and creates a new column with the corre...
void convert_if_empty(TblColPtr &col, size_t colNo, TableColumn::ColumnType type)
Tries to convert a column if the column does not contain any data (with the exception of the header).
bool convert_if_needed(TblColPtr &col, size_t colNo, TableColumn::ColumnType type)
Tries to convert a column into the selected column, if possible.