HTMLBooleanElement.h
Go to the documentation of this file.
1/* -*-mode:c++; c-file-style: "gnu";-*- */
2/*
3 * $Id: HTMLBooleanElement.h,v 1.9 2014/04/23 20:55:05 sebdiaz Exp $
4 *
5 * Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org>
6 * 2007 Sebastien DIAZ <sebastien.diaz@gmail.com>
7 * Part of the GNU cgicc library, http://www.gnu.org/software/cgicc
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 3 of the License, or (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
22 */
23
24#ifndef _HTMLBOOLEANELEMENT_H_
25#define _HTMLBOOLEANELEMENT_H_ 1
26
32#include <new>
33
34#include "HTMLElement.h"
35
36 namespace cgicc {
37
38 // ============================================================
39 // Template for concrete boolean HTML element classes
40 // ============================================================
41
61 template<class Tag>
62 class HTMLBooleanElement : public HTMLElement
63 {
64 public:
65
66 // ============================================================
67
70
75 HTMLBooleanElement()
76 : HTMLElement(0, 0, 0, eBoolean)
77 {}
78
83 HTMLBooleanElement(const std::string& text)
84 : HTMLElement(0, 0, &text, eBoolean)
85 {}
86
91 HTMLBooleanElement(const HTMLAttributeList& attributes)
92 : HTMLElement(&attributes, 0, 0, eBoolean)
93 {}
94
99 HTMLBooleanElement(const HTMLElement& embedded)
100 : HTMLElement(0, &embedded, 0, eBoolean)
101 {}
102
109 HTMLBooleanElement(const std::string& text,
110 const HTMLAttributeList& attributes)
111 : HTMLElement(&attributes, 0, &text, eBoolean)
112 {}
113
120 HTMLBooleanElement(const HTMLAttributeList& attributes,
121 const HTMLElement& embed)
122 : HTMLElement(&attributes, &embed, 0, eBoolean)
123 {}
124
129 virtual ~HTMLBooleanElement()
130 {}
132
133 // ============================================================
134
139 virtual inline HTMLElement*
140 clone() const
141 { return new HTMLBooleanElement<Tag>(*this); }
142
143 // ============================================================
144
149 virtual inline const char*
150 getName() const
151 { return Tag::getName(); }
152
153 // ============================================================
154
157
163 virtual inline void
164 swapState() const
165 { sState = ! sState; }
166
171 virtual inline bool
172 getState() const
173 { return sState; }
174
179 static inline void
180 reset()
181 { sState = false; }
183
184 private:
185 static bool sState;
186 };
187
188 template<class Tag>
189 bool cgicc::HTMLBooleanElement<Tag>::sState = false;
190
191} // namespace cgicc
192
193#endif /* ! _HTMLBOOLEANELEMENT_H_ */
HTMLElement.h
Class dealing with HTML elements.
cgicc::HTMLAttributeList
An expandable list of HTMLAttribute objects.
Definition: HTMLAttributeList.h:70
cgicc::HTMLBooleanElement
Template for concrete boolean HTMLElement subclasses.
Definition: HTMLBooleanElement.h:63
cgicc::HTMLBooleanElement::~HTMLBooleanElement
virtual ~HTMLBooleanElement()
Destructor.
Definition: HTMLBooleanElement.h:129
cgicc::HTMLBooleanElement::getName
virtual const char * getName() const
Get the name of this element. For example, "strong".
Definition: HTMLBooleanElement.h:150
cgicc::HTMLBooleanElement::reset
static void reset()
Reset the state of this boolean element to closed.
Definition: HTMLBooleanElement.h:180
cgicc::HTMLBooleanElement::HTMLBooleanElement
HTMLBooleanElement(const std::string &text)
Create a new element, specifying the enclosed text.
Definition: HTMLBooleanElement.h:83
cgicc::HTMLBooleanElement::HTMLBooleanElement
HTMLBooleanElement(const HTMLAttributeList &attributes)
Create a new element, specifying the HTMLAttribute objects.
Definition: HTMLBooleanElement.h:91
cgicc::HTMLBooleanElement::HTMLBooleanElement
HTMLBooleanElement(const std::string &text, const HTMLAttributeList &attributes)
Create a new element, specifying the enclosed text and HTMLAttribute objects.
Definition: HTMLBooleanElement.h:109
cgicc::HTMLBooleanElement::getState
virtual bool getState() const
Get the state of this boolean element.
Definition: HTMLBooleanElement.h:172
cgicc::HTMLBooleanElement::HTMLBooleanElement
HTMLBooleanElement()
Create a new empty boolean element.
Definition: HTMLBooleanElement.h:75
cgicc::HTMLBooleanElement::swapState
virtual void swapState() const
Swap the state of this boolean element.
Definition: HTMLBooleanElement.h:164
cgicc::HTMLBooleanElement::clone
virtual HTMLElement * clone() const
Clone this element.
Definition: HTMLBooleanElement.h:140
cgicc::HTMLBooleanElement::HTMLBooleanElement
HTMLBooleanElement(const HTMLAttributeList &attributes, const HTMLElement &embed)
Create a new element, specifying the HTMLAttributes and embedded HTMLElement.
Definition: HTMLBooleanElement.h:120
cgicc::HTMLBooleanElement::HTMLBooleanElement
HTMLBooleanElement(const HTMLElement &embedded)
Create a new element, specifying an embedded HTMLElement.
Definition: HTMLBooleanElement.h:99
cgicc::HTMLElement
Class representing an HTML element.
Definition: HTMLElement.h:61
cgicc::HTMLElement::eBoolean
@ eBoolean
Definition: HTMLElement.h:75
cgicc
The namespace containing the cgicc library.
Definition: Cgicc.h:52