![]() |
Trading System API
3.0
Library for Simulating and Deploying Trading and Investment Strategies
|
Defines the columnar structure of a table. Each column has a name, data type and field size. Instances of this class may also be used to describe the field structure in records. More...
#include <TSADataDef.h>
Public Member Functions | |
column_defs (void) | |
Constructor. | |
column_defs (column_defs &&) | |
Constructor. | |
column_defs (const std::string &column_definition_string) | |
Constructor. Initializes self according to column_definition_string. | |
column_defs (const char *column_definition_string) | |
Constructor. Initializes self according to column_definition_string. | |
column_defs (const column_defs &) | |
Copy constructor. | |
void | add_column (type_t column_type, const std::string &column_name, size_t length=1) |
Adds a column to self. Using this member it is possible to add columns individually without using a column-definition-string. More... | |
void | clear () |
Clears the object. defined() will return false, and size() will return 0. | |
size_t | column_count (void) const |
Returns the number of columns in self. | |
bool | column_exists (const std::string column_name) const |
Returns true if a column with given name exists. | |
size_t | column_field_length (size_t position) const |
Returns the length, in bytes, of the column field at given ordinal position. Note that this value is only relevant for fields of type string. More... | |
size_t | column_field_length (const std::string &column_name) const |
Returns the length of the field with given column_name. Note that this value is only relevant for fields of type string. More... | |
const std::string & | column_name (size_t position) const |
Returns the name of the field at given ordinal position. | |
size_t | column_number (const std::string column_name) const |
Returns the index of the column with given name. | |
type_t | column_type (size_t position) const |
Returns the type of the column at given ordinal position. | |
type_t | column_type (const std::string &field_name) const |
Returns the type of the column with given column_name. More... | |
bool | defined (void) const |
Returns true if self is not empty (has column information). | |
void | from_string (const std::string &column_definition_string) |
Initializes self according to column_definition_string. More... | |
bool | has_pointer_field (void) const |
Returns true if self contains a column that is pointer type such as: type_t::void_ptr or type_t::object_ptr. More... | |
bool | is_equal (const column_defs &other) |
Returns true if self is equal, in every way, to other. | |
void | operator= (const column_defs &other) |
Assignment operator. | |
void | remove_column (const std::string &column_name) |
Removes the column with given column_name. | |
size_t | size (void) const |
Returns the number of columns in self. | |
std::string | to_string (void) const |
Returns self as a column-definition-string. | |
![]() | |
object (void) | |
Constructor. | |
virtual | ~object (void) |
Destructor. | |
const char * | class_name (void) const |
Returns the class name as returned by the 'Real Time Type Information' (RTTI) mechanism. More... | |
bool | has_same_class_as (const object &other) const |
Returns true if self has the same type as other object. More... | |
Defines the columnar structure of a table. Each column has a name, data type and field size. Instances of this class may also be used to describe the field structure in records.
Note that the column structure of tables must not describe a record timestamp column. Since TS-API is built specifically for working with timeseries, a timestamp column is implicit to every tables.
The fields types are limited to the types declared by tsa::type_t with the exception of type_t::void_ptr. Supported types and corresponding type characters are :
Objects of this type can be initialized by a data-definition-string. This string must provide a comma separated list of column names. Each column name must be complemented by a colon and a character corresponding to the column type. For example:
initializes the object with 4 fields of type float64 (double). float64 is the default type if no type information is given. So writing:
would have the same effect as the line above.
When declaring a string field, it is necessary to add the maximum number of characters a string can have in addition to the type such as:
.
void tsa::column_defs::add_column | ( | type_t | column_type, |
const std::string & | column_name, | ||
size_t | length = 1 |
||
) |
Adds a column to self. Using this member it is possible to add columns individually without using a column-definition-string.
column_type | Type of the column. |
column_name | Name of the column. |
length | The length of the fiels (max number of characters in string fields). |
size_t tsa::column_defs::column_field_length | ( | size_t | position | ) | const |
Returns the length, in bytes, of the column field at given ordinal position. Note that this value is only relevant for fields of type string.
position | Zero-based index of the column. |
size_t tsa::column_defs::column_field_length | ( | const std::string & | column_name | ) | const |
Returns the length of the field with given column_name. Note that this value is only relevant for fields of type string.
column_name | Name of the column. |
type_t tsa::column_defs::column_type | ( | const std::string & | field_name | ) | const |
Returns the type of the column with given column_name.
field_name | Name of the field. |
void tsa::column_defs::from_string | ( | const std::string & | column_definition_string | ) |
Initializes self according to column_definition_string.
See the class description for more information about the column_definition_string.
column_definition_string | String that defined column names, types and field size. |
bool tsa::column_defs::has_pointer_field | ( | void | ) | const |
Returns true if self contains a column that is pointer type such as: type_t::void_ptr or type_t::object_ptr.