diff --git a/gb.xml/src/CNode.cpp b/gb.xml/src/CNode.cpp index 451dd8f02..1e5fb1c51 100644 --- a/gb.xml/src/CNode.cpp +++ b/gb.xml/src/CNode.cpp @@ -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"), diff --git a/gb.xml/src/CWriter.cpp b/gb.xml/src/CWriter.cpp deleted file mode 100644 index 56d92fe67..000000000 --- a/gb.xml/src/CWriter.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "CWriter.h" - -#undef THIS -#define THIS (static_cast(_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""; -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 -}; diff --git a/gb.xml/src/CWriter.h b/gb.xml/src/CWriter.h deleted file mode 100644 index 71b75f659..000000000 --- a/gb.xml/src/CWriter.h +++ /dev/null @@ -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 diff --git a/gb.xml/src/gbi.cpp b/gb.xml/src/gbi.cpp deleted file mode 100644 index e44587686..000000000 --- a/gb.xml/src/gbi.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/*************************************************************************** - - (c) 2012 Adrien Prokopowicz - - 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); -} diff --git a/gb.xml/src/gbi.h b/gb.xml/src/gbi.h deleted file mode 100644 index 4ad186fed..000000000 --- a/gb.xml/src/gbi.h +++ /dev/null @@ -1,42 +0,0 @@ -/*************************************************************************** - - (c) 2012 Adrien Prokopowicz - - 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 - inline T* New(const char *className) - { - return reinterpret_cast(GB.New(GB.FindClass(className), 0, 0)); - } - - void Return(Node *node); - void Return(Document *doc); -} - -#endif // GBI_H