Bennu Game Development

Foros en Español => Extensiones => Topic started by: Elelegido on February 25, 2009, 10:07:18 PM

Title: TinyXML para Bennu
Post by: Elelegido on February 25, 2009, 10:07:18 PM
Pues después de comerme la cabeza un buen rato con el tema este de hacer dlls para bennu (al final tuve que olvidarme de hacerlo con el Visual Studio), conseguí lo que pretendía : Enlazar unas cuantas funciones de TinyXML para usarlo con Bennu.

Para quien no lo sepa, TinyXML es un Parser XML. Un parser es un analizador sintáctico, y XML es un formato de definición de estructuras de datos mediante etiquetas (base de XHTML por ejemplo). Esto significa, que con TinyXML se puede leer información de las webs o montar una sintaxis similar si se está familiarizado con ese tipo de entornos. El objetivo final, es guardar los datos de las aplicaciones de una manera mucho más amena que en forma de binarios, teniendo así una comodidad absoluta para que pueda modificarlo a pelo hasta tu perro.

Al lío, aquí está la dll para windows : http://www.megaupload.com/?d=DKV9BJZ9

Y aquí os dejo con un ejemplo sencillo, para que comprobeis el funcionamiento:

[code language="bennu"]
import "mod_say";
import "mod_string";
import "mod_tinyxml";

PRIVATE   
        elementVar1;
   elementVar2;
   
   string cadena;
END

BEGIN
   // INICIO TEST
   
   elementVar1 = XML_Open("demo.xml",XML_WRITE); // -1 = Error
   
   elementVar1 = XML_NewElement(elementVar1,"Hijo"); // 0 = Error
   
   elementVar2=XML_NewElement(elementVar1,"Nieto1");
   XML_NewElement(elementVar1,"Nieto2");
   XML_NewElement(elementVar1,"Nieto3");
   XML_NewElement(elementVar1,"Nieto4");
   
   XML_Set_Attribute(elementVar2,"nombre","Pablo"); // -1 = Error. 0 = Exito
   XML_Set_Attribute(elementVar2,"edad",15);
   
        // En las 3 siguientes: -1 = Error. 0 = Exito
   XML_Save(elementVar1); // elementVar2 causaría el mismo efecto. El archivo 'demo.xml' ha sido creado en tu directorio.
        XML_DelElement(elementVar2); // Elimina el nodo. No se verá reflejado en 'demo.xml' porque se ha hecho después.
   XML_Close(elementVar1); // elementVar2 no causaría el mismo efecto porque apunta a un nodo que acaba de ser eliminado.
   
   // A partir de ahora, el documento está cerrado, por lo que las variables elementVar1 y elementVar2 sólo contienen basura.
   
   elementVar1 = 0;
   elementVar2 = -1;
   
   elementVar1 = XML_Open("demo.xml",XML_READ);
   
   say(XML_Value(elementVar1)); // "" = Error . Lee la etiqueta.
   
   elementVar1 = XML_FirstChild(elementVar1); // 0 = Error. Desciente al siguiente nivel, obteniendo al primer nodo hijo.
        // También está 'XML_FirstChildNamed(element,value)', hace lo mismo pero sólo considera las etiquetas que coincidan con 'value'.
        // Otra función similar es XML_ParentNode(element) : Sirve para subir un nivel en lugar de descender.
       
   
   While (elementVar1!=0):
      cadena = XML_Attribute(elementVar1,"nombre"); // "" = Error
      say(XML_Value(elementVar1));
      if (cadena != ""):
         say("Nombre: "+cadena);
      END
      XML_AttributeI(elementVar1,"edad",&elementVar2); // Si falla, no cambia elementVar2.
      if (elementVar2 != -1):
         say("Edad: "+elementVar2);
         elementVar2 = -1;
      END
      elementVar1 = XML_NextElement(elementVar1); // Va iterando entre los elementos del mismo nivel en orden de arriba a abajo.
                 // Cuando llega al final u ocurre un error, retorna 0.
                 // También existe XML_PreviousElement(element) para la misma tarea en orden inverso.
   END   
   
   XML_Close(elementVar1); // ahora sólo nos vale con elementVar1
   
   // FIN TEST

END[/code]

A continuación dejo las fuentes :

