From 00bb99ac80741fc50ef8a289719373032f2391eb Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdeaccessibility@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kttsd/filters/xhtml2ssml/xmlelement.h | 91 +++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 kttsd/filters/xhtml2ssml/xmlelement.h (limited to 'kttsd/filters/xhtml2ssml/xmlelement.h') diff --git a/kttsd/filters/xhtml2ssml/xmlelement.h b/kttsd/filters/xhtml2ssml/xmlelement.h new file mode 100644 index 0000000..c78cd6f --- /dev/null +++ b/kttsd/filters/xhtml2ssml/xmlelement.h @@ -0,0 +1,91 @@ +/**************************************************************************** + XMLElement class + + Representation of an XML element with methods for getting/setting + attributes and generating "opening" and "closing" tags. + ------------------- + Copyright: + (C) 2004 by Paul Giannaros + ------------------- + Original author: Paul Giannaros +******************************************************************************/ + +/*************************************************************************** + * * + * 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; version 2 of the License. * + * * + ***************************************************************************/ + + +#ifndef XMLELEMENT_H +#define XMLELEMENT_H + +#include + +class QString; + +typedef QMap AttributeToValueMap; + +class XMLElement { +public: + XMLElement(); + XMLElement(const QString &name); + ~XMLElement(); + + /// Copy constructor + XMLElement(const XMLElement &); + + /// Assignment operator + XMLElement operator=(const XMLElement &element); + + /// Get the name of the tag (the text between the greater than and less than symbols). + /// @returns the name of the tag. + QString name(); + + /// set the name of the tag. + /// @param name the new name of the tag. + void setName(const QString &name); + + /// Get a textual representation of the starting of the tag with all attributes and their values set out. + /// @verbatim + /// XMLElement element("elem"); + /// element.addAttribute("foo", "bar"); + /// element.startTag(); <- + /// @endverbatim + /// @returns A textual representation of the start of the element. + QString startTag(); + + /// Get a textual representation of the closed tag that XMLElement represents. + /// @returns A textual representation of the closed tag represented by the XMLElement. + QString endTag(); + + /// Create an attribute and set its value. + /// @param attr The attribute. + /// @param value The value of the attribute. + void setAttribute(const QString &attr, const QString &value); + + /// Get the value of an attribute. + /// @param attr The attribute. + /// @returns The value of @param attr + QString attribute(const QString &attr); + + /// Convert to a QString. + /// Had issues with QMap and custom classes. For now you can just convert to/from QString and use + /// That as the key/value pair. + /// @returns A QString representation of the XMLAttribute. + QString toQString(); + + /// Create an XMLElement from a QString. + /// @param str The QString to convert from. Must be of the following syntax- "foo name=\"bar\"" + static XMLElement fromQString(const QString &str); + +private: + /// The name of the tag. + QString m_name; + /// Attribute : value mappings. + AttributeToValueMap m_attrmapper; +}; + +#endif -- cgit v1.2.1