CifFile Class Reference

Public class that represents a CIF file, composed of blocks with tables. More...

#include <CifFile.h>

Inherited by DdlFile.

Inheritance diagram for CifFile:

Inheritance graph
[legend]
List of all members.

Public Types

enum  eQuoting { eSINGLE = 0, eDOUBLE }

Public Member Functions

 CifFile (const eFileMode fileMode, const string &fileName, const bool verbose=false, const StringCompare::eCompareType caseSense=StringCompare::eCASE_SENSITIVE, const unsigned int maxLineLength=STD_CIF_LINE_LENGTH, const string &nullValue=CifString::NullValue)
 CifFile (const bool verbose=false, const StringCompare::eCompareType caseSense=StringCompare::eCASE_SENSITIVE, const unsigned int maxLineLength=STD_CIF_LINE_LENGTH, const string &nullValue=CifString::NullValue)
 ~CifFile ()
bool GetVerbose ()
void SetSmartPrint (bool smartPrint=true)
bool IsSmartPrint ()
void SetQuoting (eQuoting quoting)
unsigned int GetQuoting ()
void Write (const string &cifFileName, const bool sortTables=false, const bool writeEmptyTables=false)
void Write (const string &cifFileName, const vector< string > &tableOrder, const bool writeEmptyTables=false)
void Write (ostream &outStream, const bool sortTables=false, const bool writeEmptyTables=false)
int DataChecking (CifFile &dicRef)
int DataChecking (Block &block, Block &refBlock, ostringstream &buf)
void GetAttributeValue (string &attribVal, const string &blockId, const string &category, const string &attribute)
void GetAttributeValueIf (string &attribVal, const string &blockId, const string &category, const string &attributeA, const string &attributeB, const string &valB)
bool IsAttributeValueDefined (const string &blockId, const string &category, const string &attribute)
void SetAttributeValue (const string &blockId, const string &category, const string &attribute, const string &value, const bool create=false)
void SetAttributeValueIf (const string &blockId, const string &category, const string &attributeA, const string &valA, const string &attributeB, const string &valB, const bool create=false)
void SetAttributeValueIfNull (const string &blockId, const string &category, const string &attribute, const string &value)
void GetAttributeValues (vector< string > &strings, const string &blockId, const string &category, const string &attribute)
void GetAttributeValuesIf (vector< string > &strings, const string &blockId, const string &category, const string &attributeA, const string &attributeB, const string &valB)
void SetAttributeValues (const string &blockId, const string &category, const string &attribute, const vector< string > &values)
int CheckCategories (Block &block, Block &refBlock, ostringstream &log)
void CheckCategoryKey (Block &block, ostringstream &log)
int CheckItems (Block &block, Block &refBlock, ostringstream &log)

Static Public Member Functions

static void GetItemNames (vector< string > &itemNames, ISTable &isTable)

Static Public Attributes

static const unsigned int STD_CIF_LINE_LENGTH = 80

Protected Types

enum  eIdentType { eNONE = 0, eLEFT, eRIGHT }

Protected Member Functions

int _IsQuotableText (const string &itemValue)
eIdentType _FindPrintType (const vector< string > &values)
void _PrintItemIdent (ostream &cifo, unsigned int &linePos)
void _PrintItemName (ostream &cifo, const string &category, const string &itemName, unsigned int &linePos)
void _PrintPostItemSeparator (ostream &cifo, unsigned int &linePos, const bool ident=false, const unsigned int numSpaces=1)
int _PrintItemValue (ostream &cifo, const string &itemValue, unsigned int &linePos, const eIdentType identType=eNONE, const unsigned int width=0)
int _PrintItemNameInHeader (ostream &cifo, const string &itemValue, unsigned int &linePos, const eIdentType identType=eNONE, const unsigned int width=0)
void _PrintHeaderedItems (ostream &cifo, const vector< string > &colNames, const vector< unsigned int > &colWidths, const vector< eIdentType > colPrintType)
void Write (ostream &cifo, const vector< string > &catOrder, const bool writeEmptyTables=false)
void Write (ostream &cifo, vector< unsigned int > &tables, const bool writeEmptyTables=false)

Protected Attributes

unsigned int _maxCifLineLength
string _nullValue
bool _verbose
bool _smartPrint
string _quotes

