#ifndef _NODE_H_
#define _NODE_H_
#include "Body.h"
namespace LAG
{
class Node
{
public:
Node();
Node(const Node&);
virtual ~Node();
bool AddIndexAttr();
bool AddAttr(const std::string&, const std::string&);
uint16_t GetIndex();
bool SetIndex(uint16_t);
const std::string* GetName();
bool SetBody(Body*);
bool SetParent(Node*);
bool SetFirstChild(Node*);
bool SetNext(Node*);
bool SetPrev(Node*);
relpos_t Compare(Node*);
void operator--(int);
void operator++(int);
template <class T> T* AddChild(T*);
template <class T> T* AddSibling(T*);
bool RemoveFirstByName(const char *);
std::list<Node*>* FindByName(const char *, std::list<Node*>*);
std::list<Node*>* FindWhereAttrEquals(attribute*, std::list<Node*>*);
//std::list<Node*>* FindWhereAttrDefined(attribute); /* TODO */
//std::list<Node*>* FindWhereBodyContains(std::string); /* TODO */
void Show(std::ostream&);
void ChainedShow(std::ostream&);
void ChainedCascadeShow(std::ostream&);
protected:
Body* body;
uint16_t index;
const std::string* name;
str_pairs_list attrList;
Node* firstChild;
Node* parent;
Node* prevSib;
Node* nextSib;
};
};
#endif /*_NODE_H_*/
/*
* A Declaration redefines some aspects :
* - can't have body,
* - nor children,
* - nor parents,
* - renders differently
*
*/
#ifndef _DECLARATION_H_
#define _DECLARATION_H_
#include "Element.h"
#include "Body.h"
#include "Node.h"
namespace LAG
{
class Declaration : public Node
{
public:
Declaration(const std::string&);
Declaration(const std::string&, uint16_t);
~Declaration();
bool SetBody(Body*); // throws
bool SetParent(Node*); // throws
bool SetFirstChild(Node*); // throws
template <class T> T* AddChild(T*);
void Show(std::ostream&);
void ChainedShow(std::ostream&);
void ChainedCascadeShow(std::ostream&);
};
};
#endif /*_DECLARATION_H_*/
Partager