/*
FILE:     CifFile.h
*/
/*
VERSION:  4
*/
/*
DATE:     6/17/2002
*/
/*
  Comments and Questions to: sw-help@rcsb.rutgers.edu
*/
/*
COPYRIGHT 1999-2002 Rutgers - The State University of New Jersey

This software is provided WITHOUT WARRANTY OF MERCHANTABILITY OR
FITNESS FOR A PARTICULAR PURPOSE OR ANY OTHER WARRANTY, EXPRESS OR
IMPLIED.  RUTGERS MAKE NO REPRESENTATION OR WARRANTY THAT THE
SOFTWARE WILL NOT INFRINGE ANY PATENT, COPYRIGHT OR OTHER
PROPRIETARY RIGHT.

The user of this software shall indemnify, hold harmless and defend
Rutgers, its governors, trustees, officers, employees, students,
agents and the authors against any and all claims, suits,
losses, liabilities, damages, costs, fees, and expenses including
reasonable attorneys' fees resulting from or arising out of the
use of this software.  This indemnification shall include, but is
not limited to, any and all claims alleging products liability.
*/
/*
               PDB SOFTWARE LICENSE AGREEMENT

BY CLICKING THE ACCEPTANCE BUTTON OR INSTALLING OR USING 
THIS "SOFTWARE, THE INDIVIDUAL OR ENTITY LICENSING THE  
SOFTWARE ("LICENSEE") IS CONSENTING TO BE BOUND BY AND IS 
BECOMING A PARTY TO THIS AGREEMENT.  IF LICENSEE DOES NOT 
AGREE TO ALL OF THE TERMS OF THIS AGREEMENT
THE LICENSEE MUST NOT INSTALL OR USE THE SOFTWARE.

1. LICENSE AGREEMENT

This is a license between you ("Licensee") and the Protein Data Bank (PDB) 
at Rutgers, The State University of New Jersey (hereafter referred to 
as "RUTGERS").   The software is owned by RUTGERS and protected by 
copyright laws, and some elements are protected by laws governing 
trademarks, trade dress and trade secrets, and may be protected by 
patent laws. 

2. LICENSE GRANT

RUTGERS grants you, and you hereby accept, non-exclusive, royalty-free 
perpetual license to install, use, modify, prepare derivative works, 
incorporate into other computer software, and distribute in binary 
and source code format, or any derivative work thereof, together with 
any associated media, printed materials, and on-line or electronic 
documentation (if any) provided by RUTGERS (collectively, the "SOFTWARE"), 
subject to the following terms and conditions: (i) any distribution 
of the SOFTWARE shall bind the receiver to the terms and conditions 
of this Agreement; (ii) any distribution of the SOFTWARE in modified 
form shall clearly state that the SOFTWARE has been modified from 
the version originally obtained from RUTGERS.  

2. COPYRIGHT; RETENTION OF RIGHTS.  

The above license grant is conditioned on the following: (i) you must 
reproduce all copyright notices and other proprietary notices on any 
copies of the SOFTWARE and you must not remove such notices; (ii) in 
the event you compile the SOFTWARE, you will include the copyright 
notice with the binary in such a manner as to allow it to be easily 
viewable; (iii) if you incorporate the SOFTWARE into other code, you 
must provide notice that the code contains the SOFTWARE and include 
a copy of the copyright notices and other proprietary notices.  All 
copies of the SOFTWARE shall be subject to the terms of this Agreement.  

3. NO MAINTENANCE OR SUPPORT; TREATMENT OF ENHANCEMENTS 

RUTGERS is under no obligation whatsoever to: (i) provide maintenance 
or support for the SOFTWARE; or (ii) to notify you of bug fixes, patches, 
or upgrades to the features, functionality or performance of the 
SOFTWARE ("Enhancements") (if any), whether developed by RUTGERS 
or third parties.  If, in its sole discretion, RUTGERS makes an 
Enhancement available to you and RUTGERS does not separately enter 
into a written license agreement with you relating to such bug fix, 
patch or upgrade, then it shall be deemed incorporated into the SOFTWARE 
and subject to this Agreement. You are under no obligation whatsoever 
to provide any Enhancements to RUTGERS or the public that you may 
develop over time; however, if you choose to provide your Enhancements 
to RUTGERS, or if you choose to otherwise publish or distribute your 
Enhancements, in source code form without contemporaneously requiring 
end users or RUTGERS to enter into a separate written license agreement 
for such Enhancements, then you hereby grant RUTGERS a non-exclusive,
royalty-free perpetual license to install, use, modify, prepare
derivative works, incorporate into the SOFTWARE or other computer
software, distribute, and sublicense your Enhancements or derivative
works thereof, in binary and source code form.

4. FEES.  There is no license fee for the SOFTWARE.  If Licensee
wishes to receive the SOFTWARE on media, there may be a small charge
for the media and for shipping and handling.  Licensee is
responsible for any and all taxes.

5. TERMINATION.  Without prejudice to any other rights, Licensor
may terminate this Agreement if Licensee breaches any of its terms
and conditions.  Upon termination, Licensee shall destroy all
copies of the SOFTWARE.

6. PROPRIETARY RIGHTS.  Title, ownership rights, and intellectual
property rights in the Product shall remain with RUTGERS.  Licensee 
acknowledges such ownership and intellectual property rights and will 
not take any action to jeopardize, limit or interfere in any manner 
with RUTGERS' ownership of or rights with respect to the SOFTWARE.  
The SOFTWARE is protected by copyright and other intellectual 
property laws and by international treaties.  Title and related 
rights in the content accessed through the SOFTWARE is the property 
of the applicable content owner and is protected by applicable law.  
The license granted under this Agreement gives Licensee no rights to such
content.

7. DISCLAIMER OF WARRANTY.  THE SOFTWARE IS PROVIDED FREE OF 
CHARGE, AND, THEREFORE, ON AN "AS IS" BASIS, WITHOUT WARRANTY OF 
ANY KIND, INCLUDING WITHOUT LIMITATION THE WARRANTIES THAT IT 
IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE 
OR NON-INFRINGING.  THE ENTIRE RISK AS TO THE QUALITY AND 
PERFORMANCE OF THE SOFTWARE IS BORNE BY LICENSEE.  SHOULD THE 
SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, THE LICENSEE AND NOT 
LICENSOR ASSUMES THE ENTIRE COST OF ANY SERVICE AND REPAIR.  
THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF 
THIS AGREEMENT.  NO USE OF THE PRODUCT IS AUTHORIZED HEREUNDER 
EXCEPT UNDER THIS DISCLAIMER.

8. LIMITATION OF LIABILITY.  TO THE MAXIMUM EXTENT PERMITTED BY
APPLICABLE LAW,  IN NO EVENT WILL LICENSOR BE LIABLE FOR ANY 
INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 
OUT OF THE USE OF OR INABILITY TO USE THE SOFTWARE, INCLUDING, 
WITHOUT LIMITATION, DAMAGES FOR LOSS OF GOODWILL, WORK 
STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL 
OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF ADVISED OF THE
POSSIBILITY THEREOF. 
*/
/* **************************************************************** *

  PURPOSE:      This file contains the definitions of class
                CifFile

 * **************************************************************** */

