1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
/*
**************************************************************************
description
--------------------
copyright : (C) 2000-2002 by Andreas Zehender
email : zehender@kde.org
**************************************************************************
**************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
**************************************************************************/
#ifndef PMXMLHELPER_H
#define PMXMLHELPER_H
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <tqdom.h>
#include <tqstring.h>
#include "pmobject.h"
#include "pmcolor.h"
#include "pmvector.h"
#include "pmmatrix.h"
class PMPart;
class PMParser;
/**
* Class for reading attributes out of a @ref TQDomElement
*/
class PMXMLHelper
{
public:
/**
* Creates a PMXMLHelper for the TQDomElement& e
*/
PMXMLHelper( const TQDomElement& e, PMPart* p, PMParser* par,
int majorDocumentFormat, int minorDocumentFormat );
/**
* Returns the TQDomElement
*/
TQDomElement element( ) const { return m_e; }
/**
* Returns true if the element contains the attribute
*/
bool hasAttribute( const TQString& name ) const;
/**
* Reads an integer attribute
*/
int intAttribute( const TQString& name, int def ) const;
/**
* Reads a double attribute
*/
double doubleAttribute( const TQString& name, double def ) const;
/**
* Reads a bool attribute
*/
bool boolAttribute( const TQString& name, bool def ) const;
/**
* Reads a PMThreeState attribute
*/
PMThreeState threeStateAttribute( const TQString& name ) const;
/**
* Reads a string attribute
*/
TQString stringAttribute( const TQString& name, const TQString& def ) const;
/**
* Reads a vector attribute
*/
PMVector vectorAttribute( const TQString& name, const PMVector& def ) const;
/**
* Reads a matrix attribute
*/
PMMatrix matrixAttribute( const TQString& name, const PMMatrix& def ) const;
/**
* Reads a color attribute
*/
PMColor colorAttribute( const TQString& name, const PMColor& def ) const;
/**
* Returns the "extra_data" child element or a null element, if there
* is no child element with tag name "extra_data"
*/
TQDomElement extraData( ) const;
/**
* Returns a pointer to the part
*/
PMPart* part( ) const { return m_pPart; }
/**
* Returns a pointer to the parser
*/
PMParser* parser( ) const { return m_pParser; }
/**
* Returns the documents major format number
*/
int majorDocumentFormat( ) const { return m_major; }
/**
* Returns the documents minor format number
*/
int minorDocumentFormat( ) const { return m_minor; }
private:
TQDomElement m_e;
PMPart* m_pPart;
PMParser* m_pParser;
int m_major;
int m_minor;
};
#endif
|