HTMLBooleanElement.h

Go to the documentation of this file.
00001 /* -*-mode:c++; c-file-style: "gnu";-*- */
00002 /*
00003  *  $Id: HTMLBooleanElement_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 _HTMLBOOLEANELEMENT_H_
00025 #define _HTMLBOOLEANELEMENT_H_ 1
00026 
00032 #include <new>
00033 
00034 #include "cgicc/HTMLElement.h"
00035 
00036 namespace cgicc {
00037 
00038   // ============================================================
00039   // Template for concrete boolean HTML element classes
00040   // ============================================================
00041   
00061   template<class Tag>
00062   class HTMLBooleanElement : public HTMLElement 
00063   {
00064   public:
00065     
00066     // ============================================================
00067     
00070     
00075     HTMLBooleanElement()
00076       : HTMLElement(0, 0, 0, eBoolean)
00077     {}
00078     
00083     HTMLBooleanElement(const std::string& text)
00084       : HTMLElement(0, 0, &text, eBoolean)
00085     {}
00086     
00091     HTMLBooleanElement(const HTMLAttributeList& attributes)
00092       : HTMLElement(&attributes, 0, 0, eBoolean)
00093     {}
00094     
00099     HTMLBooleanElement(const HTMLElement& embedded)
00100       : HTMLElement(0, &embedded, 0, eBoolean)
00101     {}
00102     
00109     HTMLBooleanElement(const std::string& text, 
00110                        const HTMLAttributeList& attributes)
00111       : HTMLElement(&attributes, 0, &text, eBoolean)
00112     {}
00113     
00120     HTMLBooleanElement(const HTMLAttributeList& attributes, 
00121                        const HTMLElement& embed)
00122       : HTMLElement(&attributes, &embed, 0, eBoolean)
00123     {}
00124     
00129     virtual ~HTMLBooleanElement()
00130     {}
00132     
00133     // ============================================================
00134     
00139     virtual inline HTMLElement* 
00140     clone()                                     const
00141     { return new HTMLBooleanElement<Tag>(*this); }
00142     
00143     // ============================================================
00144     
00149     virtual inline const char*
00150     getName()                                   const
00151     { return Tag::getName(); }
00152     
00153     // ============================================================
00154     
00157     
00163     virtual inline void 
00164     swapState()                                         const
00165     { sState = ! sState; }
00166     
00171     virtual inline bool 
00172     getState()                                  const 
00173     { return sState; }
00174     
00179     static inline void 
00180     reset()
00181     { sState = false; }
00183     
00184   private:
00185     static bool sState;
00186   };
00187   
00188   template<class Tag>
00189   bool cgicc::HTMLBooleanElement<Tag>::sState = false;
00190   
00191 } // namespace cgicc
00192 
00193 #endif /* ! _HTMLBOOLEANELEMENT_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