StreamBase C++ API  10.6.1.0
sb::Schema Class Reference

A type of tuple, containing zero or more fields (each encapsulated as a Schema::Field object). More...

#include <Schema.hpp>

Public Types

enum  Flags { NO_HEADER = 1 }
 Flags for creating a schema. More...
 
typedef sb::Field Field
 

Public Member Functions

 Schema ()
 Creates an uninitialized Schema. More...
 
 Schema (const Schema &schema)
 Copy constructor. More...
 
Schemaoperator= (const Schema &)
 Assignment operator. More...
 
template<typename Iterator >
 Schema (std::string name, Iterator begin, Iterator end, Flags flags=Flags())
 Constructs a Schema from a sequence of Field objects. More...
 
template<typename Iterator >
 Schema (Iterator begin, Iterator end, Flags flags=Flags())
 Constructs a Schema from a sequence of Field objects. More...
 
 Schema (std::string name, const std::vector< Field > &fields, Flags flags=Flags())
 Constructs a Schema from a vector of Field objects. More...
 
 Schema (const std::vector< Field > &fields, Flags flags=Flags())
 Constructs a Schema from a vector of Field objects. More...
 
 operator const void * () const
 Returns a non-null value if the object was not created with the no-argument constructor, i.e., this is a meaningful Schema. More...
 
bool hasHeader () const
 Return true if the schema has space for a header, false otherwise. More...
 
size_t getHeaderSize () const
 Return the size of the header. More...
 
const FieldgetField (size_t field_num) const
 Return the Fields object description of a field in the schema. More...
 
const FieldgetField (const std::string &pathName) const
 Return the Fields object description of a field in the schema. More...
 
const bool hasField (const std::string &pathName) const
 Returns true if a field of a given path name is present, otherwise it returns false. More...
 
const std::vector< Field > & getFields () const
 Returns a reference to a vector of all fields in the schema. More...
 
int indexOfField (const std::string &name) const
 Returns the index of the field with a particular name (note: not path name), or -1 if there is no such field. More...
 
const std::string & getName () const
 Returns the name of the schema or empty string at runtime. More...
 
size_t getNumFields () const
 Returns the number of fields in the schema. More...
 
std::string as_string () const
 Returns a string representation of the schema. More...
 
bool sameFieldTypes (const Schema &other) const
 Returns true if this schema has the same field types in the same order as another Schema. More...
 
bool sameFields (const Schema &other) const
 Returns true if this schema has the same field Names and Types in the same order as another Schema. More...
 
bool operator== (const Schema &other) const
 
bool operator!= (const Schema &other) const
 

Static Public Member Functions

static Schema fromXml (const std::string &input, Flags flags=Flags())
 Parse and return a schema from an XML string. More...
 

Static Public Attributes

static const Schema EMPTY_SCHEMA
 

Detailed Description

A type of tuple, containing zero or more fields (each encapsulated as a Schema::Field object).

Schemas are immutable: once constructed they may not be changed.

Member Enumeration Documentation

Flags for creating a schema.

Enumerator
NO_HEADER 
Deprecated:
ignored

Constructor & Destructor Documentation

sb::Schema::Schema ( )

Creates an uninitialized Schema.

This should NOT be used to create a Schema with no fields; to construct such a Schema use one of the other overloads and pass an empty list of fields.

sb::Schema::Schema ( const Schema schema)

Copy constructor.

template<typename Iterator >
sb::Schema::Schema ( std::string  name,
Iterator  begin,
Iterator  end,
Flags  flags = Flags() 
)

Constructs a Schema from a sequence of Field objects.

template<typename Iterator >
sb::Schema::Schema ( Iterator  begin,
Iterator  end,
Flags  flags = Flags() 
)

Constructs a Schema from a sequence of Field objects.

sb::Schema::Schema ( std::string  name,
const std::vector< Field > &  fields,
Flags  flags = Flags() 
)

Constructs a Schema from a vector of Field objects.

If the vector is empty the Schema will contain no fields.

sb::Schema::Schema ( const std::vector< Field > &  fields,
Flags  flags = Flags() 
)

Constructs a Schema from a vector of Field objects.

If the vector is empty the Schema will contain no fields.

Member Function Documentation

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

Returns a string representation of the schema.

static Schema sb::Schema::fromXml ( const std::string &  input,
Flags  flags = Flags() 
)
static

Parse and return a schema from an XML string.

The root tag must be <schema>.

const Field& sb::Schema::getField ( size_t  field_num) const

Return the Fields object description of a field in the schema.

Parameters
field_numthe zero-relative index of the field.
Exceptions
NoSuchFieldExceptionif field_num is too large
const Field& sb::Schema::getField ( const std::string &  pathName) const

Return the Fields object description of a field in the schema.

Parameters
pathNamethe path name of the field to fetch.
Exceptions
NoSuchFieldExceptionif field is not found.
const std::vector<Field>& sb::Schema::getFields ( ) const

Returns a reference to a vector of all fields in the schema.

size_t sb::Schema::getHeaderSize ( ) const
inline

Return the size of the header.

const std::string& sb::Schema::getName ( ) const

Returns the name of the schema or empty string at runtime.

size_t sb::Schema::getNumFields ( ) const

Returns the number of fields in the schema.

Referenced by sb::Tuple::getNumFields().

const bool sb::Schema::hasField ( const std::string &  pathName) const

Returns true if a field of a given path name is present, otherwise it returns false.

Parameters
pathNamethe path name of the field to fetch.
bool sb::Schema::hasHeader ( ) const
inline

Return true if the schema has space for a header, false otherwise.

Deprecated:
int sb::Schema::indexOfField ( const std::string &  name) const

Returns the index of the field with a particular name (note: not path name), or -1 if there is no such field.

sb::Schema::operator const void * ( ) const
inline

Returns a non-null value if the object was not created with the no-argument constructor, i.e., this is a meaningful Schema.

Useful in the following manner:

Schema td = callSomeMethod();
if (td) {
    cout << "someMethod returned a valid Schema: " << td << endl;
} else {
    cout << "no such Schema" << endl;
}
Schema& sb::Schema::operator= ( const Schema )

Assignment operator.

bool sb::Schema::sameFields ( const Schema other) const

Returns true if this schema has the same field Names and Types in the same order as another Schema.

bool sb::Schema::sameFieldTypes ( const Schema other) const

Returns true if this schema has the same field types in the same order as another Schema.


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