1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| #include <vector>
#include <map>
#include <string>
#include <sstream>
namespace HTML {
typedef std::map<std::string,std::string> ATTRIBUTES;
const ATTRIBUTES emptyAttributes;
/** Element fondamentale HTML ex: balise <td></td> */
class Element
{
///Map des attributs
ATTRIBUTES m_attributes;
///Text identifiant de la balise
std::string m_balise;
///Contenue de la balise
std::string m_contant;
public:
Element(const Element& e)
Element(std::string balise, std::string contant = "",ATTRIBUTES attributes = emptyAttributes);
virtual void toHTML(std::ostream& os, std::string str = "" );
void setAttibutes(ATTRIBUTES attributes);
ATTRIBUTES* getAttributes();
};
/** Element pour un tableau balise <td> */
class Cell : public Element
{
static std::string balise /* = "td" */;
public:
Cell(const Cell& cell);
Cell(const char* contant, ATTRIBUTES attributes = emptyAttributes);
Cell(std::string contant, ATTRIBUTES attributes = emptyAttributes);
};
const std::vector<Cell*> emptyCells;
/** Element pour une ligne tableau balise <tr> */
class TableRow : public Element
{
///Liste des cells d'une ligne
std::vector<Cell*> m_pCells;
public :
TableRow(TableRow& tableRow);
TableRow(std::vector<Cell*> pCells = emptyCells, ATTRIBUTES attributes = emptyAttributes );
TableRow(const char *cstring, ATTRIBUTES attributes = emptyAttributes);
~TableRow();
virtual void toHTML(std::ostream& os, std::string str = "" );
Cell* addCell(Cell cell, ATTRIBUTES attributes = emptyAttributes );
Cell* addCell(Cell *pCell );
void setCell(unsigned int pos, Cell cell, ATTRIBUTES attributes = emptyAttributes );
Cell* getCell(unsigned int pos);
};
/** Tableau balise <table> */
class Table : public Element
{
///Liste des lignes
std::vector<TableRow*> m_pRows;
public:
Table(ATTRIBUTES attributes = emptyAttributes);
~Table();
TableRow *addRow(std::vector<Cell*> cells = emptyCells, ATTRIBUTES attributes = emptyAttributes);
TableRow *addRow(TableRow row);
TableRow* getRow(int num);
virtual void toHTML(std::ostream& os, std::string str = "");
};
}; |
Partager