NumeRe v1.1.4
NumeRe: Framework für Numerische Rechnungen
|
A table column containing categorical values. More...
#include <tablecolumnimpl.hpp>
Public Member Functions | |
CategoricalColumn () | |
Default constructor. Sets only the column's type. More... | |
CategoricalColumn (size_t nElem) | |
Generalized constructor. Will prepare a column with the specified size. More... | |
virtual | ~CategoricalColumn () |
virtual std::string | getValueAsString (size_t elem) const override |
Returns the selected value or an empty string, if the value does not exist. More... | |
virtual std::string | getValueAsInternalString (size_t elem) const override |
Returns the contents as an internal string (i.e. without quotation marks). More... | |
virtual std::string | getValueAsParserString (size_t elem) const override |
Returns the contents as parser string (i.e. with quotation marks). More... | |
virtual std::string | getValueAsStringLiteral (size_t elem) const override |
Returns the contents as parser string (i.e. with quotation marks). More... | |
virtual mu::value_type | getValue (size_t elem) const override |
Returns always NaN, because this conversion is not possible. More... | |
virtual void | setValue (size_t elem, const std::string &sValue) override |
Set a single string value. More... | |
virtual void | setValue (size_t elem, const mu::value_type &vValue) override |
Set a single numerical value. More... | |
virtual CategoricalColumn * | copy (const VectorIndex &idx) const override |
Creates a copy of the selected part of this column. Can be used for simple extraction into a new table. More... | |
virtual void | assign (const TableColumn *column) override |
Assign another TableColumn's contents to this table column. More... | |
virtual void | insert (const VectorIndex &idx, const TableColumn *column) override |
Insert the contents of the passed column at the specified positions. More... | |
virtual void | deleteElements (const VectorIndex &idx) override |
Delete the specified elements. More... | |
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 than the starting position. More... | |
virtual void | appendElements (size_t elem) |
Appends the number of elements. More... | |
virtual void | removeElements (size_t pos, size_t elem) |
Removes the selected number of elements from the column and moving all following items forward. More... | |
virtual void | resize (size_t elem) override |
Resizes the internal array. More... | |
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. More... | |
virtual bool | isValid (int elem) const override |
Returns true, if the selected element is a valid value. More... | |
virtual bool | asBool (int elem) const override |
Interprets the value as a boolean. More... | |
virtual size_t | getBytes () const override |
Calculates the number of bytes occupied by this column. More... | |
virtual size_t | size () const override |
Returns the number of elements in this column (will also count invalid ones). More... | |
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. More... | |
const std::vector< std::string > & | getCategories () const |
Returns the list of internal categories to be used within expressions and code. More... | |
void | setCategories (const std::vector< std::string > &vCategories) |
Replaces the internal categories with new categories. More... | |
Public Member Functions inherited from TableColumn | |
TableColumn () | |
virtual | ~TableColumn () |
std::vector< std::string > | getValueAsString (const VectorIndex &idx) const |
Return the table column's contents as a vector of strings. More... | |
std::vector< std::string > | getValueAsInternalString (const VectorIndex &idx) const |
Returns the table column's contents as a vector containing internal strings. More... | |
std::vector< mu::value_type > | getValue (const VectorIndex &idx) const |
Return the table column's contents as a vector of numerical types. More... | |
virtual std::string | getValueAsString (size_t elem) const =0 |
virtual std::string | getValueAsInternalString (size_t elem) const =0 |
virtual std::string | getValueAsParserString (size_t elem) const =0 |
virtual std::string | getValueAsStringLiteral (size_t elem) const =0 |
virtual mu::value_type | getValue (size_t elem) const =0 |
void | setValue (const VectorIndex &idx, const std::vector< std::string > &vValue) |
Sets a string vector at the specified indices. More... | |
void | setValue (const VectorIndex &idx, const std::vector< mu::value_type > &vValue) |
Sets a numerical vector at the specified indices. More... | |
void | setValue (const VectorIndex &idx, mu::value_type *_dData, unsigned int _nNum) |
Sets a plain numerical array at the specified indices. More... | |
virtual void | setValue (size_t elem, const std::string &sValue)=0 |
virtual void | setValue (size_t elem, const mu::value_type &vValue)=0 |
TableColumn * | copy () const |
Simplification wrapper around the indiced copy method to copy the whole column. More... | |
virtual TableColumn * | copy (const VectorIndex &idx) const =0 |
virtual void | assign (const TableColumn *column)=0 |
virtual void | insert (const VectorIndex &idx, const TableColumn *column)=0 |
virtual void | deleteElements (const VectorIndex &idx)=0 |
void | shrink () |
Shrink the column by removing all invalid elements from the end. More... | |
virtual void | insertElements (size_t pos, size_t elem)=0 |
virtual void | appendElements (size_t elem)=0 |
virtual void | removeElements (size_t pos, size_t elem)=0 |
virtual void | resize (size_t elem)=0 |
virtual int | compare (int i, int j, bool flag) const =0 |
virtual bool | isValid (int elem) const =0 |
virtual bool | asBool (int elem) const =0 |
virtual size_t | size () const =0 |
virtual size_t | getBytes () const =0 |
size_t | getNumFilledElements () const |
Return the number of actual filled elements in this column, which can be different from the actual size of the column. More... | |
virtual TableColumn * | convert (ColumnType type=TableColumn::TYPE_NONE)=0 |
Private Types | |
enum | { CATEGORICAL_NAN = -1 } |
Private Attributes | |
std::vector< int > | m_data |
std::vector< std::string > | m_categories |
Additional Inherited Members | |
Public Types inherited from TableColumn | |
enum | ColumnType { TYPE_NONE , VALUELIKE , TYPE_VALUE , TYPE_DATETIME , TYPE_LOGICAL , TYPE_CATEGORICAL , STRINGLIKE , TYPE_STRING , TYPE_MIXED } |
Static Public Member Functions inherited from TableColumn | |
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. More... | |
static std::string | typeToString (ColumnType type) |
Converts the passed ColumnType value to a string representation. More... | |
static ColumnType | stringToType (const std::string &sType) |
Converts the passed string representation to a ColumnType value. More... | |
static std::vector< std::string > | getTypesAsString () |
Returns a list of all available column types as strings. More... | |
Public Attributes inherited from TableColumn | |
std::string | m_sHeadLine |
ColumnType | m_type |
A table column containing categorical values.
Definition at line 364 of file tablecolumnimpl.hpp.
|
private |
Enumerator | |
---|---|
CATEGORICAL_NAN |
Definition at line 367 of file tablecolumnimpl.hpp.
|
inline |
Default constructor. Sets only the column's type.
Definition at line 377 of file tablecolumnimpl.hpp.
References TableColumn::m_type, and TableColumn::TYPE_CATEGORICAL.
Referenced by copy().
|
inline |
Generalized constructor. Will prepare a column with the specified size.
nElem | size_t |
Definition at line 389 of file tablecolumnimpl.hpp.
References resize().
|
inlinevirtual |
Definition at line 394 of file tablecolumnimpl.hpp.
|
virtual |
Appends the number of elements.
elem | size_t |
Implements TableColumn.
Definition at line 1982 of file tablecolumnimpl.cpp.
References CATEGORICAL_NAN, and m_data.
|
overridevirtual |
Interprets the value as a boolean.
elem | int |
Implements TableColumn.
Definition at line 2080 of file tablecolumnimpl.cpp.
References CATEGORICAL_NAN, m_categories, and m_data.
|
overridevirtual |
Assign another TableColumn's contents to this table column.
column | const TableColumn* |
Implements TableColumn.
Definition at line 1893 of file tablecolumnimpl.cpp.
References SyntaxError::CANNOT_ASSIGN_COLUMN_OF_DIFFERENT_TYPE, m_categories, m_data, TableColumn::m_sHeadLine, TableColumn::m_type, TableColumn::TYPE_CATEGORICAL, and TableColumn::typeToString().
|
overridevirtual |
Returns 0, if both elements are equal, -1 if element i is smaller than element j and 1 otherwise.
i | int |
j | int |
caseinsensitive | bool |
Implements TableColumn.
Definition at line 2032 of file tablecolumnimpl.cpp.
References m_categories, m_data, max, and toLowerCase().
|
overridevirtual |
Returns the contents of this column converted to the new column type. Might even return itself.
type | ColumnType |
Implements TableColumn.
Definition at line 2116 of file tablecolumnimpl.cpp.
References CATEGORICAL_NAN, CONVTYPE_DATE_TIME, CONVTYPE_LOGICAL, CONVTYPE_NONE, CONVTYPE_VALUE, TableColumn::getValueAsInternalString(), isConvertible(), m_categories, m_data, TableColumn::m_sHeadLine, VectorIndex::OPEN_END, replaceAll(), TableColumn::setValue(), StrToCmplx(), StrToLogical(), StrToTime(), to_double(), toLowerCase(), TableColumn::TYPE_CATEGORICAL, TableColumn::TYPE_DATETIME, TableColumn::TYPE_LOGICAL, TableColumn::TYPE_NONE, TableColumn::TYPE_STRING, and TableColumn::TYPE_VALUE.
|
overridevirtual |
Creates a copy of the selected part of this column. Can be used for simple extraction into a new table.
idx | const VectorIndex& |
Implements TableColumn.
Definition at line 1866 of file tablecolumnimpl.cpp.
References CategoricalColumn(), m_categories, m_data, TableColumn::m_sHeadLine, VectorIndex::setOpenEndIndex(), VectorIndex::size(), and size().
|
overridevirtual |
Delete the specified elements.
idx | const VectorIndex& |
Implements TableColumn.
Definition at line 1933 of file tablecolumnimpl.cpp.
References CATEGORICAL_NAN, VectorIndex::front(), VectorIndex::isExpanded(), VectorIndex::last(), m_categories, m_data, VectorIndex::setOpenEndIndex(), TableColumn::shrink(), VectorIndex::size(), and size().
|
overridevirtual |
Calculates the number of bytes occupied by this column.
Implements TableColumn.
Definition at line 2096 of file tablecolumnimpl.cpp.
References m_categories, TableColumn::m_sHeadLine, and size().
|
inline |
Returns the list of internal categories to be used within expressions and code.
Definition at line 443 of file tablecolumnimpl.hpp.
References m_categories.
|
overridevirtual |
Returns always NaN, because this conversion is not possible.
elem | size_t |
Implements TableColumn.
Definition at line 1795 of file tablecolumnimpl.cpp.
References CATEGORICAL_NAN, and m_data.
|
overridevirtual |
Returns the contents as an internal string (i.e. without quotation marks).
elem | size_t |
Implements TableColumn.
Definition at line 1750 of file tablecolumnimpl.cpp.
References CATEGORICAL_NAN, m_categories, and m_data.
Referenced by getValueAsParserString(), and getValueAsStringLiteral().
|
overridevirtual |
Returns the contents as parser string (i.e. with quotation marks).
elem | size_t |
Implements TableColumn.
Definition at line 1767 of file tablecolumnimpl.cpp.
References getValueAsInternalString().
|
overridevirtual |
Returns the selected value or an empty string, if the value does not exist.
elem | size_t |
Implements TableColumn.
Definition at line 1733 of file tablecolumnimpl.cpp.
References CATEGORICAL_NAN, m_data, and toString().
|
overridevirtual |
Returns the contents as parser string (i.e. with quotation marks).
elem | size_t |
Implements TableColumn.
Definition at line 1781 of file tablecolumnimpl.cpp.
References getValueAsInternalString().
|
overridevirtual |
Insert the contents of the passed column at the specified positions.
idx | const VectorIndex& |
column | const TableColumn* |
Implements TableColumn.
Definition at line 1915 of file tablecolumnimpl.cpp.
References SyntaxError::CANNOT_ASSIGN_COLUMN_OF_DIFFERENT_TYPE, TableColumn::getValueAsInternalString(), TableColumn::m_sHeadLine, TableColumn::m_type, VectorIndex::OPEN_END, TableColumn::setValue(), TableColumn::TYPE_CATEGORICAL, and TableColumn::typeToString().
|
virtual |
Inserts as many as the selected elements at the desired position, if the column is already larger than the starting position.
pos | size_t |
elem | size_t |
Implements TableColumn.
Definition at line 1968 of file tablecolumnimpl.cpp.
References CATEGORICAL_NAN, and m_data.
|
overridevirtual |
Returns true, if the selected element is a valid value.
elem | int |
Implements TableColumn.
Definition at line 2064 of file tablecolumnimpl.cpp.
References CATEGORICAL_NAN, and m_data.
|
virtual |
Removes the selected number of elements from the column and moving all following items forward.
pos | size_t |
elem | size_t |
Implements TableColumn.
Definition at line 1998 of file tablecolumnimpl.cpp.
References m_data.
|
overridevirtual |
Resizes the internal array.
elem | size_t |
Implements TableColumn.
Definition at line 2012 of file tablecolumnimpl.cpp.
References CATEGORICAL_NAN, and m_data.
Referenced by CategoricalColumn().
void CategoricalColumn::setCategories | ( | const std::vector< std::string > & | vCategories | ) |
Replaces the internal categories with new categories.
vCategories | const std::vector<std::string>& |
Definition at line 2240 of file tablecolumnimpl.cpp.
References m_categories.
|
overridevirtual |
Set a single numerical value.
elem | size_t |
vValue | const mu::value_type& |
Implements TableColumn.
Definition at line 1840 of file tablecolumnimpl.cpp.
References CATEGORICAL_NAN, NumeReKernel::getInstance(), intCast(), isInt(), mu::isnan(), m_categories, m_data, setValue(), and toString().
|
overridevirtual |
Set a single string value.
elem | size_t |
sValue | const std::string& |
Implements TableColumn.
Definition at line 1812 of file tablecolumnimpl.cpp.
References CATEGORICAL_NAN, m_categories, and m_data.
Referenced by setValue().
|
inlineoverridevirtual |
Returns the number of elements in this column (will also count invalid ones).
Implements TableColumn.
Definition at line 428 of file tablecolumnimpl.hpp.
References m_data.
Referenced by copy(), deleteElements(), Memory::getBins(), and getBytes().
|
private |
Definition at line 370 of file tablecolumnimpl.hpp.
Referenced by asBool(), assign(), compare(), convert(), copy(), deleteElements(), getBytes(), getCategories(), getValueAsInternalString(), setCategories(), and setValue().
|
private |
Definition at line 369 of file tablecolumnimpl.hpp.
Referenced by appendElements(), asBool(), assign(), compare(), convert(), copy(), deleteElements(), getValue(), getValueAsInternalString(), getValueAsString(), insertElements(), isValid(), removeElements(), resize(), setValue(), and size().