#ifndef H_CIFFILE
#define H_CIFFILE

#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <dirent.h>
#include <iostream.h>

#include "CifString.h"
#include "CifDefs.h"
#include "CifErrorCodes.h"
#include "CifAnon.h"
#include "CifFileIo.h"
#include "CifItemValue.h"
#include "CifDataItem.h"
#include "CifDataBlock.h"
#include "ReVarCifArray.h"

class CifFile {

  CifDataBlock   _globalInformation;
  ReVarCifArray <CifDataBlock> _dataBlocks;

 public:
  CifFile() {};
  void PermanentWrite(const char *fileName);
  int PermanentRead(const char *filename, 
		    const char *dicFileName = NULL,
		    const char *dicDataBlockName = NULL);
  int ReadFile(const char *filename, 
	       const char *dicDatablockName = NULL,
	       const int verifyFlag = CIF_VERIFICATION_SET_FLAG);
  int WriteFile(const char *filename, 
		const char *outputFileName, 
		const char type, 
		const int writeComment = TRUE, 
		const int esdFlag = TRUE,
		const char *dictionary = NULL,
		const char *version = NULL);

  int WriteDataBlock(const char *outputFileName, 
		     const char type, 
		     const char *Datablock_name, 
		     const int writeComment=TRUE,
		     const int esdFlag = TRUE, 
		     const char *dictionary = NULL,
		     const char *version = NULL );
  void Print() const;
  void PrintDetails() const;
  void PrintTable() const;
  void PrintDiagnostics();
  void PrintDataBlock(const int dataBlockIndex);
  void PrintDataBlockDetails(const int dataBlockIndex);
  void PrintDataBlockTable(const int dataBlockIndex);
  void FreeExtra();
  CifFile &Copy(const CifFile &file);

  int CountDataBlocks() { return _dataBlocks.Length();}
  int CountCategories(const int dataBlockIndex);
  int CountItem(const int dataBlockIndex, const int categoryIndex);
  int CountItem(const int dataBlockIndex, const CifString categoryName);
  int CountRows(const int dataBlockIndex, const int categoryIndex);

  int GetIndex(const char *Datablock_name);
  int GetIndex(const CifString Datablock_name);

  int GetCategoryIndex(const int dataBlockIndex, const CifString categoryName) ;
  int GetCategoryIndex(const int dataBlockIndex, const char *categoryName) ;
  CifString *GetCategoryName(const int dataBlockIndex, const int categoryIndex) ;
  CifString *GetItemKeyword(const int dataBlockIndex, const int categoryIndex, 
		       const int itemIndex);
  CifString *GetItemName(const int dataBlockIndex, const int categoryIndex, 
		       const int itemIndex);
  CifString *GetItemAliasName(const int dataBlockIndex, const int categoryIndex, 
			   const int itemIndex, const CifString * dictionary
                           = NULL, const CifString * version = NULL);
  int GetItemIndex(const int dataBlockIndex, const int categoryIndex, 
		   const char *itemKeyword);

  CifCategoryIndex *GetTableIndex(const int dataBlockIndex, const char *category, const char *itemName);
  CifCategoryIndex *GetTableIndex(const int dataBlockIndex, const CifString category, const CifString itemName);

  CifCategoryIndex *GetTableIndex(const int dataBlockIndex, const char *itemName);
  CifCategoryIndex *GetTableIndex(const int dataBlockIndex, const CifString itemName);