mod_tinyxml.h
[code language="bennu"]#ifndef MOD_TINYXML_H
#define MOD_TINYXML_H

extern "C" const char * string_get (int code) ;
extern "C" int string_discard (int code) ;
extern "C" int string_new (const char* cad) ;
extern "C" int string_use (int  code);

#endif[/code]

mod_tinyxml.c
[code language="bennu"]#include "bgddl.h"

#include <stdlib.h>
#include <stdio.h>

#include "tinyxml.h"
#include "tinystr.h"

#include "mod_tinyxml.h"

/* ----------------------------------------------------------------- */
/*
Prototipos de las funciones de ejemplo
                   */

static int openXMLDocument(INSTANCE * my,int * params);
static int closeXMLDocument(INSTANCE * my,int * params);
static int saveXMLDocument(INSTANCE * my,int * params);
static int firstXMLChild(INSTANCE * my,int * params);
static int firstXMLChildElement(INSTANCE * my,int * params);
static int getParent(INSTANCE * my,int * params);
static int getAttribute(INSTANCE * my,int * params);
static int getValue(INSTANCE * my,int * params);
static int nextXMLElement(INSTANCE * my,int * params);
static int previousXMLElement(INSTANCE * my,int * params);
static int XMLQueryIntAttribute(INSTANCE * my,int * params);
static int XMLQueryFloatAttribute(INSTANCE * my,int * params);
static int XMLQueryDoubleAttribute(INSTANCE * my,int * params);
static int newXMLElement(INSTANCE * my,int * params);
static int deleteXMLElement(INSTANCE * my,int * params);
static int setAttributeXMLElement(INSTANCE * my,int * params);
static int setAttributeIntXMLElement(INSTANCE * my,int * params);


/* ----------------------------------------------------------------- */
/* Definicion de constantes (usada en tiempo de compilacion)         */

DLLEXPORT DLCONSTANT  __bgdexport(mod_tinyxml,constants_def)[] = {

    { "XML_READ", TYPE_DWORD, 0  },
    { "XML_WRITE"  , TYPE_DWORD, 1  },
    { NULL, TYPE_DWORD, 0 }
} ;

#define FENIX_export(a,b,c,d)  {a,b,c,(void*)d}

DLLEXPORT DLSYSFUNCS  __bgdexport(mod_tinyxml,functions_exports)[] = {
                    FENIX_export( "XML_OPEN", "SI", TYPE_DWORD, openXMLDocument ),
                    FENIX_export( "XML_CLOSE", "I", TYPE_INT, closeXMLDocument ),
                    FENIX_export( "XML_SAVE", "I", TYPE_INT, saveXMLDocument ),
                    FENIX_export( "XML_ATTRIBUTE", "IS", TYPE_STRING, getAttribute ),
                    FENIX_export( "XML_ATTRIBUTEI", "ISP", TYPE_INT, XMLQueryIntAttribute ),
                    FENIX_export( "XML_ATTRIBUTEF", "ISP", TYPE_INT, XMLQueryFloatAttribute ),
                    FENIX_export( "XML_ATTRIBUTED", "ISP", TYPE_INT, XMLQueryDoubleAttribute ),
                    FENIX_export( "XML_VALUE", "I", TYPE_STRING, getValue ),
                    FENIX_export( "XML_NEXTELEMENT", "I", TYPE_DWORD, nextXMLElement ),
                    FENIX_export( "XML_PREVIOUSELEMENT", "I", TYPE_DWORD, previousXMLElement ),
                    FENIX_export( "XML_FIRSTCHILD", "I", TYPE_DWORD, firstXMLChild ),
                    FENIX_export( "XML_FIRSTCHILDNAMED", "IS", TYPE_DWORD, firstXMLChildElement ),
                    FENIX_export( "XML_PARENTNODE", "I", TYPE_DWORD, getParent ),
                    FENIX_export( "XML_NEWELEMENT", "IS", TYPE_DWORD, newXMLElement ),
                    FENIX_export( "XML_DELELEMENT", "I", TYPE_DWORD, deleteXMLElement ),
                    FENIX_export( "XML_SET_ATTRIBUTE", "ISS", TYPE_DWORD, setAttributeXMLElement ),
                    FENIX_export( "XML_SET_ATTRIBUTE", "ISI", TYPE_DWORD, setAttributeIntXMLElement ),
                          { 0            , 0     , 0         , 0              }
                          };

