OEFieldMeta

class OEFieldMeta

The OEFieldMeta class is used to associate metadata with data to be stored on OERecord objects. Two types of metadata can be assigned to an OEFieldMeta object: options are simple flags, while attributes are key-value pairs. Constants defining both options and attributes are defined in the OEMetadata namespace.

Constructors

OEFieldMeta()

The default constructor initializes an empty metadata object.

OEFieldMeta(const OEFieldMeta &rhs)

Copy constructor.

SetOption

OEFieldMeta& SetOption(unsigned int option)

Adds the specified option to the OEFieldMeta object. Options are specified in the OEMetadata namespace.

SetOptions

OEFieldMeta& SetOptions(const std::vector<unsigned int> &options)

Sets all the option values for the OEFieldMeta object at once. Options are specified in the OEMetadata namespace.

GetOptions

const std::vector<unsigned int>& GetOptions() const

Returns all the option values for the OEFieldMeta object at once. Options are specified in the OEMetadata namespace.

HasOption

bool HasOption(unsigned int option) const

Returns true if this OEFieldMeta object contains the specified option.

AddRelation

OEFieldMeta& AddRelation(unsigned int relationship, const OEFieldBase &otherField)

Specifies a relationship to another field on the same record. For example, this could be used to specify that one field contains error bars for another field. The relationships are specified in the Relations section of the OEMetadata namespace.

GetRelatedFields

std::vector<std::string> GetRelatedFields()

Returns the names of fields that this OEFieldMeta object refers to.

GetFieldRelations

std::vector<unsigned int> GetFieldRelations(const std::string &fieldName) const

Returns the relationships that this OEFieldMeta object has to the named field. The relationships are specified in the Relations section of the OEMetadata namespace.

Clear

void Clear()

Clears all attributes and options from the OEFieldMeta object.

SetAttribute

OEFieldMeta& SetAttribute(unsigned int key, const std::string &value)
OEFieldMeta& SetAttribute(unsigned int key, const double &value)
OEFieldMeta& SetAttribute(unsigned int key, const int &value)

Sets a metadata key-value pair on the OEFieldMeta object. Any attribute(s) with the same key are replaced. The key values are from the OEMetadata namespace.

AddAttribute

OEFieldMeta& AddAttribute(unsigned int key, const std::string &value)
OEFieldMeta& AddAttribute(unsigned int key, const double &value)
OEFieldMeta& AddAttribute(unsigned int key, const int &value)

Sets a metadata key-value pair on the OEFieldMeta object. Multiple attributes for the same key are allowed, and this method adds additional values for the specified key. The key values are from the OEMetadata namespace.

GetAttribute

template<typename T> T GetAttribute(unsigned int key, unsigned int idx=0) const;

Returns the attribute value for the provided key and index. If the OEFieldMeta object doesn’t have a corresponding value, a default-constructed T object is returned. Because an attribute key can have multiple values, the idx argument specifies which value to return. The key values are from the OEMetadata namespace.

HasAttribute

OEFieldMeta& HasAttribute(unsigned int key)
OEFieldMeta& HasAttribute(unsigned int key, const std::string &value)
OEFieldMeta& HasAttribute(unsigned int key, const double &value)
OEFieldMeta& HasAttribute(unsigned int key, const int &value)

Returns true if this OEFieldMeta object contains the specified attribute. If the value argument is specified, the method will return true if that specific key-value pair is present. Otherwise, it will return true if any value is present for the provided key.

RemoveAttribute

OEFieldMeta& RemoveAttribute(unsigned int key)
OEFieldMeta& RemoveAttribute(unsigned int key, const std::string &value)
OEFieldMeta& RemoveAttribute(unsigned int key, const double &value)
OEFieldMeta& RemoveAttribute(unsigned int key, const int &value)

Removes a metadata key-value pair from the OEFieldMeta object. If the value is specified, that specific key-value pair is removed from the OEFieldMeta object. Otherwise, all values with the provided key are removed.

GetName

static std::string GetName(unsigned int optionOrAttributeKey)

Returns a name for the specified option or attribute key.

GetValue

static unsigned int GetValue(const std::string &name)

Returns an integer value for the specified option name. The returned values are from the OEMetadata namespace.

IsOption

static bool IsOption(unsigned int key)

Returns true if the provided metadata key is an option, rather than an attribute. The key value is from the OEMetadata namespace.