HTMLElement.h

Go to the documentation of this file.
00001 /* -*-mode:c++; c-file-style: "gnu";-*- */
00002 /*
00003  *  $Id: HTMLElement_8h-source.html,v 1.3 2008/01/19 21:53:41 sebdiaz Exp $
00004  *
00005  *  Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org>
00006  *                       2007 Sebastien DIAZ <sebastien.diaz@gmail.com>
00007  *  Part of the GNU cgicc library, http://www.gnu.org/software/cgicc
00008  *
00009  *  This library is free software; you can redistribute it and/or
00010  *  modify it under the terms of the GNU Lesser General Public
00011  *  License as published by the Free Software Foundation; either
00012  *  version 3 of the License, or (at your option) any later version.
00013  *
00014  *  This library is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  *  Lesser General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU Lesser General Public
00020  *  License along with this library; if not, write to the Free Software
00021  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA 
00022  */
00023 
00024 #ifndef _HTMLELEMENT_H_
00025 #define _HTMLELEMENT_H_ 1
00026 
00027 #ifdef __GNUG__
00028 #  pragma interface
00029 #endif
00030 
00037 #include <string>
00038 
00039 #include "cgicc/CgiDefs.h"
00040 #include "cgicc/MStreamable.h"
00041 #include "cgicc/HTMLAttributeList.h"
00042 
00043 namespace cgicc {
00044 
00045   class HTMLElementList;
00046   
00047   // ============================================================
00048   // Class HTMLElement
00049   // ============================================================
00050   
00060   class CGICC_API HTMLElement : public MStreamable 
00061   {
00062   public:
00063     
00071     enum EElementType {
00073       eAtomic,
00075       eBoolean
00076     };
00077     
00078     // ============================================================
00079     
00082     
00089     HTMLElement(const HTMLElement& element);
00090     
00096     virtual ~HTMLElement();
00098     
00099     // ============================================================
00100     
00103     
00111     bool 
00112     operator== (const HTMLElement& element)             const;
00113     
00121     inline bool 
00122     operator!= (const HTMLElement& element)             const
00123     { return ! operator==(element); }
00124     
00125 #ifdef WIN32
00126     /* Dummy operator for MSVC++ */
00127     inline bool
00128     operator< (const HTMLElement& element)              const
00129     { return false; }
00130 #endif
00131     
00139     HTMLElement&
00140     operator= (const HTMLElement& element);
00142     
00143     // ============================================================
00144     
00149     
00156     virtual const char*
00157     getName()                                   const = 0;
00158     
00165     inline std::string
00166     getData()                                   const
00167     { return fData; }
00168     
00175     inline EElementType
00176     getType()                                   const
00177     { return fType; }
00179     
00180     // ============================================================
00181     
00186     
00193     inline void
00194     setData(const std::string& data)
00195     { fData = data; }
00197     
00198     // ============================================================
00199     
00206     virtual HTMLElement*
00207     clone()                                     const = 0;
00208     
00209     // ============================================================
00210     
00215     
00222     inline const HTMLElementList*
00223     getEmbedded()                               const
00224     { return fEmbedded; }
00225     
00233     void 
00234     setEmbedded(const HTMLElementList& embedded);
00235     
00243     HTMLElement&
00244     add(const HTMLElement& element);
00245     
00253     HTMLElement&
00254     add(HTMLElement *element);
00256     
00257     // ============================================================
00258     
00263     
00270     inline const HTMLAttributeList*
00271     getAttributes()                             const
00272     { return fAttributes; }
00273     
00281     void 
00282     setAttributes(const HTMLAttributeList& attributes);
00283     
00291     HTMLElement&
00292     set(const std::string& name);
00293     
00302     HTMLElement&
00303     set(const std::string& name,
00304         const std::string& value);
00306     
00307     // ============================================================
00308     
00313     
00319     virtual void 
00320     swapState()                                 const
00321     {}
00322     
00329     virtual bool 
00330     getState()                                  const
00331     { return false; }
00333     
00340     virtual void 
00341     render(std::ostream& out)                   const;
00342     
00343   protected:
00344     
00355     HTMLElement(const HTMLAttributeList *attributes,
00356                 const HTMLElement *embedded,
00357                 const std::string *data,
00358                 EElementType type);
00359     
00366     inline bool
00367     dataSpecified()                             const
00368     { return fDataSpecified; }
00369     
00370   private:
00371     HTMLElement() {}
00372     
00373     HTMLAttributeList   *fAttributes;
00374     HTMLElementList     *fEmbedded;
00375     std::string         fData;
00376     EElementType        fType;
00377     bool                fDataSpecified;
00378   };
00379   
00380 } // namespace cgicc
00381 
00382 #endif /* ! _HTMLELEMENT_H_ */

GNU cgicc - A C++ class library for writing CGI applications
Copyright © 1996 - 2004 Stephen F. Booth
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front Cover Texts, and with no Back-Cover Texts.
Documentation generated Sat Jan 19 21:15:58 2008 for cgicc by doxygen 1.5.1