/* ----------------------------------------------------------------- */
/* Funciones de inicializacion del modulo/plugin                     */

DLLEXPORT void __bgdexport( mod_tinyxml, module_initialize )()
{

}


DLLEXPORT void __bgdexport( mod_tinyxml, module_finalize )()
{

}

static int openXMLDocument(INSTANCE * my,int * params) {
   TiXmlDocument* xmldoc;
   int i = params[1];
   
   if (i == 1)   {
      xmldoc = new TiXmlDocument ();
      TiXmlElement* header = new TiXmlElement("XMLDocumentName");
      header->SetAttribute("name",string_get(params[0]));
      xmldoc->LinkEndChild( header );
   }   else
      xmldoc = new TiXmlDocument (string_get(params[0]));

   string_discard(params[0]);
   TiXmlNode* n;

   if (i == 1)   {
      n = (TiXmlNode*) xmldoc;
   }   else   {
      if (!xmldoc->LoadFile()) {
         delete xmldoc;
         return -1;
      }

      n = xmldoc->FirstChild();

      if ( n == NULL ) {
         delete xmldoc;
         return -1;
      }
   }

   return ((int)n);
}

static int closeXMLDocument(INSTANCE * my,int * params) {
   TiXmlNode* n = reinterpret_cast<TiXmlNode*>(params[0]);

   if (n == NULL)
      return -1;

   TiXmlDocument* xmldoc = n->GetDocument();

   if (xmldoc == NULL)
      return -1;

   delete xmldoc;
   return 0;
}

static int saveXMLDocument(INSTANCE * my,int * params) {
   TiXmlNode* n = reinterpret_cast<TiXmlNode*>(params[0]);

   if (n == NULL)
      return -1;

   TiXmlDocument* xmldoc = n->GetDocument();

   if (xmldoc == NULL)
      return -1;

   TiXmlElement* e = xmldoc->FirstChildElement("XMLDocumentName");

   if ( e == NULL ||  e->Attribute("name") == NULL)
      return -1;

   char c[1024];
   sprintf(c,"%s",e->Attribute("name"));

   xmldoc->RemoveChild(e);

   if (xmldoc->SaveFile(c)) {
      TiXmlElement* header = new TiXmlElement("XMLDocumentName");
      header->SetAttribute("name",c);
      xmldoc->LinkEndChild( header );
      return 0;
   } else
      return -1;
}

static int firstXMLChild(INSTANCE * my,int * params) {

    TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);

   if (n == NULL)
      return 0;

   n = (TiXmlNode*) n->FirstChildElement();

   return ((int)n);
}

static int firstXMLChildElement(INSTANCE * my,int * params) {
    TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);
   const char* name = string_get(params[1]);
   string_discard(params[1]);

   if (n == NULL)
      return 0;

   n = (TiXmlNode*) n->FirstChildElement(name);

   return ((int)n);
}

int stringError(const char* s) {
   char b[32];
//   sprintf(b,"Error in %s",s);
   sprintf(b,"");
   int ret = string_new(b);

   string_use(ret);

   return (ret);
}

static int getAttribute(INSTANCE * my,int * params) {
   TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);
   const char* name = string_get(params[1]);
   string_discard(params[1]);

   if (n == NULL)
      return stringError("Attribute 1");

   TiXmlElement* e = n->ToElement();

   if (e == NULL)
      return stringError("Attribute 2");

   const char* atrib = e->Attribute(name);

   if (atrib == NULL)
      return stringError("Attribute 3");

   int ret = string_new(atrib);

   string_use(ret);

   return (ret);
}

static int XMLQueryIntAttribute(INSTANCE * my,int * params) {
   TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);
   const char* name = string_get(params[1]);
   string_discard(params[1]);
   int* i = (int*) params[2];

   if (n == NULL || i == NULL)
      return -1;

   TiXmlElement* e = n->ToElement();

   if (e == NULL)
      return -1;

   e->QueryIntAttribute(name,i);

   return 0;
}

