MTK++ Latest version: 0.2.0

baseParser.h
Go to the documentation of this file.
00001 
00035 #ifndef BASEPARSER_H
00036 #define BASEPARSER_H
00037 
00038 #ifdef __INTEL_COMPILER
00039 
00040 // remark #177: variable was declared but never referenced
00041 #pragma warning(disable:177)
00042 
00043 // remark #181: argument is incompatible with corresponding format string conversion
00044 #pragma warning(disable:181)
00045 
00046 // remark #304: access control not specified ("public" by default)
00047 #pragma warning(disable:304)
00048 
00049 // remark #383: value copied to temporary, reference to temporary used
00050 #pragma warning(disable:383)
00051 
00052 // remark #424: extra ";" ignored
00053 #pragma warning(disable:424)
00054 
00055 // remark #593: variable was set but never used
00056 #pragma warning(disable:593)
00057 
00058 // remark #810: conversion from "double" to "int" may lose significant bits
00059 #pragma warning(disable:810)
00060 
00061 // remark #869: parameter was never referenced
00062 #pragma warning(disable:869)
00063 
00064 // remark #981: operands are evaluated in unspecified order
00065 #pragma warning(disable:981)
00066 
00067 // warning #1125: virtual function override intended?
00068 #pragma warning(disable:1125)
00069 
00070 // remark #1418: external function definition with no prior declaration
00071 #pragma warning(disable:1418)
00072 
00073 // remark #1572: floating-point equality and inequality comparisons are unreliable
00074 // disabled -> everyone knows it, the parser passes this problem
00075 //             deliberately to the user
00076 #pragma warning(disable:1572)
00077 
00078 // remark #1599: declaration hides variable "t"
00079 #pragma warning(disable:1599)
00080 
00081 // remark #2259: non-pointer conversion from "double" to "int" may lose significant bits
00082 #pragma warning(disable:2259)
00083 
00084 #endif
00085 
00086 #include <string>
00087 #include <iostream>
00088 #include <sstream>
00089 #include <fstream>
00090 #include <iomanip>
00091 
00092 #include <stdlib.h>
00093 #include <stdio.h>
00094 
00095 #ifdef USE_QT
00096 #include <QtCore>
00097 #include <QtXml>
00098 #elif defined(USE_TINYXML)
00099 #include <sstream>
00100 #include "tinyxml/tinyxml.h"
00101 #endif
00102 
00103 namespace MTKpp
00104 {
00105 
00106 // ============================================================
00107 // Struct : AtomLine
00108 // ------------------------------------------------------------
00115 // ============================================================
00116 struct AtomLine
00117 {
00118      std::string typ;
00119      int serial;
00120      std::string name;
00121      std::string altLoc;
00122      std::string resName;
00123      int resSeq, massdiff,stereo, hcount,strcare,valence;
00124      std::string iCode;
00125      double x;
00126      double y;
00127      double z;
00128      std::string segID; 
00129      std::string element;
00130      std::string charge;
00131 };
00132 
00133 // ============================================================
00134 // Class : baseParser()
00135 // ------------------------------------------------------------
00143 // ============================================================
00144 class baseParser
00145 {
00146 public:
00147 
00151     baseParser();
00152 
00154     virtual ~baseParser();
00155 
00159     virtual void             Read();
00160 
00164     virtual void             Write();
00165 
00169     std::ofstream&            OpenFile(std::string fileName);
00170 
00174     std::string               determineElement(std::string &name);
00175 
00180     void setError(int i) {
00181       if (i) {
00182         this->bError = true;
00183       }
00184       else {
00185         this->bError = false;
00186       }
00187     }
00188 
00193     bool getError() {
00194       return this->bError;
00195     }
00196 
00201     void setErrorMessage(std::string s) {
00202       this->errorMessage = s;
00203     }
00204 
00209     std::string getErrorMessage() {
00210       return this->errorMessage;
00211     }
00212 
00213 #ifdef USE_QT
00214 protected:
00220     QString string2QString(std::string s);
00221 
00227     QString int2QString(int i);
00228 
00234     QString double2QString(double d);
00235 
00236 #endif // USE_QT
00237 
00238 #ifdef USE_TINYXML
00239 protected:
00240 
00245     const char* getIndent(unsigned int numIndents);
00246 
00251     const char* getIndentAlt(unsigned int numIndents);
00252 
00257     int dump_attribs_to_stdout(TiXmlElement* pElement, unsigned int indent);
00258 
00263     void dump_to_stdout(TiXmlNode* pParent, unsigned int indent = 0);
00264 
00269     void dump_to_stdout(const char* pFilename);
00270 
00271 #endif // USE_TINYXML
00272 
00273 protected:
00274 
00276     std::ofstream outputFileStream;
00277 
00279     bool bError;
00280 
00282     std::string errorMessage;
00283 
00285     unsigned int NUM_INDENTS_PER_SPACE;
00286 };
00287 
00288 } // MTKpp namespace
00289 
00290 #endif // BASEPARSER_H

Generated on Fri Dec 23 2011 09:28:49 for MTK++ by Doxygen 1.7.5.1