Reading, with the assistance of the CifParse
class, and writing are handled by the CifFile
class, which descends from the TableFile class.
CifFile *cifFile = new CifFile;
CifParser *cifParserP = new CifParser(cifFile);
.cif
file and a string to hold diagnostics to the CifParser Parse routine cifParserP->Parse("/path/to/file.cif", diagnostics);
delete cifParserP;
GetFirstBlockName()
method with the GetBlock(const string& blockName)
method Block& block = cifFile->GetBlock(cifFile->GetFirstBlockName());
GetTable(const string& tableName)
method ISTable& struct_conn = block.GetTable("struct_conn");
operator()(const unsigned int rowIndex, const string colName)
method string connType = struct_conn(0, "conn_type_id");
CifFile *cifFile = new CifFile;
AddBlock
method with whatever name you want to give the block cifFile->AddBlock("block");
GetBlock
method, using the name you specified when you added it Block& block = cifFile->GetBlock("block");
)
WriteTable
method with the ISTable pointer as an argument block.WriteTable(ISTablePtr);
Write
method, specifying a .cif
file pathname cifFile->Write("/path/to/file.cif");
The three major classes which function as containers of sorts are CifFile, Block, and ISTable
, where CifFile objects contain Block objects which, in turn, contain ISTable objects. Data blocks map to Block objects, while categories map to ISTable objects. The methods below are predominantly for the purposes of parsing and reading CIF files. The listed headers can be consulted for a full delineation of methods.
unsigned int GetNumBlocks()
- returns the number of Block objects (i.e., data blocks) in the filevoid GetBlockNames(vector<string>& blockNames)
- propagates blockNames with the name of every Block (data block)string GetFirstBlockName()
- returns the name of the first data blockbool IsBlockPresent(const string& blockName)
- returns a bool indicating whether or not some Block blockName is present in the fileBlock& GetBlock(const string& blockName)
- returns a reference to the Block specified by blockNamevoid GetTableNames(vector<string>& tableNames)
- propagates tableNames with the name of every table (i.e., category) in the Block
bool IsTablePresent(const string& tableName)
- returns a bool indicating whether or not some table tableName is present in the BlockISTable& GetTable(const string& tableName)
- returns a reference to the ISTable specified by tableNameISTable* GetTablePtr(const string& tableName)
- returns a pointer to the ISTable specified by tableNameconst string& operator()(const unsigned int rowIndex, const string colName)
- returns the value of the attribute colName at row index rowIndexunsigned int GetNumColumns() const
- returns the number of columns (i.e., attributes/data item names) in the tableconst vector<string>& GetColumnNames() const
- returns a vector of all the column (attribute/data item) names in the tablebool IsColumnPresent(string& colName)
- returns a bool indicating whether or not some column (attribute/data item name) is present in the tablevoid GetColumn(vector<string>& col, const string& colName)
- propagates col with the entire column specified by colNamevoid GetColumn(vector<string>& col, const string& colName, const unsigned int fromRowIndex, unsigned int toRowIndex)
- propagates col with the values of the column specified by colName in the row range [fromRowIndex, toRowIndex]void GetColumn(vector<string>& col, const string& colName, const vector<unsigned int>& rowIndex)
- propagates col with the values of the column specified by colName for every row index in rowIndexunsigned int GetNumRows() const
- returns the number of rows in the tablevoid GetRow(vector<string>& row, const unsigned int rowIndex, const string& fromColName = string(), const string& toColName = string())
- propagates row with the values of the row at index rowIndex, optionally in some column range [fromColName, toColName]const vector<string>& GetRow(const unsigned int rowIndex)
- returns the row at index rowIndexvoid Search(vector<unsigned int>& res, const vector<string>& targets, const vector<string>& colNames, const unsigned int fromRowIndex = 0, const eSearchDir searchDir = eFORWARD, const eSearchType searchType = eEQUAL, const string& indexName = string())
- propagates res with the indices of every row whose attributes colNames have the values targets