VHISTlib  1.84.0.3018
/daten/ahuesgen/projects/vhist/code/vhistlib/include/unvhistlib/xmlit.h
00001 /*
00002 $Id: xmlit.h 2792 2013-05-06 11:25:27Z michael $
00003 (c) Max-Planck-Institute for 
00004     Neurological Research (MPIFNF)
00005     Cologne, Germany 2005
00006     http://www.nf.mpg.de/vinci
00007     Email: vinci@nf.mpg.mpg.de
00008 */
00009 
00010 /*
00011     VXMLLevel1Iter xi0=qs, xi1;
00012     xi0++;
00013     if (xi0.getTag() == "Level0" ) 
00014         for (xi1=xi0.getData();xi1;xi1++)
00015         {
00016             QString tag = xi1.getTag();
00017             QString data = xi1.getData();
00018 
00019             QString qst = QString("tag: %1, data: %2\n").arg(tag).arg(data);
00020             lprintf ( qst );
00021         }
00022     else
00023     {
00024         lprintf( "*** XML error.\n" );
00025     }
00026 */
00027 
00028 #ifndef VT_XML_H
00029 #define VT_XML_H
00030 
00031 //#include "../include/misc_defines.h"
00032 
00033 #ifndef USING_PCH
00034 #include <QString>
00035 #endif
00036 
00037 namespace vhist
00038 {
00039 
00040 class VXMLLevel1Iter
00041 {
00042 public:
00043     VXMLLevel1Iter ( const QString &szXML );
00044     ~VXMLLevel1Iter ( );
00045 
00046     VXMLLevel1Iter(void);
00047     VXMLLevel1Iter(const VXMLLevel1Iter &anOther);
00048 
00049     VXMLLevel1Iter &operator=(const QString &szReInit);
00050     VXMLLevel1Iter &operator=(const VXMLLevel1Iter &anOther);
00051     
00052     inline const QString getTag(void) const;
00053     inline const QString getData(void) const;
00054     inline const QString getRemain(void) const;
00055     const QString getTagAndData(void) const;
00056 
00057     inline bool isTag(const QString szTestTag) const;
00058     inline bool isData(const QString szTestData) const;    
00059     inline int dataToInt() const;    
00060     inline double dataToDouble() const;    
00061 
00062     bool dataTo3Int(int &i1, int &i2, int &i3) const;
00063     bool dataTo3Double(double &r1, double &r2, double &r3) const;
00064     
00065     QString replaceCurrentTag(QString szReplacement);
00066     void setWithMsg(const bool bWithMsg)
00067         {m_bWithMsg=bWithMsg; }
00068 
00069     inline operator bool(void);
00070     inline operator const QString(void);
00071 
00072     const QString operator++(void);
00073     const QString operator++(int);
00074 
00075 private:
00076     QString        m_szXMLOrig;
00077     QString        m_szXML;
00078     QChar*        m_pcXML;
00079     int            m_iCurPos;
00080     int            m_iLength;
00081 
00082     int            m_iDataBlockStart;    // -1, if undefined
00083     int            m_iDataBlockEnd;    // -1, if undefined
00084 
00085     bool        m_bOK;
00086     bool        m_bWithMsg;
00087     void Init (const QString &szXML);
00088     void Copy (const VXMLLevel1Iter &anOther);
00089     QChar        *pTag, *pData, *pEnd;
00090     int m_iTagSize,m_iDataSize;
00091 
00092     void getNextDataBlock(QChar **szData, int *iSizeData);
00093 
00094 };
00095 
00096 inline const QString VXMLLevel1Iter::getTag(void) const 
00097     {return m_bOK ? QString(pTag,m_iTagSize) : QString(); }
00098 
00099 inline const QString VXMLLevel1Iter::getData(void) const 
00100     {return m_bOK ? QString(pData,m_iDataSize) : QString(); }
00101 
00102 inline const QString VXMLLevel1Iter::getRemain(void) const 
00103     {return m_bOK ? QString(m_pcXML+m_iCurPos,m_iLength-m_iCurPos) : QString(); }
00104 
00105 
00106 inline bool VXMLLevel1Iter::isTag(const QString szTestTag) const {
00107     return (getTag().compare(szTestTag) == 0);
00108 }
00109 
00110 inline bool VXMLLevel1Iter::isData(const QString szTestData) const {
00111     return (getData().compare(szTestData) == 0);
00112 }
00113 
00114 inline int VXMLLevel1Iter::dataToInt() const {
00115     return getData().toInt();
00116 }
00117 
00118 inline double VXMLLevel1Iter::dataToDouble() const {
00119     return getData().toDouble();
00120 }
00121 
00122 inline VXMLLevel1Iter::operator bool (void) 
00123 {
00124     return m_bOK; 
00125 }
00126 
00127 inline VXMLLevel1Iter::operator const QString(void) 
00128     {return getData(); }
00129 
00130 
00131 } // namespace
00132 
00133 #endif // VT_XML_H
00134 

VHISTlib 1.84.0.3018 of Jun 28 2013, generated by doxygen.