static int XMLQueryFloatAttribute(INSTANCE * my,int * params) {
   TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);
   const char* name = string_get(params[1]);
   string_discard(params[1]);
   float* i = (float*) params[2];

   if (n == NULL || i == NULL)
      return -1;

   TiXmlElement* e = n->ToElement();

   if (e == NULL)
      return -1;

   e->QueryFloatAttribute(name,i);

   return 0;
}

static int XMLQueryDoubleAttribute(INSTANCE * my,int * params) {
   TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);
   const char* name = string_get(params[1]);
   string_discard(params[1]);
   double* i = (double*) params[2];

   if (n == NULL || i == NULL)
      return -1;

   TiXmlElement* e = n->ToElement();

   if (e == NULL)
      return -1;

   e->QueryDoubleAttribute(name,i);

   return 0;
}

static int getValue(INSTANCE * my,int * params) {
   TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);

   if (n == NULL)
      return stringError("Value 1");

   const char* value = n->Value();

   if (value == NULL)
      return stringError("Value 2");

   int ret = string_new(value);

   string_use(ret);

   return (ret);
}

static int nextXMLElement(INSTANCE * my,int * params) {
   TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);

   if (n == NULL)
      return 0;

   n = (TiXmlNode*) n->NextSiblingElement();

   return ((int)n);

}

static int previousXMLElement(INSTANCE * my,int * params) {
   TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);

   if (n == NULL)
      return 0;

   for (; n ; n = n->PreviousSibling())
      if (n->ToElement())
         return ((int)n);

   return 0;

}

static int getParent(INSTANCE * my,int * params) {
    TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);

   if (n == NULL)
      return 0;

   n = (TiXmlNode*) n->Parent();

   if (n!= NULL && n->ToElement())
      return ((int)n);
   else
      return 0;
}

static int newXMLElement(INSTANCE * my,int * params) {
   TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);
   const char* name = string_get(params[1]);
   string_discard(params[1]);

   if (n == NULL)
      return 0;

   TiXmlElement* newE = new TiXmlElement(name);

   n->LinkEndChild(newE);

   return ((int)newE);
}

static int deleteXMLElement(INSTANCE * my,int * params) {
   TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);

   if (n == NULL)
      return -1;

   TiXmlNode* nParent = (TiXmlNode*) n->Parent();

   if (nParent == NULL)
      return -1;

   nParent->RemoveChild(n);

   return 0;
}

static int setAttributeXMLElement(INSTANCE * my,int * params) {
   TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);
   const char* name = string_get(params[1]);
   string_discard(params[1]);
   const char* value = string_get(params[2]);
   string_discard(params[2]);

   if (n == NULL || !n->ToElement())
      return -1;

   n->ToElement()->SetAttribute(name,value);

   return 0;
}

static int setAttributeIntXMLElement(INSTANCE * my,int * params) {
   TiXmlNode* n =  reinterpret_cast<TiXmlNode*>(params[0]);
   const char* name = string_get(params[1]);
   string_discard(params[1]);

   int value = params[2];

   if (n == NULL || !n->ToElement())
      return -1;

   n->ToElement()->SetAttribute(name,value);

   return 0;
}[/code]


Si hay algún error o alguna sugerencia, lo modificaré, pero la verdad es que en principio no tengo intención de seguir entreteniéndome más con esto. Tal como está me sirve al 100%, aunque es cierto que TinyXML es mucho más completo. De todos modos, aquí estoy para lo que sea. Espero que resulte útil a más de uno.

Se me olvidaba. Aquí el resultado de 'demo.xml':
[code language="bennu"]<Hijo>
    <Nieto1 nombre="Pablo" edad="15" />
    <Nieto2 />
    <Nieto3 />
    <Nieto4 />
