gambas-source-code/gb.xml/src/textnode.h

74 lines
2 KiB
C
Raw Normal View History

#ifndef TEXTNODE_H
#define TEXTNODE_H
#include "main.h"
#include "node.h"
class TextNode : public Node
{
public:
class Virtual : public Node::Virtual
{
public:
Virtual(TextNode *node) : Node::Virtual(node), parent(node) {}
Virtual(const Virtual &copie) : Node::Virtual(copie.parent), parent(copie.parent) {}
Virtual &operator=(const Virtual &copie) {parent = copie.parent; return *this;}
virtual Node::Type getType() {return Node::NodeText;}
virtual wstring toString(int indent = -1);
virtual wstring textContent() {return *(parent->content);}
[GB.XML] * NEW : Added a new property "State" to XmlExplorer and XmlReader, that allows to know the reader state, without knowing Read() return value. * NEW : When enumerating XmlReader.Node.Attributes, XmlReader.Node represents the current attribute. * NEW : Added an new method Open() that loads an HtmlDocument from a file and defines it as the document to read. * NEW : The Attributes property has now moved from XmlElement to XmlNode. XmlNode.Attributes returns Null if the node isn't an element. * NEW : Then enumeration of XmlNode.Attributes now returns an .XmlElementAttribute instead of a string. * NEW : The XmlNode.Attribute constant is not obsolete anymore. * NEW : Two consecutives whitespaces are now ignored (only one is preserved). * NEW : When parsing a file, line-breaks and tabulations are replaced by spaces. * BUG : XmlExplorer flags are now correctly initialized. * BUG : Added an Eof property on XmlExplorer, that was missing. * BUG : Calling XmlExplorer.Read() after Eof just returns XmlReaderNodeType.Eof, not more. * BUG : Calling XmlNode.Next() when the node hasn't got any brother after him doesn't crash anymore, it just returns Null. * BUG : Calling XmlElement.NextSibling() when the node hasn't got any element brother after him doesn't crash anymore, it just returns Null. * BUG : By default, XmlReader correctly stops when reading the end of an element. * BUG : XmlExplorer now correctly initializes and releases itself. * BUG : XmlExplorer now correctly supports its read flags. * OPT : Solved a memory leak when releasing a XmlReader. * OPT : When setting text content to a XmlNode, the string is not duplicated anymore. * OPT : When testing if characters are whitespaces or names characters while parsing texts, puts the temporary variable into registers instead of memory. git-svn-id: svn://localhost/gambas/trunk@4669 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-04-25 01:47:14 +02:00
virtual void setTextContent(wstring &content) {*(parent->content) = content;}
virtual Node* cloneNode();
TextNode *parent;
};
wstring *content;
static GB_CLASS ClassName;
};
class CommentNode : public TextNode
{
public:
class Virtual : public TextNode::Virtual
{
public:
Virtual(CommentNode *node) : TextNode::Virtual(node), parent(node) {}
Virtual(const Virtual &copie) : TextNode::Virtual(copie.parent), parent(copie.parent) {}
Virtual &operator=(const Virtual &copie) {parent = copie.parent; return *this;}
virtual Node::Type getType() {return Node::Comment;}
virtual wstring toString(int indent = -1);
virtual Node* cloneNode();
CommentNode *parent;
};
static GB_CLASS ClassName;
};
class CDATANode : public TextNode
{
public:
class Virtual : public TextNode::Virtual
{
public:
Virtual(CDATANode *node) : TextNode::Virtual(node), parent(node) {}
Virtual(const Virtual &copie) : TextNode::Virtual(copie.parent), parent(copie.parent) {}
Virtual &operator=(const Virtual &copie) {parent = copie.parent; return *this;}
virtual Node::Type getType() {return Node::CDATA;}
virtual wstring toString(int indent = -1);
virtual Node* cloneNode();
CDATANode *parent;
};
static GB_CLASS ClassName;
};
#endif // TEXTNODE_H