Static Protected Attributes

static const unsigned int STD_PRINT_SPACING = 3
static const unsigned int SMART_PRINT_SPACING = 1
static const unsigned int HEADER_SPACING = 40

Private Member Functions

void Init ()
bool IsCatDefinedInRef (const string &catName, ISTable &catTable)
bool IsItemDefinedInRef (const string &catName, const string &itemName, ISTable &refItemTable)
void CheckKeyItems (const string &blockName, ISTable &catTable, ISTable &keyTable, ostringstream &log)
void CheckMandatoryItems (const string &blockName, ISTable &catTable, ISTable &refItemTable, ostringstream &log)
void CheckAndRectifyItemTypeCode (Block &block, ostringstream &log)
int CheckParentChild (Block &block, ISTable &catTable, const vector< string > &cifItemNames, ISTable &parChildTable, ostringstream &log)
int CheckRegExpRangeEnum (Block &block, ISTable &catTable, const string &cifItemName, ISTable &itemTypeTable, ISTable &itemTypeListTable, ISTable &itemRangeTable, ISTable &itemEnumTable, ISTable &parChildTable, ostringstream &log)
int CheckCellRange (const string &cell, const string &typeCode, const vector< string > &minlist, const vector< string > &maxlist)
int CheckCellEnum (const string &cell, const string &typeCode, const string &primCode, const vector< string > &enumlist)
int CheckCellFloatRange (const string &cell, const vector< string > &minlist, const vector< string > &maxlist)
int CheckCellIntRange (const string &cell, const vector< string > &minlist, const vector< string > &maxlist)
int CheckCellFloatEnum (const string &cell, const vector< string > &enumlist)
int CheckCellIntEnum (const string &cell, const vector< string > &enumlist)
int CheckCellOtherEnum (const string &cell, const string &primCode, const vector< string > &enumlist)
ISTable * CreateKeysTable (const vector< string > &cifItemNames, ISTable &parChildTable, map< string, unsigned int > &maxKeyGroups)
void GetComboKeys (const string &parCatName, const unsigned int maxKeyGroup, ISTable &keysTable, vector< vector< string > > &comboKeys, vector< string > &parKeys)
void GetItemTypeCode (string &typeCode, const string &cifItemName, ISTable &itemTypeTable)
void ConvertEscapedString (const string &inString, string &outString)

Detailed Description

Public class that represents a CIF file, composed of blocks with tables.

This class represents a CIF file. In addition to inherited methods from TableFile class, this class provides methods for writing the data to a text file, along with methods for controlling how the data is written, and a method for verifying the CIF file against dictionary.


Member Enumeration Documentation

enum CifFile::eQuoting

Enumerator:
eSINGLE 
eDOUBLE 

enum CifFile::eIdentType [protected]

Enumerator:
eNONE 
eLEFT 
eRIGHT 


Constructor & Destructor Documentation

CifFile::CifFile ( const eFileMode  fileMode,
const string &  fileName,
const bool  verbose = false,
const StringCompare::eCompareType  caseSense = StringCompare::eCASE_SENSITIVE,
const unsigned int  maxLineLength = STD_CIF_LINE_LENGTH,
const string &  nullValue = CifString::NullValue 
)

Constructs a CIF file.

Parameters:
[in] fileMode - CIF file mode. Possible values are read-only, create, update and virtual. Detailed description of file mode is given in TableFile documentation.
[in] fileName - relative or absolute name of the file where object persistency is maintained. If fileMode specifies virtual mode, this parameter is ignored.
[in] verbose - optional parameter that indicates whether logging should be turned on (if true) or off (if false). If verbose is not specified, logging is turned off.
[in] caseSense - optional parameter that indicates case sensitivity of table names. Possible values are case sensitive and case in-sensitive. If not specified, case sensitive table names are assumed.
[in] maxLineLength - optional parameter that indicates the maximum number of written characters in one line in the written text file. If not specified, STD_CIF_LINE_LENGTH is used.
[in] nullValue - optional parameter that indicates the character that is to be used to denote unknown value in the written CIF file. If not specified, CifString::NullValue is used.
Returns:
Not applicable
Precondition:
None
Postcondition:
None
Exceptions:
 None

