23 using namespace hippodraw;
30 #if QT_VERSION < 0x040000
64 #if QT_VERSION < 0x040000
65 return string ( tagname.
latin1() );
67 return tagname.toStdString ();
74 if ( value == QString::null )
return 0;
77 int id = value.
toInt ( &ok );
78 if ( ok ==
false )
id = 0;
89 getNode (
const std::string & tagName )
const
92 QString tagname ( tagName.c_str () );
94 if ( node.isNull () )
return 0;
97 assert ( element.isNull () == false );
106 std::list < XmlElement * > & nodeList )
const
108 QString tag_name ( tagName.c_str() );
112 unsigned int size ( nodelist.count () );
113 for (
unsigned int i = 0; i <
size; i++ ) {
114 QDomNode node = nodelist.item ( i );
125 assert ( ! name.empty () );
134 assert ( ! name.empty () );
136 unsigned int value = yes ? 1 : 0;
144 assert ( ! name.empty () );
152 assert ( ! name.empty () );
162 assert ( ! name.empty () );
167 #if QT_VERSION < 0x040000
170 const QString qname ( name.c_str() );
171 const string text ( vtext.c_str() );
172 const QString qtext ( text.c_str() );
180 const std::string & value )
182 assert ( ! name.empty () );
188 attribute (
const std::string & name,
int & value )
const
191 if ( rstring == QString::null )
return false;
194 int val = rstring.
toInt ( & ok );
195 if ( ! ok )
return false;
204 attribute (
const std::string & name,
bool & value )
const
207 if ( rstring == QString::null )
return false;
210 int val = rstring.
toInt ( & ok );
211 if ( ! ok )
return false;
213 value = ( val = 1 ) ?
true :
false;
220 attribute (
const std::string & name,
unsigned int & value )
const
223 if ( rstring == QString::null )
return false;
226 int val = rstring.
toUInt ( & ok );
227 if ( ! ok )
return false;
236 attribute (
const std::string & name,
float & value )
const
239 if ( rstring == QString::null )
return false;
242 float val = rstring.
toFloat ( & ok );
243 if ( ! ok )
return false;
252 attribute (
const std::string & name,
double & value )
const
255 if ( rstring == QString::null )
return false;
258 float val = rstring.
toDouble ( & ok );
259 if ( ! ok )
return false;
268 attribute (
const std::string & name, std::string & value )
const
271 if ( val == QString::null )
return false;
273 #if QT_VERSION < 0x040000
276 value = val.toStdString ();
287 #if QT_VERSION < 0x040000
290 text = t.toStdString ();
elementsByTagName(const QString &tagname) const
QtXmlElement(const QDomElement &)
A constructor used internally.
attribute(const QString &name, const QString &defValue=QString::null) const
virtual void setAttribute(const std::string &name, int value)
Sets attribute named name to the int value value.
toDouble(bool *ok=0) const
virtual bool attribute(const std::string &name, bool &value) const
Sets value to the attribute name's value.
A pure virtual base class of XML node wrappers.
An XML element using the Qt XML module.
virtual int getID() const
Returns the ID of the element, if it has one.
setAttribute(const QString &name, const QString &value)
toInt(bool *ok=0, int base=10) const
virtual QtXmlElement * getNode(const std::string &tagName) const
Returns the single direct child element node with name tagName.
A pure virtual base class of XML element wrapper.
hippodraw::QtXmlElement class interface
QDomNode m_node
The DOM node wrapped by this object.
intp size(numeric::array arr)
string convert(int i)
Converts an integer to a string.
virtual ~QtXmlElement()
The destructor.
virtual const std::string & getText() const
Gets the text node from the element.
The namespace for conversion to string.
toFloat(bool *ok=0) const
QDomElement m_element
The DOM element node wrapped by this object.
virtual void fillNodeList(const std::string &tagName, std::list< XmlElement * > &nodeList) const
virtual std::string tagName() const
Returns the tag name of the element.
toUInt(bool *ok=0, int base=10) const
An XML element using the Qt XML module.