  int CountDataBlockWarnings(const int dataBlockIndex);
  int CountDataBlockErrors(const int dataBlockIndex) ;
  ReVarCifArray <CifString> *GetDataBlockErrors(const int dataBlockIndex);
  ReVarCifArray <CifString> *GetDataBlockWarnings(const int dataBlockIndex);
  void FreeDataBlockWarnings(const int dataBlockIndex);
  void FreeDataBlockErrors(const int dataBlockIndex);
  CifString *GetDataBlockWarning(const int dataBlockIndex, const int warningIndex);
  CifString *GetDataBlockError(const int dataBlockIndex, const int errorIndex);
  void FreeDataBlockWarning(const int dataBlockIndex, const int warningIndex);
  void FreeDataBlockError(const int dataBlockIndex, const int errorIndex);
  

  ReVarCifArray <CifString> *GetCategoryKeys(const CifString dataBlockName,
				      const CifString categoryName);
  ReVarCifArray <CifString> *GetCategoryKeys(const int dataBlockIndex, const int categoryIndex);

  CifCategory *GetItemAttribute(const CifString dataBlockIndex,
				       const CifItemValue *matchedItemValue,
				       const CifString matchedItemKeyword, 
				       const CifString categoryName,
				       const CifString itemKeyword);

  ReVarCifArray <CifItemValue> *GetColumnItemValues(const int dataBlockIndex, const int categoryIndex,
					      const int itemIndex);
  ReVarCifArray <CifItemValue> *GetColumnItemValues(const CifString dataBlockName, 
					      const CifString categoryName,
					      const CifString itemKeyword);

  int GetItemDataType(const int dataBlockIndex, const int categoryIndex,
		  const int itemIndex);
  int GetItemDataType(const int dataBlockIndex, const CifString categoryName,
		  const CifString itemName);

  int GetItemStructureIndex(const int dataBlockIndex, const int categoryIndex,
			    const int itemIndex);
  int GetItemStructureIndex(const int dataBlockIndex, const CifString categoryName,
			    const CifString itemName);

  int GetItemStructureNumValue(const int dataBlockIndex, const int categoryIndex,
				const int itemIndex);
  int GetItemStructureNumValue(const int dataBlockIndex, const CifString categoryName,
				const CifString itemName);
  int GetItemStructureDimension(const int dataBlockIndex, const int categoryIndex,
				const int itemIndex);
  int GetItemStructureDimension(const int dataBlockIndex, const CifString categoryName,
				const CifString itemName);
  int GetItemStructureOrganization(const int dataBlockIndex, const int categoryIndex,
				   const int itemIndex);
  int GetItemStructureOrganization(const int dataBlockIndex, const CifString categoryName,
				   const CifString itemName);

  int GetItemCaseSensitivity(const int dataBlockIndex, const int categoryIndex,
			     const int itemIndex);
  int GetItemCaseSensitivity(const int dataBlockIndex, const CifString categoryIndex,
			     const CifString itemIndex);
  
  CifItemValue *GetItemDefaultValue(const int dataBlockIndex, const int categoryIndex,
				 const int itemIndex);
  CifItemValue *GetItemDefaultValue(const int dataBlockIndex, const CifString category,
				 const CifString item);

  CifString *GetItemPrimitiveCode(const int dataBlockIndex, const int categoryIndex,
				 const int itemIndex);
  CifString *GetItemPrimitiveCode(const int dataBlockIndex, const CifString category,
				 const CifString item);
  CifString *GetItemDataTypeCode(const int dataBlockIndex, const int categoryIndex,
				 const int itemIndex);
  CifString *GetItemDataTypeCode(const int dataBlockIndex, const CifString category,
				 const CifString item);
  int GetDataBlockDictionaryIndex(const int dataBlockIndex) ;
  CifString *GetDataBlockName(const int dataBlockIndex) ;
  CifString *GetDataBlockFileName(const int dataBlockIndex) ;
  long   GetDataBlockFileOffset(const int dataBlockIndex) ;
  long   GetItemFileOffset(const int dataBlockIndex, const char *name) ;
  long   GetItemFileOffset(const int dataBlockIndex, const CifString name) ;

  int GetItemValue(CifItemValue **itemValue, const int dataBlockIndex,
	       const int categoryIndex, const int itemIndex, const int row_index);
  int GetItemValue(CifString **itemValue, const int dataBlockIndex, const int categoryIndex, 
	       const int itemIndex, const int row_index);
  int GetItemValue(CifItemValue **itemValue, const int dataBlockIndex,const CifString categoryName,
	       const CifString item_label, const int row_index);
  int GetItemValue(CifString **itemValue, const int dataBlockName, const CifString categoryName, 
	       const CifString item_label, const int row_index);

  int UpdateItemValue(CifItemValue *itemValue, const int dataBlockIndex, const int categoryIndex,
		  const int itemIndex, const int row_index, const int verifyFlag);
  int UpdateItemValue(CifItemValue *itemValue, const int dataBlockIndex,
		  const CifString categoryName, const CifString item_label, 
		  const int row_index, const int verifyFlag);

  int InsertItemValue(CifItemValue *itemValue, const int dataBlockIndex,
		  const int categoryIndex, const int itemIndex, 
		  const int row_index, const int verifyFlag);
  int InsertItemValue(CifItemValue *itemValue, const int dataBlockIndex,
		  const CifString categoryName,
		  const CifString item_label, const int row_index,
		  const int verifyFlag);

  int DeleteItemValue(const int dataBlockIndex,const int categoryIndex, 
		  const int itemIndex, const int row_index,
		  const int verifyFlag);
  int DeleteItemValue(const int dataBlockIndex , const CifString categoryName,
		  const CifString item_label, const int row_index,
		  const int verifyFlag);
  ReVarCifArray <CifCategoryIndex> *GetLinkParents(const int dataBlockIndex, 
					       const int categoryIndex, 
					       const int itemIndex);
  ReVarCifArray <CifCategoryIndex> *GetLinkParents(const int dataBlockIndex, 
					       const CifString categoryName,
					       const CifString item_label);
  ReVarCifArray <CifCategoryIndex> *GetLinkChildren(const int dataBlockIndex, 
						const int categoryIndex, 
						const int itemIndex);
  ReVarCifArray <CifCategoryIndex> *GetLinkChildren(const int dataBlockIndex, 
						const CifString categoryName,
						const CifString item_label);

  ReVarCifArray <CifCategoryIndex> *GetDependentItems(const int dataBlockIndex, 
						  const int categoryIndex, 
						  const int itemIndex);
  ReVarCifArray <CifCategoryIndex> *GetDependentItems(const int dataBlockIndex, 
						  const CifString categoryName,
						  const CifString item_label);
  ReVarCifArray <CifRelatedItem> *GetRelatedItems(const int dataBlockIndex, 
						 const int categoryIndex, 
						 const int itemIndex);
  ReVarCifArray <CifRelatedItem> *GetRelatedItems(const int dataBlockIndex, 
						 const CifString categoryName,
						 const CifString item_label);
  int MergeDataBlock(const char *new_dataBlockName, const int dataBlockIndex1,
		      const int dataBlockIndex2);
  void DeleteDataBlock(const int dataBlockIndex);
  void CheckDataBlock(const int dataBlockIndex);
  CifDataBlock *GetDictionaryDataBlock(const int dataBlockIndex);
  CifDataBlock *AddDatablock(const int dictionaryIndex,const CifString dataBlockName);
  CifDataBlock *AddDatablock(const int dictionaryIndex,const char *dataBlockName); 
  CifCategory* AddCategory(const int dataBlockIndex, 
				       const CifString categoryName);
  CifCategory* AddCategory(const int dataBlockIndex, const char *categoryName);
  CifDataItem* AddDataItem(const int dataBlockIndex,
			     const int categoryIndex, const CifString itemName);
  CifDataItem* AddDataItem(const int dataBlockIndex, 
			     const int categoryIndex, const char *itemName);
  int AddRow(const int dataBlockIndex, const int categoryIndex);
  void ErrorMessage(const int dataBlockIndex, const int errorFlag, const char *message);
  void ErrorMessage(const int dataBlockIndex, const int errorFlag, const CifString message);
};


// *********************************************************************
//      CifFile inline functions
// *********************************************************************

inline int CifFile::GetIndex(const CifString Datablock_label)
{
  return GetIndex(Datablock_label.Text());
}

inline void CifFile::FreeExtra()
{
  _dataBlocks.FreeExtra();
}

inline int CifFile::CountCategories(const int dataBlockIndex)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return 0;
  else return _dataBlocks[dataBlockIndex].CountCategories();
}

inline ReVarCifArray <CifString> * CifFile::GetCategoryKeys(const int dataBlockIndex, 
						       const int categoryIndex)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (ReVarCifArray <CifString> *) NULL;
  else return _dataBlocks[dataBlockIndex].GetCategoryKeys(categoryIndex);
}

inline ReVarCifArray <CifString> * CifFile::GetCategoryKeys(const CifString dataBlockName, 
						      const CifString categoryName)
{
  int dataBlockIndex;
  dataBlockIndex = GetIndex(dataBlockName);

  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (ReVarCifArray <CifString> *) NULL;
  else return _dataBlocks[dataBlockIndex].GetCategoryKeys(categoryName);
}

inline CifCategory * 
 CifFile::GetItemAttribute(const CifString dataBlockName,
			    const CifItemValue *matchedItemValue,
			    const CifString matchedItemKeyword, 
			    const CifString categoryName,
			    const CifString itemKeyword)
{
  int dataBlockIndex;
  dataBlockIndex = GetIndex(dataBlockName);

  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (CifCategory *) NULL;
  else return _dataBlocks[dataBlockIndex].GetItemAttribute(matchedItemValue,
							  matchedItemKeyword, 
							  categoryName,
							  itemKeyword);
}

inline ReVarCifArray <CifItemValue> * 
 CifFile::GetColumnItemValues(const int dataBlockIndex,
			       const int categoryIndex,
			       const int itemIndex) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (ReVarCifArray <CifItemValue> *) NULL;
  else return _dataBlocks[dataBlockIndex].GetColumnItemValues(categoryIndex, itemIndex);
}

inline ReVarCifArray <CifItemValue> *
 CifFile::GetColumnItemValues(const CifString dataBlockName,
			       const CifString categoryName,
			       const CifString itemKeyword) 

{
  int dataBlockIndex;
  dataBlockIndex = GetIndex(dataBlockName);

  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (ReVarCifArray <CifItemValue> *) NULL;
  else return _dataBlocks[dataBlockIndex].GetColumnItemValues(categoryName, itemKeyword);
}

