List of all members
cgicc::HTMLAttribute Class Reference

Class representing a name or a single name/value pair. More...

#include <cgicc/HTMLAttribute.h>

Inheritance diagram for cgicc::HTMLAttribute:
cgicc::MStreamable

Public Member Functions

Constructors and Destructor
 HTMLAttribute ()
 Create an empty HTMLAttribute.
 
 HTMLAttribute (const std::string &name)
 Create an HTMLAttribute with the given name.
 
 HTMLAttribute (const std::string &name, const std::string &value)
 Create an HTMLAttribute with the given name and value.
 
 HTMLAttribute (const HTMLAttribute &attribute)
 Copy constructor.
 
virtual ~HTMLAttribute ()
 Destructor.
 
Overloaded Operators
bool operator== (const HTMLAttribute &att) const
 Compare two HTMLAttributes for equality.
 
bool operator!= (const HTMLAttribute &att) const
 Compare two HTMLAttributes for inequality.
 
HTMLAttributeoperator= (const HTMLAttribute &att)
 Assign one HTMLAttribute to another.
 
Accessor Methods

Information on the attribute

std::string getName () const
 Get the name of this HTMLAttribute.
 
std::string getValue () const
 Get the value of this HTMLAttribute.
 
- Public Member Functions inherited from cgicc::MStreamable
 MStreamable ()
 Empty constructor.
 
virtual ~MStreamable ()
 Empty destructor.
 
virtual void render (std::ostream &out) const =0
 Write this object to a stream.

 

Mutator Methods

Set properties of the attribute

void setName (const std::string &name)
 Set the name of this HTMLAttribute.
 
void setValue (const std::string &value)
 Set the value of this HTMLAttribute.
 
virtual void render (std::ostream &out) const
 Render this attribute to an ostream.
 

Detailed Description

Class representing a name or a single name/value pair.

An HTMLAttribute represents a single name/value pair inside an HTMLElement. For example, in the HTML code:

<a href="mailto:sbooth@gnu.org">Send mail</a>

The (name, value) pair (href, mailto:sbooth@gnu.org) is an HTMLAttribute. HTMLAttribute objects are usually not created directly, but using the set() methods. To generate the HTML above using cgicc, write

cout << cgicc::a("Send Mail").set("href", "mailto:sbooth@gnu.org");
See also
HTMLAttributeList

Definition at line 71 of file HTMLAttribute.h.

Constructor & Destructor Documentation

◆ HTMLAttribute() [1/4]

cgicc::HTMLAttribute::HTMLAttribute ( )

Create an empty HTMLAttribute.

The name and value are set to an empty string.

◆ HTMLAttribute() [2/4]

cgicc::HTMLAttribute::HTMLAttribute ( const std::string &  name)

Create an HTMLAttribute with the given name.

This will simply set the name and value to the same value.

Parameters
nameThe name of the attribute.

◆ HTMLAttribute() [3/4]

cgicc::HTMLAttribute::HTMLAttribute ( const std::string &  name,
const std::string &  value 
)

Create an HTMLAttribute with the given name and value.

Most attributes are of this form

Parameters
nameThe attribute's name, for example href
valueThe attributes's alue, for exampe foo.html

◆ HTMLAttribute() [4/4]

cgicc::HTMLAttribute::HTMLAttribute ( const HTMLAttribute attribute)

Copy constructor.

Sets the name of value of this attribute to those of attribute

Parameters
attributeThe HTMLAttribute to copy.

◆ ~HTMLAttribute()

virtual cgicc::HTMLAttribute::~HTMLAttribute ( )
virtual

Destructor.

Delete this HTMLAttribute object

Member Function Documentation

◆ getName()

std::string cgicc::HTMLAttribute::getName ( ) const
inline

Get the name of this HTMLAttribute.

For example, HREF

Returns
The attribute's name.

Definition at line 179 of file HTMLAttribute.h.

◆ getValue()

std::string cgicc::HTMLAttribute::getValue ( ) const
inline

Get the value of this HTMLAttribute.

For example, http://www.gnu.org

Returns
The attribute's value.

Definition at line 189 of file HTMLAttribute.h.

◆ operator!=()

bool cgicc::HTMLAttribute::operator!= ( const HTMLAttribute att) const
inline

Compare two HTMLAttributes for inequality.

HTMLAttributes are equal if they have the same name and value.

Parameters
attThe HTMLAttribute to compare to this one.
Returns
false if the two HTMLAttributes are equal, true otherwise.

Definition at line 144 of file HTMLAttribute.h.

◆ operator=()

HTMLAttribute & cgicc::HTMLAttribute::operator= ( const HTMLAttribute att)

Assign one HTMLAttribute to another.

Sets the name of value of this attribute to those of att

Parameters
attThe HTMLAttribute to copy.
Returns
A reference to this.

◆ operator==()

bool cgicc::HTMLAttribute::operator== ( const HTMLAttribute att) const

Compare two HTMLAttributes for equality.

HTMLAttributes are equal if they have the same name and value.

Parameters
attThe HTMLAttribute to compare to this one.
Returns
true if the two HTMLAttributes are equal, false otherwise.

◆ render()

virtual void cgicc::HTMLAttribute::render ( std::ostream &  out) const
virtual

Render this attribute to an ostream.

This is used for output purposes

Parameters
outThe ostream to which to write

Implements cgicc::MStreamable.

◆ setName()

void cgicc::HTMLAttribute::setName ( const std::string &  name)
inline

Set the name of this HTMLAttribute.

Use this method if the name wasn't specified in the constructor

Parameters
nameThe new name of the attribute.

Definition at line 207 of file HTMLAttribute.h.

◆ setValue()

void cgicc::HTMLAttribute::setValue ( const std::string &  value)
inline

Set the value of this HTMLAttribute.

Use this method if the value wasn't specified in the constructor

Parameters
valueThe new value of the attribute.

Definition at line 217 of file HTMLAttribute.h.


The documentation for this class was generated from the following file:

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 Fri Mar 1 2024 08:39:42 for cgicc by doxygen 1.9.6