¿Existe una biblioteca XML en la serialización de Boost?

Inicio¿Existe una biblioteca XML en la serialización de Boost?
¿Existe una biblioteca XML en la serialización de Boost?

Is there an XML library in Boost serialization?

Boost does not have an XML library. Boost Serialization doesn’t read general XML (like) documents. It reads XML archives only. Meaning, you don’t control the XML. That all said, you can simply extend the class with another Data member, and it would accidentally result in a very similar XML archive. Perhaps this is good enough for you:

Q. Is it possible to serialize data to XML?

Luckily there is a serialization library available from Boost and it makes that pretty easy for us. You don’t even have to modify your existing data structures to write them out as XML: the library is non-invasive. Let’s say I want to serialize a list of people to a file, and read it back later. My data structures would be defined like this:

Q. How to control the serialization of an object?

Controlling XML Serialization Using Attributes. Attributes can be used to control the XML serialization of an object or to create an alternate XML stream from the same set of classes.

Q. How does the xmlarrayitemattribute control the serialization?

The XmlArrayItemAttribute, on the other hand, controls how the items contained in the array are serialized. Note that the attribute is applied to the field returning the array. The resulting XML might resemble the following. Another use of the XmlArrayItemAttribute is to allow the serialization of derived classes.

Q. How to invoke the serialization library in Java?

The serialization library invokes the following code to save or load a class instance to/from and archive. template inline void serialize ( Archive & ar, T & t, const unsigned int file_version ) { // invoke member function for class T t.serialize (ar, file_version); }

Q. Is there a default for serialization of classes?

There is no default. An attempt to serialize a class/struct for which no serialization has been explicitly specified will result in a compile time error. The serialiation of a class can be specified via either a class member function or a free funcation which takes a reference to an instance of the class as an argument.

Q. Is there a serialization library for STL classes?

The serialization library contains code for serialization of all STL classes. Hence, the reformulation below will also work as one would expect. Suppose we’re satisfied with our bus_route class, build a program that uses it and ship the product.

Videos relacionados sugeridos al azar:
¿QUÉ ES XML Y PARA QUÉ SE USA?

En este vídeo nuestro profesor Manuel Alconchel nos va a explicar qué es un fichero XML y para qué se utiliza. ►► Suscríbete para seguir ampliando tus conoci…

No Comments

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *