CifFile.h

Go to the documentation of this file.
00001 //$$FILE$$
00002 //$$VERSION$$
00003 //$$DATE$$
00004 //$$LICENSE$$
00005 
00006 
00007 /* 
00008   PURPOSE:    Base class for read/write cif files
00009 */
00010 
00011 
00012 #ifndef CIFFILE_H
00013 #define CIFFILE_H
00014 
00015 
00016 #include <string>
00017 #include <vector>
00018 #include <iostream>
00019 
00020 
00021 #include "CifString.h"
00022 #include "TableFile.h"
00023 #include "ndb_misclib.h"
00024 
00025 
00026 class CifFile : public TableFile
00027 {
00028   private:
00029     void Init();
00030     void ConvertEscapedString(const string& inString, string& outString);
00031 
00032   protected:
00033     static const unsigned int STD_PRINT_SPACING = 3;
00034     static const unsigned int SMART_PRINT_SPACING = 1;
00035     static const unsigned int HEADER_SPACING = 40;
00036 
00037     enum eIdentType
00038     {
00039         eNONE = 0,
00040         eLEFT,
00041         eRIGHT
00042     };
00043 
00044     unsigned int _maxCifLineLength;
00045     string _nullValue;
00046     bool _verbose;
00047     bool _smartPrint;
00048     string _quotes;
00049 
00050     int _IsQuotableText(const string& itemValue);
00051     eIdentType _FindPrintType(const vector<string>& values);
00052 
00053     void _PrintItemIdent(ostream& cifo, unsigned int& linePos);
00054     void _PrintItemName(ostream& cifo, const string& category,
00055       const string& itemName, unsigned int& linePos);
00056     void _PrintPostItemSeparator(ostream& cifo, unsigned int& linePos,
00057       const bool ident = false, const unsigned int numSpaces = 1);
00058 
00059     int _PrintItemValue(ostream& cifo, const string& itemValue,
00060       unsigned int& linePos, const eIdentType identType = eNONE,
00061       const unsigned int width = 0);
00062 
00063     int _PrintItemNameInHeader(ostream& cifo, const string& itemValue,
00064       unsigned int& linePos, const eIdentType identType = eNONE,
00065       const unsigned int width = 0);
00066 
00067     void _PrintHeaderedItems(ostream& cifo, const vector<string>& colNames,
00068       const vector<unsigned int>& colWidths,
00069       const vector<eIdentType> colPrintType);
00070 
00071     int Write(ostream& cifo, vector<unsigned int>& tables,
00072       const bool writeEmptyTables = false);
00073 
00074     int MandatoryCategoryChecking(CifFile& ref, ofstream& log);
00075     int ItemsChecking(CifFile& ref, ofstream& log);
00076 
00077   public:
00078     static const unsigned int STD_CIF_LINE_LENGTH = 80;
00079 
00080     enum eQuoting
00081     {
00082         eSINGLE = 0,
00083         eDOUBLE
00084     };
00085 
00086     CifFile(const StringCompare::eCompareType caseSense =
00087       StringCompare::eCASE_SENSITIVE) : TableFile(caseSense)
00088     {
00089         Init(); 
00090     };
00091 
00092     CifFile(const eFileMode fileMode, const string& objFileName,
00093       const bool verbose = false, const StringCompare::eCompareType
00094       caseSense = StringCompare::eCASE_SENSITIVE,
00095       const unsigned int maxLineLength = STD_CIF_LINE_LENGTH,
00096       const string& nullValue = CifString::NullValue);
00097 
00098     ~CifFile()
00099     {
00100     };
00101 
00102     inline bool GetVerbose()
00103     {
00104         return(_verbose);
00105     };
00106 
00107     void SetSmartPrint(bool smartPrint = true) {_smartPrint = smartPrint;};
00108     inline bool IsSmartPrint() {return(_smartPrint);};
00109 
00110     void SetQuoting(eQuoting quoting);
00111     unsigned int GetQuoting();
00112  
00113     // Does not print empty Table (table with no row) if
00114     //  writeEmptyTables = false
00115     int Write(const string& cifFileName, const bool sortTables = false,
00116       const bool writeEmptyTables = false);
00117     int Write(ostream& cifo, const bool sortTables = false,
00118       const bool writeEmptyTables = false);
00119     int Write(const string& cifFileName, const vector<string>& catOrder,
00120       const bool writeEmptyTables = false);
00121     int Write(ostream& cifo, const vector<string>& catOrder,
00122       const bool writeEmptyTables = false);
00123 
00124     int DataChecking(CifFile& ref);
00125 
00126     static void GetItemNames(vector<string>& itemNames, ISTable& isTable);
00127 
00128 };
00129 
00130 
00131 #endif

Generated on Mon Apr 2 09:28:56 2007 for cif-file-v1.0 by  doxygen 1.5.1