OECIFCategory
struct OECIFCategory
This class represents the OECIFCategory that holds CIF header data and acts as an interface to interact with this header data. This object reflects what is contained in a CIF category.
The CIF File Format section explains in more detail the CIF data structure.
See also
OECIFDataclassOECIFOptionsclass
Constructors
OECIFCategory()
OECIFCategory(const std::string &categoryName, const std::vector<std::string> &attributes, const std::vector<std::string> &values)
OECIFCategory(const std::string &categoryName, const std::string &attribute, const std::string &value)
OECIFCategory(const std::string &categoryName, const std::vector<std::string> &attributes)
OECIFCategory(const std::string &categoryName)
Create a OECIFCategory object.
AddAttribute
bool AddAttribute(const std::string &newAttribute, const std::string &newValue = "?"
bool AddAttribute(const std::string &newAttribute, const std::vector<std::string> &newValues)
Adds a column of values to the indicated CIF attribute. If no values are input, a question mark “?” value will be used to populate attribute values.
AddRow
bool AddRow(const std::vector<std::string> &nvals)
bool AddRow(const std::string init="?")
Adds a row of value(s) to the CIF category.
If no values are input, by default, it will add a question mark “?” to every attribute in the category.
DeleteRow
bool DeleteRow(unsigned int row)
Deletes a category’s indicated row.
DeleteAttribute
bool DeleteAttribute(const std::string &attribute)
Deletes a category attribute.
GetAttributes
std::vector<std::string> GetAttributes() const
Returns the category’s attributes.
GetAttributeValue
std::string GetAttributeValue(const std::string &attribute, bool raw=false) const
std::string GetAttributeValue(const std::string &attribute, unsigned int row, bool raw=false) const
Gets the saved value on the indicated attribute. If multiple values exist for a given attribute, then a row number must be identified.
GetAttributeValues
std::vector<std::string> GetAttributeValues(const std::string &attribute, bool raw=false) const
Gets all the saved values on the indicated attribute.
GetAttributeIndex
int GetAttributeIndex(const std::string &attribute) const
Returns the attribute’s base-0 index. For any given row of data associated with the category, this index correlates with the attribute’s value in that row. For example, if GetAttributeIndex(“type”)=1, for every row generated by GetRows(), the _category.type data would be the [1] value in that row.
GetCategoryName
std::vector<std::string> &GetCategoryName() const
Returns the category’s name.
GetDataItem
std::string GetDataItem(const std::string &attribute) const
Returns the CIF data item name in the format: ‘_category.attribute’
GetDataItems
std::vector<std::string> GetDataItems() const
Returns all the CIF data item names in the category in the format: ‘_category.attribute’
GetNumRows
unsigned int GetNumRows() const
Number of CIF rows in the category.
GetNumAttributes
unsigned int GetNumAttributes() const
Number of CIF attributes in the category.
GetNumericAttributeValue
GetFloatAttributeValue(String attribute, Float val)
GetIntAttributeValue(String attribute, Integer val)
GetFloatAttributeValue(String attribute, Integer row, Float val)
GetIntAttributeValue(String attribute, Integer row, Integer val)
Gets the saved value for the indicated attribute and converts it to a numeric value. If multiple values exist for a given attribute, then a row number must be identified. If a value cannot be easily converted to a numeric value, it will default to 0.
GetNumericattributeValues
bool GetFloatAttributeValues(String attribute, Vector<Float> vals)
bool GetIntAttributeValues(String attribute, Vector<Integer> vals)
Gets all the saved values for the indicated attribute and converts to a numeric value. If a value cannot be easily converted to a numeric value, it will default to 0.
GetRow
std::vector<std::string> GetRow(unsigned int row, bool raw=false) const
Returns as a specific row from the category. Row indicators are base-0. Raw values are formatted as they will appear in the header. This is most noticeable with values that contain space characters, as CIF formatting requires single or double quotes around such a string value.
GetRows
std::vector<std::vector<std::string>> GetRows(int beginRow, int endRow, bool raw=false) const
std::vector<std::vector<std::string>> GetRows(bool raw=false) const
Returns rows from the category. Row indicators are base-0. Raw values are formatted as they will appear in the header. This is most noticeable with values that contain space characters, as CIF formatting requires single or double quotes around such a string value.
GetRowIndices
std::vector<unsigned int> GetRowIndices(const std::string &attribute, const std::string &matchValue) const
Returns the base-0 row indices whose values string-match with input match values.
HasAttribute
bool HasAttribute(const std::string &attribute) const
Returns if an attribute is present in this object.
SetData
bool SetData(const std::string &attribute, const std::string &nval) const
bool SetData(const std::string &attribute, unsigned int row, const std::string &nval, const std::string init="?") const
bool SetData(const std::string &attribute, const std::vector<std::string> &nvals) const
bool SetData(unsigned int row, const std::vector<std::string> &nvals, const std::string init="?") const
Sets attribute and row data. When setting data related to row values, if the indicated row value exceeds the maximum number of rows, then empty values will populate any undefined attributes values. Rows indicators are base-0.
SortByAttribute
bool SetData(const std::string &attribute)
All rows will be rearranged according to the alphanumeric order of the indicated attribute’s values.