Describes the high level type of data containing tuples or records. More...
#include <RecordType.h>
Public Member Functions | |
RecordType (const util::Parameters ¶meters, const std::string &typestr, const std::vector< TypePtr > &types, const util::RecordLookupPtr &recordlookup) | |
Create an RecordArray with a full set of parameters. More... | |
RecordType (const util::Parameters ¶meters, const std::string &typestr, const std::vector< TypePtr > &types) | |
Creates a RecordArray without a recordlookup (set it to nullptr ). More... | |
const std::vector< TypePtr > | types () const |
The Type of each field (in order). More... | |
const util::RecordLookupPtr | recordlookup () const |
A std::shared_ptr<std::vector<std::string>> optional list of key names. More... | |
bool | istuple () const |
Returns true if recordlookup is nullptr ; false otherwise. More... | |
std::string | tostring_part (const std::string &indent, const std::string &pre, const std::string &post) const override |
Internal function to build an output string for tostring. More... | |
const TypePtr | shallow_copy () const override |
Copies this Type without copying any hierarchically nested types. More... | |
bool | equal (const TypePtr &other, bool check_parameters) const override |
Returns true if this type is equal to other ; false otherwise. More... | |
int64_t | numfields () const override |
The number of fields in the first nested tuple or records or -1 if this array does not contain a RecordType. More... | |
int64_t | fieldindex (const std::string &key) const override |
The position of a tuple or record key name if this array contains a RecordType. More... | |
const std::string | key (int64_t fieldindex) const override |
The record name associated with a given field index or the tuple index as a string (e.g. "0" , "1" , "2" ) if a tuple. More... | |
bool | haskey (const std::string &key) const override |
Returns true if the type contains a RecordType with the specified key ; false otherwise. More... | |
const std::vector< std::string > | keys () const override |
A list of RecordType keys or an empty list if this type does not contain a RecordType. More... | |
const ContentPtr | empty () const override |
Returns an empty array (Content) with this type. More... | |
const TypePtr | field (int64_t fieldindex) const |
Returns the field at a given index. More... | |
const TypePtr | field (const std::string &key) const |
Returns the field with a given key name. More... | |
const std::vector< TypePtr > | fields () const |
Returns all the fields. More... | |
const std::vector< std::pair< std::string, TypePtr > > | fielditems () const |
Returns key, field pairs for all fields. More... | |
const TypePtr | astuple () const |
Returns this RecordType without recordlookup, converting any records into tuples. More... | |
![]() | |
Type (const util::Parameters ¶meters, const std::string &typestr) | |
Called by all subclass constructors; assigns parameters and typestr upon construction. More... | |
virtual | ~Type () |
Virtual destructor acts as a first non-inline virtual function that determines a specific translation unit in which vtable shall be emitted. More... | |
const util::Parameters | parameters () const |
Get one parameter from this type. More... | |
void | setparameters (const util::Parameters ¶meters) |
Assign one parameter for this type (in-place). More... | |
const std::string | parameter (const std::string &key) const |
Custom parameters inherited from the Content that this type describes. More... | |
void | setparameter (const std::string &key, const std::string &value) |
Assign one parameter to this type (in-place). More... | |
bool | parameter_equals (const std::string &key, const std::string &value) const |
Returns true if the parameter associated with key exists and is equal to value ; false otherwise. More... | |
bool | parameters_equal (const util::Parameters &other, bool check_all) const |
Returns true if all parameters of this type are equal to the other parameters. More... | |
bool | parameter_isstring (const std::string &key) const |
Returns true if the parameter associated with key is a string; false otherwise. More... | |
bool | parameter_isname (const std::string &key) const |
Returns true if the parameter associated with key is a string that matches [A-Za-z_][A-Za-z_0-9]* ; false otherwise. More... | |
const std::string | parameter_asstring (const std::string &key) const |
Returns the parameter associated with key as a string if parameter_isstring; raises an error otherwise. More... | |
const std::string | tostring () const |
Returns a string representation of the type as a Datashape or its typestr overload (if non-empty). More... | |
const std::string | compare (TypePtr supertype) |
Returns a string showing a side-by-side comparison of two types, highlighting differences. More... | |
const std::string | typestr () const |
Optional string that overrides the default string representation (missing if empty). More... | |
Additional Inherited Members | |
![]() | |
bool | get_typestr (std::string &output) const |
Internal function that replaces output in-place with the typestr and returns true if the typestr is not missing (i.e. empty); otherwise, it leaves output untouched and returns false . More... | |
bool | parameters_empty () const |
Internal function to determine if there are no parameters except __categorical__ . More... | |
std::string | wrap_categorical (const std::string &output) const |
Internal function that wraps output with categorical[type= and ] if __categorical__ is true ; passes through otherwise. More... | |
const std::string | string_parameters () const |
Internal function to format parameters as part of the tostring string. More... | |
![]() | |
util::Parameters | parameters_ |
See parameters. More... | |
const std::string | typestr_ |
See typestr. More... | |
Describes the high level type of data containing tuples or records.
RecordArray nodes have this type.
RecordType | ( | const util::Parameters & | parameters, |
const std::string & | typestr, | ||
const std::vector< TypePtr > & | types, | ||
const util::RecordLookupPtr & | recordlookup | ||
) |
Create an RecordArray with a full set of parameters.
parameters | Custom parameters inherited from the Content that this type describes. |
typestr | Optional string that overrides the default string representation (missing if empty). |
types | The Type of each field (in order). |
recordlookup | A std::shared_ptr<std::vector<std::string>> optional list of key names. If absent (nullptr ), the data are tuples; otherwise, they are records. The number of names must match the number of types. |
RecordType | ( | const util::Parameters & | parameters, |
const std::string & | typestr, | ||
const std::vector< TypePtr > & | types | ||
) |
Creates a RecordArray without a recordlookup (set it to nullptr
).
See RecordType for a full list of parameters.
const TypePtr astuple | ( | ) | const |
Returns this RecordType without recordlookup, converting any records into tuples.
|
overridevirtual |
|
overridevirtual |
Returns true
if this type is equal to other
; false
otherwise.
other | The other Type. |
check_parameters | If true , types must have the same parameters to be considered equal; if false , types do not check parameters. |
Implements Type.
const TypePtr field | ( | int64_t | fieldindex | ) | const |
Returns the field at a given index.
Equivalent to types[fieldindex]
.
const TypePtr field | ( | const std::string & | key | ) | const |
Returns the field with a given key name.
Equivalent to types[fieldindex(key)]
.
|
overridevirtual |
The position of a tuple or record key name if this array contains a RecordType.
Implements Type.
const std::vector<std::pair<std::string, TypePtr> > fielditems | ( | ) | const |
Returns key, field pairs for all fields.
const std::vector<TypePtr> fields | ( | ) | const |
Returns all the fields.
Equivalent to types
.
|
overridevirtual |
Returns true
if the type contains a RecordType with the specified key
; false
otherwise.
Implements Type.
bool istuple | ( | ) | const |
Returns true
if recordlookup is nullptr
; false
otherwise.
|
overridevirtual |
The record name associated with a given field index or the tuple index as a string (e.g. "0"
, "1"
, "2"
) if a tuple.
Raises an error if the array does not contain a RecordType.
Implements Type.
|
overridevirtual |
A list of RecordType keys or an empty list if this type does not contain a RecordType.
Implements Type.
|
overridevirtual |
The number of fields in the first nested tuple or records or -1
if this array does not contain a RecordType.
Implements Type.
const util::RecordLookupPtr recordlookup | ( | ) | const |
A std::shared_ptr<std::vector<std::string>>
optional list of key names.
If absent (nullptr
), the data are tuples; otherwise, they are records. The number of names must match the number of types.
|
overridevirtual |
|
overridevirtual |