[GB.XML]
* NEW: Added a new XMLNode.Deserialize() method. * OPT: Remove some old unused source files. git-svn-id: svn://localhost/gambas/trunk@5906 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
5c0a93f8a3
commit
f14bbd6097
@ -309,6 +309,24 @@ if(escapedData != STRING(data)) free(escapedData);
|
||||
|
||||
END_METHOD
|
||||
|
||||
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
|
||||
|
||||
GB_DESC CElementAttributeNodeDesc[] =
|
||||
{
|
||||
GB_DECLARE("_XmlAttrNode", sizeof(CNode)), GB_INHERITS("XmlNode"),
|
||||
@ -363,6 +381,7 @@ GB_DESC CNodeDesc[] =
|
||||
GB_PROPERTY("Name", "s", CNode_name),
|
||||
|
||||
GB_STATIC_METHOD("Serialize", "s", CNode_escapeContent, "(Data)s"),
|
||||
GB_STATIC_METHOD("Deserialize", "s", CNode_unEscapeContent, "(Data)s"),
|
||||
|
||||
GB_METHOD("NewElement", "", CNode_newElement, "(Name)s[(Value)s]"),
|
||||
GB_METHOD("NewAttribute", "", CNode_setAttribute, "(Name)s(Value)s"),
|
||||
|
@ -1,67 +0,0 @@
|
||||
#include "CWriter.h"
|
||||
|
||||
#undef THIS
|
||||
#define THIS (static_cast<Writer*>(_object))
|
||||
|
||||
inline void WriteData(wstring &data, void *ob)
|
||||
{
|
||||
GB_FUNCTION *writeFunc = new GB_FUNCTION;
|
||||
|
||||
GB.GetFunction(writeFunc, ob, "_Write", "(Data)s", "");
|
||||
string str = WStringToString(data);
|
||||
GB.Push(1, GB_T_STRING, str.c_str(), str.length());
|
||||
GB.Call(writeFunc, 1, 1);
|
||||
}
|
||||
|
||||
BEGIN_METHOD_VOID(CWriter_new)
|
||||
|
||||
|
||||
END_METHOD
|
||||
|
||||
|
||||
|
||||
BEGIN_METHOD_VOID(CWriter_free)
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_METHOD(CWriter_write, GB_STRING data)
|
||||
|
||||
std::cout << "Write !";
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_METHOD(CWriter_element, GB_STRING tagName; GB_STRING content)
|
||||
|
||||
wstring data = L"<" + STRING(tagName) + L">" + STRING(content) + L"</" + STRING(tagName) + L">";
|
||||
WriteData(data, THIS);
|
||||
|
||||
END_METHOD
|
||||
|
||||
BEGIN_PROPERTY(CWriter_stream)
|
||||
|
||||
if(READ_PROPERTY)
|
||||
{
|
||||
GB.ReturnObject(THIS->stream);
|
||||
}
|
||||
else
|
||||
{
|
||||
THIS->stream = PROP(GB_STREAM);
|
||||
}
|
||||
|
||||
END_PROPERTY
|
||||
|
||||
GB_DESC CWriterDesc[] =
|
||||
{
|
||||
GB_DECLARE("XmlWriter", sizeof(Writer)),
|
||||
|
||||
GB_METHOD("_new", "", CWriter_new, ""),
|
||||
GB_METHOD("_free", "", CWriter_free, ""),
|
||||
|
||||
GB_PROPERTY("OutputStream", "Stream", )
|
||||
|
||||
GB_METHOD("_Write", "", CWriter_write, "(Data)s"),
|
||||
|
||||
GB_METHOD("Element", "", CWriter_element, "(TagName)s[(Content)s]"),
|
||||
|
||||
GB_END_DECLARE
|
||||
};
|
@ -1,17 +0,0 @@
|
||||
#ifndef CXMLWRITER_H
|
||||
#define CXMLWRITER_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
|
||||
#ifndef CLASSES_CPP
|
||||
extern GB_DESC CWriterDesc[];
|
||||
#endif
|
||||
|
||||
class Writer : public GB_BASE
|
||||
{
|
||||
public:
|
||||
GB_STREAM *stream;
|
||||
};
|
||||
|
||||
#endif // CXMLWRITER_H
|
@ -1,50 +0,0 @@
|
||||
/***************************************************************************
|
||||
|
||||
(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.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#include "node.h"
|
||||
#include "document.h"
|
||||
#include "gbi.h"
|
||||
|
||||
void GBI::Return(Node *node)
|
||||
{
|
||||
if(!node)
|
||||
{
|
||||
GB.ReturnNull(); return;
|
||||
}
|
||||
if(!node->GBObject)
|
||||
{
|
||||
node->NewGBObject();
|
||||
}
|
||||
GB.ReturnObject(node->GBObject);
|
||||
}
|
||||
|
||||
void GBI::Return(Document *doc)
|
||||
{
|
||||
if(!doc)
|
||||
{
|
||||
GB.ReturnNull(); return;
|
||||
}
|
||||
if(!doc->GBObject)
|
||||
{
|
||||
doc->NewGBObject();
|
||||
}
|
||||
GB.ReturnObject(doc->GBObject);
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
/***************************************************************************
|
||||
|
||||
(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.
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef GBI_H
|
||||
#define GBI_H
|
||||
|
||||
#include "main.h"
|
||||
|
||||
class Node;
|
||||
class Document;
|
||||
|
||||
namespace GBI
|
||||
{
|
||||
template<typename T>
|
||||
inline T* New(const char *className)
|
||||
{
|
||||
return reinterpret_cast<T*>(GB.New(GB.FindClass(className), 0, 0));
|
||||
}
|
||||
|
||||
void Return(Node *node);
|
||||
void Return(Document *doc);
|
||||
}
|
||||
|
||||
#endif // GBI_H
|
Loading…
x
Reference in New Issue
Block a user