inline int CifFile::CountItem(const int dataBlockIndex, const int categoryIndex)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return 0;
  else return _dataBlocks[dataBlockIndex].CountItem(categoryIndex);
}
inline int CifFile::CountItem(const int dataBlockIndex, const CifString categoryName)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return 0;
  else return _dataBlocks[dataBlockIndex].CountItem(categoryName);
}
inline int CifFile::CountRows(const int dataBlockIndex, const int categoryIndex)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return 0;
  else return _dataBlocks[dataBlockIndex].CountRows(categoryIndex);
}
inline CifString *CifFile::GetCategoryName(const int dataBlockIndex, const int categoryIndex)
{

  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (CifString *) NULL;
  else return _dataBlocks[dataBlockIndex].GetCategoryName(categoryIndex);
}
inline CifCategoryIndex *CifFile::GetTableIndex(const int dataBlockIndex, 
						const char *categoryName, 
						const char *item_label)
{

  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (CifCategoryIndex *) NULL;
  else return _dataBlocks[dataBlockIndex].GetTableIndex(categoryName, item_label);
}
inline CifCategoryIndex *CifFile::GetTableIndex(const int dataBlockIndex, 
						const CifString categoryName, 
						const CifString item_label)
{

  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (CifCategoryIndex *) NULL;
  else return _dataBlocks[dataBlockIndex].GetTableIndex(categoryName, item_label);
}
inline CifCategoryIndex *CifFile::GetTableIndex(const int dataBlockIndex, 
						const char *itemName)
{

  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (CifCategoryIndex *) NULL;
  else return _dataBlocks[dataBlockIndex].GetTableIndex(itemName);
}
inline CifCategoryIndex *CifFile::GetTableIndex(const int dataBlockIndex, 
						const CifString itemName) 
{

  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (CifCategoryIndex *) NULL;
  else return _dataBlocks[dataBlockIndex].GetTableIndex(itemName);
}
inline int CifFile::GetCategoryIndex(const int dataBlockIndex, 
				      const CifString categoryName)
{

  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return -1;
  else return _dataBlocks[dataBlockIndex].GetIndex(categoryName);
}
inline int CifFile::GetCategoryIndex(const int dataBlockIndex, 
				      const char *categoryName)
{

  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return -1;
  else return _dataBlocks[dataBlockIndex].GetIndex(categoryName);
}
inline CifString *CifFile::GetItemKeyword(const int dataBlockIndex,
				    const int categoryIndex, const int itemIndex) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (CifString *) NULL;
  else return _dataBlocks[dataBlockIndex].GetItemKeyword(categoryIndex, itemIndex);
}
inline int CifFile::GetItemIndex(const int dataBlockIndex,
				  const int categoryIndex, const char *itemKeyword) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  -1;
  else return _dataBlocks[dataBlockIndex].GetItemIndex(categoryIndex, itemKeyword);
}
inline CifString *CifFile::GetItemName(const int dataBlockIndex,
				    const int categoryIndex, const int itemIndex) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (CifString *) NULL;
  else return _dataBlocks[dataBlockIndex].GetItemName(categoryIndex, itemIndex);
}
inline CifString *CifFile::GetItemAliasName(const int dataBlockIndex,
				    const int categoryIndex, const int itemIndex, const CifString * dictionary, const CifString * version) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (CifString *) NULL;
  else return _dataBlocks[dataBlockIndex].GetItemAliasName(categoryIndex, itemIndex, dictionary, version);
}











inline int CifFile::GetItemStructureIndex(const int dataBlockIndex, 
				 const int categoryIndex,
				 const int itemIndex) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  CIF_DATABLOCK_NOT_EXIST ;
  else return _dataBlocks[dataBlockIndex].GetItemStructureIndex(categoryIndex, itemIndex);
}
inline int CifFile::GetItemStructureIndex(const int dataBlockIndex, 
					  const CifString categoryName,
					  const CifString itemName) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  CIF_DATABLOCK_NOT_EXIST ;
  else return _dataBlocks[dataBlockIndex].GetItemStructureIndex(categoryName, itemName);
}
inline int CifFile::GetItemStructureNumValue(const int dataBlockIndex, 
				 const int categoryIndex,
				 const int itemIndex) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  CIF_DATABLOCK_NOT_EXIST ;
  else return _dataBlocks[dataBlockIndex].GetItemStructureNumValue(categoryIndex, itemIndex);
}
inline int CifFile::GetItemStructureNumValue(const int dataBlockIndex, 
					  const CifString categoryName,
					  const CifString itemName) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  CIF_DATABLOCK_NOT_EXIST ;
  else return _dataBlocks[dataBlockIndex].GetItemStructureNumValue(categoryName, itemName);
}
inline int CifFile::GetItemStructureDimension(const int dataBlockIndex, 
				 const int categoryIndex,
				 const int itemIndex) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  CIF_DATABLOCK_NOT_EXIST ;
  else return _dataBlocks[dataBlockIndex].GetItemStructureDimension(categoryIndex, itemIndex);
}
inline int CifFile::GetItemStructureDimension(const int dataBlockIndex, 
					  const CifString categoryName,
					  const CifString itemName) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  CIF_DATABLOCK_NOT_EXIST ;
  else return _dataBlocks[dataBlockIndex].GetItemStructureDimension(categoryName, itemName);
}
inline int CifFile::GetItemStructureOrganization(const int dataBlockIndex, 
				 const int categoryIndex,
				 const int itemIndex) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  CIF_DATABLOCK_NOT_EXIST ;
  else return _dataBlocks[dataBlockIndex].GetItemStructureOrganization(categoryIndex, itemIndex);
}
inline int CifFile::GetItemStructureOrganization(const int dataBlockIndex, 
					  const CifString categoryName,
					  const CifString itemName) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  CIF_DATABLOCK_NOT_EXIST ;
  else return _dataBlocks[dataBlockIndex].GetItemStructureOrganization(categoryName, itemName);
}
inline int CifFile::GetItemCaseSensitivity(const int dataBlockIndex, 
					  const int categoryIndex,
					  const int itemIndex) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  CIF_DATABLOCK_NOT_EXIST ;
  else return _dataBlocks[dataBlockIndex].GetItemCaseSensitivity(categoryIndex, itemIndex);
}
inline int CifFile::GetItemCaseSensitivity(const int dataBlockIndex, 
					  const CifString categoryName,
					  const CifString itemName) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  CIF_DATABLOCK_NOT_EXIST ;
  else return _dataBlocks[dataBlockIndex].GetItemCaseSensitivity(categoryName, itemName);
}
inline CifItemValue*CifFile::GetItemDefaultValue(const int dataBlockIndex, 
					       const int categoryIndex,
					       const int itemIndex) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  NULL;
  else return _dataBlocks[dataBlockIndex].GetItemDefaultValue(categoryIndex, itemIndex);

}
inline CifItemValue*CifFile::GetItemDefaultValue(const int dataBlockIndex, 
					       const CifString category,
					       const CifString item) 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  NULL;
  else return _dataBlocks[dataBlockIndex].GetItemDefaultValue(category, item);
}

