HTMLElement.h
Go to the documentation of this file.
1/* -*-mode:c++; c-file-style: "gnu";-*- */
2/*
3 * $Id: HTMLElement.h,v 1.9 2014/04/23 20:55:06 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 _HTMLELEMENT_H_
25#define _HTMLELEMENT_H_ 1
26
27#ifdef __GNUG__
28# pragma interface
29#endif
30
37#include <string>
38
39#include "CgiDefs.h"
40#include "MStreamable.h"
41#include "HTMLAttributeList.h"
42
43namespace cgicc {
44
45 class HTMLElementList;
46
47 // ============================================================
48 // Class HTMLElement
49 // ============================================================
50
60 class CGICC_API HTMLElement : public MStreamable
61 {
62 public:
63
75 eBoolean
76 };
77
78 // ============================================================
79
82
90
96 virtual ~HTMLElement();
98
99 // ============================================================
100
103
111 bool
113
121 inline bool
123 { return ! operator==(element); }
124
125#ifdef WIN32
126 /* Dummy operator for MSVC++ */
127 inline bool
128 operator< (const HTMLElement& element) const
129 { return false; }
130#endif
131
139 HTMLElement&
142
143 // ============================================================
144
149
156 virtual const char*
157 getName() const = 0;
158
165 inline std::string
166 getData() const
167 { return fData; }
168
175 inline EElementType
176 getType() const
177 { return fType; }
179
180 // ============================================================
181
186
193 inline void
194 setData(const std::string& data)
195 { fData = data; }
197
198 // ============================================================
199
206 virtual HTMLElement*
207 clone() const = 0;
208
209 // ============================================================
210
215
222 inline const HTMLElementList*
224 { return fEmbedded; }
225
233 void
235
245
256
257 // ============================================================
258
263
270 inline const HTMLAttributeList*
272 { return fAttributes; }
273
281 void
283
292 set(const std::string& name);
293
303 set(const std::string& name,
304 const std::string& value);
306
307 // ============================================================
308
313
319 virtual void
320 swapState() const
321 {}
322
329 virtual bool
330 getState() const
331 { return false; }
333
340 virtual void
341 render(std::ostream& out) const;
342
343 protected:
344
356 const HTMLElement *embedded,
357 const std::string *data,
359
366 inline bool
368 { return fDataSpecified; }
369
370 private:
371 HTMLElement() {}
372
373 HTMLAttributeList *fAttributes;
374 HTMLElementList *fEmbedded;
375 std::string fData;
376 EElementType fType;
377 bool fDataSpecified;
378 };
379
380} // namespace cgicc
381
382#endif /* ! _HTMLELEMENT_H_ */
Platform and operating system specific macro definitions.
Class containing a list of HTMLAttribute objects.
Abstract base class for all streamable objects.
Template for concrete atomic HTMLElement subclasses.
An expandable list of HTMLAttribute objects.
An expandable list of HTMLElement objects.
Class representing an HTML element.
Definition HTMLElement.h:61
HTMLElement & set(const std::string &name)
Set an HTMLAttribute on this HTMLElement.
virtual void swapState() const
Swap the state of the boolean element.
HTMLElement & add(const HTMLElement &element)
Add an embedded HTMLElement in this one.
EElementType
Possible types of HTMLElements.
Definition HTMLElement.h:71
HTMLElement(const HTMLElement &element)
Copy constructor.
EElementType getType() const
Get the type of this element.
void setData(const std::string &data)
Set the data contained in this element.
std::string getData() const
Get the data contained in this element, if any.
virtual ~HTMLElement()
Destructor.
virtual const char * getName() const =0
Get the name of this element.
HTMLElement & set(const std::string &name, const std::string &value)
Set an HTMLAttribute on this HTMLElement.
void setAttributes(const HTMLAttributeList &attributes)
Set the attributes associated with this element.
virtual HTMLElement * clone() const =0
Clone this HTMLElement.
virtual bool getState() const
Get the state of this boolean element.
const HTMLAttributeList * getAttributes() const
Get the attributes associated with this element.
HTMLElement & add(HTMLElement *element)
Add an embedded HTMLElement in this one.
const HTMLElementList * getEmbedded() const
Get the HTMLElementList embedded in this element, if any.
bool dataSpecified() const
For subclasses only.
HTMLElement(const HTMLAttributeList *attributes, const HTMLElement *embedded, const std::string *data, EElementType type)
Subclass constructor.
virtual void render(std::ostream &out) const
Render this HTMLElement to an ostream.
void setEmbedded(const HTMLElementList &embedded)
Set the HTMLElementList associated with this element.
Mix-in streamable interface.
Definition MStreamable.h:67
The namespace containing the cgicc library.
Definition Cgicc.h:52

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 Tue Mar 26 2024 17:25:42 for cgicc by doxygen 1.9.8