// ---------------------------------------------------------------------------
// - HtmlTd.hpp                                                              -
// - afnix:www module - html table data 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-2006 amaury darsch                                   -
// ---------------------------------------------------------------------------

#ifndef  AFNIX_HTMLTD_HPP
#define  AFNIX_HTMLTD_HPP

#ifndef  AFNIX_HTMLELEMENT_HPP
#include "HtmlElement.hpp"
#endif

namespace afnix {

  /// The HtmlTableData class is a generic class that implement the behavior
  /// for the TD and TH element. this class cannot be instanciated directly
  /// @author amaury darsch
  
  class HtmlTableData : public HtmlElement {
  protected:
    /// the data value
    String d_data;

  protected:
    /// create a new table data element by name
    /// @param name the element name
    HtmlTableData (const String& name);

  public:
    /// set the data element
    /// @param lval the literal value to set
    void setdata (const Literal& lval);

    /// @return the data element
    String getdata (void) const;

    /// emit the data element into a buffer
    /// @param buf the recepting buffer
    void emit (Buffer& buf) const;

  private:
    // make the default constructor private
    HtmlTableData (void);

  public:
    /// @return true if the given quark is defined
    bool isquark (const long quark, const bool hflg) const;

    /// apply this object with a set of arguments and a quark
    /// @param 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);
  };

  /// The HtmlTd class is the table data class. The class is designed to hold
  /// a string value with some html tags. 
  /// @author amaury darsch

  class HtmlTd : public HtmlTableData {
  public:
    /// create an empty data element
    HtmlTd (void);
    
    /// create a data element by value
    /// @žaram lval the literal value
    HtmlTd (const Literal& lval);

    /// create a data element by value and class
    /// @žaram lval the literal value
    /// @žaram dtdc the default class
    HtmlTd (const Literal& lval, const String& dtdc);
    
    /// @return the class name
    String repr (void) const;

  private:
    // make the copy constructor private
    HtmlTd (const HtmlTd&);
    // make the assignment operator private
    HtmlTd& operator = (const HtmlTd&);

  public:
    /// create a new oject in a generic way
    /// @param argv the argument vector
    static Object* mknew (Vector* argv);
  };

  /// The HtmlTh class is the table header class. The class is similar to the
  /// HtmlTd class except that it shall be used within table header. The
  /// corresponding element is the TH element.
  /// @author amaury darsch

  class HtmlTh : public HtmlTableData {
  public:
    /// create an empty data element
    HtmlTh (void);
    
    /// create a data element by value
    /// @žaram lval the literal value
    HtmlTh (const Literal& lval);

    /// create a data element by value and class
    /// @žaram lval the literal value
    /// @žaram dtdc the default class
    HtmlTh (const Literal& lval, const String& dtdc);
    
    /// @return the class name
    String repr (void) const;

  private:
    // make the copy constructor private
    HtmlTh (const HtmlTh&);
    // make the assignment operator private
    HtmlTh& operator = (const HtmlTh&);

  public:
    /// create a new oject in a generic way
    /// @param argv the argument vector
    static Object* mknew (Vector* argv);
  };
}

#endif