inline ReVarCifArray <CifCategoryIndex> *CifFile::
  GetLinkParents(const int dataBlockIndex, const int categoryIndex, 
			 const int itemIndex)
// ----------------------------------------------------------------------
//   GetIndex() Finds the index of the keyword in items array, 
//              -1 if not found
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (ReVarCifArray <CifCategoryIndex> *)  NULL;
  else return _dataBlocks[dataBlockIndex].GetLinkParents(categoryIndex, itemIndex);

}
inline ReVarCifArray <CifCategoryIndex> *CifFile::
  GetLinkParents(const int dataBlockIndex, const CifString categoryName, 
			const CifString item_label)
// ----------------------------------------------------------------------
//   GetIndex() Finds the index of the keyword in items array, 
//              -1 if not found
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (ReVarCifArray <CifCategoryIndex> *) NULL;
  else return _dataBlocks[dataBlockIndex].GetLinkParents(categoryName, item_label);
}
inline ReVarCifArray <CifCategoryIndex> *CifFile::
GetLinkChildren(const int dataBlockIndex, const int categoryIndex, 
		const int itemIndex)
// ----------------------------------------------------------------------
//   GetIndex() Finds the index of the keyword in items array, 
//              -1 if not found
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (ReVarCifArray <CifCategoryIndex> *) NULL;
  else return _dataBlocks[dataBlockIndex].GetLinkChildren(categoryIndex, itemIndex);

}
inline ReVarCifArray <CifCategoryIndex> *CifFile::
  GetLinkChildren(const int dataBlockIndex, const CifString categoryName, 
			const CifString item_label)
// ----------------------------------------------------------------------
//   GetIndex() Finds the index of the keyword in items array, 
//              -1 if not found
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (ReVarCifArray <CifCategoryIndex> *) NULL;
  else return _dataBlocks[dataBlockIndex].GetLinkChildren(categoryName, item_label);
}
inline ReVarCifArray <CifCategoryIndex> *CifFile::
  GetDependentItems(const int dataBlockIndex, const int categoryIndex, 
		    const int itemIndex)
// ----------------------------------------------------------------------
//   GetIndex() Finds the index of the keyword in items array, 
//              -1 if not found
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (ReVarCifArray <CifCategoryIndex> *)  NULL;
  else return _dataBlocks[dataBlockIndex].GetDependentItems(categoryIndex, itemIndex);
  
}
inline ReVarCifArray <CifCategoryIndex> *CifFile::
GetDependentItems(const int dataBlockIndex, const CifString categoryName, 
		  const CifString item_label)
// ----------------------------------------------------------------------
//   GetIndex() Finds the index of the keyword in items array, 
//              -1 if not found
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (ReVarCifArray <CifCategoryIndex> *) NULL;
  else return _dataBlocks[dataBlockIndex].GetDependentItems(categoryName, item_label);
}
inline ReVarCifArray <CifRelatedItem> *CifFile::
  GetRelatedItems(const int dataBlockIndex, const int categoryIndex, 
		  const int itemIndex)
// ----------------------------------------------------------------------
//   GetIndex() Finds the index of the keyword in items array, 
//              -1 if not found
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (ReVarCifArray <CifRelatedItem> *)  NULL;
  else return _dataBlocks[dataBlockIndex].GetRelatedItems(categoryIndex, itemIndex);
  
}
inline ReVarCifArray <CifRelatedItem> *CifFile::
  GetRelatedItems(const int dataBlockIndex, const CifString categoryName, 
		  const CifString item_label)