CifFile::CifFile ( const bool  verbose = false,
const StringCompare::eCompareType  caseSense = StringCompare::eCASE_SENSITIVE,
const unsigned int  maxLineLength = STD_CIF_LINE_LENGTH,
const string &  nullValue = CifString::NullValue 
)

Constructs a CIF file in virtual mode.

Parameters:
[in] verbose - optional parameter that indicates whether logging should be turned on (if true) or off (if false). If verbose is not specified, logging is turned off.
[in] caseSense - optional parameter that indicates case sensitivity of table names. Possible values are case sensitive and case in-sensitive. If not specified, case sensitive table names are assumed.
[in] maxLineLength - optional parameter that indicates the maximum number of written characters in one line in the written text file. If not specified, STD_CIF_LINE_LENGTH is used.
[in] nullValue - optional parameter that indicates the character that is to be used to denote unknown value in the written CIF file. If not specified, CifString::NullValue is used.
Returns:
Not applicable
Precondition:
None
Postcondition:
None
Exceptions:
 None

CifFile::~CifFile (  ) 

Destructs a CIF file, by releasing all consumed resources.

Parameters:
 Not applicable
Returns:
Not applicable
Precondition:
None
Postcondition:
None
Exceptions:
 None


Member Function Documentation

bool CifFile::GetVerbose (  )  [inline]

Retrieves logging option.

Parameters:
 None
Returns:
true - if logging is turned on

false - if logging is turned off

Precondition:
None
Postcondition:
None
Exceptions:
 None

void CifFile::SetSmartPrint ( bool  smartPrint = true  )  [inline]

Sets smart printing option. Smart printing is used to beautify the output of a written text file.

Parameters:
smartPrint - smart printing. If false, smart printing is disabled. If true, smart printing is enabled. If not specified, smart printing is enabled.
Returns:
None
Precondition:
None
Postcondition:
None
Exceptions:
 None

bool CifFile::IsSmartPrint (  )  [inline]

Retrieves smart printing option.

Parameters:
 None
Returns:
true - if smart printing is enabled

false - if smart printing is disabled

Precondition:
None
Postcondition:
None
Exceptions:
 None

void CifFile::SetQuoting ( eQuoting  quoting  ) 

Sets quoting option. This option is used in order to select the type of quoting to be used in the written text file.

Parameters:
quoting - type of quoting. If eSINGLE, single quotes are used. If eDOUBLE, double quotes are used.
Returns:
None
Precondition:
None
Postcondition:
None
Exceptions:
 None

unsigned int CifFile::GetQuoting (  ) 

Retrieves quoting option.

Parameters:
 None
Returns:
eSINGLE - if single quotes are used

eDOUBLE - if double quotes are used

Precondition:
None
Postcondition:
None
Exceptions:
 None

void CifFile::Write ( const string &  cifFileName,
const bool  sortTables = false,
const bool  writeEmptyTables = false 
)

Writes the data out to a text file.

Parameters:
[in] cifFileName - relative or absolute name of the text file to which the data from CifFile object is to be written to.
[in] sortTables - optional parameter that indicates whether written tables should be sorted (if true) or not sorted (if false). If sortTables is not specified, tables are not sorted prior to writing them.
[in] writeEmptyTables - optional parameter that indicates whether empty tables (0 rows) are to be written (if true) or not written (if false). If writeEmptyTables is not specified, empty tables are not written.
Returns:
None
Precondition:
None
Postcondition:
None
Exceptions:
 None

void CifFile::Write ( const string &  cifFileName,
const vector< string > &  tableOrder,
const bool  writeEmptyTables = false 
)

Writes the data out to a text file.

Parameters:
[in] cifFileName - relative or absolute name of the text file to which the data from CifFile object is to be written to.
[in] tableOrder - vector of table names that indicates the order of written tables.
[in] writeEmptyTables - optional parameter that indicates whether empty tables (0 rows) are to be written (if true) or not written (if false). If writeEmptyTables is not specified, empty tables are not written.
Returns:
None
Precondition:
None
Postcondition:
None
Exceptions:
 None

void CifFile::Write ( ostream &  outStream,
const bool  sortTables = false,
const bool  writeEmptyTables = false 
)

Writes the data out to an output stream.