</Hijo>[/code]
Title: Re: TinyXML para Bennu
Post by: osk on February 25, 2009, 11:25:04 PM
ESPECTACULAAAAARRRRRRRRRRR!!!!!!!!!!!!!!!!
Muchísimas gracias!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Title: Re: TinyXML para Bennu
Post by: SplinterGU on February 25, 2009, 11:32:17 PM
je! si conozco la TinyXML...
lo que mas me gusta es que cada uno monta su estilo de armar las dlls y codificarlas...
muy bueno, felicitaciones! 1 karma!
Title: Re: TinyXML para Bennu
Post by: Elelegido on February 26, 2009, 01:02:05 AM
Gracias por el interés. He corregido un fallo de la función de salvar que hacía que no funcionase bien a partir de la segunda vez que intentabas salvar un mismo XML sin cerrarlo y abrirlo de nuevo. Está actualizado en el post principal.
Title: Re: TinyXML para Bennu
Post by: Prg on February 26, 2009, 04:36:35 PM
mmm
debo probarlo
gracias :)
un karma + para tí
Title: Re: TinyXML para Bennu
Post by: josebita on February 26, 2009, 07:29:16 PM
¡Ey, qué chula!
La verdad es que llevaba tiempo pensando en que sería genial hacer algo así.
Felicidades.
Title: Re: TinyXML para Bennu
Post by: osk on June 19, 2009, 04:25:19 PM
Acabo de rescatar esta librería del olvido...
¿Qué tal ponerla en la web/wiki también?
Title: Re: TinyXML para Bennu
Post by: SplinterGU on June 19, 2009, 04:27:13 PM
seria bueno que alguien haga un megapost con los contrib que vamos teniendo y vaya manteniendo ese mega post... el post deberia solo tener el link al tema original... y deberia estar cerrado a posts.

quien se quiere encargar?
Title: Re: TinyXML para Bennu
Post by: osk on June 30, 2009, 10:26:16 PM
Hola.
He intentado compilar esta librería para Windows y para Linux. En ambos casos he fracasado por unos errores de compilación que en ambos casos afectan al archivo tinystr.h de la propia TinyXML, pero que son diferentes en los dos casos.

En Linux me sale:

||=== ssss, Debug ===|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|67|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlString'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|269|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|274|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|279|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|280|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|281|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|282|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|284|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|285|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|286|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|287|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|289|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|290|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|291|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'operator'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinystr.h|298|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlOutStream'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|85|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlDocument'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|86|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlElement'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|87|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlComment'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|88|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlUnknown'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|89|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlAttribute'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|90|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlText'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|91|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlDeclaration'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|92|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlParsingData'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|103|error: expected specifier-qualifier-list before 'TiXmlCursor'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|129|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlVisitor'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|171|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TIXML_DEFAULT_ENCODING'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|195|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlBase'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|424|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlNode'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|780|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlAttribute'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|904|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlAttributeSet'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|944|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlElement'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|1154|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlComment'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|1204|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlText'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|1277|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlDeclaration'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|1346|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlUnknown'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|1385|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlDocument'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|1634|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlHandle'|
/home/q2dg/Desktop/tinyxml/tinyxml/tinyxml.h|1733|error: expected '=', ',', ';', 'asm' or '__attribute__' before 'TiXmlPrinter'|
/home/q2dg/Desktop/tinyxml/mod_tinyxml.h|4|error: expected identifier or '(' before string constant|
/home/q2dg/Desktop/tinyxml/mod_tinyxml.h|5|error: expected identifier or '(' before string constant|
/home/q2dg/Desktop/tinyxml/mod_tinyxml.h|6|error: expected identifier or '(' before string constant|
/home/q2dg/Desktop/tinyxml/mod_tinyxml.h|7|error: expected identifier or '(' before string constant|
/home/q2dg/Desktop/ssss/main.c||In function 'openXMLDocument':|
/home/q2dg/Desktop/ssss/main.c|83|error: 'TiXmlDocument' undeclared (first use in this function)|
/home/q2dg/Desktop/ssss/main.c|83|error: (Each undeclared identifier is reported only once|
/home/q2dg/Desktop/ssss/main.c|83|error: for each function it appears in.)|
/home/q2dg/Desktop/ssss/main.c|83|error: 'xmldoc' undeclared (first use in this function)|
/home/q2dg/Desktop/ssss/main.c|87|error: 'new' undeclared (first use in this function)|
/home/q2dg/Desktop/ssss/main.c|87|error: expected ';' before 'TiXmlDocument'|
/home/q2dg/Desktop/ssss/main.c|88|error: 'TiXmlElement' undeclared (first use in this function)|
/home/q2dg/Desktop/ssss/main.c|88|error: 'header' undeclared (first use in this function)|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 0 warnings ===|


