include/HTMLParser/Elements.hpp

Go to the documentation of this file.
00001 #ifndef hpp_CPP_Elements_CPP_hpp
00002 #define hpp_CPP_Elements_CPP_hpp
00003 
00004 
00005 // We generic elements declaration
00006 #include "GenericElements.hpp"
00007 // We need strings 
00008 #include "../Strings/Strings.hpp"
00009 // We need DOM declaration too
00010 #include "DOM.hpp"
00011 
00012 namespace HTML
00013 {
00014    
00016     namespace Elements
00017     {
00038         class Element
00039         {
00040         private:
00042             const HTML::GenericElement::ElementID     elementType;
00044             uint32                                    startPosition;
00046             uint32                                    endPosition;
00048             uint32                                    endTagPosition;
00050             uint32                                    finalPosition;
00051 
00052         public:    
00054             const tchar * tagName() const volatile { return elementType == HTML::GenericElement::Unknown ? "" : allowedElements[(int)elementType - 1].name; }           
00055 
00056             // Allow changing the positions
00057         public:
00061             inline void setEndPosition(uint32 position)     { endPosition = position; }
00065             inline void setStartPosition(uint32 position)   { startPosition = position; }
00069             inline void setEndTagPosition(uint32 position)  { endTagPosition = position; }
00073             inline void setFinalPosition(uint32 position)   { finalPosition = position; }
00074 
00076             inline uint32 getStartPosition()    const { return startPosition; }
00078             inline uint32 getEndPosition()      const { return endPosition; }
00080             inline uint32 getEndTagPosition()   const { return endTagPosition; }
00082             inline uint32 getFinalPosition()    const { return finalPosition; }
00083 
00085             inline bool tagClosed()             const { return (endTagPosition != -1 && finalPosition != -1); }
00086 
00088             inline const HTML::GenericElement::ElementID & getElementType() const   { return elementType; }
00090             typedef const HTML::GenericElement * const ValidationRules;
00092             inline ValidationRules getValidationRules() const { return elementType == HTML::GenericElement::Unknown ? 0 : &allowedElements[(int)elementType - 1]; }
00093 
00094 
00095             // Construction
00096         public:
00097             Element(const HTML::GenericElement::ElementID type = HTML::GenericElement::Unknown, uint32 startPos = 0, uint32 endPos = 0) : elementType(type), startPosition(startPos), endPosition(endPos), endTagPosition(-1), finalPosition(-1) {}
00098             Element(const Element & element) : elementType(element.elementType), startPosition(element.startPosition), endPosition(element.endPosition), endTagPosition(element.endTagPosition), finalPosition(element.finalPosition) {}
00099         };
00100 
00101         
00103         HTML::GenericElement::ElementID fromTag(const tchar * const input, const uint32 & length);
00105         HTML::GenericElement::Level levelFromID(const HTML::GenericElement::ElementID type);
00113         bool allowedInID(const HTML::GenericElement::ElementID container, const HTML::GenericElement::ElementID child);
00114 
00115     
00116      }
00117 }
00118 
00119 #endif

(C) An X-Ryl669 project 2007

This document describes Unlimited Zooming Interface source code. UZI stands for Unlimited Zooming Interface, and source code license is