00001 /* 00002 webEngine is the HTML processing library 00003 Copyright (C) 2009 Andrew Abramov aabramov@ptsecurity.ru 00004 00005 This file is part of webEngine 00006 00007 webEngineis free software: you can redistribute it and/or modify 00008 it under the terms of the GNU General Public License as published by 00009 the Free Software Foundation, either version 3 of the License, or 00010 (at your option) any later version. 00011 00012 webEngineis distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 GNU General Public License for more details. 00016 00017 You should have received a copy of the GNU General Public License 00018 along with webEngine. If not, see <http://www.gnu.org/licenses/>. 00019 */ 00020 #ifndef __WEIDOCUMENT_H__ 00021 #define __WEIDOCUMENT_H__ 00022 00025 00026 #include <stdexcept> 00027 #include "weiTransport.h" 00028 #include "weStrings.h" 00029 #include "weTagScanner.h" 00030 #include "weBlob.h" 00031 #include "weDiffLib.h" 00032 00033 using namespace std; 00034 00035 class iweEntity; 00036 class iweDocument; 00037 typedef vector<iweEntity*> WeEntityList; 00038 00047 class iweEntity 00048 { 00049 public: 00050 virtual ~iweEntity() { ClearChildren(); }; 00051 00052 virtual const string Attr(string); 00053 virtual void Attr(string, string); 00054 void ClearAttr(void) { attributes.clear(); }; 00055 00056 virtual iweEntity* Child(string type); 00057 virtual iweEntity* Child(int idx); 00058 virtual WeEntityList& Children() { return chldList; }; 00059 void ClearChildren(void); 00060 00061 virtual const string &InnerText(void) = 0; 00062 virtual const string &OuterText(void) = 0; 00063 00064 iweEntity* FindID(string id); 00065 WeEntityList& FindTags(string tag); 00066 00067 virtual WeScannerToken Parse(string tagName, WeTagScanner& scanner, iweTransport* processor = NULL) { return wstError; }; 00068 00069 virtual WeCmpResults* Diff(iweEntity& cmp, weCmpMode mode = weCmpDefault) = 0; 00070 virtual weCmpState Compare(iweEntity& cmp, weCmpMode mode = weCmpDefault) = 0; 00071 virtual bool operator==(iweEntity& cmp) { return (Compare(cmp) == weCmpEqual); }; 00072 00073 iweDocument* GetRootDocument(void); 00074 00076 00077 const iweEntity* Parent(void) const { return(parent); }; 00078 void Parent(iweEntity* prnt) { parent = prnt; }; 00079 //} 00080 00082 00083 00084 00085 00086 const string &Name(void) const { return(entityName); }; 00087 void Name(const string &EntityName) { entityName = EntityName; }; 00089 00091 00092 00093 00094 00095 00096 00097 00098 00099 00100 static const weCmpMode &CompareMode(void) { return(compareMode); }; 00101 static void CompareMode(const weCmpMode &cMode) { compareMode = cMode; }; 00103 00105 const string ID(void) const {return m_entityId; }; 00106 00107 protected: 00108 virtual void GenerateId(void); 00109 bool IsParentTag(string tag); 00110 00111 #ifndef __DOXYGEN__ 00112 protected: 00113 iweEntity* parent; 00114 WeAttrMap attributes; 00115 WeEntityList chldList; 00116 string entityName; 00117 string m_entityId; 00118 static weCmpMode compareMode; 00119 int startPos, endPos; 00120 #endif //__DOXYGEN__ 00121 }; 00122 00131 class iweDocument : virtual public iweEntity 00132 { 00133 virtual bool ParseData(iweResponse* resp, iweTransport* processor = NULL) = 0; 00134 virtual WeBlob& Data(void) = 0; 00135 }; 00136 00137 #endif //__WEIDOCUMENT_H__
©2009 Positive Technologies |
Generated on Tue Jul 14 18:27:30 2009 for WebEngine by |
|
1.5.7 |
|