1.11.2 split up of xml helper functions. started to work on attributes
authorinsilmaril
Thu, 08 Nov 2007 15:28:03 +0000
changeset 6177ee5bf3647d3
parent 616 16d63fc9ae42
child 618 9d9da416206e
1.11.2 split up of xml helper functions. started to work on attributes
misc.cpp
misc.h
noteobj.h
     1.1 --- a/misc.cpp	Thu Nov 08 15:28:03 2007 +0000
     1.2 +++ b/misc.cpp	Thu Nov 08 15:28:03 2007 +0000
     1.3 @@ -83,22 +83,6 @@
     1.4  }
     1.5  
     1.6  
     1.7 -// returns masked "<" ">" "&"
     1.8 -QString quotemeta(const QString &s)
     1.9 -{
    1.10 -	QString r=s;
    1.11 -    QRegExp  rx("&(?!amp;)");
    1.12 -    r.replace ( rx,"&amp;");
    1.13 -    rx.setPattern( ">");
    1.14 -    r.replace ( rx,"&gt;");
    1.15 -    rx.setPattern( "<");
    1.16 -    r.replace ( rx,"&lt;");
    1.17 -    rx.setPattern( "\"");
    1.18 -    r.replace ( rx,"&quot;");
    1.19 -    return r;
    1.20 -}
    1.21 -
    1.22 -
    1.23  qreal max(qreal a, qreal b)
    1.24  {
    1.25  	if (a>b)
    1.26 @@ -106,75 +90,3 @@
    1.27  	return b;
    1.28  }
    1.29  
    1.30 -int xmlObj::actindent=0;		// make instance of actindent
    1.31 -
    1.32 -xmlObj::xmlObj()
    1.33 -{
    1.34 -    indentwidth=4;
    1.35 -}
    1.36 -
    1.37 -
    1.38 -// returns <s at />
    1.39 -QString xmlObj::singleElement(QString s, QString at)
    1.40 -{
    1.41 -    return indent() + "<" + s +" " + at +" " + "/>\n";
    1.42 -}
    1.43 -
    1.44 -// returns <s>
    1.45 -QString xmlObj::beginElement(QString s)
    1.46 -{
    1.47 -    return indent() + "<" + s + ">\n";
    1.48 -}
    1.49 -
    1.50 -// returns <s at>
    1.51 -QString xmlObj::beginElement(QString s, QString at)
    1.52 -{
    1.53 -    return indent() + "<" + s + " " + at + ">\n";
    1.54 -}
    1.55 -
    1.56 -// returns </s>
    1.57 -QString xmlObj::endElement(QString s)
    1.58 -{
    1.59 -    return indent() + "</" + s + ">\n";
    1.60 -}
    1.61 -
    1.62 -// returns  at="val"
    1.63 -QString xmlObj::attribut(QString at, QString val)
    1.64 -{
    1.65 -    return " " + at + "=\"" + quotemeta (val) + "\""; 
    1.66 -}
    1.67 -
    1.68 -// returns <s> val </s>
    1.69 -QString xmlObj::valueElement(QString el, QString val)
    1.70 -{
    1.71 -    return indent() + "<" + el + ">" + quotemeta(val) + "</" +el + ">\n";
    1.72 -}
    1.73 -
    1.74 -// returns <s at> val </s>
    1.75 -QString xmlObj::valueElement(QString el, QString val, QString at)
    1.76 -{
    1.77 -    return indent() + "<" + el + " " + at + ">" + quotemeta(val) + "</" +el + ">\n";
    1.78 -}
    1.79 -
    1.80 -void xmlObj::incIndent()
    1.81 -{
    1.82 -    actindent++;
    1.83 -}	
    1.84 -
    1.85 -void xmlObj::decIndent()
    1.86 -{
    1.87 -    actindent--;
    1.88 -    if (actindent<0) actindent=0;
    1.89 -}	
    1.90 -
    1.91 -QString xmlObj::indent()
    1.92 -{
    1.93 -    QString s;
    1.94 -    int i;
    1.95 -    for (i=0; i<actindent*indentwidth; i++)
    1.96 -    {
    1.97 -		s= s + " ";
    1.98 -    }
    1.99 -    return s;
   1.100 -}	
   1.101 -
     2.1 --- a/misc.h	Thu Nov 08 15:28:03 2007 +0000
     2.2 +++ b/misc.h	Thu Nov 08 15:28:03 2007 +0000
     2.3 @@ -15,30 +15,8 @@
     2.4  extern ostream &operator<< (ostream &stream, QPointF const &p);
     2.5  qreal getAngle(const QPointF &);
     2.6  QPointF normalise (const QPointF &);
     2.7 -QString quotemeta(const QString&);	
     2.8  qreal max (qreal,qreal);
     2.9  class BranchObj;
    2.10  class MapEditor;
    2.11  
    2.12 -/////////////////////////////////////////////////////////////////////////////
    2.13 -class xmlObj
    2.14 -{
    2.15 -public:
    2.16 -    xmlObj();
    2.17 -    QString singleElement(QString,QString);			// name,attr
    2.18 -    QString beginElement(QString,QString);			// name,attr
    2.19 -    QString beginElement(QString);					// name
    2.20 -    QString endElement  (QString);					// name
    2.21 -    QString attribut    (QString,QString);			// name, val
    2.22 -    QString valueElement(QString,QString);			// name, val
    2.23 -    QString valueElement(QString,QString,QString);	// name, attr, val
    2.24 -    void incIndent();
    2.25 -    void decIndent();
    2.26 -    static int actindent;
    2.27 -
    2.28 -protected:  
    2.29 -    QString indent();
    2.30 -    int indentwidth;
    2.31 -};
    2.32 -
    2.33  #endif
     3.1 --- a/noteobj.h	Thu Nov 08 15:28:03 2007 +0000
     3.2 +++ b/noteobj.h	Thu Nov 08 15:28:03 2007 +0000
     3.3 @@ -5,12 +5,12 @@
     3.4  
     3.5  class NoteObj;
     3.6  
     3.7 -#include "misc.h"
     3.8 +#include "xmlobj.h"
     3.9  
    3.10  /*! \brief The text note belonging to one OrnamentedObj */
    3.11  
    3.12  
    3.13 -class NoteObj:public xmlObj
    3.14 +class NoteObj:public XMLObj
    3.15  {
    3.16  public:
    3.17  	NoteObj();