Parameters:
[in] outStream - a reference to the output stream
[in] sortTables - optional parameter that indicates whether written tables should be sorted (if true) or not sorted (if false). If sortTables is not specified, tables are not sorted prior to writing them.
[in] writeEmptyTables - optional parameter that indicates whether empty tables (0 rows) are to be written (if true) or not written (if false). If writeEmptyTables is not specified, empty tables are not written.
Returns:
None
Precondition:
None
Postcondition:
None
Exceptions:
 None

int CifFile::DataChecking ( CifFile dicRef  ) 

Checks a CIF file (all blocks in it) against the dictionary.

Parameters:
[in] dicRef - reference to a dictionary file. The check is done against the first block in the dictionary file.
Returns:
0 - if all checks passed

different than 0 - if checks failed

Precondition:
None
Postcondition:
None
Exceptions:
 None

int CifFile::DataChecking ( Block &  block,
Block &  refBlock,
ostringstream &  buf 
)

Checks a block of CIF file against the specified reference block.

Parameters:
[in] block - reference to a block that is to be checked
[in] refBlock - reference to a reference block against which block is to be checked
[out] diagBuf - diagnostics buffer that holds checking results
Returns:
0 - if all checks passed

different than 0 - if checks failed

Precondition:
None
Postcondition:
None
Exceptions:
 None

void CifFile::GetItemNames ( vector< string > &  itemNames,
ISTable &  isTable 
) [static]

Constructs CIF item names in the form "_<category>.<item>", by using the table name for the category name and each column name for the item name.

Parameters:
[out] itemNames - constructed CIF item names. The number of CIF items is equal to the number of table columns.
[in] isTable - table reference
Returns:
None
Precondition:
None
Postcondition:
None
Exceptions:
 None

void CifFile::GetAttributeValue ( string &  attribVal,
const string &  blockId,
const string &  category,
const string &  attribute 
)

void CifFile::GetAttributeValueIf ( string &  attribVal,
const string &  blockId,
const string &  category,
const string &  attributeA,
const string &  attributeB,
const string &  valB 
)

bool CifFile::IsAttributeValueDefined ( const string &  blockId,
const string &  category,
const string &  attribute 
)

void CifFile::SetAttributeValue ( const string &  blockId,
const string &  category,
const string &  attribute,
const string &  value,
const bool  create = false 
)

void CifFile::SetAttributeValueIf ( const string &  blockId,
const string &  category,
const string &  attributeA,
const string &  valA,
const string &  attributeB,
const string &  valB,
const bool  create = false 
)

void CifFile::SetAttributeValueIfNull ( const string &  blockId,
const string &  category,
const string &  attribute,
const string &  value 
)

void CifFile::GetAttributeValues ( vector< string > &  strings,
const string &  blockId,
const string &  category,
const string &  attribute 
)

void CifFile::GetAttributeValuesIf ( vector< string > &  strings,
const string &  blockId,
const string &  category,
const string &  attributeA,
const string &  attributeB,
const string &  valB 
)

void CifFile::SetAttributeValues ( const string &  blockId,
const string &  category,
const string &  attribute,
const vector< string > &  values 
)

int CifFile::CheckCategories ( Block &  block,
Block &  refBlock,
ostringstream &  log 
)

void CifFile::CheckCategoryKey ( Block &  block,
ostringstream &  log 
)

int CifFile::CheckItems ( Block &  block,
Block &  refBlock,
ostringstream &  log 
)

int CifFile::_IsQuotableText ( const string &  itemValue  )  [protected]

CifFile::eIdentType CifFile::_FindPrintType ( const vector< string > &  values  )  [protected]

void CifFile::_PrintItemIdent ( ostream &  cifo,
unsigned int &  linePos 
) [protected]

void CifFile::_PrintItemName ( ostream &  cifo,
const string &  category,
const string &  itemName,
unsigned int &  linePos 
) [protected]

void CifFile::_PrintPostItemSeparator ( ostream &  cifo,
unsigned int &  linePos,
const bool  ident = false,
const unsigned int  numSpaces = 1 
) [protected]

int CifFile::_PrintItemValue ( ostream &  cifo,
const string &  itemValue,
unsigned int &  linePos,
const eIdentType  identType = eNONE,
const unsigned int  width = 0 
) [protected]

