// ---------------------------------------------------------------------------
// - HtmlTag.hpp                                                             -
// - afnix:www library - html tag class definition                           -
// ---------------------------------------------------------------------------
// - This program is free software;  you can redistribute it  and/or  modify -
// - it provided that this copyright notice is kept intact.                  -
// -                                                                         -
// - This program  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.  In no event shall -
// - the copyright holder be liable for any  direct, indirect, incidental or -
// - special damages arising in any way out of the use of this software.     -
// ---------------------------------------------------------------------------
// - copyright (c) 1999-2005 amaury darsch                                   -
// ---------------------------------------------------------------------------

#ifndef  AFNIX_HTMLTAG_HPP
#define  AFNIX_HTMLTAG_HPP

#ifndef  AFNIX_STRING_HPP
#include "String.hpp"
#endif

namespace afnix {

  /// The HtmlTag class is a base class for a HTML element. The tag is
  /// defined as a pair of values. For compatibility with XHTML, a tag
  /// defined without a value hold the tag name.
  /// @author amaury darsch

  class HtmlTag : public Object {
  protected:
    /// the tag name
    String d_name;
    /// the tag value
    String d_tval;

  public:
    /// create an empty html tag
    HtmlTag (void);

    /// create a tag with a name
    /// @param name the tag name
    HtmlTag (const String& name);

    /// create a tag with a name and value
    /// @param name the tag name
    /// @param tval the tag value
    HtmlTag (const String& name, const Literal& tval);

    /// copy construct this tag
    /// @param that the tag to construct
    HtmlTag (const HtmlTag& that);

    /// assign a tag to this one
    /// @param that the tag to assign
    HtmlTag& operator = (const HtmlTag& that);

    /// @return the class name
    String repr (void) const;

    /// reset this tag object
    virtual void reset (void);

    /// set the tag name
    /// @param name the tag name to set
    virtual void setname (const String& name);

    /// @return the tag name
    virtual String getname (void) const;

    /// set the tag value
    /// @param tval the tag value to set
    virtual void setvalue (const Literal& tval);

    /// @return the tag value
    virtual String getvalue (void) const;

    /// @return a string representation
    virtual String tostring (void) const;

    /// generate a new html tag object
    /// @param argv the argument vector
    static Object* mknew (Vector* argv);

    /// apply this html page with a set of arguments and a quark
    /// @param robj  robj the current runnable
    /// @param nset  the current nameset    
    /// @param quark the quark to apply these arguments
    /// @param argv  the arguments to apply
    Object* apply (Runnable* robj, Nameset* nset, const long quark,
                   Vector* argv);
  };
}

#endif
