SDMDataObjectReader.h
Go to the documentation of this file.00001 #ifndef SDMDataObjectReader_CLASS
00002 #define SDMDataObjectReader_CLASS
00003
00004 #include <string>
00005 #include <map>
00006 #include <set>
00007 #include <vector>
00008 #include <bitset>
00009
00010 #ifdef REG_BASIC
00011 #undef REG_BASIC
00012 #endif
00013
00014 #ifdef REG_EXTENDED
00015 #undef REG_EXTENDED
00016 #endif
00017
00018 #ifdef REG_ICASE
00019 #undef REG_ICASE
00020 #endif
00021
00022 #ifdef REG_NOSUB
00023 #undef REG_NOSUB
00024 #endif
00025
00026 #ifdef REG_NEWLINE
00027 #undef REG_NEWLINE
00028 #endif
00029
00030 #ifdef REG_NOTBOL
00031 #undef REG_NOTBOL
00032 #endif
00033
00034 #ifdef REG_NOTEOL
00035 #undef REG_NOTEOL
00036 #endif
00037
00038 #ifdef REG_STARTEND
00039 #undef REG_STARTEND
00040 #endif
00041
00042
00043 #include <boost/regex.hpp>
00044
00045 #include "SDMDataObjectParser.h"
00046 #include "SDMDataObject.h"
00047
00048 using namespace std;
00049 using namespace boost;
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063 namespace asdmbinaries {
00067 class SDMDataObjectReaderException {
00068
00069 public:
00073 SDMDataObjectReaderException();
00074
00079 SDMDataObjectReaderException(string m);
00080
00084 virtual ~SDMDataObjectReaderException();
00085
00090 string getMessage() const;
00091
00092 protected:
00093 string message;
00094
00095 };
00096
00097 inline SDMDataObjectReaderException::SDMDataObjectReaderException() : message ("SDMDataObjectReaderException") {}
00098 inline SDMDataObjectReaderException::SDMDataObjectReaderException(string m) : message(m) {}
00099 inline SDMDataObjectReaderException::~SDMDataObjectReaderException() {}
00100 inline string SDMDataObjectReaderException::getMessage() const {
00101 return "SDMDataObjectReaderException : " + message;
00102 }
00103
00112 class SDMDataObjectReader {
00113 public:
00117 SDMDataObjectReader();
00118
00122 virtual ~SDMDataObjectReader();
00123
00131 const SDMDataObject & read(string filename);
00132
00141 const SDMDataObject & read(const char * buffer, unsigned long int size, bool fromFile=false);
00142
00143
00150 const SDMDataObject & ref() const;
00151
00158 const SDMDataObject * ptr() const;
00159
00164 void done();
00165
00166 private:
00167 enum READ {UNKNOWN_, MEMORY_, FILE_};
00168 READ read_;
00169
00170 int filedes_;
00171 unsigned int dataSize_;
00172 char* data_;
00173 string::size_type position_;
00174 string::size_type lastPosition_;
00175 string::size_type endPosition_;
00176
00177 unsigned int integrationNum_;
00178 unsigned int scanNum_;
00179
00180 static const bool initClass_;
00181 static bool initClass();
00182 void init() ;
00183 string::size_type find(const string& s);
00184 bool compare(const string& s);
00185 bool EOD();
00186
00187
00188 static const string MIMEBOUNDARY_1;
00189 static const string MIMEBOUNDARY_2;
00190
00191
00192 static const regex CONTENTIDDATASTRUCTUREREGEXP;
00193 static const regex CONTENTIDSUBSETREGEXP;
00194 static const regex CONTENTIDBINREGEXP;
00195 static const regex CONTENTIDBINREGEXP1;
00196 static const regex CONTENTIDBINREGEXP2;
00197
00198
00199 static set<string> BINATTACHNAMES;
00200 enum BINATTACHCODES {ACTUALDURATIONS=0, ACTUALTIMES=1, AUTODATA=2, FLAGS=3, CROSSDATA=4, ZEROLAGS=5};
00201 static map<string, BINATTACHCODES> name2code;
00202
00203 string extractXMLHeader(const string& boundary);
00204 void tokenize(const string& str, vector<string>& tokens, const string& delimiters);
00205 void getFields(const string& header, map<string, string>& fields);
00206 string getContentID();
00207 string getContentLocation();
00208
00209 void processMIME();
00210 void processMIMESDMDataHeader();
00211 void processMIMESDMDataSubsetHeader(SDMDataSubset& sdmDataSubset);
00212 void processMIMEIntegrations();
00213 void processMIMEIntegration();
00214 void processMIMESubscan();
00215 void processBinaryAttachment(const string& boundary, const SDMDataSubset& sdmDataSubset);
00216
00217
00218
00219 SDMDataObjectParser parser_;
00220 SDMDataObject sdmDataObject_;
00221 const SDMDataObject& sdmDataObject();
00222
00223 bitset<6> attachmentFlags;
00224
00225 const ACTUALTIMESTYPE * actualTimes_;
00226 unsigned long int nActualTimes_;
00227 const ACTUALDURATIONSTYPE * actualDurations_;
00228 unsigned long int nActualDurations_;
00229 const ZEROLAGSTYPE * zeroLags_;
00230 unsigned long int nZeroLags_;
00231 const FLAGSTYPE * flags_;
00232 unsigned long int nFlags_;
00233 const INTCROSSDATATYPE * longCrossData_;
00234 const SHORTCROSSDATATYPE * shortCrossData_;
00235 const FLOATCROSSDATATYPE * floatCrossData_;
00236 unsigned long int nCrossData_;
00237 const AUTODATATYPE * autoData_;
00238 unsigned long int nAutoData_;
00239
00240 };
00241 }
00242 #endif // SDMDataObjectReader_CLASS