summaryrefslogtreecommitdiffstats
path: root/klinkstatus/src/parser/node.h
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commite9ae80694875f869892f13f4fcaf1170a00dea41 (patch)
treeaa2f8d8a217e2d376224c8d46b7397b68d35de2d /klinkstatus/src/parser/node.h
downloadtdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.tar.gz
tdewebdev-e9ae80694875f869892f13f4fcaf1170a00dea41.zip
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/kdewebdev@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'klinkstatus/src/parser/node.h')
-rw-r--r--klinkstatus/src/parser/node.h279
1 files changed, 279 insertions, 0 deletions
diff --git a/klinkstatus/src/parser/node.h b/klinkstatus/src/parser/node.h
new file mode 100644
index 00000000..1d0b1fc3
--- /dev/null
+++ b/klinkstatus/src/parser/node.h
@@ -0,0 +1,279 @@
+/***************************************************************************
+ * Copyright (C) 2004 by Paulo Moura Guedes *
+ * moura@kdewebdev.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. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the *
+ * Free Software Foundation, Inc., *
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
+ ***************************************************************************/
+
+#ifndef NODULO_H
+#define NODULO_H
+
+#include "mstring.h"
+
+#include <qstring.h>
+
+#include <kdebug.h>
+#include <kcharsets.h>
+
+using namespace std;
+
+typedef unsigned int uint;
+
+
+class Node
+{
+public:
+
+ enum Element {
+ A,
+ AREA,
+ LINK,
+ META,
+ IMG,
+ FRAME,
+ BASE,
+ TITLE
+ };
+ enum LinkType {
+ href,
+ file_href,
+ mailto,
+ relative
+ };
+
+ Node();
+ Node(QString const& content);
+ virtual ~Node();
+
+ QString getAttribute(QString const& atributo);
+ virtual QString const& url() const = 0;
+ virtual QString const& linkLabel() const = 0; // URL label
+ virtual void setNode(QString const& content);
+ virtual void parse() = 0;
+ void setMalformed(bool flag = true);
+ virtual void setLinkType(LinkType const& lt);
+
+ QString const& content() const;
+ bool malformed() const;
+ LinkType linkType() const;
+ Element element() const;
+ virtual bool isLink() const = 0;
+
+ bool isRedirection() const;
+
+protected:
+
+ Element element_;
+ LinkType linktype_;
+ QString link_label_;
+ QString content_;
+ bool is_redirection_;
+ bool malformed_;
+};
+
+
+class NodeLink: public Node
+{
+public:
+ NodeLink();
+ NodeLink(QString const& content);
+ ~NodeLink()
+ {}
+ ;
+
+ virtual void parse();
+
+ virtual QString const& url() const;
+ virtual QString const& linkLabel() const; // URL label
+ virtual QString mailto() const;
+ virtual bool isLink() const;
+
+private:
+ virtual void parseAttributeHREF();
+ void parseLinkLabel();
+
+private:
+ QString attribute_href_;
+};
+
+class NodeA: public NodeLink
+{
+public:
+ NodeA(QString const& content);
+ ~NodeA()
+ {}
+ ;
+ QString const& attributeNAME() const;
+
+ virtual void parse();
+
+private:
+ void parseAttributeNAME();
+
+private:
+ QString attribute_name_;
+};
+
+class NodeAREA: public NodeLink
+{
+public:
+ NodeAREA(QString const& content);
+ ~NodeAREA() {};
+
+ QString const& attributeTITLE() const;
+
+ virtual void parse();
+
+private:
+ void parseAttributeTITLE();
+
+private:
+ QString attribute_title_;
+};
+
+
+class NodeLINK: public NodeLink
+{
+public:
+ NodeLINK(QString const& content);
+ ~NodeLINK()
+ {}
+ ;
+};
+
+class NodeMETA: public Node
+{
+public:
+ NodeMETA();
+ NodeMETA(QString const& content);
+ ~NodeMETA()
+ {}
+ ;
+
+ virtual QString const& url() const;
+ virtual const QString& linkLabel() const;
+ virtual bool isLink() const;
+ QString const& atributoHTTP_EQUIV() const;
+ QString const& atributoNAME() const;
+ QString const& atributoCONTENT() const;
+ QString charset() const;
+ bool isRedirection() const;
+
+ virtual void parse();
+
+private:
+ /**
+ Procura se existem os atributos HTTP-EQUIV=Refresh e URL=...
+ Se existir considera o content do atributo URL como um link.
+ ex: <META HTTP-EQUIV=Refresh CONTENT="10; URL=http://www.htmlhelp.com/">
+ */
+ void parseAttributeURL();
+
+ void parseAttributeHTTP_EQUIV();
+ void parseAttributeNAME();
+ void parseAttributeCONTENT();
+
+private:
+ QString attribute_http_equiv_;
+ QString attribute_url_;
+ QString attribute_name_;
+ QString attribute_content_;
+};
+
+class NodeIMG: public Node
+{
+public:
+ NodeIMG(QString const& content);
+ ~NodeIMG()
+ {}
+ ;
+
+ virtual void parse();
+
+ virtual QString const& url() const;
+ virtual QString const& linkLabel() const; // Image label
+ virtual bool isLink() const;
+
+private:
+ void parseAttributeSRC();
+ void parseAttributeTITLE();
+ void parseAttributeALT();
+
+private:
+ QString attribute_src_;
+ QString attribute_title_;
+ QString attribute_alt_;
+};
+
+class NodeFRAME: public Node
+{
+public:
+ NodeFRAME(QString const& content);
+ ~NodeFRAME()
+ {}
+ ;
+
+ virtual void parse();
+ virtual QString const& url() const;
+ virtual QString const& linkLabel() const;
+ virtual bool isLink() const;
+
+private:
+ void parseAttributeSRC();
+
+private:
+ QString attribute_src_;
+};
+
+class NodeBASE: public NodeLink
+{
+public:
+ NodeBASE();
+ NodeBASE(QString const& content);
+ ~NodeBASE()
+ {}
+ ;
+
+ virtual bool isLink() const;
+};
+
+class NodeTITLE: public Node
+{
+public:
+ NodeTITLE();
+ NodeTITLE(QString const& content);
+ ~NodeTITLE()
+ {}
+ ;
+
+ virtual QString const& url() const;
+ virtual QString const& linkLabel() const;
+ virtual void parse();
+ virtual bool isLink() const;
+
+ QString const& attributeTITLE() const;
+
+private:
+ void parseAttributeTITLE();
+
+private:
+ QString attribute_title_;
+};
+
+
+#include "node_impl.h"
+
+#endif