// ----------------------------------------------------------------------
//   GetIndex() Finds the index of the keyword in items array, 
//              -1 if not found
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (ReVarCifArray <CifRelatedItem> *) NULL;
  else return _dataBlocks[dataBlockIndex].GetRelatedItems(categoryName, item_label);
}
inline CifString *CifFile::GetDataBlockName(const int dataBlockIndex)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (CifString *) NULL;
  else return _dataBlocks[dataBlockIndex].GetDataBlockName();
}
inline int CifFile::GetDataBlockDictionaryIndex(const int dataBlockIndex)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  -1;
  else return _dataBlocks[dataBlockIndex].GetDataBlockDictionaryIndex();
}

inline CifString *CifFile::GetDataBlockFileName(const int dataBlockIndex)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (CifString *) NULL;
  else return _dataBlocks[dataBlockIndex].GetFileName();
}

inline long CifFile::GetDataBlockFileOffset(const int dataBlockIndex)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  -1;
  else return _dataBlocks[dataBlockIndex].GetFileOffset();
}

inline long CifFile::GetItemFileOffset(const int dataBlockIndex,
				    const char *category)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  -1;
  else return _dataBlocks[dataBlockIndex].GetItemFileOffset(category);
}

inline long CifFile::GetItemFileOffset(const int dataBlockIndex,
				    const CifString category)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  -1;
  else return _dataBlocks[dataBlockIndex].GetItemFileOffset(category);
}
/*
inline CifString *CifFile::GetAliasName(const int dataBlockIndex, const int index)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (CifString *) NULL;
  else return _dataBlocks[dataBlockIndex].GetAliasName(index);
}
inline CifString *CifFile::GetAliasItemKeyword(const int dataBlockIndex, const int index)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return (CifString *)  NULL;
  else return _dataBlocks[dataBlockIndex].GetAliasItemKeyword(index);
}
inline CifString *CifFile::GetAliasCategoryName(const int dataBlockIndex, const int index)
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return  (CifString  *) NULL;
  else return _dataBlocks[dataBlockIndex].GetAliasCategoryName(index);
}
*/
inline int CifFile::GetItemValue(CifItemValue **itemValue, const int dataBlockIndex,
			      const int categoryIndex, const int itemIndex, 
			      const int row_index)
// ----------------------------------------------------------------------
//   GetItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return CIF_DATABLOCK_NOT_EXIST;
  else return _dataBlocks[dataBlockIndex].GetItemValue(itemValue, categoryIndex,
					     itemIndex, row_index);
}

inline int CifFile::GetItemValue(CifString **itemValue, const int dataBlockIndex, 
			      const int categoryIndex, const int itemIndex, 
			      const int row_index)
// ----------------------------------------------------------------------
//   GetItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return CIF_DATABLOCK_NOT_EXIST;
  else return _dataBlocks[dataBlockIndex].GetItemValue(itemValue, categoryIndex,
					     itemIndex, row_index);
}

inline int CifFile::GetItemValue(CifItemValue **itemValue, const int dataBlockIndex,
			      const CifString categoryName, const CifString item_label, 
			      const int row_index)
// ----------------------------------------------------------------------
//   GetItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return CIF_DATABLOCK_NOT_EXIST;
  else return _dataBlocks[dataBlockIndex].GetItemValue(itemValue, categoryName,
					     item_label, row_index);
}

inline int CifFile::GetItemValue(CifString **itemValue, const int dataBlockIndex, 
			      const CifString categoryName, const CifString item_label, 
			      const int row_index)
// ----------------------------------------------------------------------
//   GetItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return CIF_DATABLOCK_NOT_EXIST;
  else 
    return _dataBlocks[dataBlockIndex].GetItemValue(itemValue, categoryName,
						item_label, row_index);
}

inline int CifFile::UpdateItemValue(CifItemValue *itemValue, const int dataBlockIndex,
			  const int categoryIndex, const int itemIndex, 
			  const int row_index, const int verifyFlag)
// ----------------------------------------------------------------------
//   UpdateItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return CIF_DATABLOCK_NOT_EXIST;
  else 
    return 
      _dataBlocks[dataBlockIndex].
	UpdateItemValue(&_dataBlocks[_dataBlocks[dataBlockIndex]._dictionaryIndex],
		    itemValue, categoryIndex,itemIndex, row_index, verifyFlag);
}

inline int CifFile::UpdateItemValue(CifItemValue *itemValue, const int dataBlockIndex,
			  const CifString categoryName, const CifString item_label, 
			  const int row_index, const int verifyFlag)
// ----------------------------------------------------------------------
//   UpdateItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return CIF_DATABLOCK_NOT_EXIST;
  else
    return 
      _dataBlocks[dataBlockIndex].
	UpdateItemValue(&_dataBlocks[_dataBlocks[dataBlockIndex]._dictionaryIndex],
		    itemValue, categoryName, item_label, row_index, verifyFlag);
}

inline int CifFile::InsertItemValue(CifItemValue *itemValue, const int dataBlockIndex,
			  const CifString categoryName, const CifString item_label, 
			  const int row_index, const int verifyFlag)
// ----------------------------------------------------------------------
//   InsertItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return CIF_DATABLOCK_NOT_EXIST;
  else return _dataBlocks[dataBlockIndex].
    InsertItemValue(&_dataBlocks[_dataBlocks[dataBlockIndex]._dictionaryIndex],
		itemValue, categoryName, item_label, row_index, verifyFlag);
}

inline int CifFile::InsertItemValue(CifItemValue *itemValue, const int dataBlockIndex,
			  const int categoryIndex, const int itemIndex, 
			  const int row_index, const int verifyFlag)
