2012-05-30 00:19:22 +02:00
|
|
|
/***************************************************************************
|
|
|
|
|
|
|
|
(c) 2012 Adrien Prokopowicz <prokopy@users.sourceforge.net>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
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. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
|
|
|
MA 02110-1301, USA.
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
***************************************************************************/
|
|
|
|
|
|
|
|
#include "CNode.h"
|
|
|
|
#include "node.h"
|
|
|
|
#include "document.h"
|
|
|
|
#include "element.h"
|
2012-08-12 23:58:13 +02:00
|
|
|
#include "textnode.h"
|
2013-07-17 00:27:47 +02:00
|
|
|
#include "serializer.h"
|
|
|
|
#include <stdlib.h>
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2014-08-05 04:02:56 +02:00
|
|
|
#define THISOBJ ((CNode*)_object)
|
[GB.XML]
OPT : A few compilation optimizations in headers inclusions.
OPT : Use of separated internal classes of gambas objects. This might prevent from a lot of problems.
OPT : Strings are not stored as wchar_t* anymore, but as simple char*, and are converted only when necessary (like UTF8 characters verification).
OPT : Does not use STL classes anymore. They are too slow. Uses now handmade classes.
OPT : Nodes are now internally linked to their brothers, so it makes find them really fasters, and allows no longer use of external linked list.
OPT : When creating new nodes, linked Gambas objects are created only when necessary, so it makes internals instanciations very faster (such as the parser).
OPT : Handmade string/memory classes and functions are now separated from the main.cpp component file.
OPT : Use specialized memory management functions (like memcpy, memchr ...) into the parser. They are really faster than C loops, and speeds up the parser for documents that have a lot of plain text.
OPT : Internally, the stream parser (XmlReader) takes only one char, not a unuseful wole string object.
OPT : Does not updates debugging data when parsing a file. They will be generated only if an error is raised (not implemented yet). It will allow a speedier parser and more precise informations.
BUG : When loading a document from a file, now correctly releases the file data.
BUG : Solved a few XmlReader uninitialized variables, that could make the stream parser crash or returns strange results.
git-svn-id: svn://localhost/gambas/trunk@4737 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-05-17 22:49:54 +02:00
|
|
|
#define THIS (static_cast<CNode*>(_object)->node)
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
#define NODE_BASE 0
|
|
|
|
#define NODE_ELEMENT 1
|
|
|
|
#define NODE_TEXT 2
|
|
|
|
#define NODE_COMMENT 3
|
|
|
|
#define NODE_CDATA 4
|
|
|
|
#define NODE_ATTRIBUTE 5
|
2014-08-05 04:02:56 +02:00
|
|
|
#define NODE_DOCUMENT 6
|
2012-05-30 00:19:22 +02:00
|
|
|
|
[GB.XML]
OPT : A few compilation optimizations in headers inclusions.
OPT : Use of separated internal classes of gambas objects. This might prevent from a lot of problems.
OPT : Strings are not stored as wchar_t* anymore, but as simple char*, and are converted only when necessary (like UTF8 characters verification).
OPT : Does not use STL classes anymore. They are too slow. Uses now handmade classes.
OPT : Nodes are now internally linked to their brothers, so it makes find them really fasters, and allows no longer use of external linked list.
OPT : When creating new nodes, linked Gambas objects are created only when necessary, so it makes internals instanciations very faster (such as the parser).
OPT : Handmade string/memory classes and functions are now separated from the main.cpp component file.
OPT : Use specialized memory management functions (like memcpy, memchr ...) into the parser. They are really faster than C loops, and speeds up the parser for documents that have a lot of plain text.
OPT : Internally, the stream parser (XmlReader) takes only one char, not a unuseful wole string object.
OPT : Does not updates debugging data when parsing a file. They will be generated only if an error is raised (not implemented yet). It will allow a speedier parser and more precise informations.
BUG : When loading a document from a file, now correctly releases the file data.
BUG : Solved a few XmlReader uninitialized variables, that could make the stream parser crash or returns strange results.
git-svn-id: svn://localhost/gambas/trunk@4737 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-05-17 22:49:54 +02:00
|
|
|
BEGIN_METHOD_VOID(CNode_new)
|
2014-08-05 04:02:56 +02:00
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
if(XMLNode_NoInstanciate()) return;
|
2012-05-30 00:19:22 +02:00
|
|
|
|
[GB.XML]
OPT : A few compilation optimizations in headers inclusions.
OPT : Use of separated internal classes of gambas objects. This might prevent from a lot of problems.
OPT : Strings are not stored as wchar_t* anymore, but as simple char*, and are converted only when necessary (like UTF8 characters verification).
OPT : Does not use STL classes anymore. They are too slow. Uses now handmade classes.
OPT : Nodes are now internally linked to their brothers, so it makes find them really fasters, and allows no longer use of external linked list.
OPT : When creating new nodes, linked Gambas objects are created only when necessary, so it makes internals instanciations very faster (such as the parser).
OPT : Handmade string/memory classes and functions are now separated from the main.cpp component file.
OPT : Use specialized memory management functions (like memcpy, memchr ...) into the parser. They are really faster than C loops, and speeds up the parser for documents that have a lot of plain text.
OPT : Internally, the stream parser (XmlReader) takes only one char, not a unuseful wole string object.
OPT : Does not updates debugging data when parsing a file. They will be generated only if an error is raised (not implemented yet). It will allow a speedier parser and more precise informations.
BUG : When loading a document from a file, now correctly releases the file data.
BUG : Solved a few XmlReader uninitialized variables, that could make the stream parser crash or returns strange results.
git-svn-id: svn://localhost/gambas/trunk@4737 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-05-17 22:49:54 +02:00
|
|
|
|
|
|
|
END_METHOD
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_METHOD_VOID(CNode_free)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
XMLNode_DestroyGBObject(THIS);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-06-05 23:17:45 +02:00
|
|
|
BEGIN_METHOD(CNode_tostring, GB_BOOLEAN indent)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
char *str = 0;
|
|
|
|
size_t len = 0;
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
GBserializeNode(THIS, str, len, VARG(indent) ? 0 : -1);
|
2012-05-30 00:19:22 +02:00
|
|
|
|
|
|
|
GB.ReturnString(str);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
END_METHOD
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
BEGIN_PROPERTY(CNode_type)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
switch(THIS->type)
|
2012-04-21 00:57:18 +02:00
|
|
|
{
|
|
|
|
case Node::ElementNode:
|
|
|
|
GB.ReturnInteger(NODE_ELEMENT);break;
|
|
|
|
case Node::Comment:
|
|
|
|
GB.ReturnInteger(NODE_COMMENT);break;
|
|
|
|
case Node::NodeText:
|
|
|
|
GB.ReturnInteger(NODE_TEXT);break;
|
|
|
|
case Node::CDATA:
|
|
|
|
GB.ReturnInteger(NODE_CDATA);break;
|
|
|
|
default:
|
|
|
|
GB.ReturnInteger(NODE_BASE);
|
|
|
|
}
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CNode_isElement)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
GB.ReturnBoolean(THIS->type == Node::ElementNode);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CNode_isText)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
GB.ReturnBoolean(THIS->type == Node::NodeText);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CNode_isComment)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
GB.ReturnBoolean(THIS->type == Node::Comment);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CNode_isCDATA)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
GB.ReturnBoolean(THIS->type == Node::CDATA);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CNode_element)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
XML_ReturnNode(THIS);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_PROPERTY(CNode_ownerDocument)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
XML_ReturnNode((Node*)XMLNode_GetOwnerDocument((Node*)THIS));
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CNode_parent)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
XML_ReturnNode((Node*)(THIS->parent));
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CNode_previous)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
XML_ReturnNode((Node*)(THIS->previousNode));
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CNode_next)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
XML_ReturnNode((Node*)(THIS->nextNode));
|
2012-05-30 00:19:22 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CNode_textContent)
|
|
|
|
|
|
|
|
|
|
|
|
if(READ_PROPERTY)
|
|
|
|
{
|
|
|
|
char *data; size_t len;
|
2013-07-17 00:27:47 +02:00
|
|
|
GBGetXMLTextContent(THIS, data, len);
|
2012-05-30 00:19:22 +02:00
|
|
|
GB.ReturnString(data);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-07-17 00:27:47 +02:00
|
|
|
XMLNode_setTextContent(THIS, PSTRING(), PLENGTH());
|
2012-05-30 00:19:22 +02:00
|
|
|
}
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CNode_name)
|
|
|
|
|
|
|
|
if(!READ_PROPERTY)
|
|
|
|
{
|
2013-07-17 00:27:47 +02:00
|
|
|
if(THIS->type == Node::ElementNode)
|
2012-04-21 00:57:18 +02:00
|
|
|
{
|
2013-07-17 00:27:47 +02:00
|
|
|
XMLElement_SetTagName((Element*)THIS, PSTRING(), PLENGTH());
|
2012-04-21 00:57:18 +02:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
switch (THIS->type)
|
2012-04-21 00:57:18 +02:00
|
|
|
{
|
|
|
|
case Node::ElementNode:
|
2013-07-17 00:27:47 +02:00
|
|
|
GB.ReturnNewString(((Element*)THIS)->tagName, ((Element*)THIS)->lenTagName);break;
|
2012-04-21 00:57:18 +02:00
|
|
|
case Node::NodeText:
|
|
|
|
GB.ReturnNewZeroString("#text");break;
|
|
|
|
case Node::Comment:
|
|
|
|
GB.ReturnNewZeroString("#comment");break;
|
|
|
|
case Node::CDATA:
|
|
|
|
GB.ReturnNewZeroString("#cdata");break;
|
2012-05-30 00:19:22 +02:00
|
|
|
case Node::AttributeNode:
|
|
|
|
GB.ReturnNewString(((Attribute*)THIS)->attrName, ((Attribute*)THIS)->lenAttrName);break;
|
2012-04-21 00:57:18 +02:00
|
|
|
default:
|
2012-05-30 00:19:22 +02:00
|
|
|
GB.ReturnNewZeroString("");
|
2012-04-21 00:57:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
|
2012-04-21 00:57:18 +02:00
|
|
|
BEGIN_METHOD(CNode_newElement, GB_STRING name; GB_STRING value)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
if(!SUPPORT_CHILDREN(THIS)) return;
|
|
|
|
Element *elmt = XMLElement_New(STRING(name), LENGTH(name));
|
|
|
|
if(!MISSING(value)) XMLElement_SetTextContent(elmt, STRING(value), LENGTH(value));
|
|
|
|
XMLNode_appendChild(THIS, elmt);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(CNode_setAttribute, GB_STRING attr; GB_STRING val)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
if(THIS->type != Node::ElementNode) return;
|
|
|
|
|
|
|
|
XMLElement_SetAttribute(((Element*)THIS), STRING(attr), LENGTH(attr),
|
2012-05-30 00:19:22 +02:00
|
|
|
STRING(val), LENGTH(val));
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
[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
|
|
|
|
|
|
|
BEGIN_METHOD(CElementAttributes_get, GB_STRING name)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
if(THIS->type != Node::ElementNode) return;
|
2012-05-30 00:19:22 +02:00
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
Attribute *attr = XMLElement_GetAttribute((Element*)THIS, STRING(name), LENGTH(name));
|
2012-05-30 00:19:22 +02:00
|
|
|
|
2016-09-13 14:37:08 +02:00
|
|
|
if(attr && attr->attrValue && attr->lenAttrValue)
|
2012-07-10 00:22:11 +02:00
|
|
|
{
|
2016-09-13 14:37:08 +02:00
|
|
|
GB.ReturnNewString(attr->attrValue, attr->lenAttrValue);
|
2012-07-10 00:22:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GB.ReturnNull();
|
|
|
|
}
|
[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
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(CElementAttributes_put, GB_STRING value; GB_STRING name)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
if(THIS->type != Node::ElementNode) return;
|
2012-05-30 00:19:22 +02:00
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
XMLElement_SetAttribute((Element*)THIS, STRING(name), LENGTH(name),
|
2012-05-30 00:19:22 +02:00
|
|
|
STRING(value), LENGTH(value));
|
[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
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CElementAttributes_count)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
if(THIS->type != Node::ElementNode)
|
2012-05-30 00:19:22 +02:00
|
|
|
{
|
|
|
|
GB.ReturnInteger(0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
[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
|
|
|
if(READ_PROPERTY)
|
|
|
|
{
|
2013-07-17 00:27:47 +02:00
|
|
|
GB.ReturnInteger(((Element*)THIS)->attributeCount);
|
[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
|
|
|
}
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_METHOD_VOID(CElementAttributes_next)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
if(THIS->type != Node::ElementNode) {GB.StopEnum(); return;}
|
2012-05-30 00:19:22 +02:00
|
|
|
|
|
|
|
Attribute *attr = *reinterpret_cast<Attribute**>((GB.GetEnum()));
|
|
|
|
if(attr == 0)
|
[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
|
|
|
{
|
2013-07-17 00:27:47 +02:00
|
|
|
attr = ((Element*)THIS)->firstAttribute;
|
2012-05-30 00:19:22 +02:00
|
|
|
*reinterpret_cast<Attribute**>(GB.GetEnum()) = attr;
|
[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
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-30 00:19:22 +02:00
|
|
|
attr = (Attribute*)attr->nextNode;
|
|
|
|
*reinterpret_cast<Attribute**>(GB.GetEnum()) = attr;
|
[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
|
|
|
}
|
|
|
|
|
2014-08-05 04:02:56 +02:00
|
|
|
THISOBJ->curAttrEnum = attr;
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
if(attr == 0) {GB.StopEnum(); return;}
|
[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
|
|
|
|
2014-08-05 04:02:56 +02:00
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
XML_ReturnNode(attr);
|
[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
|
|
|
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2014-08-05 04:02:56 +02:00
|
|
|
|
|
|
|
BEGIN_PROPERTY(CElementAttributes_name)
|
|
|
|
|
|
|
|
if(!THISOBJ->curAttrEnum)
|
|
|
|
{
|
|
|
|
GB.Error("No enumerated attribute available");
|
|
|
|
GB.ReturnNull();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-05 09:50:36 +02:00
|
|
|
if(!THISOBJ->curAttrEnum->attrName || !THISOBJ->curAttrEnum->lenAttrName)
|
|
|
|
{
|
|
|
|
GB.ReturnNull();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-05 04:02:56 +02:00
|
|
|
GB.ReturnNewString(THISOBJ->curAttrEnum->attrName, THISOBJ->curAttrEnum->lenAttrName);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CElementAttributes_value)
|
|
|
|
|
|
|
|
if(!THISOBJ->curAttrEnum)
|
|
|
|
{
|
|
|
|
GB.Error("No enumerated attribute available");
|
|
|
|
GB.ReturnNull();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-04-05 09:50:36 +02:00
|
|
|
if(!THISOBJ->curAttrEnum->attrValue || !THISOBJ->curAttrEnum->lenAttrValue)
|
|
|
|
{
|
|
|
|
GB.ReturnNull();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-08-05 04:02:56 +02:00
|
|
|
GB.ReturnNewString(THISOBJ->curAttrEnum->attrValue, THISOBJ->curAttrEnum->lenAttrValue);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-07-16 21:34:23 +02:00
|
|
|
BEGIN_PROPERTY(CNode_childNodes)
|
|
|
|
|
|
|
|
GB_ARRAY array;
|
2013-07-17 00:27:47 +02:00
|
|
|
XMLNode_getGBChildren(THIS, &array);
|
2012-07-16 21:34:23 +02:00
|
|
|
|
|
|
|
GB.ReturnObject(array);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-07-17 23:16:04 +02:00
|
|
|
BEGIN_METHOD(CNode_getUserData, GB_STRING key)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
GB_VARIANT *value = XMLNode_getUserData(THIS, STRING(key), LENGTH(key));
|
2012-07-17 23:16:04 +02:00
|
|
|
|
|
|
|
if(value)
|
|
|
|
{
|
|
|
|
GB.ReturnVariant(&(value->value));
|
|
|
|
delete value;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GB.ReturnNull();
|
|
|
|
}
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(CNode_setUserData, GB_STRING key; GB_VARIANT value)
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
XMLNode_addUserData(THIS, STRING(key), LENGTH(key), ARG(value));
|
2012-07-17 23:16:04 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-08-12 23:58:13 +02:00
|
|
|
BEGIN_METHOD(CNode_escapeContent, GB_STRING data)
|
|
|
|
|
2013-04-27 21:21:28 +02:00
|
|
|
if(!LENGTH(data))
|
|
|
|
{
|
|
|
|
GB.ReturnNull();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-08-12 23:58:13 +02:00
|
|
|
char *escapedData; size_t lenEscapedData;
|
|
|
|
|
2013-07-17 00:27:47 +02:00
|
|
|
XMLText_escapeContent(STRING(data), LENGTH(data), escapedData, lenEscapedData);
|
2012-08-12 23:58:13 +02:00
|
|
|
|
|
|
|
GB.ReturnNewString(escapedData, lenEscapedData);
|
|
|
|
|
2013-04-27 15:08:27 +02:00
|
|
|
if(escapedData != STRING(data)) free(escapedData);
|
2012-08-12 23:58:13 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2013-10-19 15:49:13 +02:00
|
|
|
BEGIN_METHOD(CNode_unEscapeContent, GB_STRING data)
|
|
|
|
|
|
|
|
if(!LENGTH(data))
|
|
|
|
{
|
|
|
|
GB.ReturnNull();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
char *unescapedData; size_t lenUnEscapedData;
|
|
|
|
|
|
|
|
XMLText_unEscapeContent(STRING(data), LENGTH(data), unescapedData, lenUnEscapedData);
|
|
|
|
|
|
|
|
GB.ReturnNewString(unescapedData, lenUnEscapedData);
|
|
|
|
|
|
|
|
if(unescapedData != STRING(data)) free(unescapedData);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_DESC CElementAttributeNodeDesc[] =
|
[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
|
|
|
{
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_DECLARE("_XmlAttrNode", sizeof(CNode)), GB_INHERITS("XmlNode"),
|
[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
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_END_DECLARE
|
|
|
|
};
|
[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
|
|
|
|
|
|
|
GB_DESC CElementAttributesDesc[] =
|
|
|
|
{
|
|
|
|
GB_DECLARE(".XmlElementAttributes", 0), GB_VIRTUAL_CLASS(),
|
|
|
|
GB_METHOD("_get", "s", CElementAttributes_get, "(Name)s"),
|
|
|
|
GB_METHOD("_put", "s", CElementAttributes_put, "(Value)s(Name)s"),
|
|
|
|
GB_METHOD("_next", "XmlNode", CElementAttributes_next, ""),
|
|
|
|
GB_PROPERTY_READ("Count", "i", CElementAttributes_count),
|
2014-08-05 04:02:56 +02:00
|
|
|
GB_PROPERTY_READ("Name", "s", CElementAttributes_name),
|
|
|
|
GB_PROPERTY_READ("Value", "s", CElementAttributes_value),
|
[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
|
|
|
GB_END_DECLARE
|
|
|
|
};
|
|
|
|
|
2012-04-21 00:57:18 +02:00
|
|
|
GB_DESC CNodeDesc[] =
|
|
|
|
{
|
[GB.XML]
OPT : A few compilation optimizations in headers inclusions.
OPT : Use of separated internal classes of gambas objects. This might prevent from a lot of problems.
OPT : Strings are not stored as wchar_t* anymore, but as simple char*, and are converted only when necessary (like UTF8 characters verification).
OPT : Does not use STL classes anymore. They are too slow. Uses now handmade classes.
OPT : Nodes are now internally linked to their brothers, so it makes find them really fasters, and allows no longer use of external linked list.
OPT : When creating new nodes, linked Gambas objects are created only when necessary, so it makes internals instanciations very faster (such as the parser).
OPT : Handmade string/memory classes and functions are now separated from the main.cpp component file.
OPT : Use specialized memory management functions (like memcpy, memchr ...) into the parser. They are really faster than C loops, and speeds up the parser for documents that have a lot of plain text.
OPT : Internally, the stream parser (XmlReader) takes only one char, not a unuseful wole string object.
OPT : Does not updates debugging data when parsing a file. They will be generated only if an error is raised (not implemented yet). It will allow a speedier parser and more precise informations.
BUG : When loading a document from a file, now correctly releases the file data.
BUG : Solved a few XmlReader uninitialized variables, that could make the stream parser crash or returns strange results.
git-svn-id: svn://localhost/gambas/trunk@4737 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-05-17 22:49:54 +02:00
|
|
|
GB_DECLARE("XmlNode", sizeof(CNode)), GB_NOT_CREATABLE(),
|
|
|
|
|
2017-08-22 10:27:41 +02:00
|
|
|
GB_METHOD("_new", NULL, CNode_new, ""),
|
|
|
|
GB_METHOD("_free", NULL, CNode_free, ""),
|
2012-05-30 00:19:22 +02:00
|
|
|
|
2012-04-21 00:57:18 +02:00
|
|
|
GB_CONSTANT("ElementNode", "i", NODE_ELEMENT),
|
|
|
|
GB_CONSTANT("TextNode", "i", NODE_TEXT),
|
|
|
|
GB_CONSTANT("CommentNode", "i", NODE_COMMENT),
|
|
|
|
GB_CONSTANT("CDATASectionNode", "i", NODE_CDATA),
|
[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
|
|
|
GB_CONSTANT("AttributeNode", "i", NODE_ATTRIBUTE),
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
GB_PROPERTY_READ("Type", "i", CNode_type),
|
|
|
|
GB_PROPERTY_READ("IsElement", "b", CNode_isElement),
|
|
|
|
GB_PROPERTY_READ("IsText", "b", CNode_isText),
|
|
|
|
GB_PROPERTY_READ("IsComment", "b", CNode_isComment),
|
|
|
|
GB_PROPERTY_READ("IsCDATA", "b", CNode_isCDATA),
|
2012-05-30 00:19:22 +02:00
|
|
|
|
2012-04-21 00:57:18 +02:00
|
|
|
GB_PROPERTY_READ("Element", "XmlElement", CNode_element),
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_PROPERTY_READ("OwnerDocument", "XmlDocument", CNode_ownerDocument),
|
2012-07-16 21:34:23 +02:00
|
|
|
GB_PROPERTY_READ("ChildNodes", "XmlNode[]", CNode_childNodes),
|
|
|
|
GB_PROPERTY_READ("Children", "XmlNode[]", CNode_childNodes),
|
2012-04-21 00:57:18 +02:00
|
|
|
GB_PROPERTY_READ("Parent", "XmlElement", CNode_parent),
|
|
|
|
GB_PROPERTY_READ("Previous", "XmlNode", CNode_previous),
|
|
|
|
GB_PROPERTY_READ("Next", "XmlNode", CNode_next),
|
2012-07-17 13:36:30 +02:00
|
|
|
GB_PROPERTY_READ("PreviousSibling", "XmlNode", CNode_previous),
|
|
|
|
GB_PROPERTY_READ("NextSibling", "XmlNode", CNode_next),
|
2012-05-30 00:19:22 +02:00
|
|
|
|
|
|
|
GB_METHOD("ToString", "s", CNode_tostring, "[(Indent)b]"),
|
2012-07-17 23:16:04 +02:00
|
|
|
GB_METHOD("GetUserData", "v", CNode_getUserData, "(Key)s"),
|
2017-08-22 10:27:41 +02:00
|
|
|
GB_METHOD("SetUserData", NULL, CNode_setUserData, "(Key)s(Value)v"),
|
2012-04-21 00:57:18 +02:00
|
|
|
GB_PROPERTY("TextContent", "s", CNode_textContent),
|
|
|
|
GB_PROPERTY("Value", "s", CNode_textContent),
|
|
|
|
GB_PROPERTY("Name", "s", CNode_name),
|
2012-08-12 23:58:13 +02:00
|
|
|
|
|
|
|
GB_STATIC_METHOD("Serialize", "s", CNode_escapeContent, "(Data)s"),
|
2013-10-19 15:49:13 +02:00
|
|
|
GB_STATIC_METHOD("Deserialize", "s", CNode_unEscapeContent, "(Data)s"),
|
2013-07-17 00:27:47 +02:00
|
|
|
|
2017-08-22 10:27:41 +02:00
|
|
|
GB_METHOD("NewElement", NULL, CNode_newElement, "(Name)s[(Value)s]"),
|
|
|
|
GB_METHOD("NewAttribute", NULL, CNode_setAttribute, "(Name)s(Value)s"),
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_PROPERTY_SELF("Attributes", ".XmlElementAttributes"),
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
GB_END_DECLARE
|
|
|
|
};
|