En Windows me sale:

||=== sss, Debug ===|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|67|error: syntax error before "TiXmlString"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|68|error: syntax error before '{' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|74|error: syntax error before "npos"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|74|warning: type defaults to `int' in declaration of `npos'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|74|warning: data definition has no type or storage class|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|78|error: syntax error before ':' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|83|warning: type defaults to `int' in declaration of `TiXmlString'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|83|error: syntax error before '&' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|86|error: syntax error before '(' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|86|warning: type defaults to `int' in declaration of `memcpy'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|86|error: conflicting types for 'memcpy'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|86|error: conflicting types for 'memcpy'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|86|warning: type defaults to `int' in declaration of `copy'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|86|error: syntax error before '.' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|90|error: syntax error before ':' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|93|error: syntax error before '(' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|93|warning: type defaults to `int' in declaration of `memcpy'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|93|warning: type defaults to `int' in declaration of `copy'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|93|warning: type defaults to `int' in declaration of `length'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|93|error: syntax error before ')' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|97|error: syntax error before "size_type"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|100|error: syntax error before '(' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|100|warning: type defaults to `int' in declaration of `memcpy'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|100|warning: type defaults to `int' in declaration of `str'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|100|warning: type defaults to `int' in declaration of `len'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|100|error: syntax error before ')' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h||In function `c_str':|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|142|error: syntax error before '{' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|211|error: syntax error before '&' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|229|error: syntax error before '}' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|231|error: syntax error before "sz"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|241|warning: type defaults to `int' in declaration of `size_type'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|241|error: syntax error before "intsNeeded"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|264|warning: type defaults to `int' in declaration of `Rep'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|264|error: storage class specified for parameter `Rep'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|264|error: syntax error before "nullrep_"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|269|warning: type defaults to `int' in declaration of `bool'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|269|error: syntax error before "operator"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|94|error: parameter `TIXML_MAJOR_VERSION' is initialized|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|95|error: parameter `TIXML_MINOR_VERSION' is initialized|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|96|error: parameter `TIXML_PATCH_VERSION' is initialized|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|103|error: syntax error before "TiXmlCursor"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|103|warning: no semicolon at end of struct or union|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|108|error: syntax error before '}' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|160|warning: enum defined inside parms|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|160|warning: empty declaration|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|169|warning: enum defined inside parms|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|169|warning: empty declaration|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|171|warning: type defaults to `int' in declaration of `TiXmlEncoding'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|171|error: syntax error before "TIXML_DEFAULT_ENCODING"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|222|error: syntax error before "condense"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|222|error: storage class specified for parameter `SetCondenseWhiteSpace'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|263|warning: type defaults to `int' in declaration of `TiXmlString'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|263|error: syntax error before '&' token|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|263|error: storage class specified for parameter `EncodeString'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|286|warning: enum defined inside parms|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|286|warning: empty declaration|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|288|error: syntax error before "protected"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|291|warning: type defaults to `int' in declaration of `bool'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|291|error: storage class specified for parameter `bool'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|291|error: redefinition of parameter 'bool'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinystr.h|269|error: previous definition of 'bool' was here|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|291|error: syntax error before "IsWhiteSpace"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|317|error: syntax error before "TiXmlString"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|321|error: storage class specified for parameter `ReadText'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|324|error: syntax error before "TiXmlEncoding"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|324|error: storage class specified for parameter `GetEntity'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|328|error: syntax error before "TiXmlEncoding"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|329|error: storage class specified for parameter `GetChar'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|372|error: storage class specified for parameter `errorString'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|374|error: syntax error before "TiXmlCursor"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|381|error: syntax error before "TiXmlEncoding"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|381|error: storage class specified for parameter `IsAlpha'|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|382|error: syntax error before "TiXmlEncoding"|
C:\Documents and Settings\pepe\Escritorio\tinyxml\tinyxml\tinyxml.h|382|error: storage class specified for parameter `IsAlphaNum'|
||More errors follow but not being shown.|
||Edit the max errors limit in compiler options...|
||=== Build finished: 50 errors, 24 warnings ===|


No tengo ni idea de lo que me está diciendo, pero supongo yo que tendrá algo que ver que TinyXML está escrita en C++ y no en C. ¿Qué opción del compilador Gnu Gcc tengo que usar para que se tenga esto en cuenta, si es que es esto el problema? Estoy usando CodeBlocks con MinGw.

Graaaaciaaas!!!
Title: Re: TinyXML para Bennu
Post by: osk on July 03, 2009, 07:44:12 PM
Hola. Estoy intentando compilar la librería TinyXML original a partir de su código fuente, para posteriormente compilar sobre ella el módulo de Bennu sobre TinyXML de Elelegido, primero para aprender y luego para portarla a Linux.

Lo estoy haciendo con Codeblocks y Windows (mediante MinGw -gnu gcc compiler-). Pero algo debo hacer mal porque un código C++ tan simple del archivo tinystr.h (el error me salta cuando quiero compilar tinyxml.cpp) como éste:

class TiXmlString
{
  public :
     typedef size_t size_type;
   static const size_type npos; // = -1;
   TiXmlString () : rep_(&nullrep_)
   {
   }
        ....
        ....

ya me da error en la primera línea, en la segunda y en la quinta así:

error: syntax error before "TiXmlString"|
error: syntax error before '{' token|
error: syntax error before "npos"|

Estoy convencido de que es un problema entre C y C++...pero no sé qué es.
¿Alguien me puede echar una mano?
Graaaaaaaaacias!!
Title: Re: TinyXML para Bennu
Post by: Elelegido on July 22, 2009, 10:50:14 PM
Si, debe ser eso. Estás usando g++ en vez de gcc?

Siento no haber contestado antes :(
Title: Re: TinyXML para Bennu
Post by: osk on July 22, 2009, 10:59:11 PM
Hola!
Estoy usando gcc.
Gracias!
Title: Re: TinyXML para Bennu
Post by: Elelegido on September 22, 2009, 02:07:31 AM
Quote from: osk on July 22, 2009, 10:59:11 PM
Hola!
Estoy usando gcc.
Gracias!

Perdona por no aclarártelo antes. Pero para compilar C++ es necesario usar g++. Espero que mi pregunta te llevase a pensar eso, y que no hayas tenido que esperar 2 meses para saberlo xD.
Title: Re: TinyXML para Bennu
Post by: panreyes on November 24, 2009, 11:45:52 PM
Holas,
Acabo de intentar probarla con la actual WIP de Bennu y no funciona.
¿Es necesario recompilarla o qué me puede fallar?
Title: Re: TinyXML para Bennu
Post by: osk on November 25, 2009, 12:28:48 AM
Yo no he podido con ella
Title: Re: TinyXML para Bennu
Post by: panreyes on November 26, 2009, 01:08:24 PM
Le he mandado un mail a ver si puede recompilarla él mismo :)
La del BennuPack tampoco funciona.
Title: Re: TinyXML para Bennu
Post by: l1nk3rn3l on November 26, 2009, 04:50:00 PM
ya la recompilare y las demas
Title: Re: TinyXML para Bennu
Post by: Elelegido on November 29, 2009, 03:42:37 PM
Quote from: l1nk3rn3l on November 26, 2009, 04:50:00 PM
ya la recompilare y las demas

Entonces, ¿no hace falta que me ponga a ello? Me harías un favor ya que tengo todo el entorno desmontado y lo tengo tan oxidado que me va a llevar un tiempo que por el momento no me sobra. Si es necesario, me pongo con ello a partir del martes..
Title: Re: TinyXML para Bennu
Post by: grisendo on April 08, 2010, 07:57:15 PM
¿Alguna novedad con lo de compilarlo para Linux? Sobre esta librería para BennuGD no he conseguido encontrar nada más que el código que sale en este post y la DLL.

Yo necesitaría:

1. Leer XML desde un string, no sólo desde un fichero (no sé si mod_tinyxml es capaz de hacerlo ya, o ni siquiera si tinyxml es capaz).
2. Compilarla para poder usarla en GNU/Linux.

Es por evitar duplicación de esfuerzos compilándola yo, y por si a Elelegido le apetece hacer él mismo lo de los strings y no chafarle el trabajo :)
Title: Re: TinyXML para Bennu
Post by: Rein (K´)ah Al-Ghul on April 08, 2010, 08:36:23 PM
Quote from: grisendo on April 08, 2010, 07:57:15 PM
1. Leer XML desde un string, no sólo desde un fichero (no sé si mod_tinyxml es capaz de hacerlo ya, o ni siquiera si tinyxml es capaz).

te refieres a algo asi:

string stringXML = <texto>inserte algo aqui</texto>
...
texto = funcionQueExtraeXMLDeString(stringXML)
// entonces texto = "inserte algo aqui";
Title: Re: TinyXML para Bennu
Post by: grisendo on April 08, 2010, 08:52:05 PM
Creo que sí es exactamente eso. Pongo un ejemplo por si acaso:

[code language="bennu"]string stringXML = "<gente><persona id='0' name='pepe'><habilidades>...</habilidades>...</persona><persona>...</gente>";
tinyXML = XML_Open(stringXML); // En lugar de un fichero, cargar el string

genteXML = XML_NewElement(tinyXML,"gente");
personaXML = XML_NewElement(genteXML,"persona");
...[/code]

Es lo que no tengo claro, si el propio tinyxml original tiene algo similar. Entonces sería fácil adaptarlo.

PD: Joder, me acabo de dar cuenta de que soy un enfermo, acabo de modificar este post para poner un punto y coma que le faltaba al código xDDDD
Title: Re: TinyXML para Bennu
Post by: Rein (K´)ah Al-Ghul on April 10, 2010, 05:17:25 PM
entonces ya no hay problema con eso??
Title: Re: TinyXML para Bennu
Post by: grisendo on April 10, 2010, 06:44:36 PM
Todavía haylo, no he dicho en ningún momento lo contrario :D

Bueno, en realidad no es un problema, es un aumento de prestaciones
Title: Re: TinyXML para Bennu
Post by: Rein (K´)ah Al-Ghul on April 23, 2010, 08:14:12 PM
si la DLL al parsear no contempla las tabulaciones, podes guardar ese texto en un archivo de texto con extension xml y despues usarla la libreria
Title: Re:TinyXML para Bennu
Post by: JaViS on August 21, 2012, 06:46:21 PM
solo por curiosidad, funciona esta lib con la ultima version de Bennu?


Un abrazo
Title: Re:TinyXML para Bennu
Post by: KeoH on August 21, 2012, 07:13:22 PM
Quote from: JaViS on August 21, 2012, 06:46:21 PM
solo por curiosidad, funciona esta lib con la ultima version de Bennu?


Un abrazo


Perfectamente
Title: Re:TinyXML para Bennu
Post by: emov2k4 on October 11, 2013, 05:23:45 PM
Alguien tiene por ahí la librería para que la vuelva a subir... gracias !
Title: Re:TinyXML para Bennu
Post by: Fourty-1 on November 06, 2013, 03:15:03 AM
En primer lugar, por favor, quiero pedir disculpas por mi mal español. Tomé francés en la escuela secundaria, pero ni siquiera eso me escapa. XD Mi lengua materna es el Inglés.

Tengo una dll para TinyXML pero nunca me dieron el código de ejemplo proporcionado para compilar. Otro código que he compila y ejecuta bien en mi equipo. Si trato de importar el módulo, la compilación no puede encontrar bgdrtm.dll, que no debería ser un problema, ya que considera que es lo contrario. También da un error sobre un token. Tengo el dll resubido a mediafire para su descarga. No sé si me falta algún archivo extra de la descarga original embargo. http://www.mediafire.com/download/c5a1rkd6e7xe9ot/mod_tinyxml.dll
Title: Re:TinyXML para Bennu
Post by: osk on November 07, 2013, 04:33:35 PM
La verdad es que esta librería nunca ha ido bien... :-[
Title: Re:TinyXML para Bennu
Post by: Fourty-1 on November 13, 2013, 01:23:59 AM
Ah, entiendo. Pero existe con fines de archivo.
Title: Re:TinyXML para Bennu
Post by: l1nk3rn3l on November 13, 2013, 03:28:37 AM
TINYXML is included in bennupack ..--->>  dll examples

http://bennupack.blogspot.com/
Title: Re:TinyXML para Bennu
Post by: laghengar on November 30, 2013, 04:41:11 PM
He visto que hace dos días fue tu cumpleaños. Felicidades ;).