Type Class Referenceabstract

Abstract superclass of all high level types (flat hierarchy). More...

#include <Type.h>

Inheritance diagram for Type:
ArrayType ListType OptionType PrimitiveType RecordType RegularType UnionType UnknownType

Public Member Functions

 Type (const util::Parameters &parameters, 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...
 
virtual std::string tostring_part (const std::string &indent, const std::string &pre, const std::string &post) const =0
 Internal function to build an output string for tostring. More...
 
virtual const TypePtr shallow_copy () const =0
 Copies this Type without copying any hierarchically nested types. More...
 
virtual bool equal (const TypePtr &other, bool check_parameters) const =0
 Returns true if this type is equal to other; false otherwise. More...
 
virtual int64_t numfields () const =0
 The number of fields in the first nested tuple or records or -1 if this array does not contain a RecordType. More...
 
virtual int64_t fieldindex (const std::string &key) const =0
 The position of a tuple or record key name if this array contains a RecordType. More...
 
virtual const std::string key (int64_t fieldindex) const =0
 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...
 
virtual bool haskey (const std::string &key) const =0
 Returns true if the type contains a RecordType with the specified key; false otherwise. More...
 
virtual const std::vector< std::string > keys () const =0
 A list of RecordType keys or an empty list if this type does not contain a RecordType. More...
 
virtual const ContentPtr empty () const =0
 Returns an empty array (Content) with this type. More...
 
const util::Parameters parameters () const
 Get one parameter from this type. More...
 
void setparameters (const util::Parameters &parameters)
 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...
 

Protected Member Functions

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...
 

Protected Attributes

util::Parameters parameters_
 See parameters. More...
 
const std::string typestr_
 See typestr. More...
 

Detailed Description

Abstract superclass of all high level types (flat hierarchy).

Constructor & Destructor Documentation

◆ Type()

Type ( const util::Parameters parameters,
const std::string &  typestr 
)

Called by all subclass constructors; assigns parameters and typestr upon construction.

◆ ~Type()

virtual ~Type ( )
virtual

Virtual destructor acts as a first non-inline virtual function that determines a specific translation unit in which vtable shall be emitted.

Member Function Documentation

◆ compare()

const std::string compare ( TypePtr  supertype)

Returns a string showing a side-by-side comparison of two types, highlighting differences.

Note
This function does not align types side-by-side.

◆ empty()

virtual const ContentPtr empty ( ) const
pure virtual

Returns an empty array (Content) with this type.

Implemented in RecordType, RegularType, UnionType, ArrayType, ListType, OptionType, PrimitiveType, and UnknownType.

◆ equal()

virtual bool equal ( const TypePtr other,
bool  check_parameters 
) const
pure virtual

Returns true if this type is equal to other; false otherwise.

Parameters
otherThe other Type.
check_parametersIf true, types must have the same parameters to be considered equal; if false, types do not check parameters.

Implemented in RecordType, RegularType, UnionType, ArrayType, ListType, OptionType, PrimitiveType, and UnknownType.

◆ fieldindex()

virtual int64_t fieldindex ( const std::string &  key) const
pure virtual

The position of a tuple or record key name if this array contains a RecordType.

Implemented in RecordType, RegularType, UnionType, ArrayType, ListType, OptionType, PrimitiveType, and UnknownType.

◆ get_typestr()

bool get_typestr ( std::string &  output) const
protected

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.

◆ haskey()

virtual bool haskey ( const std::string &  key) const
pure virtual

Returns true if the type contains a RecordType with the specified key; false otherwise.

Implemented in RecordType, RegularType, UnionType, ArrayType, ListType, OptionType, PrimitiveType, and UnknownType.

◆ key()

virtual const std::string key ( int64_t  fieldindex) const
pure virtual

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.

Implemented in RecordType, RegularType, UnionType, ArrayType, ListType, OptionType, PrimitiveType, and UnknownType.

◆ keys()

virtual const std::vector<std::string> keys ( ) const
pure virtual

A list of RecordType keys or an empty list if this type does not contain a RecordType.

Implemented in RecordType, RegularType, UnionType, ArrayType, ListType, OptionType, PrimitiveType, and UnknownType.

◆ numfields()

virtual int64_t numfields ( ) const
pure virtual

The number of fields in the first nested tuple or records or -1 if this array does not contain a RecordType.

Implemented in RecordType, RegularType, UnionType, ArrayType, ListType, OptionType, PrimitiveType, and UnknownType.

◆ parameter()

const std::string parameter ( const std::string &  key) const

Custom parameters inherited from the Content that this type describes.

If the key does not exist, this function returns "null".

Keys are simple strings, but values are JSON-encoded strings. For this reason, values that represent single strings are double-quoted: e.g. "\"actual_value"".

◆ parameter_asstring()

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.

◆ parameter_equals()

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.

Keys are simple strings, but values are JSON-encoded strings. For this reason, values that represent single strings are double-quoted: e.g. "\"actual_value"".

Equality is checked at the level of JSON DOMs. The value does not need to be exactly the same string; it needs to have equivalent JSON value.

◆ parameter_isname()

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.

◆ parameter_isstring()

bool parameter_isstring ( const std::string &  key) const

Returns true if the parameter associated with key is a string; false otherwise.

◆ parameters()

const util::Parameters parameters ( ) const

Get one parameter from this type.

If the key does not exist, this function returns "null".

Keys are simple strings, but values are JSON-encoded strings. For this reason, values that represent single strings are double-quoted: e.g. "\"actual_value"".

◆ parameters_empty()

bool parameters_empty ( ) const
protected

Internal function to determine if there are no parameters except __categorical__.

◆ parameters_equal()

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.

Keys are simple strings, but values are JSON-encoded strings. For this reason, values that represent single strings are double-quoted: e.g. "\"actual_value"".

Equality is checked at the level of JSON DOMs. The value does not need to be exactly the same string; it needs to have equivalent JSON value.

If check_all, every parameter is checked; otherwise, only "__array__" and "__record__" are checked.

◆ setparameter()

void setparameter ( const std::string &  key,
const std::string &  value 
)

Assign one parameter to this type (in-place).

Keys are simple strings, but values are JSON-encoded strings. For this reason, values that represent single strings are double-quoted: e.g. "\"actual_value"".

Note
This mutability is temporary: scikit-hep/awkward-1.0#117 Eventually, this interface will be deprecated and all Content instances will be immutable.

◆ setparameters()

void setparameters ( const util::Parameters parameters)

Assign one parameter for this type (in-place).

Keys are simple strings, but values are JSON-encoded strings. For this reason, values that represent single strings are double-quoted: e.g. "\"actual_value"".

Note
This mutability is temporary: scikit-hep/awkward-1.0#117 Eventually, this interface will be deprecated and all Content instances will be immutable.

◆ shallow_copy()

virtual const TypePtr shallow_copy ( ) const
pure virtual

Copies this Type without copying any hierarchically nested types.

Implemented in RecordType, RegularType, UnionType, ArrayType, ListType, OptionType, PrimitiveType, and UnknownType.

◆ string_parameters()

const std::string string_parameters ( ) const
protected

Internal function to format parameters as part of the tostring string.

◆ tostring()

const std::string tostring ( ) const

Returns a string representation of the type as a Datashape or its typestr overload (if non-empty).

◆ tostring_part()

virtual std::string tostring_part ( const std::string &  indent,
const std::string &  pre,
const std::string &  post 
) const
pure virtual

Internal function to build an output string for tostring.

Parameters
indentIndentation depth as a string of spaces.
prePrefix string, usually an opening XML tag.
postPostfix string, usually a closing XML tag and carriage return.

Implemented in RecordType, RegularType, UnionType, ArrayType, ListType, OptionType, PrimitiveType, and UnknownType.

◆ typestr()

const std::string typestr ( ) const

Optional string that overrides the default string representation (missing if empty).

◆ wrap_categorical()

std::string wrap_categorical ( const std::string &  output) const
protected

Internal function that wraps output with categorical[type= and ] if __categorical__ is true; passes through otherwise.

Member Data Documentation

◆ parameters_

util::Parameters parameters_
protected

See parameters.

◆ typestr_

const std::string typestr_
protected

See typestr.


The documentation for this class was generated from the following file: