2012-05-30 00:19:22 +02:00
|
|
|
/***************************************************************************
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
(c) 2012 Adrien Prokopowicz <prokopy@users.sourceforge.net>
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
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.
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
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.
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
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
|
|
|
***************************************************************************/
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
#include "CElement.h"
|
|
|
|
#include "element.h"
|
|
|
|
#include "gbi.h"
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
#define THIS (static_cast<CNode*>(_object)->node->toElement())
|
|
|
|
#define THISNODE (static_cast<CNode*>(_object)->node)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_METHOD(CElement_new, GB_STRING tagName)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
if(Node::NoInstanciate) 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
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
if(!MISSING(tagName))
|
|
|
|
{
|
|
|
|
THISNODE = new Element(STRING(tagName), LENGTH(tagName));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
THISNODE = new Element;
|
|
|
|
}
|
|
|
|
THIS->GBObject = static_cast<CNode*>(_object);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CElement_tagName)
|
|
|
|
|
|
|
|
if(READ_PROPERTY)
|
|
|
|
{
|
2012-05-30 00:19:22 +02:00
|
|
|
GB.ReturnNewString(THIS->tagName, THIS->lenTagName);
|
2012-07-11 17:14:13 +02:00
|
|
|
if(!THIS->tagName || !THIS->lenTagName)
|
|
|
|
{
|
|
|
|
GB.ReturnNull();
|
|
|
|
return;
|
|
|
|
}
|
2012-04-21 00:57:18 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-05-30 00:19:22 +02:00
|
|
|
THIS->setTagName(PSTRING(), PLENGTH());
|
2012-04-21 00:57:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-06-25 18:33:14 +02:00
|
|
|
BEGIN_PROPERTY(CElement_prefix)
|
|
|
|
|
|
|
|
if(READ_PROPERTY)
|
|
|
|
{
|
2012-07-11 17:14:13 +02:00
|
|
|
if(!THIS->prefix || !THIS->lenPrefix)
|
|
|
|
{
|
|
|
|
GB.ReturnNull();
|
|
|
|
return;
|
|
|
|
}
|
2012-06-25 18:33:14 +02:00
|
|
|
GB.ReturnNewString(THIS->prefix, THIS->lenPrefix);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
THIS->setPrefix(PSTRING(), PLENGTH());
|
|
|
|
}
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_METHOD(CElement_appendChild, GB_OBJECT newChild)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
THIS->appendChild(VARGOBJ(CNode, newChild)->node);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-10 00:22:11 +02:00
|
|
|
BEGIN_METHOD(CElement_getAttribute, GB_STRING attrName; GB_INTEGER mode)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-07-10 00:22:11 +02:00
|
|
|
Attribute *attr = THIS->getAttribute(STRING(attrName), LENGTH(attrName), VARG(mode));
|
2012-05-30 00:19:22 +02:00
|
|
|
if(attr)
|
|
|
|
{
|
2012-07-08 22:27:03 +02:00
|
|
|
GB.ReturnNewString(attr->attrValue, attr->lenAttrValue);
|
2012-05-30 00:19:22 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
GB.ReturnNull();
|
|
|
|
}
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_METHOD(CElement_setAttribute, GB_STRING attrName; GB_STRING attrValue)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
THIS->setAttribute(STRING(attrName), LENGTH(attrName),
|
|
|
|
STRING(attrValue), LENGTH(attrValue));
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_METHOD(CElement_appendFromText, GB_STRING data)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-06-26 19:45:57 +02:00
|
|
|
try
|
|
|
|
{
|
|
|
|
THIS->appendFromText(STRING(data), LENGTH(data));
|
|
|
|
}
|
|
|
|
catch(XMLParseException &e)
|
|
|
|
{
|
|
|
|
GB.Error(e.what());
|
|
|
|
}
|
2012-04-21 00:57:18 +02:00
|
|
|
END_METHOD
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_METHOD(CElement_appendChildren, GB_OBJECT children)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_ARRAY array = reinterpret_cast<GB_ARRAY>(VARG(children));
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
for(int i = 0; i < GB.Array.Count(array); i++)
|
2012-04-21 00:57:18 +02:00
|
|
|
{
|
2012-05-30 00:19:22 +02:00
|
|
|
THIS->appendChild((*(reinterpret_cast<CNode**>(GB.Array.Get(array, i))))->node);
|
2012-04-21 00:57:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_METHOD(CElement_prependChild, GB_OBJECT newChild)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
THIS->prependChild(VARGOBJ(CNode, newChild)->node);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(CElement_removeChild, GB_OBJECT oldChild)
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
THIS->removeChild(VARGOBJ(CNode, oldChild)->node);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(CElement_replaceChild, GB_OBJECT oldChild; GB_OBJECT newChild)
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
THIS->replaceChild(VARGOBJ(CNode, oldChild)->node,
|
|
|
|
VARGOBJ(CNode, newChild)->node);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_METHOD(CElement_insertAfter, GB_OBJECT child; GB_OBJECT newChild)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
THIS->insertAfter(VARGOBJ(CNode, child)->node, VARGOBJ(CNode, newChild)->node);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_METHOD(CElement_insertBefore, GB_OBJECT child; GB_OBJECT newChild)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
THIS->insertBefore(VARGOBJ(CNode, child)->node, VARGOBJ(CNode, newChild)->node);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_METHOD(CElement_appendText, GB_STRING data)
|
|
|
|
|
|
|
|
THIS->appendText(STRING(data), LENGTH(data));
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-10 02:17:15 +02:00
|
|
|
BEGIN_METHOD_VOID(CElement_clearChildren)
|
|
|
|
|
|
|
|
THIS->clearChildren();
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-17 13:36:30 +02:00
|
|
|
BEGIN_PROPERTY(CElement_previousElement)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-07-17 13:36:30 +02:00
|
|
|
GBI::Return(THIS->previousElement());
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-07-17 13:36:30 +02:00
|
|
|
BEGIN_PROPERTY(CElement_nextElement)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-07-17 13:36:30 +02:00
|
|
|
GBI::Return(THIS->nextElement());
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_METHOD(CElement_isAttributeSet, GB_STRING name)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
GB.ReturnBoolean((bool)(THIS->getAttribute(STRING(name), LENGTH(name))));
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_PROPERTY(CElement_allChildNodes)
|
|
|
|
|
|
|
|
GB_ARRAY array;
|
|
|
|
THIS->getGBAllChildren(&array);
|
|
|
|
|
|
|
|
GB.ReturnObject(array);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-04-21 00:57:18 +02:00
|
|
|
BEGIN_PROPERTY(CElement_firstChildElement)
|
|
|
|
|
[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
|
|
|
GBI::Return(THIS->firstChildElement());
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CElement_lastChildElement)
|
|
|
|
|
[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
|
|
|
GBI::Return(THIS->lastChildElement());
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_PROPERTY(CElement_childElements)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_ARRAY array;
|
|
|
|
THIS->getGBChildElements(&array);
|
|
|
|
GB.ReturnObject(array);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
END_PROPERTY
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
BEGIN_METHOD(CElement_fromText, GB_STRING data)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_ARRAY array;
|
2012-06-15 03:33:48 +02:00
|
|
|
Element::GBfromText(STRING(data), LENGTH(data), &array);
|
2012-05-30 00:19:22 +02:00
|
|
|
GB.ReturnObject(array);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-06-25 14:44:15 +02:00
|
|
|
BEGIN_METHOD(CElement_getChildrenByTagName, GB_STRING tagName; GB_INTEGER mode ; GB_INTEGER depth;)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_ARRAY array;
|
2012-06-25 14:44:15 +02:00
|
|
|
THIS->getGBChildrenByTagName(STRING(tagName), LENGTH(tagName), &array, VARGOPT(mode, GB_STRCOMP_BINARY), VARGOPT(depth, -1));
|
2012-05-30 00:19:22 +02:00
|
|
|
GB.ReturnObject(array);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-06-25 18:33:14 +02:00
|
|
|
BEGIN_METHOD(CElement_getChildrenByNamespace, GB_STRING name; GB_INTEGER mode ; GB_INTEGER depth;)
|
|
|
|
|
|
|
|
GB_ARRAY array;
|
|
|
|
THIS->getGBChildrenByNamespace(STRING(name), LENGTH(name), &array, VARGOPT(mode, GB_STRCOMP_BINARY), VARGOPT(depth, -1));
|
|
|
|
GB.ReturnObject(array);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-06-25 14:44:15 +02:00
|
|
|
BEGIN_METHOD(CElement_getChildrenByAttributeValue, GB_STRING name; GB_STRING value; GB_INTEGER mode ; GB_INTEGER depth;)
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_ARRAY array;
|
|
|
|
THIS->getGBChildrenByAttributeValue(STRING(name), LENGTH(name),
|
|
|
|
STRING(value), LENGTH(value),
|
2012-06-25 14:44:15 +02:00
|
|
|
&array, VARGOPT(mode, GB_STRCOMP_BINARY), VARGOPT(depth, -1));
|
2012-05-30 00:19:22 +02:00
|
|
|
GB.ReturnObject(array);
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
2012-07-10 15:53:38 +02:00
|
|
|
BEGIN_PROPERTY(CElement_firstChild)
|
|
|
|
|
|
|
|
GBI::Return(THIS->firstChild);
|
|
|
|
|
|
|
|
END_METHOD
|
|
|
|
|
|
|
|
BEGIN_PROPERTY(CElement_lastChild)
|
|
|
|
|
|
|
|
GBI::Return(THIS->lastChild);
|
|
|
|
|
|
|
|
END_PROPERTY
|
|
|
|
|
2012-04-21 00:57:18 +02:00
|
|
|
|
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_DESC CElementDesc[] =
|
|
|
|
{
|
|
|
|
GB_DECLARE("XmlElement", sizeof(CNode)), GB_INHERITS("XmlNode"),
|
|
|
|
|
|
|
|
GB_METHOD("_new", "", CElement_new, "[(TagName)s]"),
|
|
|
|
|
|
|
|
GB_METHOD("AppendChild", "", CElement_appendChild, "(NewChild)XmlNode"),
|
|
|
|
GB_METHOD("AppendChildren", "", CElement_appendChildren, "(NewChildren)XmlNode[]"),
|
|
|
|
GB_METHOD("PrependChild", "", CElement_prependChild, "(NewChild)XmlNode"),
|
|
|
|
GB_METHOD("InsertAfter", "", CElement_insertAfter, "(Child)XmlNode;(NewChild)XmlNode"),
|
|
|
|
GB_METHOD("InsertBefore", "", CElement_insertBefore, "(Child)XmlNode;(NewChild)XmlNode"),
|
|
|
|
GB_METHOD("RemoveChild", "", CElement_removeChild, "(OldChild)XmlNode"),
|
|
|
|
GB_METHOD("ReplaceChild", "", CElement_replaceChild, "(OldChild)XmlNode;(NewChild)XmlNode"),
|
2012-07-10 02:17:15 +02:00
|
|
|
GB_METHOD("ClearChildren", "", CElement_clearChildren, ""),
|
2012-05-30 00:19:22 +02:00
|
|
|
|
|
|
|
GB_METHOD("AppendText", "", CElement_appendText, "(Data)s"),
|
|
|
|
GB_METHOD("AppendFromText", "", CElement_appendFromText, "(Data)s"),
|
|
|
|
|
2012-06-25 14:44:15 +02:00
|
|
|
GB_METHOD("GetAttribute", "s", CElement_getAttribute, "(Name)s[(Mode)i]"),
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_METHOD("SetAttribute", "", CElement_setAttribute, "(Name)s(Value)s"),
|
|
|
|
|
|
|
|
GB_METHOD("IsAttributeSet", "b", CElement_isAttributeSet, "(Name)s"),
|
|
|
|
|
|
|
|
GB_PROPERTY_READ("ChildElements", "XmlElement[]", CElement_childElements),
|
|
|
|
GB_PROPERTY_READ("AllChildNodes", "XmlNode[]", CElement_allChildNodes),
|
2012-07-10 15:53:38 +02:00
|
|
|
GB_PROPERTY_READ("FirstChild", "XmlNode", CElement_firstChild),
|
|
|
|
GB_PROPERTY_READ("LastChild", "XmlNode", CElement_lastChild),
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_PROPERTY_READ("FirstChildElement", "XmlElement", CElement_firstChildElement),
|
|
|
|
GB_PROPERTY_READ("LastChildElement", "XmlElement", CElement_lastChildElement),
|
|
|
|
|
|
|
|
GB_PROPERTY("TagName", "s", CElement_tagName),
|
2012-06-25 18:33:14 +02:00
|
|
|
GB_PROPERTY("Prefix", "s", CElement_prefix),
|
2012-07-23 20:28:15 +02:00
|
|
|
GB_PROPERTY("PreviousElement", "XmlElement", CElement_previousElement),
|
2012-07-17 13:36:30 +02:00
|
|
|
GB_PROPERTY("NextElement", "XmlElement", CElement_nextElement),
|
2012-06-25 18:33:14 +02:00
|
|
|
|
|
|
|
GB_METHOD("GetChildrenByNamespace", "XmlElement[]", CElement_getChildrenByNamespace, "(Namespace)s[(Mode)i(Depth)i]"),
|
2012-06-25 14:44:15 +02:00
|
|
|
GB_METHOD("GetChildrenByTagName", "XmlElement[]", CElement_getChildrenByTagName, "(TagName)s[(Mode)i(Depth)i]"),
|
|
|
|
GB_METHOD("GetChildrenByAttributeValue", "XmlElement[]", CElement_getChildrenByAttributeValue, "(Attribute)s(Value)s[(Mode)i(Depth)i]"),
|
2012-05-30 00:19:22 +02:00
|
|
|
|
|
|
|
GB_STATIC_METHOD("FromText", "XmlNode[]", CElement_fromText, "(Data)s"),
|
|
|
|
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
GB_END_DECLARE
|
|
|
|
};
|
2012-04-21 00:57:18 +02:00
|
|
|
|
2012-05-30 00:19:22 +02:00
|
|
|
/*
|
2012-04-21 00:57:18 +02:00
|
|
|
GB_DESC CElementDesc[] =
|
|
|
|
{
|
[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("XmlElement", sizeof(CElement)), GB_INHERITS("XmlNode"),
|
2012-04-21 00:57:18 +02:00
|
|
|
GB_METHOD("_new", "", CElement_new, "[(TagName)s]"),
|
|
|
|
GB_METHOD("_free", "", CElement_free, ""),
|
|
|
|
GB_METHOD("AppendChild", "", CElement_AppendChild, "(NewChild)XmlNode"),
|
|
|
|
GB_METHOD("AppendChildren", "", CElement_AppendChildren, "(NewChildren)XmlNode[]"),
|
|
|
|
GB_METHOD("PrependChild", "", CElement_prependChild, "(NewChild)XmlNode"),
|
|
|
|
GB_METHOD("InsertAfter", "", CElement_insertAfter, "(Child)XmlNode;(NewChild)XmlNode"),
|
|
|
|
GB_METHOD("InsertBefore", "", CElement_insertBefore, "(Child)XmlNode;(NewChild)XmlNode"),
|
|
|
|
GB_METHOD("AppendText", "", CElement_AppendText, "(NewText)s"),
|
|
|
|
GB_METHOD("AppendFromText", "", CElement_appendFromText, "(Data)s"),
|
|
|
|
GB_METHOD("RemoveChild", "", CElement_removeChild, "(OldChild)XmlNode"),
|
|
|
|
GB_METHOD("ReplaceChild", "", CElement_replaceChild, "(OldChild)XmlNode;(NewChild)XmlNode"),
|
|
|
|
GB_METHOD("NewElement", "", CElement_newElement, "(Name)s[(Value)s]"),
|
|
|
|
|
|
|
|
GB_PROPERTY("TagName", "s", CElement_tagName),
|
|
|
|
|
|
|
|
GB_PROPERTY_READ("PreviousSibling", "XmlElement", CElement_previousSibling),
|
|
|
|
GB_PROPERTY_READ("NextSibling", "XmlElement", CElement_nextSibling),
|
|
|
|
|
|
|
|
GB_METHOD("GetAttribute", "s", CElement_getAttribute, "(Name)s"),
|
|
|
|
GB_METHOD("SetAttribute", "", CElement_setAttribute, "(Name)s(Value)s"),
|
|
|
|
GB_METHOD("NewAttribute", "", CElement_setAttribute, "(Name)s(Value)s"),
|
|
|
|
GB_METHOD("IsAttributeSet", "b", CElement_isAttributeSet, "(Name)s"),
|
|
|
|
|
|
|
|
GB_PROPERTY_READ("ChildNodes", "XmlNode[]", CElement_childNodes),
|
|
|
|
GB_PROPERTY_READ("Children", "XmlNode[]", CElement_childNodes),
|
|
|
|
GB_PROPERTY_READ("ChildElements", "XmlElement[]", CElement_childElements),
|
|
|
|
GB_PROPERTY_READ("AllChildNodes", "XmlNode[]", CElement_allChildNodes),
|
|
|
|
GB_PROPERTY_READ("FirstChildElement", "XmlElement", CElement_firstChildElement),
|
|
|
|
GB_PROPERTY_READ("LastChildElement", "XmlElement", CElement_lastChildElement),
|
|
|
|
|
|
|
|
GB_METHOD("MatchXPathFilter", "b", CElement_matchXPathFilter ,"(Filter)s"),
|
|
|
|
GB_METHOD("GetChildrenByTagName", "XmlElement[]", CElement_getChildrenByTagName, "(TagName)s[(Depth)i]"),
|
|
|
|
GB_METHOD("GetChildrenByAttributeValue", "XmlElement[]", CElement_getChildrenByAttributeValue, "(Attribute)s(Value)s[(Depth)i]"),
|
|
|
|
|
|
|
|
GB_STATIC_METHOD("FromText", "XmlNode[]", CElement_fromText, "(Data)s"),
|
|
|
|
|
|
|
|
GB_END_DECLARE
|
2012-05-30 00:19:22 +02:00
|
|
|
};*/
|