// ----------------------------------------------------------------------
//   InsertItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return CIF_DATABLOCK_NOT_EXIST;
  else
    return _dataBlocks[dataBlockIndex].
      InsertItemValue(&_dataBlocks[_dataBlocks[dataBlockIndex]._dictionaryIndex],
		  itemValue, categoryIndex, itemIndex, row_index, verifyFlag);
}

inline int CifFile::DeleteItemValue(const int dataBlockIndex,
				 const int categoryIndex, const int itemIndex, 
				 const int row_index, const int verifyFlag)
// ----------------------------------------------------------------------
//   InsertItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return CIF_DATABLOCK_NOT_EXIST;
  else return _dataBlocks[dataBlockIndex].DeleteItemValue(categoryIndex,
						      itemIndex, row_index,
						      verifyFlag);
}

inline int CifFile::DeleteItemValue(const int dataBlockIndex,
				 const CifString categoryName, const CifString item_label, 
				 const int row_index, const int verifyFlag)
// ----------------------------------------------------------------------
//   InsertItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex < 0 || dataBlockIndex >= _dataBlocks.Length())
    return CIF_DATABLOCK_NOT_EXIST;
  else return _dataBlocks[dataBlockIndex].DeleteItemValue(categoryName, item_label, 
						      row_index, verifyFlag);
}

inline void CifFile::PrintDataBlock(const int dataBlockIndex)
// ----------------------------------------------------------------------
//   InsertItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    _dataBlocks[dataBlockIndex].Print();
						 
}
inline void CifFile::PrintDataBlockDetails(const int dataBlockIndex)
// ----------------------------------------------------------------------
//   InsertItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    _dataBlocks[dataBlockIndex].PrintDetails();
						 
}
inline void CifFile::PrintDataBlockTable(const int dataBlockIndex)
// ----------------------------------------------------------------------
//   InsertItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    _dataBlocks[dataBlockIndex].PrintTable();
						 
}
inline void CifFile::ErrorMessage(const int dataBlockIndex,
				      const int errorFlag, const char *message)
// ----------------------------------------------------------------------
//   InsertItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    _dataBlocks[dataBlockIndex].ErrorMessage(errorFlag, -1, message);
						 
}
inline void CifFile::ErrorMessage(const int dataBlockIndex,
				      const int errorFlag, const CifString message)
// ----------------------------------------------------------------------
//   InsertItemValue() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    _dataBlocks[dataBlockIndex].ErrorMessage(errorFlag, -1, message);
						 
}
inline CifDataBlock *CifFile::AddDatablock(const int dictionaryIndex,
					     const CifString dataBlockName)

// ----------------------------------------------------------------------
//   AddDatabLock() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  return AddDatablock(dictionaryIndex, dataBlockName.Text());
						 
}

inline CifCategory *CifFile::AddCategory(const int dataBlockIndex,
						 const CifString categoryName)
// ----------------------------------------------------------------------
//   AddCategory() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  return AddCategory(dataBlockIndex, categoryName.Text());
}

inline CifDataItem *CifFile::AddDataItem(const int dataBlockIndex,
					    const int categoryIndex, 
					    const CifString itemName)
// ----------------------------------------------------------------------
//   AddDataItem() Gets itemValue from itemValues array
// --------------------------------------------------------------------- 
{
  return AddDataItem(dataBlockIndex, categoryIndex, itemName.Text());
}

inline int CifFile::CountDataBlockWarnings(const int dataBlockIndex)
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    return _dataBlocks[dataBlockIndex].CountWarnings();
  else return 0;
}
inline int CifFile::CountDataBlockErrors(const int dataBlockIndex) 
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    return _dataBlocks[dataBlockIndex].CountErrors() ;
  else return 0;
}
inline ReVarCifArray <CifString> *CifFile::GetDataBlockErrors(const int dataBlockIndex)
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    return _dataBlocks[dataBlockIndex].GetErrors();
  else return NULL;
}
inline ReVarCifArray <CifString> *CifFile::GetDataBlockWarnings(const int dataBlockIndex)
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    return _dataBlocks[dataBlockIndex].GetWarnings();
  else return NULL;
}
inline void CifFile::FreeDataBlockWarnings(const int dataBlockIndex)
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    _dataBlocks[dataBlockIndex].FreeWarnings();
}
inline void CifFile::FreeDataBlockErrors(const int dataBlockIndex)
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    _dataBlocks[dataBlockIndex].FreeErrors();
}
inline CifString *CifFile::GetDataBlockWarning(const int dataBlockIndex, const int warningIndex)
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
     return _dataBlocks[dataBlockIndex].GetWarning(warningIndex);
  else return NULL;
}
inline CifString *CifFile::GetDataBlockError(const int dataBlockIndex, const int errorIndex)
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    return _dataBlocks[dataBlockIndex].GetError(errorIndex);
  else return NULL;
}
inline void CifFile::FreeDataBlockWarning(const int dataBlockIndex, const int warningIndex)
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    _dataBlocks[dataBlockIndex].FreeWarning(warningIndex);
}
inline void CifFile::FreeDataBlockError(const int dataBlockIndex, const int errorIndex)
{
  if (dataBlockIndex >= 0 && dataBlockIndex < _dataBlocks.Length())
    _dataBlocks[dataBlockIndex].FreeError(errorIndex);
}
  
#endif
 
