/usr/include/cgicc/HTMLElement.h is in libcgicc5-dev 3.2.9-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 | /* -*-mode:c++; c-file-style: "gnu";-*- */
/*
* $Id: HTMLElement.h,v 1.8 2007/07/02 18:48:18 sebdiaz Exp $
*
* Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org>
* 2007 Sebastien DIAZ <sebastien.diaz@gmail.com>
* Part of the GNU cgicc library, http://www.gnu.org/software/cgicc
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 3 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
*/
#ifndef _HTMLELEMENT_H_
#define _HTMLELEMENT_H_ 1
#ifdef __GNUG__
# pragma interface
#endif
/*! \file HTMLElement.h
* \brief Class dealing with HTML elements
*
* For example, \c a, \c img, \c html, and \c body, are all HTML elements.
*/
#include <string>
#include "cgicc/CgiDefs.h"
#include "cgicc/MStreamable.h"
#include "cgicc/HTMLAttributeList.h"
namespace cgicc {
class HTMLElementList;
// ============================================================
// Class HTMLElement
// ============================================================
/*! \class HTMLElement HTMLElement.h cgicc/HTMLElement.h
* \brief Class representing an HTML element.
*
* An HTML element is any entity enclosed in angle brackets (\< and \>)
* interpreted as HTML, for example \c a, \c img, \c html, and \c body.
*
* This class is an abstract base class that defines the interface
* for all HTMLElement subclasses.
*/
class CGICC_API HTMLElement : public MStreamable
{
public:
/*!
* \brief Possible types of HTMLElements
*
* An HTMLElement is either atomic, meaning it has no corresponding
* closing tag (elements such as \c hr and \c br are atomic) or
* boolean (elements such as \c a and \c ol are boolean)
*/
enum EElementType {
/*! Atomic element, such as \c hr */
eAtomic,
/*! Boolean element, such as \c strong */
eBoolean
};
// ============================================================
/*! \name Constructors and Destructor */
//@{
/*!
* \brief Copy constructor.
*
* Sets the name and internal state of this element to those of \c element
* \param element The HTMLElement to copy.
*/
HTMLElement(const HTMLElement& element);
/*!
* \brief Destructor
*
* Delete this HTMLElement object
*/
virtual ~HTMLElement();
//@}
// ============================================================
/*! \name Overloaded Operators */
//@{
/*!
* \brief Compare two HTMLElements for equality.
*
* HTMLElements are equal if they have the same name
* \param element The HTMLElement to compare to this one.
* \return \c true if the two HTMLElements are equal, \c false otherwise.
*/
bool
operator== (const HTMLElement& element) const;
/*!
* \brief Compare two HTMLElements for inequality.
*
* HTMLElements are equal if they have the same name
* \param element The HTMLElement to compare to this one.
* \return \c false if the two HTMLElements are equal, \c true otherwise.
*/
inline bool
operator!= (const HTMLElement& element) const
{ return ! operator==(element); }
#ifdef WIN32
/* Dummy operator for MSVC++ */
inline bool
operator< (const HTMLElement& element) const
{ return false; }
#endif
/*!
* \brief Assignment operator
*
* Sets the name and internal state of this element to those of \c element
* \param element The HTMLElement to copy
* \return A reference to \c this
*/
HTMLElement&
operator= (const HTMLElement& element);
//@}
// ============================================================
/*! \name Accessor Methods
* Information on the element
*/
//@{
/*!
* \brief Get the name of this element.
*
* For example, \c html or \c body.
* \return The name of this element.
*/
virtual const char*
getName() const = 0;
/*!
* \brief Get the data contained in this element, if any.
*
* This is only applicable for boolean elements
* \return The data contained in this element.
*/
inline std::string
getData() const
{ return fData; }
/*!
* \brief Get the type of this element
*
* Most HTMLElements are boolean
* \return The type of this element
*/
inline EElementType
getType() const
{ return fType; }
//@}
// ============================================================
/*! \name Mutator Methods
* Set properties of the element
*/
//@{
/*!
* \brief Set the data contained in this element.
*
* The data is the text contained between the opening and closing tags
* \param data The data to store in this element.
*/
inline void
setData(const std::string& data)
{ fData = data; }
//@}
// ============================================================
/*!
* \brief Clone this HTMLElement
*
* This performs a deep copy of the element
* \return A pointer to a newly-allocated copy of \c this.
*/
virtual HTMLElement*
clone() const = 0;
// ============================================================
/*! \name Embedded HTMLElement Management
* Manage elements embedded in this one
*/
//@{
/*!
* \brief Get the HTMLElementList embedded in this element, if any.
*
* If this method returns 0, no elements are embedded
* \return The embedded element list.
*/
inline const HTMLElementList*
getEmbedded() const
{ return fEmbedded; }
/*!
* \brief Set the HTMLElementList associated with this element.
*
* This is usually called by subclass constructors
* \param embedded The HTMLElementList containing the HTMLElements
* embedded in this element.
*/
void
setEmbedded(const HTMLElementList& embedded);
/*!
* \brief Add an embedded HTMLElement in this one
*
*
* \param element A reference to an HTMLElement to embed in this one
* \return A reference to \c this
*/
HTMLElement&
add(const HTMLElement& element);
/*!
* \brief Add an embedded HTMLElement in this one
*
* This element takes ownership of \c element, which should not be deleted.
* \param element A pointer to an HTMLElement to embed.
* \return A reference to \c this
*/
HTMLElement&
add(HTMLElement *element);
//@}
// ============================================================
/*! \name HTMLAttribute Management
* Manage attributes embedded in this element
*/
//@{
/*!
* \brief Get the attributes associated with this element.
*
* If this method returns 0, no attributes are embedded
* \return The attribute list.
*/
inline const HTMLAttributeList*
getAttributes() const
{ return fAttributes; }
/*!
* \brief Set the attributes associated with this element.
*
* This is usually called by subclass constructors
* \param attributes The HTMLAttributeList containing the HTMLAttributes
* belonging to this element.
*/
void
setAttributes(const HTMLAttributeList& attributes);
/*!
* \brief Set an HTMLAttribute on this HTMLElement
*
*
* \param name The name of the HTMLAttribute to set
* \return A reference to \c this
*/
HTMLElement&
set(const std::string& name);
/*!
* \brief Set an HTMLAttribute on this HTMLElement
*
*
* \param name The name of the HTMLAttribute
* \param value The value of the HTMLAttribute
* \return A reference to \c this
*/
HTMLElement&
set(const std::string& name,
const std::string& value);
//@}
// ============================================================
/*! \name Boolean element methods
* Methods specific to boolean elements
*/
//@{
/*!
* \brief Swap the state of the boolean element
*
* A state of \c true means the element is active
*/
virtual void
swapState() const
{}
/*!
* \brief Get the state of this boolean element
*
*
* \return \c true if the element is active, \c false otherwise
*/
virtual bool
getState() const
{ return false; }
//@}
/*!
* \brief Render this HTMLElement to an ostream
*
* This is used for output
* \param out The ostream to which to write
*/
virtual void
render(std::ostream& out) const;
protected:
/*!
* \brief Subclass constructor
*
* This allows the subclasses to fully specify all properties
* \param attributes A pointer to an HTMLAttributeList containing the
* HTMLAttributes for this HTMLElement, if any
* \param embedded A pointer to the embedded HTMLElement, if any
* \param data A pointer to the data, if any
* \param type The type of element
*/
HTMLElement(const HTMLAttributeList *attributes,
const HTMLElement *embedded,
const std::string *data,
EElementType type);
/*!
* \brief For subclasses only
*
* Returns \c true if data was specified in the constructor.
* \return \c true if data was specified in the constructor, \c false otherwise
*/
inline bool
dataSpecified() const
{ return fDataSpecified; }
private:
HTMLElement() {}
HTMLAttributeList *fAttributes;
HTMLElementList *fEmbedded;
std::string fData;
EElementType fType;
bool fDataSpecified;
};
} // namespace cgicc
#endif /* ! _HTMLELEMENT_H_ */
|