HTMLAttribute.h
Go to the documentation of this file.
1/* -*-mode:c++; c-file-style: "gnu";-*- */
2/*
3 * $Id: HTMLAttribute.h,v 1.9 2014/04/23 20:55:04 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 _HTMLATTRIBUTE_H_
25#define _HTMLATTRIBUTE_H_ 1
26
27#ifdef __GNUG__
28# pragma interface
29#endif
30
41#include <string>
42#include <iostream>
43
44#include "CgiDefs.h"
45#include "MStreamable.h"
46
47 namespace cgicc {
48
49 // ============================================================
50 // Class HTMLAttribute
51 // ============================================================
52
71 class CGICC_API HTMLAttribute : public MStreamable
72 {
73 public:
74
75 // ============================================================
76
79
85 HTMLAttribute();
86
93 HTMLAttribute(const std::string& name);
94
102 HTMLAttribute(const std::string& name,
103 const std::string& value);
104
111 HTMLAttribute(const HTMLAttribute& attribute);
112
118 virtual ~HTMLAttribute();
120
121 // ============================================================
122
125
133 bool
134 operator== (const HTMLAttribute& att) const;
135
143 inline bool
144 operator!= (const HTMLAttribute& att) const
145 { return ! operator==(att); }
146
147#ifdef WIN32
148 /* Dummy operator for MSVC++ */
149 inline bool
150 operator< (const HTMLAttribute& att) const
151 { return false; }
152#endif
153
161 HTMLAttribute&
162 operator= (const HTMLAttribute& att);
164
165 // ============================================================
166
171
178 inline std::string
179 getName() const
180 { return fName; }
181
188 inline std::string
189 getValue() const
190 { return fValue; }
192
193 // ============================================================
194
199
206 inline void
207 setName(const std::string& name)
208 { fName = name; }
209
216 inline void
217 setValue(const std::string& value)
218 { fValue = value; }
220
227 virtual void
228 render(std::ostream& out) const;
229
230 private:
231 std::string fName;
232 std::string fValue;
233 };
234
235} // namespace cgicc
236
237#endif /* ! _HTMLATTRIBUTE_H_ */
CgiDefs.h
Platform and operating system specific macro definitions.
MStreamable.h
Abstract base class for all streamable objects.
cgicc::HTMLAttribute
Class representing a name or a single name/value pair.
Definition: HTMLAttribute.h:72
cgicc::HTMLAttribute::render
virtual void render(std::ostream &out) const
Render this attribute to an ostream.
cgicc::HTMLAttribute::HTMLAttribute
HTMLAttribute()
Create an empty HTMLAttribute.
cgicc::HTMLAttribute::setValue
void setValue(const std::string &value)
Set the value of this HTMLAttribute.
Definition: HTMLAttribute.h:217
cgicc::HTMLAttribute::getName
std::string getName() const
Get the name of this HTMLAttribute.
Definition: HTMLAttribute.h:179
cgicc::HTMLAttribute::~HTMLAttribute
virtual ~HTMLAttribute()
Destructor.
cgicc::HTMLAttribute::HTMLAttribute
HTMLAttribute(const std::string &name, const std::string &value)
Create an HTMLAttribute with the given name and value.
cgicc::HTMLAttribute::setName
void setName(const std::string &name)
Set the name of this HTMLAttribute.
Definition: HTMLAttribute.h:207
cgicc::HTMLAttribute::getValue
std::string getValue() const
Get the value of this HTMLAttribute.
Definition: HTMLAttribute.h:189
cgicc::HTMLAttribute::HTMLAttribute
HTMLAttribute(const std::string &name)
Create an HTMLAttribute with the given name.
cgicc::HTMLAttribute::HTMLAttribute
HTMLAttribute(const HTMLAttribute &attribute)
Copy constructor.
cgicc::MStreamable
Mix-in streamable interface.
Definition: MStreamable.h:67
cgicc
The namespace containing the cgicc library.
Definition: Cgicc.h:52