StreamBase C++ API
7.6.3.3
|
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... | |
Schema & | operator= (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 Field & | getField (size_t field_num) const |
Return the Fields object description of a field in the schema. More... | |
const Field & | getField (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 |
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.
enum sb::Schema::Flags |
Flags for creating a schema.
Enumerator | |
---|---|
NO_HEADER |
|
sb::Schema::Schema | ( | ) |
sb::Schema::Schema | ( | const Schema & | schema | ) |
Copy constructor.
std::string sb::Schema::as_string | ( | ) | const |
Returns a string representation of the schema.
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.
field_num | the zero-relative index of the field. |
NoSuchFieldException | if 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.
pathName | the path name of the field to fetch. |
NoSuchFieldException | if field is not found. |
const std::vector<Field>& sb::Schema::getFields | ( | ) | const |
Returns a reference to a vector of all fields in the schema.
|
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.
pathName | the path name of the field to fetch. |
|
inline |
Return true if the schema has space for a header, false otherwise.
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.
|
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; }
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.