// ---------------------------------------------------------------------------
// - HtmlTr.hpp                                                              -
// - afnix:www module - html table row 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_HTMLTR_HPP
#define  AFNIX_HTMLTR_HPP

#ifndef  AFNIX_HTMLTD_HPP
#include "HtmlTd.hpp"
#endif

namespace afnix {

  /// The HtmlTr class is the html table row class. The class is built
  /// by inserting table data element. Each table data element is designed
  /// to hold a string value and eventually some tags.
  /// @author amaury darsch
  
  class HtmlTr : public HtmlElement {
  private:
    /// the default td class
    String d_dtdc;
    /// the data element
    Vector d_tbld;
    
  public:
    /// create an empty row
    HtmlTr (void);

    /// create a row with a default td class
    /// @param dtdc the default td class
    HtmlTr (const String& dtdc);

    /// @return the class name
    String repr (void) const;
    
    /// @return the number of data elements
    long length (void) const;

    /// @return a data element by index
    HtmlTableData* gettd (const long index) const;

    /// set the default td class
    void setdtdc (const String& dtdc);

    /// @retrun the default td class
    String getdtdc (void) const;

    /// add a table data to this row
    /// @param td the table data to add
    HtmlTableData* adddata (HtmlTableData* td);

    /// add a literal data to this row
    /// @param lval the literal data to add
    HtmlTableData* adddata (const Literal& lval);

    /// add a literal head to this row
    /// @param lval the literal data to add
    HtmlTableData* addhead (const Literal& lval);

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

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

  public:
    /// create a new object in a generic way
    /// @param argv the argument vector
    static Object* mknew (Vector* argv);
    
    /// @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);
  }; 
}

#endif
