cgicc: HTMLClasses.h Source File

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

# HTMLClasses.h

Go to the documentation of this file.

    00001 /* -*-mode:c++; c-file-style: "gnu";-*- */
    00002 /*
    00003  *  $Id: HTMLClasses.h,v 1.16 2007/07/02 18:48:18 sebdiaz Exp $
    00004  *
    00005  *  Copyright (C) 1996 - 2004 Stephen F. Booth <sbooth@gnu.org>
    00006  *                       2007 Sebastien DIAZ <sebastien.diaz@gmail.com>
    00007  *  Part of the GNU cgicc library, http://www.gnu.org/software/cgicc
    00008  *
    00009  *  This library is free software; you can redistribute it and/or
    00010  *  modify it under the terms of the GNU Lesser General Public
    00011  *  License as published by the Free Software Foundation; either
    00012  *  version 3 of the License, or (at your option) any later version.
    00013  *
    00014  *  This library is distributed in the hope that it will be useful,
    00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
    00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00017  *  Lesser General Public License for more details.
    00018  *
    00019  *  You should have received a copy of the GNU Lesser General Public
    00020  *  License along with this library; if not, write to the Free Software
    00021  *  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
    00022  */
    00023
    00024 #ifndef _HTMLCLASSES_H_
    00025 #define _HTMLCLASSES_H_ 1
    00026
    00033 #include "cgicc/CgiDefs.h"
    00034 #include "cgicc/HTMLAtomicElement.h"
    00035 #include "cgicc/HTMLBooleanElement.h"
    00036 #include "cgicc/HTMLDoctype.h"
    00037
    00038 // ============================================================
    00039 // Macros defining types of elements
    00040 // ============================================================
    00041
    00048 #define TAG(name, tag) \
    00049 class name##Tag   \
    00050 { public: inline static const char* getName() { return tag; } }
    00051
    00060 #define ATOMIC_ELEMENT(name, tag) \
    00061 TAG(name, tag); typedef HTMLAtomicElement<name##Tag> name
    00062
    00072 #define BOOLEAN_ELEMENT(name, tag) \
    00073 TAG(name, tag); typedef HTMLBooleanElement<name##Tag> name
    00074
    00075
    00076 // ============================================================
    00077 // HTML 4.0 elements - for details see http://www.w3.org/
    00078 // ============================================================
    00079
    00080 namespace cgicc {
    00081
    00082   // ============================================================
    00083   // Class comment - needs special render function
    00084   // ============================================================
    00085
    00086   class nullTag
    00087   { public: inline static const char* getName() { return 0; } };
    00088
    00092   class comment : public HTMLBooleanElement<nullTag>
    00093   {
    00094     virtual void render(std::ostream& out)      const
    00095     {
    00096       if(getData().empty() && false == dataSpecified()) {
    00097         swapState();
    00098         out << (getState() ? "<!-- " : " -->");
    00099       }
    00100       else
    00101         out << "<!-- " << getData() << " -->";
    00102     }
    00103   };
    00104
    00105   BOOLEAN_ELEMENT (html,       "html");       // HTML document
    00106   BOOLEAN_ELEMENT (head,       "head");       // document head
    00107   BOOLEAN_ELEMENT (title,      "title");      // document title
    00108   ATOMIC_ELEMENT  (meta,       "meta");       // meta data
    00109   BOOLEAN_ELEMENT (style,      "style");      // style sheet
    00110   BOOLEAN_ELEMENT (body,       "body");       // document body
    00111   BOOLEAN_ELEMENT (div,        "div");        // block-level grouping
    00112   BOOLEAN_ELEMENT (span,       "span");       // inline grouping
    00113   BOOLEAN_ELEMENT (h1,         "h1");         // level 1 heading
    00114   BOOLEAN_ELEMENT (h2,         "h2");         // level 2 heading
    00115   BOOLEAN_ELEMENT (h3,         "h3");         // level 3 heading
    00116   BOOLEAN_ELEMENT (h4,         "h4");         // level 4 heading
    00117   BOOLEAN_ELEMENT (h5,         "h5");         // level 5 heading
    00118   BOOLEAN_ELEMENT (h6,         "h6");         // level 6 heading
    00119   BOOLEAN_ELEMENT (address,    "address");    // contact information
    00120
    00121   // text markup
    00122
    00123   BOOLEAN_ELEMENT (em,         "em");         // emphasis
    00124   BOOLEAN_ELEMENT (strong,     "strong");     // stronger emphasis
    00125   BOOLEAN_ELEMENT (cite,       "cite");       // citation/reference
    00126   BOOLEAN_ELEMENT (dfn,        "dfn");        // defining instance
    00127   BOOLEAN_ELEMENT (code,       "code");       // computer code
    00128   BOOLEAN_ELEMENT (samp,       "samp");       // sample output
    00129   BOOLEAN_ELEMENT (kbd,        "kbd");        // user input
    00130   BOOLEAN_ELEMENT (var,        "var");        // variable/argument
    00131   BOOLEAN_ELEMENT (abbr,       "abbr");       // abbreviated form
    00132   BOOLEAN_ELEMENT (acronym,    "acronym");    // acronym
    00133   BOOLEAN_ELEMENT (blockquote, "blockquote"); // block-level quotation
    00134   BOOLEAN_ELEMENT (q,          "q");          // inline quotation
    00135   BOOLEAN_ELEMENT (sub,        "sub");        // subscript
    00136   BOOLEAN_ELEMENT (sup,        "sup");        // superscript
    00137   BOOLEAN_ELEMENT (p,          "p");          // paragraph
    00138   ATOMIC_ELEMENT  (br,         "br");         // line break
    00139   BOOLEAN_ELEMENT (pre,        "pre");        // preformatted text
    00140   BOOLEAN_ELEMENT (ins,        "ins");        // inserted text
    00141   BOOLEAN_ELEMENT (del,        "del");        // deleted text
    00142   BOOLEAN_ELEMENT (bdo,        "bdo");        // overriding direction
    00143
    00144   // lists
    00145
    00146   BOOLEAN_ELEMENT (ul,         "ul");         // unordered list
    00147   BOOLEAN_ELEMENT (ol,         "ol");         // ordered list
    00148   BOOLEAN_ELEMENT (li,         "li");         // list item
    00149   BOOLEAN_ELEMENT (dl,         "dl");         // definition list
    00150   BOOLEAN_ELEMENT (dt,         "dt");         // term to be defined
    00151   BOOLEAN_ELEMENT (dd,         "dd");         // definition of term
    00152
    00153   // tables
    00154
    00155   BOOLEAN_ELEMENT (table,      "table");      // table element
    00156   BOOLEAN_ELEMENT (caption,    "caption");    // table caption
    00157   BOOLEAN_ELEMENT (thead,      "thead");      // table head section
    00158   BOOLEAN_ELEMENT (tfoot,      "tfoot");      // table foot section
    00159   BOOLEAN_ELEMENT (tbody,      "tbody");      // table body section
    00160   BOOLEAN_ELEMENT (colgroup,   "colgroup");   // vertical section
    00161   ATOMIC_ELEMENT  (col,        "col");        // column attributes
    00162   BOOLEAN_ELEMENT (tr,         "tr");         // table row
    00163   BOOLEAN_ELEMENT (th,         "th");         // table header cell
    00164   BOOLEAN_ELEMENT (td,         "td");         // table data cell
    00165
    00166   // links
    00167
    00168   BOOLEAN_ELEMENT (a,          "a");          // anchor
    00169   ATOMIC_ELEMENT  (link,       "link");       // document link
    00170   ATOMIC_ELEMENT  (base,       "base");       // path information
    00171
    00172   // objects
    00173
    00174   ATOMIC_ELEMENT  (img,        "img");        // inline image
    00175   BOOLEAN_ELEMENT (object,     "object");     // generic object
    00176   ATOMIC_ELEMENT  (param,      "param");      // object parameters
    00177   BOOLEAN_ELEMENT (map,        "map");        // client image map
    00178   ATOMIC_ELEMENT  (area,       "area");       // image map region
    00179   ATOMIC_ELEMENT  (hr,         "hr");         // horizontal rule
    00180
    00181   // fonts - preferably use stylesheets
    00182
    00183   BOOLEAN_ELEMENT (tt,         "tt");         // monospaced text
    00184   BOOLEAN_ELEMENT (i,          "i");          // italic text style
    00185   BOOLEAN_ELEMENT (b,          "b");          // bold text style
    00186   BOOLEAN_ELEMENT (big,        "big");        // large font
    00187   BOOLEAN_ELEMENT (small,      "small");      // small font
    00188
    00189   // frames - not part of the strict DTD
    00190
    00191   BOOLEAN_ELEMENT (frameset,   "frameset");   // frame layout
    00192   ATOMIC_ELEMENT  (frame,      "frame");      // frame contents
    00193   BOOLEAN_ELEMENT (noframes,   "noframes");   // alternative text
    00194   BOOLEAN_ELEMENT (iframe,     "iframe");     // inline frame
    00195
    00196   // forms
    00197
    00198   BOOLEAN_ELEMENT (form,       "form");       // form element
    00199   ATOMIC_ELEMENT  (input,      "input");      // generic input
    00200   BOOLEAN_ELEMENT (button,     "button");     // special button
    00201   BOOLEAN_ELEMENT (select,     "select");     // option menu
    00202   BOOLEAN_ELEMENT (optgroup,   "optgroup");   // option group
    00203   BOOLEAN_ELEMENT (option,     "option");     // option item
    00204   BOOLEAN_ELEMENT (textarea,   "textarea");   // multi-line text input
    00205   BOOLEAN_ELEMENT (label,      "label");      // input label
    00206   BOOLEAN_ELEMENT (fieldset,   "fieldset");   // grouping input fields
    00207   BOOLEAN_ELEMENT (legend,     "legend");     // caption for field set
    00208
    00209   // scripts
    00210
    00211   BOOLEAN_ELEMENT (script,     "script");     // script element
    00212   BOOLEAN_ELEMENT (noscript,   "noscript");   // alternative text
    00213
    00214 } // namespace cgicc
    00215
    00216 #endif /* ! _HTMLCLASSES_H_ */