StreamBase C++ API  10.6.0.2
sb::Field Class Reference

Information (name, type, and optionally size) about a field in a Schema. More...

#include <Field.hpp>

Public Member Functions

 Field ()
 Constructs a null (invalid) field. More...
 
 Field (const std::string &name, DataType type, size_t size=(size_t)-1)
 Constructs a field; deprecated. More...
 
 Field (const std::string &name, DataType type, const Schema &schema)
 Constructs a field; deprecated. More...
 
 Field (const std::string &name, const CompleteDataType &cdt)
 Constructs a field. More...
 
 Field (const Field &f)
 Copy constructor. More...
 
Fieldoperator= (const Field &f)
 Assignment operator. More...
 
std::string as_string () const
 Returns a string representation of a field. More...
 
const Schema getSchema () const
 Returns the field's schema (valid only if the field's type is TUPLE) More...
 
const std::string & getName () const
 Returns the name of a field. More...
 
const DataTypegetType () const
 Returns the type of a field (e.g., DataType::INT). More...
 
const CompleteDataTypegetCompleteType () const
 Returns the complete type of a field (e.g., DataType::LIST of DataType::INTs). More...
 
const CompleteDataTypegetElementCompleteType () const
 Returns the complete type of a field's elements (e.g., on a DataType::LIST of DataType::INTs, returns a CompleteDataType of DataType::INT). More...
 
const CompleteDataTypegetReturnType () const
 
const SchemagetArgumentSchema () const
 
size_t getFixedSize () const
 Returns the size of a field if it has a fixed size or -1. More...
 
int getIndex () const
 Returns the index of the field. More...
 
bool sameType (const Field &other) const
 Return true if the fields are the same type (including size information) More...
 
const std::vector< Field > & getFieldPath () const
 

Detailed Description

Information (name, type, and optionally size) about a field in a Schema.

A field can be looked up within a schema in three ways:

  1. By index: By the zero-based ordinal position of the field within the schema
  2. By simple name: By the name of the field itself (e.g., "myint")
  3. By path name: By a dot-separated list of names that define a path through a set of nested schemas that arise through the use of fields of type Tuple (e.g., "mynestedtuple.myint").

A Field object can be used to obtain the value of a field in a tuple. However, there are rules that must be obeyed in doing so. For example, one must obtain the Field object from a Schema object that describes the schema of the tuple (i.e., as opposed to directly from a Field constructor).

See the "client" StreamBase sample (streambase-install-dir/sample/client) for examples of proper use of Field objects.

Constructor & Destructor Documentation

sb::Field::Field ( )

Constructs a null (invalid) field.

sb::Field::Field ( const std::string &  name,
DataType  type,
size_t  size = (size_t)-1 
)

Constructs a field; deprecated.

Deprecated:
Use Field(std::string&, const CompleteDataType&) instead.
sb::Field::Field ( const std::string &  name,
DataType  type,
const Schema schema 
)

Constructs a field; deprecated.

Deprecated:
Use Field(std::string&, CompleteDataType::forTuple(const Schema& schema)) instead.
sb::Field::Field ( const std::string &  name,
const CompleteDataType cdt 
)

Constructs a field.

sb::Field::Field ( const Field f)

Copy constructor.

Member Function Documentation

std::string sb::Field::as_string ( ) const

Returns a string representation of a field.

const CompleteDataType& sb::Field::getCompleteType ( ) const
inline

Returns the complete type of a field (e.g., DataType::LIST of DataType::INTs).

const CompleteDataType& sb::Field::getElementCompleteType ( ) const
inline

Returns the complete type of a field's elements (e.g., on a DataType::LIST of DataType::INTs, returns a CompleteDataType of DataType::INT).

References sb::CompleteDataType::getElementCompleteType().

size_t sb::Field::getFixedSize ( ) const
inline

Returns the size of a field if it has a fixed size or -1.

int sb::Field::getIndex ( ) const
inline

Returns the index of the field.

const std::string& sb::Field::getName ( ) const
inline

Returns the name of a field.

const Schema sb::Field::getSchema ( ) const
inline

Returns the field's schema (valid only if the field's type is TUPLE)

const DataType& sb::Field::getType ( ) const
inline

Returns the type of a field (e.g., DataType::INT).

Field& sb::Field::operator= ( const Field f)

Assignment operator.

bool sb::Field::sameType ( const Field other) const
inline

Return true if the fields are the same type (including size information)


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