int CifFile::_PrintItemNameInHeader ( ostream &  cifo,
const string &  itemValue,
unsigned int &  linePos,
const eIdentType  identType = eNONE,
const unsigned int  width = 0 
) [protected]

void CifFile::_PrintHeaderedItems ( ostream &  cifo,
const vector< string > &  colNames,
const vector< unsigned int > &  colWidths,
const vector< eIdentType colPrintType 
) [protected]

void CifFile::Write ( ostream &  cifo,
const vector< string > &  catOrder,
const bool  writeEmptyTables = false 
) [protected]

void CifFile::Write ( ostream &  cifo,
vector< unsigned int > &  tables,
const bool  writeEmptyTables = false 
) [protected]

void CifFile::Init (  )  [private]

bool CifFile::IsCatDefinedInRef ( const string &  catName,
ISTable &  catTable 
) [private]

bool CifFile::IsItemDefinedInRef ( const string &  catName,
const string &  itemName,
ISTable &  refItemTable 
) [private]

void CifFile::CheckKeyItems ( const string &  blockName,
ISTable &  catTable,
ISTable &  keyTable,
ostringstream &  log 
) [private]

void CifFile::CheckMandatoryItems ( const string &  blockName,
ISTable &  catTable,
ISTable &  refItemTable,
ostringstream &  log 
) [private]

void CifFile::CheckAndRectifyItemTypeCode ( Block &  block,
ostringstream &  log 
) [private]

int CifFile::CheckParentChild ( Block &  block,
ISTable &  catTable,
const vector< string > &  cifItemNames,
ISTable &  parChildTable,
ostringstream &  log 
) [private]

int CifFile::CheckRegExpRangeEnum ( Block &  block,
ISTable &  catTable,
const string &  cifItemName,
ISTable &  itemTypeTable,
ISTable &  itemTypeListTable,
ISTable &  itemRangeTable,
ISTable &  itemEnumTable,
ISTable &  parChildTable,
ostringstream &  log 
) [private]

int CifFile::CheckCellRange ( const string &  cell,
const string &  typeCode,
const vector< string > &  minlist,
const vector< string > &  maxlist 
) [private]

int CifFile::CheckCellEnum ( const string &  cell,
const string &  typeCode,
const string &  primCode,
const vector< string > &  enumlist 
) [private]

int CifFile::CheckCellFloatRange ( const string &  cell,
const vector< string > &  minlist,
const vector< string > &  maxlist 
) [private]

int CifFile::CheckCellIntRange ( const string &  cell,
const vector< string > &  minlist,
const vector< string > &  maxlist 
) [private]

int CifFile::CheckCellFloatEnum ( const string &  cell,
const vector< string > &  enumlist 
) [private]

int CifFile::CheckCellIntEnum ( const string &  cell,
const vector< string > &  enumlist 
) [private]

int CifFile::CheckCellOtherEnum ( const string &  cell,
const string &  primCode,
const vector< string > &  enumlist 
) [private]

ISTable * CifFile::CreateKeysTable ( const vector< string > &  cifItemNames,
ISTable &  parChildTable,
map< string, unsigned int > &  maxKeyGroups 
) [private]

void CifFile::GetComboKeys ( const string &  parCatName,
const unsigned int  maxKeyGroup,
ISTable &  keysTable,
vector< vector< string > > &  comboKeys,
vector< string > &  parKeys 
) [private]

void CifFile::GetItemTypeCode ( string &  typeCode,
const string &  cifItemName,
ISTable &  itemTypeTable 
) [private]

void CifFile::ConvertEscapedString ( const string &  inString,
string &  outString 
) [private]


Member Data Documentation

const unsigned int CifFile::STD_CIF_LINE_LENGTH = 80 [static]

const unsigned int CifFile::STD_PRINT_SPACING = 3 [static, protected]

const unsigned int CifFile::SMART_PRINT_SPACING = 1 [static, protected]

const unsigned int CifFile::HEADER_SPACING = 40 [static, protected]

unsigned int CifFile::_maxCifLineLength [protected]

string CifFile::_nullValue [protected]

bool CifFile::_verbose [protected]

bool CifFile::_smartPrint [protected]

string CifFile::_quotes [protected]


The documentation for this class was generated from the following files:
Generated on Wed Feb 6 07:44:02 2008 for cif-file-v1.0 by  doxygen 1.5.1